:root {
  --brand: #1D9E75;
  --brand-dark: #085041;
  --brand-hover: #17805E;
  --mint: #E1F5EE;
  --mint-hover: #c8e9dc;
  --cream: #FFF7ED;
  --ink: #172033;
  --muted: #64748b;
  --line: #d7e6df;
  --cell: clamp(30px, 5.2vw, 48px);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #fbfdfc;
  background-image:
    radial-gradient(circle at 10% 0%, rgba(29,158,117,.11), transparent 28rem),
    radial-gradient(circle at 100% 100%, rgba(255,247,237,.9), transparent 32rem);
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.game-shell { width: min(1180px, 100%); margin: 0 auto; padding: 24px clamp(14px, 3vw, 32px) 20px; }
.game-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.eyebrow { margin: 0 0 4px; color: var(--brand); font-size: 12px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; color: var(--ink); font-size: clamp(24px, 4vw, 38px); line-height: 1.1; }
.progress { flex: 0 0 auto; min-width: 92px; padding: 10px 14px; border: 1px solid var(--mint-hover); border-radius: 16px; background: white; text-align: center; box-shadow: 0 8px 22px rgba(8,80,65,.08); }
.progress span { display: block; }
#progressText { color: var(--brand-dark); font-size: 20px; font-weight: 900; }
.progress-label { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }

.game-card { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr); overflow: hidden; border: 1px solid var(--line); border-radius: 24px; background: white; box-shadow: 0 18px 50px rgba(15,50,43,.11); }
.board-panel { min-width: 0; padding: clamp(14px, 3vw, 28px); background: linear-gradient(145deg, #fff, var(--cream)); }
.board { display: grid; justify-content: center; width: min(100%, calc(var(--columns) * var(--cell) + 16px)); margin: 0 auto; padding: 8px; border-radius: 14px; background: var(--brand-dark); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12), 0 8px 22px rgba(8,80,65,.18); }
.cell, .block { min-width: 0; aspect-ratio: 1; }
.block { background: transparent; }
.cell { position: relative; border: 1px solid #a7cabd; background: #fff; }
.cell input { display: block; min-width: 0; width: 100%; height: 100%; padding: 7px 2px 1px; border: 0; outline: 0; background: transparent; color: var(--ink); text-align: center; text-transform: uppercase; font-size: clamp(16px, 3vw, 23px); font-weight: 900; caret-color: transparent; }
.cell-number { position: absolute; z-index: 2; top: 1px; left: 2px; color: var(--brand-dark); font-size: clamp(7px, 1.3vw, 10px); font-weight: 800; pointer-events: none; }
.cell.selected { background: #bdebdc; }
.cell.active { background: #fff3bf; box-shadow: inset 0 0 0 3px #e9ad21; }
.cell.correct { background: var(--mint); }
.cell.wrong { background: #ffe0dc; animation: shake .22s linear 2; }
.cell.revealed input { color: #9a6414; }
@keyframes shake { 25% { transform: translateX(-2px); } 75% { transform: translateX(2px); } }

.active-clue { min-height: 48px; margin: 15px auto 8px; padding: 11px 14px; border-left: 4px solid var(--brand); border-radius: 0 10px 10px 0; background: var(--mint); color: var(--brand-dark); font-size: 14px; line-height: 1.55; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.button { min-height: 44px; padding: 10px 16px; border: 0; border-radius: 11px; cursor: pointer; font-weight: 800; transition: transform .15s, background .15s, box-shadow .15s; }
.button:hover { transform: translateY(-1px); }
.button:focus-visible, .clue-button:focus-visible, .dialog-link:focus-visible, .game-footer a:focus-visible { outline: 3px solid rgba(29,158,117,.35); outline-offset: 2px; }
.button-primary { background: var(--brand); color: white; box-shadow: 0 5px 14px rgba(29,158,117,.25); }
.button-primary:hover { background: var(--brand-hover); }
.button-soft { background: var(--mint); color: var(--brand-dark); }
.button-soft:hover { background: var(--mint-hover); }
.button-plain { border: 1px solid #d7dfdc; background: white; color: #53615c; }
.message { min-height: 22px; margin: 8px 0 0; color: var(--brand-dark); font-size: 13px; font-weight: 700; text-align: center; }

.clues-panel { padding: clamp(18px, 3vw, 28px); border-left: 1px solid var(--line); background: #fff; }
.clues-panel section + section { margin-top: 24px; }
.clues-panel h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; color: var(--brand-dark); font-size: 16px; }
.clues-panel h2 span { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--mint); }
.clue-list { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.clue-button { display: grid; grid-template-columns: 24px 1fr; width: 100%; padding: 8px; border: 0; border-radius: 9px; background: transparent; color: #475569; text-align: left; cursor: pointer; line-height: 1.4; }
.clue-button:hover, .clue-button.selected { background: var(--mint); color: var(--brand-dark); }
.clue-button.solved { color: #7b8c85; text-decoration: line-through; }
.clue-number { color: var(--brand); font-weight: 900; }

.game-footer { display: flex; justify-content: space-between; gap: 12px; padding: 14px 4px 0; color: var(--muted); font-size: 12px; }
.game-footer a, .dialog-link { color: var(--brand-dark); font-weight: 800; }
.dialog-backdrop { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(8,35,29,.72); backdrop-filter: blur(6px); }
.dialog-backdrop[hidden] { display: none; }
.dialog { width: min(420px, 100%); padding: 30px; border-radius: 24px; background: white; text-align: center; box-shadow: 0 24px 70px rgba(0,0,0,.3); }
.dialog h2 { margin: 0; font-size: 27px; }
.dialog p:not(.eyebrow) { color: var(--muted); line-height: 1.55; }
.win-robot { margin-bottom: 10px; font-size: 58px; }
.dialog .button { display: block; width: 100%; margin: 18px 0 12px; }
.dialog-link { display: inline-block; padding: 5px; }

@media (max-width: 820px) {
  :root { --cell: clamp(29px, 8vw, 42px); }
  .game-shell { padding-top: 14px; }
  .game-card { grid-template-columns: 1fr; border-radius: 18px; }
  .clues-panel { border-top: 1px solid var(--line); border-left: 0; }
  .game-footer { flex-direction: column; align-items: center; }
}

@media (max-width: 430px) {
  :root { --cell: min(8.2vw, 35px); }
  .game-header { align-items: flex-end; }
  .progress { min-width: 76px; padding: 7px 9px; }
  .board-panel { padding: 10px; }
  .board { width: min(100%, calc(var(--columns) * var(--cell) + 10px)); padding: 5px; }
  .active-clue { font-size: 13px; }
  .button { flex: 1 1 auto; padding-inline: 10px; font-size: 13px; }
  .clues-panel { padding: 18px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
