/* One in a Swarm. One fixed theme: a pixel-art sky behind navy panels with stepped corners.
   GT Navy and Tech Gold anchor the palette; --accent is the one bright colour and marks
   everything you can press. tests/contrast.test.js checks the text pairs below. */

@font-face {
  font-family: "Press Start 2P";
  src: url("../assets/fonts/press-start-2p.woff2") format("woff2");
  font-display: swap;
}

:root {
  --navy: #003057;
  --gold: #b3a369;
  --panel: #0b2a4a;
  --panel-2: #123a63;
  --ink: #f4f1e6;
  --muted: #b9c7d6;
  --edge: #f4f1e6;
  --accent: #ffd23f;
  --accent-ink: #00213d;
  --bad: #ffa397;
  --good: #8fe3b0;
  --miss-ink: #ffffff;

  --t-common: #c3ccd6;
  --t-clever: #35c29f;
  --t-solid: #f0a23a;
  --t-rare: #62b5f0;
  --t-deep: #d68ac0;
  --t-swarm: #ffd23f;
  --t-miss: #5b6675;
  --tier-ink: #00213d;

  --kb: 0px; /* height of the on-screen keyboard, set from visualViewport */
  --hud-h: 66px; /* measured height of the HUD, so the prompt always sits just below it */
  --pixel: "Press Start 2P", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  /* Stepped corners, two 4px steps. */
  --steps: polygon(0 8px, 4px 8px, 4px 4px, 8px 4px, 8px 0, calc(100% - 8px) 0, calc(100% - 8px) 4px, calc(100% - 4px) 4px, calc(100% - 4px) 8px, 100% 8px, 100% calc(100% - 8px), calc(100% - 4px) calc(100% - 8px), calc(100% - 4px) calc(100% - 4px), calc(100% - 8px) calc(100% - 4px), calc(100% - 8px) 100%, 8px 100%, 8px calc(100% - 4px), 4px calc(100% - 4px), 4px calc(100% - 8px), 0 calc(100% - 8px));
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font-family: var(--mono); font-size: 0.95rem; line-height: 1.45;
  color: var(--ink); background: var(--navy);
  overflow-x: hidden;
}
body.playing { overflow: hidden; }

[hidden] { display: none !important; }
p { margin: 0 0 0.6rem; }
h1, h2 { margin: 0 0 0.5rem; line-height: 1.25; }
.pixel { font-family: var(--pixel); font-weight: 400; letter-spacing: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.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: fixed; left: 8px; top: -80px; z-index: 50; background: var(--accent); color: var(--accent-ink); padding: 0.7rem 0.9rem; font-weight: 700; }
.skip:focus { top: 8px; }

/* ----- the world ----- */

#world { position: fixed; left: 0; top: 0; z-index: 0; image-rendering: crisp-edges; image-rendering: pixelated; }
canvas, .art, .pip-icon { image-rendering: pixelated; }
/* The safe area: the clear band of screen between the HUD (or prompt) and the answer bar (or
   reveal button). Tier lines are cut off at its edges. A fact is shown only when the whole of
   it is inside, so no text is ever half under a panel. */
#worldWindow { /* the box never moves or resizes (no layout shift); only what shows through it does */
  position: fixed; inset: 0; z-index: 1; clip-path: inset(var(--win-top, 0px) 0 var(--win-bottom, 0px) 0);
  overflow: hidden; pointer-events: none;
}
#worldLayer { position: absolute; left: 0; right: 0; top: 0; height: 0; will-change: transform; }
.fact { transition: opacity 0.15s linear; }
.fact.yield { opacity: 0; }
#scan {
  position: fixed; inset: 0; z-index: 40; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0, 8, 20, 0.13) 0 1px, transparent 1px 3px);
}
body.no-scan #scan { display: none; }
#flash { position: fixed; inset: 0; z-index: 30; pointer-events: none; background: var(--accent); opacity: 0; }
#flash.go { animation: flash 0.9s ease-out; }
@keyframes flash { 0% { opacity: 0.7; } 100% { opacity: 0; } }
body.shake #world, body.shake .reveal { animation: quake 0.45s linear; }
@keyframes quake { 20% { transform: translate(-6px, 3px); } 40% { transform: translate(6px, -3px); } 60% { transform: translate(-4px, -2px); } 80% { transform: translate(4px, 2px); } }

