/* Sixillion: waterfront in pixel art. */

@font-face {
  font-family: "Pixelify Sans";
  src: url("/fonts/pixelify-sans-latin-wght.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
/* Reading text: a clean grotesk with a slightly technical edge, so it sits comfortably next to the pixel faces. */
@font-face {
  font-family: "Space Grotesk";
  src: url("/fonts/space-grotesk-latin-wght.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Silkscreen";
  src: url("/fonts/silkscreen-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Silkscreen";
  src: url("/fonts/silkscreen-latin-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in: cubic-bezier(.7, 0, .84, 0);
  /* sky (also drawn by lib/scene.js; these are the CSS fallback and the panel tints) */
  --sky-1: #4FA9E6;
  --sky-2: #6CBDEF;
  --sky-3: #92D1F5;
  --sky-4: #C4E7FA;
  --lake: #2A5FA8;

  /* ink: everything readable is navy */
  --ink: #14205C;
  --ink-2: #3A4682;
  --panel: rgba(246, 251, 255, .98);
  --panel-solid: #F6FBFF;
  --tint: #E3F2FC;          /* insets inside panels: prompt window, feedback bubble, chips */
  --frame: var(--ink);
  --frame-shadow: rgba(12, 20, 64, .55);
  --accent: #FFC93C;        /* the one warm UI colour: primary action, timer, your answer */
  --accent-shade: #C98A12;
  --miss: #C42B2B;
  --ok: #1D6E45;
  --on-sky: var(--ink);     /* text that sits straight on the sky (header) */
  --wing: #FF6B57;          /* home wordmark and wings, in the Sixillion tier's coral; decoration, never text */
  --wing-shade: #C8432F;
  --navy: var(--ink);       /* the home wordmark's keyline */
  --paper: #FFF6E2;         /* ... and its letters */

  /* Tier colours follow the share-text squares (🟦 tourist, 🟪 too clever, 🟩 local, 🟨 born here,
     🟧 deep cut, 🟥 sixillion) so the copied grid matches the screen. Each has a darker edge so tiles read
     as raised blocks. Icons + words carry the meaning; colour is never the only signal. */
  --t-sixillion: #FF7B6B; --t-sixillion-edge: #B83A2E;
  --t-deepcut: #FFA640;   --t-deepcut-edge: #B8650D;
  --t-bornhere: #FFE066;  --t-bornhere-edge: #957A0C;
  --t-local: #5FD08F;     --t-local-edge: #23824C;
  --t-tooclever: #C4A6F7; --t-tooclever-edge: #7553B8;
  --t-tourist: #7CC6F2;   --t-tourist-edge: #2D7DB8;

  --px: 4px;                /* one art pixel for UI frames */
  --font: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-pixel: "Pixelify Sans", var(--font);
  --font-hud: "Silkscreen", ui-monospace, Menlo, Consolas, monospace;
  --font-num: var(--font);   /* scores: plain, open digits (Pixelify's bold 9 reads as an S) */
  color-scheme: light;
}
@media (max-width: 399px) { :root { --px: 3px; } }
/* The other skies' bands (lib/scene.js PALETTES). The page background under the canvas uses them, and newer
   phone Safari colours its top and bottom bars from it. */
html[data-sky="dusk"] { --sky-1: #5B6FB3; --sky-2: #9581C1; --sky-3: #C193BB; --sky-4: #F8CDA2; --lake: #50568F; }
html[data-sky="night"] { --sky-1: #0E0E33; --sky-2: #19194A; --sky-3: #201E56; --sky-4: #393373; --lake: #0C0B28; }
body[data-sky="night"] { --on-sky: var(--panel-solid); }
/* The scene reports how bright the strip behind the header is (lib/scene.js): focus rings on the header
   follow it. During a run the scenery behind the header can be anything (sky, the pod's lit ring, tiles,
   a dark ceiling), so the brand and the puzzle label sit on small navy plates, like the date plate on Home. */
body[data-tone="light"] { --on-sky: var(--ink); }
body[data-tone="dark"] { --on-sky: var(--panel-solid); }
body[data-scene="descent"] .brand, body[data-scene="descent"] .puzzle-label {
  color: var(--panel-solid); background: var(--ink); box-shadow: 0 3px 0 var(--frame-shadow);
}
body[data-scene="descent"] .brand { padding: 5px 12px 5px 9px; }
body[data-scene="descent"] .puzzle-label { padding: 7px 10px 6px; }
body[data-scene="descent"] .topbar :focus-visible { outline-color: var(--ink); }

* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  /* Fallback sky if the canvas can't draw: flat bands, never a smooth gradient. */
  background:
    linear-gradient(180deg, var(--sky-1) 0 24%, var(--sky-2) 24% 45%, var(--sky-3) 45% 64%, var(--sky-4) 64% 80%, var(--lake) 80%)
    fixed;
  background-color: var(--sky-3);
}
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font: 16px/1.55 var(--font);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.1; }
p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--ink); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.fine { color: var(--ink-2); font-size: .875rem; }
.hud { font-family: var(--font-hud); font-size: 16px; line-height: 1.2; letter-spacing: 0; text-transform: uppercase; }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: var(--ink); }

.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;
}
.skip { position: absolute; left: -999px; top: 8px; z-index: 30; background: var(--accent); color: var(--ink); padding: 8px 12px; font-weight: 700; }
.skip:focus { left: 8px; }

/* Focus: always visible, never colour-only. Offset clears the pixel frame drawn outside boxes. */
:focus-visible { outline: 3px solid var(--ink); outline-offset: calc(var(--px) + 3px); }
h1:focus, main:focus { outline: none; }
.topbar :focus-visible { outline-color: var(--on-sky); }

/* ---------- the scene ---------- */
.scene { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.scene canvas {
  position: absolute; left: 0; bottom: 0; display: block;
  image-rendering: pixelated; image-rendering: crisp-edges;
  opacity: 0;
}
.scene.is-ready canvas { opacity: 1; }
.scene canvas { transition: filter .3s ease; }
.scene.is-dim canvas { filter: saturate(.7) brightness(1.06); }
/* The CRT is a whisper: faint scanlines on the scene only, never over text. */
.scene::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(12, 20, 64, .06) 0 1px, transparent 1px 3px);
}

/* ---------- pixel boxes ----------
   A box is its fill plus a frame of four hard shadows, one per side, that leave the outer corners empty;
   four corner squares in the background fill the inner corners. Result: a one-step rounded pixel frame
   with no images. Set --f (frame) and --fill per component. */
.panel, .btn, .icon-btn, .badge, .tile, .answer-form input, .report-row input, .timer-segs, .toast,
.chip-mine, .share-fallback, .notice, .wing-label, .home-stats {
  --f: var(--frame);
  --fill: var(--panel-solid);
  --ring: 0 calc(var(--px) * -1) 0 0 var(--f), 0 var(--px) 0 0 var(--f), calc(var(--px) * -1) 0 0 0 var(--f), var(--px) 0 0 0 var(--f);
  --drop: 0 calc(var(--px) * 2) 0 0 var(--frame-shadow);
  background:
    linear-gradient(var(--f) 0 0) 0 0 / var(--px) var(--px) no-repeat,
    linear-gradient(var(--f) 0 0) 100% 0 / var(--px) var(--px) no-repeat,
    linear-gradient(var(--f) 0 0) 0 100% / var(--px) var(--px) no-repeat,
    linear-gradient(var(--f) 0 0) 100% 100% / var(--px) var(--px) no-repeat,
    var(--fill);
  box-shadow: var(--ring);
  border: 0;
  border-radius: 0;
}

.panel { --fill: var(--panel); box-shadow: var(--ring), var(--drop); padding: 20px 18px; margin: var(--px) var(--px) calc(var(--px) * 3 + 14px); }
.panel > :first-child { margin-top: 0; }

/* ---------- header ---------- */
.topbar {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1040px; margin: 0 auto; padding: 14px 18px 10px;
  color: var(--on-sky);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--on-sky); text-decoration: none; }
.brand-mark { width: 40px; height: 30px; flex: none; }
.brand-word { font: 700 28px/1 var(--font-pixel); letter-spacing: .01em; }
.topbar-end { display: flex; align-items: center; gap: 14px; }
.puzzle-label { font-family: var(--font-hud); font-size: 16px; text-transform: uppercase; font-variant-numeric: tabular-nums; }
@media (max-width: 399px) { /* narrow phones: the raccoon, the name and the date still fit on one line */
  .topbar .brand { gap: 7px; }
  .brand-mark { width: 30px; height: 23px; }
  .brand-word { font-size: 24px; }
  .topbar .puzzle-label { font-size: 13px; white-space: nowrap; }
  .topbar-end { gap: 8px; }
}

