@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@500;700;900&family=Rajdhani:wght@400;500;600;700&display=swap');

:root {
  --bg: #05070c;
  --bg-deep: #020306;
  --panel: #10141d;
  --panel-2: #161c28;
  --border: #2a3446;
  --border-bright: #445269;
  --text: #dbe4ee;
  --text-dim: #7c8aa0;
  --accent: #ffb703;       /* imperial console amber */
  --accent-hover: #ffc93c;
  --cyan: #4fd8e8;         /* hologram / rebel HUD cyan */
  --p0: #4fd8e8;
  --p1: #ff5d5d;
  --gold: #ffb703;
  --danger: #ff5d5d;
  --success: #6bd97a;

  --f-empire: #9aa5b8;
  --f-rebels: #e2711d;
  --f-republic: #8fb8e8;
  --f-separatists: #b5651d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-x: hidden;
  color: var(--text);
  font-family: "Rajdhani", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
}

/* Themed thin scrollbars everywhere, so a scrollbar showing up never reads as
   a jarring default-OS element -- and scrollbar-gutter: stable (set on the
   individual scroll containers) keeps its appearance from ever shifting
   layout width when content height crosses the scroll threshold. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-bright) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: var(--accent); }

body {
  background:
    radial-gradient(1px 1px at 10% 15%, #fff, transparent),
    radial-gradient(1px 1px at 25% 60%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 40% 30%, #cfe, transparent),
    radial-gradient(1px 1px at 60% 80%, #fff, transparent),
    radial-gradient(1px 1px at 75% 20%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 85% 55%, #cde, transparent),
    radial-gradient(1px 1px at 95% 85%, #fff, transparent),
    radial-gradient(1px 1px at 15% 90%, #fff, transparent),
    radial-gradient(1px 1px at 50% 10%, #fff, transparent),
    radial-gradient(1px 1px at 33% 45%, #fff, transparent),
    radial-gradient(ellipse at 30% 0%, #101a2e 0%, transparent 55%),
    radial-gradient(ellipse at 90% 90%, #1a0f1f 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-deep), var(--bg) 40%, var(--bg-deep));
  background-repeat: repeat, repeat, repeat, repeat, repeat, repeat, repeat, repeat, repeat, repeat, no-repeat, no-repeat, no-repeat;
  background-size: 220px 220px, 260px 260px, 300px 300px, 240px 240px, 280px 280px, 320px 320px, 250px 250px, 270px 270px, 230px 230px, 290px 290px, 100% 100%, 100% 100%, 100% 100%;
}

h1, h2, h3, .brand, .score-vp, .hud-font {
  font-family: "Orbitron", "Rajdhani", sans-serif;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 10px 18px;
  background: linear-gradient(180deg, rgba(16,20,29,0.95), rgba(16,20,29,0.85));
  border-bottom: 1px solid var(--border-bright);
  flex-shrink: 0;
  box-shadow: 0 2px 18px rgba(255, 183, 3, 0.06);
}

.brand {
  font-weight: 900;
  letter-spacing: 4px;
  font-size: 17px;
  color: var(--accent);
  background: none;
  border: none;
  padding: 2px 4px;
  font-family: "Orbitron", sans-serif;
  text-shadow: 0 0 12px rgba(255,183,3,0.5);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  border-radius: 3px;
  transition: text-shadow 0.15s, background 0.15s;
}
.brand:hover {
  text-shadow: 0 0 18px rgba(255,183,3,0.85);
  background: rgba(255,183,3,0.08);
}
.brand:active { text-shadow: 0 0 6px rgba(255,183,3,0.5); }
.brand .home-icon { font-size: 14px; margin-right: 4px; }

#statusline {
  flex: 1 1 100px;
  min-width: 0;
  color: var(--text-dim);
  font-size: 14px;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#trainingBadge {
  font-size: 11px;
  color: var(--cyan);
  border: 1px solid rgba(79,216,232,0.4);
  background: rgba(79,216,232,0.07);
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: "Orbitron", sans-serif;
}
#trainingBadge:hover { background: rgba(79,216,232,0.15); }

#layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

#boardWrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 20px;
  min-width: 0;
  overflow: hidden;          /* nothing on the board (tooltips, effects) may grow the page */
}

#board {
  /* 6'x3' table: keep 2:1 and fit whichever of width/height is tighter */
  width: min(100%, calc((100vh - 150px) * 2));
  height: auto;
  aspect-ratio: 2 / 1;
  background:
    repeating-linear-gradient(0deg, rgba(79,216,232,0.025) 0px, transparent 1px, transparent 34px),
    repeating-linear-gradient(90deg, rgba(79,216,232,0.025) 0px, transparent 1px, transparent 34px),
    radial-gradient(ellipse at 50% 40%, #2f3d2a 0%, #232d1e 60%, #171f14 100%);
  border: 2px solid var(--border-bright);
  outline: 1px solid rgba(255,183,3,0.15);
  outline-offset: 4px;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.6), 0 12px 50px rgba(0,0,0,0.7), inset 0 0 80px rgba(0,0,0,0.5);
  touch-action: none;
}

#replayBanner, #archiveBanner {
  position: absolute;
  z-index: 5;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 183, 3, 0.95);
  color: #1a1400;
  padding: 6px 14px;
  border-radius: 3px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
}

#sidebar {
  width: 360px;
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(16,20,29,0.9), rgba(10,13,19,0.95));
  border-left: 1px solid var(--border-bright);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.panel {
  background: linear-gradient(180deg, rgba(22,28,40,0.9), rgba(16,20,29,0.9));
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 12px;
  position: relative;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%);
}
.panel::before {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 14px; height: 14px;
  background: linear-gradient(135deg, transparent 49%, var(--border-bright) 50%, transparent 51%);
}

.panel h3 {
  margin: 0 0 8px 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-dim);
  font-weight: 700;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-header h3 { margin: 0; }

.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.score-box, .round-box {
  text-align: center;
  flex: 1;
}

.score-label {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1.5px;
  font-family: "Orbitron", sans-serif;
}

.score-vp {
  font-size: 28px;
  font-weight: 700;
}

.score-box.p0 .score-vp { color: var(--p0); text-shadow: 0 0 10px rgba(79,216,232,0.5); }
.score-box.p1 .score-vp { color: var(--p1); text-shadow: 0 0 10px rgba(255,93,93,0.5); }
.round-box .score-vp { color: var(--accent); text-shadow: 0 0 10px rgba(255,183,3,0.5); }

