:root {
  color-scheme: dark;
  --ui-scale: 1;
  --ink: #e8f0f7;
  --muted: #aab8c8;
  --faint: rgba(210, 230, 247, 0.12);
  --line: rgba(186, 215, 237, 0.25);
  --panel: rgba(5, 14, 24, 0.8);
  --panel-solid: #071524;
  --amber: #f2ba68;
  --cyan: #72d6ff;
  --warning: #ff7e57;
}

* { box-sizing: border-box; }

html,
body,
#app-root {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #06111e;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: calc(16px * var(--ui-scale));
}

button,
input,
select { font: inherit; }

button {
  border: 1px solid rgba(191, 219, 241, 0.31);
  border-radius: 5px;
  padding: 0.76rem 1rem;
  color: var(--ink);
  background: rgba(12, 29, 47, 0.82);
  cursor: pointer;
  letter-spacing: 0.035em;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

button:hover:not(:disabled),
button:focus-visible:not(:disabled) {
  border-color: var(--cyan);
  background: rgba(21, 55, 82, 0.96);
  transform: translateY(-1px);
}

button:disabled { cursor: not-allowed; opacity: 0.46; }

button.primary {
  color: #09131c;
  border-color: #f4c979;
  background: linear-gradient(120deg, #f5ca75, #db9b4b);
  font-weight: 800;
}

#app-root { position: relative; overflow: hidden; }

#app-canvas,
#art-backdrop,
#scene-vignette,
#cockpit-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#app-canvas { z-index: 0; display: block; background: #06111e; }

#art-backdrop {
  z-index: 1;
  pointer-events: none;
  opacity: 0.98;
  background-image: linear-gradient(90deg, rgba(4, 13, 23, 0.82) 0%, rgba(4, 13, 23, 0.34) 48%, rgba(4, 13, 23, 0.1) 100%), var(--art-image, none);
  background-size: cover;
  background-position: center;
  filter: brightness(1.14) saturate(1.04);
  transition: opacity 380ms ease;
}

#scene-vignette {
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 35%, transparent 24%, rgba(1, 7, 14, 0.2) 66%, rgba(0, 5, 11, 0.7) 100%);
}

#app-root::after {
  position: fixed;
  z-index: 3;
  inset: 0;
  content: "";
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, rgba(255, 58, 38, 0.03) 28%, rgba(255, 28, 18, 0.58) 100%);
}

body[data-screen="flight"][data-ground-alert="warning"] #app-root::after {
  animation: terrain-flash 760ms steps(2, end) infinite;
}

body[data-screen="flight"][data-ground-alert="critical"] #app-root::after {
  animation: terrain-flash 360ms steps(2, end) infinite;
}

@keyframes terrain-flash {
  0%, 45% { opacity: 0; }
  46%, 100% { opacity: 0.92; }
}

#cockpit-overlay {
  z-index: 4;
  display: none;
  pointer-events: none;
  overflow: hidden;
  isolation: isolate;
}

#cockpit-plate {
  position: absolute;
  inset: 0;
  background: url("../assets/art/sr71-recon/cockpit-hud-v2.png") center / cover no-repeat;
  -webkit-mask: url("../assets/art/sr71-recon/cockpit-hud-mask.svg") center / cover no-repeat;
  mask: url("../assets/art/sr71-recon/cockpit-hud-mask.svg") center / cover no-repeat;
  filter: brightness(1.02) saturate(0.92);
}

#cockpit-overlay::before {
  position: absolute;
  z-index: 1;
  inset: 0;
  content: "";
  background: radial-gradient(ellipse at 50% 20%, rgba(80, 153, 217, 0.08), transparent 44%), linear-gradient(180deg, rgba(2, 8, 16, 0.08), rgba(1, 6, 12, 0.18));
  mix-blend-mode: screen;
}