.icon-btn {
  --px: 3px;
  display: inline-grid; place-items: center; width: 40px; height: 40px; margin: 3px; padding: 0;
  color: var(--ink); cursor: pointer;
  box-shadow: var(--ring), 0 6px 0 0 var(--frame-shadow);
}
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:active { transform: translateY(3px); box-shadow: var(--ring); }
.icon-btn[aria-pressed="true"] .snd-off, .icon-btn[aria-pressed="false"] .snd-on { display: none; }

main { position: relative; z-index: 1; max-width: 1040px; margin: 0 auto; padding: 4px 18px 64px; }
/* Screens and cards fade in where they stand: nothing slides or springs into place. */
.screen { animation: enter .55s var(--ease-out) both; }
@keyframes enter { from { opacity: 0; } }
.btn, .icon-btn { transition: transform .18s var(--ease-out), translate .18s var(--ease-out), filter .18s; }
.btn:hover:not(:disabled), .icon-btn:hover { translate: 0 -1px; }

/* ---------- loading ---------- */
.loading { padding: 30vh 0; display: grid; justify-items: center; gap: 18px; color: var(--on-sky); }
.loader { display: flex; gap: 4px; padding: 6px; background: var(--panel-solid); box-shadow: 0 0 0 3px var(--frame); }
.loader i { width: 14px; height: 18px; background: rgba(20, 32, 92, .12); animation: load 1.6s ease-in-out infinite; }
.loader i:nth-child(2) { animation-delay: .2s; } .loader i:nth-child(3) { animation-delay: .4s; }
.loader i:nth-child(4) { animation-delay: .6s; } .loader i:nth-child(5) { animation-delay: .8s; }
.loader i:nth-child(6) { animation-delay: 1s; } .loader i:nth-child(7) { animation-delay: 1.2s; }
.loader i:nth-child(8) { animation-delay: 1.4s; }
@keyframes load { 0% { background: var(--accent); } 50% { background: rgba(20, 32, 92, .12); } }