.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border-bright);
  border-radius: 3px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: "Rajdhani", sans-serif;
  letter-spacing: 0.5px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.btn:hover { border-color: var(--accent); box-shadow: 0 0 10px rgba(255,183,3,0.25); }
.btn:disabled { opacity: 0.4; cursor: default; box-shadow: none; }

.btn-accent {
  background: linear-gradient(180deg, #ffc93c, #e6a300);
  border-color: #a67300;
  color: #1a1400;
  font-weight: 700;
}
.btn-accent:hover { background: linear-gradient(180deg, #ffd766, #f0ac00); box-shadow: 0 0 14px rgba(255,183,3,0.4); }

.btn-cyan {
  border-color: rgba(79,216,232,0.5);
  color: var(--cyan);
}
.btn-cyan:hover { box-shadow: 0 0 10px rgba(79,216,232,0.3); }

.btn-small { padding: 4px 10px; font-size: 12px; }
.btn-toggle.active { border-color: var(--accent); color: var(--accent); background: rgba(255,183,3,0.1); }

#unitStats {
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#actionList {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.action-row {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s;
}
.action-row:hover {
  border-color: var(--accent);
  background: #262013;
}
.action-row.attack { border-left: 3px solid var(--p1); }
.action-row.charge { border-left: 3px solid var(--gold); }
.action-row.move { border-left: 3px solid var(--p0); }

.advise-box {
  background: rgba(255,183,3,0.08);
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 8px 10px;
  font-size: 12px;
  margin: 8px 0;
}
.advise-box .adv-alt { color: var(--text-dim); margin-top: 2px; }

#actionList { max-height: 340px; }
.plan-group {
  font-family: "Orbitron", sans-serif;
  font-size: 9.5px;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-top: 4px;
}
.action-row .plan-ev {
  float: right;
  margin-left: 8px;
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
}
.action-row .plan-tag { margin-right: 6px; color: #fff; }
.action-row.tag-attack { border-left: 3px solid var(--p1); }
.action-row.tag-charge, .action-row.tag-melee { border-left: 3px solid var(--gold); }
.action-row.tag-move, .action-row.tag-withdraw { border-left: 3px solid var(--p0); }
.action-row.tag-aim, .action-row.tag-dodge, .action-row.tag-standby, .action-row.tag-recover { border-left: 3px solid var(--success); }
.action-row.unit-row { border-left: 3px solid var(--cyan); }
.action-row.recommended {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(255,183,3,0.3);
  background: rgba(255,183,3,0.08);
}
.plan-notice {
  margin: 8px 0;
  padding: 6px 10px;
  font-size: 12px;
  border: 1px solid var(--p1);
  background: rgba(255,93,93,0.08);
  border-radius: 3px;
}
.plan-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 0;
  font-size: 12px;
  color: var(--cyan);
}

/* Command phase */
.command-cards { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.command-card {
  flex: 1 1 60px;
  min-width: 60px;
  padding: 8px 4px;
  background: linear-gradient(180deg, #1c2433, #121824);
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  font-family: "Rajdhani", sans-serif;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.command-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 14px rgba(255,183,3,0.2); }
.command-card.recommended { border-color: var(--accent); box-shadow: 0 0 12px rgba(255,183,3,0.4); }
.command-card .cc-pips { color: var(--accent); font-size: 10px; letter-spacing: 2px; }
.command-card .cc-num { font-family: "Orbitron", sans-serif; font-size: 22px; font-weight: 700; }
.command-card .cc-orders { font-size: 11px; color: var(--text-dim); }
.command-hands { font-size: 12px; color: var(--text-dim); display: flex; justify-content: space-between; gap: 8px; }
.command-hands strong { color: var(--text); letter-spacing: 1px; }
.command-help { margin-top: 8px; font-size: 11px; color: var(--text-dim); line-height: 1.4; }

/* Scoreboard extras */
.round-info { margin-top: 8px; text-align: center; font-size: 12px; color: var(--text-dim); }
.winchance { margin-top: 8px; }
.winchance-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(255,93,93,0.45);
  overflow: hidden;
}
.winchance-fill { height: 100%; background: var(--p0); transition: width 0.4s ease-out; }
.winchance-label { margin-top: 3px; font-size: 11px; color: var(--text-dim); text-align: center; }

#logList {
  display: flex;
  flex-direction: column-reverse;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  font-size: 12px;
  color: var(--text-dim);
}
.log-entry {
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  justify-content: space-between;
}
.log-entry.bot { color: #ff9d9d; }
.log-entry.human { color: #9fd8ea; }
.log-entry.sys { color: var(--accent); }
.log-entry.kind-attack, .log-entry.kind-orders, .log-entry.kind-status { padding-left: 10px; font-size: 11.5px; opacity: 0.85; }
.log-entry-text { flex: 1; }
.log-explain-btn {
  flex-shrink: 0;
  border: 1px solid var(--border-bright);
  border-radius: 50%;
  width: 16px; height: 16px;
  line-height: 14px;
  text-align: center;
  font-size: 10px;
  cursor: pointer;
  color: var(--cyan);
  background: transparent;
}
.log-explain-btn:hover { border-color: var(--cyan); box-shadow: 0 0 6px rgba(79,216,232,0.4); }

.insight-box {
  margin-top: 6px;
  padding: 8px;
  background: rgba(79,216,232,0.06);
  border: 1px solid rgba(79,216,232,0.35);
  border-radius: 3px;
  font-size: 11.5px;
  color: var(--text);
}
.insight-tag {
  display: inline-block;
  font-family: "Orbitron", sans-serif;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--bg);
  background: var(--cyan);
  padding: 2px 6px;
  border-radius: 2px;
  margin-bottom: 4px;
}
.insight-winbar-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(255,93,93,0.35);
  overflow: hidden;
  margin: 4px 0;
}
.insight-winbar-fill { height: 100%; background: var(--success); }
.insight-alt { color: var(--text-dim); margin-top: 2px; }

#replaySlider { width: 100%; accent-color: var(--accent); }
.replay-controls { display: flex; gap: 6px; margin-top: 6px; }
.replay-controls .btn { flex: 1; }

.hidden { display: none !important; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2,3,6,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(2px);
}

.modal {
  position: relative;
  background: linear-gradient(180deg, #151b27, #0e1119);
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  padding: 24px;
  width: 340px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 0 40px rgba(255,183,3,0.08), 0 20px 60px rgba(0,0,0,0.6);
  clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 0 100%);
}
.modal.wide { width: 640px; }

.modal h2 {
  margin: 0;
  color: var(--accent);
  letter-spacing: 1.5px;
  font-size: 20px;
}

.modal label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-dim);
}