body[data-screen="flight"] #art-backdrop,
body[data-screen="pause"] #art-backdrop,
body[data-screen="credits"] #art-backdrop { opacity: 0; }
body[data-screen="flight"][data-camera="cockpit"][data-crash="none"] #cockpit-overlay { display: block; }
body[data-crash="active"] #cockpit-overlay,
body[data-crash="active"] #flight-director,
body[data-crash="active"] #tutorial-coach,
body[data-crash="active"] #ground-proximity-alert { display: none; }

#cockpit-telemetry {
  position: absolute;
  z-index: 2;
  inset: 0;
  color: #abffe1;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  text-shadow: 0 0 9px rgba(101, 255, 200, 0.68), 0 0 2px rgba(196, 255, 231, 0.92);
}

.cockpit-data-mask {
  overflow: hidden;
  border: 1px solid rgba(132, 255, 205, 0.2);
  background: linear-gradient(130deg, rgba(2, 20, 21, 0.04), rgba(0, 8, 11, 0.34));
  clip-path: polygon(4% 0, 96% 0, 100% 7%, 100% 93%, 96% 100%, 4% 100%, 0 93%, 0 7%);
}

#cockpit-combiner {
  position: absolute;
  left: 39.7%;
  top: 14.4%;
  width: 20.6%;
  height: 30.1%;
  border-color: rgba(113, 255, 212, 0.28);
  background: linear-gradient(180deg, rgba(5, 38, 42, 0.08), rgba(1, 9, 12, 0.02));
  clip-path: polygon(10% 0, 90% 0, 100% 100%, 0 100%);
}

#cockpit-horizon {
  position: absolute;
  inset: 9% 6% 15%;
  overflow: hidden;
}

.cockpit-horizon-line {
  position: absolute;
  left: -24%;
  top: 50%;
  width: 148%;
  height: 1px;
  border-top: 2px solid rgba(157, 255, 222, 0.9);
  box-shadow: 0 0 9px rgba(100, 255, 203, 0.84);
  transform: translateY(var(--cockpit-pitch, 0px)) rotate(var(--cockpit-bank, 0deg));
  transform-origin: center;
}

.cockpit-horizon-line::before,
.cockpit-horizon-line::after {
  position: absolute;
  top: -7px;
  width: 1px;
  height: 14px;
  content: "";
  background: currentColor;
}

.cockpit-horizon-line::before { left: 20%; }
.cockpit-horizon-line::after { right: 20%; }

.cockpit-flight-path {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(207, 255, 235, 0.92);
  border-radius: 50%;
  box-shadow: 0 0 9px rgba(100, 255, 203, 0.84);
  transform: translate(-50%, -50%);
}

.cockpit-flight-path::before,
.cockpit-flight-path::after {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 1px;
  content: "";
  background: currentColor;
}

.cockpit-flight-path::before { right: 100%; }
.cockpit-flight-path::after { left: 100%; }

.cockpit-combiner-top,
.cockpit-combiner-left,
.cockpit-combiner-right,
.cockpit-combiner-bottom {
  position: absolute;
  display: grid;
  gap: 0.12rem;
  font-size: clamp(0.42rem, 0.7vw, 0.68rem);
  line-height: 1;
}

.cockpit-combiner-top { top: 6%; left: 50%; text-align: center; transform: translateX(-50%); }
.cockpit-combiner-left { left: 8%; bottom: 11%; }
.cockpit-combiner-right { right: 8%; bottom: 11%; text-align: right; }
.cockpit-combiner-bottom { bottom: 3%; left: 50%; grid-auto-flow: column; column-gap: 1.1rem; transform: translateX(-50%); }
.cockpit-combiner-left strong,
.cockpit-combiner-right strong,
.cockpit-combiner-top span:first-child { font-size: 1.45em; }

.cockpit-screen {
  position: absolute;
  top: 60.3%;
  width: 21.6%;
  height: 28.7%;
  padding: 7% 8%;
  color: #9dffd8;
  background: linear-gradient(145deg, rgba(3, 19, 19, 0.16), rgba(0, 4, 7, 0.42));
}

#cockpit-engine-screen { left: 12.3%; }
#cockpit-mission-screen { right: 12.4%; color: #b5eaff; text-shadow: 0 0 9px rgba(86, 198, 255, 0.7); }

