/* ============================================================================
   SOMNARI — Command Console design system
   Diegetic instrument HUD: white-on-near-black with restraint. Colour is
   reserved for MEANING (security tiers, teams, HP, resources) and ACTIONS
   (cyan). Structural chrome stays neutral. Angular notched frames, corner-tick
   accents, parallelogram section markers, mono serial codes, generous space.
   ============================================================================ */
:root {
  --bg: #07080b;
  --surface0: rgba(8,9,12,0.9);
  --surface1: #0c0e13;
  --surface2: #11141b;
  --surface3: #171b24;
  --panel: var(--surface1);   /* legacy aliases */
  --panel2: var(--surface2);
  --line: #1e2937;
  --line-strong: #33485e;
  --text: #c2c8d2;
  --text-strong: #f1f3f7;
  --muted: #69707d;
  --muted-strong: #969db0;
  --accent: #dfe8f2;          /* STRUCTURAL near-white (brackets, ticks, markers, headings) */
  --action: #46c8ff;          /* ACTIONS / CTAs / "self" */
  --good: #5ad17a;
  --bad: #ff5050;
  --warn: #ff9a3d;
  --accent2: #ff6b52;         /* warm numeric highlight (costs) */
  --glass-blur: 2px;          /* diegetic theme values (THEMES.diegetic) */
  --panel-border: #243345;
  --panel-shadow: none;
  --scan-op: 0.05;
  --ink: #f1f3f7;
  --font-display: 'Chakra Petch', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;
  --font-body: 'Saira', 'Segoe UI', system-ui, sans-serif;
  --notch: 10px;
  font-family: var(--font-body);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%; width: 100%; overflow: hidden;
  background: #05080f; color: #c8d6ee;
  font-family: var(--font-body); -webkit-font-smoothing: antialiased;
  letter-spacing: 0.1px; cursor: default; user-select: none;
}
/* The Ops Console (admin.html) is a normal scrolling document, not the fixed full-screen game canvas:
   opt out of the global overflow:hidden height-lock so the long page scrolls, and re-enable text
   selection so operators can copy ids / job output. */
html:has(body.admin), body.admin { height: auto; min-height: 100%; overflow: visible; }
body.admin { user-select: text; }
/* accessibility prefs (Settings → Accessibility) */
body.mk-noanim *, body.mk-noanim *::before, body.mk-noanim *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
body.mk-bigui #game { zoom: 1.18; }
:focus-visible { outline: 2px solid var(--action); outline-offset: 1px; }
:focus:not(:focus-visible) { outline: none; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #23355a; border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #2f4a7a; }
::-webkit-scrollbar-track { background: transparent; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; } }

/* ---- prototype keyframe + animation library (mk-*) — ported VERBATIM for 1:1 motion ---- */
@keyframes mk-shimmer{0%{transform:translateX(-120%)}100%{transform:translateX(320%)}}
@keyframes mk-toastin{from{opacity:0;transform:translateX(20px)}to{opacity:1;transform:none}}
@keyframes mk-badge{0%{transform:scale(1)}40%{transform:scale(1.22)}100%{transform:scale(1)}}
@keyframes mk-spin{to{transform:rotate(360deg)}}
@keyframes mk-rise{from{transform:translateY(7px)}to{transform:none}}
@keyframes mk-blink{0%,100%{opacity:1}50%{opacity:.25}}
@keyframes mk-panelin{from{transform:translateX(-12px)}to{transform:none}}
@keyframes mk-panelinR{from{transform:translateX(12px)}to{transform:none}}
@keyframes mk-tickglow{0%,100%{opacity:.4}50%{opacity:1}}
@keyframes mk-linedraw{from{transform:scaleX(0)}to{transform:scaleX(1)}}
@keyframes mk-nodepulse{0%{box-shadow:0 0 0 0 var(--accent)}70%,100%{box-shadow:0 0 0 5px transparent}}
@keyframes mk-flick{0%,100%{opacity:1}48%{opacity:1}49%{opacity:.35}50%{opacity:1}92%{opacity:1}93%{opacity:.5}94%{opacity:1}}
@keyframes mk-barfill{from{transform:scaleX(0)}to{transform:scaleX(1)}}
@keyframes mk-scandot{0%{opacity:.2}50%{opacity:1}100%{opacity:.2}}
@keyframes mk-sheen{0%{left:-40%}100%{left:140%}}
@keyframes mk-bootline{from{transform:scaleX(0)}to{transform:scaleX(1)}}
@keyframes mk-bootrow{from{opacity:0;transform:translateX(-8px)}to{opacity:1;transform:none}}
@keyframes mk-ringspin{from{transform:rotate(0)}to{transform:rotate(360deg)}}
@keyframes mk-bootfade{to{opacity:0;visibility:hidden}}
@keyframes mk-conn-line{from{transform:scaleX(0)}to{transform:scaleX(1)}}
@keyframes mk-conn-node{0%{transform:scale(0);opacity:0}60%{transform:scale(1.3)}100%{transform:scale(1);opacity:1}}
@keyframes mk-conn-label{from{opacity:0;transform:translateX(-4px)}to{opacity:1;transform:none}}
.mk-anim-card{animation:mk-panelin .42s cubic-bezier(.2,.7,.2,1) both}
.mk-anim-cardR{animation:mk-panelinR .42s cubic-bezier(.2,.7,.2,1) both}
.mk-stagger>*:nth-child(1){animation:mk-panelinR .4s cubic-bezier(.2,.7,.2,1) both;animation-delay:.02s}
.mk-stagger>*:nth-child(2){animation:mk-panelinR .4s cubic-bezier(.2,.7,.2,1) both;animation-delay:.07s}
.mk-stagger>*:nth-child(3){animation:mk-panelinR .4s cubic-bezier(.2,.7,.2,1) both;animation-delay:.12s}
.mk-stagger>*:nth-child(4){animation:mk-panelinR .4s cubic-bezier(.2,.7,.2,1) both;animation-delay:.17s}
.mk-stagger>*:nth-child(5){animation:mk-panelinR .4s cubic-bezier(.2,.7,.2,1) both;animation-delay:.22s}
.mk-stagger>*:nth-child(n+6){animation:mk-panelinR .4s cubic-bezier(.2,.7,.2,1) both;animation-delay:.27s}

