/* GO / NO-GO: space-themed, friendly, glassy. */
:root {
  --bg: #050816;
  --ink: #eaf1ff;
  --ink-2: #b6c3e0;
  --muted: #8a98b8;
  --glass: rgba(14, 22, 48, 0.62);
  --glass-strong: rgba(12, 18, 40, 0.86);
  --line: rgba(150, 180, 255, 0.16);
  --line-strong: rgba(150, 190, 255, 0.32);
  --cyan: #6ee7ff;
  --blue: #5b8cff;
  --violet: #a78bfa;
  --mint: #5af2b0;
  --amber: #ffb547;
  --coral: #ff6b6b;
  --radius: 16px;
  --radius-sm: 10px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: none; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
body[data-screen="menu"] .screen-menu,
body[data-screen="setup"] .screen-setup,
body[data-screen="flight"] .screen-flight,
body[data-screen="validation"] .screen-validation { display: flex; }

.screen-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-bottom: 16px; }
.screen-head h2 { margin: 0; font-size: 20px; letter-spacing: 0.02em; text-align: center; }
.screen-head > :last-child { justify-self: end; }

/* ---------- type ---------- */
.eyebrow { margin: 0 0 6px; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--cyan); font-weight: 600; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.section-title { margin: 22px 0 10px; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.fineprint { color: var(--muted); font-size: 12px; margin: 18px 0 0; min-height: 1em; }
kbd { font-family: var(--mono); font-size: 12px; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line-strong); background: rgba(255,255,255,0.05); }

