/* A Captain's Story : HUD styles. Race skins override the CSS variables (see ui/themes.json). */
:root {
  --primary: #1f6fff; --primary-dim: #0b2c6b; --secondary: #39c0ff; --accent: #42ff8a;
  --text: #9fd2ff; --text-bright: #e6f4ff; --warning: #ff4040; --caution: #ffb020;
  --panel-bg: rgba(2, 10, 30, 0.82); --panel-border: #1f6fff; --font: 'Bahnschrift', 'Segoe UI', sans-serif;
  --mono: 'Consolas', 'Lucida Console', monospace;
  --left-width: clamp(290px, 17vw, 380px);
  --right-width: clamp(260px, 15vw, 340px);
  --right2-width: clamp(220px, 13vw, 290px);
  --toolbar-width: 34px;
  --panel-gap: 6px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: var(--text); font-family: var(--font); user-select: none; }
#viewport { position: fixed; inset: 0; }
.hidden { display: none !important; }

/* ---------- HUD frame ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; font-size: 12px; z-index: 3; }
#hud .panel { pointer-events: auto; background: var(--panel-bg); border: 2px solid var(--panel-border); border-radius: 10px;
  box-shadow: 0 0 10px color-mix(in srgb, var(--primary) 40%, transparent) inset; padding: 6px 8px; }
#hud .panel h3 { margin: 0 0 4px; font-size: 11px; letter-spacing: 2px; color: var(--secondary); text-transform: uppercase; font-weight: 600; }
/* #212 panel heading: drag box, title, minimize bar and close × */
#hud .panel h3.panel-heading { display: flex; align-items: center; gap: 5px; }
#hud .panel .panel-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#hud .panel .panel-grip { flex: none; width: 9px; height: 9px; border: 1px solid var(--primary); border-radius: 2px; cursor: grab; pointer-events: auto; touch-action: none;
  background: repeating-linear-gradient(0deg, var(--primary-dim) 0 1px, transparent 1px 3px); }
#hud .panel .panel-grip:hover { background: var(--primary); }
#hud .panel.dragging { opacity: 0.55; }
#hud .panel .panel-controls { flex: none; display: flex; gap: 2px; }
#hud .panel button.panel-ctl { pointer-events: auto; width: 15px; height: 15px; padding: 0; border: none; background: transparent; color: var(--secondary); cursor: pointer;
  font: 600 13px/13px var(--font); display: flex; align-items: center; justify-content: center; letter-spacing: 0; border-radius: 3px; }
#hud .panel button.panel-ctl:hover { color: var(--text-bright); background: color-mix(in srgb, var(--primary) 45%, transparent); }
#hud .panel button.panel-close:hover { background: color-mix(in srgb, var(--warning) 60%, transparent); }
#hud .panel button.panel-min i { display: block; width: 8px; height: 0; border-bottom: 2px solid currentColor; margin-top: 6px; }
#hud .panel.minimized > :not(h3) { display: none !important; }
#hud .panel.minimized h3 { margin-bottom: 0; }
#hud .panel.minimized button.panel-min i { margin-top: 0; height: 6px; border: 1px solid currentColor; }
.panel-drop-marker { position: fixed; height: 3px; background: var(--accent); box-shadow: 0 0 6px var(--accent); pointer-events: none; z-index: 50; }
/* #89 panel columns: placed by hud.js layoutPanels() (left column first, then columns from the upper right) */
#panel-area { position: absolute; inset: 0; pointer-events: none; }
.hud-column { position: absolute; top: 6px; bottom: 6px; display: flex; flex-direction: column; gap: var(--panel-gap); pointer-events: none; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; }
.hud-column.left { width: var(--left-width); }
.hud-column.right { width: var(--right-width); }
.hud-column > .panel { flex: none; }
#top-bar { position: absolute; top: 4px; left: var(--left-span, calc(var(--toolbar-width) + var(--left-width) + 14px)); right: 8px; height: 36px; display: flex; gap: 12px; align-items: center; justify-content: space-between; }
#bottom-bar { position: absolute; bottom: 4px; left: var(--left-span, calc(var(--toolbar-width) + var(--left-width) + 14px)); right: 8px; height: 40px; display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.bar-block { pointer-events: auto; display: flex; flex-direction: column; align-items: center; min-width: 170px; background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 6px; padding: 2px 10px; }
.bar-block label { font-size: 9px; letter-spacing: 2px; color: var(--secondary); }
.meter { width: 160px; height: 9px; background: #111; border: 1px solid var(--primary-dim); position: relative; }
.meter > div { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 50%, white)); }
.meter.warn > div { background: linear-gradient(90deg, var(--warning), var(--caution)); }
.clock { font-family: var(--mono); font-size: 15px; color: var(--text-bright); }

/* ---------- buttons ---------- */
button.sfc { pointer-events: auto; background: var(--primary-dim); color: var(--text-bright); border: 1px solid var(--primary); border-radius: 5px;
  font-family: var(--font); font-size: 11px; padding: 3px 7px; cursor: pointer; letter-spacing: 1px; text-transform: uppercase; }