.modal select, .modal input {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 6px 8px;
  font-size: 14px;
  font-family: "Rajdhani", sans-serif;
}

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-close { position: absolute; top: 10px; right: 14px; cursor: pointer; color: var(--text-dim); font-size: 18px; }
.modal-close:hover { color: var(--accent); }

/* SVG board elements */
.mini-selected { stroke: var(--gold) !important; stroke-width: 0.16 !important; }
.mini-activated { opacity: 0.4; }
.mini-clickable { cursor: grab; }
.target-highlight { fill: none; stroke: var(--p1); stroke-width: 0.15; stroke-dasharray: 0.2,0.15; }
.move-marker { fill: rgba(79, 216, 232, 0.45); stroke: var(--cyan); stroke-width: 0.06; cursor: pointer; }
.move-marker:hover, .move-marker.drag-hover, .move-marker.active { fill: rgba(79, 216, 232, 0.9); stroke-width: 0.12; }

/* terrain (legion_ai kinds) */
.terrain-block { fill: #2b2f28; stroke: #0d100b; stroke-width: 0.1; }
.terrain-heavy { fill: rgba(96, 88, 70, 0.9); stroke: #1a1f14; stroke-width: 0.08; }
.terrain-light { fill: rgba(150, 120, 60, 0.55); stroke: #3a2f18; stroke-width: 0.06; }
.terrain-area { fill: rgba(40, 90, 40, 0.5); stroke: rgba(20, 50, 20, 0.8); stroke-width: 0.06; stroke-dasharray: 0.3,0.2; }

/* objectives */
.objective .obj-range { fill: none; stroke-width: 0.07; stroke-dasharray: 0.35,0.3; opacity: 0.55; }
.objective .obj-token { stroke-width: 0.12; }
.obj-none .obj-range { stroke: var(--gold); }
.obj-none .obj-token { fill: rgba(255,183,3,0.25); stroke: var(--gold); }
.obj-p0 .obj-range { stroke: var(--p0); }
.obj-p0 .obj-token { fill: rgba(79,216,232,0.4); stroke: var(--p0); }
.obj-p1 .obj-range { stroke: var(--p1); }
.obj-p1 .obj-token { fill: rgba(255,93,93,0.4); stroke: var(--p1); }

/* activation affordances */
.eligible-ring { fill: rgba(79,216,232,0.06); stroke: var(--cyan); stroke-width: 0.1; stroke-dasharray: 0.4,0.25; animation: eligible-pulse 1.6s ease-in-out infinite; }
.eligible-ring.selected { stroke: var(--gold); fill: rgba(255,183,3,0.08); animation: none; }
@keyframes eligible-pulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }
.mini-panicked { stroke: var(--p1) !important; stroke-dasharray: 0.15,0.1; }
.order-token { fill: var(--accent); stroke: #3a2a00; stroke-width: 0.05; transform-box: fill-box; transform-origin: center; transform: rotate(45deg); }
.token { stroke: #000; stroke-width: 0.04; }
.tok-aim { fill: #6bd97a; }
.tok-dodge { fill: #4fd8e8; }
.tok-standby { fill: #ffb703; }
.token-letter { font-size: 0.4px; fill: #05070c; font-weight: 700; text-anchor: middle; dominant-baseline: central; pointer-events: none; }

/* plan preview */
#planPreview { pointer-events: none; }
.plan-path { fill: none; stroke: var(--cyan); stroke-width: 0.14; stroke-dasharray: 0.35,0.2; opacity: 0.95; }
.plan-ghost { fill: rgba(79,216,232,0.18); stroke: var(--cyan); stroke-width: 0.08; }
.plan-melee { stroke: var(--gold); stroke-width: 0.16; }
.threat-range { fill: none; stroke: rgba(79,216,232, 0.3); stroke-width: 0.05; stroke-dasharray: 0.15,0.15; }
.weapon-range-ring { fill: none; stroke: rgba(255,93,93,0.25); stroke-width: 0.04; stroke-dasharray: 0.08,0.12; }
.los-line { stroke: var(--gold); stroke-width: 0.08; stroke-dasharray: 0.25,0.15; opacity: 0.85; }
.drag-hover .mini-p0, .drag-hover .mini-p1, .drag-hover circle { filter: drop-shadow(0 0 0.4px var(--gold)); }
.drag-ghost { opacity: 0.85; pointer-events: none; filter: drop-shadow(0 0 0.35px #fff); }
.drag-ghost-snapped { transition: cx 0.12s ease-out, cy 0.12s ease-out; }
.drag-origin { opacity: 0.3; transition: opacity 0.1s; }
.unit-type-glyph { fill: #fff; font-size: 0.55px; text-anchor: middle; dominant-baseline: central; pointer-events: none; paint-order: stroke; stroke: #000; stroke-width: 0.05px; }
.wound-badge { font-size: 0.5px; fill: #fff; text-anchor: middle; paint-order: stroke; stroke: #000; stroke-width: 0.08px; pointer-events: none; }
.suppress-badge { fill: #f2c94c; stroke: #7a5a00; stroke-width: 0.05; }

#legendBar {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
  background: rgba(5, 7, 12, 0.85);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 4px 12px;
  font-size: 11px;
  color: var(--text-dim);
}
#legendBar span { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
#legendBar { flex-wrap: wrap; justify-content: center; max-width: calc(100% - 24px); }
.legend-glyph { color: #fff; }
.legend-sep { width: 1px; align-self: stretch; background: var(--border); }
.legend-swatch { display: inline-block; width: 11px; height: 11px; border-radius: 2px; }
.legend-swatch.t-block { background: #2b2f28; border: 1px solid #555; }
.legend-swatch.t-heavy { background: rgb(96, 88, 70); }
.legend-swatch.t-light { background: rgba(150, 120, 60, 0.8); }
.legend-swatch.t-area { background: rgba(40, 90, 40, 0.8); border: 1px dashed rgba(120,170,120,0.8); }

.unit-tooltip {
  position: absolute;
  left: 0;
  top: 0;
  max-height: calc(100% - 8px);
  overflow: hidden;
  will-change: transform;
  z-index: 20;
  background: rgba(10, 13, 19, 0.97);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 12px;
  width: 230px;
  pointer-events: none;
  box-shadow: 0 6px 24px rgba(0,0,0,0.6), 0 0 20px rgba(255,183,3,0.1);
}
.unit-tooltip .tt-name { font-weight: 700; color: var(--accent); font-size: 13px; margin-bottom: 2px; font-family: "Orbitron", sans-serif; }
.unit-tooltip .tt-sub { color: var(--text-dim); font-size: 11px; margin-bottom: 6px; }
.unit-tooltip .tt-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; margin-bottom: 6px; }
.unit-tooltip .tt-weapon { margin-top: 4px; border-top: 1px solid var(--border); padding-top: 4px; }
.unit-tooltip .tt-weapon-name { font-weight: 600; }
.die { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 2px; vertical-align: middle; }
.die-red { background: #c0392b; }
.die-black { background: #2b2b2b; border: 1px solid #555; }
.die-white { background: #e5e5e5; }
.tt-keywords { color: var(--text-dim); font-style: italic; margin-top: 4px; }

.weapon-row { font-size: 12px; margin-bottom: 4px; }
.weapon-row .weapon-name { font-weight: 600; }

/* Attack dice preview popup */
.dice-preview {
  position: fixed;
  z-index: 21;
  background: rgba(10,13,19,0.97);
  border: 1px solid var(--p1);
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 12px;
  width: 200px;
  pointer-events: none;
  box-shadow: 0 6px 24px rgba(0,0,0,0.6), 0 0 16px rgba(255,93,93,0.15);
}
.dice-preview .dp-title { font-family:"Orbitron",sans-serif; font-size: 11px; color: var(--p1); margin-bottom: 6px; }
.dice-preview .dp-row { display: flex; justify-content: space-between; margin-top: 3px; }
.dice-preview .dp-val { color: var(--accent); font-weight: 700; }
.dice-preview .dp-plan { margin-top: 6px; color: var(--text-dim); font-size: 11px; }

/* Spectator mode bar */
#spectatorBar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(255,183,3,0.08);
  border: 1px solid rgba(255,183,3,0.35);
  border-radius: 3px;
  margin-bottom: 8px;
  font-size: 12px;
}
#spectatorBar .btn { padding: 4px 10px; font-size: 11px; }

/* Training modal */
.training-progress-track {
  height: 10px;
  border-radius: 5px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
  border: 1px solid var(--border);
}
.training-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--accent));
}
.checkpoint-chip {
  display: inline-block;
  padding: 3px 8px;
  margin: 2px;
  border: 1px solid var(--border-bright);
  border-radius: 3px;
  font-size: 11px;
  font-family: "Orbitron", sans-serif;
  color: var(--text-dim);
}
.checkpoint-chip.current { border-color: var(--accent); color: var(--accent); }
#lossChart, #speedChart { width: 100%; height: 130px; background: var(--panel); border: 1px solid var(--border); border-radius: 3px; }

.td-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.td-header h2 { margin: 0; }

.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: "Orbitron", sans-serif;
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--success);
  border: 1px solid var(--success);
  border-radius: 3px;
  padding: 3px 8px;
}
.live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  animation: live-pulse 1.4s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

.td-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}
.td-stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 10px;
  text-align: center;
}
.td-stat-value {
  font-family: "Orbitron", sans-serif;
  font-size: 19px;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(79,216,232,0.35);
}
.td-stat-label {
  margin-top: 3px;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-family: "Orbitron", sans-serif;
}

.td-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.td-chart-box { display: flex; flex-direction: column; gap: 4px; }
.td-chart-title {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-family: "Orbitron", sans-serif;
  text-transform: uppercase;
}

.td-buffer-row { display: flex; flex-direction: column; gap: 4px; }
.td-buffer-label { font-size: 12px; color: var(--text-dim); }
.td-buffer-label span { color: var(--accent); font-family: "Orbitron", sans-serif; }

.td-recent { display: flex; flex-direction: column; gap: 4px; }
#tdRecentTable {
  max-height: 130px;
  overflow-y: auto;
  font-size: 11.5px;
  border: 1px solid var(--border);
  border-radius: 3px;
}
.td-recent-row {
  display: grid;
  grid-template-columns: 60px 1fr 1fr 70px;
  gap: 8px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
}
.td-recent-row:last-child { border-bottom: none; }
.td-recent-row.cols-4 { grid-template-columns: 1fr 90px 60px 50px; }
.td-recent-row.cols-5 { grid-template-columns: 50px 1fr 1fr 1fr 50px; }
#tdEvalTable { font-size: 11.5px; border: 1px solid var(--border); border-radius: 3px; }
#checkpointChips { max-height: 90px; overflow-y: auto; }
.td-recent-row.header {
  font-family: "Orbitron", sans-serif;
  font-size: 9.5px;
  letter-spacing: 0.5px;
  color: var(--accent);
  position: sticky;
  top: 0;
  background: var(--panel-2);
}

/* Archive list */
.archive-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
  margin-bottom: 6px;
  cursor: pointer;
  font-size: 12.5px;
}
.archive-row:hover { border-color: var(--accent); background: rgba(255,183,3,0.05); }
.archive-row .arch-meta { color: var(--text-dim); font-size: 11px; }
.archive-row .arch-winner { font-family: "Orbitron", sans-serif; font-size: 11px; padding: 2px 6px; border-radius: 2px; }
.archive-row .arch-winner.p0 { background: rgba(79,216,232,0.15); color: var(--cyan); }
.archive-row .arch-winner.p1 { background: rgba(255,93,93,0.15); color: var(--p1); }
.archive-row .arch-winner.draw { background: rgba(255,255,255,0.1); color: var(--text-dim); }
.archive-row.legacy { opacity: 0.5; cursor: default; }
.archive-row.legacy:hover { border-color: var(--border); background: none; }
#archiveList { max-height: 400px; overflow-y: auto; }

/* Narrow viewports: stack board above sidebar instead of squeezing the board
   down to nothing beside a fixed-width sidebar. Placed last so it wins the
   cascade over the base #sidebar/#boardWrap rules at equal specificity. */
@media (max-width: 720px) {
  #layout { flex-direction: column; }
  #sidebar { width: 100%; max-height: 55vh; border-left: none; border-top: 1px solid var(--border-bright); }
  #boardWrap { flex: 1 1 auto; min-height: 220px; padding: 10px; }
}

#emptyState {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  color: var(--text-dim);
  font-family: "Orbitron", sans-serif;
  letter-spacing: 2px;
  pointer-events: none;
}
#emptyState .es-sub { font-family: "Rajdhani", sans-serif; letter-spacing: 0.5px; font-size: 13px; }

/* ---------------------------------------------------------------------- */
/* Home / lobby screen                                                    */
/* ---------------------------------------------------------------------- */

#homeScreen {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
  display: flex;
  justify-content: center;
}

.home-scroll {
  width: 100%;
  max-width: 900px;
  padding: 36px 24px 60px;
  animation: home-boot-in 0.5s ease-out;
}

@keyframes home-boot-in {
  from { opacity: 0; transform: translateY(10px); filter: blur(2px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

.home-hero { text-align: center; margin-bottom: 34px; }

.home-radar {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  position: relative;
  margin: 0 auto 22px;
  background:
    repeating-radial-gradient(circle, rgba(79,216,232,0.14) 0, rgba(79,216,232,0.14) 1px, transparent 1px, transparent 40px),
    radial-gradient(circle, rgba(79,216,232,0.10), transparent 72%);
  border: 1px solid rgba(79,216,232,0.4);
  box-shadow: 0 0 30px rgba(79,216,232,0.12), inset 0 0 30px rgba(0,0,0,0.5);
  overflow: hidden;
}
.home-radar::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(0deg, transparent 49.5%, rgba(79,216,232,0.15) 50%, transparent 50.5%),
              linear-gradient(90deg, transparent 49.5%, rgba(79,216,232,0.15) 50%, transparent 50.5%);
}
.home-radar .sweep {
  position: absolute;
  top: 50%; left: 50%;
  width: 50%; height: 100%;
  transform-origin: left center;
  background: conic-gradient(from 0deg, rgba(79,216,232,0.55), transparent 35%);
  animation: radar-sweep 4s linear infinite;
}
@keyframes radar-sweep { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.home-radar .blip {
  position: absolute;
  width: 7px; height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: blip-pulse 2.2s ease-in-out infinite;
}
.home-radar .blip.blip-red { background: var(--p1); box-shadow: 0 0 8px var(--p1); }
@keyframes blip-pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.75); }
  50% { opacity: 1; transform: scale(1.25); }
}

.home-title {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 6px;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(255,183,3,0.5);
  margin: 0 0 12px;
}
.home-title span { color: var(--cyan); text-shadow: 0 0 16px rgba(79,216,232,0.6); }

.home-tagline {
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.5;
  max-width: 580px;
  margin: 0 auto 24px;
}

.home-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn-lobby { padding: 12px 26px; font-size: 15px; letter-spacing: 1px; }

.home-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 30px;
}
.home-stat-card {
  background: linear-gradient(180deg, rgba(22,28,40,0.9), rgba(16,20,29,0.9));
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 14px 10px;
  text-align: center;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
}
.home-stat-value {
  font-family: "Orbitron", sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(79,216,232,0.4);
}
.home-stat-label {
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  font-family: "Orbitron", sans-serif;
}

.home-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.home-panel {
  background: linear-gradient(180deg, rgba(22,28,40,0.85), rgba(16,20,29,0.85));
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 16px;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%);
}
.home-panel h3 {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 1.5px;
  color: var(--accent);
  font-family: "Orbitron", sans-serif;
}
.home-panel p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-dim); }

