/* Growing Minds Science — arcade.css
   The arcade shell: one overlay every game shares (see makeShell in
   arcade-core.js). Paper ground, Newsreader title, Inter HUD, a quiet rule
   between the frame and the play field, a surface card for prompts, pips for
   timed power-ups, a toast for chapter beats, the local leaderboard and the
   initials form. Loaded only on /arcade. Game files draw everything inside
   the canvas themselves; nothing here knows one game from another.
*/

/* ---------- Page tear-away ---------- */
body.gms-arcade-lock { overflow: hidden; }
/* While a game is open the body is pinned at its scroll offset (top is set by
   core). overflow:hidden alone does not stop iOS Safari panning the page under
   the overlay, and each pan resizes the viewport as the URL bar moves. */
body.gms-arcade-fixed { position: fixed; left: 0; right: 0; width: 100%; overflow: hidden; }
.gms-arcade-falling { will-change: transform, opacity; }

/* ---------- Overlay ---------- */
.gms-arcade-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: contain;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  /* Vertical pans only (the prompt and the puzzle boards scroll); no pinch
     zoom and no double-tap zoom anywhere over a game. The canvas and the
     touch buttons narrow this to none. */
  touch-action: pan-y;
  color: var(--ink);
  font-family: var(--font-body);
}
.gms-arcade-overlay input { user-select: text; -webkit-user-select: text; }
.gms-arcade-overlay.is-open { display: block; }

.gms-arcade-backdrop {
  position: absolute;
  inset: 0;
  background: var(--paper);
  animation: gms-arcade-fade 360ms ease both;
}

@keyframes gms-arcade-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes gms-arcade-rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Panel: head / HUD / stage / help / touch ---------- */
.gms-arcade-panel {
  position: absolute;
  inset: 0;
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--paper);
  padding: calc(clamp(10px, 2vh, 20px) + env(safe-area-inset-top, 0px)) calc(clamp(12px, 4vw, 48px) + env(safe-area-inset-right, 0px)) calc(clamp(10px, 2vh, 18px) + env(safe-area-inset-bottom, 0px)) calc(clamp(12px, 4vw, 48px) + env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.4vh, 14px);
  animation: gms-arcade-rise 420ms var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) 120ms both;
}

@media (prefers-reduced-motion: reduce) {
  .gms-arcade-backdrop,
  .gms-arcade-panel { animation: none; }
}

.gms-arcade-panel__head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
}

.gms-arcade-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.25rem, 1rem + 1vw, 1.75rem);
  line-height: 1.1;
  letter-spacing: -0.015em;
  color: var(--ink);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 12px;
}
.gms-arcade-title span {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  color: var(--ink-muted);
  letter-spacing: 0;
}

.gms-arcade-head__actions { display: flex; gap: 8px; flex-shrink: 0; }

.gms-arcade-iconbtn,
.gms-arcade-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px; /* the touch-target floor */
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  touch-action: manipulation;
  transition: color var(--t-hover, 180ms) ease, border-color var(--t-hover, 180ms) ease, background-color var(--t-hover, 180ms) ease;
}
.gms-arcade-iconbtn:hover,
.gms-arcade-close:hover { color: var(--ink); border-color: var(--ink-muted); }
.gms-arcade-iconbtn:focus-visible,
.gms-arcade-close:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }
.gms-arcade-iconbtn svg { display: block; }
.gms-arcade-iconbtn .x { display: none; }
.gms-arcade-iconbtn.is-muted .x { display: block; }
.gms-arcade-iconbtn.is-muted .w1,
.gms-arcade-iconbtn.is-muted .w2 { display: none; }

