:root {
  --ink: #e8eef2;
  --dim: #8d9aa4;
  --line: rgba(232, 238, 242, 0.14);
  --amber: #ffb347;
  --green: #8dfc9a;
  --red: #ff4a3a;
  --panel: rgba(6, 9, 12, 0.82);
  --mono: "DejaVu Sans Mono", "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  --display: "Bahnschrift", "DIN Condensed", "Oswald", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #020304; color: var(--ink); font-family: var(--mono); }
#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; outline: none; }
button { font: inherit; }
kbd { display: inline-block; min-width: 1.7em; padding: 0.1em 0.45em; margin: 0 0.1em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: rgba(255,255,255,0.06); font-family: var(--mono); font-size: 0.85em; text-align: center; }

.screen { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 20; padding: 24px; }
.screen.on { display: flex; }
.screen.passthrough { pointer-events: none; }
.screen.passthrough .hangar-card { pointer-events: auto; }
.stamp { display: inline-block; color: var(--red); border: 2px solid var(--red); padding: 3px 9px; letter-spacing: 0.18em; font-size: 11px; transform: rotate(-1.5deg); margin-bottom: 14px; font-weight: 700; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: 0.04em; margin: 0 0 10px; text-transform: uppercase; }

#loading { background: #020304; z-index: 50; }
.load-box { text-align: center; }
.load-box h1 { font-size: clamp(34px, 6vw, 72px); }
.load-box .bar { width: min(420px, 80vw); height: 3px; background: var(--line); margin: 18px auto 0; }
.load-box .bar span { display: block; height: 100%; width: 0; background: var(--amber); transition: width 0.2s; }
#load-text { color: var(--dim); }

/* title */
#screen-title { justify-content: flex-start; align-items: center; background: linear-gradient(90deg, rgba(2,3,4,0.85) 0%, rgba(2,3,4,0.35) 45%, rgba(2,3,4,0) 70%); }
.title-block { max-width: 560px; padding: 0 0 0 3vw; }
.title-block h1 { font-size: clamp(40px, min(6vw, 9vh), 92px); line-height: 0.92; }
.title-block h1 span { color: var(--amber); }
.title-block .sub { font-family: var(--display); letter-spacing: 0.4em; text-transform: uppercase; color: var(--dim); margin: 0 0 16px; }
.lede { font-size: 15px; line-height: 1.6; color: #c6d0d6; max-width: 46ch; }
.hint { color: var(--dim); font-size: 12px; }
.menu { display: flex; flex-direction: column; gap: 6px; margin: 18px 0; align-items: flex-start; }
.menu button, .row button {
  background: rgba(8, 12, 16, 0.6); color: var(--ink); border: 1px solid var(--line); padding: 10px 18px; min-width: 220px; text-align: left;
  letter-spacing: 0.12em; text-transform: uppercase; font-size: 13px; cursor: pointer; transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.menu button:hover, .row button:hover, .menu button:focus-visible, .row button:focus-visible { background: rgba(255, 179, 71, 0.12); border-color: var(--amber); transform: translateX(4px); outline: none; }
button.primary { border-color: var(--amber); color: var(--amber); }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.row button { min-width: 0; }

.panel { background: var(--panel); border: 1px solid var(--line); padding: 26px 30px; width: min(520px, 94vw); max-height: 92vh; overflow: auto; backdrop-filter: blur(6px); }
.panel.wide { width: min(760px, 94vw); }
.panel label { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.panel select, .panel input[type=range] { background: #0b1016; color: var(--ink); border: 1px solid var(--line); padding: 4px 6px; font: inherit; }
.panel p { line-height: 1.6; color: #c6d0d6; }
.panel .small { font-size: 12px; color: var(--dim); }
.keys div { padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }

/* operations */
#screen-ops { background: rgba(2, 3, 4, 0.72); }
.ops { width: min(1080px, 96vw); }
.ops-grid { display: grid; grid-template-columns: minmax(260px, 360px) 1fr; gap: 18px; }
#mission-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
#mission-list li { border: 1px solid var(--line); background: var(--panel); padding: 12px 14px; cursor: pointer; display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center; }
#mission-list li:hover, #mission-list li.sel { border-color: var(--amber); }
#mission-list li.locked { opacity: 0.4; cursor: not-allowed; }
#mission-list .n { font-family: var(--display); font-size: 26px; color: var(--amber); }
#mission-list .t { font-family: var(--display); text-transform: uppercase; letter-spacing: 0.05em; font-size: 17px; }
#mission-list .k { font-size: 11px; color: var(--dim); }
#mission-list .g { font-family: var(--display); font-size: 22px; color: var(--green); }
#mission-detail { background: var(--panel); border: 1px solid var(--line); padding: 22px 26px; min-height: 380px; }
#mission-detail .kicker { color: var(--amber); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; }
#mission-detail h3 { font-size: 34px; margin-top: 6px; }
#mission-detail p { line-height: 1.65; color: #c6d0d6; }
#md-objectives { padding-left: 18px; color: #c6d0d6; font-size: 13px; line-height: 1.7; }
.md-best { color: var(--green); font-size: 13px; }

.hangar-card { position: fixed; left: 3vw; bottom: 5vh; width: min(420px, 90vw); background: var(--panel); border: 1px solid var(--line); padding: 20px 22px; }
.hangar-card p { font-size: 13px; line-height: 1.6; color: #c6d0d6; }
.toggles label { display: block; padding: 5px 0; font-size: 13px; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; font-size: 13px; text-shadow: 0 1px 2px rgba(0,0,0,0.8); }
#hud.hidden { display: none; }
#hud-mission { position: absolute; left: 18px; top: 16px; max-width: 380px; }
#hud-title { font-family: var(--display); text-transform: uppercase; letter-spacing: 0.12em; color: var(--amber); font-size: 15px; margin-bottom: 6px; }
#objectives { margin: 0; padding-left: 18px; line-height: 1.55; color: var(--dim); }
#objectives li.cur { color: var(--ink); }
#objectives li.done { color: var(--green); text-decoration: line-through; opacity: 0.7; }
#objectives li.opt { color: #9fb2c0; font-style: italic; }
#objectives .pct { color: var(--amber); }
#flight-data { position: absolute; right: 18px; top: 16px; display: grid; grid-template-columns: repeat(2, 104px); gap: 4px; }
.fd { background: rgba(0,0,0,0.35); border: 1px solid var(--line); padding: 5px 8px; }
.fd span { display: block; font-size: 10px; color: var(--dim); letter-spacing: 0.12em; }
.fd b { font-size: 19px; font-weight: 700; color: var(--green); }
.fd b.bad { color: var(--red); }
.dmg { grid-column: span 2; font-size: 10px; color: var(--dim); letter-spacing: 0.12em; }
.dmg i { display: block; height: 4px; background: rgba(255,255,255,0.1); margin-top: 3px; }
.dmg em { display: block; height: 100%; width: 0; background: var(--red); }
#throttle { position: absolute; right: 250px; top: 16px; width: 36px; text-align: center; }
#throttle .track { position: relative; height: 150px; width: 14px; margin: 0 auto; border: 1px solid var(--line); background: rgba(0,0,0,0.35); }
#d-thr { position: absolute; bottom: 0; left: 0; right: 0; background: var(--green); }
#d-thr.ab { background: linear-gradient(0deg, var(--green) 0%, var(--green) 72%, var(--amber) 72%); }
#throttle .ab-line { position: absolute; left: -6px; right: -6px; bottom: 72%; border-top: 1px dashed var(--amber); }
#d-thr-label { font-size: 10px; margin-top: 4px; color: var(--dim); white-space: nowrap; transform: translateX(-20%); }
#warn { position: absolute; top: 14%; left: 50%; transform: translateX(-50%); font-family: var(--display); font-size: 26px; letter-spacing: 0.2em; padding: 6px 18px; display: none; }
#warn.on { display: block; animation: blink 0.5s steps(2) infinite; }
#warn.red { color: var(--red); border: 2px solid var(--red); background: rgba(40,0,0,0.35); }
#warn.amber { color: var(--amber); border: 2px solid var(--amber); background: rgba(40,24,0,0.35); animation: none; }
@keyframes blink { 50% { opacity: 0.35; } }
#toast { position: absolute; top: 22%; left: 50%; transform: translate(-50%, 0); color: var(--ink); background: rgba(0,0,0,0.55); border: 1px solid var(--line); padding: 6px 14px; opacity: 0; transition: opacity 0.3s; font-size: 14px; }
#toast.on { opacity: 1; }
#radio { position: absolute; left: 50%; bottom: 72px; transform: translateX(-50%); max-width: min(760px, 90vw); background: rgba(0,0,0,0.6); border-left: 3px solid var(--amber); padding: 8px 14px; opacity: 0; transition: opacity 0.25s; font-size: 14px; line-height: 1.45; }
#radio.on { opacity: 1; }
#radio-who { color: var(--amber); margin-right: 10px; letter-spacing: 0.1em; font-weight: 700; }
#status-line { position: absolute; left: 18px; bottom: 16px; color: var(--dim); font-size: 12px; }
#status-line b { color: var(--green); font-weight: 700; }
#status-line b.a { color: var(--amber); }
#status-line b.r { color: var(--red); }
#view-mode { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); color: var(--dim); letter-spacing: 0.2em; font-size: 11px; }
#keyhint { position: absolute; right: 18px; bottom: 16px; color: rgba(141,154,164,0.8); font-size: 11px; }
#hud.minimal #flight-data, #hud.minimal #throttle, #hud.minimal #keyhint { display: none; }
#markers { position: absolute; inset: 0; }
.marker { position: absolute; left: 0; top: 0; color: var(--amber); font-size: 11px; white-space: nowrap; }
.marker .diamond { position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; border: 2px solid currentColor; transform: rotate(45deg); }
.marker .lbl { position: absolute; left: 14px; top: -7px; }
.marker.edge .diamond { background: currentColor; opacity: 0.7; }
.marker.tanker { color: #7fd4ff; }
.marker.field { color: var(--green); }
.marker.threat { color: var(--red); }
#refuel-director { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: none; text-align: center; }
#refuel-director.on { display: block; }
#refuel-director .ring { width: 180px; height: 180px; border: 1px solid rgba(127,212,255,0.6); border-radius: 50%; position: relative; margin: 0 auto; }
#refuel-director .ring::before, #refuel-director .ring::after { content: ""; position: absolute; background: rgba(127,212,255,0.35); }
#refuel-director .ring::before { left: 50%; top: 0; bottom: 0; width: 1px; }
#refuel-director .ring::after { top: 50%; left: 0; right: 0; height: 1px; }
#refuel-dot { position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #7fd4ff; box-shadow: 0 0 10px #7fd4ff; }
#refuel-director.contact #refuel-dot { background: var(--green); box-shadow: 0 0 14px var(--green); }
#refuel-text { margin-top: 10px; color: #7fd4ff; }
#rso { position: absolute; inset: 0; display: none; color: #b8ffcf; }
#rso.on { display: block; }
#rso .reticle { position: absolute; left: 50%; top: 50%; width: 320px; height: 320px; transform: translate(-50%, -50%); fill: none; stroke: #b8ffcf; stroke-width: 1.2; opacity: 0.85; }
#rso-mode { position: absolute; left: 24px; top: 20px; font-size: 18px; letter-spacing: 0.18em; }
#rso-frames { position: absolute; right: 24px; top: 20px; }
#rso-info { position: absolute; left: 24px; bottom: 58px; white-space: pre; }
#rso-target { position: absolute; left: 50%; top: calc(50% + 180px); transform: translateX(-50%); text-align: center; color: var(--amber); }
#rso-help { position: absolute; left: 24px; bottom: 24px; color: rgba(184,255,207,0.7); font-size: 12px; }
#hud.rso-on #hud-mission, #hud.rso-on #flight-data, #hud.rso-on #throttle, #hud.rso-on #keyhint, #hud.rso-on #view-mode { display: none; }
#map { position: absolute; left: 8vw; top: 8vh; width: 84vw; height: 84vh; display: none; border: 1px solid var(--line); }
#map.on { display: block; }

/* debrief */
.debrief .db-head { display: flex; gap: 22px; align-items: center; }
.grade { font-family: var(--display); font-size: 96px; line-height: 1; color: var(--amber); min-width: 90px; text-align: center; }
#db-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 22px; margin: 18px 0 0; }
#db-stats div { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 5px 0; font-size: 13px; }
#db-stats dt { color: var(--dim); }
#db-stats dd { margin: 0; color: var(--green); }

@media (max-width: 760px) {
  .ops-grid { grid-template-columns: 1fr; }
  #flight-data { grid-template-columns: repeat(2, 86px); }
  #throttle { right: 200px; }
  #keyhint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  #warn.on { animation: none; }
}
