/* Poople — warm, papery, brown. Light and dark both first-class. */

:root {
  --bg: #faf6ef;
  --surface: #ffffff;
  --surface-2: #f2ebe0;
  --text: #2c2118;
  --muted: #7c6a58;
  --line: #ded2c1;
  --tile-line: #cdbda8;
  --accent: #8b5e34;
  --accent-ink: #ffffff;
  --good: #6aaa64;
  --detour: #b58863;
  --danger: #b5443a;
  --key: #e6dccd;
  --key-ink: #2c2118;
  --shadow: 0 10px 30px rgba(70, 48, 26, .13);
  --radius: 14px;
  /* guessing-game tiles. Amber rather than yellow: green and amber differ in
     lightness as well as hue, so they stay apart for colour-blind players. */
  --correct: #5f9c59;
  --present: #c08b2c;
  --absent: #7d6f5f;
  --tile-ink: #ffffff;
}

:root[data-theme="dark"] {
  --bg: #16130f;
  --surface: #221d17;
  --surface-2: #2c251d;
  --text: #f3ece2;
  --muted: #a79683;
  --line: #3a3126;
  --tile-line: #4a3f31;
  --accent: #c08a55;
  --accent-ink: #1b160f;
  --good: #6aaa64;
  --detour: #9c7550;
  --danger: #d9736a;
  --key: #362e24;
  --key-ink: #f3ece2;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --correct: #5f9c59;
  --present: #b8842a;
  --absent: #574a3c;
  --tile-ink: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16130f;
    --surface: #221d17;
    --surface-2: #2c251d;
    --text: #f3ece2;
    --muted: #a79683;
    --line: #3a3126;
    --tile-line: #4a3f31;
    --accent: #c08a55;
    --accent-ink: #1b160f;
    --detour: #9c7550;
    --danger: #d9736a;
    --key: #362e24;
    --key-ink: #f3ece2;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);
    --present: #b8842a;
    --absent: #574a3c;
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-rounded, "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- top bar ---------- */

.topbar {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

/* Grid children default to min-width:auto, which lets a long game name shove the
 * topbar buttons off a narrow screen. The name gives way instead; the emoji never does. */
.topbar > * { min-width: 0; }

.wordmark {
  margin: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  font-size: clamp(1.15rem, 4.8vw, 1.75rem);
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: lowercase;
  white-space: nowrap;
}

.wordmark span { margin-left: .15em; }

#wordmark-name {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

#wordmark-emoji { flex: none; }

.topbar-left,
.topbar-right {
  display: flex;
  gap: 4px;
}

.topbar-right { justify-content: flex-end; }

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
}

.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 21px; height: 21px; fill: currentColor; }

/* ---------- main ---------- */

main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 0 12px;
}

.puzzle-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 2px 6px;
  font-size: .82rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: .02em;
}

.puzzle-sep { opacity: .5; flex: none; }

/*
 * The status line has to give way before the mode button does — on a narrow phone a
 * long label (four boards report both tries and boards solved) would otherwise push
 * the button off the side of the screen.
 */
.puzzle-label,
.score-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.mode-btn {
  flex: none;
  margin-left: auto;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.mode-btn:hover { color: var(--text); border-color: var(--tile-line); }
.mode-btn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- board (shared by every game) ---------- */

.board-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  /* Centre a short board; "safe" keeps the top reachable once it overflows. */
  display: grid;
  align-content: center;
  align-content: safe center;
}

.board {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 6px 0 10px;
}

.row {
  display: flex;
  align-items: center;
  gap: 5px;
  position: relative;
}