/* HUD: small tracked labels, tabular values. */
.gms-arcade-scores {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.gms-arcade-scores strong,
.gms-arcade-hud__value {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  font-size: 15px;
  margin-left: 6px;
}
.gms-arcade-hud__cell { display: inline-flex; align-items: baseline; }
.gms-arcade-hud__cell[hidden] { display: none; }
.gms-arcade-hud__cell.is-flash .gms-arcade-hud__value { animation: gms-arcade-hud-flash 420ms ease; }
@keyframes gms-arcade-hud-flash { 0% { color: var(--forest); transform: translateY(-1px); } 100% { color: var(--ink); transform: none; } }

/* The stage takes the remaining height; the canvas is sized by makeCanvas.fit(). */
.gms-arcade-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.gms-arcade-canvas {
  display: block;
  cursor: pointer;
  outline: 2px solid transparent;
  outline-offset: -2px;
  touch-action: none;
  border-radius: var(--radius-lg, 10px);
  border: 1px solid var(--border-soft);
  background: var(--paper);
}
/* Legacy games (pre core v2) size the canvas with CSS and draw pixel art. */
.gms-arcade-canvas:not(.is-fit) {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  border: 0;
  border-radius: 0;
}
.gms-arcade-canvas.is-fit:not(.is-smooth) { image-rendering: pixelated; }
.gms-arcade-canvas:focus-visible { outline-color: var(--forest); }

/* ---------- Power-up pips (top-left of the stage) ---------- */
.gms-arcade-pips {
  position: absolute;
  top: 10px; left: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  z-index: 2;
}
.gms-arcade-pip {
  --pip: var(--forest);
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 84px;
  padding: 4px 10px 6px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  overflow: hidden;
}
.gms-arcade-pip::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: var(--pip); flex-shrink: 0; }
.gms-arcade-pip[data-uses]::after { content: attr(data-uses); color: var(--ink); font-variant-numeric: tabular-nums; }
.gms-arcade-pip__bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: var(--pip);
  transform-origin: left center;
  transform: scaleX(1);
}

/* ---------- Toast (chapter beats, short notices) ---------- */
.gms-arcade-toast {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--field-ink);
  color: var(--on-ink);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  text-align: center;
  max-width: min(360px, calc(100% - 24px));
  pointer-events: none;
  z-index: 3;
}
.gms-arcade-toast[hidden] { display: none; }
.gms-arcade-toast.is-in { animation: gms-arcade-toast 1400ms ease both; }
@keyframes gms-arcade-toast {
  0% { opacity: 0; transform: translate(-50%, -6px); }
  12% { opacity: 1; transform: translate(-50%, 0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .gms-arcade-toast.is-in { animation: gms-arcade-fade 200ms ease both; } }

/* ---------- Rotate hint (portrait field, phone held sideways) ---------- */
.gms-arcade-rotate {
  position: absolute;
  top: 8px; left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  max-width: calc(100% - 16px);
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  text-align: center;
  cursor: pointer;
}
.gms-arcade-rotate[hidden] { display: none; }
.gms-arcade-rotate:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }

/* ---------- Prompt: start / pause / chapter / game over ---------- */
.gms-arcade-prompt[hidden] { display: none; }
.gms-arcade-prompt {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  /* The card centers itself with auto margins: align-items:center would clip
     the top of a card taller than the stage (a game-over card on a short
     phone) and leave it unreachable by scrolling. */
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  background: color-mix(in oklab, var(--paper) 72%, transparent);
  z-index: 4;
}
.gms-arcade-prompt__card {
  width: 100%;
  max-width: 440px;
  margin: auto;
  padding: clamp(20px, 3vw, 32px);
  border-radius: var(--radius-lg, 10px);
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: gms-arcade-rise 320ms var(--ease-out, ease) both;
}
.gms-arcade-prompt__card.is-compact { max-width: 360px; padding: 18px 22px; }
@media (prefers-reduced-motion: reduce) { .gms-arcade-prompt__card { animation: none; } }
.gms-arcade-prompt__kicker {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.gms-arcade-prompt__kicker[hidden] { display: none; }
.gms-arcade-prompt__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.gms-arcade-prompt__text { margin: 0; font-size: 15px; line-height: 1.5; color: var(--ink-soft); max-width: 36ch; }
.gms-arcade-prompt__text[hidden] { display: none; }
.gms-arcade-prompt__board { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.gms-arcade-prompt__board:empty { display: none; }
.gms-arcade-prompt__actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.gms-arcade-prompt__actions[hidden] { display: none; }
.gms-arcade-overlay .btn { border-radius: var(--radius, 6px); min-height: 44px; font-size: 1rem; }
.gms-arcade-overlay .btn--ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.gms-arcade-overlay .btn--ghost:hover { background: var(--sage-mist); }
.gms-arcade-overlay .btn:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }

/* Run summary: two-column definition list above the board. */
.gms-arcade-summary {
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 18px;
  margin: 0;
  font-size: 14px;
}
.gms-arcade-summary dt { color: var(--ink-muted); text-align: right; }
.gms-arcade-summary dd { margin: 0; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; text-align: left; }
.gms-arcade-summary__board { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.gms-arcade-summary__board:empty { display: none; }

/* Chapter and mode choices on a start card. */
.gms-arcade-choices { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.gms-arcade-choice {
  min-height: 44px;
  padding: 0 14px;
  touch-action: manipulation;
  border-radius: var(--radius, 6px);
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.gms-arcade-choice[aria-pressed="true"] { background: var(--forest); color: var(--on-forest); border-color: var(--forest); }
.gms-arcade-choice:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }

.gms-arcade-help {
  flex: 0 0 auto;
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink-muted);
  text-align: center;
}
.gms-arcade-help:empty { display: none; }

/* ---------- Local leaderboard ---------- */
.gms-arcade-lb { width: 100%; max-width: 280px; margin: 0 auto; pointer-events: none; }
.gms-arcade-lb__title {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  text-align: center;
}
.gms-arcade-lb__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.gms-arcade-lb__row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px;
  font-size: 14px;
  padding: 3px 10px;
  border-radius: var(--radius-sm, 4px);
}
.gms-arcade-lb__row.is-you { background: var(--sage-mist); }
.gms-arcade-lb__who { font-weight: 600; color: var(--ink); letter-spacing: 0.04em; }
.gms-arcade-lb__pts { font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.gms-arcade-lb__empty { font-size: 14px; color: var(--ink-muted); text-align: center; }

/* ---------- Initials entry ---------- */
.gms-arcade-initials { pointer-events: auto; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.gms-arcade-initials__label { font-size: 14px; font-weight: 600; color: var(--ink); }
.gms-arcade-initials__row { display: flex; gap: 8px; }
.gms-arcade-initials__input {
  width: 5rem;
  font-family: var(--font-body);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.35em;
  text-align: center;
  text-transform: uppercase;
  text-indent: 0.35em;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius, 6px);
  background: var(--paper);
  color: var(--ink);
}
.gms-arcade-initials__input:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }

/* ---------- Touch controls ---------- */
.gms-arcade-touchrow {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  justify-content: center;
}
.gms-arcade-touchrow[hidden] { display: none; }
.gms-arcade-touchbtn {
  flex: 1 1 0;
  min-width: 64px;
  max-width: 150px;
  min-height: 50px;
  padding: 8px 14px;
  border-radius: var(--radius, 6px);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: pointer;
  transition: transform 80ms ease, background-color 80ms ease;
}
.gms-arcade-touchbtn.is-wide { max-width: 220px; flex-grow: 2; }
.gms-arcade-touchbtn:active,
.gms-arcade-touchbtn.is-held {
  background: var(--forest);
  color: var(--on-forest);
  border-color: var(--forest);
  transform: scale(0.96);
}
@media (prefers-reduced-motion: reduce) {
  .gms-arcade-touchbtn { transition: none; }
  .gms-arcade-touchbtn:active,
  .gms-arcade-touchbtn.is-held { transform: none; }
}

/* ---------- Floating virtual stick (GMSArcade.makeStick) ---------- */
.gms-arcade-stick {
  position: absolute;
  width: 96px;
  height: 96px;
  margin: -48px 0 0 -48px;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--forest) 45%, transparent);
  background: color-mix(in oklab, var(--surface) 30%, transparent);
  pointer-events: none;
  z-index: 3;
}
.gms-arcade-stick__nub {
  position: absolute;
  top: 50%; left: 50%;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--forest) 70%, transparent);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* Precise pointers (mouse) hide the on-screen controls. */
