:root {
  --ink: #050913;
  --steel-0: #0e1628;
  --steel-1: #1c2840;
  --steel-2: #2c3c5c;
  --steel-3: #4b6189;
  --steel-4: #8aa3cc;
  --cyan: #6ff3ff;
  --cyan-dim: #2f8fb0;
  --green: #7dff9a;
  --green-dim: #2c7a48;
  --amber: #ffb84a;
  --red: #ff4a4a;
  --text: #cfe2ff;
  --dash-h: clamp(210px, 34vh, 380px);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #000; color: var(--text);
  font: 500 12px/1.3 var(--mono); user-select: none; -webkit-user-select: none;
}
canvas { display: block; }
button { font: inherit; color: inherit; }

#sky { position: fixed; inset: 0; width: 100vw; height: 100vh; }

/* glass: a faint reflection and a vignette, so the windshield reads as a pane and not a screen */
#glass {
  position: fixed; inset: 0; pointer-events: none;
  background:
    linear-gradient(115deg, transparent 18%, rgba(140, 190, 255, 0.045) 24%, transparent 31%,
      transparent 60%, rgba(140, 190, 255, 0.03) 64%, transparent 69%),
    radial-gradient(ellipse 80% 70% at 50% 36%, transparent 55%, rgba(0, 4, 16, 0.55) 100%);
}
#flash { position: fixed; inset: 0; pointer-events: none; background: #dff6ff; opacity: 0; mix-blend-mode: screen; }

#canopy { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none;
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.6)); }

/* --- top rail ---------------------------------------------------------- */
#rail {
  position: fixed; top: 0; left: 0; right: 0; height: 28px; padding: 0 18px;
  display: flex; align-items: center; gap: 10px; letter-spacing: 0.14em; font-size: 11px;
  color: var(--steel-4); text-shadow: 0 1px 0 #000;
}
#rail b { color: var(--cyan); letter-spacing: 0.2em; }
#rail .grow { flex: 1; }
#rail .sep { width: 1px; height: 12px; background: var(--steel-3); }
#utc { color: var(--cyan); }
.dim { opacity: 0.7; }

.led { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #3a1010;
  box-shadow: inset 0 0 2px #000; flex: none; }
.led.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.led.amber.on { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.led.red.on { background: var(--red); box-shadow: 0 0 6px var(--red); }
.led.cyan.on { background: var(--cyan); box-shadow: 0 0 6px var(--cyan); }

/* --- windshield HUD ----------------------------------------------------- */
#hud {
  position: fixed; left: 50%; top: 52px; transform: translateX(-50%); text-align: center;
  pointer-events: none; color: var(--cyan); text-shadow: 0 0 8px rgba(111, 243, 255, 0.6);
}
#phase { font-size: 13px; letter-spacing: 0.5em; padding-left: 0.5em; }
#target { margin-top: 4px; font-size: 11px; letter-spacing: 0.25em; opacity: 0.75; }

#notes { position: fixed; left: 12vw; top: 64px; display: flex; gap: 10px; pointer-events: none; }

/* --- welcome card (after Belt Nine's title card): a bezelled plate on scan lines over the glass --- */
#welcome {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  padding-bottom: var(--dash-h); background: rgba(2, 4, 10, 0.35); cursor: pointer;
  transition: opacity 0.6s;
}
body.on #welcome { opacity: 0; pointer-events: none; }
#welcome .card {
  width: min(580px, 92vw); color: var(--text); text-align: center;
  background: rgba(6, 10, 20, 0.92);
  background-image: repeating-linear-gradient(to bottom, rgba(140, 170, 220, 0.06) 0 1px, transparent 1px 3px);
  border: 1px solid var(--steel-3);
  box-shadow: 0 0 0 1px #000, 0 0 0 2px rgba(138, 163, 204, 0.25), 0 20px 60px rgba(0, 0, 0, 0.6);
}
#welcome .head { padding: 26px 20px 14px; }
#welcome .title {
  font-size: clamp(18px, min(5.4vw, 6vh), 40px); letter-spacing: 0.42em; padding-left: 0.42em; color: #eef4ff;
  text-shadow: 0 0 14px rgba(160, 200, 255, 0.35);
}
#welcome .sub { margin-top: 8px; font-size: 11px; letter-spacing: 0.22em; color: var(--steel-4); }
#welcome .rows { padding: 0 28px 14px; }
#welcome .row {
  display: flex; align-items: baseline; gap: 8px; width: 100%; padding: 6px 0; border: 0; background: none;
  cursor: pointer; font-size: 12px; letter-spacing: 0.18em;
}
#welcome .row .k { color: var(--steel-4); }
#welcome .row .dots { flex: 1; border-bottom: 1px dotted var(--steel-3); transform: translateY(-3px); }
#welcome .row .v { color: #eef4ff; min-width: 3.2em; text-align: right; }
#welcome .row[aria-pressed="true"] .v { color: var(--green); text-shadow: 0 0 8px rgba(125, 255, 154, 0.6); }
#welcome .row:hover .k, #welcome .row:focus-visible .k { color: var(--text); }
#welcome .go {
  display: block; width: 100%; padding: 16px 0 18px; border: 0; border-top: 2px solid #dfe9ff;
  background: none; cursor: pointer; color: #eef4ff; font-size: 13px; letter-spacing: 0.24em;
  animation: blink 2.2s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { #welcome .go { animation: none; } }

/* --- the dash ----------------------------------------------------------- */
/* #dash spans the window; #dash-in holds the instruments at a design size and is scaled to fit
   (src/cockpit/layout.js sets its width, height and scale, and #dash's height) */
#dash { position: fixed; left: 0; right: 0; bottom: 0; height: var(--dash-h); }
#dash-in {
  position: absolute; left: 50%; bottom: 0; width: 1600px; height: 330px; transform-origin: 50% 100%;
  display: grid; grid-template-columns: minmax(0, 23fr) minmax(0, 54fr) minmax(0, 23fr); grid-template-rows: minmax(0, 1fr);
  gap: 0; perspective: 1100px; perspective-origin: 50% -40%;
}
/* the coaming: the lip the dash wears under the windshield */
#dash::before {
  content: ""; position: absolute; left: -2%; right: -2%; top: -16px; height: 30px; border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  background: linear-gradient(#5d76a3, #2a3a5a 40%, #121b2e);
  box-shadow: 0 -2px 0 rgba(170, 205, 255, 0.35), 0 8px 20px rgba(0, 0, 0, 0.7);
}
#dash::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(#18233a, #0b1222 60%, #050912);
}