.tile {
  width: clamp(42px, 13vw, 56px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 2px solid var(--tile-line);
  border-radius: 10px;
  background: var(--surface);
  font-size: clamp(1.25rem, 5.5vw, 1.7rem);
  font-weight: 800;
  text-transform: uppercase;
  line-height: 1;
  user-select: none;
}

/* the committed letter that differed from the row above */
.row.step .tile.changed {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.row.start .tile {
  background: var(--surface-2);
  border-color: var(--line);
}

.row.active .tile.filled { border-color: var(--accent); }
.row.active .tile.just { animation: pop .1s ease-out; }

.row.goal .tile {
  border-style: dashed;
  background: transparent;
  color: var(--muted);
  opacity: .55;
}

.row.solved-goal .tile {
  border-style: solid;
  opacity: 1;
  background: var(--good);
  border-color: var(--good);
  color: #fff;
}

.row-tag {
  position: absolute;
  left: calc(100% + 10px);
  font-size: .65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  white-space: nowrap;
}

.row-tag.hint { color: var(--accent); }

.ladder-gap {
  width: 2px;
  height: 12px;
  border-radius: 2px;
  background: var(--line);
}

/* ---------- wordle ---------- */

/* Five across instead of four, so the tiles give up a little width. */
.board.wordle .tile { width: clamp(38px, 12vw, 54px); }

.tile.correct,
.tile.present,
.tile.absent {
  color: var(--tile-ink);
  border-color: transparent;
}

.tile.correct { background: var(--correct); }
.tile.present { background: var(--present); }
.tile.absent { background: var(--absent); }

.row.empty .tile { opacity: .55; }

/*
 * The scored row flips a tile at a time. `backwards` fill means a tile still
 * waiting its turn shows the 0% keyframe — uncoloured — so the answer arrives
 * with the flip rather than before it. app.js sets the per-tile delay.
 */
.row.revealing .tile {
  animation: flip .26s ease-in-out backwards;
}

@keyframes flip {
  0% {
    transform: rotateX(0deg);
    background: var(--surface);
    border-color: var(--tile-line);
    color: var(--text);
  }
  49.9% {
    transform: rotateX(-90deg);
    background: var(--surface);
    border-color: var(--tile-line);
    color: var(--text);
  }
  50% { transform: rotateX(-90deg); }
  100% { transform: rotateX(0deg); }
}

.key.correct { background: var(--correct); color: var(--tile-ink); }
.key.present { background: var(--present); color: var(--tile-ink); }
.key.absent { background: var(--absent); color: var(--tile-ink); opacity: .75; }

/*
 * A key carrying one state per board, a corner each. Declared after the single-state
 * rules above so it wins at equal specificity. app.js sets --k1..--k4 inline; a corner
 * left unset falls back to the plain key colour, which is what a letter looks like on a
 * board that had already frozen before it was first guessed.
 */
.key {
  --k1: var(--key);
  --k2: var(--key);
  --k3: var(--key);
  --k4: var(--key);
}

.key.split {
  background:
    linear-gradient(var(--k1), var(--k1)) 0 0 / 50% 50% no-repeat,
    linear-gradient(var(--k2), var(--k2)) 100% 0 / 50% 50% no-repeat,
    linear-gradient(var(--k3), var(--k3)) 0 100% / 50% 50% no-repeat,
    linear-gradient(var(--k4), var(--k4)) 100% 100% / 50% 50% no-repeat;
  color: var(--tile-ink);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .45);
}

/* ---------- quordle ---------- */

/* Four boards, two across. The tiles give up most of their width to fit. */
.board.quordle {
  display: grid;
  grid-template-columns: repeat(2, auto);
  justify-content: center;
  gap: 10px 14px;
}

.board.quordle .quad {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.board.quordle .row { gap: 3px; }

.board.quordle .tile {
  width: clamp(19px, 6.2vw, 27px);
  border-width: 1.5px;
  border-radius: 5px;
  font-size: clamp(.6rem, 2.6vw, .85rem);
}

/* A solved board keeps its height so the grid stays square, but stops drawing blanks. */
.board.quordle .quad.done .row.empty { visibility: hidden; }

.board.quordle .row.answer .tile {
  background: transparent;
  border-style: dashed;
  color: var(--muted);
}

/* Four rows flip together, so each tile turns faster than Wordle's single row. */
.board.quordle .row.revealing .tile { animation-duration: .18s; }

.quordle-tally {
  display: grid;
  grid-template-columns: repeat(2, 34px);
  gap: 4px;
  justify-content: center;
  margin: 14px 0 4px;
}

.quordle-tally .tally-cell {
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  font-weight: 800;
  color: var(--tile-ink);
}

.quordle-tally .got { background: var(--correct); }
.quordle-tally .missed { background: var(--absent); }

/* ---------- rank ladder (shared by the games you climb) ---------- */

.rank-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 320px;
  margin-bottom: 4px;
}

.rank-label {
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
}

.rank-track {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
}

.rank-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line);
}