/* ---------- panels ---------- */
.panel {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 12px;
  padding: 10px 16px; min-height: 44px;
  cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: transform 160ms var(--ease-out), background-color 160ms ease, border-color 160ms ease, opacity 160ms ease;
  font-weight: 600;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible, .choice:focus-visible, .chip:focus-visible, .segmented button:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(180deg, #6aa2ff, #4a6cf0); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255,255,255,0.25); }
.btn-go { background: linear-gradient(180deg, #5af2b0, #1fb983); color: #03241a; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255,255,255,0.4); }
.btn-glass { background: rgba(255,255,255,0.06); border-color: var(--line-strong); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-icon { min-width: 44px; padding: 8px 10px; background: rgba(255,255,255,0.06); border-color: var(--line); }
.btn-lg { padding: 14px 22px; min-height: 56px; border-radius: 14px; font-size: 16px; }
.btn[aria-pressed="true"] { background: rgba(110,231,255,0.18); border-color: var(--cyan); }
@media (hover: hover) and (pointer: fine) {
  .btn-glass:hover, .btn-icon:hover { background: rgba(255,255,255,0.11); }
  .btn-ghost:hover { color: var(--ink); }
  .btn-primary:hover { filter: brightness(1.08); }
  .btn-go:hover { filter: brightness(1.05); }
}

/* ---------- main menu ---------- */
.screen-menu { align-items: center; padding-left: clamp(16px, 7vw, 120px); }
.menu-card { max-width: 520px; width: 100%; }
.logo {
  margin: 4px 0 10px; font-size: clamp(44px, 8vw, 92px); line-height: 0.95; letter-spacing: -0.03em; font-weight: 800; white-space: nowrap;
  color: #f4f7ff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}
.logo-slash { color: var(--amber); }
.menu-credit { margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.tagline { font-size: 18px; color: var(--ink-2); margin: 0 0 28px; max-width: 30ch; }
.menu-actions { display: grid; gap: 12px; }
.menu-actions .btn-lg { flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
.btn-label { font-size: 17px; }
.btn-sub { font-size: 13px; font-weight: 500; opacity: 0.85; }
.menu-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* ---------- setup ---------- */
.screen-setup { flex-direction: column; overflow-y: auto; background: linear-gradient(180deg, rgba(5,8,22,0.55), rgba(5,8,22,0.85)); }
.setup-grid { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 20px; max-width: 1100px; width: 100%; margin: 0 auto; }
.mission-card { padding: 22px; align-self: start; }
.mission-card h3 { margin: 0 0 8px; font-size: 22px; }
.facts { margin: 18px 0 0; display: grid; gap: 10px; }
.facts div { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 10px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.setup-col .section-title:first-child { margin-top: 0; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.choice-grid.two { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.choice {
  text-align: left; cursor: pointer; padding: 16px; border-radius: var(--radius);
  background: var(--glass); border: 1px solid var(--line);
  display: grid; gap: 4px;
  transition: transform 160ms var(--ease-out), border-color 160ms ease, background-color 160ms ease;
}
.choice:active { transform: scale(0.98); }
.choice[aria-checked="true"] { border-color: var(--cyan); background: rgba(40, 80, 140, 0.45); box-shadow: 0 0 0 1px var(--cyan) inset; }
.choice-title { font-weight: 700; font-size: 16px; }
.choice-text { color: var(--ink-2); font-size: 13px; }
.choice-specs { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.choice-specs b { color: var(--ink); font-family: var(--mono); font-weight: 600; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  cursor: pointer; border-radius: 999px; padding: 9px 14px; min-height: 40px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--line-strong);
  transition: transform 160ms var(--ease-out), background-color 160ms ease, border-color 160ms ease;
}
.chip:active { transform: scale(0.97); }
.chip[aria-checked="true"] { background: rgba(110,231,255,0.16); border-color: var(--cyan); }
.chip small { color: var(--muted); margin-left: 6px; font-family: var(--mono); }
.setup-foot { display: flex; justify-content: center; padding: 22px 0 8px; }
@media (hover: hover) and (pointer: fine) {
  .choice:hover { border-color: var(--line-strong); }
  .chip:hover { background: rgba(255,255,255,0.09); }
}

.choice-grid.three { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.choice-era { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--amber); }
.mission-era { margin: 0 0 6px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--amber); }
.nasa-box { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.nasa-title { margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--cyan); }
.source-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.source-list.wide { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.source-list li { font-size: 12px; color: var(--ink-2); }
.source-list a { color: var(--ink); font-weight: 600; text-decoration: underline; text-decoration-color: rgba(110,231,255,0.5); text-underline-offset: 3px; }
.source-list a:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.history { margin: 14px 0 0; display: grid; gap: 6px; }
.history div { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.history dt { color: var(--muted); }
.history dd { margin: 0; text-align: right; }
.history a { color: var(--cyan); font-size: 11px; margin-left: 6px; }
.preflight { padding: 14px 16px; }
.preflight[data-tone="good"] { border-color: rgba(90,242,176,0.4); }
.preflight[data-tone="warn"] { border-color: rgba(255,181,71,0.45); }
.preflight[data-tone="bad"] { border-color: rgba(255,107,107,0.45); }
.preflight-head { margin: 0; font-weight: 700; }
.preflight[data-tone="good"] .preflight-head { color: var(--mint); }
.preflight[data-tone="warn"] .preflight-head { color: var(--amber); }
.preflight[data-tone="bad"] .preflight-head { color: var(--coral); }
.preflight-text { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); }
.nasa-panel { max-width: 1000px; width: 100%; margin: 14px auto 0; padding: 16px 20px; }
.result-extra { display: grid; gap: 12px; margin-top: 14px; }
.result-block { padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,0.04); border: 1px solid var(--line); }
.result-block h3 { margin: 0 0 8px; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--cyan); }
.result-block p { margin: 6px 0 0; font-size: 13px; color: var(--ink-2); }
.result-block a { color: var(--cyan); }
.compare { width: 100%; border-collapse: collapse; font-size: 13px; }
.compare th, .compare td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.compare th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.compare td { font-variant-numeric: tabular-nums; }
.coverage { height: 10px; border-radius: 99px; background: rgba(255,255,255,0.08); overflow: hidden; margin-top: 8px; }
.coverage div { height: 100%; background: linear-gradient(90deg, #ffb547, #ff6b3d); border-radius: 99px; }
.target-line b { color: var(--amber); }
.val-card .nasa-tag { font-size: 11px; color: var(--cyan); font-weight: 700; }
.val-card .nasa-tag a { color: var(--cyan); }

/* ---------- design room ---------- */
.design-room { padding: 16px; display: grid; gap: 14px; }
.gauges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gauge { padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,0.04); border: 1px solid var(--line); display: grid; gap: 3px; min-width: 0; }
.gauge-label { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.gauge-value { font-family: var(--mono); font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gauge-sub { font-size: 12px; color: var(--ink-2); min-height: 2.6em; }
.gauge-bar { height: 6px; border-radius: 99px; background: rgba(255,255,255,0.08); overflow: hidden; }
.gauge-bar div { height: 100%; width: 0; border-radius: 99px; background: var(--mint); transition: width 200ms var(--ease-out); }
.gauge[data-tone="warn"] { border-color: rgba(255,181,71,0.45); }
.gauge[data-tone="warn"] .gauge-value { color: var(--amber); }
.gauge[data-tone="warn"] .gauge-bar div { background: var(--amber); }
.gauge[data-tone="bad"] { border-color: rgba(255,107,107,0.55); }
.gauge[data-tone="bad"] .gauge-value { color: var(--coral); }
.gauge[data-tone="bad"] .gauge-bar div { background: var(--coral); }
.design-warn { margin: 0; padding: 8px 12px; border-radius: 10px; background: rgba(255,107,107,0.12); border: 1px solid rgba(255,107,107,0.5); color: #ffd0d0; font-size: 13px; }
.design-row { display: grid; gap: 8px; }
.design-label { margin: 0; font-size: 13px; font-weight: 600; }
.design-label small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.part-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.part { padding: 12px; }
.part .choice-specs { margin-top: 4px; }
.part[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }

/* ---------- rocket builder ---------- */
.gauges.four { grid-template-columns: repeat(4, 1fr); }
.build-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px 18px; align-items: start; }
.build-grid .design-row.wide { grid-column: 1 / -1; }
.build-stepper { display: inline-flex; align-items: center; gap: 8px; }
.build-stepper b { min-width: 64px; text-align: center; font-family: var(--mono); font-size: 16px; font-variant-numeric: tabular-nums; }
@media (max-width: 680px) { .gauges.four { grid-template-columns: repeat(2, 1fr); } }
.build-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.build-head .hint { margin: 0; }
.builder-layout { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; align-items: start; }
.builder-tools .build-grid { grid-template-columns: 1fr; }
.builder-layout[data-buildview="drag"] #build-text, .builder-layout[data-buildview="text"] #parts-bin { display: none; }
.design-label small { color: var(--muted); font-weight: 500; margin-left: 6px; }

.parts-bin { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.part-tile {
  display: grid; justify-items: center; gap: 2px; padding: 8px 6px 10px; border-radius: 12px; cursor: grab;
  background: rgba(255,255,255,0.04); border: 1px solid var(--line); text-align: center;
  touch-action: none; user-select: none; -webkit-user-select: none;
  transition: transform 160ms var(--ease-out), border-color 160ms ease, background-color 160ms ease;
}
.part-tile:active { transform: scale(0.97); cursor: grabbing; }
.part-tile[aria-pressed="true"] { border-color: var(--cyan); background: rgba(40,80,140,0.35); }
.part-tile:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.part-icon { width: 52px; height: 52px; }
.part-name { font-size: 12px; font-weight: 600; line-height: 1.3; }
.part-count { font-size: 12px; color: var(--muted); font-family: var(--mono); }
@media (hover: hover) and (pointer: fine) { .part-tile:hover { border-color: var(--line-strong); background: rgba(255,255,255,0.07); } }
.drag-ghost { position: fixed; left: 0; top: 0; width: 56px; height: 56px; pointer-events: none; z-index: 30; opacity: 0.92; }
.drag-ghost .part-icon { width: 56px; height: 56px; }

.rocket-diagram { border-radius: 12px; background: rgba(2,4,12,0.45); border: 1px solid var(--line); }
.rv-svg { display: block; width: 100%; height: auto; }
.rv-svg text { fill: var(--ink-2); font-family: var(--font); }
.rv-svg .rv-head { fill: var(--ink); font-size: 13px; font-weight: 700; }
.rv-svg .rv-sub { font-size: 12px; }
.rv-svg .rv-dim { font-size: 12px; fill: var(--muted); }
.rv-zone { fill: transparent; stroke: transparent; stroke-width: 2; cursor: pointer; transition: fill 160ms ease, stroke 160ms ease; }
.rv-zone:focus-visible { stroke: var(--cyan); outline: none; }
.rv-zone.selected { stroke: var(--cyan); stroke-dasharray: 5 4; }
@media (hover: hover) and (pointer: fine) { .rv-zone:hover { fill: rgba(110,231,255,0.08); stroke: rgba(110,231,255,0.5); } }
.dragging .rv-zone.target { fill: rgba(90,242,176,0.12); stroke: var(--mint); stroke-dasharray: 6 4; }
.dragging.over-rocket .rv-zone.target { fill: rgba(90,242,176,0.24); }
.rv-zone.snap { animation: rv-snap 420ms var(--ease-out); }
@keyframes rv-snap { from { fill: rgba(90,242,176,0.45); stroke: var(--mint); } to { fill: transparent; stroke: transparent; } }

.staging { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); }
.staging b { color: var(--amber); font-family: var(--mono); font-weight: 600; }
.builder-view { display: grid; gap: 8px; }
.builder-detail { padding: 14px; display: grid; gap: 8px; }
.pd-svg { display: block; width: 100%; max-width: 200px; height: auto; margin: 0 auto; }
.pd-name { margin: 0; font-size: 16px; }
.pd-does { margin: 0; font-size: 13px; color: var(--ink-2); }
.pd-fitted { margin: 0; font-size: 13px; font-weight: 600; color: var(--cyan); font-family: var(--mono); }
.pd-facts { margin: 0; display: grid; gap: 6px; }
.pd-facts div { border-top: 1px solid var(--line); padding-top: 6px; }
.pd-facts dt { font-size: 12px; color: var(--muted); }
.pd-facts dd { margin: 0; font-size: 13px; }
.pd-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (prefers-reduced-motion: reduce) {
  .rv-zone.snap { animation: none; }
  .part-tile { transition: none; }
  .part-tile:active { transform: none; }
}

/* ---------- role calls (team flights) ---------- */
.role-call {
  --role: var(--cyan);
  pointer-events: none; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  max-width: min(94vw, 680px); padding: 8px 14px; border-radius: 14px;
  background: var(--glass-strong); border: 1px solid var(--role);
  transition: border-color 200ms ease, opacity 200ms ease, transform 200ms var(--ease-out);
  @starting-style { opacity: 0; transform: translateY(6px); }
}
.role-call[data-role="scientist"] { --role: var(--violet); }
.role-call[data-role="engineer"] { --role: var(--amber); }
.role-call[data-role="comms"] { --role: var(--cyan); }
.role-call[data-role="pm"] { --role: var(--mint); }
.role-call-who { font-size: 13px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--role); white-space: nowrap; }
.role-call-text { font-size: 14px; color: var(--ink); text-align: center; }
.screen-flight [data-called="true"] { outline: 2px solid var(--call-color, var(--amber)); outline-offset: 2px; }
.calls-cell { white-space: nowrap; }

/* ---------- team mode ---------- */
.role-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; margin-top: 10px; }
.role { padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,0.04); border: 1px solid var(--line); display: grid; gap: 6px; align-content: start; }
.role-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.role-head b { font-size: 14px; }
.role-head span { font-size: 12px; color: var(--muted); }
.role p { margin: 0; font-size: 13px; color: var(--ink-2); }
.role .btn { min-height: 36px; padding: 6px 12px; font-size: 13px; justify-self: start; }
.goal-state { font-size: 13px; font-weight: 600; }
.goal-state[data-ok="true"] { color: var(--mint); }
.goal-state[data-ok="false"] { color: var(--amber); }
.poll-list { display: grid; gap: 8px; margin-top: 14px; }
.poll-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,0.04); border: 1px solid var(--line); }
.poll-row .meta { display: grid; gap: 2px; min-width: 0; }
.poll-row .meta span { font-size: 12px; color: var(--muted); }
.poll-row .segmented button[data-vote="go"][aria-checked="true"] { background: rgba(90,242,176,0.2); color: var(--mint); }
.poll-row .segmented button[data-vote="nogo"][aria-checked="true"] { background: rgba(255,107,107,0.2); color: var(--coral); }
.poll-result { margin: 12px 0 0; font-weight: 600; min-height: 1.4em; }
.poll-result[data-tone="good"] { color: var(--mint); }
.poll-result[data-tone="bad"] { color: var(--coral); }

/* ---------- failure replay ---------- */
.replay { display: block; width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); background: #040815; margin-top: 8px; }
.replay-cause { font-weight: 600; color: #ffd0d0 !important; }
.result-block .btn { margin-top: 8px; min-height: 36px; padding: 6px 12px; font-size: 13px; }
.team-table td:last-child { font-weight: 600; }
.team-table td[data-ok="true"] { color: var(--mint); }
.team-table td[data-ok="false"] { color: var(--coral); }
.event-card { margin: 8px 0 10px; padding: 10px 12px; border-radius: 10px; background: rgba(255,181,71,0.1); border: 1px solid rgba(255,181,71,0.5); font-size: 12px; color: #ffe2b3; }
.event-card b { display: block; font-size: 13px; color: var(--amber); margin-bottom: 2px; }
.event-card[data-over="true"] { opacity: 0.6; }

@media (max-width: 680px) {
  .gauges { grid-template-columns: repeat(2, 1fr); }
  .gauge-value { font-size: 15px; }
}

/* ---------- flight HUD ---------- */
.screen-flight { pointer-events: none; flex-direction: column; justify-content: space-between; }
.screen-flight .btn, .screen-flight .panel, .screen-flight input, .screen-flight .segmented button { pointer-events: auto; }

.hud-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 12px; }
.hud-mission { display: grid; gap: 2px; font-size: 13px; }
.hud-rocket { font-weight: 700; font-size: 15px; }
.hud-site { color: var(--ink-2); }
.hud-clock { display: grid; justify-items: center; gap: 6px; }
.clock { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 26px; font-weight: 600; letter-spacing: 0.04em; text-shadow: 0 2px 12px rgba(0,0,0,0.6); }
.status-chip { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,0.08); border: 1px solid var(--line-strong); }
.status-chip[data-tone="good"] { color: var(--mint); border-color: rgba(90,242,176,0.5); background: rgba(90,242,176,0.1); }
.status-chip[data-tone="warn"] { color: var(--amber); border-color: rgba(255,181,71,0.5); background: rgba(255,181,71,0.1); }
.status-chip[data-tone="bad"] { color: var(--coral); border-color: rgba(255,107,107,0.5); background: rgba(255,107,107,0.12); }
.hud-top-actions { justify-self: end; display: flex; gap: 8px; }

.hud-panel { position: absolute; top: 96px; width: 232px; padding: 14px 16px; }
.hud-left { left: max(16px, env(safe-area-inset-left)); }
.hud-right { right: max(16px, env(safe-area-inset-right)); }
.panel-title { margin: 0 0 8px; font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--cyan); font-weight: 700; }
.panel-title.sub { margin-top: 14px; color: var(--muted); }
.readout { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 4px 0; font-size: 13px; color: var(--ink-2); }
.readout i { font-style: normal; color: var(--muted); font-size: 11px; }
.readout b { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; font-size: 14px; white-space: nowrap; }
.readout b[data-tone="good"] { color: var(--mint); }
.readout b[data-tone="warn"] { color: var(--amber); }
.readout b[data-tone="bad"] { color: var(--coral); }
.meter-block { margin-top: 6px; }
.meter { position: relative; height: 6px; border-radius: 99px; background: rgba(255,255,255,0.08); overflow: visible; }
.meter-fill { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--mint), var(--amber) 70%, var(--coral)); transform-origin: left; }
.meter-fill.heat { background: linear-gradient(90deg, #ffd27a, var(--coral)); }
.meter-mark { position: absolute; top: -3px; width: 2px; height: 12px; background: var(--coral); border-radius: 2px; }
.meter-mark.safe { background: var(--mint); }

.fuel-bars { display: grid; gap: 8px; }
.fuel { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); }
.fuel-head { display: flex; justify-content: space-between; }
.fuel-head b { font-family: var(--mono); color: var(--ink); font-weight: 600; }
.fuel-track { height: 6px; border-radius: 99px; background: rgba(255,255,255,0.08); overflow: hidden; }
.fuel-fill { height: 100%; background: linear-gradient(90deg, #5b8cff, var(--cyan)); border-radius: 99px; }
.fuel[data-state="gone"] { opacity: 0.35; }
.fuel[data-state="gone"] .fuel-fill { background: var(--muted); }
.fuel[data-state="active"] .fuel-head span::before { content: "● "; color: var(--amber); }

.hud-bottom { display: grid; justify-items: center; gap: 8px; }
.advice { margin: 0; min-height: 22px; padding: 6px 14px; border-radius: 999px; background: rgba(5,8,22,0.55); font-size: 14px; color: var(--ink); text-align: center; max-width: min(92vw, 640px); }
.advice:empty { visibility: hidden; }
.dock { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 16px; padding: 10px 14px; max-width: 100%; }
.dock-group { display: flex; align-items: center; gap: 8px; }
.segmented { display: inline-flex; padding: 3px; border-radius: 12px; background: rgba(255,255,255,0.05); border: 1px solid var(--line); }
.segmented button { border: 0; background: transparent; padding: 8px 10px; min-height: 38px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink-2); transition: background-color 160ms ease, color 160ms ease; }
.segmented button[aria-checked="true"] { background: rgba(110,231,255,0.18); color: var(--ink); }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper-value { display: grid; justify-items: center; min-width: 52px; line-height: 1.1; }
.stepper-value b { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 16px; }
.stepper-value small { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.throttle-group { flex-direction: column; align-items: stretch; gap: 4px; min-width: 150px; }
.throttle-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); display: flex; justify-content: space-between; }
.throttle-label b { font-family: var(--mono); color: var(--ink); letter-spacing: 0; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 99px; background: linear-gradient(90deg, var(--amber), #ff7a3d); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 99px; background: linear-gradient(90deg, var(--amber), #ff7a3d); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: #fff; }
input[type="range"]:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-stage {
  flex-direction: column; gap: 0; min-width: 132px; min-height: 56px; padding: 6px 16px; border-radius: 14px;
  background: linear-gradient(180deg, #ff9a4d, #f2602b); color: #1c0700;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255,255,255,0.35);
}
.stage-word { font-weight: 800; letter-spacing: 0.14em; font-size: 15px; }
.stage-next { font-size: 11px; font-weight: 600; opacity: 0.8; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-stage[data-urgent="true"] { animation: urgent 900ms ease-in-out infinite; }
@keyframes urgent { 50% { outline: 3px solid rgba(255, 181, 71, 0.85); outline-offset: 3px; } }
.take-control { pointer-events: auto; font-size: 13px; min-height: 36px; padding: 6px 12px; }

.countdown {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  font-family: var(--mono); font-size: clamp(80px, 18vw, 180px); font-weight: 700;
  color: rgba(255,255,255,0.92); text-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

/* fuel gauge */
.fuel-gauge { flex-direction: column; align-items: stretch; gap: 4px; min-width: 150px; }
.fg-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.fg-head b { font-family: var(--mono); font-size: 14px; font-variant-numeric: tabular-nums; }
.fg-track { height: 10px; border-radius: 99px; background: rgba(255,255,255,0.08); overflow: hidden; border: 1px solid var(--line); }
.fg-fill { height: 100%; width: 100%; border-radius: 99px; background: linear-gradient(90deg, #5b8cff, var(--cyan)); transition: width 160ms linear; }
.fuel-gauge[data-level="low"] .fg-fill { background: linear-gradient(90deg, var(--amber), #ffd27a); }
.fuel-gauge[data-level="critical"] .fg-fill { background: linear-gradient(90deg, var(--coral), #ff9b9b); }
.fuel-gauge[data-level="critical"] .fg-head b { color: var(--coral); }
.fg-time { font-size: 11px; color: var(--muted); font-family: var(--mono); }
@media (max-width: 680px) { .fuel-gauge { min-width: 110px; } }

/* operations, landing */
.ops-panel { width: 300px; max-height: calc(100vh - 260px); overflow-y: auto; }
.task-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.task-list li { display: grid; grid-template-columns: 18px 1fr; gap: 6px; font-size: 12px; color: var(--ink-2); }
.task-list li b { color: var(--ink); font-size: 13px; }
.task-list li .tick { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line-strong); margin-top: 2px; }
.task-list li[data-done="true"] .tick { background: var(--mint); border-color: var(--mint); }
.task-list li[data-done="true"] b { color: var(--mint); }
.meter-fill.power { background: linear-gradient(90deg, var(--coral), var(--amber) 35%, var(--mint)); }
.meter-fill.fuel { background: linear-gradient(90deg, var(--coral), var(--amber) 30%, var(--cyan)); }
.inset { display: block; width: 100%; height: auto; margin-top: 10px; border-radius: 10px; border: 1px solid var(--line); background: #02040b; }
.inset-caption { margin: 6px 0 0; font-size: 12px; color: var(--ink-2); min-height: 1.2em; }
.panel-hint { margin: 8px 0 0; font-size: 11px; color: var(--muted); }
.mini-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.ops-dock .segmented button[aria-checked="true"] { background: rgba(110,231,255,0.18); color: var(--ink); }
.result-list { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); }
@media (max-width: 900px) { .ops-panel { width: 230px; } }
@media (max-width: 680px) {
  .ops-panel { width: calc(50% - 22px); }
  .ops-panel .readout:nth-of-type(n+4), .ops-panel .inset-caption { display: none; }
  .landing-panel .readout:nth-of-type(n+5), .landing-panel .panel-hint { display: none; }
}

/* toasts */
.toasts { position: absolute; top: 92px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; width: min(92vw, 520px); pointer-events: none; }
.toast {
  padding: 9px 16px; border-radius: 12px; font-size: 14px; text-align: center;
  background: var(--glass-strong); border: 1px solid var(--line-strong);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  transition: opacity 240ms ease, transform 240ms var(--ease-out);
  @starting-style { opacity: 0; transform: translateY(-8px) scale(0.98); }
}
.toast.leaving { opacity: 0; transform: translateY(-6px); transition-duration: 180ms; }
.toast[data-type="orbit"], .toast[data-type="deploy"], .toast[data-type="fairing"] { border-color: rgba(90,242,176,0.55); }
.toast[data-type="warning"], .toast[data-type="event"] { border-color: rgba(255,181,71,0.6); color: #ffe2b3; }
.toast[data-type="destroyed"], .toast[data-type="crash"] { border-color: rgba(255,107,107,0.7); color: #ffd0d0; }
.toast[data-type="save"] { border-color: rgba(110,231,255,0.5); }

/* ---------- validation ---------- */
.screen-validation { flex-direction: column; overflow-y: auto; background: linear-gradient(180deg, rgba(5,8,22,0.6), rgba(5,8,22,0.9)); }
.val-intro, .val-list, .val-limits { max-width: 1000px; width: 100%; margin-left: auto; margin-right: auto; }
.val-intro { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; }
.val-intro p { margin: 0; }
.val-score { font-family: var(--mono); font-size: 30px; font-weight: 700; color: var(--mint); white-space: nowrap; }
.val-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-top: 14px; }
.val-card { padding: 16px; display: grid; gap: 8px; align-content: start; }
.val-card h3 { margin: 0; font-size: 15px; display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.val-card .formula { font-family: var(--mono); font-size: 13px; color: var(--cyan); background: rgba(110,231,255,0.07); padding: 6px 10px; border-radius: 8px; }
.val-card .plain { font-size: 13px; color: var(--ink-2); margin: 0; }
.val-nums { display: grid; grid-template-columns: 1fr 1fr 0.7fr; gap: 6px; }
.val-nums div { background: rgba(255,255,255,0.04); border-radius: 8px; padding: 6px 8px; }
.val-nums span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.val-nums b { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.val-card .source { font-size: 12px; color: var(--muted); margin: 0; }
.badge { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.badge.pass { background: rgba(90,242,176,0.14); color: var(--mint); }
.badge.approx { background: rgba(255,181,71,0.14); color: var(--amber); }
.badge.fail { background: rgba(255,107,107,0.16); color: var(--coral); }
.badge.running { background: rgba(255,255,255,0.08); color: var(--ink-2); }
.val-limits { margin-top: 14px; margin-bottom: 24px; padding: 14px 18px; }
.val-limits summary { cursor: pointer; font-weight: 600; }
.val-limits li { margin: 8px 0; color: var(--ink-2); font-size: 14px; }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(2, 4, 12, 0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); z-index: 10; }
.modal-card {
  width: min(420px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  padding: 24px; border-radius: 20px;
  background: var(--glass-strong); border: 1px solid var(--line-strong);
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
  transition: opacity 200ms ease, transform 200ms var(--ease-out);
  @starting-style { opacity: 0; transform: scale(0.96); }
}
#modal-pause .modal-card { transition: none; }
.modal-card.wide { width: min(640px, 100%); }
.modal-card h2 { margin: 0 0 6px; font-size: 22px; }
.modal-actions { display: grid; gap: 10px; margin-top: 16px; }
.modal-actions.row { display: flex; flex-wrap: wrap; justify-content: flex-end; }
.modal-actions .section-title { margin: 8px 0 0; }
.slot-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.slot-row .btn { flex-direction: column; gap: 0; padding: 8px; }
.slot-row small { font-weight: 500; font-size: 11px; color: var(--muted); }
.save-list { display: grid; gap: 10px; margin-top: 14px; }
.save-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 14px; background: rgba(255,255,255,0.04); border: 1px solid var(--line); }
.save-item .meta { display: grid; gap: 2px; min-width: 0; }
.save-item .meta b { font-size: 15px; }
.save-item .meta span { font-size: 12px; color: var(--muted); }
.save-item .acts { display: flex; gap: 6px; flex-shrink: 0; }
.save-item.empty { color: var(--muted); }
.help-steps { padding-left: 20px; color: var(--ink-2); }
.help-steps li { margin: 8px 0; }
.help-steps b { color: var(--ink); }
.keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px 14px; font-size: 13px; color: var(--ink-2); margin-top: 10px; }
.result-card h2 { font-size: 28px; }
.result-reason { color: var(--ink-2); margin: 6px 0 14px; }
.result-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0; }
.result-stats div { padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,0.05); border: 1px solid var(--line); }
.result-stats dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.result-stats dd { margin: 2px 0 0; font-family: var(--mono); font-size: 16px; font-variant-numeric: tabular-nums; }
.result-card[data-tone="good"] .eyebrow { color: var(--mint); }
.result-card[data-tone="bad"] .eyebrow { color: var(--coral); }
.result-card[data-tone="warn"] .eyebrow { color: var(--amber); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .setup-grid { grid-template-columns: 1fr; }
  .hud-panel { width: 190px; padding: 10px 12px; }
  .readout { font-size: 12px; }
  .readout b { font-size: 13px; }
}
@media (max-width: 680px) {
  body { font-size: 14px; }
  .menu-row { grid-template-columns: 1fr; }
  .screen-menu { align-items: flex-end; padding-bottom: 40px; }
  .hud-top { grid-template-columns: 1fr auto; }
  .hud-mission { display: none; }
  .hud-clock { justify-items: start; }
  .clock { font-size: 20px; }
  .hud-panel { top: 86px; width: calc(50% - 22px); padding: 8px 10px; }
  .hud-panel .meter-block, .hud-panel .panel-title.sub { display: none; }
  .hud-right .readout:nth-of-type(3), .hud-right .readout:nth-of-type(n+5) { display: none; }
  .hud-left .readout:nth-of-type(n+4) { display: none; }
  .readout { font-size: 11px; }
  .readout i { display: none; }
  .fuel-bars { display: none; }
  .toasts { top: 196px; }
  .toast { font-size: 13px; padding: 7px 12px; }
  .dock { gap: 8px; padding: 8px; }
  .hud-top-actions .btn-icon { min-width: 40px; padding: 6px 8px; }
  .throttle-group { min-width: 120px; }
  .btn-stage { min-width: 110px; }
  .val-nums { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .choice, .chip, .toast, .modal-card, .role-call { transition: opacity 160ms ease; }
  .btn:active, .choice:active, .chip:active { transform: none; }
  .btn-stage[data-urgent="true"] { animation: none; outline: 2px solid var(--amber); }
}

/* ---------- mission score ---------- */
.score-block h3 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.score-big { font-family: var(--mono); font-size: 22px; color: var(--ink); letter-spacing: 0; text-transform: none; }
.score-grade { font-size: 13px; font-weight: 800; padding: 2px 10px; border-radius: 999px; background: rgba(255,255,255,0.08); color: var(--ink); text-transform: none; letter-spacing: 0.04em; }
.score-grade[data-grade="A"], .score-grade[data-grade="B"] { background: rgba(90,242,176,0.16); color: var(--mint); }
.score-grade[data-grade="C"] { background: rgba(255,181,71,0.16); color: var(--amber); }
.score-grade[data-grade="D"], .score-grade[data-grade="F"] { background: rgba(255,107,107,0.16); color: var(--coral); }
.score-table td { font-size: 12px; color: var(--ink-2); }
.score-table .score-pts { font-family: var(--mono); color: var(--ink); white-space: nowrap; font-size: 13px; }

/* ---------- share a design ---------- */
.share-box { padding: 14px 16px; display: grid; gap: 10px; }
.share-box .hint { margin: 0; }
.share-row { display: flex; flex-wrap: wrap; gap: 8px; }
.share-row input { flex: 1 1 200px; min-width: 0; min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: rgba(2,4,12,0.5); font-family: var(--mono); font-size: 16px; }
.share-status { margin: 0; font-size: 13px; color: var(--ink-2); min-height: 1.2em; }
.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; }

/* ---------- beginners ---------- */
.starter { padding: 14px 16px; margin-bottom: 18px; display: grid; gap: 10px; }
.starter p { margin: 0; font-size: 14px; color: var(--ink-2); }
.starter p b { color: var(--ink); }
.starter-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.starter-msg { color: var(--mint) !important; font-weight: 600; }

/* map view: drag to look around */
#scene.map-drag { cursor: grab; }
#scene.map-drag:active { cursor: grabbing; }