button.sfc:hover { background: var(--primary); }
button.sfc.active { background: var(--accent); color: var(--accent-text, #001); border-color: var(--accent); }
button.sfc.danger { border-color: var(--warning); }
button.sfc.danger.active { background: var(--warning); color: #fff; }
button.sfc:disabled { opacity: 0.35; cursor: default; }
.row { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.small { font-size: 10px; }
.mono { font-family: var(--mono); }
.bright { color: var(--text-bright); }
.warning { color: var(--warning); }
.caution { color: var(--caution); }
.good { color: var(--accent); }

/* ---------- helm ---------- */
#helm .grid3 button { height: 30px; font-size: 14px; }

/* ---------- weapons ---------- */
.weapon-list { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; scrollbar-width: thin; }
.weapon { display: grid; grid-template-columns: 18px 1fr 56px 50px; gap: 4px; align-items: center; padding: 1px 3px; border-radius: 3px; cursor: pointer; pointer-events: auto; }
.weapon:hover { background: color-mix(in srgb, var(--primary) 30%, transparent); }
.weapon.selected { outline: 1px solid var(--accent); }
.weapon .dot { width: 12px; height: 12px; border-radius: 50%; background: #333; border: 1px solid #666; }
.weapon .dot.ready { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.weapon .dot.arming { background: var(--caution); }
.weapon .dot.dead { background: var(--warning); }
.weapon .dot.inarc { outline: 2px solid var(--text-bright); }
.weapon .status { font-family: var(--mono); font-size: 10px; text-align: right; }
.weapon .charge { grid-column: 2 / 5; height: 3px; background: #222; border-radius: 2px; overflow: hidden; margin-top: -1px; }
.weapon .charge i { display: block; height: 100%; width: 0; background: var(--caution); transition: width 0.25s linear; }
.weapon .charge.full i { background: var(--accent); }

/* ---------- shields ---------- */
#shield-display { position: relative; width: 116px; height: 116px; flex: none; }   /* #355 was 150: the buttons beside it were cut off */
/* #156 shield ring on the left, the buttons to the right of it */
.shield-layout { display: flex; align-items: center; gap: 8px; }
.shield-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
/* #355 labels fit: one button per line, the full width of the side, no letter spacing */
.shield-side .shield-buttons { display: flex; flex-direction: column; gap: 3px; }
.shield-side button.sfc.small { font-size: 12px; letter-spacing: 0; padding: 3px 4px; white-space: normal; line-height: 1.15; }
.shield-side .shield-slider input[type=range] { min-width: 0; flex: 1; width: 100%; }
#shield-display svg { width: 100%; height: 100%; }

/* ---------- ssd ---------- */
.ssd { display: flex; flex-wrap: wrap; gap: 2px; }
.ssd .sys { font-family: var(--mono); font-size: 10px; padding: 1px 3px; border: 1px solid var(--primary-dim); border-radius: 2px; }
.ssd .sys.damaged { border-color: var(--caution); color: var(--caution); }
.ssd .sys.destroyed { border-color: var(--warning); color: var(--warning); text-decoration: line-through; }

/* ---------- messages ---------- */
#message-log { position: absolute; left: var(--left-span, calc(var(--toolbar-width) + var(--left-width) + 14px)); bottom: 52px; width: 460px; max-height: 200px; overflow: hidden;
  font-family: var(--mono); font-size: 11px; display: flex; flex-direction: column-reverse; pointer-events: none; text-shadow: 0 0 3px #000; }
#message-log div { color: var(--text); }
#message-log div.damage { color: #ff7050; }
#message-log div.hit { color: #ffd060; }
#message-log div.info { color: var(--secondary); }
#center-banner { position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%); font-size: 44px; font-weight: 700; color: var(--text-bright);
  text-shadow: 0 0 14px var(--primary); letter-spacing: 4px; pointer-events: none; }

/* ---------- target box ---------- */
#target-panel .name { font-size: 14px; color: var(--text-bright); }
.labels-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
.unit-label { position: absolute; transform: translate(-50%, 0); font-family: var(--mono); font-size: 11px; white-space: nowrap; text-shadow: 0 0 3px #000; pointer-events: auto; cursor: pointer; }
.seeker-tag, .mine-tag { font-size: 10px; transform: translate(-50%, -100%); }
.seeker-tag.inbound { color: #ff5040; font-weight: bold; } .seeker-tag.enemy { color: #ffb050; } .seeker-tag.friend { color: #70e8ff; }
.mine-tag.enemy { color: #ff6050; } .mine-tag.friend { color: #60ff90; }
.known-card { position: fixed; z-index: 5; min-width: 210px; max-width: 300px; padding: 8px 10px; background: rgba(4, 10, 24, 0.92); border: 1px solid var(--primary); border-radius: 6px;
  font-family: var(--mono); font-size: 11px; color: var(--text); pointer-events: auto; box-shadow: 0 0 12px rgba(0, 0, 0, 0.6); }
.known-card .name { color: #ff8a7a; font-weight: bold; font-size: 12px; margin-bottom: 3px; }
.known-card .close { position: absolute; top: 2px; right: 6px; cursor: pointer; color: var(--text-dim, #889); }
.unit-label .shields { font-size: 9px; }
/* user 2026-11-10: a little ring around each fighter / shuttle (screen size, so it shows at any zoom) */
.craft-ring { position: absolute; width: 16px; height: 16px; margin: -9px 0 0 -9px; border: 1px solid currentColor; border-radius: 50%; pointer-events: auto; cursor: pointer; opacity: 0.8; box-shadow: 0 0 3px #000; }
.craft-ring.enemy { color: #ff6a5a; } .craft-ring.friend { color: #6af0ff; } .craft-ring.player { color: #b0ffb0; } .craft-ring.targeted { color: #ffff60; border-width: 2px; opacity: 1; }
.unit-label.enemy { color: #ff6a5a; } .unit-label.friend { color: #6af0ff; } .unit-label.player { color: #b0ffb0; } .unit-label.targeted { color: #ffff60; font-weight: bold; }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.55); }
.modal .menu-box { max-width: 900px; }

/* ---------- menu ---------- */
#menu { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(10,20,60,0.75), rgba(0,0,0,0.95)); z-index: 10; }
#menu.hidden { display: none; }
.menu-box { width: min(1100px, 94vw); max-height: 92vh; overflow-y: auto; background: var(--panel-bg); border: 2px solid var(--panel-border); border-radius: 14px; padding: 20px 26px; }
.menu-box h1 { margin: 0 0 4px; font-size: 34px; letter-spacing: 6px; color: var(--text-bright); text-shadow: 0 0 12px var(--primary); }
.menu-box h2 { font-size: 15px; letter-spacing: 3px; color: var(--secondary); margin: 16px 0 6px; }
.menu-box select, .menu-box input { background: #020a1e; color: var(--text-bright); border: 1px solid var(--primary); border-radius: 4px; padding: 4px; font-family: var(--font); }
.card-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.card { border: 1px solid var(--primary-dim); border-radius: 8px; padding: 8px; cursor: pointer; }
.card:hover, .card.selected { border-color: var(--accent); background: color-mix(in srgb, var(--primary) 18%, transparent); }
.card .title { color: var(--text-bright); font-size: 14px; }
.help { font-size: 12px; line-height: 1.5; }
.help kbd { background: #111; border: 1px solid #555; border-radius: 3px; padding: 0 4px; font-family: var(--mono); }

/* special-function grid: keep labels readable in narrow columns */
#hud .grid3 button { letter-spacing: 0; padding-left: 2px; padding-right: 2px; }

/* ================================================================== #69 toolbar, columns, status block */
#hud-toolbar { position: absolute; left: 2px; top: 4px; width: calc(var(--toolbar-width) - 4px); display: flex; flex-direction: column; gap: 3px; pointer-events: auto; z-index: 4; }
#hud-toolbar button.sfc.tool { width: 100%; height: 28px; padding: 2px; display: flex; align-items: center; justify-content: center; opacity: 0.55; }
#hud-toolbar button.sfc.tool.active { opacity: 1; background: var(--primary-dim); color: var(--text-bright); border-color: var(--accent); box-shadow: 0 0 6px color-mix(in srgb, var(--accent) 60%, transparent) inset; }
#hud-toolbar button.sfc.tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#hud-toolbar .tool-all { margin-top: 6px; }
.status-block { position: absolute; left: var(--left-span, calc(var(--toolbar-width) + var(--left-width) + 14px)); top: 48px; max-width: 360px; pointer-events: auto; padding-right: 16px;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.35; text-shadow: 0 0 3px #000, 0 0 2px #000; }
.status-block button.status-close { position: absolute; top: 1px; right: 1px; pointer-events: auto; width: 15px; height: 15px; padding: 0; border: none; background: transparent;
  color: var(--secondary); cursor: pointer; font: 600 13px/13px var(--font); border-radius: 3px; opacity: 0.6; }
.status-block:hover button.status-close { opacity: 1; }
.status-block button.status-close:hover { color: var(--text-bright); background: color-mix(in srgb, var(--warning) 60%, transparent); }
.status-block .cs-line { white-space: nowrap; color: var(--text); }
/* pending HUD-1 own condition: shock gauge (D23) and critical-hit badges (D8) */
.status-block .cs-own { white-space: normal; }
.status-block .cs-critical { display: inline-block; padding: 0 4px; margin: 1px 2px 1px 0; border: 1px solid var(--warning); border-radius: 3px; font-size: 0.85em; }
.status-block .cs-gauge { display: inline-block; width: 48px; height: 6px; border: 1px solid var(--primary); vertical-align: middle; }
.status-block .cs-gauge i { display: block; height: 100%; background: var(--warning); }
.status-block .cs-range { color: #ff7a6a; }
.status-block .cs-defense { color: #5dff7a; }
.status-block .cs-attack { color: #ffd36a; }
.status-block .cs-good { color: #5dff7a; }
.status-block .cs-ready { color: #ffb050; }
.status-block .cs-wait { color: #ff6050; }

/* ---------- tooltips, toasts, dialogs (#65, #67) */
.hud-tooltip { position: fixed; z-index: 40; max-width: 360px; padding: 6px 9px; background: rgba(2, 8, 22, 0.96); color: var(--text-bright); border: 1px solid var(--primary);
  border-radius: 5px; font-family: var(--font); font-size: 12px; line-height: 1.4; white-space: pre-line; pointer-events: none; box-shadow: 0 2px 10px rgba(0,0,0,0.7); }
.hud-toast { position: fixed; z-index: 41; top: 16%; left: 50%; transform: translateX(-50%); padding: 7px 14px; background: rgba(2, 8, 22, 0.95); border: 1px solid var(--primary);
  border-radius: 6px; color: var(--text-bright); font-size: 13px; pointer-events: none; }
.hud-toast.caution { border-color: var(--caution); color: var(--caution); }
.hud-toast.warning { border-color: var(--warning); color: #ffb0a0; }
.hud-dialog { z-index: 30; }
.hud-dialog-box { max-width: 460px !important; }
.hud-dialog-buttons { margin-top: 14px; justify-content: flex-end; }
/* #95 disabled controls stay readable: grey text on a dark grey face, not black on dark blue */
button.sfc.disabled, button.sfc.disabled:hover { opacity: 1; cursor: not-allowed; background: #1a202b; color: #8d9bb0; border-color: #3b4659; box-shadow: none; }
body.het-targeting canvas { cursor: crosshair !important; }

/* ---------- bottom bar: draggable speed bar (#61), alert buttons (#62) */
.speed-block { cursor: ew-resize; min-width: 230px; touch-action: none; }
.speed-track { position: relative; width: 210px; height: 8px; margin: 2px 0 1px; background: #111; border: 1px solid var(--primary-dim); }
.speed-track .speed-actual { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, var(--primary), var(--secondary)); }
.speed-track .speed-throttle { position: absolute; top: -3px; bottom: -3px; width: 3px; margin-left: -1px; background: var(--accent); box-shadow: 0 0 5px var(--accent); }
.alert-buttons { gap: 3px; margin-top: 1px; }
.alert-buttons button.sfc { padding: 1px 6px; font-size: 10px; }
/* #171 weapon status WS-0 … WS-III (S4.0) */
.alert-buttons button.sfc.ws-button { padding: 1px 4px; }
.ws-button.ws-0.active { background: #5a6878; border-color: #a0b0c0; color: #fff; }
.ws-button.ws-1.active { background: #20b048; border-color: #50ff80; color: #001; }
.ws-button.ws-2.active { background: #d8b818; border-color: #ffe860; color: #110; }
.ws-button.ws-3.active { background: var(--warning); color: #fff; }
.ws-row { gap: 3px; }

/* ---------- helm (SFC layout) */
#helm .helm-name { font-family: var(--mono); color: var(--text-bright); border: 1px solid var(--primary); border-radius: 4px; padding: 1px 6px; margin-bottom: 5px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#helm .helm-pad { display: flex; flex-direction: column; gap: 4px; }
#helm .helm-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
#helm .helm-row.two { grid-template-columns: repeat(2, 1fr); padding: 0 16%; }
#helm button.helm-btn { height: 38px; font-size: 20px; padding: 0; display: flex; align-items: center; justify-content: center; letter-spacing: 0; }
#helm button.helm-btn .glyph { font-size: 22px; line-height: 1; font-family: 'Segoe UI Symbol', 'Segoe UI', sans-serif; }
#helm button.helm-btn.het { font-size: 15px; font-weight: 700; }
#helm button.helm-btn.het.active { background: var(--caution); color: #110; border-color: var(--caution); animation: het-pulse 0.9s ease-in-out infinite alternate; }
@keyframes het-pulse { from { box-shadow: 0 0 2px var(--caution); } to { box-shadow: 0 0 12px var(--caution); } }
#helm .helm-het { display: flex; justify-content: space-between; align-items: center; margin: 5px 4px; font-size: 10px; letter-spacing: 2px; color: var(--secondary); }
#helm .helm-het b { color: var(--text-bright); border: 1px solid var(--primary); border-radius: 4px; padding: 0 8px; font-size: 14px; min-width: 64px; text-align: right; }
#helm button.helm-full { width: 76%; margin: 4px 12% 2px; height: 34px; font-size: 13px; }
#helm .helm-info { margin-top: 4px; line-height: 1.35; }

/* ---------- weapon grouping view (#63) */
.wg-head { display: flex; justify-content: space-between; align-items: center; gap: 4px; margin-bottom: 3px; }
.wg-quick button.sfc, .wg-views button.sfc { padding: 1px 5px; font-size: 10px; }
.wg-view { position: relative; width: 100%; aspect-ratio: 1 / 0.86; border: 1px solid var(--primary-dim); border-radius: 6px; overflow: hidden;
  background: radial-gradient(ellipse at center, rgba(20, 50, 110, 0.35), rgba(0, 4, 14, 0.7)); }
.wg-ship { position: absolute; left: 50%; top: 50%; height: 92%; max-width: 92%; object-fit: contain; transform: translate(-50%, -50%); opacity: 0.55;
  filter: grayscale(1) sepia(1) hue-rotate(175deg) saturate(3.2) brightness(0.85); pointer-events: none; }
.wg-outline { position: absolute; left: 34%; right: 34%; top: 6%; bottom: 6%; border: 2px solid color-mix(in srgb, var(--primary) 55%, transparent);
  border-radius: 48% 48% 30% 30% / 30% 30% 18% 18%; pointer-events: none; }
.wg-icons { position: absolute; inset: 4% 3%; }
.wg-icon { position: absolute; width: 13%; height: calc(86% / var(--wg-rows, 7)); max-height: 44px; min-height: 26px; transform: translate(-50%, -50%); cursor: pointer;
  border: 2px solid #1a3d8a; border-radius: 4px; background: #0d2a6e; overflow: hidden; box-shadow: 0 0 0 1px #000; }
.wg-icon .fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(0deg, #ff7a18, #c03c00); opacity: 0.85; transition: height 0.25s linear; }
.wg-icon .tag { position: absolute; left: 2px; top: 0; font-family: var(--mono); font-size: 9px; color: #cfe4ff; text-shadow: 0 0 2px #000; letter-spacing: 0; }
.wg-icon .dots { position: absolute; right: 2px; top: 2px; bottom: 2px; display: grid; grid-template-columns: 5px 5px; grid-auto-rows: 5px; gap: 2px; align-content: center; }
.wg-icon .dots i { display: block; width: 5px; height: 5px; border-radius: 50%; background: #3a4a6a; }
.wg-icon .dots i.ready { background: #4dff6a; box-shadow: 0 0 3px #4dff6a; }
.wg-icon .dots i.charging { background: #4dd8ff; }
.wg-icon .dots i.fired { background: #ffb040; }
.wg-icon .dots i.offline, .wg-icon .dots i.empty { background: #556; }
.wg-icon .dots i.dead { background: #e03020; }
.wg-icon.ready { border-color: #2f7dff; background: #1150d0; }
.wg-icon.dead { background: #2a0806; border-color: #7a1810; }
.wg-icon.inarc { box-shadow: 0 0 0 1px #000, 0 0 6px 1px rgba(255, 255, 140, 0.75); }
.wg-icon.selected { border-color: #ffe23a; }
.wg-icon.arc-mode { background: transparent; border-color: transparent; box-shadow: none; aspect-ratio: 1; width: auto; }
.wg-icon.arc-mode.selected { border-color: #ffe23a; border-radius: 4px; }
.wg-icon.arc-mode svg { width: 100%; height: 100%; display: block; }
.wg-icon .arc-ring { fill: rgba(0, 10, 30, 0.8); stroke: #2f7dff; stroke-width: 1.2; }
.wg-icon .arc-fill { fill: rgba(60, 200, 255, 0.55); }
.wg-icon.ready .arc-fill { fill: rgba(80, 255, 120, 0.6); }
.wg-icon.dead .arc-fill { fill: rgba(200, 40, 20, 0.6); }
.wg-icon .arc-ship { fill: #e6f4ff; }
.wg-unlisted { margin-top: 2px; color: var(--caution); }
.wg-mines { margin-top: 4px; }
.caption { font-size: 9px; letter-spacing: 1.5px; color: var(--secondary); text-transform: uppercase; }

/* ---------- fire screen */
.fc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.fc-name { font-size: 11px; letter-spacing: 2px; color: var(--text-bright); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-expected { font-size: 10px; color: var(--secondary); white-space: nowrap; }
.fc-row { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.fc-row button.fc-all { width: 30px; height: 30px; border-radius: 50%; padding: 0; font-size: 17px; flex: none; }
.fc-row button.fc-fire { flex: none; font-size: 17px; padding: 3px 14px; font-weight: 700; letter-spacing: 3px; }
.fc-charge { flex: 1; height: 8px; background: #111; border: 1px solid var(--primary-dim); border-radius: 4px; overflow: hidden; }
.fc-charge i { display: block; height: 100%; width: 0; background: var(--caution); transition: width 0.25s linear; }
.fc-charge.full i { background: var(--accent); }
.fc-lamp { width: 24px; height: 24px; border-radius: 50%; background: #123; border: 1px solid var(--primary-dim); flex: none; }
.fc-lamp.on { background: radial-gradient(circle at 40% 35%, #e8ffff, #7ff0ff 55%, #2aa8c8); box-shadow: 0 0 8px #7ff0ff; }
.fc-modes { display: flex; gap: 8px; align-items: center; }
.fc-mode-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; flex: 1; }
.fc-mode-buttons button.fc-mode { font-size: 11px; padding: 3px 4px; letter-spacing: 1.5px; }
.fc-ovals { display: flex; gap: 3px; width: 74px; flex-wrap: wrap; justify-content: center; }
.fc-ovals i { display: block; width: 11px; height: 22px; border-radius: 50%; background: #334; }
.fc-ovals i.ready { background: #20c050; }
.fc-ovals i.charging { background: #40e0d0; }
.fc-ovals i.fired { background: #ff9a30; }
.fc-ovals i.dead { background: #c02818; }
.fc-toggles { margin-top: 4px; }
.fc-toggles button.sfc { padding: 2px 5px; font-size: 10px; }

/* ---------- small panels */
.power-row .caption { width: 82px; }
.hangar-status { color: var(--text-bright); margin: 1px 0 4px 6px; }
.raid-system { max-width: 150px; background: #020a1e; color: var(--text-bright); border: 1px solid var(--primary); border-radius: 3px; font-size: 11px; }
.board-count { width: 46px; background: #020a1e; color: var(--text-bright); border: 1px solid var(--primary); border-radius: 3px; font-size: 11px; }

/* ---------- phones / small windows */
@media (max-width: 900px) {
  :root { --left-width: min(290px, 80vw); --right-width: min(260px, 80vw); --right2-width: min(240px, 80vw); }
  #top-bar, #bottom-bar { flex-wrap: wrap; height: auto; }
  .status-block { font-size: 10px; }
}
#hud-toolbar button.sfc.tool.tool-all { opacity: 0.9; }

/* ---------- B284-3 phones: the desktop panels (270 px) are made narrower and smaller so two of them leave the middle of the
   screen free; each column scrolls on its own (touch-action pan-y) */
@media (max-width: 700px) {
  :root { --left-width: min(210px, 46vw); --right-width: min(200px, 44vw); --right2-width: min(190px, 44vw); }
  #hud { font-size: 10px; }
  #hud .panel { padding: 4px 5px; border-width: 1px; border-radius: 7px; }
  #hud .panel h3 { font-size: 9px; letter-spacing: 1px; }
  #hud .panel button.sfc.small { font-size: 9px; padding: 2px 4px; }
  .hud-column { touch-action: pan-y; }
}
@media (max-height: 520px) and (max-width: 950px) {   /* landscape phone */
  #hud { font-size: 10px; }
  .hud-column { touch-action: pan-y; }
}

/* ---------- #79 phones / touch screens: bigger toolbar buttons */
body.sfc-mobile #hud { --toolbar-width: 44px; }
body.sfc-mobile #hud-toolbar button.sfc.tool { height: 34px; }

/* ---------- #87 shields */
#shield-display text { font-family: var(--mono); }
#shield-display .shield-value { fill: #03101c; font-size: 21px; font-weight: 700; }   /* #356 (#11) larger */
#shield-display .shield-value.off { fill: #b8c4d4; }
#shield-display .shield-extra { fill: #03101c; font-size: 15px; font-weight: 700; }
#shield-display .shield-band { fill: #5ff0ff; stroke: #000; stroke-width: 1; }
#shield-display .shield-band.planned { fill: none; stroke: #8fb0d0; stroke-width: 1.5; stroke-dasharray: 4 3; }
#shield-display .shield-extra.planned { font-size: 11px; font-weight: 400; font-style: italic; }
#shield-display .shield-extra.off { fill: #b8c4d4; }
#shield-display .shield-center { fill: #e8f4ff; font-size: 15px; }
#shield-display .shield-center.general { fill: #ffe060; font-size: 14px; }
.shield-buttons { display: grid; grid-template-columns: 1fr; gap: 3px; }
.shield-buttons button.sfc { padding: 3px 2px; letter-spacing: 0.5px; font-size: 12px; }
.shield-buttons .shield-auto356 { font-size: 11px; color: #ffe060; }
/* #356 (#2) power priority panel, (#18) tug pods */
.priority356-row { flex-wrap: nowrap; gap: 4px; }
.priority356-row .priority356-rank { width: 2.2em; text-align: right; }
.priority356-row .priority356-label { flex: 1; min-width: 0; }
.priority356-row .priority356-power { width: 3.4em; text-align: right; }
.priority356-row.caution .priority356-power { color: #ffb040; }
.priority356-reserve { margin-top: 4px; color: #ffe060; }
.pods356 { margin-top: 4px; }
.shield-slider { margin-top: 0; flex-wrap: nowrap; }
.shield-slider input[type=range] { flex: 1; min-width: 60px; accent-color: var(--accent); pointer-events: auto; }

/* ---------- #88 power read-out */
.power-info { display: grid; grid-template-columns: minmax(0, 1fr); font-size: 11px; line-height: 1.5; }
.power-info .pw-line { display: flex; justify-content: space-between; gap: 6px; white-space: nowrap; }
.power-info .pw-line span { color: var(--secondary); min-width: 0; overflow: hidden; text-overflow: ellipsis; }   /* #355 the value always shows; a long label shortens */
.power-info .pw-line b { color: var(--text-bright); font-weight: 400; flex: none; }
.power-info .caution { grid-column: 1 / -1; }
.panel-info { white-space: pre-line; line-height: 1.4; margin-bottom: 3px; }

/* ---------- #95 hangar */
.hangar-bays { margin: 3px 0; }
.hangar-craft { display: flex; flex-direction: column; gap: 2px; max-height: 150px; overflow-y: auto; scrollbar-width: thin; margin: 3px 0; }
.craft-chip { display: flex; justify-content: space-between; gap: 6px; padding: 2px 6px; border: 1px solid var(--primary-dim); border-radius: 3px; cursor: pointer; pointer-events: auto; font-size: 11px; color: var(--text-bright); }
.craft-chip span { color: var(--text); font-family: var(--mono); font-size: 10px; }
.craft-chip.selected { border-color: #ffe23a; background: rgba(255, 226, 58, 0.12); }
.craft-chip.gone { opacity: 0.5; }
.hangar-actions { margin-top: 3px; }
.hangar-actions button.sfc { padding: 2px 5px; font-size: 10px; letter-spacing: 0.5px; }

/* ---------- #96 / #97 crew and system icons */
.crew-icons { display: flex; flex-wrap: wrap; gap: 5px; margin: 3px 0; }
.crew-icon { font-family: var(--mono); font-size: 12px; color: var(--secondary); border: 1px solid var(--primary-dim); border-radius: 3px; padding: 0 5px; pointer-events: auto; }
.crew-icon b { margin-left: 3px; color: var(--text-bright); font-weight: 400; }
.crew-icon.guard { color: #ffb050; }
.crew-icon.officer { color: #ffd84a; border-color: #a08420; }
.system-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 3px; max-height: 150px; overflow-y: auto; scrollbar-width: thin; margin: 3px 0; }
.system-icon { border: 1px solid var(--primary-dim); border-radius: 3px; text-align: center; cursor: pointer; pointer-events: auto; padding: 2px 1px; font-size: 9px; color: var(--text-bright); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.system-icon i { display: block; font-style: normal; font-size: 14px; color: var(--secondary); }
.system-icon.selected { border-color: #ffe23a; background: rgba(255, 226, 58, 0.15); }

/* ---------- #113 mines */
.mine-racks { display: flex; flex-direction: column; gap: 2px; margin: 3px 0; }
.mine-rack { display: flex; align-items: center; gap: 6px; }
.mine-rack.gone { opacity: 0.5; }
.mine-icons { flex: 1; }
.mine-icons i { font-style: normal; color: #ffb050; margin-right: 2px; }

/* ---------- #94 damage */
.repair-info { font-size: 11.5px; }
.damage-list { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; scrollbar-width: thin; margin-top: 3px; }
.damage-row { display: flex; justify-content: space-between; gap: 6px; font-family: var(--mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--primary-dim); border-radius: 3px; cursor: pointer; pointer-events: auto; color: var(--caution); }
.damage-row b { font-weight: 400; color: var(--text-bright); }
.damage-row.current { border-color: var(--accent); color: var(--accent); }
.damage-row.priority { border-color: #ffe23a; }
.damage-row.norepair { color: #ff8070; cursor: default; }
.damage-row.info { cursor: default; color: var(--text); border-style: dashed; }
.damage-row.good { color: var(--accent); }

/* ---------- #99 scout channels */
.ew-scout-head { margin-top: 5px; }
.scout-channels { display: flex; flex-direction: column; gap: 1px; margin-top: 3px; }
.scout-channel { font-family: var(--mono); font-size: 11px; padding: 1px 4px; border-radius: 3px; cursor: pointer; pointer-events: auto; color: var(--text); }
.scout-channel.selected { color: var(--text-bright); background: color-mix(in srgb, var(--primary) 30%, transparent); }

/* ---------- #92 tactical radar */
.radar-holder { position: relative; }
.radar-holder canvas { display: block; cursor: pointer; }
.radar-zoom { position: absolute; top: 4px; right: 4px; display: flex; flex-direction: column; gap: 2px; }
.radar-zoom button.sfc { width: 22px; height: 20px; padding: 0; font-size: 13px; line-height: 1; letter-spacing: 0; }
.radar-scale { position: absolute; right: 6px; bottom: 4px; font-size: 10px; color: var(--secondary); pointer-events: none; text-shadow: 0 0 3px #000; }

/* ---------- #91 graphical SSD view (hud_ssdview.js): target panel, SSD window, Encyclopedia */
.target-ssd { margin-top: 4px; }
.ssdv { display: grid; grid-template-columns: minmax(0, 1fr) 16px auto; gap: 6px; align-items: stretch; }
.ssdv .wg-icon { cursor: default; }
.ssdv .wg-icon.unknown { background: #1c2433; border-color: #3a4558; }
.ssdv-hull { position: relative; background: #0b0f16; border: 1px solid var(--primary-dim); border-radius: 3px; overflow: hidden; }
.ssdv-hull i { position: absolute; left: 0; right: 0; bottom: 0; height: 100%; background: linear-gradient(0deg, var(--accent), color-mix(in srgb, var(--accent) 50%, white)); transition: height 0.25s linear; }
.ssdv-hull.warn i { background: linear-gradient(0deg, var(--warning), var(--caution)); }
.ssdv-hull.unknown i { background: #3a4558; }
.ssdv-hull span { position: absolute; top: 3px; left: 0; right: 0; writing-mode: vertical-rl; font-family: var(--mono); font-size: 10px; color: #fff; text-shadow: 0 0 3px #000, 0 0 2px #000; display: flex; align-items: center; }
.ssdv-stats { font-size: 10.5px; line-height: 1.3; min-width: 72px; color: var(--text); font-family: var(--mono); }
.ssdv-shields { margin-bottom: 4px; color: var(--text-bright); }
.ssdv-shields b { color: var(--secondary); font-weight: 400; }
.ssdv-lines span { color: var(--secondary); }
.ssdv-unknown { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--caution); font-size: 12px; text-align: center; }
.modal.ssd .ssdv { max-width: 560px; margin: 6px 0 4px; }
/* #79 phones: the bars (when shown) use the full width and wrap instead of running off the screen */
body.sfc-mobile #hud #top-bar, body.sfc-mobile #hud #bottom-bar { left: calc(var(--toolbar-width) + 4px) !important; height: auto; flex-wrap: wrap; justify-content: flex-start; gap: 4px; }
body.sfc-mobile #hud .bar-block { min-width: 0; }

/* #129 weapons of a target our side has not seen yet are not drawn (D17.4) */
.ssdv .wg-icon .dots i.unseen { display: none; }

/* #126 weapon group buttons 1–0 */
.wg-groups { margin-top: 4px; gap: 2px; flex-wrap: nowrap; }
.wg-groups button.sfc.wg-group { padding: 1px 0; min-width: 0; flex: 1; font-size: 10px; letter-spacing: 0; }
.wg-groups button.sfc.wg-group.empty { opacity: 0.55; }

/* #132 fleet mine ships */
.mine-ship-head { margin-top: 5px; }
.mine-ships .mine-ship { justify-content: space-between; color: var(--text-bright); }

/* ================================================================== batch 142 */
/* #151/#171 weapon status read-out colour; the WS-III control blinks while contacts are known below WS-III */
.alert-block .clock.ws-0 { color: #a0b0c0; }
.alert-block .clock.ws-1 { color: #50ff80; }
.alert-block .clock.ws-2 { color: #ffe860; }
.alert-block .clock.ws-3 { color: var(--warning); }
/* #355 Power Allocation: weapon status line, weapons-not-arming warning, ARM WEAPONS */
.arm-row355 { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.arm-row355 .ws-line355 span { color: var(--secondary); }
.arm-row355 .ws-line355 b { font-weight: 700; letter-spacing: 1px; }
.arm-row355 .ws-line355 b.ws-0 { color: #a0b0c0; } .arm-row355 .ws-line355 b.ws-1 { color: #50ff80; }
.arm-row355 .ws-line355 b.ws-2 { color: #ffe860; } .arm-row355 .ws-line355 b.ws-3 { color: var(--warning); }
.arm-row355 .ws-line355 span.caution { color: var(--caution); }
.arm-row355 .arm-warning355 { white-space: normal; line-height: 1.3; }
@keyframes sfc-contact-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.alert-block.contact-prompt .alert-buttons .ws-3 { animation: sfc-contact-blink 0.8s step-end infinite; box-shadow: 0 0 8px #ff3020; }
#hud.sfc-classic .alert-block.contact-prompt .cl-light-red { animation: sfc-contact-blink 0.8s step-end infinite; background: transparent; box-shadow: 0 0 10px 2px #ff3020; }
/* #159 repair progress */
.repair-progress { margin: 3px 0 4px; }
.repair-progress-text { color: var(--text-bright); font-size: 11px; }
.repair-progress .meter { width: 100%; height: 7px; margin-top: 2px; }
.repair-queue { opacity: 0.8; }
/* #160 emergency operations */
.emergency-leave { margin-top: 4px; }
.self-destruct-info { margin-top: 4px; font-size: 12px; }
/* #162 self-destruct countdown, centre of the screen */
.self-destruct-box { position: absolute; top: 16%; left: 50%; transform: translateX(-50%); pointer-events: auto; z-index: 6; min-width: 220px;
  padding: 8px 14px; text-align: center; background: rgba(40, 0, 0, 0.85); border: 2px solid var(--warning); border-radius: 8px; box-shadow: 0 0 14px #ff302080; }
.self-destruct-box .sd-title { color: var(--warning); font-weight: 700; letter-spacing: 3px; font-size: 13px; }
.self-destruct-box .sd-time { color: #fff; font-size: 28px; font-weight: 700; margin: 2px 0 4px; }
.self-destruct-box .meter { width: 100%; height: 6px; margin-bottom: 6px; }
.self-destruct-box .meter > div { background: var(--warning); }
.self-destruct-box button.sfc { width: 100%; font-size: 14px; }
/* #170 phones: the HUD stays inside the safe area (notch / rounded corners / home bar; index.html viewport-fit=cover), the toolbar always
   fits on screen — it scrolls when it is taller than the screen, and on short (landscape) screens its buttons flow into a second column */
#hud { top: env(safe-area-inset-top, 0px); right: env(safe-area-inset-right, 0px); bottom: env(safe-area-inset-bottom, 0px); left: env(safe-area-inset-left, 0px); }
body.sfc-mobile #hud-toolbar { max-height: calc(100% - 8px); overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }
@media (max-height: 560px) {
  body.sfc-mobile #hud-toolbar { display: grid; grid-auto-flow: column; grid-template-rows: repeat(auto-fill, 30px); grid-auto-columns: 38px; gap: 3px;
    width: max-content; height: calc(100% - 8px); overflow: hidden; }
  body.sfc-mobile #hud-toolbar button.sfc.tool { height: 30px; }
  body.sfc-mobile #hud-toolbar .tool-all { margin-top: 0; }
}
body #menu, body #menu.front { padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }

/* ================================================================== batch 171 */
/* #172 spectator mode after the player's ship is lost: only the message log and the banner of the HUD stay */
#hud.spectating > :not(#message-log):not(#center-banner) { display: none !important; }
.spectator-bar { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 21; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center;
  max-width: calc(100vw - 32px); padding: 6px 10px; background: rgba(0, 8, 20, 0.78); border: 1px solid var(--primary-dim, #2a5a8a); border-radius: 4px;
  font: 12px/1.3 Consolas, monospace; color: var(--text-bright, #cfe0f0); }
.spectator-bar .spectator-title { color: var(--warning, #ff5040); font-weight: bold; letter-spacing: 1px; }
.spectator-bar .spectator-follow { min-width: 220px; text-align: center; }
.spectator-bar .spectator-follow .friend { color: #8fe08f; }
.spectator-bar .spectator-follow .foe { color: #ff9070; }
.spectator-bar .spectator-state { color: #ffd070; }
/* #183 scenario options and #177 legendary officers in the briefing modal */
.modal .scenario-options, .modal .officer-shop { max-height: 30vh; overflow-y: auto; }
/* #192 LEGENDARY OFFICERS panel (src/ui/hud_officers.js) */
.officer-card { border: 1px solid var(--primary-dim); border-radius: 4px; padding: 3px 4px; margin-bottom: 4px; display: flex; flex-direction: column; gap: 2px; }
.officer-head { font-size: 11px; color: var(--text-bright); }
.officer-head.hurt { color: var(--caution); }
.officer-head.dead { color: #ff8070; text-decoration: line-through; }
.officer-passive { cursor: default; }
.officer-action { gap: 4px; align-items: center; flex-wrap: wrap; }
.officer-edr-boxes { display: flex; flex-wrap: wrap; gap: 2px 8px; max-height: 90px; overflow-y: auto; }
.officer-check { white-space: nowrap; font-size: 11px; }

/* #286 touch pad for a battle on a phone / tablet (src/ui/touchcontrols.js) */
.touch-pad { position: fixed; right: calc(6px + env(safe-area-inset-right, 0px)); bottom: calc(6px + env(safe-area-inset-bottom, 0px)); z-index: 8;
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px; pointer-events: none; touch-action: none; user-select: none; -webkit-user-select: none; }
.touch-pad.hidden { display: none; }
.touch-pad button.sfc { pointer-events: auto; touch-action: none; -webkit-tap-highlight-color: transparent; }
.touch-grid { display: grid; grid-template-columns: repeat(2, 52px); grid-auto-rows: 42px; gap: 5px; padding: 5px; border-radius: 10px;
  background: rgba(0, 8, 22, 0.45); border: 1px solid color-mix(in srgb, var(--primary) 45%, transparent); }
.touch-pad .touch-button { min-width: 0; padding: 0; font-size: 13px; font-weight: 700; letter-spacing: 0.05em; opacity: 0.88; }
.touch-pad .touch-button.held, .touch-pad .touch-button:active { background: var(--accent); color: var(--accent-text, #001); opacity: 1; }
.touch-pad .touch-left, .touch-pad .touch-right { font-size: 22px; }
.touch-pad .touch-fire { background: color-mix(in srgb, var(--warning, #ff5040) 55%, #000); border-color: var(--warning, #ff5040); }
.touch-pad .touch-menu { grid-column: 1 / 3; }
.touch-pad .touch-fold { min-height: 26px; padding: 0 10px; font-size: 12px; opacity: 0.8; }
.touch-pad.collapsed .touch-grid { display: none; }
@media (max-height: 520px) {   /* landscape phone: a wider, lower pad */
  .touch-grid { grid-template-columns: repeat(3, 50px); grid-auto-rows: 38px; }
  .touch-pad .touch-menu { grid-column: auto; }
}
/* the message log and the bottom bar stay clear of the pad on a phone */
body.sfc-touch #hud #message-log { max-width: calc(100vw - 150px); }