.cockpit-screen-title {
  margin-bottom: 0.72rem;
  border-bottom: 1px solid currentColor;
  padding-bottom: 0.36rem;
  font-size: clamp(0.36rem, 0.55vw, 0.58rem);
  font-weight: 800;
}

.cockpit-screen dl { display: grid; gap: 0.48rem; margin: 0; }
.cockpit-screen dl div { display: flex; justify-content: space-between; gap: 0.4rem; }
.cockpit-screen dt { color: rgba(191, 255, 228, 0.68); font-size: clamp(0.38rem, 0.6vw, 0.6rem); }
.cockpit-screen dd { margin: 0; font-size: clamp(0.46rem, 0.78vw, 0.78rem); font-weight: 800; }
.cockpit-bar { position: absolute; right: 8%; bottom: 9%; left: 8%; height: 4px; border: 1px solid rgba(179, 255, 223, 0.5); }
.cockpit-bar span { display: block; width: var(--cockpit-throttle, 0%); height: 100%; background: #9dffd8; box-shadow: 0 0 8px rgba(112, 255, 203, 0.96); }

#cockpit-mission,
#cockpit-objective-short,
#cockpit-threat,
#cockpit-cloud-state { font-size: clamp(0.43rem, 0.66vw, 0.66rem); line-height: 1.45; }
#cockpit-objective-short { min-height: 2.6em; color: #e9f7ff; }
#cockpit-threat { color: #c7ffe0; }
#cockpit-threat.locked { color: #ff9b74; text-shadow: 0 0 10px rgba(255, 97, 64, 0.88); }
#cockpit-cloud-state { margin-top: 0.52rem; color: #96d9ff; }
.cockpit-screen-rule { height: 1px; margin: 0.52rem 0; background: currentColor; opacity: 0.42; }

#screen-layer {
  position: fixed;
  z-index: 3;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(18px, 4vw, 56px);
  pointer-events: none;
}

.screen {
  display: none;
  width: min(690px, 100%);
  max-height: min(82vh, 760px);
  overflow: auto;
  pointer-events: auto;
  padding: clamp(1.25rem, 3.1vw, 2.5rem);
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(7, 20, 33, 0.91), rgba(3, 11, 20, 0.84));
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(14px);
}

.screen.active { display: block; }

#screen-title {
  width: min(720px, 100%);
  align-self: center;
  margin-right: auto;
  border: none;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  padding-left: clamp(0.25rem, 4vw, 4rem);
}

.eyebrow,
.screen-kicker {
  margin-bottom: 0.7rem;
  color: var(--amber);
  font-size: 0.69em;
  font-weight: 800;
  letter-spacing: 0.2em;
}

h1,
h2,
p { margin: 0; }

h1 {
  font-size: clamp(3.8rem, 10vw, 7.6rem);
  line-height: 0.78;
  letter-spacing: -0.08em;
  font-weight: 880;
}

h1 em { color: var(--amber); font-family: Georgia, "Times New Roman", serif; font-weight: 500; }

#screen-title h1 { font-size: clamp(3.5rem, 7.6vw, 6.3rem); }

h2 {
  font-size: clamp(2rem, 4vw, 3.45rem);
  line-height: 0.96;
  letter-spacing: -0.045em;
}

.title-copy,
.screen-copy {
  max-width: 58ch;
  margin-top: 1.35rem;
  color: #d7e3ed;
  font-size: 1.03em;
  line-height: 1.58;
}

.screen-subtitle {
  margin-top: 0.45rem;
  color: var(--cyan);
  font-size: 0.92em;
  letter-spacing: 0.04em;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.7rem;
}

.button-row button { flex: 1 1 190px; }

.text-actions { display: flex; gap: 0.25rem; margin-top: 0.85rem; }
.text-actions button { border-color: transparent; background: transparent; color: var(--muted); padding-left: 0; }

.control-note {
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.76em;
  line-height: 1.4;
}

.mission-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1.4rem;
}