@media (hover: hover) and (pointer: fine) {
  .gms-arcade-touchrow { display: none; }
}
/* Touch screens hide the keyboard help line: it is keyboard hints, and the
   height goes to the field. The dialog's description still reads it. */
@media (hover: none) and (pointer: coarse) {
  .gms-arcade-help { display: none; }
}

/* ---------- DOM games (the daily puzzles) ---------- */
/* They put a .gms-arcade-board in the stage instead of a canvas. */
.gms-arcade-board {
  width: 100%;
  max-width: 520px;
  max-height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 4px;
  outline: none;
}
/* A short stage must scroll the board, never squash it: a grid with
   overflow:hidden would otherwise shrink to nothing as a flex child. */
.gms-arcade-board > * { flex-shrink: 0; }
.gms-arcade-board:focus-visible { box-shadow: inset 0 0 0 2px var(--forest); border-radius: var(--radius-lg, 10px); }
.daily__meta { margin: 0; font-size: 13px; color: var(--ink-muted); text-align: center; }
.daily__share {
  margin: 0;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 14px;
  line-height: 1.25;
  letter-spacing: 1px;
  color: var(--ink);
  background: var(--paper);
  padding: 8px 12px;
  border-radius: var(--radius, 6px);
}
.daily__next { margin: 0; font-size: 13px; color: var(--ink-muted); }
.daily__stats { display: flex; gap: 18px; justify-content: center; font-size: 14px; }