/* ---------- buttons ---------- */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; margin: var(--px);
  font: 600 1.125rem/1 var(--font-pixel); color: var(--ink); text-decoration: none; cursor: pointer;
  box-shadow: var(--ring), var(--drop);
}
.btn:hover:not(:disabled) { --fill: #FFFFFF; }
.btn:active:not(:disabled) { transform: translateY(var(--px)); box-shadow: var(--ring); }
.btn:disabled { cursor: default; color: var(--ink-2); --f: var(--ink-2); box-shadow: var(--ring); transform: translateY(var(--px)); }
.btn-accent { --fill: var(--accent); }
.btn-accent:hover:not(:disabled) { --fill: #FFD666; }
.btn-ghost { --fill: var(--panel-solid); }
.btn-big { min-height: 60px; font-size: 1.375rem; width: calc(100% - var(--px) * 2); letter-spacing: .02em; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px 10px; margin-top: 20px; }

/* ---------- tiers ---------- */
.tier-sixillion { --tier: var(--t-sixillion); --tier-edge: var(--t-sixillion-edge); }
.tier-deepcut { --tier: var(--t-deepcut); --tier-edge: var(--t-deepcut-edge); }
.tier-bornhere { --tier: var(--t-bornhere); --tier-edge: var(--t-bornhere-edge); }
.tier-local { --tier: var(--t-local); --tier-edge: var(--t-local-edge); }
.tier-tooclever { --tier: var(--t-tooclever); --tier-edge: var(--t-tooclever-edge); }
.tier-tourist { --tier: var(--t-tourist); --tier-edge: var(--t-tourist-edge); }

.badge {
  --px: 2px; --f: var(--tier-edge); --fill: var(--tier);
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 7px; margin: 2px;
  color: var(--ink); font: 600 .9375rem/1.2 var(--font-pixel); white-space: nowrap;
  box-shadow: var(--ring), 0 4px 0 0 var(--tier-edge);
}
.badge .icon { width: 12px; height: 12px; flex: none; }
.badge-sm { font-size: .875rem; padding: 3px 8px 3px 6px; }
.badge-xl { --px: 4px; font-size: 1.5rem; padding: 10px 20px 10px 14px; gap: 10px; box-shadow: var(--ring), 0 8px 0 0 var(--tier-edge); }
.badge-xl .icon { width: 24px; height: 24px; }
.tier-miss.badge { --f: var(--ink-2); --fill: var(--panel-solid); box-shadow: var(--ring); }

.tile {
  --px: 2px; --f: var(--tier-edge); --fill: var(--tier);
  display: inline-grid; place-items: center; width: 36px; height: 36px; margin: 2px;
  color: var(--ink); box-shadow: var(--ring), 0 4px 0 0 var(--tier-edge);
}
.tile .icon { width: 24px; height: 24px; }
.tile.tier-miss { --f: var(--ink-2); --fill: var(--panel-solid); color: var(--ink-2); box-shadow: var(--ring); }

/* ---------- home ----------
   A sign on the sky, centred and symmetric like the TTC emblem it borrows from: a pixel wordmark, a pair of
   red stepped wings around a navy date plate (the emblem's shield), one line of copy and one button.
   How to play opens on demand. The scene behind is untouched. */
.home-main {
  max-width: 620px; margin: 0 auto; padding-top: clamp(8px, 5vh, 56px);
  display: grid; justify-items: center; text-align: center;
}
body[data-screen="home"] .puzzle-label { visibility: hidden; } /* the date is on the sign */

/* Cream letters with a navy keyline, pushed out into a coral-then-navy block; "Six" in the accent yellow. */
.wordmark {
  font: 700 clamp(60px, 15vw, 132px)/.9 var(--font-pixel); letter-spacing: .01em; color: var(--paper);
  text-shadow:
    -3px 0 0 var(--navy), 3px 0 0 var(--navy), 0 -3px 0 var(--navy),
    -3px 3px 0 var(--navy), 3px 3px 0 var(--navy),
    0 6px 0 var(--wing), -3px 6px 0 var(--navy), 3px 6px 0 var(--navy),
    0 9px 0 var(--wing-shade), -3px 9px 0 var(--navy), 3px 9px 0 var(--navy),
    0 12px 0 var(--navy);
}
.wm-six { color: var(--accent); }

.wings { display: flex; align-items: center; justify-content: center; gap: 0; margin: 26px 0 0; }
.wing { width: 88px; height: auto; display: block; flex: none; } /* 2 px per wing pixel */
.wing-r { transform: scaleX(-1); }
.wing .wg-edge { fill: var(--frame); }
.wing .wg-body { fill: var(--wing); }
.wing .wg-shade { fill: var(--wing-shade); }
.wing .wg-stripe { fill: var(--panel-solid); }
.wing-label {
  --px: 3px; --f: var(--ink); --fill: var(--ink);
  margin: 0 var(--px); padding: 9px 14px 8px; white-space: nowrap;
  color: var(--panel-solid); font-variant-numeric: tabular-nums;
}

.home-tag { margin-top: 26px; font: 600 clamp(1.25rem, 3.4vw, 1.625rem)/1.2 var(--font-pixel); color: var(--on-sky); text-wrap: balance; }

/* Start, the two small buttons and the stats share one column width so the stack reads as one object. */
.start, .home-links, .home-stats { width: min(100% - var(--px) * 2, 420px); }
.start { margin-top: 26px; display: grid; gap: 8px; }
.start .btn { width: calc(100% - var(--px) * 2); }

.home-links { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 10px; }
.home-links .btn { padding: 0 6px; font-size: .9375rem; white-space: nowrap; }

.home-stats {
  --px: 3px; --f: var(--ink); --fill: var(--ink);
  display: grid; grid-template-columns: repeat(3, 1fr);
  margin: 22px var(--px) 0; padding: 10px 6px; color: var(--panel-solid);
}
.home-stats div { display: grid; gap: 4px; }
.home-stats div + div { box-shadow: -1px 0 0 rgba(246, 251, 255, .2); }
.home-stats dd { margin: 0; color: var(--accent); }

/* How to play: a modal <dialog> over the home sign. The page behind blurs and dims; Esc, the close
   button or a click outside the panel closes it, and focus returns to the button that opened it. */
.how-dialog {
  width: min(560px, calc(100% - 32px)); max-width: none; max-height: calc(100dvh - 48px);
  margin: auto; padding: 0; overflow: auto; overscroll-behavior: contain;
  color: var(--ink); text-align: left;
}
.how-dialog[open] { animation: pop .32s var(--ease-out) both; }
.how-dialog::backdrop {
  background: rgba(12, 20, 64, .32);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: veil .24s ease both;
}
@keyframes pop { from { transform: translateY(10px); opacity: 0; } }
@keyframes veil { from { opacity: 0; } }
body:has(.how-dialog[open]) { overflow: hidden; }
.how-inner { padding: 22px 20px 20px; }
.how-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.how-head h2 { margin: 6px 0 0; }
.how-close { flex: none; margin: 3px; }
.how-close svg { width: 16px; height: 16px; }
.how-done { margin-top: 18px; }
.section-title, .how h2 { font: 700 1.375rem/1.1 var(--font-pixel); margin-bottom: 14px; }

.how-steps { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; counter-reset: step; }
.how-steps li { color: var(--ink-2); display: grid; grid-template-columns: 22px 1fr; align-items: baseline; counter-increment: step; }
.how-steps li::before { content: counter(step); font: 400 16px/1 var(--font-hud); color: var(--ink); }

.ladder { list-style: none; margin: 22px 0 0; padding: 0; display: grid; gap: 8px 28px; }
.ladder li { display: flex; align-items: center; justify-content: space-between; }
.ladder-pts { font: 600 1rem/1 var(--font-pixel); font-variant-numeric: tabular-nums; }
.ladder-pts::after { content: " pts"; font-weight: 400; color: var(--ink-2); font-size: .8125rem; }
.how-note { margin-top: 18px; padding-top: 12px; border-top: 1px solid rgba(20, 32, 92, .14); }

@media (min-width: 640px) {
  .wing { width: 132px; } /* 3 px per wing pixel */
  .ladder { grid-template-columns: 1fr 1fr; grid-auto-flow: column; grid-template-rows: repeat(3, auto); }
}
@media (min-width: 860px) {
  .wing { width: 176px; } /* 4 px per wing pixel */
  .panel { padding: 28px 30px; }
  .how-dialog.panel { padding: 0; }
  .how-inner { padding: 28px 30px 26px; }
}

/* ---------- play ---------- */
.play, .roundresult { max-width: 640px; margin: 0 auto; }
.play-panel { padding-top: 14px; }
.play-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 0 12px; }
.score-so-far { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.dots { display: flex; gap: 5px; list-style: none; margin: 0; padding: 0; }
.dot { width: 10px; height: 10px; background: rgba(20, 32, 92, .16); }
.dot[class*="tier-"] { background: var(--tier); box-shadow: inset -2px -2px 0 var(--tier-edge); }
.dot.tier-miss { background: transparent; box-shadow: inset 0 0 0 2px var(--ink-2); }
.dot.is-current { background: var(--ink); outline: 2px solid var(--ink); outline-offset: 2px; }

.prompt-card {
  padding: 18px 16px 20px; background: var(--tint);
  box-shadow: inset 0 3px 0 rgba(20, 32, 92, .12);
  min-height: 150px; display: flex; flex-direction: column; justify-content: center;
}
.phase-label { color: var(--ink-2); margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.play[data-phase="open"] .phase-label { color: var(--ink); }
.prompt-text { font: 600 28px/1.2 var(--font); letter-spacing: -.01em; text-wrap: balance; }

.timer { display: flex; align-items: center; gap: 14px; margin: 18px 0 16px; }
.timer-segs { --px: 2px; flex: 1; display: flex; gap: 2px; padding: 3px; height: 22px; }
.timer-segs i { flex: 1; background: var(--accent); box-shadow: inset 0 -3px 0 var(--accent-shade); }
.timer-segs i.off { background: rgba(20, 32, 92, .1); box-shadow: none; }
.play.hurry .timer-segs i:not(.off) { background: var(--miss); box-shadow: inset 0 -3px 0 #7E1A1A; }
.timer-num { min-width: 2.2ch; text-align: right; font-size: 24px; font-variant-numeric: tabular-nums; }
.play.hurry .timer-num { color: var(--miss); }

.answer-form { position: relative; display: flex; gap: 10px; align-items: stretch; }
.answer-form input {
  flex: 1; min-width: 0; height: 52px; padding: 0 14px; margin: var(--px);
  font-size: 1.15rem; caret-color: var(--ink);
}
.answer-form input::placeholder { color: #5E6A9E; }
.answer-form input:focus { --fill: #FFFFFF; outline: none; box-shadow: var(--ring), 0 0 0 calc(var(--px) * 2) var(--accent); }
.answer-form input[readonly] { --fill: var(--tint); }
.answer-form .btn { height: 52px; min-height: 52px; }
.shake { animation: shake .32s ease-in-out; }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }

.feedback { position: relative; min-height: 64px; margin-top: 16px; font-size: 1rem; }
.feedback:empty { visibility: hidden; }
.feedback.fb-miss, .feedback.fb-wrong, .feedback.fb-slow, .feedback.fb-invalid, .feedback.fb-error, .feedback.fb-wait, .feedback.fb-confirm {
  padding: 12px 14px 12px 16px; background: var(--tint); border-left: 6px solid var(--ink-2);
}
/* A stepped speech tail pointing up at the answer box. */
.feedback[class*="fb-"]::before {
  content: ""; position: absolute; top: -9px; left: 22px; width: 12px; height: 9px; background: var(--tint);
  clip-path: polygon(0 100%, 0 66%, 33% 66%, 33% 33%, 66% 33%, 66% 0, 100% 0, 100% 100%);
}
.fb-miss, .fb-error { border-left-color: var(--miss) !important; }
.fb-wrong { border-left-color: var(--t-tooclever-edge) !important; }
.fb-confirm { border-left-color: var(--accent-shade) !important; }
.fb-guess { font-weight: 700; margin-right: 6px; }
.fb-guess::before { content: "\201C"; } .fb-guess::after { content: "\201D"; }
.confirm-actions { display: flex; flex-wrap: wrap; gap: 6px 10px; margin: 8px 0 4px; }
.play-hint { color: var(--ink-2); font-size: .875rem; margin-top: 10px; }

@media (min-width: 640px) {
  .prompt-text { font-size: 36px; }
  .prompt-card { padding: 22px 22px 26px; min-height: 170px; }
}

/* ---------- round result ---------- */
/* One centred column: every row, the button included, shares the same axis. */
.rr-panel, .rr-body { display: flex; flex-direction: column; align-items: center; text-align: center; }
.rr-panel { position: relative; padding: 26px 18px 26px; }
.rr-body { width: 100%; }
.rr-round { color: var(--ink-2); font-size: .9375rem; }
.rr-badge { margin: 20px 0; }
.rr-badge .badge { margin: 0; animation: drop .4s var(--ease-out) both; }
@keyframes drop { from { transform: translateY(-16px); opacity: 0; } }
.rr-answer { max-width: 100%; font: 700 40px/1.05 var(--font-pixel); letter-spacing: 0; text-wrap: balance; overflow-wrap: anywhere; }
.rr-points { margin-top: 10px; font-size: 1.1rem; color: var(--ink-2); }
.rr-points .num { font: 700 2.25rem/1 var(--font-num); color: var(--ink); }
.rr-meta { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; margin-top: 8px; color: var(--ink-2); font-weight: 650; }
.rr-meta .num { color: var(--ink); }
.rr-sep { margin: 0 8px; color: var(--ink-2); }
#rr-next { margin: var(--px); min-width: 200px; }
.rr-hint { margin-top: 16px; }
@media (hover: none) { .rr-hint { display: none; } } /* phones: the button is the way on */
.rr-total { margin-top: 20px; padding-top: 12px; border-top: 3px dotted rgba(20, 32, 92, .3); color: var(--ink-2); }
.rr-total strong { color: var(--ink); }

/* ---------- results ----------
   Pixel cards and buttons over the landing scene, which stays sharp behind them. */
.results { max-width: 580px; margin: 0 auto; }
/* The header sits on the same small navy plates as during a run, so it reads on any evening sky. */
body[data-screen="results"] .brand, body[data-screen="results"] .puzzle-label { color: var(--panel-solid); background: var(--ink); box-shadow: 0 3px 0 var(--frame-shadow); }
body[data-screen="results"] .brand { padding: 5px 12px 5px 9px; }
body[data-screen="results"] .puzzle-label { padding: 7px 10px 6px; }
/* Starting from home: the camera flies into the tower's antenna (scene.js zoomToTower), so the sign rushes
   past it, swelling and thinning out as if the lens went straight through it. */
body.is-flying #screen-home { animation: fly-past .75s cubic-bezier(.5, 0, .75, .2) forwards; pointer-events: none; }
body.is-flying .topbar { animation: fly-dip .75s var(--ease-in) both; }
@keyframes fly-past { to { transform: scale(1.9); opacity: 0; } }
@keyframes fly-dip { 50% { opacity: .35; } }
/* Leaving the last round: its card lifts away before the camera starts up. */
body.is-leaving main > .screen { animation: leave .45s var(--ease-in) forwards; pointer-events: none; }
@keyframes leave { to { transform: translateY(40px); opacity: 0; } }

.results > div { animation: enter .5s var(--ease-out) both; }
.results > div:nth-of-type(2) { animation-delay: .1s; }
.results > div:nth-of-type(n+3) { animation-delay: .18s; }
.results-title { font: 400 14px/1.2 var(--font-hud); text-transform: uppercase; color: var(--ink-2); text-align: center; padding-bottom: 12px; border-bottom: 2px dotted rgba(20, 32, 92, .3); }
.res-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 16px; }
.score-big { font: 700 clamp(64px, 18vw, 96px)/.95 var(--font-num); letter-spacing: -.02em; font-variant-numeric: tabular-nums lining-nums; }
.res-zone { margin-top: 6px; font: 700 1.375rem/1.15 var(--font-pixel); }
.metres { font: 400 13px/1.4 var(--font-hud); text-transform: uppercase; color: var(--ink-2); }
.res-rank { display: grid; justify-items: center; gap: 6px; max-width: 46%; padding: 12px 14px 10px; text-align: center; background: var(--tier, var(--tint)); box-shadow: 0 0 0 3px var(--ink), 0 8px 0 0 var(--tier-edge, var(--frame-shadow)); }
.res-rank .icon { width: 36px; height: 36px; }
.res-rank-name { font: 700 1.0625rem/1.15 var(--font-pixel); text-wrap: balance; }
.res-rank-top { padding: 3px 7px 2px; font: 700 11px/1.3 var(--font-hud); text-transform: uppercase; background: var(--ink); color: var(--accent); }
.landmark { margin-top: 20px; padding: 10px 14px; font: 600 1.0625rem/1.35 var(--font-pixel); text-align: center; background: var(--tint); text-wrap: balance; }

.res-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; }
.res-head .section-title { margin-bottom: 14px; }
.res-note { font: 400 12px/1.2 var(--font-hud); text-transform: uppercase; color: var(--ink-2); }
.res-main .res-head { margin-top: 26px; }

.res-crowd { margin: 22px 0 0; }
.crowd-bars { display: flex; align-items: flex-end; gap: 2px; height: 104px; border-bottom: 3px solid var(--ink); }
.crowd-bars i { flex: 1; height: calc(var(--h) * 90%); min-height: 3px; background: var(--t-tourist); box-shadow: inset 0 3px 0 var(--t-tourist-edge); transform-origin: 50% 100%; animation: bar .5s var(--ease-out) both; animation-delay: calc(var(--i) * 18ms); }
.crowd-bars i.is-you { background: var(--accent); box-shadow: 0 0 0 2px var(--ink), 0 -10px 0 -2px var(--ink); }
@keyframes bar { from { transform: scaleY(0); } }
.crowd-axis { position: relative; height: 24px; font: 400 11px/24px var(--font-hud); color: var(--ink-2); }
.crowd-axis > * { position: absolute; transform: translateX(-50%); }
.crowd-axis > span[style="left:0%"] { transform: none; }
.crowd-axis > span[style="left:100%"] { transform: translateX(-100%); }
.crowd-axis b { color: var(--ink); text-transform: uppercase; }
.better { margin-top: 6px; text-align: center; font: 600 1rem/1.35 var(--font); }
.better strong { padding: 0 5px; background: var(--accent); font-weight: 700; }

.log { --fall: 210px; position: relative; height: calc(var(--fall) + 66px); }
.log-grid span { position: absolute; left: 0; right: 0; top: calc(8px + var(--d) * var(--fall)); height: 0; font: 400 11px/0 var(--font-hud); color: var(--ink-2); }
.log-grid span::after { content: ""; position: absolute; left: 36px; right: 0; top: 0; border-top: 2px dotted rgba(20, 32, 92, .25); }
.log-drops { position: absolute; inset: 8px 0 0 36px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); list-style: none; margin: 0; padding: 0; }
.drop { position: relative; }
.drop-line { position: absolute; left: calc(50% - 2px); top: 0; width: 4px; height: calc(var(--d) * var(--fall)); background: var(--tier-edge, var(--ink-2)); transform-origin: 50% 0; animation: pour .6s var(--ease-out) both; animation-delay: calc(300ms + var(--i) * 120ms); }
.drop-end { position: absolute; left: calc(50% - 15px); top: calc(var(--d) * var(--fall)); width: 30px; height: 30px; animation: land-in .4s var(--ease-out) both; animation-delay: calc(520ms + var(--i) * 120ms); }
.drop-end .tile { --px: 2px; display: grid; place-items: center; width: 26px; height: 26px; margin: 2px; }
.drop-end .tile .icon { width: 18px; height: 18px; }
.drop-num { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; font: 700 12px/1 var(--font-hud); }
@keyframes pour { from { transform: scaleY(0); } }
@keyframes land-in { from { opacity: 0; transform: translateY(-14px); } }

/* Two buttons under the score: copy and share. Practice and home wait at the bottom. */
.res-actions { display: grid; gap: 18px; margin: 0 var(--px) 34px; }
.res-actions .btn, .res-last .btn { display: inline-flex; align-items: center; justify-content: center; min-height: 54px; font-size: 1.1875rem; text-decoration: none; text-align: center; }
.res-actions .btn { width: 100%; }
.res-actions .btn-big { min-height: 64px; font-size: 1.5rem; }
.res-last { display: flex; flex-wrap: wrap; gap: 18px 14px; }
.res-last .btn { flex: 1 1 180px; }
.res-btn-practice { --fill: var(--accent); }
.res-btn-practice:hover:not(:disabled) { --fill: #FFD666; } /* the same hover as .btn-accent */
.share-status { min-height: 1.5em; font-size: .925rem; font-weight: 700; text-align: center; color: var(--ink); }
.res-actions .share-status:empty { display: none; }
.res-actions .share-status:not(:empty) { padding: 6px 10px; background: var(--panel-solid); color: var(--ok); }
.share-fallback {
  --px: 2px; --f: rgba(20, 32, 92, .5); --fill: var(--tint);
  display: block; width: 100%; margin: 0; padding: 12px 14px; border: 0; resize: none;
  font: .9rem/1.45 ui-monospace, Menlo, Consolas, monospace; color: var(--ink-2);
}

/* The levels: a plain list, yours picked out in yellow. */
.levels { list-style: none; margin: 0; padding: 0; }
.level { display: flex; align-items: center; gap: 10px; padding: 9px 10px; color: var(--ink-2); }
.level + .level { border-top: 2px dotted rgba(20, 32, 92, .18); }
.level-name { font: 600 1.0625rem/1.2 var(--font-pixel); }
.level-pts { margin-left: auto; font-size: .875rem; font-variant-numeric: tabular-nums; }
.level.is-here { color: var(--ink); background: var(--accent); border-top-color: transparent; }
.level.is-here + .level { border-top-color: transparent; }
.level-here { padding: 3px 6px 2px; font: 700 11px/1.2 var(--font-hud); text-transform: uppercase; background: var(--ink); color: var(--accent); }

.answers { list-style: none; margin: 0; padding: 0; }
.answers li + li { border-top: 2px dotted rgba(20, 32, 92, .25); }
.ans { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto 12px; gap: 12px; align-items: center; width: 100%; padding: 12px 4px; background: none; border: 0; text-align: left; cursor: pointer; }
.ans { transition: background-color .25s ease; }
.ans:hover, .answers li.is-open .ans { background: var(--tint); }
.ans-chevron { width: 8px; height: 8px; border: solid var(--ink); border-width: 0 3px 3px 0; rotate: 45deg; translate: 0 -2px; transition: rotate .4s var(--ease-out), translate .4s var(--ease-out); }
.answers li.is-open .ans-chevron { rotate: 225deg; translate: 0 2px; }
/* The drop-down: it grows from nothing to its own height. */
.drawer { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .5s var(--ease-out); }
.drawer-in { overflow: hidden; min-height: 0; opacity: 0; transition: opacity .35s ease; }
.answers li.is-open .drawer { grid-template-rows: 1fr; }
.answers li.is-open .drawer-in { opacity: 1; }
.drawer-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 14px 8px 18px; }
.ans-icon { display: grid; place-items: center; width: 36px; height: 36px; margin: 3px; background: var(--tier, var(--panel-solid)); box-shadow: 0 0 0 3px var(--tier-edge, var(--ink-2)); }
.ans-icon .icon { width: 24px; height: 24px; }
.ans-text { display: grid; min-width: 0; }
.ans-prompt { font-size: .8125rem; line-height: 1.35; color: var(--ink-2); }
.ans-yours { font: 700 1.1875rem/1.25 var(--font-pixel); overflow-wrap: anywhere; }
.tier-miss .ans-yours { color: var(--ink-2); }
.ans-said { font-size: .8125rem; color: var(--ink-2); }
.ans-tip { margin: 8px 0 12px; }
.ans-pts { font: 700 1.25rem/1 var(--font-num); font-variant-numeric: tabular-nums; }

.res-foot { display: grid; gap: 18px; margin: 0 var(--px); }
.res-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 0; }
.res-stats div { display: flex; flex-direction: column-reverse; align-items: center; gap: 4px; padding: 12px 6px 10px; background: var(--panel-solid); box-shadow: 0 0 0 3px var(--ink), 0 8px 0 0 var(--frame-shadow); }
.res-stats dt { font: 400 12px/1.2 var(--font-hud); text-transform: uppercase; color: var(--ink-2); }
.res-stats dd { margin: 0; font: 700 1.875rem/1 var(--font-num); font-variant-numeric: tabular-nums; }
.res-next { justify-self: center; padding: 8px 14px 7px; font: 400 13px/1.3 var(--font-hud); text-transform: uppercase; background: var(--ink); color: var(--panel-solid); }
.res-next strong { color: var(--accent); }

.share-dialog { width: min(440px, calc(100% - 28px)); max-height: calc(100dvh - 28px); border: 0; color: var(--ink); }
.share-dialog.panel { padding: 0; margin: auto; } /* .panel's own margin would pin it to a corner */
.share-dialog::backdrop { background: rgba(12, 20, 64, .55); }
.share-inner { display: grid; gap: 16px; padding: 18px; }
.share-head { display: flex; justify-content: space-between; align-items: center; }
.share-head .section-title { margin: 0; }
.share-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; padding-inline: var(--px); }
.share-grid .btn { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; text-decoration: none; }
.share-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
/* The share card preview: 16:9, held open by the frame while the image is drawn. */
.card-frame { aspect-ratio: 1200 / 675; margin: 3px; background: var(--tint); box-shadow: 0 0 0 3px var(--frame); }
.card-img { display: block; width: 100%; height: 100%; image-rendering: pixelated; }