/* Things that live in the world and slide past with it. */
.tier-line span, .tag {
  font-family: var(--mono); font-weight: 700; background: var(--panel); color: var(--ink);
  border: 2px solid var(--edge);
}
/* Facts: small text with a dotted leader running to the ruler, alternating sides. */
.fact {
  position: absolute; margin: 0; max-width: min(40vw, 260px); transform: translateY(-50%);
  font-family: var(--mono); font-size: 0.72rem; font-weight: 700; line-height: 1.25; color: #ffffff;
  text-shadow: 1px 1px 0 #00213d, -1px 1px 0 #00213d, 1px -1px 0 #00213d, -1px -1px 0 #00213d, 0 2px 0 #00213d;
}
.fact.left { left: 8px; }
.fact.right { right: calc(var(--ruler, 108px) + 8px); text-align: right; }
.fact::after { content: ""; position: absolute; top: 50%; border-top: 2px dotted rgba(244, 241, 230, 0.7); }
.fact.left::after { left: calc(100% + 6px); width: 100vw; }
.fact.right::after { left: calc(100% + 4px); width: var(--ruler, 108px); }
.tier-line { position: absolute; left: 0; right: var(--ruler, 90px); /* stops short of the ruler's numbers */ border-top: 3px dashed var(--line, var(--edge)); opacity: 0; }
.tier-line.on { opacity: 1; animation: line-pulse 0.5s ease-out; } /* a pulse as the answer passes */
.tier-line.won { border-top: 5px solid var(--line, var(--edge)); margin-top: -1px; box-shadow: 0 0 12px var(--line, var(--edge)); } /* where it stopped */
.tier-line.won span { outline: 2px solid #ffffff; }
/* a glow, never a change of size: the label is a child of the line and must stay one size */
@keyframes line-pulse { 0% { opacity: 0; box-shadow: 0 0 0 0 var(--line, var(--edge)); filter: brightness(1); } 30% { opacity: 1; box-shadow: 0 0 16px 4px var(--line, var(--edge)); filter: brightness(1.5); } 100% { opacity: 1; box-shadow: 0 0 0 0 transparent; filter: brightness(1); } }
.tier-line span { position: absolute; right: 6px; top: -13px; padding: 0.1rem 0.45rem; font-family: var(--pixel); font-size: 0.6rem; line-height: 1.6; background: var(--line, var(--panel)); color: var(--tier-ink); border-color: var(--tier-ink); }
.tag {
  position: fixed; z-index: 2; left: 50%; max-width: 46vw; padding: 0.35rem 0.6rem; font-size: 0.95rem; line-height: 1.2;
  background: var(--accent); color: var(--accent-ink); border: 3px solid var(--accent-ink);
  box-shadow: 4px 4px 0 rgba(0, 20, 40, 0.55); overflow-wrap: anywhere; pointer-events: none;
}

/* A small notice in the open sky, clear of the prompt and the answer bar. */
.toast {
  position: fixed; z-index: 7; left: 8px; top: 40vh; margin: 0; /* placed by the layout manager in app.js */
  padding: 0.35rem 0.5rem; max-width: 60vw; font-size: 0.5rem; line-height: 1.7; pointer-events: none; white-space: pre-line;
  background: var(--accent); color: var(--accent-ink); border: 2px solid var(--accent-ink);
}
/* One caption at a time, in the top corner of the safe area. */
.caption {
  position: fixed; z-index: 7; top: calc(var(--win-top, 80px) + 8px); left: 8px; margin: 0; max-width: min(62vw, 22rem); pointer-events: none;
  font-family: var(--mono); font-size: 0.8rem; font-weight: 700; font-style: italic; line-height: 1.3; color: var(--accent);
  text-shadow: 1px 1px 0 #00213d, -1px 1px 0 #00213d, 1px -1px 0 #00213d, -1px -1px 0 #00213d, 0 2px 0 #00213d;
  transition: opacity 0.3s linear;
}
.caption.out, .caption.yield, .toast.yield { opacity: 0; }
/* captions belong to the flight: never over the title screen panels' text or the results */
body[data-phase="results"] .caption, body[data-phase="infover"] .caption, body[data-phase="error"] .caption { display: none; }
.toast::first-line { font-size: 0.55rem; }
.sight-grid { list-style: none; margin: 0.4rem 0 0.6rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(8.6rem, 1fr)); gap: 0.3rem; }
.sight-grid li { display: flex; align-items: center; gap: 0.4rem; padding: 0.2rem 0.35rem; font-size: 0.78rem; background: var(--panel-2); min-width: 0; }
.sight-grid li::before { content: ""; flex: none; width: 12px; height: 12px; background: var(--accent); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.sight-grid li.unfound { color: var(--muted); }
.sight-grid li.unfound::before { background: #05080f; } /* a silhouette */
.night-line { margin: 0; font-style: italic; color: var(--accent); }

/* ----- panels and buttons ----- */

.panel { position: relative; isolation: isolate; clip-path: var(--steps); background: var(--edge); padding: 1rem 1.1rem; }
.panel::before { content: ""; position: absolute; inset: 3px; z-index: -1; clip-path: var(--steps); background: var(--panel); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 48px; padding: 0.6rem 1rem; border: 0; cursor: pointer;
  clip-path: var(--steps); background: var(--accent); color: var(--accent-ink);
  font-family: var(--pixel); font-size: 0.7rem; line-height: 1.4; text-align: center;
}
.btn:hover { background: #ffe07a; }
.btn:active { transform: translateY(2px); }
.btn-big { width: 100%; min-height: 60px; font-size: 0.9rem; }
.btn-small { min-height: 44px; font-size: 0.6rem; padding: 0.4rem 0.8rem; }
.btn-ghost { background: var(--panel-2); color: var(--ink); box-shadow: inset 0 0 0 3px var(--accent); }
.btn-ghost:hover { background: #1b4b7c; }
.btn[disabled], .btn[aria-disabled="true"] { background: var(--t-miss); color: var(--miss-ink); cursor: default; }

/* A clip-path cuts off outside outlines, so focus is drawn inside the shape. */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn:focus-visible { outline: 3px solid var(--accent-ink); outline-offset: -7px; }
.btn-ghost:focus-visible { outline-color: var(--ink); }
h1:focus-visible { outline: none; }

.tools { position: fixed; z-index: 20; top: max(6px, env(safe-area-inset-top)); right: 6px; display: flex; gap: 4px; }
.tool { width: 44px; height: 44px; padding: 9px; border: 0; cursor: pointer; background: var(--panel); clip-path: var(--steps); }
.tool svg { width: 100%; height: 100%; fill: var(--ink); image-rendering: pixelated; }
.tool:focus-visible { outline-offset: -6px; }
.tool[aria-pressed="false"] svg { fill: var(--muted); }
#soundBtn[aria-pressed="true"] .off, #soundBtn[aria-pressed="false"] .on { display: none; }
#scanBtn[aria-pressed="false"] { opacity: 0.75; }
body.playing #homeBtn, body.playing #scanBtn { display: none; }

main { position: relative; z-index: 5; }
.center-screen { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; text-align: center; }

/* ----- start screen ----- */

section[data-view="home"] { min-height: 100dvh; padding: 3.6rem 1rem 0.6rem; display: flex; flex-direction: column; align-items: center; }
.title-block { width: min(100%, 22rem); text-align: center; padding: 0.6rem 0.8rem 0.5rem; }
.home-gap { flex: 1 0 40vh; width: 100%; }
.flight-no { margin: 0 0 0.45rem; font-size: 0.55rem; color: var(--accent); }
.title { font-size: clamp(1.05rem, 5.6vw, 1.7rem); line-height: 1.3; margin: 0 0 0.4rem; color: var(--ink); text-shadow: 2px 2px 0 #00182f; }
.title span { color: var(--accent); }
.tagline { margin: 0; font-size: 0.82rem; }
.start-panel { width: min(100%, 26rem); display: grid; gap: 0.45rem; padding: 0.8rem 0.9rem; }
.start-panel p { margin: 0; }
.rule-line { font-weight: 700; }
.start-panel p:empty { display: none; }
/* Three small controls in a row. An opened one drops its contents across the full width below. */
.start-links { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; align-items: start; }
.start-links .btn, .start-links summary { min-height: 44px; padding: 0.3rem 0.4rem; justify-content: center; text-align: center; font-size: 0.5rem; line-height: 1.5; }
.start-links summary { background: var(--panel-2); box-shadow: inset 0 0 0 3px var(--accent); clip-path: var(--steps); color: var(--ink); }
.start-links summary::before { display: none; }
.start-links details[open] { grid-column: 1 / -1; }
.start-links > * { min-width: 0; }
.start-links summary { flex-direction: column; }
.start-links summary span { display: block; }
.start-panel .rule-line { font-size: 0.9rem; }
.start-panel .btn-big { min-height: 54px; }
.how summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-family: var(--pixel); font-size: 0.65rem; color: var(--accent); }
.how summary::before { content: "+"; margin-right: 0.6rem; }
.how[open] summary::before { content: "-"; }
.how summary::-webkit-details-marker { display: none; }
.rules { margin: 0 0 0.6rem; padding-left: 1.1rem; }
.rules li { margin-bottom: 0.45rem; }
.foot { margin: 0.6rem 0 0; padding: 0.3rem 0.6rem; max-width: 30rem; text-align: center; font-size: 0.72rem; background: var(--navy); color: var(--ink); }

/* ----- play ----- */

section[data-view="play"] { position: fixed; inset: 0; pointer-events: none; }
section[data-view="play"] > * { pointer-events: auto; }
.hud {
  position: fixed; z-index: 6; left: 6px; right: 56px; top: max(6px, env(safe-area-inset-top));
  display: grid; grid-template-columns: 1fr 1fr; grid-template-areas: "alt score" "mid mid"; align-items: center; gap: 0.25rem 0.5rem; padding: 0.45rem 0.8rem;
}
.hud-alt { grid-area: alt; }
.hud-score { grid-area: score; }
.hud .hud-mid { grid-area: mid; flex-direction: row; justify-content: center; align-items: center; gap: 0.6rem; }
.hud-cell { display: flex; flex-direction: column; min-width: 0; }
.hud .hud-alt, .hud .hud-score { flex-direction: row; align-items: center; gap: 0.4rem; }
.hud .hud-score { justify-content: flex-end; }
.hud-mid { align-items: center; }
.hud-label { font-size: 0.65rem; font-weight: 700; color: var(--muted); letter-spacing: 0.08em; }
.hud-num { font-size: 0.7rem; white-space: nowrap; }
.hud-num small { font-size: 0.55rem; color: var(--muted); }
.hud-text { margin: 0; font-size: 0.65rem; font-weight: 700; color: var(--muted); text-transform: uppercase; white-space: nowrap; }
.pips { list-style: none; display: flex; gap: 3px; margin: 0; padding: 0; }
.pips li { width: 16px; height: 16px; background: var(--panel-2); box-shadow: inset 0 0 0 2px var(--muted); }
.pips li.done { box-shadow: inset 0 0 0 2px var(--tier-ink); }
.pips li.now { box-shadow: inset 0 0 0 2px var(--accent); animation: pulse 0.9s steps(2, end) infinite; }
.pip-icon { display: block; width: 16px; height: 16px; }
@keyframes pulse { 50% { background: var(--accent); } }

.prompt-card { position: absolute; left: 6px; right: 6px; top: calc(max(6px, env(safe-area-inset-top)) + var(--hud-h, 66px) + 6px); max-width: 44rem; margin: 0 auto; padding: 0.7rem 0.9rem; }
.clar { margin: 0.25rem 0 0; font-size: 0.8rem; font-style: italic; color: var(--muted); } /* the short rule under a prompt */
.prompt-card.slide { animation: slide 0.35s steps(6, end); }
@keyframes slide { from { transform: translateY(-140%); } to { transform: none; } }
.eyebrow { margin: 0 0 0.25rem; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.prompt-card h1 { margin: 0; font-family: var(--mono); font-size: 1.05rem; font-weight: 700; line-height: 1.3; }
.liftoff { margin: 0.5rem 0 0; font-size: 0.6rem; line-height: 1.5; color: var(--accent); }

.dock { position: absolute; left: 6px; right: 6px; bottom: calc(max(6px, env(safe-area-inset-bottom)) + var(--kb)); max-width: 44rem; margin: 0 auto; }
.feedback { min-height: 1.5rem; margin: 0 0 0.25rem; padding: 0 0.4rem; font-weight: 700; }
.dock .feedback:not(:empty) { display: inline-block; background: var(--panel); border: 2px solid var(--edge); padding: 0.15rem 0.5rem; }
.feedback.bad { color: var(--bad); }
.feedback.good { color: var(--good); }
.tried { list-style: none; display: flex; gap: 0.3rem; margin: 0 0 0.25rem; padding: 0; overflow: hidden; white-space: nowrap; }
.tried li { flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; padding: 0 0.4rem; font-size: 0.75rem; background: var(--panel); color: var(--muted); text-decoration: line-through; border: 1px solid var(--muted); }
.dock-form { display: flex; align-items: center; gap: 0.5rem; padding: 0.55rem 0.6rem; }
.ring { position: relative; flex: none; width: 48px; height: 48px; display: grid; place-items: center; }
.ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 5; }
.ring-track { stroke: var(--panel-2); }
.ring-fill { stroke: var(--accent); stroke-dasharray: 125.66; stroke-dashoffset: 0; }
.ring span { position: relative; font-size: 0.7rem; }
.ring.low .ring-fill { stroke: var(--bad); }
.ring.low span { color: var(--bad); }
.ring.paused .ring-fill { stroke: var(--muted); }
.field { flex: 1 1 auto; min-width: 0; }
.field input {
  display: block; width: 100%; min-height: 44px; padding: 0.3rem 0.6rem;
  font-family: var(--mono); font-size: 1.05rem; font-weight: 700;
  color: var(--accent-ink); background: var(--ink); border: 3px solid var(--accent-ink); border-radius: 0;
}
.field input::placeholder { color: #51606f; opacity: 1; font-weight: 400; }
.field input:focus-visible { outline: 3px solid var(--accent); outline-offset: 0; }
.field.shake { animation: shake 0.3s linear; }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }
.bar { height: 4px; margin-top: 4px; background: var(--panel-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); transform-origin: left center; }
.bar.low i { background: var(--bad); }
.btn-fly { flex: none; min-height: 52px; font-size: 0.8rem; }
.dock-actions { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 0.4rem; }
body[data-phase="climb"] .dock, body[data-phase="climb"] .prompt-card { visibility: hidden; }
body[data-phase="home"] .fact, body[data-phase="results"] .fact, body[data-phase="infover"] .fact, body[data-phase="error"] .fact, body[data-phase="loading"] .fact { display: none; }

/* When the on-screen keyboard leaves little room, everything tightens so the clock, the
   prompt and the answer box all stay in view. The class is set from visualViewport. */
body.tight .hud { padding: 0.3rem 0.7rem; }
body.tight .hud-mid { display: none; }
body.tight .hud { grid-template-areas: "alt score"; }
body.tight .prompt-card { padding: 0.45rem 0.7rem; }
body.tight .prompt-card .eyebrow { display: none; }
body.tight .prompt-card h1 { font-size: 0.95rem; }
body.tight .tried { display: none; }
body.tight .dock-form { padding: 0.35rem 0.5rem; }
body.tight .feedback { min-height: 0; }

/* ----- the reveal: no panel. Creature, tier, answer, points and a quip sit straight on the
   sky over a soft dark scrim, and one button waits at the bottom. ----- */

section[data-view="between"] { position: fixed; inset: 0; pointer-events: none; }
.reveal {
  position: absolute; left: 50%; top: calc(max(6px, env(safe-area-inset-top)) + var(--hud-h, 66px) + 10px); transform: translateX(-50%);
  width: min(94%, 30rem); padding: 0.5rem 1rem 1.1rem; text-align: center; animation: rise 0.3s steps(5, end);
  background: radial-gradient(ellipse at center, rgba(0, 14, 30, 0.66) 0, rgba(0, 14, 30, 0.5) 45%, rgba(0, 14, 30, 0) 72%);
  text-shadow: 0 2px 0 #00182f, 2px 0 0 #00182f, -2px 0 0 #00182f, 0 -2px 0 #00182f;
}
@keyframes rise { from { transform: translate(-50%, 16px); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
.reveal .art { display: block; width: 96px; height: 80px; margin: 0 auto 0.2rem; filter: drop-shadow(0 0 8px var(--tier, #ffffff)) drop-shadow(0 0 2px #00182f); }
.reveal .eyebrow { margin: 0 0 0.3rem; font-size: 0.65rem; }
.tier-name { margin: 0 0 0.45rem; font-size: clamp(1.05rem, 6.2vw, 1.8rem); line-height: 1.3; color: var(--tier, var(--ink)); }
.reveal-answer { margin: 0 0 0.4rem; font-size: 1.2rem; font-weight: 700; overflow-wrap: anywhere; }
.reveal-answer::before { content: "\201C"; }
.reveal-answer::after { content: "\201D"; }
.reveal.is-miss .reveal-answer::before, .reveal.is-miss .reveal-answer::after { content: ""; }
.reveal-points { margin: 0 0 0.45rem; font-size: 0.58rem; line-height: 1.7; color: var(--accent); }
.reveal-quip { white-space: pre-line; margin: 0; font-size: 0.9rem; }
.reveal.is-miss .tier-name { color: #c3ccd6; }
.reveal.is-miss .reveal-points { color: var(--muted); }
.reveal-foot { position: absolute; left: 50%; bottom: calc(max(12px, env(safe-area-inset-bottom))); transform: translateX(-50%); width: min(94%, 24rem); text-align: center; pointer-events: auto; }
.reveal-next { margin: 0 0 0.35rem; font-size: 0.8rem; font-weight: 700; color: #ffffff; text-shadow: 0 2px 0 #00182f, 2px 0 0 #00182f, -2px 0 0 #00182f, 0 -2px 0 #00182f; }
@media (max-height: 620px) { .reveal .art { width: 60px; height: 50px; } .reveal-quip { display: none; } }

/* ----- results ----- */

section[data-view="results"], section[data-view="infover"] { min-height: 100dvh; padding: 3.6rem 6px 1.5rem; display: flex; justify-content: center; align-items: flex-start; }
.results { width: min(100%, 40rem); padding: 1.2rem 1.1rem; }
.results h2 { margin: 1.4rem 0 0.6rem; font-size: 0.7rem; color: var(--accent); }
.band { font-size: clamp(1rem, 5.4vw, 1.6rem); margin-bottom: 0.6rem; }
.numbers, .stats { margin: 0.8rem 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: 0.8rem; }
.numbers dt, .stats dt { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.numbers dd, .stats dd { margin: 0.2rem 0 0; }
/* four numbers never share a row narrower than they are: two columns */
[data-view="infover"] .numbers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* A number and its unit never part ("8,893 ft" stays on one line). On a wide screen the stats sit
   in a row; on a narrow one they go two to a row, with the altitude on a full-width row of its own. */
.numbers dd { font-size: clamp(0.8rem, 4.2vw, 1.4rem); white-space: nowrap; }
[data-view="results"] .numbers { grid-template-columns: repeat(3, minmax(0, 1fr)); }
[data-view="results"] .numbers dd { font-size: clamp(0.8rem, 4.2vw, 1.1rem); } /* "238,855 mi" has to fit a third of the panel */
@media (max-width: 560px) {
  [data-view="results"] .numbers, [data-view="infover"] .numbers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .numbers .wide { grid-column: 1 / -1; order: 9; }
}
.stats { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 520px) { .stats { grid-template-columns: repeat(3, 1fr); } }
/* Your flights: one bar per flight, the last 30, on the same 0 to 700 scale */
.hist { list-style: none; margin: 0.5rem 0 0; padding: 0; height: 96px; display: flex; align-items: flex-end; gap: 2px; border-bottom: 3px solid var(--edge); background: linear-gradient(to top, transparent 49.5%, var(--panel-2) 49.5%, var(--panel-2) 50.5%, transparent 50.5%); }
.hist li { flex: 1 1 0; max-width: 22px; min-height: 3px; background: var(--accent); }
.hist li.today { background: var(--ink); }
.hist li.best { box-shadow: inset 0 3px 0 var(--good); }
h3.sub { margin: 1rem 0 0.4rem; font-size: 0.6rem; color: var(--muted); }
.tier-counts { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0.3rem 0.8rem; font-size: 0.85rem; }
.tier-counts li { display: flex; align-items: center; gap: 0.45rem; }
.tier-counts .pip-icon { width: 18px; height: 18px; flex: none; outline: 2px solid var(--tier-ink); }
.tier-counts strong { margin-left: auto; font-variant-numeric: tabular-nums; }
.stats dd { font-size: 0.85rem; }

/* Flight log: one column per round. Each round's mark sits at the altitude the flight had reached,
   on a line rising from the ground, against the zones it passed through. */
.log-wrap { position: relative; height: 300px; border-bottom: 3px solid var(--edge); margin-bottom: 1.7rem; }
.log-bands { list-style: none; margin: 0; padding: 0; position: absolute; inset: 0; display: flex; flex-direction: column-reverse; }
.log-bands li { position: relative; min-height: 0; overflow: hidden; }
.log-bands span { position: absolute; left: 4px; top: 2px; font-size: 0.6rem; font-weight: 700; letter-spacing: 0.06em; color: rgba(255, 255, 255, 0.75); text-transform: uppercase; white-space: nowrap; }
.log { list-style: none; margin: 0; padding: 0 0 0 4.6rem; position: absolute; inset: 0; display: grid; grid-template-columns: repeat(7, 1fr); align-items: end; }
.log li { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.log .stem { width: 2px; background: var(--edge); flex: none; }
.log .pip-icon { width: 22px; height: 22px; flex: none; outline: 2px solid var(--tier-ink); }
.log .round { position: absolute; bottom: -1.4rem; font-size: 0.7rem; color: var(--muted); }
.ladder { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column-reverse; gap: 0.15rem; color: var(--muted); }
.ladder li { padding: 0.15rem 0.4rem; }
.ladder li.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }

.breakdown { list-style: none; margin: 0; padding: 0; }
.breakdown li { padding: 0.55rem 0; border-top: 2px dotted var(--panel-2); }
.breakdown li:first-child { border-top: 0; }
.breakdown .q { display: block; font-size: 0.8rem; color: var(--muted); }
.breakdown .misses { display: block; font-size: 0.75rem; color: var(--muted); font-style: italic; }
.breakdown .a { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.3rem 0.7rem; font-weight: 700; }
.breakdown .ans { overflow-wrap: anywhere; }
.breakdown .meta { display: inline-flex; align-items: center; gap: 0.4rem; }
.badge { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.1rem 0.45rem 0.1rem 0.15rem; font-size: 0.78rem; font-weight: 700; white-space: nowrap; background: var(--t-miss); color: var(--miss-ink); }
.badge .pip-icon { width: 16px; height: 16px; }
.tier-common { background: var(--t-common); color: var(--tier-ink); }
.tier-clever { background: var(--t-clever); color: var(--tier-ink); }
.tier-solid { background: var(--t-solid); color: var(--tier-ink); }
.tier-rare { background: var(--t-rare); color: var(--tier-ink); }
.tier-deep { background: var(--t-deep); color: var(--tier-ink); }
.tier-swarm { background: var(--t-swarm); color: var(--tier-ink); }
.tier-miss { background: var(--t-miss); color: var(--miss-ink); }

.share { display: block; width: 100%; resize: none; overflow: hidden; padding: 0.6rem; font-family: var(--mono); font-size: 1rem; line-height: 1.5; color: var(--accent-ink); background: var(--ink); border: 3px solid var(--accent-ink); border-radius: 0; margin-bottom: 0.6rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-bottom: 0.8rem; }
.row .feedback { margin: 0; min-height: 0; }
.spoilers { margin-top: 0.4rem; }

@media (max-width: 359px) {
  .start-links .btn, .start-links summary { font-size: 0.42rem; padding: 0.3rem 0.2rem; }
  .hud-label { display: none; } /* the narrowest phones: the numbers speak for themselves */
  .hud-num { font-size: 0.62rem; }
}

/* ----- wider screens ----- */

@media (min-width: 720px) {
  body { font-size: 1rem; }
  .hud { left: 50%; right: auto; width: min(44rem, calc(100vw - 130px)); transform: translateX(-50%); padding: 0.6rem 1.1rem; grid-template-columns: 1fr auto 1fr; grid-template-areas: "alt mid score"; }
  .hud .hud-mid { flex-direction: column; gap: 0.2rem; }
  .hud .hud-alt, .hud .hud-score { flex-direction: column; align-items: flex-start; gap: 0; }
  .hud .hud-score { align-items: flex-end; }
  .hud-num { font-size: 1rem; }
  .pips li, .pips .pip-icon { width: 24px; height: 24px; }
  .pips { gap: 5px; }
  .prompt-card { padding: 1rem 1.2rem; }
  .prompt-card h1 { font-size: 1.35rem; }
  .fact { font-size: 0.85rem; }
  .tag { font-size: 1.15rem; left: 41%; max-width: 30vw; }
  .tier-line span { font-size: 0.7rem; }
  .btn { font-size: 0.75rem; }
  .btn-big { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  #scan { display: none; }
  .reveal { animation: fade 0.25s linear !important; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