/* Five Letters: tiles and keyboard. Color plus a glyph for every state. */
.five__grid { display: flex; flex-direction: column; gap: 6px; }
.five__row { display: flex; gap: 6px; }
.five__row.is-shake { animation: five-shake 420ms ease; }
@keyframes five-shake { 0%, 100% { transform: none; } 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
.five__tile {
  position: relative;
  width: clamp(44px, 11vw, 58px);
  height: clamp(44px, 11vw, 58px);
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--border);
  border-radius: var(--radius, 6px);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: clamp(1.25rem, 5vw, 1.75rem);
  text-transform: uppercase;
  user-select: none;
}
.five__tile.is-filled { border-color: var(--ink-muted); }
.five__tile.is-pop { animation: five-pop 110ms ease; }
@keyframes five-pop { 50% { transform: scale(1.08); } }
.five__tile.is-reveal { animation: five-flip 520ms ease; }
@keyframes five-flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
.five__tile.is-correct { background: var(--forest); border-color: var(--forest); color: var(--on-forest); }
.five__tile.is-present { background: var(--note-amber); border-color: var(--note-amber); color: var(--ink); }
[data-theme="dark"] .five__tile.is-present { color: #0E1A16; }
.five__tile.is-absent { background: var(--surface-2); border-color: var(--surface-2); color: var(--ink-muted); }
.five__tile.is-correct::after,
.five__tile.is-present::after {
  position: absolute; top: 2px; right: 5px;
  font-size: 11px; line-height: 1; font-weight: 700; opacity: 0.9;
}
.five__tile.is-correct::after { content: "✓"; }
.five__tile.is-present::after { content: "•"; font-size: 16px; top: 0; }
.five__kb { display: flex; flex-direction: column; gap: 6px; align-items: center; width: 100%; }
.five__kbrow { display: flex; gap: 5px; justify-content: center; width: 100%; }
.five__key {
  flex: 0 1 auto;
  min-width: clamp(28px, 8vw, 42px);
  height: 48px;
  padding: 0 6px;
  border-radius: var(--radius-sm, 4px);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.five__key.is-wide { min-width: clamp(48px, 13vw, 66px); font-size: 12px; }
.five__key:active { transform: scale(0.96); }
.five__key:focus-visible { outline: 2px solid var(--forest); outline-offset: 1px; }
.five__key.is-correct { background: var(--forest); border-color: var(--forest); color: var(--on-forest); }
.five__key.is-present { background: var(--note-amber); border-color: var(--note-amber); color: var(--ink); }
[data-theme="dark"] .five__key.is-present { color: #0E1A16; }
.five__key.is-absent { background: var(--surface-2); border-color: var(--surface-2); color: var(--ink-muted); }
@media (prefers-reduced-motion: reduce) {
  .five__row.is-shake, .five__tile.is-pop, .five__tile.is-reveal { animation: none; }
}
.five__kb { max-width: 100%; }
@media (max-width: 400px) {
  .five__tile { width: 48px; height: 48px; }
  .five__key { min-width: 30px; padding: 0 4px; height: 46px; }
}
/* 320px phones: ten keys and nine gaps must fit 296px. */
@media (max-width: 340px) {
  .five__kbrow { gap: 4px; }
  .five__key { min-width: 26px; padding: 0 2px; font-size: 13px; }
  .five__key.is-wide { min-width: 40px; font-size: 11px; }
}
/* Short screens: smaller tiles so grid and keyboard share the stage. */
@media (max-height: 640px) {
  .five__tile { width: 38px; height: 38px; font-size: 1.15rem; }
  .five__grid, .five__row { gap: 5px; }
  .five__key { height: 42px; }
}

/* Groupings: a 4x4 of word tiles, solved bands above, controls below. */
.daily-groups { max-width: 560px; }
.groups__solved { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.groups__solved:empty { display: none; }
.groups__band {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 12px;
  border-radius: var(--radius, 6px);
  border: 1px solid var(--border);
  background: var(--surface);
  text-align: center;
  animation: gms-arcade-rise 320ms var(--ease-out, ease) both;
}
.groups__band-title { font-family: var(--font-display); font-weight: 500; font-size: 1.1rem; color: var(--ink); letter-spacing: -0.01em; }
.groups__band-words { font-size: 13px; color: var(--ink-soft); letter-spacing: 0.04em; }
.groups__band.is-level-1 { background: var(--sage-mist); }
.groups__band.is-level-2 { background: var(--sage); color: var(--on-sage); }
.groups__band.is-level-2 .groups__band-title, .groups__band.is-level-2 .groups__band-words { color: var(--on-sage); }
.groups__band.is-level-3 { background: color-mix(in oklab, var(--note-amber) 55%, var(--surface)); }
.groups__band.is-level-4 { background: color-mix(in oklab, var(--research) 32%, var(--surface)); }
.groups__band::before { content: ""; width: 10px; height: 10px; border-radius: 999px; background: var(--ink); opacity: 0.55; margin-bottom: 2px; }
.groups__band.is-level-1::before { border-radius: 2px; }
.groups__band.is-level-2::before { clip-path: polygon(50% 0, 100% 100%, 0 100%); border-radius: 0; }
.groups__band.is-level-3::before { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); border-radius: 0; }
.groups__grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; width: 100%; }
.groups__grid.is-shake { animation: five-shake 420ms ease; }
.groups__word {
  min-height: 60px;
  padding: 6px 4px;
  border-radius: var(--radius, 6px);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: clamp(11px, 2.6vw, 15px);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.1;
  overflow-wrap: normal;
  word-break: keep-all;
  hyphens: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: background-color 120ms ease, transform 80ms ease;
}
.groups__word.is-long { font-size: clamp(9px, 2.2vw, 12px); letter-spacing: 0; padding-inline: 2px; }
.groups__word.is-xlong { font-size: clamp(8px, 1.9vw, 10px); letter-spacing: 0; padding-inline: 1px; }
.groups__word:active { transform: scale(0.97); }
.groups__word.is-selected { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.groups__word:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }
.groups__mistakes { margin: 0; font-size: 13px; color: var(--ink-muted); letter-spacing: 0.15em; }
.groups__controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.groups__ctl {
  min-height: 44px; padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
}
.groups__ctl.is-primary { background: var(--forest); border-color: var(--forest); color: var(--on-forest); }
.groups__ctl:disabled { opacity: 0.45; cursor: default; }
.groups__ctl:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .groups__band, .groups__grid.is-shake { animation: none; } }

/* Letter Nest: a hive of seven hex cells, an input line, found words. */
.daily-nest { max-width: 520px; }
.nest__input {
  min-height: 44px;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 6vw, 2rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  border-bottom: 2px solid var(--border);
  min-width: 200px;
  padding: 0 8px 2px;
}
.nest__input .is-center { color: var(--forest); }
.nest__input .nest__caret { display: inline-block; width: 2px; height: 1.1em; background: var(--forest); margin-left: 2px; animation: nest-caret 1s steps(2) infinite; }
@keyframes nest-caret { 50% { opacity: 0; } }
.nest__hive { position: relative; width: 236px; height: 212px; margin: 4px auto; }
.nest__cell {
  position: absolute;
  width: 76px; height: 68px;
  display: flex; align-items: center; justify-content: center;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  background: var(--surface-2);
  color: var(--ink);
  border: 0;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.4rem;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
  transition: transform 80ms ease;
}
.nest__cell:active { transform: scale(0.94); }
.nest__cell.is-center { background: var(--forest); color: var(--on-forest); }
.nest__cell:focus-visible { outline: 2px solid var(--forest); outline-offset: 3px; }
.nest__cell[data-pos="0"] { left: 80px; top: 72px; }
.nest__cell[data-pos="1"] { left: 80px; top: 0; }
.nest__cell[data-pos="2"] { left: 142px; top: 36px; }
.nest__cell[data-pos="3"] { left: 142px; top: 108px; }
.nest__cell[data-pos="4"] { left: 80px; top: 144px; }
.nest__cell[data-pos="5"] { left: 18px; top: 108px; }
.nest__cell[data-pos="6"] { left: 18px; top: 36px; }
.nest__controls { display: flex; gap: 8px; justify-content: center; }
.nest__rank { width: 100%; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-soft); }
.nest__rank strong { color: var(--ink); white-space: nowrap; }
.nest__rankbar { flex: 1; height: 4px; border-radius: 999px; background: var(--surface-2); position: relative; }
.nest__rankbar span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--forest); transition: width 240ms ease; }
.nest__rank .nest__pts { font-variant-numeric: tabular-nums; white-space: nowrap; }
.nest__found {
  width: 100%;
  min-height: 44px;
  max-height: 120px;
  overflow-y: auto;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius, 6px);
  background: var(--surface);
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.6;
}
.nest__found span { display: inline-block; margin-right: 10px; text-transform: capitalize; }
.nest__found .is-pangram { color: var(--forest); font-weight: 600; }
.nest__found .is-pangram::after { content: " ✦"; }
@media (prefers-reduced-motion: reduce) { .nest__input .nest__caret { animation: none; } }