.notice {
  --px: 3px; --f: var(--ok); --fill: #E4F6EC;
  display: flex; gap: 12px; align-items: flex-start; margin: 14px 3px 6px; padding: 12px 14px;
}
.notice .icon { width: 24px; height: 24px; color: var(--ok); flex: none; }

/* The pop-ups rise and fade in over a dimming backdrop, and leave the same way. */
.share-dialog, .how-dialog {
  opacity: 0; translate: 0 28px; scale: .95;
  transition: opacity .35s var(--ease-out), translate .5s var(--ease-out), scale .5s var(--ease-out), overlay .35s allow-discrete, display .35s allow-discrete;
}
.share-dialog[open], .how-dialog[open] { opacity: 1; translate: 0 0; scale: 1; }
.share-dialog::backdrop, .how-dialog::backdrop { opacity: 0; transition: opacity .35s ease, overlay .35s allow-discrete, display .35s allow-discrete; }
.share-dialog[open]::backdrop, .how-dialog[open]::backdrop { opacity: 1; }
@starting-style {
  .share-dialog[open], .how-dialog[open] { opacity: 0; translate: 0 28px; scale: .95; }
  .share-dialog[open]::backdrop, .how-dialog[open]::backdrop { opacity: 0; }
}
.card-img { animation: fade-in .4s ease both; }
@keyframes fade-in { from { opacity: 0; } }

