/* Seeker client, portrait-first (ODQ-58 (b), BP-3a-1b). One 9:16 stage built for the Seeker
   held upright (400 x 711 CSS px), centred with dark bars in landscape and never blocked.
   Every size is in container query units (cqw), so the layout scales with the stage, and the
   stage follows Chrome's toolbar through dvh. */

:root {
  --bg: #0b0b0c;
  --bar: #000;
  --panel: #16171a;
  --panel-edge: #2a2c31;
  --text: #e8e6e1;
  --muted: #9a978f;
  --accent: #d9a441;
  --accent-ink: #1a1408;
  --danger: #c8443a;
  --warn: #8f6cc9;
  --good: #7fd17f; /* BP-37a: a roll that made it */
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Barlow', system-ui, sans-serif;
  --mono: 'Share Tech Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bar);
  color: var(--text);
  font-family: var(--body);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body { display: flex; align-items: center; justify-content: center; }

/* ── the 9:16 stage ─────────────────────────────────────────────────────── */
.stage {
  position: relative;
  aspect-ratio: 9 / 16;
  width: min(100dvw, 100dvh * 9 / 16);
  height: auto;
  background: radial-gradient(ellipse at 50% 30%, #1c1d21 0%, var(--bg) 70%);
  overflow: hidden;
  container-type: size;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5cqw;
  padding: 8cqw 6cqw;
  text-align: center;
}

.screen[hidden] { display: none; }

/* ── controls ───────────────────────────────────────────────────────────── */
.btn {
  font-family: var(--display);
  font-weight: 700;
  font-size: 6cqw;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  background: var(--panel);
  border: 0.5cqw solid var(--panel-edge);
  border-radius: 1.5cqw;
  padding: 3cqw 6cqw;
  min-height: 13cqw;
  width: 100%;
  max-width: 84cqw;
  cursor: pointer;
}

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:focus-visible { outline: 0.6cqw solid var(--text); outline-offset: 0.8cqw; }

.status, .explainer, .error-text {
  max-width: 88cqw;
  margin: 0;
  font-size: 4.6cqw;
  line-height: 1.4;
}

.explainer { color: var(--muted); }
.status { min-height: 7cqw; color: var(--accent); }
.error-text { color: var(--text); }

/* ── title ──────────────────────────────────────────────────────────────── */
.title-logo { width: 92cqw; max-height: 40cqh; object-fit: contain; }
.title-tagline { margin: 0; font-family: var(--display); font-size: 5.5cqw; font-style: italic; color: var(--muted); }

/* ── Genesis (BP-3c-2): a text badge, no art ────────────────────────────── */
.screen-genesis { gap: 4cqw; }
.genesis-badge {
  margin: 0;
  padding: 2cqw 5cqw;
  font-family: var(--display);
  font-weight: 800;
  font-size: 5.5cqw;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  border: 0.6cqw solid var(--accent);
  border-radius: 1.5cqw;
}
.genesis-title { margin: 0; font-family: var(--display); font-weight: 800; font-size: 7.5cqw; line-height: 1.15; }
.genesis-body { margin: 0; max-width: 84cqw; font-size: 4.6cqw; line-height: 1.45; color: var(--muted); }

/* ── working ────────────────────────────────────────────────────────────── */
.spinner {
  width: 14cqw; height: 14cqw;
  border: 1.4cqw solid var(--panel-edge);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* ── reveal ─────────────────────────────────────────────────────────────── */
.screen-reveal { justify-content: flex-start; gap: 3cqw; padding: 5cqw 5cqw 6cqw; }

.reveal-content {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 3cqw;
  overflow-y: auto;
}

.reveal-heading {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: 7.5cqw;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.commander-card {
  display: grid;
  grid-template-columns: 30cqw 1fr;
  gap: 1.2cqw 4cqw;
  text-align: left;
  background: var(--panel);
  border: 0.4cqw solid var(--panel-edge);
  border-radius: 2cqw;
  padding: 4cqw;
}
.commander-card.is-kia { border-color: var(--danger); }
.commander-card.is-shattered { border-color: var(--warn); }

.portrait {
  grid-column: 1;
  grid-row: 1 / span 2;
  margin-bottom: 2cqw;
  position: relative;
  width: 30cqw;
  aspect-ratio: 3 / 4;
  border-radius: 1.5cqw;
  background: linear-gradient(180deg, #24262b, #121316);
  border: 0.4cqw solid var(--panel-edge);
  overflow: hidden;
}
.portrait-head { position: absolute; left: 50%; top: 18%; width: 38%; aspect-ratio: 1; transform: translateX(-50%); border-radius: 50%; background: #33363d; }
.portrait-body { position: absolute; left: 50%; bottom: -12%; width: 78%; height: 48%; transform: translateX(-50%); border-radius: 50% 50% 0 0; background: #33363d; }

/* the info column's children flow into the card grid: name and grade beside the portrait,
   the stat rows full width below it */
.commander-info { display: contents; }
.commander-name, .commander-grade { grid-column: 2; }
.commander-name { grid-row: 1; align-self: end; }
.commander-grade { grid-row: 2; align-self: start; }

.commander-name {
  margin: 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 2cqw;
  font-family: var(--display);
  font-weight: 800;
  font-size: 7cqw;
  line-height: 1.05;
}

.commander-grade {
  font-family: var(--display);
  font-weight: 700;
  font-size: 5cqw;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.stat { grid-column: 1 / -1; display: flex; gap: 3cqw; font-size: 4.2cqw; line-height: 1.25; }
.stat-label { flex: 0 0 27cqw; color: var(--muted); font-family: var(--mono); text-transform: uppercase; font-size: 3.6cqw; }
.stat-value { min-width: 0; overflow-wrap: anywhere; }

.badges { display: inline-flex; gap: 1.5cqw; }
.badge { font-family: var(--mono); font-size: 3.4cqw; padding: 0.5cqw 2cqw; border-radius: 1cqw; color: #fff; }
.badge-kia { background: var(--danger); }
.badge-shattered { background: var(--warn); }

.outfit { text-align: left; }
.outfit-heading { margin: 0 0 2cqw; font-family: var(--display); font-weight: 700; font-size: 5cqw; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 1.6cqw; }
.chip { display: inline-flex; align-items: baseline; gap: 2cqw; background: var(--panel); border: 0.4cqw solid var(--panel-edge); border-radius: 1.5cqw; padding: 1.4cqw 2.4cqw; font-size: 3.8cqw; }
.chip-kind { font-family: var(--mono); font-size: 3.2cqw; text-transform: uppercase; color: var(--muted); }
.chip-detail { color: var(--muted); }

.btn-continue { flex: none; }

/* ── hub: the sector map (BP-3a-2) ──────────────────────────────────────── */
/* A 10cqw title bar, the map, a 16cqw button bar. The map canvas owns its touches. */
.screen-hub { padding: 0; gap: 0; justify-content: flex-start; }

.hub-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 10cqw;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hub-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: 5.5cqw;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.hub-map {
  position: absolute;
  top: 10cqw; left: 0;
  width: 100%;
  height: calc(100% - 26cqw);
  display: block;
  touch-action: none;
}

.hub-bottom {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 16cqw;
  display: flex;
  align-items: center;
  gap: 2cqw;
  padding: 0 3cqw;
}

.btn-bar {
  flex: 1;
  width: auto;
  max-width: none;
  min-height: 11cqw;
  padding: 0 2cqw;
  font-size: 4.4cqw;
}

.legend {
  position: absolute;
  left: 3cqw; right: 3cqw;
  bottom: 17cqw;
  max-height: calc(100% - 30cqw);
  overflow-y: auto;
  padding: 3cqw;
  background: rgba(11, 11, 12, 0.94);
  border: 0.4cqw solid var(--panel-edge);
  border-radius: 2cqw;
  text-align: left;
}

.legend[hidden] { display: none; }

.legend-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.6cqw 3cqw;
  font-size: 3.8cqw;
}

.legend-item { display: flex; align-items: center; gap: 2cqw; min-width: 0; }
.legend-wide { grid-column: 1 / -1; }

.swatch {
  flex: none;
  width: 4cqw;
  height: 4cqw;
  border: 0.5cqw solid transparent;
}

.swatch-hex { border-radius: 0.8cqw; }
.swatch-dot { border-radius: 50%; }

/* ── battle loop (BP-3b-2) ──────────────────────────────────────────────── */
/* Missions, briefing, the presentation, the AAR and the end of the run. The stage is always
   9:16 (177.8cqw tall), so every block below is budgeted in cqw against that height. */
.btn-bar-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.screen-missions, .screen-briefing, .screen-battle, .screen-aar {
  justify-content: flex-start;
  gap: 3cqw;
  padding: 5cqw 5cqw 6cqw;
}

.screen-heading {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: 7cqw;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.still {
  flex: none;
  width: 100%;
  height: 46cqw;
  object-fit: cover;
  border-radius: 2cqw;
  border: 0.4cqw solid var(--panel-edge);
  background: var(--panel);
}
.still-short { height: 24cqw; }
.still-wipeout { filter: grayscale(1) brightness(0.5); }

/* mission list */
.missions-list {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3cqw;
}

.mission-row {
  width: 100%;
  display: grid;
  gap: 1.2cqw;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 0.4cqw solid var(--panel-edge);
  border-radius: 2cqw;
  padding: 3.5cqw 4cqw;
  cursor: pointer;
}
.mission-row:focus-visible { outline: 0.6cqw solid var(--text); outline-offset: 0.6cqw; }
.mission-name { font-family: var(--display); font-weight: 800; font-size: 6.2cqw; text-transform: uppercase; letter-spacing: 0.03em; }
.mission-diff { display: flex; align-items: baseline; gap: 2.5cqw; }
.mission-diff-label { font-family: var(--mono); font-size: 3.4cqw; text-transform: uppercase; color: var(--muted); }
.mission-pips { font-size: 3.6cqw; letter-spacing: 0.08em; color: var(--accent); }
.mission-meta { font-size: 3.9cqw; color: var(--muted); }

/* briefing */
.briefing-text { margin: 0; font-size: 4.4cqw; line-height: 1.4; font-style: italic; }
.briefing-line { margin: 0; font-size: 4.4cqw; color: var(--muted); }
.briefing-actions {
  margin-top: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5cqw;
}
.debug-toggle { display: flex; align-items: center; gap: 2cqw; font-family: var(--mono); font-size: 3.6cqw; color: #7fd17f; }
.debug-toggle input { width: 5cqw; height: 5cqw; }

/* the presentation: each line fades in, then counts up */
.score-lines {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.4cqw;
}
.score-row, .battle-reveal {
  opacity: 0;
  transform: translateY(1.5cqw);
  transition: opacity 0.25s ease-out, transform 0.25s ease-out;
}
.score-row.shown, .battle-reveal.shown { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .score-row, .battle-reveal { transition: none; transform: none; }
}
.score-row {
  display: flex;
  justify-content: space-between;
  padding: 1.2cqw 3cqw;
  background: var(--panel);
  border-radius: 1.2cqw;
  font-size: 4.4cqw;
}
.score-label { color: var(--muted); }
.score-value { font-family: var(--mono); font-size: 4.6cqw; }
.battle-reveal { margin: 0; }
.battle-chance, .battle-roll { font-family: var(--display); font-weight: 700; font-size: 6cqw; }
.battle-roll.roll-made { color: var(--good); }     /* BP-37a: the roll lands green on a success */
.battle-roll.roll-missed { color: var(--danger); } /* BP-37a: and red on a failure */
.battle-outcome { font-family: var(--display); font-weight: 800; font-size: 8cqw; text-transform: uppercase; letter-spacing: 0.04em; min-height: 9cqw; }
#btn-skip { margin-top: auto; }
#btn-skip:disabled { pointer-events: none; } /* BP-37a-2 (Reviewer BP-37a F2): a tap on the greyed button reaches the screen, which hurries the log */

.outcome-Success { color: var(--accent); }
.outcome-Defeat { color: var(--text); }
.outcome-Wipeout { color: var(--danger); }

/* the after-action report */
.screen-aar { gap: 1.8cqw; padding-top: 4cqw; }
.aar-outcome { margin: 0; font-family: var(--display); font-weight: 800; font-size: 6.4cqw; text-transform: uppercase; letter-spacing: 0.04em; }
.panel-heading { margin: 0 0 1.4cqw; font-family: var(--display); font-weight: 700; font-size: 4.4cqw; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.aar-panel {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  text-align: left;
}
.aar-units {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6cqw;
}
.unit-row {
  display: grid;
  grid-template-columns: 6cqw 24cqw 1fr;
  align-items: center;
  gap: 2cqw;
  padding: 0.6cqw 2.4cqw;
  background: var(--panel);
  border-radius: 1cqw;
  font-size: 3.9cqw;
}
.unit-glyph { font-size: 4.2cqw; }
.unit-status { color: var(--muted); }
.unit-wounded .unit-status { color: var(--accent); }
.unit-kia .unit-status { color: var(--danger); }
.aar-row { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 2.5cqw; text-align: left; }
.aar-box { background: var(--panel); border: 0.4cqw solid var(--panel-edge); border-radius: 1.5cqw; padding: 2.4cqw 3cqw; min-width: 0; }
.pay-line { margin: 0; font-size: 3.8cqw; line-height: 1.35; overflow-wrap: anywhere; }
.pay-none { color: var(--muted); }
.aar-commander { display: flex; flex-direction: column; gap: 0.8cqw; font-size: 3.8cqw; }
.aar-commander-name { font-family: var(--display); font-weight: 800; font-size: 4.6cqw; overflow-wrap: anywhere; }
.aar-rankup { color: var(--accent); }

/* the end of the run */
.screen-end { gap: 3cqw; }
.end-title { margin: 0; font-family: var(--display); font-weight: 800; font-size: 10cqw; text-transform: uppercase; letter-spacing: 0.05em; color: var(--danger); }
.end-name { margin: 0; font-family: var(--display); font-weight: 800; font-size: 7.5cqw; }
.end-grade { margin: 0; font-family: var(--display); font-weight: 700; font-size: 5cqw; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.end-flaw { margin: 0; font-family: var(--mono); font-size: 4cqw; color: var(--muted); }
.end-body { margin: 0; max-width: 84cqw; font-size: 4.6cqw; line-height: 1.45; }
.end-glorious { margin: 0; font-style: italic; font-size: 4.4cqw; color: var(--accent); }
.end-glorious[hidden] { display: none; }

/* ── checkout (BP-3c-2b): one screen, every state ───────────────────────── */
.screen-checkout { gap: 4cqw; }
.checkout-title { margin: 0; font-family: var(--display); font-weight: 800; font-size: 7.5cqw; line-height: 1.15; }
.checkout-line { margin: 0; max-width: 88cqw; font-size: 4.8cqw; line-height: 1.4; color: var(--accent); }
.checkout-body { margin: 0; max-width: 84cqw; font-size: 4.6cqw; line-height: 1.45; color: var(--muted); }
.checkout-actions { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 2.5cqw; }
.checkout-line[hidden], .checkout-body[hidden] { display: none; }

/* ── mute (BP-3c-3): one button above every screen ──────────────────────── */
.mute-btn {
  position: absolute; top: 1cqw; right: 1.5cqw; z-index: 6; /* inside the hub's 10 cqw header, clear of the map */
  width: 8cqw; height: 8cqw; padding: 0;
  font-size: 4.5cqw; line-height: 1; cursor: pointer;
  color: var(--text); background: rgba(0, 0, 0, 0.45); border: 0.4cqw solid var(--panel-edge); border-radius: 50%;
}
.reveal-note { margin: 0; max-width: 88cqw; font-size: 4.2cqw; line-height: 1.4; color: var(--accent); }
.reveal-note[hidden] { display: none; }

/* ── debug footer (?debug=1) ────────────────────────────────────────────── */
.debug {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 1cqw 2cqw;
  font-family: var(--mono); font-size: 3cqw;
  color: #7fd17f; background: rgba(0, 0, 0, 0.75);
  overflow-wrap: anywhere; z-index: 5;
  pointer-events: none; /* never swallows a tap on the hub's bottom bar */
}
.debug[hidden] { display: none; }