.wing, .console { position: relative; padding: 18px 12px 10px; display: flex; gap: 8px; min-width: 0; }
.wing { flex-direction: column; transform-style: preserve-3d; overflow: hidden; }
.wing > .plate { flex: 0 1 auto; min-height: 0; }
/* angled toward the pilot, and pushed back so the near edge doesn't swell past the dash */
.wing.left { transform: translateZ(-70px) rotateY(11deg); transform-origin: 100% 50%; padding-left: 26px; }
.wing.right { transform: translateZ(-70px) rotateY(-11deg); transform-origin: 0% 50%; padding-right: 26px; }
.console { transform: rotateX(14deg); transform-origin: 50% 100%; gap: 10px; padding-top: 22px; }

.plate {
  position: relative; border-radius: 6px; padding: 8px;
  background: linear-gradient(160deg, var(--steel-3), var(--steel-2) 18%, var(--steel-1) 70%, var(--steel-0));
  box-shadow: inset 0 1px 0 rgba(200, 220, 255, 0.35), inset 0 -2px 4px rgba(0, 0, 0, 0.6), 0 3px 8px rgba(0, 0, 0, 0.6);
}
.plate::before, .plate::after {
  content: ""; position: absolute; width: 5px; height: 5px; border-radius: 50%; top: 4px;
  background: radial-gradient(circle at 35% 35%, #9bb0d6, #2a3654 70%);
}
.plate::before { left: 4px; } .plate::after { right: 4px; }
.row { display: flex; gap: 8px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.tight { padding: 6px 10px; }

.gauges { display: flex; justify-content: space-around; align-items: center; gap: 4px; }
.dial { width: 30%; max-width: 92px; aspect-ratio: 1; }
.dial.small { width: 24%; }

.screen {
  position: relative; background: radial-gradient(ellipse at 50% 40%, #0a2238, #030a14 75%);
  border-radius: 6px; overflow: hidden;
  box-shadow: inset 0 0 0 2px #0b1426, inset 0 0 18px rgba(80, 200, 255, 0.18), 0 0 0 3px #3b4e72, 0 0 0 4px #121a2b,
    0 0 22px rgba(70, 180, 255, 0.18);
}
.screen::after { /* scan lines */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 3px);
}
.screen.round { border-radius: 50%; width: 38%; max-width: 104px; aspect-ratio: 1; flex: none; }

.console > .screen { flex: 1; display: flex; overflow: hidden; flex-direction: column; padding: 8px 10px; min-width: 0; }
.console > .term { flex: 1.25; background: #020805; box-shadow: inset 0 0 0 2px #0b1426, inset 0 0 22px rgba(120, 255, 160, 0.12),
  0 0 0 3px #3b4e72, 0 0 0 4px #121a2b, 0 0 22px rgba(120, 255, 160, 0.12); }

.title, .bar { display: flex; justify-content: space-between; align-items: center; letter-spacing: 0.2em;
  font-size: 10px; color: var(--cyan-dim); margin-bottom: 4px; }
.title .hl { color: var(--cyan); text-shadow: 0 0 6px rgba(111, 243, 255, 0.6); letter-spacing: 0.12em; }
.bar { background: var(--green); color: #031; padding: 1px 6px; margin: -2px -4px 4px; letter-spacing: 0.1em; font-weight: 700; }

.cv { position: relative; flex: 1; min-height: 0; }
.cv canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#spectrum-box { flex: 1.1; }
#scope-box { flex: 0.6; }

.readout { display: grid; grid-template-columns: auto 1fr; gap: 1px 8px; margin: 4px 0 0; font-size: 10.5px; }
.readout dt { color: var(--cyan-dim); letter-spacing: 0.12em; }
.readout dd { margin: 0; color: var(--cyan); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 0 5px rgba(111, 243, 255, 0.5); }

#log { flex: 1; margin: 0; color: var(--green); font-size: 10.5px; line-height: 1.35; overflow: hidden; white-space: pre;
  text-shadow: 0 0 4px rgba(125, 255, 154, 0.45); display: flex; flex-direction: column; justify-content: flex-end; }
#log .hi { background: rgba(125, 255, 154, 0.85); color: #031; text-shadow: none; }
#log .dim { color: var(--green-dim); opacity: 1; }
#log .cy { color: var(--cyan); }
#log .am { color: var(--amber); }

.vol { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 10px; letter-spacing: 0.2em; color: var(--cyan-dim); }
.vol input { flex: 1; accent-color: var(--cyan); height: 10px; }

.keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; flex: 1; }
.key {
  height: 16px; border-radius: 3px; border: 0; cursor: pointer; font-size: 8px; letter-spacing: 0.05em; color: #9fb4d8;
  background: linear-gradient(#3d5078, #1f2b45); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 0 #000;
  display: flex; align-items: center; justify-content: center; gap: 3px; padding: 0;
}
.key:active { transform: translateY(1px); }
.key .led { width: 4px; height: 4px; }

.bigred {
  width: 42px; height: 42px; border-radius: 50%; border: 3px solid #4b1d1d; cursor: pointer; flex: none;
  background: radial-gradient(circle at 40% 35%, #ff8a7a, #d42020 45%, #6a0b0b); color: #ffe6e0; font-weight: 800;
  font-size: 10px; letter-spacing: 0.1em; box-shadow: 0 0 0 3px #1a2236, 0 4px 10px rgba(0, 0, 0, 0.7), 0 0 18px rgba(255, 60, 60, 0.4);
}
.bigred:active { transform: scale(0.96); }
body.on .bigred { box-shadow: 0 0 0 3px #1a2236, 0 4px 10px rgba(0, 0, 0, 0.7), 0 0 28px rgba(255, 60, 60, 0.85); }

.switches { display: flex; gap: 8px; flex: 1; justify-content: space-around; }
.switch { width: 14px; height: 28px; border-radius: 3px; background: #0b111e; border: 0; padding: 0; cursor: pointer; position: relative;
  box-shadow: inset 0 0 0 1px #3b4e72; }
.switch::after { content: ""; position: absolute; left: 3px; right: 3px; height: 12px; top: 3px; border-radius: 2px;
  background: linear-gradient(#c7d6f2, #60769f); transition: top 0.12s; }
.switch.on::after { top: 11px; }
.switch + .led { margin-top: 3px; }
.sw { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 7px; color: #8aa3cc; letter-spacing: 0.1em; }

.seg { font-family: var(--mono); background: #0a0f08; color: #ff5b4a; padding: 2px 6px; border-radius: 3px; font-size: 12px;
  letter-spacing: 0.12em; text-shadow: 0 0 6px rgba(255, 90, 70, 0.8); box-shadow: inset 0 0 0 1px #2c3c5c; white-space: nowrap; overflow: hidden; }
.seg.amber { color: var(--amber); text-shadow: 0 0 6px rgba(255, 184, 74, 0.8); }

.wing > .comms { flex: 1 1 auto; }
.comms { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.comms .title { color: #9fb4d8; }
#comms { flex: 1; border-radius: 4px; background: #060b16; color: #6c84ad; padding: 6px 8px; font-size: 10.5px;
  box-shadow: inset 0 0 0 1px #2c3c5c; overflow: hidden; }

.meters { display: flex; gap: 3px; align-items: flex-end; height: 34px; flex: 1; }
.meters i { flex: 1; background: linear-gradient(to top, var(--green), var(--amber) 70%, var(--red)); border-radius: 1px;
  transform-origin: bottom; opacity: 0.9; }
.chip { width: 34px; height: 34px; border-radius: 6px; border: 0; cursor: pointer; font-size: 18px; color: var(--cyan);
  background: linear-gradient(#2c3c5c, #121a2b); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 2px 4px #000; }

/* --- tall windows: the console on top, the two wings side by side under it ------------------ */
#dash-in.stack { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  perspective-origin: 50% -20%; }
.stack > .console { grid-column: 1 / -1; grid-row: 1; transform: rotateX(8deg); }
.stack > .wing { grid-row: 2; transform: none; padding: 14px 10px 10px; }
.stack > .wing.left { grid-column: 1; padding-left: 14px; }
.stack > .wing.right { grid-column: 2; padding-right: 14px; }

@media (max-width: 900px) { #notes { left: 18px; } }
@media (max-width: 560px) {
  #rail .dim, #rail .sep { display: none; }
}