/* ---------- the real answers ---------- */
.tier-group h3 { font-size: .875rem; font-weight: 600; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; background: var(--tint); font-size: .9rem; }
.chip-share { color: var(--ink-2); font-size: .78rem; font-variant-numeric: tabular-nums; }
.chip-mine { --px: 2px; --fill: var(--accent); margin: 2px; font-weight: 750; }
.chip-mine .chip-share { color: var(--ink); }
.chip-you { font: 700 .75rem/1 var(--font-hud); background: var(--ink); color: var(--accent); padding: 3px 5px; }
.pick { color: var(--t-sixillion); } /* the cards are navy: the light coral is the one that shows */
.chip-mine .pick { color: var(--ink); }
.report label { display: block; font-size: .9rem; color: var(--ink-2); margin-bottom: 6px; }
.report-row { display: flex; gap: 10px; align-items: center; }
/* Colours set outright: phones otherwise draw the box's text in their own (dark or greyed) default. */
.report-row input {
  --px: 3px; flex: 1; min-width: 0; height: 40px; padding: 0 12px; margin: 3px;
  -webkit-appearance: none; appearance: none;
  color: var(--ink); -webkit-text-fill-color: var(--ink); caret-color: var(--ink);
}
.report-row input:disabled { opacity: 1; color: var(--ink-2); -webkit-text-fill-color: var(--ink-2); }
.report-row input:focus { --fill: #FFFFFF; outline: none; box-shadow: var(--ring), 0 0 0 6px var(--accent); }
.report-status { min-height: 1.4em; margin-top: 6px; font-size: .875rem; color: var(--ok); font-weight: 600; }

/* ---------- misc ---------- */
.error { max-width: 540px; margin: 0 auto; padding-top: 10vh; }
.error h1 { font: 700 32px/1.1 var(--font-pixel); margin-bottom: 10px; }
.toast {
  --px: 3px;
  animation: toast-in .32s var(--ease-out) both;
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 40px); padding: 12px 18px; z-index: 20;
  font: 600 1rem/1.3 var(--font-pixel); color: var(--ink);
  box-shadow: var(--ring), 0 6px 0 0 var(--frame-shadow);
}
.noscript { position: relative; z-index: 1; text-align: center; padding: 20vh 16px; font: 700 1.5rem var(--font-pixel); }

/* ---------- the descent ---------- */
/* The zone the camera drops into: a navy tab that slides in from the left edge under the header. */
.zone-caption {
  position: fixed; left: 0; top: 74px; z-index: 3; margin: 0;
  padding: 9px 16px 8px 18px; background: var(--ink); color: var(--accent);
  box-shadow: 0 4px 0 var(--frame-shadow); pointer-events: none; white-space: nowrap;
}
.zone-caption.is-in { animation: slide-in .32s var(--ease-out) both; }
.zone-caption.is-out { animation: slide-out .2s var(--ease-in) both; }
@keyframes slide-in { from { transform: translateX(-100%); } }
@keyframes slide-out { to { transform: translateX(-100%); } }

/* Round result: how far this answer dropped you, and the place you reached. */
.down-arrow {
  display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -1px; background: var(--ink);
  clip-path: polygon(33% 0, 67% 0, 67% 50%, 100% 50%, 100% 67%, 83% 67%, 83% 83%, 67% 83%, 67% 100%, 33% 100%, 33% 83%, 17% 83%, 17% 67%, 0 67%, 0 50%, 33% 50%);
}

/* Tier flourishes on the badge: a camera flash (Tourist), a roof (Local), a burst of sparks (Sixillion). */
.rr-panel:has(.flourish-tourist)::after {
  content: ""; position: absolute; inset: 0; background: #FFFFFF; pointer-events: none;
  animation: shutter .36s ease-in-out .24s both;
}
@keyframes shutter { 0% { opacity: .85; } 34% { opacity: .5; } 67%, 100% { opacity: 0; } }

/* ---------- microinteractions ----------
   All eased, one thing moving at a time, and every one has a still version under reduced motion
   (the block at the end of this file stops them). Transforms set elsewhere (button presses) are left
   alone: these use the separate translate / scale / rotate properties. */
.btn-big.btn-accent:not(:disabled) { animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 0%, 70%, 100% { translate: 0 0; } 85% { translate: 0 -3px; } }
.btn:focus-visible, .icon-btn:focus-visible, a:focus-visible, summary:focus-visible { animation: ring-in .12s ease-in-out; }
@keyframes ring-in { from { outline-offset: calc(var(--px) + 9px); outline-color: transparent; } }
.icon-btn[aria-pressed="true"] .snd-on { animation: waves .3s ease-in-out both; }
.icon-btn[aria-pressed="false"] .snd-off { animation: waves-off .2s ease-in-out both; }
@keyframes waves { from { clip-path: inset(0 55% 0 0); } }
@keyframes waves-off { from { clip-path: inset(0 0 0 0); scale: 1.15; } }
@keyframes toast-in { from { transform: translate(-50%, 12px); opacity: 0; } }
.toast.is-out { animation: toast-out .2s var(--ease-in) both; }
@keyframes toast-out { to { transform: translate(-50%, 12px); opacity: 0; } }
.brand-lid { opacity: 0; }
.brand.blink .brand-lid { animation: lid .9s steps(1) both; }
@keyframes lid { 0%, 50% { opacity: 1; } 25%, 75%, 100% { opacity: 0; } }