.mission-card {
  min-height: 226px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  text-align: left;
  overflow: hidden;
  position: relative;
  isolation: isolate;
  padding: 1rem;
  background: linear-gradient(0deg, rgba(2, 10, 17, 0.97), rgba(2, 10, 17, 0.1)), var(--card-art);
  background-size: cover;
  background-position: center;
}

.mission-card::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  background: linear-gradient(0deg, rgba(2, 11, 19, 0.86), transparent 66%);
}

.mission-card.selected { border-color: var(--amber); box-shadow: inset 0 0 0 1px rgba(242, 186, 104, 0.22); }
.mission-card-number,
.mission-card-grade { color: var(--amber); font-size: 0.67em; letter-spacing: 0.13em; }
.mission-card strong { margin: 0.45rem 0 0.26rem; font-size: 1.14em; }
.mission-card span:not(.mission-card-number):not(.mission-card-grade) { color: #d0dce7; font-size: 0.76em; line-height: 1.34; }
.mission-card-grade { margin-top: 0.85rem; }

.dossier-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 1.65rem 0 0;
}

.dossier-grid div { min-height: 92px; padding: 0.8rem; border-left: 2px solid rgba(114, 214, 255, 0.52); background: rgba(126, 172, 208, 0.07); }
.dossier-grid dt { color: var(--cyan); font-size: 0.67em; font-weight: 800; letter-spacing: 0.13em; }
.dossier-grid dd { margin: 0.55rem 0 0; color: #d4e1eb; font-size: 0.82em; line-height: 1.38; }

.cinematic-screen { background: rgba(2, 10, 19, 0.64); border-color: rgba(217, 237, 255, 0.28); }
.compact-screen { width: min(510px, 100%); }
.credits-screen { align-self: end; margin: 0 0 1.7rem auto; border-color: rgba(123, 203, 240, 0.4); background: linear-gradient(135deg, rgba(2, 12, 23, 0.9), rgba(5, 27, 42, 0.68)); }
.credits-roll { margin: 1.15rem 0; color: var(--amber); font-size: 0.67em; font-weight: 800; letter-spacing: 0.13em; line-height: 1.65; }

.tutorial-steps { display: grid; gap: 0.9rem; padding: 0; margin: 1.4rem 0 0; list-style: none; counter-reset: flight-tutorial; }
.tutorial-steps li { display: grid; grid-template-columns: 34px 1fr; column-gap: 0.7rem; }
.tutorial-steps li::before { counter-increment: flight-tutorial; content: counter(flight-tutorial, decimal-leading-zero); color: var(--amber); font-size: 0.78em; font-weight: 800; letter-spacing: 0.08em; padding-top: 0.15rem; }
.tutorial-steps strong { display: block; }
.tutorial-steps span { grid-column: 2; color: var(--muted); font-size: 0.86em; line-height: 1.42; }

.settings-screen { width: min(880px, 100%); }
.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 1.4rem 0; }
fieldset { min-width: 0; margin: 0; padding: 0.9rem; border: 1px solid var(--line); background: rgba(9, 23, 37, 0.5); }
legend { padding: 0 0.35rem; color: var(--cyan); font-size: 0.69em; font-weight: 800; letter-spacing: 0.12em; }
fieldset label { display: grid; grid-template-columns: 1fr auto; gap: 0.7rem; align-items: center; margin: 0.68rem 0; color: #d4dfe8; font-size: 0.78em; }
input[type="range"] { width: 100%; grid-column: 1 / -1; accent-color: var(--amber); }
input[type="checkbox"] { accent-color: var(--amber); }
.audio-level { margin-top: -0.35rem; padding-bottom: 0.28rem; }
.audio-level > span { display: flex; justify-content: space-between; gap: 0.65rem; color: var(--muted); font-size: 0.9em; }
.audio-level output { color: var(--amber); font-family: "Courier New", monospace; font-weight: 800; }
select { padding: 0.26rem; color: var(--ink); border: 1px solid var(--line); background: #10243a; }

.debrief-grade { float: right; margin: -3.8rem 0 0 1rem; color: var(--amber); font-family: Georgia, "Times New Roman", serif; font-size: clamp(4rem, 9vw, 7rem); line-height: 0.8; }
.debrief-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

#flight-hud {
  display: none;
  position: fixed;
  z-index: 5;
  top: 0;
  left: 0;
  right: 0;
  grid-template-columns: 1.45fr repeat(4, minmax(76px, 0.7fr)) minmax(190px, 1.5fr) auto auto;
  align-items: stretch;
  min-height: 74px;
  color: #edf6ff;
  border-bottom: 1px solid rgba(165, 207, 239, 0.26);
  background: linear-gradient(180deg, rgba(4, 13, 23, 0.92), rgba(4, 13, 23, 0.56));
  backdrop-filter: blur(10px);
}

#flight-hud.active { display: grid; }
.hud-brand,
.hud-readout,
#hud-objective,
#hud-camera,
.hud-pause { padding: 0.75rem 0.9rem; border-right: 1px solid rgba(165, 207, 239, 0.15); }
.hud-brand span { display: block; color: var(--amber); font-size: 0.68em; font-weight: 900; letter-spacing: 0.18em; }
.hud-brand small { color: #ccdce9; font-size: 0.72em; }
.hud-readout span { display: block; color: var(--muted); font-size: 0.58em; font-weight: 800; letter-spacing: 0.13em; }
.hud-readout strong { display: block; margin-top: 0.2rem; font-size: 0.94em; letter-spacing: 0.04em; }
#hud-objective { align-content: center; color: var(--cyan); font-size: 0.68em; font-weight: 800; letter-spacing: 0.08em; }
#hud-camera { align-content: center; color: var(--muted); font-size: 0.65em; letter-spacing: 0.1em; }
#hud-camera { min-width: 0; border: 0; border-radius: 0; background: transparent; text-align: left; }
#hud-camera:hover,
#hud-camera:focus-visible { color: var(--cyan); background: rgba(21, 55, 82, 0.46); transform: none; }
.hud-pause { min-width: 0; border: 0; border-radius: 0; background: transparent; color: var(--ink); font-size: 0.75em; }
#hud-warning { grid-column: 1 / -1; min-height: 25px; padding: 0.28rem 0.9rem; color: #a8c0d2; background: rgba(2, 8, 14, 0.68); font-size: 0.64em; font-weight: 800; letter-spacing: 0.14em; }

#hud-alert {
  position: fixed;
  z-index: 6;
  left: 50%;
  bottom: 7vh;
  width: min(580px, calc(100vw - 2rem));
  transform: translateX(-50%) translateY(1rem);
  padding: 0.85rem 1rem;
  color: #fff4db;
  border-left: 3px solid var(--amber);
  background: rgba(6, 15, 25, 0.87);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.34);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  font-size: 0.84em;
  line-height: 1.4;
}