/* ---------- Phones ---------- */
@media (max-width: 700px) {
  .gms-arcade-panel { padding: calc(10px + env(safe-area-inset-top, 0px)) calc(12px + env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) calc(12px + env(safe-area-inset-left, 0px)); gap: 8px; }
  .gms-arcade-panel__head { align-items: center; padding-bottom: 8px; }
  .gms-arcade-title { font-size: 1.15rem; }
  .gms-arcade-title span { display: none; }
  .gms-arcade-scores { gap: 2px 14px; font-size: 11px; }
  .gms-arcade-scores strong, .gms-arcade-hud__value { font-size: 14px; }
  .gms-arcade-help { font-size: 12px; }
  .gms-arcade-touchrow { flex-wrap: wrap; gap: 6px; }
  /* Five buttons share a 320px row (52px each); six wrap one onto a second row. */
  .gms-arcade-touchbtn { min-width: 52px; padding: 6px 6px; font-size: 12px; white-space: nowrap; }
  .gms-arcade-pips { top: 6px; left: 6px; }
  .gms-arcade-pip { min-width: 0; font-size: 10px; padding: 3px 8px 5px; }
  .gms-arcade-prompt { padding: 10px; }
  .gms-arcade-prompt__card { padding: 18px 16px; }
}

/* Phones held sideways: the head and HUD stack in a column on the left, the
   touch buttons in a column on the right, and the whole height goes to the
   play field. (The old single column gave a portrait field half the height.) */