.rank-dot.on { background: var(--accent); }
/* The rung you are on reads as a marker rather than one more filled dot. */
.rank-dot.now { transform: scale(1.7); }

/* ---------- a word being typed, any length ---------- */

.word-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 34px;
  font-size: clamp(1.1rem, 5vw, 1.5rem);
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.wl-letter { color: var(--text); }
.wl-letter.accent { color: var(--accent); }

.wl-caret {
  width: 2px;
  height: 1.1em;
  margin-left: 1px;
  background: var(--accent);
  animation: blink 1.1s step-end infinite;
}

@keyframes blink { 50% { opacity: 0; } }

/* ---------- spelling bee ---------- */

.board.bee {
  gap: 10px;
  width: 100%;
}

/*
 * The found words sit above the comb so the comb stays in thumb reach, and the panel
 * scrolls rather than pushing the letters off the bottom of a phone.
 */
.bee-found {
  width: 100%;
  max-width: 320px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 8px 10px;
  max-height: 132px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.bee-found-head {
  font-size: .7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 6px;
}

.bee-found-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: .85rem;
}

.bee-word { text-transform: capitalize; }
.bee-word.pangram { color: var(--accent); font-weight: 800; }

.bee-comb {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Negative margin pulls the rows together so the hexagons interlock. */
.bee-comb-row {
  display: flex;
  gap: 6px;
  margin-top: -12px;
}

.bee-comb-row:first-child { margin-top: 0; }

.bee-cell {
  width: clamp(58px, 19vw, 74px);
  aspect-ratio: 1 / 1.12;
  border: 0;
  padding: 0;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: clamp(1.2rem, 5.5vw, 1.6rem);
  font-weight: 800;
  cursor: pointer;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}

.bee-cell:active { transform: scale(.94); }
.bee-cell.centre { background: var(--accent); color: var(--accent-ink); }

/* ---------- word hunt ---------- */

.board.hunt { gap: 10px; }

.hunt-grid {
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 5px;
}

.hunt-cell {
  width: clamp(48px, 15vw, 62px);
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  transition: background .12s ease, border-color .12s ease;
}

/* The route your typed letters trace, so the path is visible before you commit. */
.hunt-cell.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.hunt-cell.head { box-shadow: 0 0 0 3px var(--surface-2); }

/* Typed letters that join up nowhere: the whole grid says so rather than one cell. */
.hunt-grid.astray .hunt-cell { border-color: var(--danger); }

.hunt-found {
  width: 100%;
  max-width: 320px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 8px 10px;
  max-height: 118px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.hunt-found-head {
  font-size: .7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 6px;
}

.hunt-found-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: .85rem;
}

.hunt-word { text-transform: capitalize; }
.hunt-word.long { color: var(--accent); font-weight: 800; }

/* ---------- cryptogram ---------- */

/*
 * Prose, not tile rows. Each word is a group that can't break, so a word never wraps
 * mid-way and its trailing comma never orphans onto the next line. Your answer sits
 * above the cipher glyph the way a printed cryptogram is set, so the sentence reads
 * left to right as it resolves.
 */
.board.cipher .cipher-text {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  column-gap: 16px;
  row-gap: 16px;
  max-width: 100%;
}

/* A gap between letters so each one keeps its own rule — without it the underlines
 * fuse into a single line and the word stops looking like letters at all. */
.board.cipher .cw {
  display: flex;
  gap: 3px;
}

.board.cipher .cl {
  width: clamp(17px, 5.2vw, 24px);
  border: 0;
  background: none;
  padding: 0;
  display: grid;
  gap: 2px;
  cursor: pointer;
  color: var(--text);
  font: inherit;
}

.board.cipher .cl-slot {
  height: 26px;
  display: grid;
  place-items: center;
  border-bottom: 2px solid var(--tile-line);
  font-size: 1.05rem;
  font-weight: 800;
}

.board.cipher .cl-glyph {
  /* Monospace keeps the cipher letters aligned under variable-width answers. */
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .6rem;
  letter-spacing: .06em;
  color: var(--muted);
}

.board.cipher .cl.sel .cl-slot {
  background: var(--surface-2);
  border-color: var(--accent);
  border-bottom-width: 3px;
}

.board.cipher .cl.given .cl-slot { color: var(--accent); }

.board.cipher .cl.dupe .cl-slot,
.board.cipher .cl.wrong .cl-slot {
  color: var(--danger);
  border-color: var(--danger);
}

.board.cipher .cp {
  align-self: end;
  height: 26px;
  line-height: 26px;
  color: var(--muted);
}

.cipher-author {
  margin-top: 18px;
  text-align: center;
  font-size: .95rem;
}

.cipher-source {
  display: block;
  margin-top: 2px;
  font-size: .75rem;
  color: var(--muted);
}

.result-sub {
  color: var(--muted);
  font-size: .9rem;
  margin-top: 6px;
}

.example-keys { gap: 10px; }
.example-keys .key { flex: 0 0 auto; width: 34px; height: 40px; }
.example-note { font-size: .8rem; color: var(--muted); }

@keyframes pop {
  from { transform: scale(.9); }
  to { transform: scale(1); }
}

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

.row.shake { animation: shake .5s; }

@keyframes settle {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* only the row that was just committed animates in — render() rebuilds them all */
.row.enter { animation: settle .16s ease-out; }

/* ---------- toast + controls ---------- */

.toast {
  flex: none;
  margin: 0;
  min-height: 1.5rem;
  text-align: center;
  font-size: .85rem;
  font-weight: 700;
  color: var(--danger);
  opacity: 0;
  transition: opacity .12s;
}

.toast.show { opacity: 1; }
.toast.nice { color: var(--good); }

.controls {
  flex: none;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 2px 0 8px;
}

.pill-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .8rem;
  font-weight: 700;
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
}

.pill-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pill-btn:disabled { opacity: .38; cursor: default; }

/* ---------- keyboard ---------- */

.keyboard {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 10px;
}

.kb-row {
  display: flex;
  justify-content: center;
  gap: 5px;
}

.key {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 44px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: var(--key);
  color: var(--key-ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
}

.key:active { transform: translateY(1px); }
.key.wide { flex: 1.5 1 auto; max-width: 66px; font-size: .72rem; letter-spacing: .04em; }
.key svg { width: 22px; height: 22px; fill: currentColor; }

/* ---------- modals ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 20, 10, .5);
  z-index: 10;
}

.modal {
  position: fixed;
  z-index: 11;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(440px, calc(100vw - 28px));
  max-height: min(86vh, 720px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.modal h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: .1em;
}

.modal h3 {
  margin: 20px 0 8px;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
}

.modal p { line-height: 1.55; }

.close-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
}

.rules {
  margin: 0 0 4px;
  padding-left: 20px;
  line-height: 1.6;
}

.rules li { margin-bottom: 7px; }

.example {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 16px 0;
}

.example-label { margin: 0 0 8px; font-size: .85rem; color: var(--muted); }

.example-chain {
  margin: 0;
  padding-left: 20px;
  font-weight: 800;
  letter-spacing: .14em;
  line-height: 1.75;
}

.example-chain em {
  font-style: normal;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 4px;
  padding: 1px 3px;
}

.example-note {
  margin-left: 10px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--muted);
  text-transform: uppercase;
}

.fineprint { font-size: .8rem; color: var(--muted); margin-bottom: 0; }

/* tile rows used inside the help dialog */
.example-row { justify-content: center; margin: 0 0 12px; }

.example-row .tile {
  width: 34px;
  border-width: 2px;
  border-radius: 7px;
  font-size: 1rem;
}

/* ---------- game picker ---------- */

.games-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.game-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  padding: 12px 14px;
  cursor: pointer;
}

.game-card:hover { border-color: var(--accent); }

.game-card.on {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.game-emoji { font-size: 1.6rem; line-height: 1; }
.game-name { display: block; font-weight: 800; letter-spacing: .02em; }

.game-tagline {
  display: block;
  font-size: .78rem;
  color: var(--muted);
  margin-top: 2px;
}

/* ---------- stats ---------- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  text-align: center;
}

.stat-val { font-size: 1.7rem; font-weight: 800; line-height: 1.1; }

.stat-key {
  font-size: .64rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  line-height: 1.25;
  margin-top: 2px;
}

.dist { display: flex; flex-direction: column; gap: 5px; }

.dist-row {
  display: grid;
  grid-template-columns: 76px 1fr;
  align-items: center;
  gap: 8px;
  font-size: .78rem;
  font-weight: 700;
}

.dist-key { color: var(--muted); text-align: right; }

.dist-bar {
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 4px;
  padding: 2px 7px;
  text-align: right;
  min-width: 26px;
  font-variant-numeric: tabular-nums;
}

.dist-bar.empty { background: var(--surface-2); color: var(--muted); }
.dist-bar.best { background: var(--good); color: #fff; }

.stats-footer {
  margin-top: 18px;
  font-size: .78rem;
  color: var(--muted);
  text-align: center;
}

/* ---------- result ---------- */

.result-line { margin: 0 0 14px; font-size: 1rem; }
.result-line b { font-size: 1.1rem; }

.result-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 12px;
}

.sq {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--detour);
}

