/* MISSION COMMAND. One small system: dark olive glass panels, one amber accent.
   Three text roles (label, body, display), one corner radius, big touch targets. */
:root {
  --ink: #eef0e6;
  --dim: #a9ad9a;
  --amber: #ffb23e;
  --glass: rgba(12, 15, 10, 0.66);
  --line: rgba(255, 190, 90, 0.26);
  --r: 10px;
  --label: 12px;
  --body: clamp(15px, 1.1vw + 10px, 18px);
  --pad: clamp(14px, 2.2vw, 28px);
  --font: "Avenir Next", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #0b0d0a; color: var(--ink); font-family: var(--font); overflow: hidden; overscroll-behavior: none; touch-action: none; user-select: none; -webkit-user-select: none; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#view.thermal { filter: grayscale(1) contrast(1.35) brightness(1.5); }
#lens { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 46%, transparent 58%, rgba(0, 0, 0, 0.34) 100%); }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

/* screens */
.screen { position: fixed; inset: 0; display: grid; place-items: center; justify-items: start; padding: max(var(--pad), env(safe-area-inset-top)) max(var(--pad), env(safe-area-inset-right)) max(var(--pad), env(safe-area-inset-bottom)) max(var(--pad), env(safe-area-inset-left)); background: linear-gradient(90deg, rgba(8, 10, 7, 0.82) 0%, rgba(8, 10, 7, 0.42) 48%, rgba(8, 10, 7, 0) 80%); overflow-y: auto; touch-action: pan-y; }
#loading { background: #0b0d0a; justify-items: center; }
#pause, #result { background: rgba(8, 10, 7, 0.55); justify-items: center; }
.card { width: min(100%, 500px); display: grid; gap: clamp(12px, 1.8vh, 20px); padding: clamp(18px, 3vw, 32px); background: var(--glass); border: 1px solid var(--line); border-radius: var(--r); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.card.bare { background: none; border: 0; backdrop-filter: none; -webkit-backdrop-filter: none; text-align: center; width: min(100%, 440px); }
h1, h2 { margin: 0; font-weight: 700; text-transform: uppercase; letter-spacing: 0.16em; line-height: 1.02; color: #fff; }
h1 { font-size: clamp(40px, 6.4vw, 78px); }
h2 { font-size: clamp(24px, 3vw, 36px); }
.lede { margin: 0; font-size: var(--body); line-height: 1.45; color: var(--ink); max-width: 36ch; }
.help { margin: 0; font-size: var(--label); line-height: 1.6; letter-spacing: 0.04em; color: var(--dim); }
.go { min-height: 56px; padding: 0 16px; border-radius: var(--r); background: var(--amber); color: #171106; font-size: clamp(16px, 1.5vw, 20px); font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; transition: transform 0.12s; }
.go.alt { background: #e6e2cf; }
.go:active { transform: scale(0.98); }
.go[disabled] { opacity: 0.4; }
.plain { min-height: 48px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line); font-size: var(--body); letter-spacing: 0.08em; text-transform: uppercase; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.row3 .go, .row3 .plain { font-size: clamp(13px, 1.1vw, 16px); letter-spacing: 0.1em; min-height: 52px; padding: 0 6px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; font-size: var(--label); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink); }
.loadbar { height: 3px; background: rgba(255, 255, 255, 0.12); border-radius: 3px; overflow: hidden; }
.loadbar i { display: block; height: 100%; width: 4%; background: var(--amber); transition: width 0.3s; }
#fleet { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.veh { display: grid; gap: 2px; text-align: left; min-height: 52px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r); background: rgba(20, 24, 16, 0.5); }
.veh b { font-size: clamp(14px, 1.2vw, 17px); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.veh span { font-size: var(--label); letter-spacing: 0.03em; color: var(--dim); }
.veh[aria-checked="true"] { border-color: var(--amber); background: rgba(90, 64, 18, 0.5); box-shadow: 0 0 0 1px var(--amber) inset; }
.veh[aria-checked="true"] span { color: var(--ink); }
.licence { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); }
.licence h3 { grid-column: 1 / -1; margin: 0; font-size: var(--body); font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }
.licence p { grid-column: 1 / -1; margin: 0; font-size: var(--label); line-height: 1.5; color: var(--dim); }
.licence div { display: grid; gap: 2px; }
.licence span, .results span, .chip span { font-size: var(--label); letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.licence b { font-size: var(--body); font-weight: 600; color: var(--amber); font-variant-numeric: tabular-nums; }
.results { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.results div { display: grid; gap: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); }
.results b { font-size: clamp(20px, 2.4vw, 28px); font-weight: 600; color: var(--amber); font-variant-numeric: tabular-nums; }

/* in the vehicle */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud button { pointer-events: auto; }
.hud-top { position: absolute; top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); right: 160px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: grid; grid-template-columns: auto auto; column-gap: 6px; align-items: baseline; justify-content: start; padding: 7px 11px; min-width: 84px; background: var(--glass); border: 1px solid var(--line); border-radius: var(--r); }
.chip span { grid-column: 1 / -1; }
.chip b { font-size: clamp(17px, 1.7vw, 22px); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip i { font-style: normal; font-size: var(--label); color: var(--dim); }
.hud-side { position: absolute; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); display: flex; gap: 8px; }
.tool { display: grid; justify-items: center; gap: 2px; width: 64px; min-height: 56px; padding: 8px 4px 6px; background: var(--glass); border: 1px solid var(--line); border-radius: var(--r); }
.tool svg, #nav svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tool span { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
#nav { position: absolute; left: 50%; top: max(84px, calc(env(safe-area-inset-top) + 84px)); transform: translateX(-50%); display: none; align-items: center; gap: 8px; padding: 6px 12px; background: var(--glass); border: 1px solid var(--line); border-radius: 999px; }
#nav.show { display: flex; }
#nav svg { stroke: var(--amber); fill: var(--amber); transition: transform 0.1s linear; }
#nav b { font-size: var(--body); font-weight: 600; font-variant-numeric: tabular-nums; }
#reticle { position: absolute; left: 0; top: 0; width: 0; height: 0; display: none; }
#reticle.show { display: block; }
#reticle i { position: absolute; left: -17px; top: -17px; width: 34px; height: 34px; border: 2px solid var(--amber); border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(0, 0, 0, 0.5); }
#reticle i::after { content: ""; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; background: var(--amber); border-radius: 50%; }
#reticle b { position: absolute; left: 24px; top: -9px; font-size: var(--label); font-weight: 600; letter-spacing: 0.06em; white-space: nowrap; color: var(--amber); text-shadow: 0 1px 2px #000; }
#sight { position: absolute; inset: 0; display: none; background: radial-gradient(circle at 50% 50%, transparent 0, transparent 38vmin, rgba(0, 0, 0, 0.9) 39vmin); }
#sight.show { display: block; }
#reload { position: absolute; left: 50%; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 4px); transform: translateX(-50%); width: min(30vw, 220px); height: 5px; background: rgba(255, 255, 255, 0.16); border-radius: 5px; overflow: hidden; display: none; }
#reload.show { display: block; }
#reload i { display: block; height: 100%; width: 100%; background: var(--amber); }
#banner { position: absolute; left: 0; right: 0; top: 24%; text-align: center; font-size: clamp(30px, 6vw, 80px); font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: #fff; text-shadow: 0 2px 24px rgba(0, 0, 0, 0.7); opacity: 0; transition: opacity 0.25s; }
#banner.show { opacity: 1; }
#banner.small { font-size: clamp(18px, 2.6vw, 30px); top: 31%; }
#coach { position: absolute; left: 50%; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 22px); transform: translateX(-50%); padding: 10px 16px; width: max-content; max-width: min(88vw, 620px); text-align: center; font-size: var(--body); line-height: 1.5; background: var(--glass); border: 1px solid var(--line); border-radius: var(--r); opacity: 0; transition: opacity 0.4s; }
#coach.show { opacity: 1; }
#coach kbd { display: inline-block; min-width: 1.9em; padding: 1px 7px; margin: 0 2px; border: 1px solid var(--amber); border-radius: 6px; font: inherit; font-weight: 600; color: var(--amber); }

/* touch */
.stick { position: absolute; width: 132px; height: 132px; margin: -66px 0 0 -66px; border: 2px solid var(--line); border-radius: 50%; background: rgba(12, 15, 10, 0.3); opacity: 0; transition: opacity 0.15s; }
.stick.on { opacity: 1; }
.nub { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; border-radius: 50%; background: rgba(255, 178, 62, 0.6); transform: translate(-50%, -50%); }
.pad { position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: calc(max(18px, env(safe-area-inset-bottom)) + 150px); width: 92px; height: 92px; display: none; place-items: center; border-radius: 50%; border: 2px solid var(--amber); background: var(--glass); font-size: 13px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; touch-action: none; }
.pad.show { display: grid; }
.pad.down { background: rgba(255, 178, 62, 0.4); }
body.touch #coach { bottom: auto; top: max(84px, calc(env(safe-area-inset-top) + 84px)); font-size: 14px; }
body.touch #nav { top: auto; bottom: max(14px, env(safe-area-inset-bottom)); }
body.touch #reload { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 52px); }

@media (max-height: 520px) {
  .card { gap: 8px; padding: 14px 16px; width: min(100%, 470px); }
  h1 { font-size: clamp(30px, 9vh, 48px); }
  h2 { font-size: 20px; }
  .veh { min-height: 44px; padding: 5px 10px; }
  .veh span { display: none; }
  .go { min-height: 46px; } .plain { min-height: 44px; }
  .row3 .go, .row3 .plain { min-height: 46px; }
  .licence { padding: 8px 12px; gap: 4px 12px; }
  .licence p { display: none; }
  .chip { padding: 5px 9px; min-width: 70px; }
  .chip.wide { min-width: 0; }
  #fleet { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 640px) and (orientation: portrait) {
  .screen { background: linear-gradient(180deg, rgba(8, 10, 7, 0.3) 0%, rgba(8, 10, 7, 0.85) 60%); align-items: end; justify-items: center; }
  .hud-top { right: 12px; top: calc(max(12px, env(safe-area-inset-top)) + 64px); }
}