@media (max-height: 480px) and (orientation: landscape) {
  .gms-arcade-panel {
    display: grid;
    grid-template-columns: minmax(88px, 118px) minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "head stage touch" "hud stage touch";
    column-gap: 10px;
    row-gap: 8px;
    align-items: start;
    padding: calc(8px + env(safe-area-inset-top, 0px)) calc(10px + env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) calc(10px + env(safe-area-inset-left, 0px));
  }
  .gms-arcade-panel__head { grid-area: head; flex-direction: column; align-items: flex-start; gap: 8px; padding-bottom: 0; border-bottom: 0; margin: 0; }
  .gms-arcade-title { font-size: 1rem; }
  .gms-arcade-title span { display: none; }
  .gms-arcade-head__actions { gap: 6px; }
  .gms-arcade-scores { grid-area: hud; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 4px; font-size: 10px; text-align: left; }
  .gms-arcade-scores strong, .gms-arcade-hud__value { font-size: 13px; }
  .gms-arcade-help { display: none; }
  .gms-arcade-stage { grid-area: stage; align-self: stretch; }
  .gms-arcade-touchrow { grid-area: touch; flex-direction: column; flex-wrap: nowrap; justify-content: center; align-self: stretch; gap: 6px; }
  .gms-arcade-touchbtn, .gms-arcade-touchbtn.is-wide { flex: 0 0 auto; width: 100%; min-width: 60px; max-width: 96px; min-height: 44px; padding: 4px 6px; font-size: 12px; }
  .gms-arcade-iconbtn, .gms-arcade-close { width: 44px; height: 44px; }
  .gms-arcade-prompt { padding: 8px; }
  .gms-arcade-prompt__card { padding: 14px 16px; gap: 6px; }
  .gms-arcade-prompt__title { font-size: 1.3rem; }
  .gms-arcade-prompt__text { font-size: 14px; }
}

/* Six Sudoku: a 6x6 grid with 2x3 boxes, a digit pad, tools. */
.daily-six { max-width: 440px; }
.six__grid { display: flex; flex-direction: column; border: 2px solid var(--ink); border-radius: var(--radius-sm, 4px); overflow: hidden; background: var(--surface); }
.six__row { display: flex; }
.six__cell {
  position: relative;
  width: clamp(44px, 12vw, 58px);
  height: clamp(44px, 12vw, 58px);
  display: flex; align-items: center; justify-content: center;
  border: 0;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--forest);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: clamp(1.25rem, 5vw, 1.6rem);
  cursor: pointer;
  padding: 0;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