.home-links { text-align: center; }

@media (max-width: 720px) {
  .home-title { font-size: 24px; letter-spacing: 3px; }
  .home-radar { width: 150px; height: 150px; }
}

/* ---------------------------------------------------------------------- */
/* Unit tokens (icon on a faction base)                                   */
/* ---------------------------------------------------------------------- */
.mini-base { stroke: rgba(0,0,0,0.75); stroke-width: 0.06; }
.mini-base.mini-p0 { stroke: #bff6ff; stroke-width: 0.09; }
.mini-base.mini-p1 { stroke: #ffc2b8; stroke-width: 0.09; }
.mini-inner { fill: rgba(8,10,14,0.55); pointer-events: none; }
.mini-icon { pointer-events: none; }
.mini-leader { fill: none; stroke: #ffe08a; stroke-width: 0.07; pointer-events: none; }
.mini-token.spent { opacity: 0.45; }
.rank-badge { fill: #0b0e14; stroke: #ffe08a; stroke-width: 0.05; pointer-events: none; }
.rank-glyph { fill: #ffe08a; font-size: 0.42px; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.objective .obj-core { fill: #fff6d0; opacity: 0.85; }
.obj-p0 .obj-core { fill: #d8fbff; }
.obj-p1 .obj-core { fill: #ffd8d0; }

/* floating combat text + round banner */
.fx-popup { font-family: "Orbitron", sans-serif; font-size: 0.9px; font-weight: 700; text-anchor: middle;
            paint-order: stroke; stroke: rgba(0,0,0,0.85); stroke-width: 0.18px; pointer-events: none; }
.fx-popup.big { font-size: 1.35px; }
.fx-banner {
  position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%) scale(0.9);
  text-align: center; pointer-events: none; z-index: 8;
  animation: banner-in 0.35s ease-out forwards;
}
.fx-banner.out { transition: opacity 0.5s, transform 0.5s; opacity: 0; transform: translate(-50%, -60%) scale(1.05); }
.fx-banner-title { font-family: "Orbitron", sans-serif; font-weight: 900; font-size: 44px; letter-spacing: 10px;
                   color: var(--accent); text-shadow: 0 0 24px rgba(255,183,3,0.7), 0 0 4px #000; }
.fx-banner-sub { font-family: "Orbitron", sans-serif; font-size: 13px; letter-spacing: 3px; color: var(--text); text-shadow: 0 0 6px #000; }
@keyframes banner-in { from { opacity: 0; transform: translate(-50%, -40%) scale(0.8); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

/* ---------------------------------------------------------------------- */
/* Portraits (Blender renders)                                            */
/* ---------------------------------------------------------------------- */
.tt-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.tt-portrait { width: 64px; height: 64px; flex-shrink: 0; border-radius: 4px;
               background: radial-gradient(circle at 50% 60%, #243248, #070a10 75%); border: 1px solid var(--border-bright); }
.tt-portrait.p0, .unit-portrait.p0 { box-shadow: 0 0 10px rgba(79,216,232,0.35); }
.tt-portrait.p1, .unit-portrait.p1 { box-shadow: 0 0 10px rgba(255,93,93,0.35); }
.unit-tooltip { width: 250px; }
.unit-portrait { float: right; width: 96px; height: 96px; margin: -4px 0 4px 8px; border-radius: 4px;
                 background: radial-gradient(circle at 50% 60%, #243248, #070a10 75%); border: 1px solid var(--border-bright); }
.action-row.unit-row { display: flex; align-items: center; gap: 8px; padding: 4px 8px; }
.row-portrait { width: 34px; height: 34px; flex-shrink: 0; border-radius: 3px; background: radial-gradient(circle at 50% 60%, #243248, #070a10 75%); }
.row-name { flex: 1; }
.action-row.unit-row .plan-ev { float: none; }

/* ---------------------------------------------------------------------- */
/* Sound settings popover                                                 */
/* ---------------------------------------------------------------------- */
.settings-wrap { position: relative; }
.settings-pop {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 60; width: 230px;
  background: linear-gradient(180deg, #151b27, #0e1119); border: 1px solid var(--border-bright); border-radius: 4px;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}
.settings-pop .set-row { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
.settings-pop input[type=range] { width: 100%; accent-color: var(--accent); }
.settings-pop .set-note { font-size: 10.5px; color: var(--text-dim); margin-top: 2px; }

/* ---------------------------------------------------------------------- */
/* 3D holo-table                                                           */
/* ---------------------------------------------------------------------- */
#holoWrap {
  position: absolute; inset: 8px; z-index: 2; border-radius: 4px; overflow: hidden;
  background: radial-gradient(ellipse at 50% 55%, #0a2233 0%, #04101a 45%, #010306 100%);
  border: 1px solid rgba(79,216,232,0.35); box-shadow: inset 0 0 80px rgba(79,216,232,0.08);
}
#holoWrap canvas { width: 100% !important; height: 100% !important; display: block; cursor: grab; }
#holoWrap canvas:active { cursor: grabbing; }
#boardWrap.holo-on #board { visibility: hidden; }
#boardWrap.holo-on #legendBar { z-index: 3; }
#holoCamBtn { position: absolute; top: 16px; right: 16px; z-index: 4; }
.holo-overlay { position: absolute; inset: 0; pointer-events: none; }
.holo-popup { position: absolute; transform: translate(-50%, -50%); font-family: "Orbitron", sans-serif; font-weight: 700;
              font-size: 14px; text-shadow: 0 0 6px #000, 0 0 12px rgba(0,0,0,0.8); white-space: nowrap; }
.holo-popup.big { font-size: 20px; }
.legend-hint { color: var(--text-dim); font-style: italic; }

/* =====================================================================
   Rules 2026 UI: turn panel, action bar, orders, builder, rules, tour
   ===================================================================== */
#statusline.warn { color: var(--danger); }
.command-cards.v2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.command-card.v2 { width: auto; min-height: 0; text-align: left; padding: 7px 8px; display: block; }
.cc-head { display: flex; align-items: baseline; gap: 6px; }
.command-card.v2 .cc-pips, .cc-mini .cc-pips { color: var(--accent); font-size: 11px; letter-spacing: 1px; }
.cc-name { font-family: "Orbitron", sans-serif; font-size: 11.5px; font-weight: 700; color: var(--text); }
.command-card.v2 .cc-orders, .cc-mini .cc-orders { font-size: 11.5px; color: var(--cyan); margin-top: 2px; }
.cc-text { font-size: 11.5px; color: var(--text-dim); margin-top: 3px; line-height: 1.25; }
.cc-approx { font-size: 9.5px; color: #c89a3a; margin-top: 3px; letter-spacing: 0.5px; text-transform: uppercase; }
.cc-mini { border: 1px solid var(--border); border-radius: 5px; padding: 6px 8px; margin: 6px 0; background: rgba(255,255,255,0.02); }
.command-help { font-size: 12px; color: var(--text-dim); margin: 6px 0; line-height: 1.3; }
.pick-list { display: flex; flex-direction: column; gap: 3px; margin: 6px 0; max-height: 300px; overflow-y: auto; }
.pick-list button.action-row { text-align: left; font-family: inherit; color: var(--text); }
.action-row.chosen { border-color: var(--gold) !important; background: rgba(255,183,3,0.10); }
.action-row .chk { color: var(--gold); width: 16px; }
.row-actions { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; }
.row-actions .btn { width: 100%; }
.row-actions .btn.recommended { box-shadow: 0 0 10px rgba(255,183,3,0.55); border-color: var(--accent); }
.step-info { font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; line-height: 1.35; }
.step-info b { color: var(--text); font-size: 14px; }
.step-info .free { color: var(--success); }
.warnc { color: #ffb347; }
.action-bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 8px; }
.act-btn { background: var(--panel-2); border: 1px solid var(--border-bright); color: var(--text); border-radius: 5px;
  padding: 6px 4px; font-family: "Rajdhani", sans-serif; font-size: 13px; font-weight: 600; cursor: pointer; line-height: 1.1; }
.act-btn:hover:not(:disabled) { border-color: var(--cyan); background: rgba(79,216,232,0.10); }
.act-btn.active { border-color: var(--accent); background: rgba(255,183,3,0.18); color: #fff; }
.act-btn.warn { border-color: #b8862b; }
.act-btn.end { grid-column: span 3; border-color: #5a6a86; }
.act-btn.end.pulse { border-color: var(--accent); animation: eligible-pulse 1.4s ease-in-out infinite; }
.act-btn:disabled { opacity: 0.38; cursor: not-allowed; }
.act-btn kbd, .rules kbd, .tour kbd { font-family: "Orbitron", sans-serif; font-size: 8.5px; border: 1px solid var(--border-bright);
  border-radius: 3px; padding: 0 3px; color: var(--text-dim); margin-left: 3px; }
.suggest-box { border-top: 1px solid var(--border); padding-top: 6px; max-height: 330px; overflow-y: auto; }
.plan-tag2 { font-family: "Orbitron", sans-serif; font-size: 9px; color: var(--accent); margin-right: 4px; letter-spacing: 0.5px; }
.action-row.tag-card-action { border-left: 3px solid #c9f; }

/* board overlays */
.band-deploy { fill: rgba(79,216,232,0.10); stroke: var(--cyan); stroke-width: 0.08; stroke-dasharray: 0.3,0.2; pointer-events: none; }
.band-infiltrate { fill: rgba(107,217,122,0.10); stroke: var(--success); stroke-width: 0.08; stroke-dasharray: 0.3,0.2; pointer-events: none; }
.move-line { stroke: var(--cyan); stroke-width: 0.08; stroke-dasharray: 0.25,0.15; pointer-events: none; }
.move-line.bad { stroke: var(--danger); }
.move-ghost { fill: rgba(79,216,232,0.25); stroke: var(--cyan); stroke-width: 0.1; pointer-events: none; }
.move-ghost.bad { fill: rgba(255,93,93,0.18); stroke: var(--danger); }
.charge-highlight { fill: none; stroke: var(--gold); stroke-width: 0.14; stroke-dasharray: 0.25,0.12; }
.target-highlight.melee { stroke: var(--gold); }
.target-label { font-size: 0.75px; fill: #ffd2d2; font-family: "Orbitron", sans-serif; font-weight: 700; text-anchor: middle;
  paint-order: stroke; stroke: #05070c; stroke-width: 0.18px; pointer-events: none; }
.eligible-ring.eligible { stroke: var(--cyan); }
.eligible-ring.chosen { stroke: var(--gold); fill: rgba(255,183,3,0.10); animation: none; }
.eligible-ring.fixed { stroke: #b38cff; fill: rgba(180,140,255,0.08); animation: none; }
.eligible-ring.active { stroke: var(--gold); fill: rgba(255,183,3,0.06); stroke-dasharray: none; animation: none; stroke-width: 0.14; }
.order-token.pending { fill: rgba(255,183,3,0.45); stroke-dasharray: 0.08,0.05; }
.suppress-badge.hot { fill: #ff9f1c; }
.suppress-badge.panic { fill: var(--danger); }
.tok-surge { fill: #f2c94c; }
.tok-obs { fill: #c9a0ff; }
.tok-immob { fill: #ff7a7a; }
.tok-shield { fill: #8fd3ff; }
.smoke-token { fill: rgba(200,200,210,0.35); stroke: rgba(230,230,240,0.6); stroke-width: 0.06; }
.legend-swatch.t-obj { background: transparent; border: 1px solid var(--accent); border-radius: 50%; }

/* tooltips / unit panel */
.kw { color: var(--text); }
.kw.nm, .tt-upgrades .nm, .unit-tooltip .nm { color: #6e7a8e; text-decoration: line-through dotted rgba(140,150,170,0.5); }
.tt-upgrades { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; }
.w-src { color: var(--text-dim); font-weight: 400; font-size: 10.5px; }
.unit-tooltip { max-width: 290px; }

/* reserves */
.reserve-row { font-size: 12px; margin: 3px 0; line-height: 1.6; }
.reserve-who { color: var(--text-dim); font-family: "Orbitron", sans-serif; font-size: 10px; }
.reserve-chip { display: inline-block; border: 1px solid var(--border); border-radius: 10px; padding: 0 7px; margin: 1px 2px; cursor: pointer; }
.reserve-row.p0 .reserve-chip { border-color: rgba(79,216,232,0.45); }
.reserve-row.p1 .reserve-chip { border-color: rgba(255,93,93,0.45); }
.reserve-chip.ordered { box-shadow: inset 0 0 0 1px var(--accent); }

/* new-game army choices */
.army-choice { border: 1px solid var(--border); border-radius: 6px; padding: 8px; margin: 6px 0; display: grid;
  grid-template-columns: 1fr 1fr; gap: 6px; align-items: center; }
.ac-title { grid-column: span 2; font-family: "Orbitron", sans-serif; font-size: 11px; color: var(--accent); letter-spacing: 1px; }
.ac-summary { grid-column: span 2; font-size: 12px; color: var(--text-dim); }
.army-choice select { margin: 0; width: 100%; min-width: 0; text-overflow: ellipsis; }
.army-choice > * { min-width: 0; }          /* grid items may shrink below their longest option */
#newGameModal .modal { width: 400px; }

/* army builder */
.modal.builder { width: min(1000px, 96vw); max-height: 92vh; display: flex; flex-direction: column; }
.builder-top { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.builder-top label { flex: 0 0 auto; }
.builder-import { border: 1px solid var(--border); border-radius: 6px; padding: 8px; margin-top: 6px; }
.builder-import textarea { width: 100%; background: var(--bg-deep); color: var(--text); border: 1px solid var(--border-bright);
  border-radius: 4px; font-family: Consolas, monospace; font-size: 12px; margin: 6px 0; }
.bi-help, .bi-msg { font-size: 12px; color: var(--text-dim); }
.builder-cols { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; min-height: 0; flex: 1; margin-top: 8px; }
.builder-roster, .builder-list { overflow-y: auto; max-height: 56vh; border: 1px solid var(--border); border-radius: 6px; padding: 6px; }
.builder-roster input { width: 100%; margin-bottom: 6px; }
.b-unit { display: flex; justify-content: space-between; padding: 3px 6px; cursor: pointer; border-radius: 4px; font-size: 13px; }
.b-unit:hover { background: rgba(79,216,232,0.10); }
.b-pts { color: var(--accent); font-family: "Orbitron", sans-serif; font-size: 11px; }
.b-merc { font-size: 9.5px; color: #b7a06a; border: 1px solid #6d5f3a; border-radius: 6px; padding: 0 4px; margin-left: 4px; }
.b-points { font-size: 14px; margin-bottom: 4px; }
.b-errors { font-size: 12px; color: #ffb347; margin-bottom: 6px; }
.b-errors .ok { color: var(--success); }
.b-entry { border: 1px solid var(--border); border-radius: 5px; padding: 5px 6px; margin-bottom: 5px; }
.b-entry-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 3px; }
.b-slot { width: 100%; margin: 2px 0 !important; font-size: 12px !important; padding: 2px 4px !important; }
.b-note { font-size: 11.5px; color: var(--text-dim); margin-right: auto; }
.nm-badge { color: #8a95a8; border: 1px solid #4a5568; border-radius: 4px; padding: 0 4px; font-size: 10.5px; }

/* rules */
.modal.rules { width: min(920px, 96vw); max-height: 90vh; display: flex; flex-direction: column; }
.rules-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.rules-tab { background: var(--panel-2); border: 1px solid var(--border); color: var(--text-dim); border-radius: 4px;
  padding: 3px 9px; font-family: "Rajdhani", sans-serif; font-size: 13px; cursor: pointer; }
.rules-tab.active, .rules-tab:hover { color: var(--text); border-color: var(--accent); }
.rules-body { overflow-y: auto; font-size: 14.5px; line-height: 1.45; padding-right: 6px; }
.rules-body h3 { font-family: "Orbitron", sans-serif; color: var(--accent); font-size: 15px; }
.rules-body li { margin: 4px 0; }
.r-sim { color: var(--cyan); font-size: 13.5px; border-left: 3px solid var(--cyan); padding-left: 8px; }
.r-dl dt { font-weight: 700; color: var(--accent); margin-top: 6px; }
.r-dl dd { margin: 0 0 0 14px; }

/* tutorial */
.tour { position: fixed; inset: 0; z-index: 3000; pointer-events: none; }
.tour-spot { position: fixed; border: 2px solid var(--accent); border-radius: 8px; box-shadow: 0 0 0 9999px rgba(0,0,0,0.45), 0 0 24px rgba(255,183,3,0.6);
  pointer-events: none; transition: all 0.25s ease; }
.tour-box { position: fixed; width: 340px; background: #0d121c; border: 1px solid var(--accent); border-radius: 8px; padding: 12px 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.6); pointer-events: auto; }
.tour-step { font-family: "Orbitron", sans-serif; font-size: 10px; color: var(--text-dim); letter-spacing: 1px; }
.tour-title { font-family: "Orbitron", sans-serif; font-size: 15px; color: var(--accent); margin: 4px 0 6px; }
.tour-text { font-size: 14px; line-height: 1.4; color: var(--text); }
.tour-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 10px; }
.row-actions .plan-ev { font-size: 11.5px; color: var(--text-dim); line-height: 1.25; margin-bottom: 4px; }

/* upgrade abilities, formation picker, upgrade text */
.act-btn.upgrade-btn { border-color: rgba(120, 200, 255, 0.55); }
.free-tag { font-size: 10px; padding: 0 4px; border-radius: 3px; background: rgba(90, 220, 140, 0.25); color: #9ff0bf; }
.free-tag.act { background: rgba(255, 190, 90, 0.22); color: #ffd28a; }
.formation-box { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 6px 0 2px; }
.form-btn { font: inherit; font-size: 12px; padding: 3px 9px; border-radius: 3px; cursor: pointer;
  background: var(--panel); color: var(--text); border: 1px solid var(--border); }
.form-btn.active { border-color: var(--accent); color: var(--accent); }
.up-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.up-row { font-size: 12px; line-height: 1.35; }
.up-row.exhausted b, .up-row.expended b { opacity: 0.55; text-decoration: line-through; }
.up-slot { color: var(--text-dim); font-size: 11px; }
.up-text { color: var(--text-dim); font-size: 11.5px; }
.up-state { color: var(--text-dim); }

/* smoother turn panel / hover feedback */
@keyframes panelIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
#turnBody.panel-in { animation: panelIn 180ms ease-out; }
.suggest-box { min-height: 120px; transition: opacity 150ms ease; }
.suggest-box.loading { opacity: 0.45; pointer-events: none; }
.action-row, .act-btn, .form-btn { transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, opacity 120ms ease; }
#board g[data-unit-id] .mini-base { transition: stroke-width 120ms ease, filter 120ms ease; }
#board g[data-unit-id]:hover .mini-base { stroke-width: 0.14; filter: brightness(1.25); }
.unit-tooltip { transition: opacity 90ms ease; }

/* ---- satisfying interactions: lift on hover, press on click ---- */
.btn, .act-btn, .form-btn, .action-row, .modal button {
  transition: transform 90ms ease, box-shadow 140ms ease, background-color 120ms ease, border-color 120ms ease, color 120ms ease, filter 120ms ease;
}
.btn:not(:disabled):hover, .act-btn:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,0.35), 0 0 12px rgba(255,183,3,0.12); }
.btn:not(:disabled):active, .act-btn:not(:disabled):active, .form-btn:active { transform: translateY(0) scale(0.96); box-shadow: none; filter: brightness(1.2); }
.action-row:hover { transform: translateX(2px); }
.action-row:active { transform: translateX(2px) scale(0.99); }
.act-btn.end.armed { border-color: #ff7a59; color: #ffb39e; animation: armedPulse 0.9s ease-in-out infinite; }
@keyframes armedPulse { 50% { box-shadow: 0 0 14px rgba(255,122,89,0.45); } }
#threatBtn.active { border-color: #ff6b6b; color: #ff9d9d; }
@media (prefers-reduced-motion: reduce) {
  .btn, .act-btn, .form-btn, .action-row { transition: none; }
  .btn:hover, .act-btn:hover, .action-row:hover { transform: none; }
}

/* threat view rings (2D board) */
#board .enemy-threat { fill: rgba(255, 70, 70, 0.018); stroke: rgba(255, 90, 90, 0.42); stroke-width: 0.08; stroke-dasharray: 0.5 0.35; pointer-events: none; }
#board .enemy-reach { fill: none; stroke: rgba(255, 170, 60, 0.6); stroke-width: 0.07; stroke-dasharray: 0.2 0.3; pointer-events: none; }

/* toasts */
#toasts { position: absolute; top: 14px; right: 18px; z-index: 25; display: flex; flex-direction: column; gap: 6px;
  align-items: flex-end; pointer-events: none; }
.toast { background: rgba(10, 13, 19, 0.94); border: 1px solid var(--border-bright); border-left: 3px solid var(--accent);
  border-radius: 3px; padding: 7px 12px; min-width: 180px; max-width: 280px; box-shadow: 0 6px 20px rgba(0,0,0,0.5);
  opacity: 0; transform: translateX(18px); transition: opacity 220ms ease, transform 220ms cubic-bezier(.2,.9,.3,1.2); }
.toast.in { opacity: 1; transform: none; }
.toast.out { opacity: 0; transform: translateX(10px); }
.toast-title { font-family: "Orbitron", sans-serif; font-size: 12px; letter-spacing: 1px; color: var(--accent); }
.toast-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.toast.good { border-left-color: #5ee08a; } .toast.good .toast-title { color: #8ff0ae; }
.toast.bad { border-left-color: #ff6b6b; } .toast.bad .toast-title { color: #ff9d9d; }
.toast.turn { border-left-color: #4fd8e8; } .toast.turn .toast-title { color: #8eeaf5; font-size: 14px; }
