:root {
  --night: #0c0817;
  --night-2: #140e26;
  --panel: #1a1233e6;
  --edge: #33275a;
  --edge-dark: #0a0614;
  --text: #f3ead7;
  --muted: #9a8fb8;
  --amber: #ffb547;
  --gold: #ffd166;
  --teal: #5ee6c9;
  --rose: #ff6b8b;
  --lime: #a3e36b;
  --orange: #ff8a3d;
  --ground-h: 27.5%; /* matches Scene.GROUND_FRACTION; % of the viewport box, which (unlike vh on iOS) is what's visible */
  --pixel: "VT323", ui-monospace, monospace;
  --display: "Press Start 2P", "VT323", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
html { touch-action: manipulation; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
body {
  background: var(--night);
  color: var(--text);
  font-family: var(--pixel);
  font-size: 24px;
  line-height: 1.15;
  -webkit-font-smoothing: none;
}

#scene {
  position: fixed; inset: 0; width: 100%; height: 100%;
  transition: transform .25s ease-out; /* slides up while a phone keyboard is open */
  image-rendering: pixelated; image-rendering: crisp-edges;
}
.crt {
  position: fixed; inset: 0; pointer-events: none; z-index: 10;
  background: repeating-linear-gradient(#0000 0 2px, #0c08171f 2px 3px);
  animation: crt-zap 7s steps(1) infinite;
}
.hidden { display: none !important; }

/* Pixel frame */
.tag, .card {
  background: var(--panel);
  box-shadow: 0 0 0 2px var(--edge-dark), 0 0 0 4px var(--edge), 0 4px 0 4px var(--edge-dark), 8px 10px 0 4px #00000055;
}

/* ---------- HUD ---------- */
.hud {
  position: fixed; top: 20px; left: 24px; right: 24px; z-index: 5;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
}
.tag { justify-self: start; padding: 4px 12px; font-size: 26px; color: var(--gold); white-space: nowrap; }
.tag.score { justify-self: end; }
.hud-left { justify-self: start; display: flex; align-items: center; gap: 12px; min-width: 0; }
/* Before the game: just the menu button. Results: menu instead of the era. Playing: era, pips, score. */
.menu-btn { display: none; padding: 9px 10px; border: 0; cursor: pointer; color: var(--gold); }
.menu-btn svg { width: 20px; height: 16px; display: block; }
@media (hover: hover) { .menu-btn:hover { color: #fff; } }
body[data-view="intro"] .menu-btn, body[data-view="done"] .menu-btn { display: block; }
body[data-view="intro"] #era-tag, body[data-view="done"] #era-tag,
body[data-view="intro"] .pips, body[data-view="intro"] .score { display: none; }
.tag.slam { animation: score-slam .5s ease-out; }
.tag.mute {
  position: fixed; right: 24px; bottom: 20px; z-index: 5; padding: 4px; display: flex;
  border: 0; cursor: pointer; color: var(--gold);
}
.tag.mute svg { width: 22px; height: 18px; display: block; }
.tag.music { right: 64px; }
.tag.music svg { width: 18px; height: 18px; }
.tag.music.off { opacity: 0.7; }
.tag.mute:hover { color: #fff; }
body.kb .tag.mute { display: none; }

.pips { display: flex; gap: 6px; }
.pip {
  width: 14px; height: 14px; background: #0c0817b3;
  box-shadow: 0 0 0 2px var(--edge-dark), 0 0 0 3px var(--edge);
  transition: background .2s;
}
.pip.now { box-shadow: 0 0 0 2px var(--edge-dark), 0 0 0 3px var(--teal), 0 0 10px #5ee6c988; animation: glow-pulse 1s steps(2) infinite; }
.pip.filled { animation: pip-pop .35s ease-out; }

/* ---------- Menu ---------- */
.menu {
  position: fixed; inset: 0; z-index: 8; display: grid; place-items: center; padding: 16px;
  background: #060310d9; animation: fade-in .2s;
}
.menu-card { width: min(480px, 100%); padding: 20px 24px 26px; background: #1a1233; }
.menu-head { display: flex; justify-content: space-between; align-items: start; margin-bottom: 18px; }
.menu-head .eyebrow { margin: 0 0 4px; color: var(--teal); letter-spacing: 3px; }
.menu-head .logo { margin: 0; font-size: 32px; }
.menu-x { font: inherit; font-size: 26px; padding: 2px 12px; border: 0; cursor: pointer; color: var(--muted); }
@media (hover: hover) { .menu-x:hover { color: #fff; } }
.menu-section { display: flex; align-items: center; gap: 12px; letter-spacing: 3px; margin-bottom: 16px; }
.menu-section::after { content: ""; flex: 1; border-top: 2px dashed var(--edge); }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 22px 8px 18px;
  background: var(--night-2); color: var(--muted); text-decoration: none; text-align: center;
  text-transform: uppercase; letter-spacing: 2px; font-size: 20px;
  box-shadow: 0 0 0 2px var(--edge-dark), 0 0 0 4px var(--edge), 0 4px 0 4px var(--edge-dark);
  transition: color .1s;
}
.tile svg { height: 24px; width: auto; display: block; }
.tile.now { color: var(--amber); box-shadow: 0 0 0 2px var(--edge-dark), 0 0 0 4px var(--amber), 0 4px 0 4px var(--edge-dark); }
@media (hover: hover) { .tile:hover { color: var(--text); } }
.tile:focus-visible, .menu-x:focus-visible, .menu-btn:focus-visible { outline: 2px dashed var(--teal); outline-offset: 5px; }

/* ---------- Centre stage ---------- */
.stage {
  position: fixed; z-index: 4; left: 0; right: 0; top: 64px; bottom: var(--ground-h);
  display: grid; place-items: center; padding: 12px 24px 28px; pointer-events: none;
}
body.free .stage { bottom: 0; padding-bottom: 20px; }
.card {
  pointer-events: auto; width: min(640px, 100%); max-height: 100%; overflow: auto;
  padding: 18px 24px; animation: card-in .35s cubic-bezier(.2, 1.4, .4, 1);
}
.logo {
  margin: 0 0 8px; font-family: var(--display); font-weight: normal; font-size: 44px; letter-spacing: 3px; color: var(--amber);
  text-shadow: 4px 4px 0 #7a3a1a, 0 0 22px #ffb54766; animation: title-flicker 6s infinite;
}
.eyebrow { margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-size: 20px; }
/* Infinite time-travel start screen: ERALY ∞, gold line, gold edge (like the Infinite Pass) */
#intro.infinite { box-shadow: 0 0 0 2px var(--edge-dark), 0 0 0 4px var(--gold), 0 4px 0 4px var(--edge-dark), 0 0 30px 6px #ffd16640, 8px 10px 0 4px #00000055; }
#intro.infinite .eyebrow { color: var(--gold); }
#intro.infinite .logo { display: flex; align-items: center; gap: .4em; }
#intro.infinite .logo svg { width: 1.45em; flex: none; color: var(--gold); filter: drop-shadow(0 0 8px #ffd166aa); }
.rules { margin: 0 0 16px; padding-left: 22px; }
.rules li { margin: 4px 0; }
.rules b { color: var(--amber); font-weight: normal; }

.bands { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; font-size: 20px; }
.bands span { padding: 1px 6px; color: var(--night); }
.b100 { background: var(--gold); } .b85 { background: var(--teal); } .b60 { background: var(--lime); }
.b30 { background: var(--orange); } .b10 { background: var(--rose); }

.prompt-card { text-align: center; width: fit-content; max-width: min(900px, 100%); padding: 18px 40px; } /* hugs the prompt */
.prompt { margin: 0; font-size: 64px; font-weight: normal; line-height: 1; }
.context { margin: 12px 0 0; color: var(--muted); font-size: 28px; }
.context:empty { display: none; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-size: 28px; cursor: pointer; border: 0; padding: 8px 20px;
  color: var(--night); background: var(--amber);
  box-shadow: 0 0 0 2px var(--edge-dark), 0 4px 0 2px #a0601a;
  transition: transform .08s;
  animation: btn-bob 2.4s ease-in-out infinite;
}
@media (hover: hover) { .btn:hover { background: var(--gold); } }
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 2px var(--edge-dark), 0 1px 0 2px #a0601a; }
.btn:focus-visible { outline: 2px dashed var(--teal); outline-offset: 5px; }

/* ---------- Answer bar on the ground ---------- */
.ground {
  position: fixed; z-index: 5; left: 0; right: 0; bottom: 0; height: var(--ground-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  animation: fade-up .3s both;
}
.answer { display: flex; gap: 18px; align-items: stretch; }
.answer .btn { animation: none; font-size: 34px; padding: 0 26px; }
#guess {
  width: 280px; font: inherit; font-size: 64px; text-align: center; letter-spacing: 8px; text-indent: 8px;
  color: var(--gold); background: #0c0817e6; border: 0; padding: 4px 12px; caret-color: var(--teal);
  box-shadow: inset 0 0 0 2px var(--edge-dark), 0 0 0 4px var(--edge), 0 6px 0 4px var(--edge-dark);
}
#guess:focus { outline: none; box-shadow: inset 0 0 0 2px var(--edge-dark), 0 0 0 4px var(--teal), 0 6px 0 4px var(--edge-dark), 0 0 20px #5ee6c955; }
#guess::placeholder { color: #4a3f6a; letter-spacing: 4px; }
.answer.shake { animation: shake .4s; }

.timer {
  position: relative; width: 64px; height: 64px; align-self: center; display: flex; justify-content: center; align-items: center;
  background: #0c0817e6; padding: 6px; box-shadow: 0 0 0 4px var(--edge), 0 6px 0 4px var(--edge-dark);
}
#timer-num { font-size: 32px; color: var(--teal); line-height: 1; }
/* Time left: a bar around the frame that empties clockwise from 12 o'clock */
.timer-ring { position: absolute; inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px); overflow: visible; pointer-events: none; }
#timer-fill { fill: none; stroke: var(--teal); stroke-width: 4; stroke-dasharray: 100 200; shape-rendering: crispEdges; }
.timer.low #timer-num { color: var(--rose); animation: glow-pulse .5s steps(2) infinite; }
.timer.low #timer-fill { stroke: var(--rose); }

.hint { margin: 0; color: var(--text); opacity: .75; font-size: 20px; text-shadow: 2px 2px 0 #000; }
.hint.err { color: var(--rose); opacity: 1; }

/* ---------- Walk overlays ---------- */
.sign, .flash { position: fixed; left: 0; top: 0; z-index: 3; pointer-events: none; transform: translate(-50%, -100%); }
/* Score stakes in the ground: where each score would take you. Below the feet, so the board never hides them. */
.marks { position: fixed; inset: 0; z-index: 2; pointer-events: none; }
.mark-line {
  position: absolute; left: 0; width: 0; height: 9vh; margin-left: -1px;
  border-left: 2px dashed var(--c); opacity: .25; transition: opacity .25s;
  filter: drop-shadow(2px 2px 0 #0009);
}
/* little stake head on the ground surface */
.mark-line::before { content: ""; position: absolute; left: -6px; top: -3px; width: 10px; height: 6px; background: var(--c); }
.mark-line span { position: absolute; top: 100%; left: 0; transform: translateX(-50%); padding-top: 6px; font-size: 22px; color: var(--c); }
/* Dim until the traveller walks over them; the one he lands on lights up fully */
.mark-line.passed { opacity: .75; }
.mark-line.target.passed { opacity: 1; }
.mark-line.target.passed span { font-size: 26px; }

/* +85 and +100: the world dims around the traveller, then a flash at the star burst (teal for +85) */
.vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0; transition: opacity .9s ease;
  background: radial-gradient(circle at var(--vx, 25%) var(--vy, 70%), transparent 0 9%, #06031070 22%, #060310e0 55%, #060310f5 100%);
}
.vignette.on { opacity: 1; }
/* +100: darker, and the spotlight closes in during the build-up (game.js sets --hole and opacity every frame) */
.vignette.deep {
  transition: none;
  background: radial-gradient(circle at var(--vx, 25%) var(--vy, 70%), transparent 0 var(--hole, 6%), #060310a0 calc(var(--hole, 6%) + 10%),
    #060310f0 calc(var(--hole, 6%) + 34%), #060310 100%);
}
.flashbang { position: fixed; inset: 0; z-index: 6; pointer-events: none; opacity: 0; background: radial-gradient(circle, #fff6d8 0%, #ffd16655 60%, transparent 100%); }
.flashbang.fire { background: radial-gradient(circle at 20% 75%, #ffd166cc 0%, #ff6a2a66 35%, transparent 75%); }
.flashbang.teal { background: radial-gradient(circle, #e0fff8 0%, #5ee6c955 60%, transparent 100%); }
.flashbang.go { animation: flashbang .7s ease-out; }
/* Last 5 seconds: the top and side edges glow amber, flaring with each warning bip */
.edge-glow {
  position: fixed; inset: 0; z-index: 4; pointer-events: none; opacity: 0; transition: opacity .3s;
  box-shadow: inset 0 60px 60px -45px #ffb03a, inset 60px 0 60px -45px #ffb03a, inset -60px 0 60px -45px #ffb03a;
}
.edge-glow.on { opacity: .3; }
.edge-glow.on.flare { animation: edge-flare .8s ease-out; }
@keyframes edge-flare { from { opacity: .8; } }

/* Board held above the traveller's head */
.sign {
  padding: 2px 10px; font-size: 30px; color: var(--night); line-height: 1.1;
  box-shadow: 0 0 0 2px var(--edge-dark), 0 4px 0 2px #00000066;
  margin-top: -28px; animation: sign-pop .3s cubic-bezier(.2, 1.6, .4, 1);
}
.sign::after { content: ""; position: absolute; left: 50%; top: 100%; width: 4px; height: 22px; margin-left: -2px; background: #5a3a24; box-shadow: 0 0 0 1px var(--edge-dark); }
/* "+60 Historian" above the board */
.flash {
  display: flex; flex-direction: column; align-items: center; line-height: 1;
  text-shadow: 3px 3px 0 var(--edge-dark); opacity: 0; /* points stay hidden until he stops at his line */
}
.flash b { font-family: var(--display); font-weight: normal; font-size: 26px; }
.flash span { font-size: 22px; text-transform: uppercase; letter-spacing: 2px; margin-top: 4px; }
.flash.arrived { opacity: 1; }
.flash.arrived > * { animation: score-slam .6s ease-out; }
/* Shimmering label: teal for +85, gold (and bigger) for +100 */
.flash.close b, .flash.close span, .flash.perfect b, .flash.perfect span {
  background: linear-gradient(90deg, var(--shine)); background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: none;
  filter: drop-shadow(2px 2px 0 var(--edge-dark)) drop-shadow(0 0 10px var(--glow));
}
.flash.close { --shine: #5ee6c9, #e0fff8, #2fb89c, #8ff0dc, #5ee6c9; --glow: #5ee6c999; }
.flash.perfect { --shine: #ffd166, #fff6d8, #ffb03a, #ffffff, #ffd166; --glow: #ffd166bb; }
.flash.close b { font-size: 34px; }
.flash.perfect b { font-size: 40px; }
.flash.close > *, .flash.perfect > * { animation: shimmer 1.4s linear infinite; }
.flash.close.arrived > *, .flash.perfect.arrived > * { animation: score-slam .6s ease-out, shimmer 1.4s linear infinite; }

/* The board flies out of his hands when he trips */
.sign.tumble { animation: sign-tumble .8s cubic-bezier(.3, 0, .6, 1) forwards; }

/* ---------- Reveal ---------- */
/* Number line: guess label above its marker, answer label below its marker */
.line { position: relative; height: 124px; margin: 6px 12px 22px; } /* tall enough for the answer label below */
.line::before { content: ""; position: absolute; left: 0; right: 0; top: 54px; height: 4px; background: var(--edge); }
.gap { position: absolute; top: 52px; height: 8px; animation: grow .5s .3s both steps(12); }
.mark { position: absolute; top: 0; bottom: 0; width: 0; }
.mark::after { content: ""; position: absolute; left: -6px; top: 44px; width: 12px; height: 24px; box-shadow: 0 0 0 2px var(--edge-dark); }
.mark.you::after { background: var(--teal); }
.mark.ans::after { background: var(--gold); }
.lbl {
  position: absolute; left: 0; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; white-space: nowrap;
  font-size: 16px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted);
}
.lbl b { font-family: var(--display); font-weight: normal; font-size: 22px; letter-spacing: 0; margin: 4px 0; }
.you .lbl { top: 0; }
.you .lbl b { color: var(--teal); }
.ans .lbl { top: 70px; }
.ans .lbl b { color: var(--gold); order: -1; }
.mark.ans { animation: drop .35s .15s both; }

.verdict { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; font-size: 22px; }
.points { font-size: 30px; padding: 0 10px; color: var(--night); animation: score-slam .6s .3s ease-out both; }
.fact { margin: 0 0 14px; font-size: 22px; animation: fade-up .5s .45s both; }
#reveal .btn { display: block; margin-left: auto; font-size: 24px; padding: 6px 16px; }

/* ---------- Done ---------- */
.done-card { width: min(580px, 100%); }
/* Laptops: the whole results card a touch smaller (zoom keeps it identical, just 90%); phones keep full size */
@media (min-width: 601px) { .done-card { zoom: .9; } }
/* It scrolls, but without a visible bar (the cut-off rows already show there's more) */
.done-card { scrollbar-width: none; }
.done-card::-webkit-scrollbar { display: none; }
/* Dividers on the results, a little brighter than the frame colour so they show on the dimmed scene */
#done { --rule: #54478a; }
#done .log-title::after { border-top-color: var(--rule); }
/* The score is on the results already, so the HUD's score tag steps aside (keeping its space, so the pips stay put) */
body[data-view="done"] .tag.score, body[data-view="done"] .pips { visibility: hidden; }
/* Results scroll the full height of the screen, under the menu button, instead of stopping short of the top and bottom */
body[data-view="done"] .stage { top: 0; bottom: 0; padding-top: 0; padding-bottom: 0; }
body[data-view="done"] .done-card { padding-top: 84px; padding-bottom: 40px; }
@media (max-width: 600px) { body[data-view="done"] .done-card { padding-top: 64px; padding-bottom: 28px; } }
/* No box around the results: the text sits on the scene, dimmed behind it (under the HUD and mute button) */
.done-card { background: none; box-shadow: none; animation: none; }
body[data-view="done"] .stage::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: rgba(6, 3, 16, .6); animation: dim-in .4s both;
}
@keyframes dim-in { from { opacity: 0; } }
.total { font-family: var(--display); font-size: 56px; line-height: 1; color: var(--gold); margin: 6px 0 10px; text-shadow: 4px 4px 0 #7a3a1a; animation: score-slam .7s ease-out; transform-origin: left center; } /* grows to the right, so the card edge never clips it */
.total small { font-size: 20px; color: var(--muted); text-shadow: none; margin-left: 6px; }
.reached { margin: 0 0 18px; font-size: 22px; color: var(--teal); }
/* Wardrobe unlock: only on the day something new is earned */
.unlock {
  display: flex; align-items: center; gap: 14px; width: fit-content; max-width: 100%; margin: -6px 0 20px; padding: 10px 16px 10px 10px;
  color: var(--text); text-decoration: none; background: #0c081766; box-shadow: 0 0 0 2px var(--gold), 0 0 18px #ffd16633;
}
.unlock canvas { width: 80px; height: 72px; image-rendering: pixelated; flex: none; }
.unlock span { display: flex; flex-direction: column; text-align: left; }
.unlock b { font-family: var(--display); font-weight: normal; font-size: 14px; color: var(--gold); margin-bottom: 6px; }
.unlock strong { font-weight: normal; font-size: 24px; line-height: 1; }
.unlock small { font-size: 18px; color: var(--muted); }
@media (hover: hover) { .unlock:hover strong { color: var(--gold); } }
.unlock:focus-visible { outline: 2px dashed var(--teal); outline-offset: 5px; }

/* Everyone's scores: smooth curve, you marked on it */
.curve { --plot-h: 130px; position: relative; margin: 4px 0 30px; }
.curve svg { display: block; width: 100%; height: var(--plot-h); overflow: visible; }
.curve .area { fill: #5ee6c922; }
.curve .ln { fill: none; stroke: var(--teal); stroke-width: 3; vector-effect: non-scaling-stroke; }
.curve .you { stroke: var(--rose); stroke-width: 2; vector-effect: non-scaling-stroke; }
.you-dot { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; background: var(--rose); box-shadow: 0 0 0 2px var(--edge-dark), 0 0 10px var(--rose); }
.you-lbl { position: absolute; top: calc(100% + 2px); transform: translateX(-50%); font-weight: normal; font-size: 18px; color: var(--rose); letter-spacing: 1px; }
.axis { display: flex; justify-content: space-between; border-top: 2px solid var(--edge); padding-top: 4px; font-size: 16px; color: var(--muted); }
.axis span { width: 0; display: flex; justify-content: center; }
.pct { margin: 0 0 22px; font-size: 22px; color: var(--teal); text-transform: uppercase; letter-spacing: 1px; }

/* Time log: a stake per question over dashed tier lines */
.log-title { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; font-weight: normal; }
.log-title span { color: #6a5f8a; }
.log-title::after { content: ""; flex: 1; border-top: 2px dashed var(--edge); }
.tlog { position: relative; height: 182px; margin: 0 14px 34px 30px; border-left: 2px solid var(--edge); }
.guide { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px dashed var(--c); opacity: .4; }
.guide span { position: absolute; top: 100%; left: 0; transform: translateX(-50%); padding-top: 6px; font-size: 16px; color: var(--c); }
.stake { position: absolute; left: 0; height: 0; width: var(--h); border-top: 2px solid var(--c); margin-top: -1px; animation: stake-out .5s steps(10) backwards; }
.stake i { position: absolute; right: -7px; top: -7px; width: 12px; height: 12px; background: var(--c); box-shadow: 0 0 0 2px var(--edge-dark), 0 0 10px var(--c); }
.stake b { position: absolute; right: calc(100% + 10px); top: -10px; font-weight: normal; font-size: 18px; color: var(--muted); }

.tiles { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 4px; font-size: 20px; }
.tiles li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 4px 8px; background: var(--night-2); animation: fade-up .3s both; }
.tiles li > span:first-child { display: grid; grid-template-columns: 22px 1fr; }
.tiles li b { font-weight: normal; color: var(--muted); }
.tiles li small { grid-column: 2; font-size: 17px; color: var(--muted); }
.tiles li > span:last-child { color: var(--night); padding: 0 8px; flex: none; }
.row { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 8px; }
.card .hint { text-shadow: none; color: var(--muted); }
/* Results buttons: Copy result + Share… on one row, the big ∞ button under them */
#done .row { flex-wrap: nowrap; gap: 14px; margin-bottom: 18px; padding-top: 22px; border-top: 2px dashed var(--rule); }
#done .row .btn { animation: none; font-size: 24px; padding: 10px 16px; letter-spacing: 2px; text-transform: uppercase; }
#share { flex: 1; }
/* Share…: amber outline, so it pairs with Copy result without looking like the question rows */
.share-to { color: var(--amber); background: transparent; box-shadow: 0 0 0 2px var(--amber), 0 4px 0 2px #a0601a; }
@media (hover: hover) { .share-to:hover { color: var(--night); background: var(--amber); } }
.share-to:active { box-shadow: 0 0 0 2px var(--amber), 0 1px 0 2px #a0601a; }
.infinite-btn {
  display: flex; justify-content: center; align-items: center; gap: 12px; margin: 0 0 22px; padding: 10px 16px;
  font-size: 24px; letter-spacing: 2px; text-transform: uppercase; color: var(--night); background: var(--teal); text-decoration: none;
  box-shadow: 0 0 0 2px var(--edge-dark), 0 4px 0 2px #2a8f7a, 0 0 22px #5ee6c944; transition: transform .08s;
}
.infinite-btn svg { height: 14px; width: auto; }
@media (hover: hover) { .infinite-btn:hover { background: #8ff0dc; } }
.infinite-btn:active { transform: translateY(3px); box-shadow: 0 0 0 2px var(--edge-dark), 0 1px 0 2px #2a8f7a; }
.infinite-btn:focus-visible { outline: 2px dashed var(--teal); outline-offset: 5px; }

/* Idea box and rating, quiet, at the bottom of the results */
.say { margin: 24px 0 4px; padding-top: 22px; border-top: 2px dashed var(--rule); }
.say-q { display: block; margin: 0 0 10px; font-size: 18px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }
.idea-line { display: flex; align-items: flex-end; gap: 18px; }
#idea-text {
  flex: 1; min-width: 0; font: inherit; font-size: 20px; color: var(--text); background: none; border: 0; padding: 4px 0;
  border-bottom: 2px solid var(--edge); border-radius: 0; caret-color: var(--teal); outline: none;
}
#idea-text::placeholder { color: #6a5f8a; }
#idea-text:focus { border-bottom-color: var(--teal); }
.idea-line button, .rate-row button { font: inherit; cursor: pointer; background: none; border: 0; color: var(--muted); }
.idea-line button { padding: 4px 0; font-size: 18px; letter-spacing: 2px; text-transform: uppercase; }
@media (hover: hover) { .idea-line button:hover { color: var(--teal); } }
.idea-line button:disabled { opacity: .5; cursor: default; }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.say-done { margin: 0; color: var(--teal); font-size: 20px; }
.say-done.err { color: var(--rose); }
/* Clipped sideways so the waiting Send (28px to the right) can't widen the results and wobble them on phones; the padding keeps room for focus outlines */
.rate-row { display: flex; gap: 12px; overflow-x: clip; padding: 6px; margin: -6px; }
.rate-row button { width: 56px; height: 56px; font-size: 22px; box-shadow: inset 0 0 0 2px var(--edge); }
@media (hover: hover) { .rate-row button:not(:disabled):hover { color: var(--teal); box-shadow: inset 0 0 0 2px var(--teal); } }
.rate-row button:disabled { cursor: default; opacity: .45; }
.rate-row button.on { opacity: 1; color: var(--night); background: var(--teal); box-shadow: inset 0 0 0 2px var(--teal); }
/* A picked number is only lit up; Send (its space always kept, so the numbers never move) slides in to count it */
.rate-row button.pick { opacity: 1; color: var(--teal); box-shadow: inset 0 0 0 2px var(--teal); background: #5ee6c922; }
.rate-row .rate-send { width: 96px; font-size: 18px; letter-spacing: 2px; text-transform: uppercase; }
.rate-row .rate-send:not(.shown) { opacity: 0; transform: translateX(28px); pointer-events: none; }
.rate-row .rate-send.shown { opacity: 1; transition: opacity .55s ease-out, transform .55s cubic-bezier(.2, .9, .3, 1.15); }
.rate-row .rate-send:not(:disabled) { color: var(--night); background: var(--teal); box-shadow: inset 0 0 0 2px var(--teal); }
@media (hover: hover) { .rate-row .rate-send:not(:disabled):hover { color: var(--night); background: #8ff0dc; } }
.rate-row .rate-send.sent { color: var(--teal); background: none; box-shadow: inset 0 0 0 2px var(--teal); }
.rate-row button:focus-visible, .idea-line button:focus-visible { outline: 2px dashed var(--teal); outline-offset: 4px; }

/* Infinite: "seen everything" note above the buttons */
.more { margin: 0 0 22px; padding: 12px 16px; box-shadow: 0 0 0 2px var(--teal); }
.more p { margin: 0; color: var(--teal); }
.more .btn { margin-top: 10px; font-size: 22px; padding: 4px 14px; color: var(--teal); background: transparent; box-shadow: 0 0 0 2px var(--teal); }
@media (hover: hover) { .more .btn:hover { color: var(--night); background: var(--teal); } }

/* ---------- Animations ---------- */
@keyframes title-flicker { 0%, 93%, 95.5%, 100% { opacity: 1 } 93.6% { opacity: .65 } 94.4% { opacity: .95 } 95% { opacity: .6 } }
@keyframes crt-zap { 0%, 96% { opacity: 1 } 97% { opacity: .4; transform: translateY(2px) } 98% { opacity: .8; transform: translateY(-1px) } }
@keyframes card-in { from { opacity: 0; transform: translateY(30px) scale(.94) } }
@keyframes score-slam { 0% { transform: scale(1) } 35% { transform: scale(1.35) rotate(-2deg); filter: drop-shadow(0 0 14px #ffd166) } 100% { transform: scale(1) } }
@keyframes shake { 0%, 100% { transform: translate(0) } 20% { transform: translate(-8px, 3px) } 40% { transform: translate(7px, -3px) } 60% { transform: translate(-5px, 2px) } 80% { transform: translate(3px, -1px) } }
@keyframes fade-up { from { opacity: 0; transform: translateY(10px) } }
@keyframes glow-pulse { 50% { opacity: .55 } }
@keyframes btn-bob { 0%, 100% { translate: 0 0 } 50% { translate: 0 -3px } }
@keyframes pip-pop { 50% { transform: scale(1.3) } }
@keyframes grow { from { transform: scaleX(0) } }
@keyframes shimmer { to { background-position: -300% 0 } }
@keyframes flashbang { 0% { opacity: .85 } 100% { opacity: 0 } }
@keyframes sign-tumble { 30% { transform: translate(0%, -170%) rotate(80deg) } 100% { transform: translate(60%, 160%) rotate(200deg); opacity: 0 } }
@keyframes fade-in { from { opacity: 0 } }
@keyframes sign-pop { from { transform: translate(-50%, -100%) scale(.2) } }
@keyframes stake-out { from { width: 0 } }
@keyframes drop { from { opacity: 0; transform: translateY(-16px) } }

/* ---------- Phones ---------- */
@media (max-width: 600px) {
  body { font-size: 21px; }
  /* one row: era · small progress pips · score */
  .hud { top: max(10px, env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; justify-content: space-between; gap: 8px; } /* pips float midway between the tags */
  .tag { font-size: 19px; padding: 2px 6px; }
  .menu-btn { padding: 6px 7px; }
  .menu-btn svg { width: 18px; height: 14px; }
  .menu-card { padding: 16px 16px 20px; }
  .menu-grid { gap: 12px; }
  .tile { font-size: 18px; letter-spacing: 1px; padding: 18px 6px 14px; }
  .tag.mute { right: 12px; bottom: max(10px, env(safe-area-inset-bottom)); padding: 3px; }
  .tag.music { right: 48px; }
  body[data-view="done"] .tag.mute { display: none; } /* the results card fills the phone screen */
  #era-tag { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .pips { gap: 3px; }
  .pip { width: 8px; height: 8px; box-shadow: 0 0 0 1px var(--edge-dark), 0 0 0 2px var(--edge); }
  .pip.now { box-shadow: 0 0 0 1px var(--edge-dark), 0 0 0 2px var(--teal), 0 0 6px #5ee6c988; }
  .stage { top: 56px; padding: 8px 16px 16px; }
  .card { padding: 14px 16px; }
  .logo { font-size: 32px; letter-spacing: 2px; }
  .eyebrow { font-size: 18px; }
  .rules { padding-left: 18px; }
  .bands { font-size: 18px; }
  .prompt-card { padding: 14px 18px; }
  .prompt { font-size: 38px; }
  .context { font-size: 22px; margin-top: 8px; }
  .btn { font-size: 24px; }

  .ground { padding-bottom: env(safe-area-inset-bottom); }
  .answer { gap: 10px; }
  .answer .btn { font-size: 28px; padding: 0 18px; }
  #guess { width: 150px; font-size: 50px; letter-spacing: 4px; text-indent: 4px; padding: 2px 8px; }
  .timer { width: 54px; height: 54px; }
  #timer-num { font-size: 28px; }
  .hint { font-size: 18px; }

  .sign { font-size: 26px; }
  .mark-line span { font-size: 18px; }
  .mark-line.target.passed span { font-size: 22px; }

  .lbl b { font-size: 18px; }
  .verdict { font-size: 20px; flex-wrap: wrap; }
  .points { font-size: 26px; }
  .fact { font-size: 20px; }
  .total { font-size: 44px; }
  .tlog { height: 168px; }
  .reached { font-size: 20px; }
  .tiles { font-size: 18px; }
  #done .row { gap: 10px; }
  #done .row .btn, .infinite-btn { font-size: 20px; letter-spacing: 1px; padding: 9px 12px; }
  .say-q { font-size: 16px; letter-spacing: 1px; }
  .rate-row { gap: 8px; }
  .rate-row button { flex: 1; width: auto; height: 50px; }
  .rate-row .rate-send { flex: 1.7; font-size: 16px; letter-spacing: 1px; }
  #reveal { align-self: start; } /* keep the traveller in view below it */
  body[data-view="reveal"] .sign, body[data-view="reveal"] .flash { display: none; } /* tucked behind the card; it repeats them */
}

/* Landscape phones: little height to spare */
@media (max-height: 500px) {
  .hud { top: max(8px, env(safe-area-inset-top)); grid-template-columns: 1fr auto 1fr; }
  .tag { font-size: 20px; padding: 2px 8px; }
  .stage { top: 46px; padding: 6px 16px 10px; }
  .card { padding: 10px 16px; }
  .logo { font-size: 28px; margin-bottom: 4px; }
  .rules { margin-bottom: 10px; }
  .rules li { margin: 2px 0; }
  .bands { margin-bottom: 12px; }
  .prompt { font-size: 34px; }
  .context { font-size: 20px; }
  .answer .btn { font-size: 26px; }
  #guess { font-size: 42px; width: 140px; }
  .timer { width: 48px; height: 48px; }
  .ground { gap: 4px; }
  .line { height: 112px; margin-bottom: 12px; }
  #reveal { justify-self: end; width: min(560px, 68%); } /* the traveller stands at the left */
}

/* Phone keyboard open (game.js sets body.kb and the --vv/--bar/--stage values) */
body.kb .hud { top: calc(var(--vv-top) + 8px); }
body.kb .stage { top: var(--stage-top); bottom: auto; height: var(--stage-h); padding: 4px 16px; align-items: start; } /* card under the HUD, clear of the traveller */
body.kb .ground { top: var(--bar-top); bottom: auto; height: auto; padding: 10px 0; gap: 6px; animation: none; }
body.kb .prompt { font-size: 32px; }
body.kb .context { font-size: 20px; }
body.kb-tight .hud, body.kb-tight .context, body.kb-tight .hint { display: none; }
body.kb-tight .prompt { font-size: 26px; }
body.kb-tight .prompt-card { padding: 8px 14px; }

@media (prefers-reduced-motion: reduce) {
  *, .crt { animation: none !important; transition: none !important; }
}