.six__cell.is-box-right { border-right: 2px solid var(--ink); }
.six__cell.is-box-bottom { border-bottom: 2px solid var(--ink); }
.six__row:last-child .six__cell { border-bottom: 0; }
.six__cell:last-child { border-right: 0; }
.six__cell.is-fixed { color: var(--ink); font-weight: 600; }
.six__cell.is-peer { background: var(--paper-2); }
.six__cell.is-same { background: var(--sage-mist); }
.six__cell.is-selected { background: var(--sage-mist-2); box-shadow: inset 0 0 0 2px var(--forest); }
.six__cell.is-conflict .six__value { color: var(--danger); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.six__cell.is-wrong { background: color-mix(in oklab, var(--note-warm) 22%, var(--surface)); }
.six__cell.is-wrong .six__value { color: var(--clay-text); }
.six__cell:focus-visible { outline: 2px solid var(--forest); outline-offset: -2px; }
.six__notes { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; height: 100%; padding: 3px; }
.six__notes i { font-style: normal; font-size: 10px; line-height: 1; color: var(--ink-muted); display: flex; align-items: center; justify-content: center; }
.six__pad { display: flex; gap: 6px; }
.six__digit {
  width: clamp(40px, 11vw, 52px); height: 48px;
  border-radius: var(--radius, 6px);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body); font-size: 1.2rem; font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.six__digit.is-done { opacity: 0.35; }
.six__digit:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }
.six__tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.six__tools .groups__ctl[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

/* Little Crossword: numbered squares, a clue bar, clue lists, tools. */
.daily-mini { max-width: 560px; }
.mini__clue { width: 100%; min-height: 44px; padding: 8px 12px; border-radius: var(--radius, 6px); background: var(--sage-mist); color: var(--ink); font-size: 15px; line-height: 1.4; text-align: center; }
.mini__clue strong { color: var(--forest); }
.mini__grid { --n: 5; display: flex; flex-direction: column; border: 2px solid var(--ink); border-radius: var(--radius-sm, 4px); overflow: hidden; background: var(--ink); gap: 1px; }
.mini__row { display: flex; gap: 1px; }
.mini__cell {
  position: relative;
  width: clamp(48px, 13vw, 62px);
  height: clamp(48px, 13vw, 62px);
  display: flex; align-items: center; justify-content: center;
  border: 0; padding: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: clamp(1.25rem, 5vw, 1.6rem);
  text-transform: uppercase;
  cursor: pointer;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
.mini__cell.is-black { background: var(--ink); cursor: default; }
.mini__cell.is-word { background: var(--sage-mist); }
.mini__cell.is-selected { background: var(--note-amber); color: var(--ink); }
[data-theme="dark"] .mini__cell.is-selected { color: #0E1A16; }
.mini__cell.is-wrong .mini__letter { color: var(--danger); text-decoration: line-through; }
.mini__cell:focus-visible { outline: 2px solid var(--forest); outline-offset: -3px; }
.mini__num { position: absolute; top: 2px; left: 4px; font-size: 10px; font-weight: 600; color: var(--ink-muted); }
.mini__cell.is-selected .mini__num { color: var(--ink); }
.mini__tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.mini__lists { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; width: 100%; }
.mini__listhead { margin: 0 0 4px; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); }
.mini__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.mini__cluebtn { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; text-align: left; padding: 6px 8px; border: 0; touch-action: manipulation; border-radius: var(--radius-sm, 4px); background: transparent; color: var(--ink); font-family: var(--font-body); font-size: 14px; line-height: 1.35; cursor: pointer; }
.mini__cluenum { flex: 0 0 1.4em; font-weight: 600; color: var(--ink-muted); }
.mini__clueitem.is-current .mini__cluebtn { background: var(--sage-mist); }
.mini__clueitem.is-done .mini__cluetext { color: var(--ink-muted); text-decoration: line-through; text-decoration-color: var(--border); }
.mini__cluebtn:focus-visible { outline: 2px solid var(--forest); outline-offset: 1px; }
.mini__kb[hidden] { display: none; }
@media (max-width: 480px) { .mini__lists { grid-template-columns: 1fr; } .mini__cluebtn { font-size: 13px; } }

/* Phones held sideways, the puzzle boards: smaller cells and no meta line, so
   a board fits a stage about 360px tall. After every board's base rules so
   these win on equal specificity. */
@media (max-height: 480px) and (orientation: landscape) {
  .daily__meta { display: none; }
  .gms-arcade-board { gap: 8px; }
  .five__tile { width: 34px; height: 34px; font-size: 1.05rem; }
  .five__grid, .five__row { gap: 4px; }
  .five__key { height: 38px; min-width: 30px; }
  .six__cell { width: 42px; height: 42px; font-size: 1.2rem; }
  .six__digit { height: 44px; }
  .mini__cell { width: 42px; height: 42px; font-size: 1.15rem; }
  .mini__clue { min-height: 40px; padding: 6px 10px; font-size: 14px; }
  .groups__word { min-height: 46px; }
  .nest__hive { transform: scale(0.82); transform-origin: top center; height: 176px; }
  .nest__found { max-height: 72px; }
}

/* =========================================================================
   The hub page (/arcade/): the Daily band and the games grid. Card art is
   inline SVG colored by these classes, so it follows the theme.
   ========================================================================= */
.ar-head { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 16px clamp(32px, 5vw, 80px); align-items: end; margin-bottom: clamp(28px, 4vw, 48px); }
.ar-head h2 { font-size: clamp(1.75rem, 1.3rem + 1.6vw, 2.75rem); line-height: 1.05; }
.ar-head p { color: var(--ink-soft); max-width: 42ch; margin: 0; }
@media (max-width: 760px) { .ar-head { grid-template-columns: minmax(0, 1fr); } }

.ar-daily-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.ar-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
@media (max-width: 1100px) { .ar-daily-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) { .ar-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .ar-grid, .ar-daily-grid { grid-template-columns: minmax(0, 1fr); } }

.ar-card {
  display: flex; flex-direction: column; min-width: 0;
  border-radius: var(--radius-lg, 10px);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  overflow: hidden;
}
.hub-sec--white .ar-card { background: var(--paper); }
.ar-card__art { aspect-ratio: 3 / 2; background: var(--sage-mist); display: flex; align-items: center; justify-content: center; padding: 10px 18px; }
.ar-card--daily .ar-card__art { aspect-ratio: 2 / 1; padding: 8px 20px; }
.ar-card__art svg { width: 100%; height: 100%; max-height: 150px; overflow: visible; }
.ar-t { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.ar-t rect, .ar-t path, .ar-t circle { fill: var(--surface); }
.ar-t .ar-f { fill: var(--forest); }
.ar-t .ar-s { fill: var(--sage); }
.ar-t .ar-m { fill: var(--surface); }
.ar-t .ar-i { fill: var(--sage-mist-2); }
.ar-t .ar-o { fill: var(--note-amber); }
.ar-t .ar-k { fill: var(--ink); }
.ar-t .ar-k2 { fill: var(--research); }
.ar-t .ar-body { fill: none; stroke: var(--forest); stroke-width: 11; }
.ar-t .ar-eye { fill: var(--surface); stroke: var(--ink); stroke-width: 0.9; }
.ar-t .ar-leaf { fill: var(--sage-deep); }
.ar-t .ar-dash { fill: none; stroke: var(--ink-muted); stroke-dasharray: 4 4; }
.ar-t .ar-trail { fill: var(--note-amber); fill-opacity: 0.35; stroke: none; }
.ar-t .ar-ground { fill: none; stroke-width: 2; }
.ar-t .ar-q { fill: var(--on-forest); stroke: none; font-family: var(--font-display); font-size: 14px; font-weight: 500; }
.ar-t .ar-card-m { fill: var(--surface); stroke: var(--note-warm); }
.ar-t .ar-pl { fill: var(--surface); }
.ar-t .ar-ring { fill: none; stroke: var(--forest); stroke-width: 2; }
.ar-t .ar-dot { fill: var(--ink-muted); stroke: none; }
.ar-t .ar-face { fill: var(--surface); }
.ar-t .ar-wall { fill: none; stroke: var(--sage-deep); stroke-width: 5; }
.ar-t .ar-n { fill: var(--ink); stroke: none; font-family: var(--font-body); font-size: 9px; font-weight: 600; }
.ar-t .ar-n.ar-nf { fill: var(--forest); }
.ar-t .ar-k2 + text { fill: var(--ink); }
[data-theme="dark"] .ar-t .ar-q { fill: var(--on-forest); }

.ar-card__body { display: flex; flex: 1; flex-direction: column; padding: clamp(18px, 2.2vw, 26px); }
.fg .ar-card h3 { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.25rem, 1.1rem + 0.5vw, 1.6rem); line-height: 1.12; letter-spacing: -0.01em; margin: 0; }
.fg .ar-card p { margin: 8px 0 0; color: var(--ink-soft); font-size: 15px; line-height: 1.45; }
.fg .ar-card p.ar-card__chip {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  margin-top: 12px; padding: 4px 10px;
  border-radius: 999px;
  background: var(--sage-mist);
  color: var(--ink);
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
}
.fg .ar-card p.ar-card__chip.is-done { background: var(--forest); color: var(--on-forest); }
.fg .ar-card p.ar-card__chip.is-empty { background: transparent; color: var(--ink-muted); padding-inline: 0; }
.fg .ar-card__play { margin-top: auto; padding-top: 0; width: 100%; justify-content: space-between; }
.fg .ar-card__body .ar-card__play { margin-top: 18px; }
.ar-card__play span { font-weight: 400; }
.ar-card__play.is-loading { cursor: progress; }
.ar-card__play.is-loading span { display: none; }
.ar-card__play.is-loading::after { content: "Loading\2026"; font-weight: 400; font-size: 14px; }
.ar-card .gms-arcade-load-error { margin-top: 12px; font-size: 14px; color: var(--ink); }
.arcade-page .gms-arcade-title span { display: none; }
