:root {
  --bg: #070b16;
  --glass: rgba(10, 16, 32, 0.58);
  --glass-strong: rgba(10, 16, 32, 0.82);
  --line: rgba(190, 205, 235, 0.14);
  --line-strong: rgba(190, 205, 235, 0.3);
  --text: #eef0f5;
  --dim: rgba(222, 228, 240, 0.62);
  --faint: rgba(222, 228, 240, 0.38);
  --accent: #f3b34c;
  --accent-rgb: 243, 179, 76;
  --blue: #6fa8ff;
  --cyan: #59e3ff;
  --red: #ff4d4d;
  --amber: #ffb02e;
  --green: #4be38a;
  --mono: 'B612 Mono', ui-monospace, monospace;
  --ui: 'Inter', system-ui, sans-serif;
  --r: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--ui); font-size: 13px; -webkit-font-smoothing: antialiased; }
#app, #app canvas { position: fixed; inset: 0; display: block; }
#hud { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
.mono { font-family: var(--mono); }
kbd { font-family: var(--mono); font-size: 10px; color: var(--faint); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 6px; line-height: 15px; display: inline-block; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.glass { background: var(--glass); border: 1px solid var(--line); border-radius: var(--r); backdrop-filter: blur(14px) saturate(130%); -webkit-backdrop-filter: blur(14px) saturate(130%); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); }
.gt { font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--faint); margin: 2px 4px 6px; }
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#ui > * { pointer-events: auto; }

/* brand */
#brand { position: absolute; top: 16px; left: 18px; pointer-events: none; }
#brand .mark { font-family: 'B612', var(--ui); font-weight: 700; letter-spacing: 0.42em; font-size: 20px; text-shadow: 0 2px 18px rgba(0, 0, 0, 0.45); }
#brand .sub { color: var(--dim); font-size: 11px; letter-spacing: 0.04em; margin-top: 3px; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5); }