#hud-alert.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

#ground-proximity-alert {
  position: fixed;
  z-index: 7;
  top: 31%;
  left: 50%;
  display: grid;
  justify-items: center;
  gap: 0.22rem;
  width: min(540px, calc(100vw - 2rem));
  transform: translate(-50%, -50%) scale(0.96);
  padding: 0.72rem 1rem;
  color: #fff0ea;
  border: 2px solid #ff573e;
  background: rgba(78, 7, 5, 0.84);
  box-shadow: 0 0 28px rgba(255, 44, 24, 0.72), inset 0 0 22px rgba(255, 61, 37, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 100ms ease, transform 100ms ease;
  text-align: center;
  text-shadow: 0 0 8px rgba(255, 214, 200, 0.8);
}

#ground-proximity-alert strong { font-size: clamp(0.82rem, 1.4vw, 1.05rem); letter-spacing: 0.2em; }
#ground-proximity-alert span { font-size: clamp(1.1rem, 2.8vw, 1.8rem); font-weight: 900; letter-spacing: 0.16em; }
#ground-proximity-alert.visible { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#hud-warning.ground-warning { color: #fff0eb; background: rgba(112, 10, 7, 0.78); }

#flight-director {
  display: none;
  position: fixed;
  z-index: 6;
  top: 5.8rem;
  left: 1rem;
  width: min(338px, calc(100vw - 2rem));
  gap: 0.42rem;
  border: 1px solid rgba(132, 201, 238, 0.38);
  padding: 0.72rem 0.82rem;
  color: #d9ecf8;
  background: linear-gradient(135deg, rgba(4, 15, 25, 0.93), rgba(8, 32, 45, 0.76));
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(8px);
  font-size: 0.73rem;
}

