/* Puzzle Me This — presentation.
   Measurements come from PuzzleMeThis.psd (853×1844 mock, 1 CSS px ≈ 1.875 PSD px).
   The hero (title + blue frame + board) is a fixed-aspect box sized in cqw so
   every piece keeps its proportion to the traced frame at any width. */

@font-face { font-family: 'PBS Sans Condensed'; src: url('../assets/fonts/PBSSansCondensed-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'PBS Sans Condensed'; src: url('../assets/fonts/PBSSansCondensed-BoldItalic.woff2') format('woff2'); font-weight: 700; font-style: italic; font-display: swap; }
@font-face { font-family: 'PBS Sans Condensed'; src: url('../assets/fonts/PBSSansCondensed-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'PBS Sans'; src: url('../assets/fonts/PBSSans-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'PBS Sans'; src: url('../assets/fonts/PBSSans-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --bg: #07080a;
  --ink: #050505;
  --paper: #ffffff;
  --paper-edge: #e4e4e2;
  --red: #c90b14;          /* title, labels */
  --strip: #c60a12;        /* found-word paper */
  --select: #d70000;       /* selected letters */
  --outline: #b2272e;      /* placeholders */
  --blue: #0238c0;         /* clue paper */
  --blue-hi: #1a4fd6;
  --slot-line: #bab9b8;
  --muted: #9a9aa0;
  --text: #f4f4f2;
  --focus: #6aa8ff;
  --cond: 'PBS Sans Condensed', 'Arial Narrow', 'Roboto Condensed', sans-serif;
  --sans: 'PBS Sans', 'Helvetica Neue', Arial, sans-serif;
  --paper-tex: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --s: 1;                  /* side-column scale (desktop raises it) */
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-settle: cubic-bezier(.3, 1.35, .5, 1);
  --t-press: 100ms;
  --t-select: 150ms;
  --t-confirm: 300ms;
  --t-transfer: 400ms;
  --t-stage: 440ms;
  --t-reveal: 800ms;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  overflow-x: clip;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; touch-action: manipulation; }
img, svg { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ----------------------------------------------------------- site header
   Stand-in for the pbs.org navigation, using pbs.org's own values:
   #000525 bar under an 8px #2638c4 top border; bar height 43px (52px from
   768px, 64px from 1140px); logos at 57% of the bar; 16px inline spacing. */
.site-header {
  --nav-h: 43px;
  --nav-img: calc(var(--nav-h) * .57);
  --nav-gap: 16px;
  --nav-edge: 16px;
  background: #000525;
  border-top: 8px solid #2638c4;
  padding-top: env(safe-area-inset-top);
}
@media (min-width: 768px) { .site-header { --nav-h: 52px; --nav-edge: 32px; } }
@media (min-width: 1140px) { .site-header { --nav-h: 64px; --nav-gap: 12px; --nav-edge: 64px; } }
.site-header__bar {
  display: flex; align-items: center; height: var(--nav-h);
  padding-inline: max(var(--nav-edge), env(safe-area-inset-left)) max(calc(var(--nav-edge) - var(--nav-gap)), env(safe-area-inset-right));
}
.site-header a { display: flex; align-items: center; height: var(--nav-h); color: #fff; text-decoration: none; }
.site-header__home { position: relative; padding-inline-end: var(--nav-gap); }
.site-header__home img { height: var(--nav-img); width: auto; }
.site-header__home::after { content: ''; position: absolute; inset-inline-end: 0; width: 1px; height: var(--nav-img); background: #94a1b2; }
@media (min-width: 768px) { .site-header__home::after { display: none; } }
.site-header__station { padding-inline-start: var(--nav-gap); }
.site-header__station img { width: auto; height: auto; max-width: 90px; max-height: var(--nav-img); }
@media (min-width: 380px) { .site-header__station img { max-width: 150px; } }
.site-header__caret { width: 12px; height: auto; margin-inline-start: 8px; fill: #fff; }
.site-header__search { margin-inline-start: auto; padding-inline: calc(var(--nav-gap) / 2); }
@media (min-width: 380px) { .site-header__search { padding-inline: var(--nav-gap); } }
.site-header__search svg { width: 20px; height: 20px; }
.site-header__menu { padding: var(--nav-gap); }
.site-header__menu svg { width: 20px; height: 20px; translate: 0 3px; }
.site-header a:hover svg { opacity: .7; }

/* ------------------------------------------------------------------ game */
.game {
  max-width: 430px;
  margin: 0 auto;
  padding: 0 0 calc(20px + env(safe-area-inset-bottom));
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.hero {
  position: relative;
  container-type: inline-size;
  width: calc(100% - 5px);
  margin-left: 5px;
  aspect-ratio: 723 / 817;
}
.frame { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
/* Status line: length and color change only after a guess or clue. */
/* Status line length and red tip are tweened in JS (main.js renderLine). */
.hud__status.is-terminated .hud__rank { color: var(--red); }

.title {
  position: absolute;
  left: 4.6cqw; top: 7.4cqw;
  margin: 0;
  font: 700 13.8cqw/1 var(--cond);
  transform: scaleX(.762);            /* PSD: 2.07 × 2.72 text transform */
  transform-origin: 0 0;
  text-transform: uppercase;
  color: #fff;
  white-space: nowrap;
}
.title__me { color: var(--red); }
.title__btn { all: unset; cursor: pointer; display: inline; font: inherit; color: inherit; white-space: nowrap; }
.title__btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
.title__btn:active { opacity: .85; }

/* Help: a small, quiet torn scrap of black paper (the Status/Clue treatment)
   with "? HELP" in white. The visible scrap is small; the tap area stays 44px. */
.help-btn {
  position: absolute; left: 79.7cqw; top: 7.1cqw;
  width: 15cqw; height: 15.6cqw; min-width: 44px; min-height: 44px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2cqw;
  padding: 0; border: 0; background: transparent; color: #fff; cursor: pointer;
  transition: opacity var(--t-press);
}
.help-btn__paper {
  position: absolute; left: 50%; top: 50%; z-index: 0;
  width: 13.4cqw; height: 14cqw; translate: -50% -50%; rotate: -3deg;
  background: #000;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
  clip-path: polygon(6% 4%, 30% 0, 58% 3%, 88% 1%, 100% 9%, 97% 34%, 100% 62%, 96% 88%, 100% 97%, 70% 100%, 44% 96%, 14% 100%, 0 92%, 4% 64%, 0 38%, 3% 16%);
}
.help-btn__q { position: relative; font: 700 7.3cqw/.85 var(--cond); }
.help-btn__label { position: relative; font: 400 3.6cqw/1 var(--cond); text-transform: uppercase; letter-spacing: .07em; opacity: .85; }
@media (hover: hover) { .help-btn:hover .help-btn__q, .help-btn:hover .help-btn__label { opacity: 1; } }
.help-btn:active { transform: scale(.94); }
.help-btn:focus-visible { outline-offset: 2px; }

/* stage area = inside of the blue frame */
.stage-area { position: absolute; left: 4.3cqw; right: 3.4cqw; top: 31.6cqw; bottom: 3.2cqw; }

/* ------------------------------------------------------------------ board */
.board {
  --cols: 6;
  /* PSD tile paper 84×111 on a 103×130 pitch: gap = 22.6% of a tile. Any column
     count keeps the original 6-column grid width (82.9cqw) and that ratio, so
     the side margins inside the frame match the design. */
  --tw: min(calc(82.9cqw / (var(--cols) + (var(--cols) - 1) * .2263)), 11.62cqw);
  --th: calc(var(--tw) * 1.321);
  --gap-x: calc(var(--tw) * .2263);
  --gap-y: var(--gap-x);
  position: absolute;
  left: 0; right: 0; top: 3.6cqw; height: calc(4 * var(--th) + 3 * var(--gap-y)); /* the frame is sized to hug this grid */
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--tw));
  grid-auto-rows: var(--th);
  column-gap: var(--gap-x);
  row-gap: var(--gap-y);
  justify-content: center;
  align-content: center;
}
.board[hidden] { display: none; }
.board__row { display: contents; }

.tile {
  position: relative;
  width: 100%; height: 100%;
  padding: 0; border: 0; background: transparent; cursor: pointer;
  transform: translate(var(--jx, 0), var(--jy, 0)) rotate(var(--rot, 0deg));
  transition: transform var(--t-select) var(--ease-settle), opacity var(--t-select) ease;
  -webkit-user-select: none; user-select: none;
}
/* Hit area reaches into the gutters so small boards still give ≥44px targets. */
.tile::before { content: ''; position: absolute; inset: calc(var(--gap-y) / -2) calc(var(--gap-x) / -2); }
.tile__paper {
  position: absolute; inset: 0;
  clip-path: var(--clip);
  background: var(--paper-tex), var(--paper);
  box-shadow: inset 0 0 0 .3cqw var(--paper-edge);
  transition: transform var(--t-press) var(--ease-out), background-color var(--t-select);
}
.tile__ch > span, .slot__ch > span { display: block; transform: scaleX(.84); }
.tile__ch {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font: 700 calc(var(--th) * .775)/1 var(--cond);
  padding-top: calc(var(--th) * .05);
  color: var(--ink);
  letter-spacing: 0;
  transition: color var(--t-select) ease, transform var(--t-press) var(--ease-out);
}
.tile__ord {
  position: absolute; left: 9%; top: 6%;
  font: 700 calc(var(--th) * .16)/1 var(--cond);
  color: var(--select);
  opacity: 0; transform: translateY(2px);
  transition: opacity var(--t-select), transform var(--t-select) var(--ease-out);
}


@media (hover: hover) {
  .tile:not([aria-disabled="true"]):hover .tile__paper { transform: translateY(-1.5%); }
}
.tile:active .tile__paper, .tile.is-pressed .tile__paper { transform: scale(.94); }
.tile:active .tile__ch, .tile.is-pressed .tile__ch { transform: scale(.94); }

.tile.is-selected { transform: translate(var(--jx, 0), calc(var(--jy, 0px) - .35cqw)) rotate(calc(var(--rot, 0deg) * -1)); z-index: 2; }
.tile.is-selected .tile__ch { color: var(--select); }
.tile.is-selected .tile__ord, .tile.is-locked .tile__ord { opacity: 1; transform: none; }
/* Correct letter in the right place: blue paper, white letter (same in CURRENT). */
.tile.is-locked .tile__paper { background: var(--paper-tex), var(--blue); box-shadow: inset 0 0 0 .3cqw rgba(255,255,255,.14); }
.tile.is-locked .tile__ch { color: #fff; }
.tile.is-locked .tile__ord { color: #fff; }
.tile.is-locked { transform: translate(var(--jx, 0), calc(var(--jy, 0px) - .35cqw)) rotate(0deg); }
.tile.is-out { cursor: default; }
.tile.is-out .tile__paper { opacity: .2; }
.tile.is-out .tile__ch { color: #444; }
.tile.is-used { visibility: hidden; pointer-events: none; }
.tile { touch-action: none; } /* lets a letter be dragged on touch screens */
.tile.is-lifted { opacity: 0; transition: none; }
.tile-ghost {
  position: fixed !important; left: 0; top: 0; z-index: 60; margin: 0; pointer-events: none;
  transition: none !important; filter: drop-shadow(0 10px 18px rgba(0,0,0,.6));
}
.tile-ghost::before, .tile-ghost::after { display: none; }
.tile.is-returning { animation: settle var(--t-select) var(--ease-settle); }
@keyframes settle { from { transform: translate(var(--jx, 0), calc(var(--jy, 0px) - .35cqw)) rotate(var(--rot)); } }

.tile:focus-visible { outline: none; }
.tile:focus-visible::after {
  content: ''; position: absolute; inset: -1.2cqw; border: 3px solid var(--focus); border-radius: 2px;
}

/* -------------------------------------------------------------- assembly */
.assembly, .solved {
  position: absolute; inset: 0;
  padding: 5.6cqw 7cqw 5.6cqw;   /* keeps text well clear of the line */
  display: flex; flex-direction: column;
}
.stage-heading {
  margin: 0; font: 700 6.2cqw/1 var(--cond); text-transform: uppercase; color: #fff; letter-spacing: .01em;
}
.stage-heading:focus { outline: none; }
.stage-sub { margin: 2cqw 0 0; font: 400 3.6cqw/1.35 var(--sans); color: var(--muted); }
.sentence {
  list-style: none; margin: auto 0; padding: 4cqw 0;
  display: flex; flex-wrap: wrap; align-content: center; align-items: center;
  column-gap: 2.4cqw; row-gap: 4.2cqw;
}
.sentence__pos { display: flex; align-items: flex-end; gap: .6cqw; }
.sentence__punct { font: 700 11cqw/1 var(--cond); color: var(--red); margin-bottom: -.6cqw; }

.word {
  --h: 13cqw;
  position: relative; isolation: isolate;
  height: var(--h); min-height: 44px;
  padding: 0 3cqw 0 calc(3cqw + .17em);
  border: 0; background: transparent; cursor: grab;
  font: 700 8.1cqw/1 var(--cond); letter-spacing: .17em; color: #fff; text-transform: uppercase;
  touch-action: none;
  transform: rotate(var(--rot, 0deg));
  transition: transform var(--t-select) var(--ease-settle), opacity var(--t-select);
  -webkit-user-select: none; user-select: none;
}
.word::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: var(--strip); clip-path: var(--clip);
  transition: background-color var(--t-select), transform var(--t-press) var(--ease-out);
}
.word > span { position: relative; display: block; padding-top: .06em; }
.word:active::before { transform: scale(.96); }
@media (hover: hover) { .word:not(.is-pinned):hover::before { background: #d81019; } }
.word.is-picked { transform: translateY(-1.6cqw) rotate(0deg); }
.word.is-picked::before { background: #e3141e; box-shadow: none; }
.word.is-picked::after, .word.is-target::after {
  content: ''; position: absolute; left: 8%; right: 8%; bottom: -1.8cqw; height: .8cqw; background: #fff;
}
.word.is-target::before { background: #e3141e; }
.word.is-pinned { cursor: default; }
.word.is-pinned::after {
  content: ''; position: absolute; right: -1cqw; top: -1cqw; width: 2.6cqw; height: 2.6cqw;
  border-radius: 50%; background: #fff; box-shadow: 0 0 0 .6cqw var(--strip);
}
.word.is-dragging { opacity: .22; }
.word.is-dragging::before { background: transparent; box-shadow: inset 0 0 0 2px var(--strip); }
.word-ghost {
  position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none;
  transform-origin: 0 0; box-shadow: 0 10px 24px rgba(0,0,0,.6);
}

.solved { justify-content: flex-start; text-align: center; align-items: center; } /* top-aligned: room for the series description */
.solved__title {
  margin: 0; font: 700 9.4cqw/.95 var(--cond); text-transform: uppercase; color: #fff;
}
.game[data-stage="solved"] .hud, .game[data-stage="solved"] .clue-panel { display: none !important; }
.solved__title span { color: var(--red); display: inline-block; }
.solved__title:focus { outline: none; }
.solved__closed { margin: 2.4cqw 0 0; font: 700 6cqw/1 var(--cond); letter-spacing: .3em; text-transform: uppercase; }
.solved__status {
  margin: 4.4cqw 0 0; font: 700 4.4cqw/1 var(--cond); text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.solved__status span { color: #fff; font-style: italic; }
.solved__steps { margin: 1.6cqw 0 0; font: 700 4.4cqw/1 var(--cond); text-transform: uppercase; letter-spacing: .06em; color: #fff; }
.solved__quote { margin: 4.4cqw 0 0; padding: 0; }
/* Show section inside the frame, under the quote. */
.solved .show {
  /* Sized to its content and centred under the quote, so image, title and
     button sit balanced in the frame rather than drifting left. */
  display: grid; grid-template-columns: 36cqw auto; column-gap: 4cqw; align-items: center; justify-content: center;
  width: auto; max-width: 100%; margin: 5.4cqw auto 0; padding: 0; text-align: left;
}
.solved .show__art { grid-row: 1; width: 100%; margin: 0; }
.solved .show__about {
  grid-column: 1 / -1; margin: 3.6cqw 0 0; max-width: 76cqw;
  font: 400 3.7cqw/1.4 var(--sans); color: #d8d8d8; text-align: left;
  display: block; -webkit-line-clamp: unset; overflow: visible;
}
.solved .show__title-row { display: flex; flex-direction: column; align-items: flex-start; gap: 2.4cqw; margin: 0; }
.solved .show__name { margin: 0; font: 700 6.4cqw/1 var(--cond); text-transform: uppercase; color: var(--red); }
.solved .show__watch { min-height: 44px; padding: 0 4cqw; font-size: 4.6cqw; }
/* Status + steps, outside the frame above the buttons. */
.result { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 0 0 calc(14px * var(--s)); }
.result__status { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.result__label { font: 700 calc(12px * var(--s))/1 var(--cond); text-transform: uppercase; letter-spacing: .08em; color: #4d7dff; }
.result__rank { font: italic 700 calc(24px * var(--s))/1 var(--cond); text-transform: uppercase; color: #fff; }
.result__steps { margin: 0; font: 700 calc(24px * var(--s))/1 var(--cond); text-transform: uppercase; color: var(--red); white-space: nowrap; }
/* CASE CLOSED: a red rubber stamp. */
.stamp {
  display: inline-block; padding: .5cqw 1.4cqw .3cqw calc(1.4cqw + .3em);
  border: .55cqw solid #fff; color: #fff; rotate: -4deg; font-size: .78em;
  box-shadow: inset 0 0 0 .2cqw rgba(255, 255, 255, .3);
  -webkit-mask-image: radial-gradient(circle at 30% 40%, #000 60%, rgba(0,0,0,.82) 100%);
          mask-image: radial-gradient(circle at 30% 40%, #000 60%, rgba(0,0,0,.82) 100%);
}
.solved.is-entering .stamp { animation: stamp 520ms 380ms cubic-bezier(.2, .9, .3, 1.25) both; }
@keyframes stamp {
  0% { opacity: 0; transform: scale(2.6) rotate(-9deg); }
  55% { opacity: 1; transform: scale(.92) rotate(1deg); }
  75% { transform: scale(1.04) rotate(0deg); }
  100% { opacity: 1; transform: none; }
}
.solved__mark { font: 700 9cqw/1 var(--cond); color: #fff; align-self: flex-start; margin: -1cqw .6cqw 0 0; }
.sentence__pos .solved__mark { margin: -1cqw 0 0 .4cqw; }
.solved__attrib { margin-top: 2.6cqw; font: 400 3.8cqw/1.2 var(--cond); text-transform: uppercase; letter-spacing: .12em; color: #d8d8d8; }
.solved__sentence {
  margin: 0; display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end;
  gap: 2.6cqw 2cqw;
}
.solved__sentence .word { cursor: default; --h: 8.4cqw; font-size: 5cqw; min-height: 0; }

/* ------------------------------------------------------------ side panels */
.side { padding: calc(28px * var(--s)) 22px 0 31px; }
.panel { margin: 0 0 calc(22px * var(--s)); }
.panel__head { display: flex; align-items: baseline; gap: 10px; min-height: 22px; }
.label {
  margin: 0 0 calc(8px * var(--s)); font: 700 calc(12.6px * var(--s))/1 var(--cond);
  text-transform: uppercase; letter-spacing: .015em; color: #fff;
}
.text-btn {
  margin-left: auto; min-height: 44px; min-width: 44px; padding: 0 8px; margin-top: -14px; margin-bottom: -10px;
  border: 0; background: transparent; cursor: pointer;
  font: 700 calc(12px * var(--s))/1 var(--cond); text-transform: uppercase; letter-spacing: .1em; color: var(--muted);
  transition: color var(--t-press);
}
.text-btn:hover { color: #fff; }

.current__wrap { position: relative; container-type: inline-size; }
.slots {
  --n: 4;
  --sw: min(calc(42px * var(--s)), calc((100cqw - (var(--n) - 1) * 3px) / var(--n)));
  display: flex; gap: 3px;
  min-height: calc(var(--sw) * 1.07);
}
.slot {
  position: relative; flex: 0 0 var(--sw); width: var(--sw); height: calc(var(--sw) * 1.07); min-height: 44px;
  padding: 0; border: 0; background: transparent; cursor: default;
}
.slot__box { position: absolute; inset: 0; border: 2px solid var(--slot-line); background: #020303; }
.slot__paper {
  position: absolute; inset: 0; background: var(--paper-tex), var(--paper); clip-path: var(--clip);
  box-shadow: inset 0 0 0 1.5px var(--paper-edge);
}
.slot__ch {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font: 700 calc(var(--sw) * .8)/1 var(--cond); padding-top: .05em; color: var(--select);
}
.slot.is-locked .slot__paper { background: var(--paper-tex), var(--blue); box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.14); }
.slot.is-locked .slot__ch { color: #fff; }
.slot.is-drop .slot__box { border-color: #fff; background: #0d1a3d; }
.slot.is-drop .slot__paper { filter: brightness(.85); }
.slot.is-filled { cursor: pointer; }
.slot.is-filled .slot__box { display: none; }
.slot.is-locked { cursor: default; }
.slot.is-new .slot__paper, .slot.is-new .slot__ch { animation: pop var(--t-select) var(--ease-settle); }
@keyframes pop { from { transform: scale(.7) translateY(6px); opacity: 0; } }
.slot.is-filled:not(.is-locked):hover .slot__paper { filter: brightness(.94); }

.current { margin-bottom: calc(26px * var(--s)); }
.current.is-miss .slots { animation: shake 280ms ease; }
@keyframes shake { 20% { transform: translateX(-5px); } 45% { transform: translateX(4px); } 70% { transform: translateX(-2px); } 100% { transform: none; } }
.slots.is-hit .slot__paper { animation: confirm var(--t-confirm) var(--ease-out); }
.slots.is-hit .slot__ch { color: #fff; }
.slots.is-hit .slot__paper { background: var(--strip); box-shadow: none; }
@keyframes confirm { 0% { transform: scale(1); } 40% { transform: scale(1.08) translateY(-3px); } 100% { transform: scale(1); } }


.found__list {
  list-style: none; margin: 0; padding: 2px 0 0;
  display: flex; flex-wrap: wrap; align-items: center;
  column-gap: calc(20px * var(--s)); row-gap: calc(16px * var(--s));
}
.found__item { display: flex; }
.strip {
  --h: calc(30px * var(--s));
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  height: var(--h);
  padding: 0 0 0 .26em;
  font: 700 calc(19.6px * var(--s))/1 var(--cond); letter-spacing: .26em; color: #fff; text-transform: uppercase;
  transform: rotate(var(--rot, 0deg));
}
.strip::before { content: ''; position: absolute; inset: 0; z-index: -1; background: var(--strip); clip-path: var(--clip); }
.strip > span { padding-top: .08em; }
.strip.is-new { animation: stripIn var(--t-transfer) var(--ease-out) both; }
@keyframes stripIn { from { opacity: 0; transform: translateY(6px) rotate(var(--rot, 0deg)) scale(.96); } }
.found__item { --len: 3; font-size: calc(19.6px * var(--s)); height: calc(32px * var(--s)); align-items: center; }
.found__item > .strip, .found__item > .placeholder { width: calc(var(--len) * .74em + 1.1em); }
.placeholder {
  display: block; height: calc(32px * var(--s));
  border: 2px solid var(--outline);
  transform: rotate(var(--rot, 0deg));
}
.word-fly {
  position: fixed; left: 0; top: 0; z-index: 40; pointer-events: none; transform-origin: 0 0; margin: 0;
}

/* ------------------------------------------------------------------- CTAs */
.cta {
  position: relative; isolation: isolate; display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 0 20px;
  border: 0; background: transparent; color: #fff; cursor: pointer; text-decoration: none;
  font: 700 calc(17px * var(--s))/1 var(--cond); text-transform: uppercase; letter-spacing: .04em;
  transition: transform var(--t-press) var(--ease-out);
}
.cta::before { content: ''; position: absolute; inset: 0; z-index: -1; clip-path: polygon(1.5% 6%, 99% 0, 97.5% 100%, 0 93%); transition: background-color var(--t-press), filter var(--t-press); }
.cta--blue::before { background: var(--blue); }
.cta--red::before { background: var(--strip); }
.cta--outline::before { background: transparent; clip-path: none; border: 2px solid rgba(255,255,255,.75); }
.cta:hover::before { filter: brightness(1.15); }
.cta:active { transform: scale(.96); }
.cta[disabled] { opacity: .45; cursor: default; }

.assemble-panel { text-align: left; }
.assemble-panel__text { margin: 0 0 14px; font: 400 calc(14px * var(--s))/1.4 var(--sans); color: #d8d8d8; }
.assemble-panel__text.is-miss { color: #fff; }

.complete__stats { margin: 0; font: 700 calc(22px * var(--s))/1.1 var(--cond); text-transform: uppercase; color: #fff; letter-spacing: .01em; }
.complete__rank { margin: 6px 0 18px; font: 400 calc(14px * var(--s))/1.4 var(--sans); color: #d8d8d8; }
.show { margin: 0 0 20px; padding: 16px 0 0; }
.show__art {
  width: 100%; height: auto; aspect-ratio: 800 / 420; object-fit: cover; margin-bottom: 14px;
  clip-path: polygon(0.6% 1.4%, 99.2% 0, 100% 98.2%, 0 100%); transform: rotate(-.4deg);
}
.show__title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 8px; }
.show__title-row .show__name { margin: 0; }
.show__watch { min-height: 44px; padding: 0 18px; flex: none; }
.show__eyebrow { margin: 0; font: 700 11px/1 var(--cond); text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
.show__name { margin: 6px 0 6px; font: 700 calc(28px * var(--s))/1 var(--cond); text-transform: uppercase; color: var(--red); }
.show__about { margin: 0 0 14px; font: 400 calc(14px * var(--s))/1.45 var(--sans); color: #d8d8d8; }
.complete__actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* --------------------------------------------------------------- clue panel */
.clue-panel {
  position: relative; margin: 0 0 18px; padding: 16px 16px 18px;
  background: #0b0d14; border-left: 4px solid var(--blue);
  animation: panelIn var(--t-select) var(--ease-out);
}
@keyframes panelIn { from { opacity: 0; transform: translateY(6px); } }
.clue-panel__head { display: flex; align-items: center; }
.clue-panel__head .label { margin: 0; }
.clue-panel__hints { margin: 6px 0 10px; padding-left: 0; list-style: none; font: 400 calc(15px * var(--s))/1.4 var(--sans); color: #fff; }
.clue-panel__hints li + li { margin-top: 6px; }
.clue-panel__hints:empty { display: none; }

/* --------------------------------------------------------------------- HUD */
.hud {
  display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: center;
  margin: calc(6px * var(--s)) -6px 0 -16px;
  min-height: calc(68px * var(--s));
}
.hud__guesses { display: flex; flex-direction: column; align-items: center; gap: calc(6px * var(--s)); }
.hud__guess-label { font: 700 calc(15px * var(--s))/1 var(--cond); color: var(--red); text-transform: uppercase; letter-spacing: .01em; }
.hud__guess-num { font: 700 calc(25px * var(--s))/1 var(--cond); color: #fff; font-variant-numeric: tabular-nums; }
.hud__guess-num.is-bump { animation: bump var(--t-confirm) var(--ease-settle); }
@keyframes bump { 40% { transform: scale(1.25); } }

.hud__status {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: calc(60px * var(--s)); padding: 0 10px; text-align: center;
  isolation: isolate;
}
.hud__status::before {
  content: ''; position: absolute; inset: 0 -4px; z-index: -1; background: #000;
  clip-path: polygon(22% 4%, 60% 0, 85% 7%, 99% 38%, 96% 82%, 72% 100%, 30% 97%, 4% 86%, 0 56%, 9% 22%);
}
.hud__status-label { font: 700 calc(8.8px * var(--s))/1 var(--cond); text-transform: uppercase; letter-spacing: .04em; color: #fff; margin-bottom: 3px; }
.hud__rank { display: flex; flex-direction: column; align-items: center; font: 700 calc(17px * var(--s))/.98 var(--cond); text-transform: uppercase; color: #fff; letter-spacing: .01em; }
.hud__rank em { font-style: italic; }
.hud__rank em:empty { display: none; }
.hud__status.is-promoted .hud__rank { animation: bump 600ms var(--ease-settle); }

.clue-btn {
  justify-self: center; position: relative; padding: 0; border: 0; background: transparent; cursor: pointer;
  width: calc(96px * var(--s)); height: calc(58px * var(--s)); isolation: isolate;
  transition: transform var(--t-press) var(--ease-out);
}
.clue-btn::before {
  content: ''; position: absolute; inset: -2px -8px -6px -10px; z-index: -1; background: #000;
  clip-path: polygon(3% 8%, 96% 0, 100% 46%, 97% 100%, 6% 96%, 0 55%);
}
.clue-btn__face {
  position: absolute; inset: 7% 4% 12% 6%;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  font: 700 calc(17px * var(--s))/1 var(--cond); text-transform: uppercase; color: #fff; letter-spacing: .03em;
}
.clue-btn__face::before {
  content: ''; position: absolute; inset: 0; z-index: -1; background: var(--blue);
  /* Four straight edges, each a slightly different length and angle. */
  clip-path: polygon(2.5% 7%, 99% 1.5%, 97% 94%, 0.5% 99%);
  transition: background-color var(--t-press);
}
.clue-btn__face span { padding-top: 0; } /* optically centred in the blue paper */
.clue-btn__face svg { width: calc(18px * var(--s)); height: calc(18px * var(--s)); }
.clue-btn:hover .clue-btn__face::before, .clue-btn[aria-expanded="true"] .clue-btn__face::before { background: var(--blue-hi); }
.clue-btn:active { transform: scale(.95); }
.clue-btn[disabled] { opacity: .4; cursor: default; }

.meta {
  display: flex; align-items: center; gap: 4px; margin: calc(14px * var(--s)) -8px 0 0;
  padding-top: 4px;
}
.meta__case { font: 700 calc(12px * var(--s))/1 var(--cond); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-right: auto; }
.meta .text-btn { margin: 0; }

/* ----------------------------------------------------------------- dialogs */
.sheet {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 0; background: transparent; color: var(--text);
}
.sheet::backdrop { background: rgba(0, 0, 0, .72); }
.sheet[open] { animation: sheetIn var(--t-stage) var(--ease-out); }
@keyframes sheetIn { from { opacity: 0; transform: translateY(12px); } }
.sheet__inner {
  position: relative; background: #0a0b0e; padding: 22px 22px 24px;
  border: 3px solid transparent;
  background-image: linear-gradient(#0a0b0e, #0a0b0e), linear-gradient(35deg, #3f72c6, #0c2f93 60%, #171c66);
  background-origin: border-box; background-clip: padding-box, border-box;
}
.sheet__head { display: flex; align-items: center; margin-bottom: 8px; }
.sheet__title { margin: 0; font: 700 30px/1 var(--cond); text-transform: uppercase; color: #fff; }
.sheet__options { display: flex; align-items: center; gap: 4px; padding-bottom: 4px; }
.sheet__options .text-btn { margin: 0; }
.sheet__options .meta__case { margin-right: auto; }
.sheet__section { margin-top: 16px; }
.sheet__section h3 { margin: 0 0 6px; font: 700 18px/1.1 var(--cond); text-transform: uppercase; color: var(--red); letter-spacing: .02em; }
.sheet__section ul { margin: 0; padding-left: 18px; font: 400 15px/1.45 var(--sans); color: #e4e4e4; }
.sheet__section li + li { margin-top: 4px; }
.sheet__foot { margin-top: 22px; }

.archive { list-style: none; margin: 8px 0 0; padding: 0; }
.archive li + li { margin-top: 2px; }
/* More cases + Sound: red, like the title's ME. */
.meta .text-btn, .sheet__options .text-btn { color: var(--red); }
.meta .text-btn:hover, .sheet__options .text-btn:hover { color: #ff3b44; }
#archiveBtn, #helpArchiveBtn { color: #fff; }
#archiveBtn:hover, #helpArchiveBtn:hover { color: #c8c8c8; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; }
.meta .icon-btn[aria-pressed="true"], .sheet__options .icon-btn[aria-pressed="true"],
.meta .icon-btn[aria-pressed="true"]:hover, .sheet__options .icon-btn[aria-pressed="true"]:hover { color: #fff; } /* sound on */
.icon-btn svg { width: 1.45em; height: 1.45em; }   /* sized from the row's text */
.archive button {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; width: 100%;
  min-height: 56px; padding: 8px 4px; border: 0; background: transparent; cursor: pointer; text-align: left;
}
.archive button:hover { background: #12141a; }
.archive__case { font: 700 22px/1 var(--cond); color: #fff; text-transform: uppercase; }
.archive__date { font: 400 14px/1.2 var(--sans); color: var(--muted); }
.archive__state { white-space: nowrap; font: 700 13px/1 var(--cond); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.archive__state.is-solved { color: #fff; }
.archive__state.is-solved::before { content: '✓ '; color: var(--red); }
.archive__state.is-current { color: var(--focus); }

.noscript { padding: 40px 20px; text-align: center; font: 700 20px var(--cond); }

/* --------------------------------------------------------- stage changes */
.game[data-stage="assemble"] .current,
.game[data-stage="assemble"] .found,
.game[data-stage="solved"] .current,
.game[data-stage="solved"] .found { display: none; }
.stage-area > .is-entering { animation: stageIn var(--t-stage) var(--ease-out) both; }
@keyframes stageIn { from { opacity: 0; transform: translateY(1.5cqw); } }
.board.is-leaving { animation: stageOut 260ms ease both; }
@keyframes stageOut { to { opacity: 0; transform: scale(.97); } }
.solved.is-entering .solved__title { animation: reveal var(--t-reveal) var(--ease-out) both; }
.solved.is-entering .solved__quote { animation: reveal var(--t-reveal) 700ms var(--ease-out) both; }
.solved.is-entering .solved__status, .solved.is-entering .solved__steps { animation: reveal var(--t-reveal) 860ms var(--ease-out) both; }
@keyframes reveal { from { opacity: 0; transform: translateY(2cqw) scale(.98); letter-spacing: .06em; } }

/* ------------------------------------------------- phones: one screen, no scroll
   The page is exactly one viewport tall. The controls take their natural
   height and the board (title + frame + letters) scales to whatever is left,
   never wider than the side gutters allow. Very short screens fall back to
   scrolling once the board would get smaller than the min-height. */
@media (max-width: 959px) and (orientation: portrait) {
  /* A definite height (not min-height) so the board's container can size by height. */
  body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; height: var(--app-h, 100dvh); }
  .site-header { flex: none; }
  .game {
    flex: 1 1 auto; display: flex; flex-direction: column; width: 100%; max-width: 560px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom)); /* bottom row clear of the screen edge */
  }
  .hero-wrap {
    flex: 1 0 auto; container-type: size;
    min-height: max(250px, calc(var(--hero-w, 0px) * var(--frame-ratio, 1.13))); /* never shorter than the board */
    display: flex; justify-content: center; align-items: flex-start;
    padding: 0 max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  }
  /* --hero-w / --s are computed in main.js (layoutPhone) so the board and the
     controls under it fill the screen exactly; cq units are the fallback. */
  .hero { width: var(--hero-w, min(100cqw, 100cqh * 723 / 817)); margin: 0; flex: none; }
  /* Same width as the board; left edge on the frame's left line (28/723 of the
     artwork at its base), right edge on the frame's right line (5/723). */
  .side {
    --edge-l: calc(var(--hero-w, 340px) * 28 / 723);
    --edge-r: calc(var(--hero-w, 340px) * 5 / 723);
    flex: none; position: relative; box-sizing: border-box;
    width: var(--hero-w, calc(100% - 44px)); margin-inline: auto;
    padding: calc(8px * var(--s)) var(--edge-r) 0 var(--edge-l);
  }
  .panel { margin-bottom: calc(9px * var(--s)); }
  .current { margin-bottom: calc(9px * var(--s)); }
  .label { margin-bottom: calc(6px * var(--s)); }
  .found__list { row-gap: calc(10px * var(--s)); column-gap: calc(14px * var(--s)); }
  .hud { margin: 0; min-height: calc(54px * var(--s)); grid-template-columns: auto 1fr auto; column-gap: 8px; }
  .hud__guesses { align-items: flex-start; }
  .clue-btn { justify-self: end; }
  .clue-btn::before { inset: -2px 0 -6px -10px; }
  /* Bottom row, compact: case label, More cases, Sound. */
  .meta { margin: 0; padding-top: 0; white-space: nowrap; }
  .meta .text-btn { min-height: calc(40px * var(--s)); font-size: calc(11px * var(--s)); padding: 0 0 0 calc(12px * var(--s)); }
  .meta__case { font-size: calc(11px * var(--s)); }
  .side { padding-top: 4px; }

  /* Clue opens as a card above the controls instead of pushing them down. */
  .clue-panel {
    position: absolute; left: var(--edge-l); right: var(--edge-r); bottom: calc(102px * var(--s)); z-index: 30; margin: 0;
    padding: 10px 14px 12px; overflow: auto;
    box-shadow: 0 -6px 30px rgba(0, 0, 0, .75);
  }
  /* The clue itself, Close top-right, and the Reveal button underneath. */
  .clue-panel { display: grid; grid-template-columns: 1fr auto; align-items: start; column-gap: 8px; row-gap: 8px; }
  .clue-panel__head { display: contents; }
  .clue-panel__head .text-btn { grid-column: 2; grid-row: 1; margin: -10px -6px 0 0; }
  .clue-panel__hints { grid-column: 1; grid-row: 1; margin: 0; padding-left: 0; list-style: none; font-size: 14px; line-height: 1.35; }
  .clue-panel .cta { grid-column: 1 / -1; grid-row: 2; justify-self: start; min-height: 40px; padding: 0 14px; font-size: 14px; }

  /* Solved page: thumbnail beside the title and Watch Now. */
  .show { display: grid; grid-template-columns: 40% 1fr; column-gap: 14px; align-items: center; margin-bottom: 12px; padding-top: 12px; }
  .show__art { grid-row: 1 / span 3; margin: 0; }
  .show__title-row { flex-direction: column; align-items: flex-start; gap: 8px; margin: 4px 0 0; }
  .show__name { font-size: 24px; }
  .show__watch { min-height: 40px; padding: 0 14px; font-size: 15px; }
  .show__about { grid-column: 1 / -1; margin: 10px 0 0; font-size: 13px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .complete__actions { gap: 8px; }
  .complete__actions { flex-wrap: nowrap; }
  .complete__actions .cta { min-height: 44px; padding: 0 6px; font-size: calc(14px * var(--s)); flex: 1 1 0; white-space: nowrap; }
}

/* Phones: tighter vertical rhythm under the board. Every pixel saved here
   becomes board width (the board is height-limited), i.e. less side padding. */
@media (max-width: 959px) and (orientation: portrait) {
  .side { padding-top: calc(4px * var(--s)); }
  .panel, .current { margin-bottom: calc(6px * var(--s)); }
  /* Breathing room: CURRENT → Scrambled words, Scrambled words → Steps/Status/Clue.
     --gap-extra is any spare screen height, shared out by layoutPhone(). */
  .current { margin-bottom: calc(16px * var(--s) + var(--gap-extra, 0px)); }
  .found { margin-bottom: calc(18px * var(--s) + var(--gap-extra, 0px)); }
  .side { padding-top: calc(13px * var(--s)); }   /* CURRENT sits a little lower under the board */
  /* Same label → boxes gap for CURRENT and SCRAMBLED WORDS. */
  .label { margin-bottom: calc(7px * var(--s)); }
  .current .panel__head { min-height: 0; position: relative; }
  .current #clearBtn { position: absolute; right: 0; top: 50%; transform: translateY(-50%); margin: 0; padding: 0 0 0 10px; }
  .found__list { padding-top: 0; }
  .found__item { align-items: flex-start; }
  .label { margin-bottom: calc(4px * var(--s)); }
  .slots { --sw: min(calc(38px * var(--s)), calc((100cqw - (var(--n) - 1) * 3px) / var(--n))); }
  .slot { min-height: 0; }
  .found__list { row-gap: calc(7px * var(--s)); }
  .found__item { font-size: calc(18px * var(--s)); height: calc(28px * var(--s)); }
  .strip { --h: calc(27px * var(--s)); font-size: calc(18px * var(--s)); }
  .placeholder { height: calc(28px * var(--s)); }
  .hud { min-height: calc(50px * var(--s)); }
  .hud__status { height: calc(50px * var(--s)); }
  .clue-btn { height: calc(50px * var(--s)); }
  .meta .text-btn { min-height: calc(34px * var(--s)); }
  /* Bottom row sits on the bottom edge: leftover height goes above it, and its
     text rests at the bottom of each (full-size) tap target. */
  .meta { margin-top: var(--meta-gap, 0px); align-items: flex-end; }
  .meta .text-btn { display: inline-flex; align-items: flex-end; padding-bottom: 3px; }
  /* Centre the speaker on the text's capitals (measured: caps centre is .585em
     above the text box bottom; the icon's centre is half its 1.45em height). */
  .meta .icon-btn { padding-bottom: calc(3px + .585em - .725em - .8px); } /* centred on the capitals */
  .meta__case { padding-bottom: 3px; }
}

/* ----------------------------------------------------------------- tablet */
@media (min-width: 600px) {
  .game { max-width: 520px; }
  .side { padding-left: 40px; padding-right: 32px; }
  :root { --s: 1.1; }
}

/* ----------------------------------------------------------------- desktop */
@media (min-width: 960px) {
  :root { --s: 1.3; }
  .game {
    max-width: 1060px; padding: 0 32px 48px; /* frame line meets the header bar */
    display: grid; grid-template-columns: minmax(0, 560px) minmax(360px, 420px);
    justify-content: center; column-gap: 56px; align-items: start;
  }
  .hero { width: 100%; margin-left: 0; }
  .side { padding: 150px 0 0; }
  .hud { margin-left: -14px; margin-right: -8px; }
}

/* --------------------------------------------------------------- landscape phones */
@media (max-height: 520px) and (orientation: landscape) and (max-width: 959px) {
  .game { max-width: 760px; display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; align-items: start; }
  .side { padding-top: 16px; }
}

/* ---------------------------------------------------------- reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important; animation-delay: 0ms !important;
    transition-duration: 1ms !important;
  }
  .tile.is-selected, .tile.is-locked, .word.is-picked { transform: translate(var(--jx, 0), var(--jy, 0)) rotate(var(--rot, 0deg)); }
}