/* status / alerts */
#status { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
#statusText { background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 11px; letter-spacing: 0.08em; backdrop-filter: blur(12px); white-space: nowrap; }
#alerts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; max-width: 60vw; }
.alert { font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; padding: 4px 10px; border-radius: 6px; }
.alert.w { background: rgba(255, 60, 60, 0.92); color: #fff; animation: blink 0.9s steps(2) infinite; }
.alert.c { background: rgba(255, 176, 46, 0.9); color: #1b1203; }
.alert.i { background: rgba(80, 160, 255, 0.85); color: #fff; }
@keyframes blink { 50% { opacity: 0.55; } }

/* top right */
#topRight { position: absolute; top: 14px; right: 16px; display: flex; gap: 8px; }
.icon { width: 36px; height: 36px; display: grid; place-items: center; color: var(--dim); font-weight: 600; }
.icon svg { width: 18px; height: 18px; }
.icon:hover, .chip:hover { color: var(--text); border-color: var(--line-strong); }
.icon.muted .wave { opacity: 0.15; }
.chip { height: 36px; padding: 0 12px; color: var(--dim); display: flex; align-items: center; font-weight: 500; }
.chip.on { color: #1a1205; background: rgba(var(--accent-rgb), 0.92); border-color: transparent; }
.chip.on kbd { color: rgba(0, 0, 0, 0.55); border-color: rgba(0, 0, 0, 0.25); }

/* left rail */
#rail { position: absolute; left: 16px; top: 78px; display: flex; flex-direction: column; gap: 10px; width: 168px; }
.group { padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.group button { display: flex; justify-content: space-between; align-items: center; padding: 7px 9px; border-radius: 7px; color: var(--dim); text-align: left; font-weight: 500; }
.group button:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.group button.on { background: rgba(var(--accent-rgb), 0.16); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }

/* flight data */
/* right column: flight data with the systems panel stacked under it, so systems always starts below the flight panel
   however tall that grows (the take-off director is kept narrower than the gap between the side columns); on very
   short windows the systems panel scrolls instead of running off the bottom */
#rcol { position: absolute; right: 16px; top: 64px; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; max-height: calc(100vh - 80px); }
#flight { flex: none; width: 300px; padding: 10px 12px 12px; }
.ftop { display: flex; justify-content: space-between; font-size: 11px; letter-spacing: 0.06em; color: var(--accent); margin-bottom: 8px; }
#fAp { color: var(--green); }
.fgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 10px; }
.fgrid div { display: flex; flex-direction: column; }
.fgrid label { font-size: 9px; letter-spacing: 0.16em; color: var(--faint); }
.fgrid b { font-size: 17px; font-weight: 700; line-height: 1.2; }
.fgrid i { font-style: normal; font-size: 9px; color: var(--faint); }
.bars { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.bar { display: grid; grid-template-columns: 40px 1fr 44px 12px; align-items: center; gap: 8px; }
.bar label { font-size: 9px; letter-spacing: 0.16em; color: var(--faint); }
.bar b { text-align: right; font-size: 13px; }
.bar i { font-style: normal; font-size: 9px; color: var(--faint); }
.track { position: relative; height: 6px; background: rgba(255, 255, 255, 0.08); border-radius: 4px; overflow: hidden; }
.track > div { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #58d1ff, #6f8bff); border-radius: 4px; }
.track.cg > #fCgBar { width: 3px; left: 50%; background: var(--accent); }
.track.cg > #fCgTgt { width: 9px; left: 50%; background: rgba(75, 227, 138, 0.35); border-radius: 2px; }
.therm { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 10px; color: var(--dim); }
.therm b { color: var(--text); }

/* systems */
#systems { width: 300px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; min-height: 0; overflow-y: auto; }
.srow { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 28px; color: var(--dim); }
.srow > span { white-space: nowrap; }
.seg { display: flex; background: rgba(255, 255, 255, 0.05); border-radius: 7px; padding: 2px; }
.seg button { padding: 4px 8px; border-radius: 5px; font-family: var(--mono); font-size: 11px; color: var(--dim); white-space: nowrap; }
.seg button.on { background: rgba(var(--accent-rgb), 0.92); color: #1a1205; font-weight: 700; }
#rateSeg button { padding: 4px 5px; }   /* six sim rates (1×–32×) fit the systems panel */
.tog { font-family: var(--mono); font-size: 11px; font-weight: 700; padding: 5px 10px; border-radius: 6px; border: 1px solid var(--line-strong); color: var(--dim); min-width: 64px; }
.tog.on { background: rgba(75, 227, 138, 0.18); border-color: rgba(75, 227, 138, 0.55); color: var(--green); }
.tog.hot { background: rgba(255, 120, 40, 0.22); border-color: rgba(255, 140, 60, 0.7); color: #ffb072; }
.tog.small { min-width: 0; padding: 4px 8px; }
.eng { display: flex; gap: 4px; margin-left: auto; }
.eng span { width: 26px; text-align: center; font-family: var(--mono); font-size: 10px; padding: 3px 0; border-radius: 4px; background: rgba(255, 255, 255, 0.06); color: var(--faint); }
.eng span.run { background: rgba(75, 227, 138, 0.2); color: var(--green); }
.eng span.rh { background: rgba(255, 120, 40, 0.3); color: #ffc08a; }
.eng span.st { background: rgba(80, 160, 255, 0.25); color: #a9ccff; }

/* director */
#director { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(820px, calc(100vw - 652px)); padding: 10px 12px; }
.vbugs { display: flex; gap: 16px; font-size: 11px; color: var(--dim); letter-spacing: 0.05em; margin-bottom: 8px; }
.vbugs b { color: var(--accent); font-size: 13px; }
.vbugs .dist { margin-left: auto; }
#steps { display: flex; gap: 4px; overflow: hidden; }
.step { flex: 1; min-width: 0; padding: 6px 7px; border-radius: 6px; background: rgba(255, 255, 255, 0.04); color: var(--faint); font-size: 10.5px; line-height: 1.25; border: 1px solid transparent; }
.step.active { color: var(--text); background: rgba(var(--accent-rgb), 0.18); border-color: rgba(var(--accent-rgb), 0.6); }
.step.done { color: var(--green); background: rgba(75, 227, 138, 0.08); }
.step.rto { color: #fff; background: rgba(255, 60, 60, 0.6); }
.dbtns { display: flex; gap: 8px; margin-top: 9px; }
.cta { padding: 7px 12px; border-radius: 7px; font-weight: 600; background: rgba(var(--accent-rgb), 0.92); color: #1a1205; display: inline-flex; align-items: center; }
.cta kbd { color: rgba(0, 0, 0, 0.5); border-color: rgba(0, 0, 0, 0.25); }
.cta.alt { background: rgba(111, 168, 255, 0.9); color: #06142d; }
.cta.ghost { background: rgba(255, 255, 255, 0.06); color: var(--dim); }
.cta.land { background: rgba(75, 227, 138, 0.85); color: #04210f; }
.cta.land kbd { color: rgba(0, 0, 0, 0.5); border-color: rgba(0, 0, 0, 0.25); }
.cta.ghost kbd { color: var(--faint); border-color: var(--line); }
.cta.active { box-shadow: 0 0 0 2px rgba(75, 227, 138, 0.8); }

/* help / settings */
#help { position: absolute; left: 16px; bottom: 16px; width: 340px; padding: 10px 12px; display: none; }
#help.show { display: block; }
.keys div { display: flex; align-items: center; gap: 4px; padding: 3px 0; color: var(--dim); }
.keys kbd { margin-left: 0; color: var(--text); }
.keys span { margin-left: 6px; }
.muted { color: var(--faint); }
#settings { position: absolute; right: 16px; top: 58px; width: 330px; padding: 10px 12px; display: none; z-index: 6; }
#settings.show { display: block; }
.scols { display: flex; flex-direction: column; gap: 10px; }
.scol { display: flex; flex-direction: column; gap: 6px; flex: 1 1 0; min-width: 0; }
.ssub { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); margin: 0 2px; }
/* the open panel sits over the flight-data panel: hide it rather than leave its lower rows peeking out underneath */
body:has(#settings.show) #flight { visibility: hidden; }
/* wide screens: two columns, so the open panel ends above the systems panel (top 330 px) instead of cutting through it */
@media (min-width: 1181px) {
  #settings { width: 656px; }
  .scols { flex-direction: row; gap: 20px; }
}

/* legend (x-ray / exploded) */
#legend { position: absolute; left: 196px; bottom: 16px; padding: 8px 12px; display: none; gap: 14px; flex-wrap: wrap; max-width: 520px; }
#legend.show { display: flex; }
#legend span { display: flex; align-items: center; gap: 6px; color: var(--dim); font-size: 11px; }
#legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* exploded / machine labels */
.plabel { position: absolute; left: 0; top: 0; font-size: 11px; color: var(--text); white-space: nowrap; padding: 3px 8px; border-radius: 5px; background: rgba(8, 12, 24, 0.72); border: 1px solid var(--line); transition: opacity 0.3s; pointer-events: none; }
.plabel::before { content: ''; position: absolute; left: -5px; top: 50%; width: 5px; height: 5px; margin-top: -3px; border-radius: 50%; background: var(--accent); }
.plabel.sel { border-color: var(--accent); background: rgba(40, 28, 6, 0.85); }

/* machine panel */
#machinePanel { position: absolute; right: 16px; top: 64px; bottom: 16px; width: 380px; padding: 12px 14px; display: none; overflow-y: auto; }
#machinePanel.show { display: block; }
#machinePanel h2 { font-family: 'B612', var(--ui); font-size: 15px; letter-spacing: 0.12em; margin: 0 0 2px; }
#machinePanel .msub { color: var(--dim); font-size: 11px; margin-bottom: 10px; }
.mparts { display: flex; flex-direction: column; gap: 3px; margin: 8px 0 10px; }
.mparts button { text-align: left; padding: 6px 8px; border-radius: 6px; color: var(--dim); display: flex; gap: 8px; align-items: baseline; }
.mparts button b { font-family: var(--mono); font-size: 10px; color: var(--faint); width: 18px; }
.mparts button.on { background: rgba(var(--accent-rgb), 0.16); color: var(--text); }
.mnote { font-size: 12px; line-height: 1.5; color: var(--text); background: rgba(255, 255, 255, 0.04); border-radius: 8px; padding: 9px 10px; margin-bottom: 10px; }
.mnote em { color: var(--accent); font-style: normal; }
.mctl { display: grid; grid-template-columns: 70px 1fr 54px; gap: 6px 8px; align-items: center; font-size: 11px; color: var(--dim); margin-bottom: 8px; }
.mctl input[type=range] { width: 100%; accent-color: var(--accent); }
.mctl b { font-family: var(--mono); color: var(--text); text-align: right; }
table.st { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 10.5px; }
table.st th { text-align: right; color: var(--faint); font-weight: 400; padding: 2px 4px; }
table.st th:first-child, table.st td:first-child { text-align: left; }
table.st td { text-align: right; padding: 3px 4px; border-top: 1px solid var(--line); }
.mkpi { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
.mkpi div { background: rgba(255, 255, 255, 0.04); border-radius: 7px; padding: 6px 8px; }
.mkpi label { display: block; font-size: 9px; letter-spacing: 0.14em; color: var(--faint); }
.mkpi b { font-family: var(--mono); font-size: 15px; }

/* tach overlay */
#tach { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); width: min(760px, 70vw); height: auto; z-index: 6; display: none; border-radius: 14px; pointer-events: none; }
#tach.show { display: block; }

/* call-out & toast */
#callout { position: fixed; left: 50%; top: 58%; transform: translate(-50%, -50%); font-family: 'B612', var(--ui); font-weight: 700; font-size: 34px; letter-spacing: 0.2em; color: var(--accent); text-shadow: 0 4px 24px rgba(0, 0, 0, 0.6); opacity: 0; transition: opacity 0.25s; pointer-events: none; z-index: 6; }
#callout.show { opacity: 1; }
#toast { position: absolute; left: 50%; bottom: 152px; transform: translateX(-50%); background: var(--glass-strong); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font-size: 12px; opacity: 0; transition: opacity 0.3s; pointer-events: none; white-space: nowrap; }
#toast.show { opacity: 1; }
#pauseBadge { position: absolute; left: 50%; top: 84px; transform: translateX(-50%); padding: 5px 12px; border-radius: 6px; background: rgba(80, 160, 255, 0.85); font-size: 11px; letter-spacing: 0.2em; display: none; }
#pauseBadge.show { display: block; }

/* crash */
#crash { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%); padding: 18px 22px; z-index: 8; display: none; text-align: center; min-width: 320px; }
#crash.show { display: block; }
#crash .ct { font-family: 'B612', var(--ui); font-weight: 700; letter-spacing: 0.2em; color: var(--red); margin-bottom: 8px; }
#crashMsg { color: var(--dim); margin-bottom: 14px; }

/* loader */
#loader { position: fixed; inset: 0; z-index: 10; background: radial-gradient(ellipse at 50% 40%, #121b33 0%, #05070d 70%); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; transition: opacity 0.8s; }
#loader.hide { opacity: 0; pointer-events: none; }
.lmark { font-family: 'B612', var(--ui); font-weight: 700; font-size: 30px; letter-spacing: 0.6em; padding-left: 0.6em; }
.lbar { width: 260px; height: 2px; background: rgba(255, 255, 255, 0.1); border-radius: 2px; overflow: hidden; }
#lprog { height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
#lmsg { font-size: 11px; color: var(--dim); letter-spacing: 0.12em; }

/* modes: hide flight panels while inspecting */
body.inspect #director, body.inspect #systems { display: none; }
body.machine #flight, body.machine #systems, body.machine #director, body.machine #rail .group:first-child { display: none; }
body.cockpit #brand .sub { opacity: 0.4; }

@media (max-width: 1180px) {
  #director { width: calc(100vw - 32px); bottom: 12px; }
  #systems { display: none; }
  #flight { width: 260px; }
  .fgrid b { font-size: 15px; }
  #toast { bottom: 170px; }
}
@media (max-width: 760px) {
  #rail { top: auto; bottom: 200px; width: auto; flex-direction: row; left: 12px; right: 12px; }
  #rail .group { flex-direction: row; flex-wrap: wrap; flex: 1; }
  #rail .gt { display: none; }
  #rail kbd { display: none; }
  #flight { top: auto; left: 12px; right: 12px; width: auto; bottom: 300px; display: none; }
  #brand .sub, #status #statusText { display: none; }
  #steps .step:not(.active) { display: none; }
  .dbtns { flex-wrap: wrap; }
  #tach { width: 94vw; }
  #machinePanel { left: 12px; right: 12px; width: auto; top: auto; height: 46vh; }
}