/* ---- som-* aliases kept for existing call sites; values aligned to the prototype ---- */
@keyframes som-rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@keyframes som-linedraw { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes som-flick { 0%,100%{opacity:1} 48%{opacity:1} 49%{opacity:.35} 50%{opacity:1} 92%{opacity:1} 93%{opacity:.5} 94%{opacity:1} }
@keyframes som-spin { to { transform: rotate(360deg); } }
@keyframes toast-in { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- typography ---- */
h3 {
  margin: 0 0 10px; font-family: var(--font-display); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: 2px; color: var(--text-strong);
  display: flex; align-items: center; gap: 8px; position: relative;
}
h3::before {
  content: ""; width: 12px; height: 11px; flex: none; background: var(--accent);
  transform: skewX(-22deg); opacity: 0.9;
}
h3::after {
  content: ""; position: absolute; left: 0; bottom: -5px; height: 1px; width: 100%;
  background: linear-gradient(90deg, var(--line-strong), transparent);
  transform-origin: left; animation: som-linedraw 0.5s cubic-bezier(.2,.7,.2,1) both;
}
h4 { margin: 10px 0 5px; font-family: var(--font-display); font-weight: 500; font-size: 11px;
  text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted-strong); }

/* ---- diegetic frame primitives ---- */
.hud-frame {
  position: relative; background: var(--surface1);
  border: 1px solid var(--line); padding: 12px;
  clip-path: polygon(var(--notch) 0, 100% 0, 100% calc(100% - var(--notch)), calc(100% - var(--notch)) 100%, 0 100%, 0 var(--notch));
}
.corner-tick { position: absolute; width: 9px; height: 9px; border: 1px solid var(--accent); opacity: 0.5; pointer-events: none; }
.corner-tick.tl { top: 5px; left: 5px; border-right: 0; border-bottom: 0; }
.corner-tick.tr { top: 5px; right: 5px; border-left: 0; border-bottom: 0; }
.corner-tick.bl { bottom: 5px; left: 5px; border-right: 0; border-top: 0; }
.corner-tick.br { bottom: 5px; right: 5px; border-left: 0; border-top: 0; }
.serial { font-family: var(--font-mono); font-size: 10px; letter-spacing: 2px; color: var(--muted); text-transform: uppercase; }

/* ---- controls ---- */
button {
  background: var(--surface2); color: var(--text); border: 1px solid var(--line);
  padding: 6px 11px; cursor: pointer; font-family: var(--font-display); font-size: 12px;
  letter-spacing: 0.6px; transition: border-color .12s, color .12s, background .12s;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}
button:hover { border-color: var(--line-strong); color: var(--text-strong); background: var(--surface3); }
button.secondary { opacity: 0.85; }
button.active { border-color: var(--action); color: var(--action); }
button.cta { border-color: var(--action); color: var(--action); background: rgba(70,200,255,0.08); }
button.cta:hover { background: rgba(70,200,255,0.16); color: #cdeeff; }
input, select {
  background: #06070a; color: var(--text); border: 1px solid var(--line);
  padding: 8px 10px; font-family: var(--font-body); font-size: 13px;
}
input:focus, select:focus { outline: none; border-color: var(--action); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 18px; font-size: 13px; font-family: var(--font-mono); }
.mono { font-family: var(--font-mono); }

/* ---- login ---- */
.login-screen {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 28% 18%, rgba(20,40,70,0.5) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 90%, rgba(70,200,255,0.06) 0%, transparent 50%),
    var(--bg);
}
.login-box {
  position: relative; width: 360px; padding: 34px 32px 30px; display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(12,13,18,0.7), rgba(8,9,12,0.92));
  border: 1px solid var(--line-strong); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 40px 100px -20px #000d;
}
.login-symbol { width: 48px; height: 48px; object-fit: contain; margin: 0 auto 16px; display: block; }
.login-wordmark { height: 22px; object-fit: contain; display: block; margin: 0 auto; }
.login-eyebrow { font-family: var(--font-mono); font-size: 9px; letter-spacing: 5px; color: var(--muted); margin-top: 8px; text-align: center; }
.tagline { font-size: 11px; color: var(--muted); margin: 13px 0 24px; letter-spacing: 0.5px; text-align: center; }
.login-label { font-family: var(--font-mono); font-size: 9px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); margin: 0 0 5px; display: block; }
.login-box input { margin-bottom: 14px; }
.login-box .cta { width: 100%; padding: 13px; background: var(--action); color: #06070a; font-weight: 700; letter-spacing: 2.5px; text-transform: uppercase; font-size: 12px; border: 0; clip-path: none; cursor: pointer; }
.login-register { font-size: 10.5px; color: var(--muted); margin-top: 15px; text-align: center; }
.login-register span { color: var(--action); cursor: pointer; }

/* ---- layout ---- */
#game { display: flex; flex-direction: column; height: 100vh; }
#topbar {
  display: flex; align-items: center; gap: 0; padding: 0; height: 46px; flex: 0 0 46px;
  background: linear-gradient(180deg, var(--surface1), var(--surface0));
  border-bottom: 1px solid var(--line-strong);
  box-shadow: 0 1px 0 #00000080, inset 0 1px 0 #ffffff08; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 16px 0 15px; height: 100%; border-right: 1px solid var(--line); }
.brand-mark { width: 23px; height: 23px; opacity: 0.95; }
.brand-wordmark { height: 13px; opacity: 0.95; }
#topbar nav { display: flex; align-items: center; gap: 2px; padding: 0 8px; height: 100%; }
.navbtn { height: 30px; padding: 0 13px; background: transparent; border: 1px solid transparent; border-radius: 4px; color: #8295b8; font-weight: 600; font-size: 12px; letter-spacing: 0.6px; }
.navbtn:hover { color: #eaf2ff; background: transparent; }
.navbtn.active { border-color: transparent; color: #eaf2ff; }
.crumbs { display: flex; align-items: center; gap: 7px; padding: 0 12px; height: 100%; font-size: 12px; color: #5f7398; min-width: 0; }
.crumbs .navbtn { color: #5f7398; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* long system/planet names truncate with … instead of hard-clipping */
.crumbs .navbtn.active { color: #eaf2ff; }
.crumb-sep { color: #2b3f66; font-size: 12px; }
.crumbs:empty, .crumbs:not(:has(.navbtn:not(.hidden))) { border: 0; padding: 0; }
#topbar .spacer { flex: 1; }
#topgauges { display: flex; align-items: center; height: 100%; }
.vital { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; padding: 0 14px; height: 100%; border-left: 1px solid var(--line); min-width: 64px; }
.vital .vl { font-size: 9px; letter-spacing: 1.2px; text-transform: uppercase; color: #5f7398; }
.vital .vv { font-family: var(--font-mono); font-size: 14px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
/* secondary vitals (Standing + Tick) — merged into ONE compact stacked block so the primary line
   (power gauges · colony resources · credits) owns the bar and the crumbs get room to breathe */
.vital.duo { padding: 0 11px; min-width: 0; gap: 1px; border-left-color: var(--line-strong); }
.vital.duo .mini { display: flex; align-items: baseline; gap: 6px; }
.vital.duo .ml { font-size: 8px; letter-spacing: 1px; text-transform: uppercase; color: #5f7398; opacity: 0.8; }
.vital.duo .mv { font-family: var(--font-mono); font-size: 10.5px; font-weight: 500; color: #8295b8; font-variant-numeric: tabular-nums; opacity: 0.8; }
/* current-colony resource strip — an always-visible glance at the planet/system you're viewing.
   Right-aligned to sit flush with the Credits/Standing/Tick vitals (a consistent right cluster). */
.colstrip { align-items: flex-end; min-width: 0; max-width: 230px; }
.colstrip .vl { display: flex; align-items: center; gap: 5px; }
.colstrip .cs-row { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 3px; }
.colstrip .cs-res { display: inline-flex; align-items: center; gap: 3px; font-family: var(--font-mono); font-size: 11px; color: var(--text); font-variant-numeric: tabular-nums; }
.colstrip .res-icon { width: 12px; height: 12px; }
.colstrip .lp { color: #ffb84d; }
.colstrip.lowpwr .vl { color: #ffb84d; }
.cmdr { display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 100%; border-left: 1px solid var(--line); }
.cmdr-name { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.cmdr-name #hud-user { font-size: 11.5px; color: #c8d6ee; font-family: var(--font-body); }
.cmdr-rank { font-size: 9.5px; letter-spacing: 0.5px; color: #5f7398; font-family: var(--font-mono); }
#btn-logout { width: 30px; height: 30px; padding: 0; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: var(--surface0); border-radius: 4px; color: #5f7398; }
.cmdr-name { cursor: pointer; }
/* top-bar meta entries: notifications, settings, vanguard pass */
.topmeta { position: relative; width: 38px; height: 100%; border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: color .12s; }
.topmeta:hover { color: var(--text); }
.notif-dot { position: absolute; top: 9px; right: 8px; min-width: 13px; height: 13px; padding: 0 3px; border-radius: 7px; background: var(--accent2); color: #06070a; font-family: var(--font-mono); font-size: 8px; font-weight: 700; display: flex; align-items: center; justify-content: center; line-height: 1; }
.notif-dot.hidden { display: none; }
.vanguard-chip { display: flex; align-items: center; gap: 9px; padding: 0 13px; height: 100%; border: 0; border-left: 1px solid var(--line); background: transparent; cursor: pointer; }
.vg-tier { width: 26px; height: 26px; border: 1px solid var(--accent2); background: rgba(255,107,82,0.12); display: flex; align-items: center; justify-content: center; color: var(--accent2); font-family: var(--font-display); font-size: 11px; font-weight: 700; clip-path: polygon(6px 0, 100% 0, 100% 100%, 0 100%, 0 6px); }
.vg-meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.vg-lbl { font-size: 8px; color: var(--muted); letter-spacing: 1.3px; font-family: var(--font-mono); }
.vg-bar { width: 54px; height: 3px; background: #10131a; margin-top: 3px; display: block; overflow: hidden; }
.vg-bar > span { display: block; height: 100%; width: 64%; background: var(--accent2); }
main { flex: 1; display: flex; min-height: 0; position: relative; }
aside { width: 252px; background: var(--surface0); padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
/* cmdfloat: floating command panel, top-left of the viewport, shown on selection (display toggle; motion via the inner card's .mk-anim-card) */
#left {
  position: absolute; left: 9px; top: 9px; width: 264px; z-index: 25;
  display: none; flex-direction: column; gap: 8px;
  background: transparent; border: 0; padding: 0;
  max-height: calc(100% - 18px); overflow-y: auto; pointer-events: auto;
}
#left.shown { display: flex; }
#right { width: 50px; flex: 0 0 50px; display: flex; padding: 0; gap: 0; }
#viewport { flex: 1; position: relative; min-width: 0; background: #05080f; }
#canvas { display: block; width: 100%; height: 100%; cursor: crosshair; image-rendering: pixelated; }
/* diegetic ambiance overlays (above the canvas, below the HUD widgets) */
#vignette { position: absolute; inset: 0; pointer-events: none; z-index: 5; background: radial-gradient(125% 125% at 50% 42%, transparent 56%, rgba(3,5,10,0.58) 100%); }
#scanlines { position: absolute; inset: 0; pointer-events: none; z-index: 6; opacity: 0.05; background: repeating-linear-gradient(0deg, rgba(120,180,255,0.5) 0px, rgba(120,180,255,0.5) 1px, transparent 1px, transparent 3px); }
/* diegetic viewport chrome (corner brackets + telemetry micro-labels) */
.vp-corner { position: absolute; width: 15px; height: 15px; opacity: 0.45; pointer-events: none; z-index: 7; }
.vp-corner.tl { top: 7px; left: 7px; border-top: 1px solid var(--line-strong); border-left: 1px solid var(--line-strong); }
.vp-corner.tr { top: 7px; right: 7px; border-top: 1px solid var(--line-strong); border-right: 1px solid var(--line-strong); }
.vp-corner.bl { bottom: 7px; left: 7px; border-bottom: 1px solid var(--line-strong); border-left: 1px solid var(--line-strong); }
.vp-corner.br { bottom: 7px; right: 7px; border-bottom: 1px solid var(--line-strong); border-right: 1px solid var(--line-strong); }
.vp-micro { position: absolute; pointer-events: none; z-index: 7; font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 1.6px; color: var(--muted); line-height: 1.9; }
.vp-ops { top: 16px; left: 20px; }
.vp-tel { top: 16px; right: 20px; text-align: right; }
.vp-accent { color: var(--accent); }
.vp-bars { display: flex; gap: 3px; justify-content: flex-end; margin-top: 2px; }
.vp-bars span { height: 3px; background: var(--line-strong); }
.vp-bars span:first-child { width: 14px; background: var(--accent); }
.vp-bars span:nth-child(2) { width: 8px; }
.vp-bars span:nth-child(3) { width: 5px; }

/* ---- viewport overlays ---- */
#view-hint {
  /* bottom-CENTER, one row ABOVE the bottom control strip: at bottom:12 it shared a line with the
     heatmap/lanes pill (left:200) and clipped behind the minimap at narrow widths. */
  position: absolute; bottom: 40px; left: 50%; transform: translateX(-50%); text-align: center; max-width: 46%;
  font-size: 11px; color: var(--muted);
  font-family: var(--font-mono); pointer-events: none; text-shadow: 0 1px 2px #000; letter-spacing: 0.4px;
}
#minimap-frame {
  position: absolute; left: 12px; bottom: 12px; z-index: 8;
  border: 1px solid var(--line-strong); background: #06070a; overflow: hidden;
}
#minimap-frame .mm-head {
  display: flex; align-items: center; justify-content: space-between; padding: 5px 8px;
  border-bottom: 1px solid var(--line); background: rgba(255,255,255,0.02);
  font-family: var(--font-mono); font-size: 8px; letter-spacing: 1.5px; color: var(--muted);
}
#minimap { display: block; cursor: pointer; background: #06070a; }
#mm-scale { letter-spacing: 1px; }
.mm-tick { position: absolute; width: 10px; height: 10px; pointer-events: none; }
.mm-tick.tl { top: -1px; left: -1px; border-top: 1px solid var(--accent); border-left: 1px solid var(--accent); }
.mm-tick.br { bottom: -1px; right: -1px; border-bottom: 1px solid var(--accent); border-right: 1px solid var(--accent); }
/* ambient comms overlay (v2): bottom-left above the minimap, transparent until focused */
/* bottom:200px (not the prototype's 190) clears our taller bottom-left minimap; z-index:5 per proto */
#chat { position: absolute; left: 12px; bottom: 200px; width: 340px; max-height: 40%; z-index: 5; display: flex; flex-direction: column; justify-content: flex-end; pointer-events: none; }
/* galaxy legend panel — bottom-right (the only viewport corner free of OPS/TEL chrome + minimap + chat) */
#galaxy-legend { position: absolute; right: 12px; bottom: 12px; z-index: 7; pointer-events: none; display: none; }
@keyframes mk-chatfade { 0% { opacity: 0; transform: translateY(4px); } 9% { opacity: 1; transform: none; } 68% { opacity: 1; } 100% { opacity: 0; } }
#objective-banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 15;
  background: var(--surface0); border: 1px solid var(--line-strong); border-left: 3px solid var(--action);
  padding: 8px 16px; font-size: 13px; cursor: pointer; max-width: 60%;
  box-shadow: 0 2px 12px rgba(0,0,0,0.5); animation: som-rise 0.3s both;
}
#objective-banner b { color: var(--text-strong); }
#objective-banner .od { color: var(--muted); font-size: 12px; }
.dir-done { opacity: 0.55; }
.dir-active { border-left: 3px solid var(--action); }
.dir-reward { color: var(--accent2); font-size: 11.5px; font-family: var(--font-mono); }
#btn-heatmap, #btn-lanes {
  /* bottom-left, right of the minimap (prototype heatui slot) — was top-left, colliding with the
     OPS micro-labels + the floating command card whenever a unit was selected. The heatmap button is
     surface-only and the lanes button galaxy-only, so they never show together → they share this slot. */
  position: absolute; left: 200px; bottom: 12px; z-index: 16; font-size: 11px;
  background: var(--surface0); border: 1px solid var(--line);
}
#btn-heatmap.on, #btn-lanes.on { border-color: var(--action); color: var(--action); box-shadow: 0 0 8px rgba(70,200,255,0.35); }
#heatmap-legend {
  /* bottom-right (shares the corner with #galaxy-legend, but they're mutually exclusive by view) —
     was top-left under the OPS labels + command card. */
  position: absolute; right: 12px; bottom: 12px; z-index: 7; pointer-events: none;
  background: var(--surface0); border: 1px solid var(--line); padding: 8px 11px;
  font-size: 11.5px; max-width: 210px;
  clip-path: polygon(8px 0, 100% 0, 100% 100%, 0 100%, 0 8px);
}
#heatmap-legend .lg { display: flex; align-items: center; gap: 6px; padding: 1px 0; }
#heatmap-legend .sw { width: 12px; height: 12px; flex: none; }
#heatmap-legend h4 { margin: 0 0 5px; }

/* ---- tooltip — matches the HUD frame language: notched glass + glowing accent edge ---- */
#tooltip {
  position: fixed; pointer-events: none; z-index: 100;
  background: linear-gradient(180deg, var(--surface2), var(--surface1));
  border: 1px solid var(--line-strong); padding: 10px 13px; font-size: 12px; max-width: 300px;
  line-height: 1.5; box-shadow: 0 10px 28px #000d, inset 0 1px 0 #ffffff0a;
  /* notch top-left + bottom-right, like hudFrame's diagonal cut corners */
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}
/* the HUD's signature: a short glowing accent bar emerging from the top-left notch */
#tooltip::before {
  content: ''; position: absolute; left: 0; top: 0; width: 34px; height: 2px;
  background: var(--accent); box-shadow: 0 0 7px var(--accent);
}
#tooltip .tt-title { color: var(--text-strong); font-family: var(--font-display); font-weight: 600; letter-spacing: 0.5px; }
#tooltip .sub { color: var(--muted); font-size: 11px; }
#tooltip .kv span:last-child { color: var(--accent2); font-family: var(--font-mono); }

/* ---- toasts ---- */
#toasts {
  position: absolute; top: 12px; right: 12px; width: 288px; z-index: 22; display: flex;
  flex-direction: column; gap: 7px; align-items: stretch; pointer-events: none;
}
/* UX-11: when the right pane is open, shift toasts to its LEFT so they don't stack on top of it.
   #toasts is a following sibling of #pane, so this fires only while the pane is visible. */
#pane:not(.hidden) ~ #toasts { right: 310px; }
.toast {
  background: var(--surface0); border: 1px solid var(--line); border-left: 3px solid var(--action);
  padding: 8px 13px; font-size: 12.5px; max-width: 340px; animation: toast-in 0.25s ease-out; transition: opacity 0.6s;
  clip-path: polygon(7px 0, 100% 0, 100% 100%, 0 100%, 0 7px);
}
.toast.warn { border-left-color: var(--warn); }
.toast.good { border-left-color: var(--good); }
.toast.fading { opacity: 0; }

/* ---- left command card (matches the prototype command card) ---- */
.cmd-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.cmd-tile {
  width: 46px; height: 46px; flex: none; border: 1px solid var(--line-strong); background: #0a1322;
  display: flex; align-items: center; justify-content: center;
  clip-path: polygon(8px 0, 100% 0, 100% 100%, 0 100%, 0 8px);
}
.cmd-tile.self { box-shadow: inset 0 0 16px -3px var(--action); }
.cmd-tile.enemy { box-shadow: inset 0 0 16px -3px var(--warn); }
.cmd-tile.pirate { box-shadow: inset 0 0 16px -3px var(--bad); }
.cmd-head .nm { font-size: 13px; color: var(--text-strong); font-weight: 600; }
.cmd-head .fac { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.cmd-head .vet { color: #ffd24a; }
.statbar { margin-bottom: 7px; }
.statbar .sbh { display: flex; justify-content: space-between; font-size: 9.5px; color: var(--muted); margin-bottom: 3px; letter-spacing: 0.5px; text-transform: uppercase; }
.statbar .sbh .v { color: var(--text); font-family: var(--font-mono); text-transform: none; }
.statbar .sbt { height: 5px; background: #05080f; overflow: hidden; border: 1px solid var(--line); }
.statbar .sbt > div { height: 100%; transition: width 0.3s cubic-bezier(.2,.7,.2,1); }

/* ---- command verb grid (prototype 3-col verb buttons) ---- */
.verbgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
.verbbtn {
  position: relative; height: 44px; border: 1px solid var(--line); background: rgba(255,255,255,0.015);
  color: var(--muted-strong); cursor: pointer; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; clip-path: none; transition: .12s;
}
.verbbtn:hover { border-color: var(--line-strong); background: rgba(255,255,255,0.06); color: var(--text-strong); }
.verbbtn .vg { font-size: 14px; line-height: 1; }
.verbbtn .vl { font-size: 8.5px; letter-spacing: 1px; text-transform: uppercase; font-family: var(--font-display); }
.verbbtn .vk { position: absolute; top: 3px; right: 4px; font-size: 7.5px; color: var(--accent); font-family: var(--font-mono); }
.verbbtn::before { content: ""; position: absolute; top: 0; left: 0; width: 8px; height: 8px; border-top: 1px solid var(--line-strong); border-left: 1px solid var(--line-strong); }

/* ---- left command panel ---- */
.group-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; cursor: pointer; }
.group-row:hover { color: var(--text-strong); }
.sel-icon { image-rendering: pixelated; flex: none; background: #06070a; }
.res-icon { width: 14px; height: 14px; image-rendering: pixelated; vertical-align: -2px; margin-right: 4px; }
.subsection { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 6px; }
.subsection .rowbtns { margin-top: 4px; }
.buildbtn .group-row, .prodbtn .group-row { cursor: inherit; }

/* ---- right icon rail + floating pane (SOMNARI Command Console) ---- */
#rail {
  width: 50px; flex: 0 0 50px; display: flex; flex-direction: column; gap: 2px;
  padding: 6px 5px; background: var(--surface0); border-left: 1px solid var(--line);
}
#rail button {
  position: relative; height: 46px; border: 1px solid transparent; background: transparent;
  color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center;
  clip-path: none; transition: color .14s, background .14s, border-color .14s;
}
#rail button:hover { color: var(--text); }
#rail button.active { color: var(--text-strong); background: rgba(255,255,255,0.06); border-color: var(--line-strong); }
#rail button .tind {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%) skewX(-22deg);
  width: 3px; height: 18px; background: var(--accent); box-shadow: 0 0 8px var(--accent); opacity: 0; transition: opacity .14s;
}
#rail button.active .tind { opacity: 1; }
#rail .logbadge { position: absolute; top: 7px; right: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px var(--accent); }
#pane {
  position: absolute; right: 9px; top: 9px; bottom: 9px; width: 290px; z-index: 20;
  display: flex; flex-direction: column; min-height: 0;
  background: linear-gradient(180deg, rgba(10,12,16,0.97), rgba(8,9,12,0.97));
  border: 1px solid var(--line-strong); box-shadow: 0 14px 44px -14px rgba(0,0,0,0.93);
  animation: som-panelin .22s cubic-bezier(.2,.7,.2,1);
}
@keyframes som-panelin { from { transform: translateX(12px); } to { transform: none; } }
.hdr-serial { margin-left: auto; animation: mk-flick 7s steps(1) infinite; }
#pane.hidden { display: none !important; }
#pane-head { flex: 0 0 auto; }
#pane-body { flex: 1; overflow-y: auto; padding: 13px 13px 16px; font-size: 13px; }
/* (the live pane header is generated by paneHead() in app.js — the old .pane-hd CSS was dead + divergent) */

/* ---- cards / lists ---- */
.card {
  position: relative; background: transparent; border: 0; border-top: 1px solid var(--line);
  padding: 12px 13px 13px 16px; margin-bottom: 0; font-size: 12.5px; transition: background 0.16s; clip-path: none;
}
.card::before { content: ""; position: absolute; left: 0; top: 12px; width: 2px; height: 14px; background: var(--line-strong); transition: background 0.16s; }
.card:hover { background: var(--surface1); }
.card:hover::before { background: var(--accent); }
.card b { color: var(--text-strong); }
.card .sub { color: var(--muted); font-size: 11.5px; }
/* event log rows */
.log-row { display: flex; gap: 9px; padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 11.5px; }
.log-row .log-dot { flex: 0 0 9px; font-size: 9px; margin-top: 3px; color: var(--muted-strong); }
.log-row.build .log-dot, .log-row.construction .log-dot { color: var(--action); }
.log-row.combat .log-dot, .log-row.threat .log-dot, .log-row.attack .log-dot { color: var(--bad); }
.log-row.market .log-dot, .log-row.trade .log-dot { color: #ffb84d; }
.log-row.research .log-dot { color: var(--good); }
.log-row.rank .log-dot, .log-row.score .log-dot { color: #ffd24a; }
.log-row .log-msg { color: var(--text); line-height: 1.4; }
.log-row .log-meta { color: var(--muted); font-family: var(--font-mono); font-size: 9.5px; margin-top: 2px; letter-spacing: 0.5px; }
/* fleet table */
.fleet-list { border: 1px solid var(--line); }
.fleet-row { display: grid; grid-template-columns: 16px 1fr auto 44px; gap: 8px; padding: 7px 9px; border-bottom: 1px solid var(--line); align-items: center; font-size: 11.5px; }
.fleet-row.head { background: var(--surface2); font-family: var(--font-display); font-size: 9.5px; letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); }
.fleet-row.unit { cursor: pointer; transition: background 0.14s; }
.fleet-row.unit:hover { background: var(--surface1); }
.fleet-row .hp { text-align: right; font-family: var(--font-mono); }
.kv { display: flex; justify-content: space-between; gap: 18px; padding: 1.5px 0; }
.kv span:first-child { white-space: nowrap; }
.kv span:last-child { text-align: right; }
.kv span:last-child { color: var(--accent2); font-family: var(--font-mono); }
.kv.rank-me { color: var(--action); font-weight: 600; }
.prodbtn { display: block; width: 100%; text-align: left; margin-bottom: 4px; font-size: 12px; }
.prodbtn .cost { color: var(--accent2); font-size: 11px; display: block; font-family: var(--font-mono); }
/* build-menu item — prototype _buildBuildMenu row: icon box + name/category + accent2 cost */
.buildbtn {
  position: relative; display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 8px 9px; font-size: 12px; border: 1px solid var(--line);
  background: rgba(255,255,255,0.015); color: var(--text); cursor: pointer; transition: border-color .14s, background .14s;
}
.buildbtn:not(:disabled):hover { border-color: var(--line-strong); background: rgba(255,255,255,0.04); }
.buildbtn.active { border-color: var(--accent); background: rgba(255,255,255,0.06); }
.buildbtn:disabled { opacity: 0.4; cursor: not-allowed; }
.buildbtn.cant-afford { opacity: 0.55; }
.buildbtn .cost { color: var(--accent2); font-size: 9.5px; font-family: var(--font-mono); margin-top: 2px; line-height: 1.3; overflow-wrap: anywhere; } /* in the bi-body column → wraps within the button, never overflows */
.bi-icon { width: 30px; height: 30px; flex: 0 0 30px; background: rgba(70,200,255,0.06); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; }
.bi-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.bi-name { color: var(--text-strong); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.bi-cat { font-family: var(--font-mono); font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.rowbtns { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.bar { height: 4px; background: #05080f; overflow: hidden; margin-top: 4px; border: 1px solid var(--line); }
.bar > div { height: 100%; background: var(--action); }
.qrow { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.qx { padding: 0 6px; font-size: 11px; line-height: 1.5; color: var(--muted); }
.qx:hover { color: var(--bad); border-color: var(--bad); }

/* ---- chat ---- */

/* ---- admin page ---- */
.admin-wrap { max-width: 1100px; margin: 0 auto; padding: 20px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.admin-card { background: var(--surface1); border: 1px solid var(--line); padding: 14px; }
.admin-card h3 { margin-top: 0; }
.admin-card label { display: block; font-size: 12px; color: var(--muted); margin: 6px 0 2px; }
.admin-card input, .admin-card select, .admin-card textarea { width: 100%; }
.admin-card textarea {
  background: #06070a; color: var(--text); border: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 12px; min-height: 90px;
}
pre.out {
  background: #06070a; border: 1px solid var(--line); padding: 8px; font-size: 11.5px;
  font-family: var(--font-mono); overflow-x: auto; color: var(--good); max-height: 220px; overflow-y: auto;
}
table.metrics { width: 100%; border-collapse: collapse; font-size: 12.5px; font-family: var(--font-mono); }
table.metrics td, table.metrics th { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; }

/* ===== Main Menu (cinematic pre-game front end) ===== */
:root { --mm-acc: #46c8ff; }
#menu-root { position: fixed; inset: 0; z-index: 200; overflow: hidden; background: #04060b; font-family: 'Saira', 'Segoe UI', sans-serif; color: #c2c8d2; }
#menu-root.hidden { display: none; }
.mm-corner { position: absolute; width: 20px; height: 20px; pointer-events: none; }
@keyframes mm-kb { 0% { transform: scale(1.04); } 100% { transform: scale(1.15) translate(-1.6%, -1%); } }
@keyframes mm-kb2 { 0% { transform: scale(1.13) translate(1.2%, .6%); } 100% { transform: scale(1.04); } }
@keyframes mm-rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes mm-fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes mm-pulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
@keyframes mm-eq { 0%, 100% { transform: scaleY(.25); } 50% { transform: scaleY(1); } }
@keyframes mm-gate { 0%, 100% { opacity: .4; } 50% { opacity: 1; } }
.mm-navitem { position: relative; display: flex; align-items: center; gap: 15px; padding: 10px 6px; cursor: pointer; color: #9aa4b6; transition: color .18s, transform .18s; text-decoration: none; background: none; border: none; text-align: left; width: 100%; font-family: inherit; }
.mm-navitem:hover { color: #f1f3f7; transform: translateX(8px); }
.mm-navitem:hover .mm-navbar { transform: scaleX(1); }
.mm-navitem:hover .mm-navnum { color: var(--mm-acc); }
.mm-navitem:hover .mm-navchev { opacity: 1; transform: none; }
.mm-navbar { position: absolute; left: 0; bottom: 1px; height: 1px; width: 100%; background: linear-gradient(90deg, var(--mm-acc, #46c8ff), transparent); transform: scaleX(0); transform-origin: left; transition: transform .24s cubic-bezier(.2, .7, .2, 1); }
.mm-field { width: 100%; padding: 11px 13px; background: rgba(4, 7, 12, .72); border: 1px solid #243345; color: #e8edf5; font-size: 13px; outline: none; font-family: 'JetBrains Mono', monospace; transition: border-color .15s; letter-spacing: 1px; }
.mm-field:focus { border-color: #46c8ff; }
.mm-field::placeholder { color: #4a5366; }
#menu-root button:focus-visible, #menu-root a:focus-visible, #menu-root input:focus-visible { outline: 2px solid var(--mm-acc); outline-offset: 2px; }
/* reduced motion: drop Ken Burns + the heavy SVG displacement warp (particles freeze in JS) */
body.mk-noanim #menu-root .mm-bg-img { animation: none !important; filter: none !important; }

/* ---- narrow-viewport guards (windowed play): below ~900px HUD layers started stacking on each other —
   the galaxy SECURITY legend under the directive banner, and the command card over half the map. ---- */
@media (max-width: 900px) {
  #galaxy-legend { display: none !important; } /* legend data also lives in system tooltips */
  #left { width: 232px; }
  #objective-banner { max-width: 46vw; }
}
