/* Bridge Console - weirdlab
   Themes are sets of CSS variables on <body>: skin-aurora / skin-tactical,
   plus alert-red on top of either. System fonts only. */

/* ---------- themes ---------- */

body {
  --font-head: Bahnschrift, "DIN Alternate", "Roboto Condensed", sans-serif-condensed, "Arial Narrow", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, Menlo, "Roboto Mono", "DejaVu Sans Mono", monospace;
}

.skin-aurora {
  --bg1: #06182c; --bg2: #020a14;
  --accent: #5fe0ff; --accent-soft: rgba(95, 224, 255, 0.14); --accent2: #54f0c8;
  --warn: #ffc24d; --danger: #ff5468;
  --text: #d6f3ff; --text-dim: rgba(168, 212, 234, 0.62);
  --panel-bg: rgba(9, 28, 47, 0.5); --panel-border: rgba(95, 224, 255, 0.28);
  --grid: rgba(95, 224, 255, 0.06); --glow: rgba(95, 224, 255, 0.4); --rim: rgba(95, 224, 255, 0.22);
  --bracket-op: 0; --scan-op: 0; --veil: transparent;
}

.skin-tactical {
  --bg1: #072019; --bg2: #02100b;
  --accent: #43efa6; --accent-soft: rgba(67, 239, 166, 0.12); --accent2: #8ef0d2;
  --warn: #ffd24d; --danger: #ff6a4d;
  --text: #cffce6; --text-dim: rgba(146, 222, 188, 0.6);
  --panel-bg: rgba(6, 30, 23, 0.5); --panel-border: rgba(67, 239, 166, 0.26);
  --grid: rgba(67, 239, 166, 0.06); --glow: rgba(67, 239, 166, 0.34); --rim: rgba(67, 239, 166, 0.22);
  --bracket-op: 1; --scan-op: 0.06; --veil: transparent;
}

/* red alert keeps the skin's brackets and scan lines, recolours the rest */
.alert-red {
  --bg1: #2a0810; --bg2: #0c0205;
  --accent: #ff5468; --accent-soft: rgba(255, 84, 104, 0.16); --accent2: #ffb24d;
  --warn: #ffb24d; --danger: #ff3b50;
  --text: #ffdadf; --text-dim: rgba(255, 150, 165, 0.6);
  --panel-bg: rgba(42, 8, 13, 0.52); --panel-border: rgba(255, 84, 104, 0.36);
  --grid: rgba(255, 84, 104, 0.07); --glow: rgba(255, 84, 104, 0.45); --rim: rgba(255, 84, 104, 0.3);
  --veil: rgba(255, 40, 60, 0.2);
}

/* ---------- base ---------- */

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