/* Home */
.ladder li:hover .icon { animation: hop .24s ease-in-out; }
@keyframes hop { 50% { translate: 0 -2px; } }
.flame { width: 10px; height: 14px; margin-left: 6px; vertical-align: -1px; }
.flame .fl-a { fill: var(--t-sixillion); animation: flick .5s ease-in-out infinite; }
.flame .fl-b { fill: var(--t-deepcut); animation: flick .5s ease-in-out -.25s infinite; }
.flame .fl-core { fill: var(--t-bornhere); }
@keyframes flick { 50% { visibility: hidden; } }

/* Playing */
.phase-label.bump { animation: bump .2s ease-in-out; }
@keyframes bump { from { translate: 0 -6px; } }
.timer-segs i.pop { animation: seg-pop .2s ease-in-out; }
@keyframes seg-pop { 0% { background: var(--accent); box-shadow: inset 0 -3px 0 var(--accent-shade); } 50% { background: var(--accent); translate: 0 2px; } }
/* The last five seconds: red light in hard bands at both sides of the screen, deeper and wider each
   second (--hurry runs .2 to 1, set by app.js), with a kick on every tick. Over the scene, under the panels. */
.hurry-edge {
  --red: 196, 43, 43;
  --w: calc(3vw + var(--hurry, 0) * 9vw);
  position: fixed; inset: 0; z-index: 1; pointer-events: none; visibility: hidden; opacity: 0;
  background:
    linear-gradient(90deg, rgba(var(--red), .62) 0 calc(var(--w) / 4), rgba(var(--red), .4) 0 calc(var(--w) / 2),
      rgba(var(--red), .22) 0 calc(var(--w) * .75), rgba(var(--red), .1) 0 var(--w), transparent 0),
    linear-gradient(270deg, rgba(var(--red), .62) 0 calc(var(--w) / 4), rgba(var(--red), .4) 0 calc(var(--w) / 2),
      rgba(var(--red), .22) 0 calc(var(--w) * .75), rgba(var(--red), .1) 0 var(--w), transparent 0);
}
body.is-hurry[data-screen="play"]:not(.is-dropping) .hurry-edge { visibility: visible; opacity: calc(.45 + var(--hurry, 0) * .55); }
.hurry-edge.beat { animation: hurry-beat .5s ease-in-out; }
@keyframes hurry-beat { 0% { filter: brightness(1.5) saturate(1.3); } }
.play.hurry .timer-segs i.pop { animation-name: seg-pop-hurry; }
@keyframes seg-pop-hurry { 0% { background: var(--miss); } 50% { background: var(--miss); translate: 0 2px; } }
.crumble {
  position: absolute; display: flex; align-items: center; padding: 0 14px; overflow: hidden; pointer-events: none;
  font-size: 1.15rem; white-space: pre; color: var(--ink);
}
.crumble span { display: inline-block; animation: crumble .36s var(--ease-in) both; animation-delay: calc(var(--i) * 25ms); }
@keyframes crumble { to { translate: 0 16px; opacity: 0; } }
.typeout { display: inline-block; animation: type calc(var(--n, 8) * 30ms) linear both; }
@keyframes type { from { clip-path: inset(0 100% 0 0); } }
kbd.key {
  display: inline-block; margin: 0 3px; padding: 2px 5px 3px; font: 700 .75rem/1 var(--font-hud);
  background: var(--panel-solid); color: var(--ink); box-shadow: 0 0 0 2px var(--ink), 0 3px 0 2px var(--ink);
  animation: keypress 1.6s ease-in-out infinite;
}
@keyframes keypress { 80% { translate: 0 2px; box-shadow: 0 0 0 2px var(--ink); } }
.answer-form[data-tier="tourist"] { --flash: var(--t-tourist); } .answer-form[data-tier="tooclever"] { --flash: var(--t-tooclever); }
.answer-form[data-tier="local"] { --flash: var(--t-local); } .answer-form[data-tier="bornhere"] { --flash: var(--t-bornhere); }
.answer-form[data-tier="deepcut"] { --flash: var(--t-deepcut); } .answer-form[data-tier="sixillion"] { --flash: var(--t-sixillion); }
.answer-form.accept input { animation: accept .36s var(--ease-out) both; }
/* The ring swells out and the box stays in the tier's colour while the card leaves. */
@keyframes accept {
  from { box-shadow: var(--ring), 0 0 0 0 var(--flash, var(--accent)); --fill: var(--flash, var(--accent)); }
  to { box-shadow: var(--ring), 0 0 0 calc(var(--px) * 2) var(--flash, var(--accent)); --fill: var(--flash, var(--accent)); }
}
.leap {
  position: fixed; z-index: 25; padding: 4px 7px; pointer-events: none; transform-origin: left top;
  font: 700 1.15rem/1 var(--font-pixel); color: var(--ink); background: var(--accent); box-shadow: 0 0 0 2px var(--ink);
}
.dot.pop { animation: dot-pop .24s ease-in-out; }
@keyframes dot-pop { 50% { scale: 1.7; } }

/* Results */
.stamp, #share.stamp { animation: stamp .32s var(--ease-out); }
@keyframes stamp { from { scale: 1.12; rotate: -3deg; } }

/* ---------- the raccoon (lib/raccoon.js) ----------
   A pixel companion perched on top of the run's panel. --rc is one of its art pixels; the panel under it
   gets enough top margin for it to sit on the frame. Decorative: it never takes clicks. */
:root { --rc: 3px; }
@media (min-width: 860px) and (min-height: 760px) { :root { --rc: 4px; } }
@media (max-height: 700px) { :root { --rc: 2px; } }
body.has-raccoon .play-panel,
body.has-raccoon #screen-results > .res-main { position: relative; margin-top: calc(var(--rc) * 23); }
.raccoon {
  position: absolute; z-index: 3; right: 22px; bottom: calc(100% + var(--px) - var(--rc));
  width: calc(var(--rc) * 24); height: calc(var(--rc) * 24); pointer-events: none;
}
.raccoon[hidden] { display: none; }
.rc-body { position: absolute; inset: 0; transform-origin: 50% 100%; animation: rc-breathe 3.2s ease-in-out infinite; }
.rc-art, .rc-sprite { display: block; width: 100%; height: 100%; }
.rc-tail { animation: rc-wag 1.4s ease-in-out infinite; }
@keyframes rc-breathe { 50% { scale: 1 .97; } }
@keyframes rc-wag { 50% { translate: 0 -1px; } }

/* Emotes pop up over its head; the speech bubble sits to its left, pointing at it. */
.rc-emote { position: absolute; left: 72%; top: calc(var(--rc) * -9); width: calc(var(--rc) * 7); height: calc(var(--rc) * 7); }
.rc-emote svg { display: block; width: 100%; height: 100%; }
.rc-emote:empty { display: none; }
.rc-emote.is-in { animation: rc-emote 1.6s ease-in-out both; }
@keyframes rc-emote { 0% { translate: 0 8px; opacity: 0; } 15% { translate: 0 0; opacity: 1; } 80% { opacity: 1; } 100% { translate: 0 -10px; opacity: 0; } }
.rc-bubble {
  position: absolute; right: calc(100% + 10px); top: 4%; margin: 0; padding: 6px 9px 5px;
  font: 700 12px/1.15 var(--font-hud); text-transform: uppercase; white-space: nowrap; color: var(--ink);
  background: var(--panel-solid); box-shadow: 0 0 0 2px var(--ink), 0 4px 0 2px var(--frame-shadow);
}
.rc-bubble::after { /* the pointer, a 3-step pixel wedge */
  content: ""; position: absolute; left: 100%; top: 7px; width: 8px; height: 8px;
  background:
    linear-gradient(var(--ink) 0 0) 0 0 / 2px 8px no-repeat,
    linear-gradient(var(--panel-solid) 0 0) 0 2px / 2px 4px no-repeat,
    linear-gradient(var(--ink) 0 0) 2px 1px / 2px 6px no-repeat,
    linear-gradient(var(--ink) 0 0) 4px 2px / 2px 4px no-repeat,
    linear-gradient(var(--ink) 0 0) 6px 3px / 2px 2px no-repeat;
}
.rc-bubble[hidden] { display: none; }
.rc-bubble.is-in { animation: rc-pop .24s var(--ease-out) both; }
@keyframes rc-pop { from { scale: .6; translate: 6px 0; } }
@media (max-width: 420px) { .rc-bubble { font-size: 11px; width: max-content; max-width: 52vw; white-space: normal; } }