body[data-screen="flight"][data-camera="chase"] #flight-director { display: grid; }
.flight-director-heading,
.flight-director-readouts { display: flex; justify-content: space-between; gap: 0.75rem; }
.flight-director-heading span,
#hud-director-control,
#hud-director-throttle-state { color: #9fb8c8; font-size: 0.72em; font-weight: 800; letter-spacing: 0.13em; }
.flight-director-heading strong { color: var(--cyan); font-size: 0.94em; letter-spacing: 0.12em; }
.flight-director-readouts { color: #b9d1e0; font-family: "Courier New", monospace; font-size: 0.9em; font-weight: 800; }
.takeoff-power-guide,
.takeoff-throttle-meter,
.takeoff-throttle-labels { display: none; }
#flight-director[data-takeoff-power="visible"] .takeoff-power-guide { display: grid; }
#flight-director[data-takeoff-power="visible"] .takeoff-throttle-meter { display: block; }
#flight-director[data-takeoff-power="visible"] .takeoff-throttle-labels { display: flex; }
.takeoff-power-guide {
  grid-template-columns: 3.25rem 1fr auto;
  gap: 0.62rem;
  align-items: center;
  margin: 0.1rem -0.2rem 0;
  border: 1px solid rgba(255, 192, 91, 0.28);
  padding: 0.58rem;
  background: linear-gradient(110deg, rgba(41, 24, 7, 0.78), rgba(8, 27, 38, 0.72));
}
#hud-takeoff-key {
  display: grid;
  width: 3.25rem;
  height: 3.25rem;
  place-items: center;
  border: 1px solid rgba(255, 211, 132, 0.78);
  border-bottom-width: 4px;
  border-radius: 0.28rem;
  color: #171005;
  background: linear-gradient(160deg, #ffe0a2, #d89438);
  box-shadow: 0 0 18px rgba(255, 171, 57, 0.22);
  font: 900 1.42rem/1 "Courier New", monospace;
  transition: transform 80ms ease, border-bottom-width 80ms ease, filter 80ms ease;
}
#hud-takeoff-key[data-state="held"] {
  border-bottom-width: 1px;
  transform: translateY(3px);
  filter: brightness(1.3);
  box-shadow: 0 0 24px rgba(255, 177, 61, 0.64);
}
#hud-takeoff-key[data-state="set"] { color: #061813; background: linear-gradient(160deg, #bcffe1, #4fc99e); }
#hud-takeoff-key[data-state="reducing"] { color: #240a07; background: linear-gradient(160deg, #ffb39f, #dc6248); }
.takeoff-power-copy { display: grid; gap: 0.22rem; min-width: 0; }
#hud-takeoff-action { color: #fff0ce; font-size: 0.84em; letter-spacing: 0.045em; line-height: 1.28; }
#hud-takeoff-explanation { color: #afc5d2; font-size: 0.7em; line-height: 1.35; }
#hud-takeoff-percent { color: #ffd27d; font: 900 1.08em/1 "Courier New", monospace; }
.takeoff-throttle-meter { position: relative; height: 9px; overflow: visible; border: 1px solid rgba(255, 207, 126, 0.34); background: rgba(14, 25, 31, 0.88); }
.takeoff-throttle-meter span { display: block; width: var(--takeoff-throttle, 0%); height: 100%; background: linear-gradient(90deg, #d47d2d, #ffd16f 55%, #7cf3c0); box-shadow: 0 0 12px rgba(255, 185, 74, 0.72); transition: width 90ms linear; }
.takeoff-throttle-meter i { position: absolute; top: -4px; bottom: -4px; left: 55%; width: 2px; background: #fff1ba; box-shadow: 0 0 7px rgba(255, 229, 151, 0.9); }
.takeoff-throttle-labels { justify-content: space-between; margin-top: -0.25rem; color: #7894a4; font: 700 0.58em/1 "Courier New", monospace; letter-spacing: 0.08em; }
.takeoff-throttle-labels span:nth-child(2) { color: #e6bd6a; transform: translateX(22%); }
.flight-director-progress-label { color: #8eb9cd; font: 800 0.68em/1 "Courier New", monospace; letter-spacing: 0.08em; }
.flight-director-meter { height: 4px; overflow: hidden; background: rgba(155, 210, 238, 0.16); }
.flight-director-meter span { display: block; width: var(--director-progress, 0%); height: 100%; background: #73d9ff; box-shadow: 0 0 10px rgba(87, 218, 255, 0.86); transition: width 140ms linear; }
.flight-director-nav { display: grid; gap: 0.18rem; padding-top: 0.46rem; border-top: 1px solid rgba(116, 193, 225, 0.22); font-family: "Courier New", monospace; }
.flight-director-nav strong { color: #d9f4ff; font-size: 0.88em; letter-spacing: 0.04em; }
.flight-director-nav span { color: #82cce9; font-size: 0.78em; }
#hud-director-instruction { color: #f0f8ff; font-size: 0.93em; letter-spacing: 0.04em; }
#hud-director-next { color: #a7d8ee; font-family: "Courier New", monospace; font-size: 0.85em; }
#flight-director[data-state="ready"] { border-color: rgba(255, 193, 108, 0.84); }
#flight-director[data-state="ready"] .flight-director-heading strong,
#flight-director[data-state="ready"] #hud-director-instruction { color: #ffd27b; }
#flight-director.advancing .flight-director-meter span { animation: director-pulse 720ms ease-in-out infinite alternate; }
#flight-director.compact { width: min(286px, calc(100vw - 2rem)); opacity: 0.78; }
#flight-director.compact .flight-director-readouts,
#flight-director.compact .flight-director-progress-label,
#flight-director.compact .flight-director-meter,
#flight-director.compact #hud-director-instruction,
#flight-director.compact #hud-director-next,
#flight-director.compact #hud-director-control,
#flight-director.compact #hud-director-throttle-state { display: none; }

#tutorial-coach {
  position: fixed;
  z-index: 6;
  top: 22rem;
  left: 1rem;
  display: grid;
  gap: 0.45rem;
  width: min(304px, calc(100vw - 2rem));
  padding: 0.8rem 0.9rem;
  border: 1px solid rgba(255, 192, 99, 0.7);
  background: rgba(6, 20, 31, 0.9);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.35), inset 3px 0 #f0b85b;
  opacity: 0;
  transform: translateX(-1rem);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
#tutorial-coach.visible { opacity: 1; transform: translateX(0); pointer-events: auto; }
.coach-kicker { color: var(--amber); font-size: 0.65rem; font-weight: 900; letter-spacing: 0.17em; }
#tutorial-coach-title { color: #f7fbff; font-size: 1.05rem; }
#tutorial-coach-copy { color: #bfd0dc; font-size: 0.83rem; line-height: 1.42; }
#tutorial-coach-control { color: var(--cyan); font-family: "Courier New", monospace; font-weight: 800; letter-spacing: 0.08em; }
#tutorial-coach button { justify-self: start; min-height: 0; padding: 0.42rem 0.66rem; font-size: 0.72rem; }
body:not([data-ground-alert="none"]) #tutorial-coach { opacity: 0; pointer-events: none; }

#mission-radio {
  position: fixed;
  z-index: 7;
  left: 50%;
  bottom: 3.8rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: center;
  width: min(700px, calc(100vw - 2rem));
  padding: 0.75rem 0.9rem;
  border-left: 3px solid var(--cyan);
  background: rgba(4, 17, 28, 0.92);
  color: #d9edf8;
  opacity: 0;
  transform: translate(-50%, 0.8rem);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}
#mission-radio.visible { opacity: 1; transform: translate(-50%, 0); }
#mission-radio > span { color: var(--cyan); font-size: 0.68rem; font-weight: 900; letter-spacing: 0.18em; }
#mission-radio strong { font-size: 0.82rem; font-weight: 650; }
#mission-radio.urgent { border-left-color: #ff735f; background: rgba(58, 9, 8, 0.93); }

.asset-readiness { margin: 0.6rem 0 0; color: #a8bbc7; font-family: "Courier New", monospace; font-size: 0.72rem; }
.asset-readiness.ready { color: #8ee3b0; }
.asset-readiness.error { color: #ff9182; }
.settings-danger-zone { display: flex; align-items: center; gap: 0.85rem; margin: 1rem 0; padding-top: 0.85rem; border-top: 1px solid var(--line); }
.settings-danger-zone span { color: var(--muted); font-size: 0.78rem; }
#setting-reset-progress { color: #ffd0c7; border-color: rgba(255, 115, 95, 0.45); }
.debrief-art { width: 100%; height: min(23vh, 210px); margin: 0.65rem 0; border: 1px solid rgba(135, 193, 220, 0.28); object-fit: cover; object-position: center 56%; filter: saturate(0.9) contrast(1.05); }

@keyframes director-pulse { to { filter: brightness(1.55); } }

@media (max-width: 900px) {
  body { overflow: auto; }
  #screen-layer { align-items: start; padding: 1rem; overflow: auto; }
  .screen { max-height: calc(100vh - 2rem); }
  #screen-title { padding: 1rem 0.25rem; margin-top: 6vh; }
  .mission-cards { grid-template-columns: 1fr; }
  .mission-card { min-height: 145px; }
  .dossier-grid,
  .settings-grid { grid-template-columns: 1fr; }
  #flight-hud {
    grid-template-columns: repeat(4, 1fr);
    min-height: 0;
  }
  .hud-brand { grid-column: 1 / -1; }
  #hud-objective { grid-column: span 2; }
  #hud-camera { display: block; grid-column: span 1; }
  .hud-pause { grid-column: span 1; }
  #cockpit-engine-screen,
  #cockpit-mission-screen { display: none; }
  #cockpit-combiner { left: 31%; width: 38%; }
  .cockpit-combiner-bottom { column-gap: 0.38rem; }
  .cockpit-combiner-bottom span:last-child { display: none; }
  .hud-brand,
  .hud-readout,
  #hud-objective,
  .hud-pause { padding: 0.46rem 0.55rem; }
  .hud-readout strong { font-size: 0.78em; }
  #hud-alert { bottom: 1rem; font-size: 0.75em; }
  #ground-proximity-alert { top: 15rem; width: min(330px, calc(100vw - 1.3rem)); }
  #flight-director { top: 19rem; left: 0.65rem; width: min(310px, calc(100vw - 1.3rem)); padding: 0.58rem 0.64rem; font-size: 0.68rem; }
  body[data-tutorial-coach="active"] #flight-director { top: 21.2rem; }
  #tutorial-coach { top: 10.4rem; left: 0.65rem; width: min(330px, calc(100vw - 1.3rem)); }
  #mission-radio { bottom: 0.7rem; width: calc(100vw - 1.3rem); }
  .settings-danger-zone { align-items: flex-start; flex-direction: column; }
  .credits-screen { align-self: end; margin: auto 0 0; }
}

@media (max-width: 520px) {
  #screen-title h1 { font-size: clamp(2.45rem, 15vw, 3.65rem); letter-spacing: -0.065em; }
  h2 { font-size: 2.05rem; }
  .button-row { display: grid; grid-template-columns: 1fr; }
  .button-row button { width: 100%; }
  .text-actions { flex-wrap: wrap; }
  .screen { padding: 1.1rem; }
  #flight-hud { font-size: 0.83rem; }
  #hud-objective { font-size: 0.58em; }
}