html, body { margin: 0; height: 100%; background: #02060c; overflow: hidden; }
body { font-family: var(--font-mono); color: var(--text); -webkit-font-smoothing: antialiased; }
button, input { font-family: inherit; }
::-webkit-scrollbar { width: 0; height: 0; }

@keyframes radarSweep { to { transform: rotate(360deg); } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes blinkHard { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0.25; } }
@keyframes veilPulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
@keyframes corePulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 18px var(--glow), inset 0 0 18px var(--accent-soft); }
  50% { transform: scale(1.05); box-shadow: 0 0 28px var(--glow), inset 0 0 22px var(--accent-soft); }
}
@keyframes warpRush { from { background-position: 0 0; } to { background-position: 0 -90px; } }
@keyframes fireFlash { 0% { opacity: 0; } 12% { opacity: 1; } 100% { opacity: 0; } }
@keyframes blipPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes dialogIn { from { transform: scale(0.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* tone = colour by meaning; app.js sets data-tone */
[data-tone="ok"]   { --tone: var(--accent2); }
[data-tone="warn"] { --tone: var(--warn); }
[data-tone="bad"]  { --tone: var(--danger); }
[data-tone="acc"]  { --tone: var(--accent); }
[data-tone="dim"]  { --tone: var(--text-dim); }
[data-tone="txt"]  { --tone: var(--text); }

/* ---------- screen + background layers ---------- */

.screen {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 28%, var(--bg1), var(--bg2) 82%);
}

.bg-stars, .bg-grid, .bg-veil, .bg-warp, .scanlines { position: fixed; inset: 0; pointer-events: none; }

.bg-stars {
  z-index: 0;
  opacity: 0.5;
  background-image:
    radial-gradient(1px 1px at 12% 18%, #cfefff, transparent), radial-gradient(1px 1px at 68% 32%, #bfe6ff, transparent),
    radial-gradient(1px 1px at 84% 64%, #fff, transparent), radial-gradient(1px 1px at 32% 78%, #cdeaff, transparent),
    radial-gradient(1px 1px at 52% 12%, #fff, transparent), radial-gradient(1px 1px at 24% 52%, #bfe0ff, transparent),
    radial-gradient(1px 1px at 92% 22%, #fff, transparent), radial-gradient(1px 1px at 8% 86%, #cfeaff, transparent),
    radial-gradient(1px 1px at 44% 44%, #bfe6ff, transparent), radial-gradient(1px 1px at 76% 88%, #fff, transparent);
}

.bg-grid {
  z-index: 0;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 40%, #000 28%, transparent 86%);
  mask-image: radial-gradient(ellipse at 50% 40%, #000 28%, transparent 86%);
}

.bg-veil {
  z-index: 1;
  background: radial-gradient(ellipse at 50% 45%, transparent 36%, var(--veil) 100%);
  animation: veilPulse 1.6s ease-in-out infinite;
}

.bg-warp {
  z-index: 1;
  opacity: 0.45;
  background-image: repeating-linear-gradient(0deg, transparent 0 7px, var(--accent-soft) 7px 8px);
  background-size: 100% 90px;
  animation: warpRush 0.5s linear infinite;
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000, transparent 72%);
  mask-image: radial-gradient(circle at 50% 50%, #000, transparent 72%);
}

.scanlines {
  z-index: 5;
  opacity: var(--scan-op);
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.55) 0 1px, transparent 1px 3px);
}

.console { position: relative; z-index: 2; display: flex; flex-direction: column; height: 100%; }

/* ---------- shared small parts ---------- */

.lbl { font-size: 9px; letter-spacing: 0.12em; color: var(--text-dim); white-space: nowrap; }
.val { font-size: 11px; color: var(--text); }
.val-ok { color: var(--accent2); }
.status { font-size: 10px; letter-spacing: 0.1em; color: var(--tone, var(--text-dim)); white-space: nowrap; }
.head-info { font-size: 9.5px; letter-spacing: 0.08em; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.row-bottom { align-items: flex-end; }
.stack { display: flex; flex-direction: column; gap: 5px; }
.stack-right { align-items: flex-end; }

.bar {
  height: 7px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  border-radius: 2px;
  overflow: hidden;
}
.bar-tall { height: 11px; }
.bar-mid { height: 9px; }
.bar-thin { height: 6px; margin-top: 2px; }
.bar-bare { height: 5px; border: none; }

.fill {
  width: 0;
  height: 100%;
  background: var(--tone, var(--accent));
  box-shadow: 0 0 9px var(--tone, var(--accent));
  border-radius: 2px;
  transition: width 0.8s ease, background 0.3s;
}

/* ---------- buttons ---------- */

.btn {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.1em;
  padding: 8px 11px;
  min-height: 36px;
  border-radius: 2px;
  cursor: pointer;
  white-space: nowrap;
  background: transparent;
  color: var(--tone, var(--accent));
  border: 1px solid var(--tone, var(--panel-border));
}
.btn[data-tone="ok"], .btn[data-tone="acc"] { background: var(--accent-soft); }
.btn:hover { filter: brightness(1.2); }
.btn:focus-visible, .btn-sq:focus-visible, .skin-tab:focus-visible { outline: 1px solid var(--text); outline-offset: 2px; }

/* filled red: hot alert button, armed fire buttons */
.btn.is-hot { background: var(--danger); border-color: var(--danger); color: #1a0306; font-weight: 700; box-shadow: 0 0 14px var(--glow); }
/* looks disabled but still clickable, so the log can say why it won't fire */
.btn.is-off { opacity: 0.4; color: var(--text-dim); border-color: var(--text-dim); cursor: not-allowed; }

.btn-soft { background: var(--accent-soft); }
.btn-small { min-height: 0; padding: 6px 12px; font-size: 10px; letter-spacing: 0.12em; }
.btn-alert { --tone: var(--danger); }
.btn-ok { --tone: var(--accent2); background: var(--accent-soft); }
.btn-danger { --tone: var(--danger); }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

.btn-sq {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  border-radius: 2px;
  font-size: 15px;
  padding: 0;
}
.btn-sq.btn-mini { width: 22px; height: 22px; font-size: 13px; flex: none; }

/* ---------- header ---------- */

.topbar {
  flex: none;
  height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  border-bottom: 1px solid var(--panel-border);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.4), transparent);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; overflow: hidden; }
.home-link {
  flex: none;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-decoration: none;
  padding: 4px 0;
}
.home-link:hover, .home-link:focus-visible { color: var(--accent); }

.brand-logo {
  flex: none;
  width: 30px; height: 30px;
  border: 1.5px solid var(--accent);
  transform: rotate(45deg);
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 14px var(--glow);
}
.brand-logo > div { width: 8px; height: 8px; background: var(--accent); box-shadow: 0 0 8px var(--accent); }

.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ship-name { font-family: var(--font-head); font-weight: 700; font-size: 15px; letter-spacing: 0.2em; white-space: nowrap; }
.ship-sub { font-size: 9.5px; letter-spacing: 0.12em; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.stardate { display: flex; flex-direction: column; align-items: center; gap: 2px; justify-self: center; }
.stardate-main { font-family: var(--font-head); font-weight: 600; font-size: 12px; letter-spacing: 0.2em; color: var(--accent); white-space: nowrap; }
.stardate-sub { font-size: 9.5px; letter-spacing: 0.14em; color: var(--text-dim); white-space: nowrap; }

.top-controls { display: flex; align-items: center; gap: 9px; justify-self: end; }
.skin-tabs { display: flex; border: 1px solid var(--panel-border); border-radius: 2px; overflow: hidden; }
.skin-tab {
  font-family: var(--font-head); font-weight: 600; font-size: 9.5px; letter-spacing: 0.13em;
  padding: 6px 9px; min-height: 32px; white-space: nowrap; cursor: pointer;
  background: transparent; border: none; color: var(--text-dim);
}
.skin-tab.is-on { background: var(--accent-soft); color: var(--accent); }

.condition {
  padding: 6px 9px; border-radius: 2px; border: 1px solid var(--accent2);
  font-family: var(--font-head); font-weight: 600; font-size: 10px; letter-spacing: 0.12em; white-space: nowrap;
  color: var(--accent2); background: var(--accent-soft);
}
.condition.is-red { color: #fff; background: var(--danger); border-color: var(--danger); animation: blinkHard 1s infinite; }

/* ---------- panels ---------- */

.panels {
  flex: 1;
  display: grid;
  grid-template-columns: 20.5% 1fr 23%;
  gap: 12px;
  padding: 12px;
  min-height: 0;
}
.col { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.col-right { overflow: hidden; }

.panel {
  position: relative;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  padding: 11px 13px 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  box-shadow: inset 0 0 26px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.p-shields { flex: 1.05; }
.p-weapons { flex: 1; }
.p-sensors { flex: 1; min-height: 0; }
.p-helm, .p-reactor, .p-life { flex: none; }
.p-hull { flex: 1; min-height: 0; gap: 8px; }

/* corner brackets (Tactical skin); app.js adds the four <i> */
.corner { position: absolute; width: 11px; height: 11px; opacity: var(--bracket-op); border: 0 solid var(--accent); }
.corner.tl { top: 5px; left: 5px; border-top-width: 2px; border-left-width: 2px; }
.corner.tr { top: 5px; right: 5px; border-top-width: 2px; border-right-width: 2px; }
.corner.bl { bottom: 5px; left: 5px; border-bottom-width: 2px; border-left-width: 2px; }
.corner.br { bottom: 5px; right: 5px; border-bottom-width: 2px; border-right-width: 2px; }

.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 6px;
}
.panel-title { font-family: var(--font-head); font-weight: 600; font-size: 11px; letter-spacing: 0.22em; white-space: nowrap; }
.head-right { display: flex; align-items: baseline; gap: 8px; }
.big-num { font-family: var(--font-head); font-weight: 700; font-size: 18px; line-height: 1; }

/* shields */
.quad-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1.05fr 1fr;
  gap: 7px 8px;
  align-items: center;
}
.quad { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.quad-row { display: flex; justify-content: space-between; }
.quad-row .lbl { letter-spacing: 0.1em; }
.quad-val { font-size: 9px; }
.quad-ship { display: flex; align-items: center; justify-content: center; }
.quad-ship > div { width: 30px; height: 30px; border: 1.5px solid var(--accent); transform: rotate(45deg); box-shadow: 0 0 12px var(--glow); position: relative; }
.quad-ship > div > div { position: absolute; inset: 6px; background: var(--accent-soft); }

/* weapons */
.banks { display: flex; gap: 6px; }
.bank { width: 9px; height: 9px; border-radius: 50%; background: var(--tone, var(--text-dim)); }
.bank[data-tone="ok"] { box-shadow: 0 0 8px var(--tone); }
.torps { display: flex; gap: 4px; }
.torp { width: 7px; height: 13px; border-radius: 1px; border: 1px solid var(--panel-border); background: transparent; transition: background 0.3s; }
.torp.is-loaded { background: var(--warn); }
.target-box { border: 1px solid var(--panel-border); border-radius: 2px; padding: 6px 8px; display: flex; flex-direction: column; gap: 1px; }
.target-name { font-family: var(--font-head); font-weight: 600; font-size: 13px; letter-spacing: 0.04em; color: var(--tone, var(--text-dim)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.target-sub { font-size: 9px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-weapons .btn-row { gap: 6px; }
.p-weapons .btn-row .btn { padding: 8px 4px; font-size: 10.5px; letter-spacing: 0.06em; min-width: 0; }

/* sensors */
.sensors-body { display: flex; gap: 13px; flex: 1; min-height: 0; }
.radar-wrap { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; min-height: 0; min-width: 0; }
.radar { position: relative; height: 100%; aspect-ratio: 1; max-width: 100%; }
.ring { position: absolute; border: 1px solid var(--rim); border-radius: 50%; }
.ring-1 { inset: 0; }
.ring-2 { inset: 16.6%; opacity: 0.7; }
.ring-3 { inset: 33.3%; opacity: 0.5; }
.axis { position: absolute; background: var(--rim); }
.axis-h { left: 0; right: 0; top: 50%; height: 1px; }
.axis-v { top: 0; bottom: 0; left: 50%; width: 1px; }
.sweep { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; }
.sweep > div {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0deg, transparent 318deg, var(--accent-soft) 356deg, var(--accent) 360deg);
  animation: radarSweep 4s linear infinite;
}
.compass { position: absolute; font-size: 8px; letter-spacing: 0.1em; color: var(--text-dim); }
.c-n { top: 2px; left: 50%; transform: translateX(-50%); }
.c-e { right: 3px; top: 50%; transform: translateY(-50%); }
.c-s { bottom: 2px; left: 50%; transform: translateX(-50%); }
.c-w { left: 3px; top: 50%; transform: translateY(-50%); }

/* line / beam: left+top = centre, width = distance, rotated toward the target */
.target-line, .beam { position: absolute; left: 50%; top: 50%; transform-origin: 0 50%; }
.target-line { height: 1px; background: var(--accent); opacity: 0.55; box-shadow: 0 0 6px var(--accent); }
.beam { height: 2px; background: var(--danger); box-shadow: 0 0 10px var(--danger); animation: fireFlash 0.65s ease-out forwards; }
.target-reticle {
  position: absolute; width: 22px; height: 22px; transform: translate(-50%, -50%);
  border: 1px solid var(--accent); box-shadow: 0 0 8px var(--accent);
  transition: left 1s linear, top 1s linear;
}
.torpedo-dot {
  position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--warn); box-shadow: 0 0 10px var(--warn), 0 0 3px #fff;
  z-index: 1;
}
.torpedo-dot.is-flying { transition: left 1s ease-in, top 1s ease-in; }

.blip {
  position: absolute; width: 9px; height: 9px;
  transform: translate(-50%, -50%) rotate(45deg);
  border-radius: 1px;
  background: var(--tone); box-shadow: 0 0 10px var(--tone);
  border: 1px solid rgba(255, 255, 255, 0.45);
  transition: left 1s linear, top 1s linear;
  cursor: pointer;
}
.blip.is-friend { transform: translate(-50%, -50%); border-radius: 50%; }
.blip.is-hostile { animation: blipPulse 0.9s ease-in-out infinite; }
.blip.is-hit { animation: fireFlash 0.5s ease-out; }

.own-ship {
  position: absolute; left: 50%; top: 50%; width: 8px; height: 8px;
  transform: translate(-50%, -50%) rotate(45deg);
  background: var(--text); box-shadow: 0 0 10px var(--text);
}
.warp-note {
  position: absolute; left: 50%; top: 62%; transform: translateX(-50%);
  font-family: var(--font-head); font-size: 10px; letter-spacing: 0.18em; color: var(--accent);
  background: rgba(0, 0, 0, 0.5); padding: 3px 8px; border: 1px solid var(--panel-border); white-space: nowrap;
}

.contacts { width: 186px; flex: none; display: flex; flex-direction: column; gap: 7px; min-height: 0; }
.contact-list { flex: 1; display: flex; flex-direction: column; gap: 5px; overflow-y: auto; min-height: 0; }
.contact {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 7px; border-radius: 2px; cursor: pointer;
  border: 1px solid transparent; background: transparent;
  text-align: left; color: inherit; font: inherit; width: 100%;
}
.contact.is-locked { border-color: var(--tone); background: rgba(255, 255, 255, 0.05); }
.contact-dot { width: 8px; height: 8px; flex: none; border-radius: 1px; transform: rotate(45deg); background: var(--tone); box-shadow: 0 0 6px var(--tone); }
.contact.is-friend .contact-dot { border-radius: 50%; transform: none; }
.contact-text { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.contact-name { font-size: 10px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-sub { font-size: 8px; letter-spacing: 0.06em; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-br { font-size: 8.5px; color: var(--text-dim); white-space: nowrap; }
.contacts > .btn { min-height: 34px; font-size: 10px; letter-spacing: 0.14em; padding: 8px; }

/* helm */
.helm-body { display: flex; gap: 14px; align-items: stretch; }
.helm-heading, .helm-speed { flex: none; }
.helm-dest { flex: 1; min-width: 0; justify-content: center; gap: 4px; }
.vsep { width: 1px; background: var(--panel-border); }
.heading-num { font-family: var(--font-head); font-weight: 700; font-size: 28px; line-height: 1; color: var(--accent); white-space: nowrap; }
.heading-mark { font-size: 14px; color: var(--text-dim); }
.heading-set { display: flex; gap: 6px; }
.heading-set input {
  width: 52px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--panel-border); color: var(--text);
  font-size: 13px; padding: 6px 7px; border-radius: 2px; text-align: center; outline: none;
}
.heading-set input:focus { border-color: var(--accent); }
.dest-name { font-family: var(--font-head); font-weight: 600; font-size: 13px; letter-spacing: 0.06em; }
.dest-eta { font-size: 9.5px; color: var(--text-dim); }
.speed-num { font-family: var(--font-head); font-weight: 700; font-size: 20px; line-height: 1; white-space: nowrap; }
.speed-btns { display: flex; gap: 6px; }
.btn-warp { min-height: 30px; padding: 6px 12px; }
.btn-warp.is-on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); box-shadow: 0 0 12px var(--glow); }

/* reactor */
.reactor-top { display: flex; gap: 13px; align-items: center; }
.core {
  position: relative; width: 60px; height: 60px; flex: none; border-radius: 50%;
  border: 1.5px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  animation: corePulse 2.4s ease-in-out infinite;
}
.core > div { position: absolute; inset: 9px; border-radius: 50%; background: radial-gradient(circle, var(--accent), transparent 70%); opacity: 0.5; }
.core > span { position: relative; font-family: var(--font-head); font-weight: 700; font-size: 16px; }
.reactor-nums { flex: 1; gap: 3px; }
.reactor-nums .val { font-size: 10px; }
#loadTxt { color: var(--tone, var(--text)); }
.power-list { display: flex; flex-direction: column; gap: 6px; }
.power-row { display: flex; align-items: center; gap: 8px; }
.power-row .lbl { width: 64px; flex: none; letter-spacing: 0.08em; }
.power-row .bar { flex: 1; }
.power-val { font-size: 10px; width: 30px; text-align: right; flex: none; }

/* life support */
.life-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gauge { border: 1px solid var(--panel-border); border-radius: 2px; padding: 6px 7px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.gauge .lbl { font-size: 8.5px; letter-spacing: 0.1em; }
.gauge-num { display: flex; align-items: baseline; gap: 2px; }
.gauge-val { font-family: var(--font-head); font-weight: 600; font-size: 15px; color: var(--text); }
.gauge-val[data-tone="bad"] { color: var(--danger); }
.gauge-unit { font-size: 8px; color: var(--text-dim); }
.gauge .bar { height: 4px; border: none; }

/* hull */
.hull-pct { font-family: var(--font-head); font-weight: 700; font-size: 13px; color: var(--tone, var(--text)); }
.section-list { display: flex; flex-direction: column; gap: 5px; flex: 1; min-height: 0; }
.section-row { display: flex; align-items: center; gap: 8px; }
.section-name { font-size: 9px; letter-spacing: 0.06em; width: 88px; flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.section-row .bar { flex: 1; }
.section-status { font-size: 8.5px; letter-spacing: 0.08em; color: var(--tone); width: 56px; text-align: right; flex: none; }

/* ---------- log ---------- */

.log {
  flex: none;
  height: 94px;
  border-top: 1px solid var(--panel-border);
  display: flex; flex-direction: column;
  padding: 7px 18px; gap: 3px;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.4), transparent);
}
.log-head { display: flex; align-items: center; gap: 10px; }
.log-head .lbl { font-size: 8.5px; letter-spacing: 0.18em; }
.log-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: blink 1.4s ease-in-out infinite; }
.log-list { flex: 1; display: flex; flex-direction: column; gap: 2px; overflow: hidden; font-size: 11px; }
.log-row { display: flex; gap: 10px; color: var(--tone, var(--text-dim)); white-space: nowrap; }
.log-time { opacity: 0.55; min-width: 66px; flex: none; }

/* ---------- overlays ---------- */

.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.5);
}
.dialog {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  min-width: min(340px, 100%);
  padding: 22px 26px;
  text-align: center;
  background: var(--bg2);
  border: 1px solid var(--accent);
  border-radius: 3px;
  box-shadow: 0 0 40px var(--glow), inset 0 0 30px rgba(0, 0, 0, 0.5);
  animation: dialogIn 0.25s ease-out;
}
.dialog .btn-row { align-self: stretch; margin-top: 6px; }
.dialog-kicker { font-size: 10px; letter-spacing: 0.24em; color: var(--text-dim); }
.dialog-title { font-family: var(--font-head); font-weight: 700; font-size: 30px; letter-spacing: 0.18em; color: var(--accent2); }
.dialog-text { font-size: 12px; line-height: 1.5; color: var(--text); max-width: 30em; }

.overlay-lost { background: rgba(20, 0, 4, 0.82); }
.dialog-lost { border-color: #ff3b50; background: #0c0205; box-shadow: 0 0 60px rgba(255, 59, 80, 0.45), inset 0 0 30px rgba(0, 0, 0, 0.5); }
.dialog-lost .dialog-title { color: #ff3b50; font-size: 40px; animation: blinkHard 1.2s infinite; }
.dialog-lost .dialog-kicker { color: rgba(255, 150, 165, 0.7); }
.dialog-lost .dialog-text { color: #ffdadf; }
.dialog-lost .btn { --tone: #ff3b50; }

/* ---------- short laptop windows: same 3 columns, page scrolls ---------- */

@media (min-width: 1100px) and (max-height: 799px) {
  html, body { height: auto; overflow: auto; }
  .screen { position: relative; inset: auto; min-height: 100vh; overflow: visible; background: none; }
  body { background: radial-gradient(ellipse at 50% 28%, var(--bg1), var(--bg2) 82%) fixed, #02060c; }
  .console { height: auto; min-height: 100vh; }
  .panels { flex: 1 0 720px; }
  .col-right { overflow: visible; }
}

/* ---------- scrolling layout: tablets and phones ---------- */

@media (max-width: 1099px) {
  html, body { height: auto; overflow: auto; }
  .screen { position: relative; inset: auto; min-height: 100vh; overflow: visible; }
  .screen { background: none; }
  body { background: radial-gradient(ellipse at 50% 0%, var(--bg1), var(--bg2) 70%) fixed, #02060c; }
  .console { height: auto; min-height: 100vh; }

  .topbar {
    height: auto;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand controls" "date date";
    padding: 10px 14px;
    row-gap: 8px;
  }
  .brand { grid-area: brand; }
  .top-controls { grid-area: controls; }
  .stardate { grid-area: date; flex-direction: row; justify-self: start; gap: 14px; align-items: baseline; flex-wrap: wrap; }

  .panels { grid-template-columns: 1fr 1fr; align-items: start; }
  .col { display: contents; }
  .panel { min-height: 0; }
  .p-sensors { order: 1; grid-column: 1 / -1; }
  .p-weapons { order: 2; }
  .p-shields { order: 3; align-self: stretch; }
  .p-helm    { order: 4; grid-column: 1 / -1; }
  .p-reactor { order: 5; align-self: stretch; }
  .p-life    { order: 6; align-self: stretch; }
  .p-hull    { order: 7; grid-column: 1 / -1; }

  .radar-wrap { flex: none; width: min(100%, 360px); align-self: center; }
  .radar { width: 100%; height: auto; }
  .sensors-body { align-items: stretch; }
  .contacts { flex: 1; width: auto; }
  .contact-list { overflow: visible; }

  /* bigger text so it stays readable */
  .lbl, .quad-row .lbl, .power-row .lbl, .gauge .lbl, .log-head .lbl { font-size: 11px; }
  .quad-val, .val, .reactor-nums .val, .power-val { font-size: 12.5px; }
  .status, .head-info { font-size: 11px; }
  .panel-title { font-size: 13px; }
  .ship-sub, .stardate-sub, .dest-eta, .target-sub { font-size: 11px; }
  .stardate-main { font-size: 13px; }
  .contact-name { font-size: 13px; }
  .contact-sub, .contact-br { font-size: 10.5px; }
  .compass { font-size: 10px; }
  .section-name { font-size: 11.5px; width: 110px; }
  .section-status { font-size: 10.5px; width: 68px; }
  .power-row .lbl { width: 76px; }
  .power-val { width: 40px; }
  .gauge-unit { font-size: 10px; }
  .gauge-val { font-size: 17px; }
  .home-link { font-size: 12px; }
  .bar { height: 9px; }
  .bar-tall { height: 12px; }
  .btn-sq.btn-mini { width: 32px; height: 32px; font-size: 16px; }
  .p-weapons .btn-row .btn { font-size: 12px; min-height: 42px; }

  .log { height: auto; padding: 10px 14px 16px; }
  .log-list { font-size: 12.5px; gap: 4px; }
  .log-row { white-space: normal; }
}

/* phones: one column */
@media (max-width: 699px) {
  .topbar { grid-template-columns: 1fr; grid-template-areas: "brand" "date" "controls"; }
  .top-controls { justify-self: stretch; flex-wrap: wrap; }
  .top-controls .btn-alert { flex: 1; }
  .brand { gap: 10px; }
  .ship-name { font-size: 14px; letter-spacing: 0.14em; }

  .panel-head { flex-wrap: wrap; row-gap: 4px; }
  .panels { grid-template-columns: 1fr; padding: 10px; gap: 10px; }
  .panel { grid-column: 1 / -1; }
  .sensors-body { flex-direction: column; }
  .radar-wrap { width: min(100%, 340px); }
  .helm-body { flex-wrap: wrap; row-gap: 12px; }
  .helm-dest { order: 3; flex-basis: 100%; border-top: 1px solid var(--panel-border); padding-top: 10px; }
  .helm-body .vsep { display: none; }
  .helm-heading, .helm-speed { flex: 1; }
  .life-grid { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .sweep > div, .bg-veil, .bg-warp, .core, .log-dot, .blip.is-hostile, .condition.is-red, .dialog-lost .dialog-title { animation: none; }
}