/* Moves: all eased, using translate / scale / rotate so the flight's transform is left alone. */
.rc-body.rc-hop { animation: rc-hop .36s ease-in-out; }
.rc-body.rc-hop2 { animation: rc-hop .32s ease-in-out 2; }
.rc-body.rc-dance { animation: rc-dance .5s ease-in-out 4; }
.rc-body.rc-nod { animation: rc-nod .5s ease-in-out 2; }
.rc-body.rc-shrug { animation: rc-shrug .7s ease-in-out; }
.rc-body.rc-slump { animation: rc-slump 1.2s ease-in-out both; }
.rc-body.rc-flinch { animation: rc-flinch .3s ease-in-out; }
.rc-body.rc-land { animation: rc-land .24s ease-in-out; }
.rc-body.rc-shiver { animation: rc-flinch .25s ease-in-out infinite; }
@keyframes rc-hop { 50% { translate: 0 calc(var(--rc) * -5); scale: .94 1.08; } }
@keyframes rc-dance { 0% { translate: 0 calc(var(--rc) * -4); rotate: -8deg; } 50% { translate: 0 calc(var(--rc) * -4); rotate: 8deg; } }
@keyframes rc-nod { 50% { translate: 0 var(--rc); scale: 1.03 .95; } }
@keyframes rc-shrug { 33% { scale: 1.06 .92; } 66% { translate: 0 calc(var(--rc) * -1); } }
@keyframes rc-slump { 40%, 100% { scale: 1.06 .9; translate: 0 var(--rc); } }
@keyframes rc-flinch { 25% { translate: calc(var(--rc) * -1) 0; } 75% { translate: var(--rc) 0; } }
@keyframes rc-land { 50% { scale: 1.18 .78; } }
/* Falling: wind streaks over its head. */
.rc-body.rc-falling { animation: none; }
.rc-body.rc-falling::before {
  content: ""; position: absolute; left: 18%; right: 30%; bottom: 96%; height: 70%;
  background: repeating-linear-gradient(90deg, rgba(246, 251, 255, .85) 0 var(--rc), transparent var(--rc) calc(var(--rc) * 4));
  -webkit-mask: linear-gradient(transparent, #000); mask: linear-gradient(transparent, #000);
}
@media (prefers-reduced-motion: reduce) {
  .rc-body, .rc-tail, .rc-emote.is-in, .rc-bubble.is-in { animation: none !important; }
}

/* ---------- the drop (lib/dropfx.js) ----------
   Between a scored answer and its card: the play panel steps aside, the raccoon rides the camera down past
   a ladder of tier lines, each lighting in its tier's colour as it is passed, and the landing washes the
   screen in the colour of the tier you got. Over the scene, under the header; decorative, never clickable. */
body.is-dropping #screen-play { animation: dfx-aside .5s cubic-bezier(.45, 0, .25, 1) forwards; pointer-events: none; }
@keyframes dfx-aside { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-40px) scale(.97); } }
/* The ladder and the rider come up as the card goes, so the two cross over instead of swapping. */
.dfx-lines, .dfx-marker { animation: dfx-in .4s ease-out both; }
@keyframes dfx-in { from { opacity: 0; } }
.dfx { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.dfx[hidden] { display: none; }
.dfx-lines, .dfx-beams, .dfx-wash { position: absolute; inset: 0; }
.dfx-wash { background: var(--tier, #FFFFFF); opacity: 0; will-change: opacity; }
.dfx-wash.is-on { animation: dfx-wash .7s ease-out both; }
@keyframes dfx-wash { from { opacity: var(--wash, .25); } to { opacity: 0; } }

/* A tier line: a dashed hairline with the points on the left and the tier on the right, lit once passed. */
.dfx-line { position: absolute; left: 0; right: 0; top: 0; height: 0; will-change: transform; }
.dfx-line::before {
  content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 2px;
  background: repeating-linear-gradient(90deg, rgba(246, 251, 255, .6) 0 8px, transparent 8px 14px);
}
.dfx-pts, .dfx-name {
  position: absolute; bottom: 5px; padding: 3px 6px 2px; font-size: 12px; white-space: nowrap;
  background: rgba(20, 32, 92, .72); color: rgba(246, 251, 255, .85);
}
.dfx-pts { left: 10px; }
.dfx-name { right: 10px; }
.dfx-line.is-hit::before {
  top: -2px; height: 4px; background: var(--tier);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tier) 40%, transparent), 0 0 0 9px color-mix(in srgb, var(--tier) 15%, transparent);
  animation: dfx-light .4s var(--ease-out) both;
}
@keyframes dfx-light { from { transform: scaleX(.04); } }
.dfx-line.is-hit .dfx-pts, .dfx-line.is-hit .dfx-name { background: var(--tier); color: var(--ink); box-shadow: 0 2px 0 var(--tier-edge); }
.dfx-line.is-past { opacity: .35; }

/* The beam a lit line shoots up the screen from the raccoon; the line you land on throws a wider one. */
.dfx-beam {
  position: absolute; left: 50%; top: 0; width: 4px; margin-left: -2px; transform-origin: 50% 100%;
  background: linear-gradient(to top, var(--tier), color-mix(in srgb, var(--tier) 0%, transparent));
  animation: dfx-beam .8s var(--ease-out) forwards;
}
.dfx-beam.is-mine { width: 8px; margin-left: -4px; }
@keyframes dfx-beam { 0% { transform: scaleY(0); } 25% { transform: scaleY(1); opacity: 1; } 100% { transform: scale(.25, 1); opacity: 0; } }

/* The raccoon's spot: its feet on the current depth, the counter up to its left, the answer tag under it. */
.dfx-marker { position: absolute; left: 50%; top: 0; width: 0; height: 0; will-change: transform; }
.dfx-rider { position: absolute; left: calc(var(--rc) * -10); bottom: 0; width: calc(var(--rc) * 24); height: calc(var(--rc) * 24); }
.dfx-rider .raccoon { left: 0; top: 0; right: auto; bottom: auto; }
.dfx-count {
  position: absolute; right: calc(var(--rc) * 12); bottom: calc(var(--rc) * 16); padding: 5px 8px 4px;
  font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; transform-origin: 100% 100%;
  background: var(--ink); color: var(--panel-solid); box-shadow: 0 0 0 2px var(--panel-solid);
}
.dfx-count.is-lit { background: var(--tier); color: var(--ink); box-shadow: 0 0 0 2px var(--ink), 0 4px 0 2px var(--tier-edge); }
.dfx-count.is-land { animation: dfx-pop .45s var(--ease-out); }
@keyframes dfx-pop { from { transform: scale(1.8); } }
.dfx-tag {
  position: absolute; left: 0; top: 12px; transform: translateX(-50%); max-width: 70vw; overflow: hidden; text-overflow: ellipsis;
  padding: 4px 7px 3px; font: 700 12px/1.1 var(--font-hud); text-transform: uppercase; white-space: nowrap;
  background: var(--panel-solid); color: var(--ink); box-shadow: 0 0 0 2px var(--ink), 0 4px 0 2px var(--frame-shadow);
}
.dfx.is-out .dfx-lines, .dfx.is-out .dfx-marker, .dfx.is-out .dfx-beams { animation: dfx-out .2s var(--ease-in) forwards; }
@keyframes dfx-out { to { opacity: 0; } }
@media (max-width: 520px) { .dfx-pts, .dfx-name { font-size: 11px; } .dfx-count { font-size: 15px; } }

@media (prefers-reduced-motion: reduce) {
  .dfx { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  /* No shake: show a static red frame instead. */
  .shake { animation: none !important; }
  .shake input { --f: var(--miss); }
  .loader i:nth-child(-n+4) { background: var(--accent); }
  .crumble, .leap { display: none; }
  .typeout, .rr-badge .badge::before, .rr-badge .badge::after { animation: none !important; }
  .results > div, .crowd-bars i, .drop-line, .drop-end { animation-delay: 0s !important; }
}

/* ---------- the two cards ----------
   A run's screens fill the window: the question (or the result) floats in the middle, and a second card
   sits near the bottom: the answer box, then, in the same spot, the way on to the next round.
   --vvh is the visible height, so the bottom card stays above a phone's keyboard (app.js). */
body[data-screen="play"] main, body[data-screen="roundresult"] main { padding-bottom: 12px; }
#screen-play, #screen-roundresult {
  display: flex; flex-direction: column; gap: 14px;
  min-height: calc(var(--vvh, 100dvh) - 90px);
}
body.has-raccoon #screen-play, body.has-raccoon #screen-roundresult { padding-top: calc(var(--rc) * 23); }
#screen-play .play-panel, body.has-raccoon #screen-play .play-panel { margin-block: auto; }
.rr-wrap { position: relative; isolation: isolate; margin-block: auto; }
.rr-wrap > .panel { margin-block: var(--px) calc(var(--px) * 2); }
.dock { flex: none; width: calc(100% - var(--px) * 2); min-height: 176px; margin: 0 var(--px) calc(var(--px) * 2 + 4px); }
.answer-dock .feedback { min-height: 52px; margin-top: 14px; }
.answer-dock .play-hint { text-align: center; }
.rr-dock { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
@media (max-height: 700px) {
  .dock { min-height: 0; padding-block: 12px; }
  .prompt-card { min-height: 110px; }
  /* Short phones still get the emblem, just smaller. */
  .fx-emblem { width: 48px; height: 48px; box-shadow: 0 0 0 3px var(--tier-edge), 0 5px 0 3px var(--tier-edge); }
  .fx-emblem .icon { width: 32px; height: 32px; }
  #screen-roundresult .rr-badge { gap: 16px; } /* the base gap is set further down */
}

/* Typing on a phone (body.is-typing, app.js): the keyboard leaves about half the screen. The play screen is
   pinned to that visible part (--vvt, --vvh) and drops everything but the question, the timer, the box and
   any reply, so nothing has to scroll and the question stays in view above the box. */
body.is-typing[data-screen="play"] .topbar { visibility: hidden; }
body.is-typing[data-screen="play"] #screen-play {
  position: fixed; z-index: 3; left: 0; right: 0; top: var(--vvt, 0); height: var(--vvh, 100dvh); min-height: 0;
  max-width: 1040px; margin: 0 auto; padding: 8px 10px 4px; gap: 8px; overflow-y: auto; overscroll-behavior: contain;
}
body.is-typing[data-screen="play"] .raccoon,
body.is-typing[data-screen="play"] .play-hint,
body.is-typing[data-screen="play"] .phase-label { display: none; }
body.is-typing #screen-play .play-panel { margin: var(--px) var(--px) 0; padding: 10px 12px; }
body.is-typing #screen-play .play-head { padding-bottom: 8px; }
body.is-typing #screen-play .prompt-card { min-height: 0; padding: 10px 12px; }
body.is-typing #screen-play .prompt-text { font-size: 20px; }
body.is-typing #screen-play .timer { margin: 10px 0 0; }
body.is-typing #screen-play .dock { min-height: 0; margin-top: auto; margin-bottom: var(--px); padding: 10px 12px; } /* sits on the keyboard */
body.is-typing #screen-play .feedback { min-height: 0; margin-top: 10px; }
body.is-typing #screen-play .feedback:empty { display: none; }

/* ---------- tier results ----------
   A scored result keeps the same dark card; behind the badge are a faint halo,
   slow rays, a large emblem and a few small copies drifting out once. Only transform and opacity move. */
.rr-badge { position: relative; isolation: isolate; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.fx { position: absolute; left: 50%; top: 50%; width: 0; height: 0; z-index: -1; pointer-events: none; }
.fx-glow, .fx-rays { position: absolute; width: 220px; height: 220px; left: -110px; top: -110px; border-radius: 50%; }
/* A soft, still halo that fades in once. */
.fx-glow { background: radial-gradient(closest-side, color-mix(in srgb, var(--tier) 30%, transparent), transparent 100%); animation: fade-in .8s ease both; }
.fx-rays {
  background: repeating-conic-gradient(color-mix(in srgb, var(--tier) 12%, transparent) 0 7deg, transparent 7deg var(--ray, 30deg));
  -webkit-mask: radial-gradient(closest-side, #000 25%, transparent 100%); mask: radial-gradient(closest-side, #000 25%, transparent 100%);
  animation: fade-in .8s ease both, spin 60s linear infinite;
}
@keyframes spin { to { transform: rotate(1turn); } }
.fx-emblem {
  display: grid; place-items: center; width: 84px; height: 84px; color: var(--ink); background: var(--tier);
  box-shadow: 0 0 0 4px var(--tier-edge), 0 8px 0 4px var(--tier-edge);
  animation: emblem-in .6s var(--ease-out) both, float 4s ease-in-out .6s infinite;
}
.fx-emblem .icon { width: 60px; height: 60px; }
@keyframes emblem-in { from { transform: scale(.8); opacity: 0; } }
@keyframes float { 50% { transform: translateY(-3px); } }

/* A few small copies drift out once as the card arrives, then are gone. */
.fx-bits i {
  position: absolute; left: -6px; top: -6px; width: 12px; height: 12px; color: var(--tier); opacity: 0;
  animation: burst 1.4s var(--ease-out) calc(var(--i) * 20ms + .2s) both;
}
.fx-bits i:nth-child(even) { display: none; }
.fx-bits .icon { display: block; width: 12px; height: 12px; }
@keyframes burst {
  0% { transform: rotate(calc(var(--i) * 36deg)) translateY(-45px) scale(.6); opacity: 0; }
  30% { opacity: .65; }
  100% { transform: rotate(calc(var(--i) * 36deg)) translateY(-90px) scale(.8); opacity: 0; }
}

/* Each tier keeps its own ray spacing; only the rarest shimmers a second, fainter set. */
.rr-wrap.tier-tourist { --ray: 45deg; }
.rr-wrap.tier-tooclever { --ray: 20deg; }
.rr-wrap.tier-local { --ray: 36deg; }
.rr-wrap.tier-deepcut { --ray: 18deg; }
.rr-wrap.tier-sixillion { --ray: 15deg; }
.tier-sixillion .fx-rays::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: repeating-conic-gradient(from 7deg, color-mix(in srgb, var(--accent) 16%, transparent) 0 4deg, transparent 4deg 30deg);
}
@media (prefers-reduced-motion: reduce) {
  .fx-glow, .fx-rays, .fx-emblem { animation: none !important; }
  .fx-bits { display: none; }
}
/* The burst and the rays pass behind the words. */
.rr-body > :not(.rr-badge) { position: relative; z-index: 1; }
.rr-badge { gap: 26px; }
/* The emblem above is the logo; the tier's badge under it is just the word. */
.rr-badge .badge:not(.tier-miss) > .icon { display: none; }
/* Laptop and shorter-phone heights: tighten up so the result and the button both fit without scrolling. */
@media (min-height: 701px) and (max-height: 900px) {
  .dock { min-height: 0; padding-block: 16px; }
  .rr-panel { padding-block: 16px; }
  .rr-badge { margin: 20px 0 12px; gap: 20px; }
  .fx-emblem { width: 60px; height: 60px; }
  .fx-emblem .icon { width: 36px; height: 36px; }
  .rr-badge .badge-xl { font-size: 1.25rem; padding-block: 6px; }
  .rr-answer { font-size: 32px; }
  .rr-total { margin-top: 12px; padding-top: 8px; }
}

/* ---------- dark cards ----------
   Every card is deep navy with light text. The tokens are re-pointed on the cards themselves, so the sky,
   the header and the home screen keep their own colours. */
.panel, .toast, .res-stats div, .res-actions .btn-ghost, .res-last .btn-ghost, .res-actions .share-status:not(:empty) {
  --ink: #F6FBFF; --ink-2: #B7BCE4;
  --panel: rgba(22, 27, 72, .97); --panel-solid: #161B48; --tint: #252C66;
  --frame: #7079C4; --frame-shadow: rgba(4, 6, 24, .6);
  --miss: #FF8A80; --ok: #7BE0A8; --line: rgba(246, 251, 255, .18);
  color: var(--ink); color-scheme: dark;
}
.res-actions .share-status:not(:empty) { color: var(--ok); background: var(--panel-solid); }
.res-stats div { box-shadow: 0 0 0 3px var(--frame), 0 8px 0 0 var(--frame-shadow); }
/* Anything filled with a bright colour keeps navy lettering. */
.panel .btn-accent, .panel .badge:not(.tier-miss), .panel .tile:not(.tier-miss), .panel .res-rank:not(.tier-miss),
.panel .chip-mine, .panel .level.is-here, .panel .ans:not(.tier-miss) .ans-icon, .panel .fx-emblem, .panel .better strong,
.panel .notice, .panel .answer-form.accept input { --ink: #14205C; --ink-2: #3A4682; --ok: #1D6E45; color: var(--ink); }
.panel .res-rank { box-shadow: 0 0 0 3px #0A0E2E, 0 8px 0 0 var(--tier-edge, var(--frame-shadow)); }
.panel .res-rank-top, .panel .level-here, .panel .chip-you { background: #14205C; }
.panel .btn-ghost:hover:not(:disabled), .res-actions .btn-ghost:hover, .res-last .btn-ghost:hover { --fill: var(--tint); }
.panel .answer-form input:focus, .panel .report-row input:focus { --fill: #0D1134; }
.panel .answer-form input::placeholder, .panel .report-row input::placeholder { color: #9CA2D4; }
.panel .prompt-card { box-shadow: inset 0 3px 0 rgba(4, 6, 24, .35); }
.panel .dot:not([class*="tier-"]):not(.is-current), .panel .timer-segs i.off { background: var(--line); }
.panel .rr-total, .panel .results-title, .results-title, .panel .how-note, .panel .level + .level, .panel .answers li + li { border-color: var(--line); }
.panel .level.is-here, .panel .level.is-here + .level { border-top-color: transparent; }
.panel .log-grid span::after { border-top-color: var(--line); }