.sq.good { background: var(--good); }
.sq.correct { background: var(--correct); }
.sq.present { background: var(--present); }
.sq.absent { background: var(--absent); }

/* the guessing game shares out a small replica of the board */
.result-tiles {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.result-tile-row { display: flex; gap: 4px; }
.result-tiles .sq { width: 22px; height: 22px; border-radius: 5px; }

.result-path {
  font-size: .82rem;
  color: var(--muted);
  letter-spacing: .08em;
  font-weight: 700;
  line-height: 1.7;
  margin: 0 0 4px;
  word-spacing: .1em;
}

.result-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.countdown {
  flex: 1;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.5;
}

.countdown b {
  display: block;
  font-size: 1.35rem;
  letter-spacing: .04em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.share-btn {
  border: 0;
  border-radius: 999px;
  background: var(--good);
  color: #fff;
  font: inherit;
  font-size: .95rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 13px 26px;
  cursor: pointer;
}

.share-btn:hover { filter: brightness(1.06); }

/* ---------- footer ---------- */

.sitefoot {
  flex: none;
  text-align: center;
  font-size: .72rem;
  color: var(--muted);
  padding: 0 0 8px;
}

.linkish {
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
  padding: 2px;
}

/* ---------- celebration ---------- */

.confetti {
  position: fixed;
  top: -40px;
  font-size: 1.5rem;
  pointer-events: none;
  z-index: 9; /* below the overlay, so it never obscures the result text */
  animation: fall linear forwards;
}

@keyframes fall {
  to { transform: translateY(105vh) rotate(var(--spin, 360deg)); opacity: .1; }
}

.hidden { display: none !important; }

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

/* Short viewports (landscape phones): shrink the chrome, keep the board usable. */
@media (max-height: 620px) {
  .key { height: 42px; }
  .tile { width: clamp(34px, 10vw, 44px); }
  .board.quordle .tile { width: clamp(16px, 5vw, 22px); }
  .sitefoot { display: none; }
}
