/* Solvd Space Command — dark 32-bit pixel skin (Celeste / Hades mood) */
:root {
  --bg: #07040f;
  --panel: #120b22;
  --panel-2: #1b1233;
  --border: #3a2a5c;
  --edge: #5b4690;
  --text: #efe6ff;
  --muted: #9b8cc4;
  --accent: #4fe3c1;   /* teal */
  --ember: #ff7a3d;
  --hot: #ff4f8b;      /* rose */
  --danger: #ff4060;
  --warning: #ff9f1c;
  --good: #4fe3c1;
  --energy: #ffcc5c;   /* gold */
  --violet: #9a5ad6;
  --font: "Pixelify Sans", ui-monospace, monospace;
  --notch: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
  --notch-sm: polygon(5px 0, calc(100% - 5px) 0, 100% 5px, 100% calc(100% - 5px), calc(100% - 5px) 100%, 5px 100%, 0 calc(100% - 5px), 0 5px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.35 var(--font);
}
body {
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(154, 90, 214, 0.18), transparent 60%),
    radial-gradient(900px 500px at 100% 110%, rgba(79, 227, 193, 0.1), transparent 60%),
    var(--bg);
}
/* Very light scanlines — a hint of CRT, not a filter. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.12) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}

h1, h2, h3 { margin: 0; font-family: var(--font); }
h3 { font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }

@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0.25; } }
@keyframes rise { 0% { transform: translateY(12px); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes pop { 0% { transform: scale(0.7); opacity: 0; filter: blur(4px); } 70% { transform: scale(1.04); opacity: 1; filter: none; } 100% { transform: scale(1); } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.blink { animation: blink 1.2s steps(2) infinite; }

button {
  font: 600 14px/1.2 var(--font);
  letter-spacing: 0.04em;
  color: var(--text);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 2px solid var(--edge);
  border-radius: 0;
  clip-path: var(--notch-sm);
  padding: 12px 16px;
  min-height: 44px;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.06), inset 0 -3px 0 rgba(0, 0, 0, 0.35);
  transition: color 0.12s, border-color 0.12s, background 0.12s, transform 0.06s;
}
button:hover { border-color: var(--accent); color: #fff; background: linear-gradient(180deg, #23183f, var(--panel)); }
button:active { transform: translateY(2px); box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.4); }
button.primary {
  color: #1a0c05;
  background: linear-gradient(180deg, #ffd98a, var(--energy) 45%, #e9a83a);
  border-color: #fff1c9;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6), inset 0 -3px 0 rgba(120, 60, 0, 0.35), 0 0 24px rgba(255, 204, 92, 0.25);
}
button.primary:hover { color: #1a0c05; background: linear-gradient(180deg, #ffe7ad, #ffd36e 45%, #f0b44a); }
button.ghost { background: rgba(18, 11, 34, 0.6); }
button.small { padding: 8px 12px; min-height: 36px; font-size: 12px; }

input {
  font: 500 24px/1 var(--font);
  color: var(--energy);
  background: #0b0717;
  border: 2px solid var(--border);
  border-radius: 0;
  clip-path: var(--notch-sm);
  padding: 10px 12px;
  outline: none;
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.4);
}
input:focus { border-color: var(--accent); }

/* ---------- Lobby ---------- */
.lobby {
  max-width: 600px;
  margin: 0 auto;
  padding: 22px 16px 56px;
  display: grid;
  gap: 18px;
}
.back-link { justify-self: start; font-weight: 600; font-size: 14px; color: var(--muted); text-decoration: none; padding: 8px 0; letter-spacing: 0.04em; }
.back-link:hover { color: var(--accent); }
.lobby-header { display: grid; gap: 12px; text-align: center; padding: 22px 0 8px; animation: rise 0.6s ease-out both; }
.lobby-header h1 {
  font-size: clamp(36px, 10vw, 60px);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.01em;
  color: var(--text);
  text-shadow: 0 3px 0 #3a1a55, 0 0 32px rgba(154, 90, 214, 0.55);
}
.lobby-header h1 span {
  display: block;
  margin-bottom: 8px;
  font-size: 0.32em;
  font-weight: 600;
  letter-spacing: 0.5em;
  color: var(--accent);
  text-shadow: 0 0 14px rgba(79, 227, 193, 0.6);
}
.tagline { color: var(--muted); margin: 0; font-size: 18px; text-wrap: pretty; }
.press-start { font-size: 13px; font-weight: 600; letter-spacing: 0.3em; text-transform: uppercase; color: var(--energy); text-shadow: 0 0 12px rgba(255, 204, 92, 0.5); }
.card {
  position: relative;
  background: linear-gradient(180deg, rgba(27, 18, 51, 0.92), rgba(18, 11, 34, 0.92));
  border: 2px solid var(--border);
  clip-path: var(--notch);
  padding: 18px;
  display: grid;
  gap: 14px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.04);
  animation: rise 0.6s 0.1s ease-out both;
}
.card h2 { font-size: 15px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.card p { margin: 0; color: var(--muted); }
.field { display: grid; gap: 6px; }
.field span { font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
#code { text-transform: uppercase; letter-spacing: 0.35em; font-size: 36px; max-width: 12rem; text-align: center; }
.station-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.station-picker button { display: grid; text-align: left; gap: 4px; padding: 14px; }
.station-picker strong { font-size: 16px; font-weight: 700; color: var(--energy); }
.station-picker small { font-size: 14px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.station-picker button:hover strong { color: var(--accent); }
.error { color: var(--danger); min-height: 1.2em; margin: 0; }
.primary-link {
  display: block; text-align: center; text-decoration: none;
  font-weight: 600; font-size: 14px;
  color: #1a0c05; background: linear-gradient(180deg, #ffd98a, var(--energy) 45%, #e9a83a);
  border: 2px solid #fff1c9; clip-path: var(--notch-sm); padding: 14px;
}

/* ---------- Station layout ---------- */
.station { height: 100dvh; display: flex; flex-direction: column; }
.station-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
  background: linear-gradient(180deg, #1b1233, #120b22);
  flex-wrap: wrap;
}
.station-header h1 { font-size: 18px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text); text-shadow: 0 0 14px rgba(154, 90, 214, 0.6); }
.code-chip { font-size: 12px; font-weight: 600; letter-spacing: 0.14em; color: var(--accent); border: 2px solid rgba(79, 227, 193, 0.5); clip-path: var(--notch-sm); padding: 4px 10px; text-transform: uppercase; }
.connection { color: var(--warning); font-size: 14px; margin-left: auto; animation: blink 1.2s steps(2) infinite; }
.station-header .header-buttons { margin-left: auto; display: flex; gap: 8px; }
.connection:not(:empty) + .header-buttons { margin-left: 0; }
.station-header button { min-height: 36px; padding: 6px 12px; font-size: 12px; }
.sound-toggle.on { border-color: var(--accent); color: var(--accent); }

.station-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
}
.radar-wrap { position: relative; min-height: 0; background: var(--bg); }
canvas.radar { display: block; touch-action: none; image-rendering: pixelated; }
.radar-wrap canvas.radar { position: absolute; inset: 10px; width: calc(100% - 20px); height: calc(100% - 20px); }
.panel {
  border-left: 2px solid var(--border);
  background: linear-gradient(180deg, rgba(27, 18, 51, 0.6), rgba(12, 8, 24, 0.9));
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}
.hint { color: var(--muted); font-size: 14px; margin: 0; line-height: 1.35; }
.muted { color: var(--muted); margin: 0; }

.readout-row { display: flex; gap: 8px; }
.readout { flex: 1; background: #0b0717; border: 2px solid var(--border); clip-path: var(--notch-sm); padding: 8px 10px; min-width: 0; box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.35); }
.readout-label { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.readout-value { display: block; font-size: 24px; font-weight: 600; line-height: 1.1; color: var(--energy); text-shadow: 0 0 10px rgba(255, 204, 92, 0.35); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Segmented meters with a glow. */
.bar { display: grid; grid-template-columns: 7rem 1fr 3.4rem; align-items: center; gap: 10px; }
.bar-label { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.bar-track { position: relative; height: 14px; background: #0b0717; border: 2px solid var(--border); clip-path: var(--notch-sm); overflow: hidden; padding: 2px; }
.bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  -webkit-mask: repeating-linear-gradient(90deg, #000 0 6px, transparent 6px 8px);
          mask: repeating-linear-gradient(90deg, #000 0 6px, transparent 6px 8px);
  transition: width 0.25s steps(4);
  filter: drop-shadow(0 0 4px currentColor);
}
.bar-value { text-align: right; font-size: 15px; font-weight: 600; color: var(--text); }
.bar.hull .bar-fill { background: linear-gradient(90deg, #ff4060, #ffcc5c 45%, #4fe3c1 85%); color: #4fe3c1; }
.bar.shield .bar-fill { background: linear-gradient(90deg, #2f8fd0, #8fd3ff); color: #8fd3ff; }
.bar.energy .bar-fill { background: linear-gradient(90deg, #e9a83a, #ffe7ad); color: var(--energy); }
.bar.heat .bar-fill { background: linear-gradient(90deg, var(--ember), var(--danger)); color: var(--danger); }
.bar.charge .bar-fill { background: linear-gradient(90deg, var(--violet), var(--hot)); color: var(--hot); }

.control { display: grid; gap: 6px; }
.control-label { display: flex; justify-content: space-between; align-items: center; font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.slider-value { font-size: 18px; font-weight: 600; letter-spacing: 0; color: var(--energy); }
.slider { -webkit-appearance: none; appearance: none; width: 100%; padding: 0; height: 36px; background: transparent; border: 0; clip-path: none; box-shadow: none; }
.slider::-webkit-slider-runnable-track { height: 10px; background: linear-gradient(90deg, #1b1233, #2a1d4a); border: 2px solid var(--border); }
.slider::-moz-range-track { height: 6px; background: #1b1233; border: 2px solid var(--border); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 28px; margin-top: -11px; background: linear-gradient(180deg, #ffe7ad, var(--energy)); border: 2px solid #fff1c9; border-radius: 0; box-shadow: 0 0 12px rgba(255, 204, 92, 0.5); }
.slider::-moz-range-thumb { width: 14px; height: 24px; background: var(--energy); border: 2px solid #fff1c9; border-radius: 0; }
.slider.coolant::-webkit-slider-thumb { background: linear-gradient(180deg, #b8fff0, var(--accent)); border-color: #e0fff8; box-shadow: 0 0 12px rgba(79, 227, 193, 0.5); }
.slider.coolant::-moz-range-thumb { background: var(--accent); }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }
.button-row button { flex: 1; }

/* ---------- Weapons ---------- */
.toggle { font-size: 15px; font-weight: 700; letter-spacing: 0.08em; border-color: var(--danger); color: var(--danger); background: linear-gradient(180deg, #2a0b18, #160612); }
.toggle.on { border-color: #b8fff0; color: #04140f; background: linear-gradient(180deg, #b8fff0, var(--accent)); box-shadow: 0 0 24px rgba(79, 227, 193, 0.35); }
.beam-bars { display: grid; gap: 8px; }
.contacts { display: grid; gap: 6px; }
.contact { display: flex; justify-content: space-between; padding: 10px 12px; }
.contact-range { font-weight: 500; color: var(--muted); }
.contact.active { border-color: var(--energy); color: var(--energy); background: linear-gradient(180deg, #2a1f08, #160f05); }
.contact.active .contact-range { color: var(--energy); }

/* ---------- Engineering ---------- */
.station-engineering { display: flex; flex-direction: column; overflow-y: auto; padding: 16px; gap: 16px; }
.engineering-top { display: grid; grid-template-columns: minmax(0, 2fr) 1fr 1fr auto; gap: 12px; align-items: center; }
.systems { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.system {
  background: linear-gradient(180deg, rgba(27, 18, 51, 0.92), rgba(14, 9, 27, 0.92));
  border: 2px solid var(--border);
  clip-path: var(--notch);
  padding: 14px;
  display: grid;
  gap: 10px;
}
.system.overheating { border-color: var(--danger); background: linear-gradient(180deg, rgba(60, 12, 28, 0.92), rgba(24, 8, 16, 0.92)); animation: blink 0.8s steps(2) infinite; }
.system-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.system-head h3 { color: var(--text); font-size: 13px; }
.system-output { font-size: 14px; font-weight: 600; color: var(--accent); }
.system .bar { grid-template-columns: 4.4rem 1fr 3rem; }

/* ---------- Main screen ---------- */
.station-main { display: block; position: relative; overflow: hidden; background: var(--bg); }
.station-main canvas.radar { position: absolute; inset: 0; width: 100%; height: 100%; }
.hud {
  position: absolute;
  background: linear-gradient(180deg, rgba(27, 18, 51, 0.82), rgba(12, 8, 24, 0.82));
  backdrop-filter: blur(4px);
  border: 2px solid var(--border);
  clip-path: var(--notch);
  padding: 14px;
  display: grid;
  gap: 10px;
}
.hud-left { top: 14px; left: 14px; width: min(360px, calc(100% - 28px)); }
.hud-left button { justify-self: start; }
.hud-right { top: 14px; right: 14px; min-width: 220px; }
.hud-bottom { bottom: 14px; left: 14px; max-width: min(600px, calc(100% - 28px)); }
.wave { font-size: 20px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--energy); text-shadow: 0 0 14px rgba(255, 204, 92, 0.45); }
.crew-list, .log { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 15px; }
.crew-list li { display: flex; justify-content: space-between; gap: 16px; }
.crew-list span { color: var(--muted); }
.crew-list strong { font-weight: 600; color: var(--accent); }
.log li { color: var(--muted); animation: rise 0.3s ease-out both; }
.log li::before { content: "› "; color: var(--violet); }
.log li:last-child { color: var(--text); }
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 16px;
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(18, 11, 34, 0.7), rgba(7, 4, 15, 0.92));
}
.overlay h2 {
  font-size: clamp(22px, 4vw, 40px);
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
  animation: rise 0.5s ease-out both;
}
.overlay h2 .code {
  display: block;
  margin-top: 8px;
  font-size: 2.6em;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--text);
  text-shadow: 0 4px 0 #3a1a55, 0 0 40px rgba(79, 227, 193, 0.55);
}
.overlay p { max-width: 38rem; color: var(--text); margin: 0; font-size: 20px; text-wrap: pretty; }
.overlay .hi-score { font-size: 14px; font-weight: 600; letter-spacing: 0.24em; text-transform: uppercase; color: var(--energy); }
.overlay button { font-size: 18px; padding: 16px 30px; }
.wave-banner {
  position: absolute;
  left: 50%;
  top: 36%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  display: grid;
  gap: 10px;
}
.wave-banner strong {
  font: 700 clamp(40px, 9vw, 96px)/1 var(--font);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  text-shadow: 0 5px 0 #3a1a55, 0 0 48px rgba(255, 79, 139, 0.6);
  animation: pop 0.5s ease-out both;
}
.wave-banner span { font-size: 16px; font-weight: 600; letter-spacing: 0.5em; text-transform: uppercase; color: var(--accent); }

@media (max-width: 800px) {
  .station-body { grid-template-columns: 1fr; grid-template-rows: 52vh auto; overflow-y: auto; }
  .panel { border-left: 0; border-top: 2px solid var(--border); overflow: visible; }
  .engineering-top { grid-template-columns: 1fr 1fr; }
  .engineering-top .bar { grid-column: 1 / -1; }
  .hud-right { display: none; }
  .hud-bottom { display: none; }
  .station-header h1 { font-size: 15px; }
}

/* ---------- Missions: select, briefing, debrief ---------- */
.overlay.scroll { justify-content: flex-start; overflow-y: auto; padding: 28px 20px 40px; }
.mission-select { width: min(1240px, 100%); display: grid; gap: 22px; text-align: left; animation: rise 0.5s ease-out both; }
.join-bar { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; padding: 14px 18px; background: linear-gradient(180deg, rgba(27, 18, 51, 0.9), rgba(12, 8, 24, 0.9)); border: 2px solid var(--border); clip-path: var(--notch); }
.join-code { display: grid; gap: 2px; }
.join-code span { font-size: 11px; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.join-code strong { font-size: 44px; font-weight: 700; letter-spacing: 0.18em; line-height: 1; color: var(--text); text-shadow: 0 3px 0 #3a1a55, 0 0 28px rgba(79, 227, 193, 0.5); }
.overlay .join-bar p { margin: 0; max-width: none; font-size: 17px; color: var(--muted); flex: 1; min-width: 220px; }
.overlay h2.select-title { font-size: clamp(22px, 3vw, 34px); letter-spacing: 0.2em; color: var(--text); text-align: left; animation: none; }
.mission-group { display: grid; gap: 12px; }
.mission-group h3 { color: var(--accent); }
.mission-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.mission-card { display: flex; flex-direction: column; align-items: stretch; gap: 8px; text-align: left; padding: 16px; min-height: 170px; clip-path: var(--notch); letter-spacing: 0; }
.mission-card:hover { border-color: var(--energy); }
.mission-card:hover .mission-title { color: var(--energy); }
.mission-card.locked { cursor: default; opacity: 0.5; filter: saturate(0.35); }
.mission-card.locked:hover { border-color: var(--edge); color: var(--text); background: linear-gradient(180deg, var(--panel-2), var(--panel)); }
.mission-card.locked:hover .mission-title { color: var(--text); }
.mission-card.locked:active { transform: none; }
.mission-top { display: flex; justify-content: space-between; align-items: center; }
.mission-num { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.1em; }
.mission-title { font-size: 20px; font-weight: 700; line-height: 1.1; color: var(--text); }
.overlay p.mission-hook { margin: 0; max-width: none; font-size: 14px; font-weight: 400; line-height: 1.35; color: var(--muted); flex: 1; text-wrap: pretty; }
.mission-meta, .mission-needs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mission-needs > span { font-size: 10px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.chip { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; padding: 3px 7px; border: 1px solid var(--border); color: var(--muted); background: rgba(7, 4, 15, 0.6); white-space: nowrap; }
.chip.ready { color: #04140f; background: var(--accent); border-color: var(--accent); }
.chip.soon { color: var(--muted); }
.chip.need { color: var(--hot); border-color: rgba(255, 79, 139, 0.4); }

.briefing, .debrief { width: min(760px, 100%); display: grid; gap: 16px; text-align: left; padding: 28px; background: linear-gradient(180deg, rgba(27, 18, 51, 0.94), rgba(12, 8, 24, 0.94)); border: 2px solid var(--edge); clip-path: var(--notch); animation: rise 0.5s ease-out both; }
.briefing-kicker { font-size: 12px; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--accent); }
.overlay h2.briefing-title, .overlay h2.debrief-title { font-size: clamp(34px, 5vw, 60px); font-weight: 700; letter-spacing: 0.02em; line-height: 1; text-transform: none; color: var(--text); text-shadow: 0 4px 0 #3a1a55, 0 0 32px rgba(154, 90, 214, 0.5); animation: none; }
.briefing-from { font-size: 14px; color: var(--energy); }
.briefing-from::before { content: "◆ "; color: var(--energy); }
.overlay p.briefing-text { margin: 0; font-size: 20px; line-height: 1.45; max-width: none; text-wrap: pretty; }
.briefing-objectives { display: grid; gap: 8px; padding: 14px 16px; background: rgba(7, 4, 15, 0.6); border: 2px solid var(--border); }
.briefing-objectives ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 18px; }
.briefing-objectives li::before { content: "▸ "; color: var(--accent); }
.overlay p.briefing-tip { margin: 0; font-size: 15px; color: var(--muted); max-width: none; }
.overlay-actions { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; }
.overlay .overlay-actions button { font-size: 16px; padding: 14px 22px; }
.debrief.win .debrief-title { color: var(--accent); }
.debrief.lose .debrief-title { color: var(--danger); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { display: grid; gap: 4px; padding: 12px 14px; background: #0b0717; border: 2px solid var(--border); clip-path: var(--notch-sm); }
.stat span { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.stat strong { font-size: 30px; font-weight: 700; color: var(--energy); line-height: 1; }

/* HUD extras */
.hud-mission { font-size: 11px; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--accent); }
.hud-counter { font-size: 15px; color: var(--muted); }
.hud-counter:empty { display: none; }
.objective-chip { font-size: 13px; font-weight: 600; color: var(--energy); border-left: 2px solid var(--energy); padding: 2px 10px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw; }

/* Alert states + hit flash, shared by every station */
.station { position: relative; }
.station::before { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 50; box-shadow: inset 0 0 0 0 transparent; transition: box-shadow 0.3s; }
.station.alert-yellow::before { box-shadow: inset 0 0 0 3px rgba(255, 204, 92, 0.7), inset 0 0 60px rgba(255, 204, 92, 0.18); }
.station.alert-red::before { box-shadow: inset 0 0 0 3px rgba(255, 64, 96, 0.85), inset 0 0 90px rgba(255, 64, 96, 0.28); animation: redalert 1.2s ease-in-out infinite; }
@keyframes redalert { 50% { box-shadow: inset 0 0 0 3px rgba(255, 64, 96, 0.4), inset 0 0 40px rgba(255, 64, 96, 0.1); } }
.station.hit .station-body { animation: shake 0.25s steps(4); }
@keyframes shake { 25% { transform: translate(3px, -2px); } 50% { transform: translate(-3px, 2px); } 75% { transform: translate(2px, 1px); } }
.station-picker button[disabled] { opacity: 0.45; cursor: not-allowed; filter: saturate(0.3); }
.station-picker button[disabled]:hover { border-color: var(--edge); }
.station-picker button[disabled] strong { color: var(--muted); }

@media (max-width: 800px) {
  .objective-chip { order: 10; max-width: 100%; flex-basis: 100%; }
  .join-code strong { font-size: 34px; }
  .briefing, .debrief { padding: 20px; }
}

/* Overlays sit on an opaque backdrop and hide the HUD behind them. */
.overlay { background: radial-gradient(ellipse at center, #140c27, #07040f 75%); z-index: 20; }
.station-main:has(.overlay:not([hidden])) .hud { visibility: hidden; }

/* ---------- New systems ---------- */
button.active { border-color: var(--accent); color: #fff; background: linear-gradient(180deg, #1d3b3a, #102221); }
button[disabled] { opacity: 0.45; cursor: not-allowed; }

/* Helm: docking + jump */
.dock-status { font-size: 14px; color: var(--muted); }
.dock-status.ready { color: #78e696; }
.jump-button.counting { border-color: var(--violet); color: #fff; background: linear-gradient(180deg, #3a1a55, #1b1233); animation: blink 0.8s steps(2) infinite; }

/* Weapons: frequency + missiles */
.freq-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.freq { padding: 8px 4px; min-height: 40px; font-size: 13px; }
.freq-hint { min-height: 1.2em; }
.freq-hint.good { color: var(--accent); }
.missile-types { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.missile-type { display: grid; gap: 2px; justify-items: center; padding: 8px 4px; min-height: 52px; font-size: 12px; }
.missile-type .stock { font-size: 20px; font-weight: 700; color: var(--energy); }
.missile-type.empty .stock { color: var(--danger); }
.tubes { display: grid; gap: 8px; }
.tube { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "name status btn" "track track track"; align-items: center; gap: 6px 10px; padding: 10px; background: #0b0717; border: 2px solid var(--border); clip-path: var(--notch-sm); }
.tube strong { grid-area: name; font-size: 13px; }
.tube-status { grid-area: status; font-size: 14px; color: var(--muted); }
.tube.loaded { border-color: var(--energy); }
.tube.loaded .tube-status { color: var(--energy); }
.tube > button { grid-area: btn; }
.tube-track { grid-area: track; height: 6px; background: #1b1233; overflow: hidden; }
.tube-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--violet), var(--energy)); transition: width 0.2s linear; }

/* Science */
.science-weak { font-size: 16px; font-weight: 600; color: var(--accent); min-height: 1.2em; }
.scan-status { font-size: 15px; color: var(--muted); }
.scan-status.deep { color: var(--energy); }
.scan-status.done { color: var(--accent); }
.scan-band { display: grid; gap: 6px; }
.wave-canvas { width: 100%; height: 90px; display: block; border: 2px solid var(--border); clip-path: var(--notch-sm); }
.slider.scan::-webkit-slider-thumb { background: linear-gradient(180deg, #ffd0e0, var(--hot)); border-color: #ffe0ec; box-shadow: 0 0 12px rgba(255, 79, 139, 0.5); }

/* Relay */
.comms-box { display: grid; gap: 10px; padding: 14px; background: linear-gradient(180deg, #1d1438, #120b22); border: 2px solid var(--energy); clip-path: var(--notch); animation: rise 0.3s ease-out both; }
.comms-from { font-size: 13px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--energy); }
.comms-from::before { content: "◆ "; }
.comms-text { margin: 0; font-size: 17px; line-height: 1.4; text-wrap: pretty; }
.comms-replies { display: flex; flex-wrap: wrap; gap: 8px; }
.comms-pending { font-size: 13px; color: var(--muted); }
.comms-pending:empty { display: none; }
.alert-row { display: grid; grid-template-columns: repeat(3, 1fr); }
.alert-btn.yellow.active { border-color: var(--energy); color: #1a0c05; background: linear-gradient(180deg, #ffe7ad, var(--energy)); }
.alert-btn.red.active { border-color: #ffb0c0; color: #fff; background: linear-gradient(180deg, #ff6a85, #b8203f); }
.waypoint-list { display: flex; flex-wrap: wrap; gap: 6px; }
.waypoint-chip { color: var(--energy); }

/* Main screen: comms card + countdown */
.comms-hud { top: 14px; left: 50%; transform: translateX(-50%); width: min(560px, calc(100% - 28px)); border-color: var(--energy); z-index: 5; }
.comms-hud .comms-text { font-size: 20px; }
.countdown { position: absolute; top: 14px; right: 260px; display: grid; justify-items: end; gap: 2px; padding: 10px 14px; background: rgba(12, 8, 24, 0.85); border: 2px solid var(--border); clip-path: var(--notch-sm); }
.countdown span { font-size: 11px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.countdown strong { font-size: 34px; font-weight: 700; color: var(--text); line-height: 1; }
.countdown.urgent { border-color: var(--danger); }
.countdown.urgent strong { color: var(--danger); animation: blink 1s steps(2) infinite; }
.station-main:has(.comms-hud:not([hidden])) .countdown { top: auto; bottom: 14px; right: 14px; }

@media (max-width: 800px) {
  .countdown { right: 14px; top: auto; bottom: 14px; }
  .comms-hud { top: auto; bottom: 14px; }
}

/* Keep the comms card clear of the status panel on laptop-size main screens. */
@media (max-width: 1460px) {
  .comms-hud { top: auto; bottom: 14px; }
  .station-main:has(.comms-hud:not([hidden])) .hud-bottom { visibility: hidden; }
  .station-main:has(.comms-hud:not([hidden])) .countdown { top: 14px; bottom: auto; right: 260px; }
}
@media (max-width: 800px) {
  .station-main:has(.comms-hud:not([hidden])) .countdown { top: 14px; right: 14px; }
}
