/* ============================================================
   FieldOp - Defcon-style tactical map
   ============================================================ */

:root {
  --bg-deep:        #02060c;
  --bg-ocean:       #04101a;
  --grid-line:      #0c2e1c;
  --grid-line-maj:  #103a22;
  --border:         #2dff85;
  --border-dim:     #1ea864;
  --phosphor:       #7fffb8;
  --hud-fg:         #5cffa3;
  --hud-dim:        #2a7a55;
  --hud-bg:         #03110a;
  --hud-edge:       #0a3a22;
  --warn:           #ff7755;
}

* { box-sizing: border-box; }

/* ── Themed scrollbars (HUD phosphor) ─────────────────────────────────
   No custom scrollbar styling existed, so every scrollable panel fell back
   to the OS default (light grey on dark). These rules tint all scrollbars
   to match the green-phosphor theme. Firefox uses scrollbar-width/color;
   Chromium/WebKit uses the ::-webkit-scrollbar pseudo-elements. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--hud-dim) transparent;
}
::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}
::-webkit-scrollbar-track {
  background: rgba(10, 58, 34, 0.18);
}
::-webkit-scrollbar-thumb {
  background: var(--hud-dim);
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-dim);
  background-clip: padding-box;
}
::-webkit-scrollbar-corner { background: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg-deep);
  color: var(--hud-fg);
  font-family: "JetBrains Mono", "Fira Code", "Menlo", "Consolas", monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── App grid ─────────────────────────────────────────────────────────────
   Row 1 (1fr):   map + right sidebar
   Row 2 (235px): bottom command bar (state strip + action row)
   ──────────────────────────────────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-areas:
    "map     sidebar"
    "cmdbar  cmdbar";
  grid-template-rows: 1fr 235px;
  grid-template-columns: 1fr 290px;
  height: 100%;
}

/* ── HUD bars ─────────────────────────────────────────────────────────────*/
.hud-bar {
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: var(--hud-bg);
  border-bottom: 1px solid var(--hud-edge);
  text-transform: uppercase;
  font-size: 11px;
  gap: 16px;
}
.hud-cluster   { display: flex; align-items: center; gap: 8px; }
.hud-label     { color: var(--hud-fg); font-weight: 600; }
.hud-dim       { color: var(--hud-dim); }
.hud-sep       { color: var(--hud-dim); }
.hud-mono      { color: var(--hud-fg); font-variant-numeric: tabular-nums; }

/* ── CONFIRM button ───────────────────────────────────────────────────── */
#confirm-btn {
  --accent: #5cffa3;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 14px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  border: 1px solid var(--accent);
  cursor: pointer;
  transition: background 100ms linear, color 100ms linear;
}
#confirm-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
}
#confirm-btn:disabled {
  --accent: #2a7a55;
  cursor: not-allowed;
  opacity: 0.6;
}
#confirm-btn.playing {
  --accent: #ff7755;
  letter-spacing: 0.18em;
}

/* ── Map area ─────────────────────────────────────────────────────────── */
.map-shell {
  grid-area: map;
  position: relative;
  overflow: hidden;
  background: var(--bg-deep);
}

/* ── Canvas layers — behind the SVG, fill the map-shell exactly ──────── */
.map-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;   /* SVG on top handles all pointer events */
  display: block;
}

/* SVG is transparent (canvas layers do all visual rendering);
   it sits on top only to route pointer events to country paths.
   pointer-events:all ensures the element captures clicks on its
   full bounding box — not just over visible SVG child paths.
   Without this, open-ocean and wrapped-copy canvas areas (which
   have no corresponding SVG <path> children) silently swallow
   clicks and onMapClick never fires there. */
#map {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  background: transparent;
  pointer-events: all;
}
#map.dragging  { cursor: grabbing; }
#map.placing   { cursor: crosshair; }
#map.moving    { cursor: crosshair; }
#map.launching { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='10' r='7' fill='none' stroke='%23ff9955' stroke-width='1.5'/%3E%3Cline x1='10' y1='2' x2='10' y2='18' stroke='%23ff9955' stroke-width='1'/%3E%3Cline x1='2' y1='10' x2='18' y2='10' stroke='%23ff9955' stroke-width='1'/%3E%3C/svg%3E") 10 10, crosshair; }

/* ── Country borders — SVG hit-test paths (invisible by default) ──────── */
/* All actual country border / fill rendering is done on cv-bg canvas.
   These invisible SVG paths exist only so hover / click events still fire.
   The interactive state classes add a translucent overlay so the player
   can see what is selected on top of the canvas background. */
#countries path {
  --accent: #7fffb8;
  fill: transparent;
  stroke: transparent;        /* invisible — canvas does the border drawing */
  stroke-width: 1.0;
  vector-effect: non-scaling-stroke;
  cursor: crosshair;
}
#countries path.neutral {
  cursor: default;
}
#countries path.territory-hover {
  fill: color-mix(in srgb, var(--accent) 22%, transparent);
  stroke: var(--accent);
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}
#countries path.territory-selected {
  fill: color-mix(in srgb, var(--accent) 42%, transparent);
  stroke: var(--accent);
  stroke-width: 1.6;
}
#countries path.territory-opponent {
  fill: color-mix(in srgb, #ff3344 45%, transparent);
  stroke: #ff3344;
  stroke-width: 1.6;
}

/* ── City dots ────────────────────────────────────────────────────────── */
#cities circle {
  --accent: #7fffb8;
  fill: var(--accent);
  stroke: rgba(0, 0, 0, 0.45);
  stroke-width: 0.25;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
  opacity: 0.30;   /* dimmed — units should be easier to spot */
}
#cities circle.capital     { opacity: 0.55; }
#cities circle.neutral     { fill: #4a7a62; opacity: 0.30; }
#cities circle.city-setup  { fill: #7fffb8; opacity: 0.30; }
#cities circle.city-player { fill: var(--accent); opacity: 0.55; }
#cities circle.city-player.capital { stroke: #ffffff; stroke-width: 0.4; }
#cities circle.city-ai     { fill: var(--accent); opacity: 0.40; }

/* ── Units ────────────────────────────────────────────────────────────── */
#units g.unit {
  --unit-accent: #5cffa3;
  cursor: default;
}
#units g.unit .unit-base {
  fill: rgba(2, 6, 12, 0.82);
  stroke: var(--unit-accent);
  stroke-width: 0.6;
  stroke-dasharray: 2.5 1.5;
  opacity: 0.7;
  vector-effect: non-scaling-stroke;
}
#units g.unit path,
#units g.unit polygon,
#units g.unit rect,
#units g.unit ellipse,
#units g.unit circle {
  stroke: var(--unit-accent);
  stroke-width: 2.0;
  stroke-linejoin: round;
  stroke-linecap: round;
  fill: color-mix(in srgb, var(--unit-accent) 18%, transparent);
  vector-effect: non-scaling-stroke;
  transition: stroke 120ms, fill 120ms;
}
#units g.unit line {
  stroke: var(--unit-accent);
  stroke-width: 1.5;
  fill: none;
  vector-effect: non-scaling-stroke;
}
#units g.unit .unit-base { stroke-width: 1.3; }
/* HUD bars — more-specific selectors beat the generic icon rules above */
/* Health bar background */
#units g.unit .hbar-bg {
  fill: rgba(0,0,0,0.65);
  stroke: rgba(0,0,0,0.5);
  stroke-width: 0.8;
  transition: none;
}
/* Health bar fill and XP fill: colour is set via element.style (inline) by JS;
   we only need to suppress the accent stroke from the icon rule */
#units g.unit .hbar-fill,
#units g.unit .xpbar-fill {
  stroke: none;
  stroke-width: 0;
  transition: none;
}
/* XP bar background */
#units g.unit .xpbar-bg {
  fill: rgba(0,0,0,0.45);
  stroke: none;
  stroke-width: 0;
  transition: none;
}
/* Veterancy stars — fill/stroke via CSS so inline attributes don't fight cascade */
#units g.unit .vet-pip {
  fill: var(--unit-accent);
  stroke: rgba(0,0,0,0.85);
  stroke-width: 1.5;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  transition: none;
}
#units g.unit .vet-pip.vet-pip--elite {
  fill: #ffe97a;
}
#units g.unit--ai         { --unit-accent: #ff3344; }
#units g.unit--player     { cursor: pointer; }
#units g.unit--player:hover path,
#units g.unit--player:hover polygon,
#units g.unit--player:hover rect,
#units g.unit--player:hover ellipse,
#units g.unit--player:hover circle {
  fill: color-mix(in srgb, var(--unit-accent) 45%, transparent);
}
/* Keep HUD bars and vet stars unaffected by hover/selected fill changes */
#units g.unit--player:hover .hbar-bg,
#units g.unit--player:hover .xpbar-bg { fill: rgba(0,0,0,0.65); }
#units g.unit--player:hover .vet-pip  { fill: var(--unit-accent); }
#units g.unit--player:hover .vet-pip.vet-pip--elite { fill: #ffe97a; }
#units g.unit--selected .unit-base {
  stroke-dasharray: none;
  stroke-width: 2;
  opacity: 1;
  /* No CSS filter — avoid per-unit compositing layer that slows zoom */
}
#units g.unit--selected path,
#units g.unit--selected polygon,
#units g.unit--selected rect,
#units g.unit--selected ellipse {
  fill: color-mix(in srgb, var(--unit-accent) 38%, transparent);
}
/* HUD bars stay intact when unit is selected */
#units g.unit--selected .hbar-bg,
#units g.unit--selected .xpbar-bg { fill: rgba(0,0,0,0.65); }
/* Moving: slightly brighter base — no animation, no GPU layer */
#units g.unit--moving .unit-base { opacity: 1; }
/* Returning-home: orange tint on base, no animation */
#units g.unit--returning .unit-base {
  stroke: #ff9955 !important;
  opacity: 0.85;
}
/* No per-unit will-change — creates too many GPU compositing layers. */
/* Intercept projectile — no pointer events needed */
.intercept-projectile { pointer-events: none; }

/* Attack-order indicator — dashed red line + target reticle */
.attack-indicator-line {
  stroke: #ff3344;
  stroke-width: 0.5;
  stroke-dasharray: 2.5 2.5;
  opacity: 0.65;
  pointer-events: none;
}
.attack-reticle {
  fill: none;
  stroke: #ff3344;
  stroke-width: 0.7;
  opacity: 0.9;
  pointer-events: none;
}
.attack-reticle-inner {
  fill: none;
  stroke: #ff3344;
  stroke-width: 0.4;
  opacity: 0.5;
  pointer-events: none;
}

/* Hypersonic in-flight: small amber plasma dot */
.missile-dot-hsm {
  fill: #ff8800;
  filter: drop-shadow(0 0 1.5px #ff6600);
  pointer-events: none;
}

/* Interceptor / SAM blue dot */
.intercept-dot {
  fill: #44bbff;
  filter: drop-shadow(0 0 1.5px #22aaff);
  pointer-events: none;
}

/* ── Move destination overlay ─────────────────────────────────────────── */
.move-dest-ring {
  fill: none;
  stroke: var(--unit-accent, #5cffa3);
  stroke-width: 0.7;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
  opacity: 0.85;
}
.move-dest-line {
  stroke: var(--unit-accent, #5cffa3);
  stroke-width: 0.45;
  stroke-dasharray: 2 2;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
  opacity: 0.55;
}

/* ── Missiles ─────────────────────────────────────────────────────────── */
/* missile-pulse removed — no per-unit animations */
#units g.unit--missile { opacity: 0.9; }

/* Launch range ring */
@keyframes range-pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.75; } }
.launch-range-ring {
  fill: none;
  stroke: #ff9955;
  stroke-width: 0.6;
  stroke-dasharray: 4 4;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
  animation: range-pulse 2s ease-in-out infinite;
}

/* Unit selection range ring — shown for all units on click */
.unit-range-ring {
  fill: none;
  stroke: var(--unit-range-color, #5cffa3);
  stroke-width: 0.5;
  stroke-dasharray: 3 5;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
  opacity: 0.28;
  transition: opacity 120ms;
}

/* Missile arc trajectory */
.missile-arc {
  fill: none;
  stroke-width: 0.5;
  stroke-dasharray: 2.5 3;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
  opacity: 0.7;
}

/* Missile projectile diamond */
.missile-projectile {
  opacity: 0.95;
  pointer-events: none;
}

/* ── Floating info panel ──────────────────────────────────────────────── */
#info-panel {
  --info-accent: #5cffa3;
  position:       absolute;
  z-index:        30;
  min-width:      190px;
  max-width:      250px;
  background:     rgba(2, 8, 5, 0.96);
  border:         1px solid var(--info-accent);
  padding:        10px 14px 12px;
  pointer-events: none;
  backdrop-filter: blur(3px);
  box-shadow:     0 0 14px rgba(0,0,0,0.7),
                  0 0 6px color-mix(in srgb, var(--info-accent) 18%, transparent);
  font-size: 9px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  line-height: 1.7;
}
#info-panel.ip-hidden { display: none; }
.ip-title {
  color: var(--info-accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.13em;
  margin-bottom: 7px;
  padding-bottom: 6px;
  border-bottom: 1px solid color-mix(in srgb, var(--info-accent) 30%, transparent);
}
.ip-row  { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 1px; }
.ip-k    { color: var(--hud-dim); flex-shrink: 0; }
.ip-v    { color: var(--hud-fg); text-align: right; font-weight: 600; }

/* ── Territory ownership tints (setup / placement only) ──────────────── */
#countries path.territory-player {
  fill: transparent;
  stroke: var(--accent);
  stroke-width: 1.4;
}
#countries path.territory-ai {
  fill: transparent;
  stroke: color-mix(in srgb, #ff3344 70%, var(--border));
  stroke-width: 1.2;
}

/* ── Per-country conquest ownership (playing phase) ──────────────────── */
/* Captured countries: clearly tinted fill + accent border */
#countries path.country-player {
  fill: rgba(74, 168, 255, 0.18);
  stroke: var(--accent);
  stroke-width: 1.4;
  opacity: 1;
}
#countries path.country-ai {
  fill: rgba(255, 51, 68, 0.14);
  stroke: #ff3344;
  stroke-width: 1.2;
  opacity: 1;
}
/* Neutral countries during playing phase are de-emphasised */
#countries path:not(.country-player):not(.country-ai).territory-hover-off {
  opacity: 0.35;
}

/* ── Placement animations ─────────────────────────────────────────────── */
@keyframes placement-ping {
  0%   { transform: scale(0.15); opacity: 0.9; }
  100% { transform: scale(3.5);  opacity: 0;   }
}
.placement-ping {
  transform-box: fill-box;
  transform-origin: center;
  animation: placement-ping 0.7s ease-out forwards;
  pointer-events: none;
}
@keyframes unit-appear { from { opacity: 0; } to { opacity: 1; } }
.unit--new { animation: unit-appear 0.3s ease-out forwards; }

/* ── Territory hover – context suppression ────────────────────────────── */
#map.city-hovered #countries path.territory-hover {
  fill: transparent;
  stroke: var(--accent);
  stroke-width: 0.9;
}
#map.zoomed-in #countries path.territory-hover {
  fill: transparent;
  stroke: var(--accent);
  stroke-width: 1.5;
}

/* ── Pause button ─────────────────────────────────────────────────────── */
.pause-btn {
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 2px 9px;
  background: transparent;
  color: var(--phosphor);
  border: 1px solid var(--phosphor);
  cursor: pointer;
  transition: color 80ms, border-color 80ms, background 80ms;
}
.pause-btn:hover {
  background: color-mix(in srgb, var(--phosphor) 18%, transparent);
}
.pause-btn--paused {
  color: #ff4455;
  border-color: #ff4455;
  background: color-mix(in srgb, #ff4455 12%, transparent);
  letter-spacing: 0.08em;
}
.pause-btn--paused:hover {
  background: color-mix(in srgb, #ff4455 22%, transparent);
}

/* ── Speed controls ───────────────────────────────────────────────────── */
.speed-btn {
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  background: transparent;
  color: var(--hud-dim);
  border: 1px solid var(--hud-edge);
  cursor: pointer;
  transition: color 80ms, border-color 80ms, background 80ms;
}
.speed-btn:hover       { color: var(--hud-fg); border-color: var(--hud-fg); }
.speed-btn--active {
  color: var(--phosphor);
  border-color: var(--phosphor);
  background: color-mix(in srgb, var(--phosphor) 12%, transparent);
}

/* ── Economy HUD ──────────────────────────────────────────────────────── */
#econ-pop      { font-variant-numeric: tabular-nums; color: var(--hud-fg); }
.econ-balance  {
  font-variant-numeric: tabular-nums;
  color: #5cffa3;
  text-shadow: 0 0 6px rgba(92, 255, 163, 0.55);
  font-weight: 700;
}
.econ-income   { color: var(--hud-dim); font-variant-numeric: tabular-nums; }

/* ── City hover ───────────────────────────────────────────────────────── */
.city-hover-el { min-width: 6ch; font-variant-numeric: tabular-nums; transition: color 80ms, text-shadow 80ms; }
.city-hover--active { color: #ffe97a; text-shadow: 0 0 8px rgba(255, 233, 122, 0.6); }

/* ── Scanline / CRT ───────────────────────────────────────────────────── */
.scanline {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.18) 3px
    ),
    radial-gradient(
      ellipse at center,
      rgba(0, 0, 0, 0) 60%,
      rgba(0, 0, 0, 0.45) 100%
    );
  mix-blend-mode: multiply;
}

/* ══════════════════════════════════════════════════════════════════════════
   RIGHT SIDEBAR
   ══════════════════════════════════════════════════════════════════════════ */
#right-sidebar {
  grid-area: sidebar;
  background: rgba(2, 10, 6, 0.98);
  border-left: 1px solid var(--hud-edge);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* No backdrop-filter — compositor cost not worth it */
}

/* ── Placement panel (inside sidebar during placement phase) ─────────── */
#placement-panel {
  --player-accent: #4aa8ff;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 12px 10px;
  overflow-y: auto;
}
#placement-panel.pp-hidden { display: none !important; }

.pp-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--hud-edge);
  margin-bottom: 8px;
}
.pp-title {
  color: var(--player-accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
}
.pp-sub { color: var(--hud-dim); font-size: 9px; letter-spacing: 0.08em; }

.pp-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.pp-card {
  border: 1px solid var(--hud-edge);
  padding: 6px 8px;
  cursor: pointer;
  transition: border-color 80ms, background 80ms;
  background: rgba(255,255,255,0.02);
}
.pp-card:hover:not(.pp-card--full) {
  border-color: var(--player-accent);
  background: color-mix(in srgb, var(--player-accent) 8%, transparent);
}
.pp-card--armed {
  border-color: var(--player-accent) !important;
  background: color-mix(in srgb, var(--player-accent) 15%, transparent) !important;
  box-shadow: 0 0 6px color-mix(in srgb, var(--player-accent) 30%, transparent);
}
.pp-card--full { opacity: 0.4; cursor: not-allowed; }

.pp-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2px;
}
.pp-card-abbr  { color: var(--player-accent); font-size: 11px; font-weight: 700; letter-spacing: 0.1em; }
.pp-card-cat   { color: var(--hud-dim); font-size: 9px; }
.pp-card-name  { color: var(--hud-fg); font-size: 9px; letter-spacing: 0.06em; margin-bottom: 3px; }
.pp-card-count { color: var(--hud-dim); font-size: 9px; }
.pp-card-count .pp-placed { color: var(--player-accent); font-weight: 700; }

.pp-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 8px;
  font-size: 8.5px;
  color: var(--hud-fg);
  letter-spacing: 0.04em;
  margin: 2px 0 4px;
  font-variant-numeric: tabular-nums;
}
.pp-stat   { display: inline-flex; align-items: baseline; gap: 3px; }
.pp-stat-k { color: var(--hud-dim); font-size: 8px; letter-spacing: 0.08em; }

.pp-status {
  font-size: 9px;
  color: var(--hud-fg);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 0 4px;
  min-height: 24px;
  border-top: 1px solid var(--hud-edge);
  margin-top: 4px;
}

.pp-budget {
  font-size: 10px;
  color: var(--hud-dim);
  padding: 4px 0;
  text-transform: uppercase;
}
.pp-dim { color: var(--hud-dim); }

.pp-begin {
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 8px 0;
  width: 100%;
  background: color-mix(in srgb, var(--player-accent) 15%, transparent);
  color: var(--player-accent);
  border: 1px solid var(--player-accent);
  cursor: pointer;
  margin-top: 6px;
  transition: background 100ms, box-shadow 100ms;
}
.pp-begin:hover:not(:disabled) {
  background: color-mix(in srgb, var(--player-accent) 30%, transparent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--player-accent) 35%, transparent);
}
.pp-begin:disabled { opacity: 0.35; cursor: not-allowed; }

.pp-blocs {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 0 10px;
  border-bottom: 1px solid var(--hud-edge);
  margin-bottom: 8px;
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.pp-blocs-list { display: flex; flex-direction: column; gap: 3px; margin-top: 2px; }
.pp-bloc-tag {
  border: 1px solid;
  padding: 1px 5px;
  font-size: 9px;
  letter-spacing: 0.08em;
  background: rgba(255, 51, 68, 0.06);
  opacity: 0.85;
}

/* ── Game panel (unit roster, playing phase) ─────────────────────────── */
#game-panel {
  --gp-accent: #5cffa3;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
#game-panel.gp-hidden { display: none !important; }

.gp-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 11px 11px 9px;
  border-bottom: 1px solid var(--hud-edge);
  flex-shrink: 0;
}
.gp-title { font-size: 12px; font-weight: 700; letter-spacing: 0.12em; }
.gp-sub   { color: var(--hud-dim); font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; }

.gp-roster {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.gp-empty {
  font-size: 9px;
  color: var(--hud-dim);
  text-align: center;
  padding: 20px 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  cursor: pointer;
  transition: background 80ms;
  border-left: 2px solid transparent;
}
.gp-row:hover {
  background: rgba(255,255,255,0.04);
}
.gp-row--selected {
  background: color-mix(in srgb, var(--row-accent, #5cffa3) 10%, transparent);
  border-left-color: var(--row-accent, #5cffa3);
}

.gp-icon {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 8, 5, 0.6);
}

.gp-row-info {
  flex: 1;
  min-width: 0;
}

.gp-row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 3px;
}
.gp-abbr {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.gp-row-status {
  font-size: 8px;
  color: var(--hud-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.gp-status-moving  { color: #ffe97a; }
.gp-status-launch  { color: #ff9955; }

.gp-hp-track {
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 2px;
}
.gp-hp-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 400ms;
}
.gp-hp-label {
  font-size: 8px;
  color: var(--hud-dim);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

/* ── Mini SVG icons (command bar + game panel) ────────────────────────── */
.unit-mini-svg {
  display: block;
  overflow: visible;
}
.unit-mini-svg .unit-base {
  fill: rgba(2, 6, 12, 0.85);
  stroke: var(--unit-accent);
  stroke-width: 0.8;
  stroke-dasharray: 2.5 1.5;
  opacity: 0.85;
  vector-effect: non-scaling-stroke;
}
.unit-mini-svg path,
.unit-mini-svg polygon,
.unit-mini-svg rect,
.unit-mini-svg ellipse,
.unit-mini-svg circle {
  stroke: var(--unit-accent);
  stroke-width: 1.1;
  stroke-linejoin: round;
  stroke-linecap: round;
  fill: color-mix(in srgb, var(--unit-accent) 20%, transparent);
  vector-effect: non-scaling-stroke;
}
.unit-mini-svg line {
  stroke: var(--unit-accent);
  stroke-width: 0.9;
  fill: none;
  vector-effect: non-scaling-stroke;
}

/* ══════════════════════════════════════════════════════════════════════════
   BOTTOM COMMAND BAR
   ══════════════════════════════════════════════════════════════════════════ */
#cmd-bar {
  grid-area: cmdbar;
  display: grid;
  grid-template-rows: 26px 1fr;   /* trim top strip; give actions area more room for many-button units like carriers */
  background: var(--hud-bg);
  border-top: 1px solid var(--hud-edge);
  font-size: 11px;
  text-transform: uppercase;
  overflow: hidden;
}

/* ── State strip (top row — formerly the top HUD bar) ─────────────────── */
.cmd-state {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  border-bottom: 1px solid var(--hud-edge);
  background: rgba(0, 0, 0, 0.25);
  overflow: hidden;
  white-space: nowrap;
}
.cmd-state .hud-sep { opacity: 0.35; }

/* ── Main row (bottom row — unit detail + actions + meta) ─────────────── */
.cmd-main {
  display: flex;
  align-items: stretch;
  overflow: hidden;
  min-height: 0;
}

/* ── Left: unit detail / idle status ─────────────────────────────────── */
.cmd-detail {
  width: 310px;
  flex-shrink: 0;
  padding: 10px 14px;
  border-right: 1px solid var(--hud-edge);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 8px;
  overflow: hidden;
}

.cmd-idle {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Unit card layout */
.cmd-unit-card {
  --cmd-accent: #5cffa3;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.cmd-icon-wrap {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border: 1px solid var(--cmd-accent, #5cffa3);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 8, 5, 0.7);
}

.cmd-icon-svg { display: block; }

.cmd-unit-info {
  flex: 1;
  min-width: 0;
}

.cmd-unit-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmd-unit-meta {
  font-size: 8.5px;
  color: var(--hud-dim);
  letter-spacing: 0.07em;
  margin-bottom: 4px;
  display: flex;
  gap: 5px;
  align-items: baseline;
}
.cmd-abbr   { color: var(--hud-fg); font-weight: 700; }
.cmd-sep    { color: var(--hud-dim); }
.cmd-status-badge   { color: var(--hud-dim); }
.cmd-status-moving  { color: #ffe97a !important; }
.cmd-status-launch  { color: #ff9955 !important; }

.cmd-hp-track {
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 3px;
}
.cmd-hp-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 300ms;
}
.cmd-unit-stats {
  display: flex;
  gap: 10px;
  font-size: 8.5px;
  color: var(--hud-fg);
  font-variant-numeric: tabular-nums;
}
.cmd-stat-k { color: var(--hud-dim); font-size: 8px; letter-spacing: 0.07em; margin-right: 2px; }

/* ── Center: action buttons ───────────────────────────────────────────── */
.cmd-actions {
  flex: 1;
  padding: 10px 18px;
  display: flex;
  flex-direction: column;
  /* Anchor buttons to the top and scroll when the unit has too many actions
     (e.g. a carrier with launch / deploy / retreat / disband / blockade /
     ignore / deselect).  Centering caused top items to clip when overflow hit. */
  justify-content: flex-start;
  gap: 6px;
  border-right: 1px solid var(--hud-edge);
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
}

/* Hint text in cmd-actions when no button needed */
.cmd-move-hint, .cmd-launch-hint {
  font-size: 9px;
  color: var(--hud-dim);
  letter-spacing: 0.07em;
}
.cmd-launch-hint { color: #ff9955; }

/* Action buttons */
.cmd-btn {
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 14px;
  background: transparent;
  border: 1px solid;
  cursor: pointer;
  width: fit-content;
  transition: background 100ms, box-shadow 100ms;
}

.cmd-btn--launch {
  color: #ff9955;
  border-color: #ff9955;
}
.cmd-btn--launch:hover {
  background: rgba(255, 153, 85, 0.14);
  box-shadow: 0 0 8px rgba(255, 153, 85, 0.3);
}

/* Aggressive action buttons (e.g. BLOCKADE [LANE]?).  Vivid red so the player
   doesn't mistake them for the muted DISBAND / IGNORE / DESELECT cluster. */
.cmd-btn--attack {
  color: #ff4d4d;
  border-color: #ff4d4d;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255, 77, 77, 0.25),
              0 0 6px rgba(255, 77, 77, 0.25);
}
.cmd-btn--attack:hover {
  background: rgba(255, 77, 77, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 77, 77, 0.5),
              0 0 10px rgba(255, 77, 77, 0.5);
}

.cmd-btn--warn {
  color: var(--warn);
  border-color: var(--warn);
}
.cmd-btn--warn:hover {
  background: rgba(255, 119, 85, 0.14);
}

.cmd-btn--cancel {
  color: var(--hud-dim);
  border-color: var(--hud-edge);
}
.cmd-btn--cancel:hover {
  color: var(--warn);
  border-color: var(--warn);
}

/* ── Right: meta (economy, speed, hints) ──────────────────────────────── */
.cmd-meta {
  width: 480px;
  flex-shrink: 0;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 6px;
}

.cmd-econ {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  font-size: 11px;
}

.cmd-speed {
  display: flex;
  align-items: center;
  gap: 5px;
}

.cmd-hints {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 9px;
  color: var(--hud-dim);
}
.cmd-hints .hud-mono { font-size: 9px; }

.cmd-zoom-row {
  display: flex;
  gap: 7px;
  align-items: center;
  font-size: 10px;
}

/* ── Fuel bar (game panel roster) ─────────────────────────────────────── */
.gp-fuel-track {
  height: 2px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 2px;
}
.gp-fuel-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 400ms;
}

/* Returning status */
.gp-row--returning {
  background: rgba(255, 153, 85, 0.05);
}
.gp-status-returning { color: #ff9955; }

/* ── Fuel bar (command bar unit card) ─────────────────────────────────── */
.cmd-fuel-track {
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 3px;
}
.cmd-fuel-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 300ms;
}

/* ── Missile recharge bar ──────────────────────────────────────────────── */
.cmd-cooldown-track {
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 3px;
}
.cmd-cooldown-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 400ms;
}

/* Fuel warning label */
.cmd-fuel-warn {
  color: #ff9955;
  font-size: 8.5px;
  letter-spacing: 0.05em;
  margin-left: 4px;
}

/* Returning status badge */
.cmd-status-warn { color: #ff9955 !important; }

/* ── City / territory info icons ─────────────────────────────────────── */
.cmd-info-icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border: 1px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: rgba(2, 8, 5, 0.7);
  letter-spacing: 0;
}
.cmd-city-icon { border-radius: 2px; }
.cmd-terr-icon { font-size: 26px; }

/* Capital city badge */
.cmd-badge {
  font-size: 7.5px;
  letter-spacing: 0.1em;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ══════════════════════════════════════════════════════════════════════════
   RECRUITMENT SYSTEM  (sidebar-native — no overlay)
   ══════════════════════════════════════════════════════════════════════════ */

/* ── View-toggle button (RECRUIT / ← FORCES) ─────────────────────────── */
.gp-toggle-btn {
  --gp-accent: #5cffa3;
  display: block;
  width: calc(100% - 20px);
  margin: 7px 10px 4px;
  padding: 6px 0;
  background: color-mix(in srgb, var(--gp-accent) 10%, transparent);
  border: 1px solid var(--gp-accent);
  color: var(--gp-accent);
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 120ms;
  flex-shrink: 0;
}
.gp-toggle-btn:hover {
  background: color-mix(in srgb, var(--gp-accent) 22%, transparent);
}

/* ── Recruit view container (fills remaining sidebar height) ─────────── */
.gp-recruit-view {
  --recruit-accent: #5cffa3;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 0;
  min-height: 0;
}

/* Balance strip at top of shop */
.shop-balance-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 10px 5px;
  border-bottom: 1px solid var(--hud-edge);
  flex-shrink: 0;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.shop-bal-label { color: var(--hud-dim); }
.shop-bal-val   { color: var(--hud-fg); font-weight: 700; font-variant-numeric: tabular-nums; }

/* Unit card list (single column in sidebar) */
.shop-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.shop-card {
  --card-accent: #5cffa3;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  background: transparent;
  border-bottom: 1px solid var(--hud-edge);
  cursor: pointer;
  transition: background 80ms;
}
.shop-card:hover:not(.shop-card--disabled) {
  background: color-mix(in srgb, var(--card-accent) 8%, transparent);
}
.shop-card--disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.shop-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(1,6,3,0.7);
}

.shop-card-info {
  flex: 1;
  min-width: 0;
}
.shop-card-name {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  color: var(--hud-fg);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.shop-card-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}
.shop-cost {
  font-size: 9px;
  font-weight: 700;
  color: var(--card-accent);
  letter-spacing: 0.05em;
}
.shop-cost--broke { color: #ff5533; }
.shop-cost--na    { color: var(--hud-dim); font-weight: 400; font-size: 8px; }
.shop-card-count {
  font-size: 8px;
  color: var(--hud-dim);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* ── Armed placement cursor ─────────────────────────────────────────── */
#map.recruit-armed {
  cursor: crosshair;
}
#map.recruit-armed * {
  cursor: crosshair !important;
}

/* Country conquest tints — duplicate block removed; see above rules */

/* ══════════════════════════════════════════════════════════════════════════
   FOG OF WAR
   ══════════════════════════════════════════════════════════════════════════ */

/* The fog overlay rect is rendered via SVG mask inside fog.js;
   no extra CSS needed for the rect itself.  These rules handle
   the radar-pulse animation on the player's units. */

/* No radar-pulse animation — per-unit drop-shadow filter is expensive. */

/* Missile reload indicator on interceptor/ICBM/hypersonic */
.unit--reloading .unit-base {
  opacity: 0.45;
}

/* ══════════════════════════════════════════════════════════════════════════
   AMPHIBIOUS MARINES
   ══════════════════════════════════════════════════════════════════════════ */

/* Amphibious units use the standard unit styling — the wave in the SVG
   icon already distinguishes them visually.  The mobilty badge shown
   in the command bar will read "AMPHIB". */

/* Intercept flash: the blue explosion for a successful interception */
.missile-intercept-flash {
  pointer-events: none;
}

/* ══════════════════════════════════════════════════════════════════════════
   SAVE / LOAD SYSTEM
   ══════════════════════════════════════════════════════════════════════════ */

.save-bar {
  display: flex;
  gap: 6px;
  padding: 8px 10px 6px;
  border-bottom: 1px solid var(--hud-edge);
  flex-shrink: 0;
}

.save-btn {
  flex: 1;
  background: transparent;
  border: 1px solid var(--hud-dim);
  color: var(--hud-dim);
  font-family: inherit;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 5px 4px;
  cursor: pointer;
  transition: color 80ms, border-color 80ms, background 80ms;
  text-align: center;
}
.save-btn:hover {
  color: var(--hud-fg);
  border-color: var(--hud-fg);
  background: color-mix(in srgb, var(--hud-fg) 8%, transparent);
}
.save-btn--save:hover {
  color: var(--phosphor);
  border-color: var(--phosphor);
  background: color-mix(in srgb, var(--phosphor) 10%, transparent);
}
.save-btn--load:hover {
  color: #ffe97a;
  border-color: #ffe97a;
  background: color-mix(in srgb, #ffe97a 8%, transparent);
}

/* ══════════════════════════════════════════════════════════════════════════
   MOBILE SIDEBAR TOGGLE BUTTON
   (hidden on desktop; shown by media query below)
   ══════════════════════════════════════════════════════════════════════════ */

.mob-sidebar-btn {
  display: none;  /* hidden on desktop */
}

/* ══════════════════════════════════════════════════════════════════════════
   MOBILE / TOUCH  (≤ 768 px)
   ══════════════════════════════════════════════════════════════════════════ */
/* DISABLED: superseded by the body.fieldop-mobile layer (JS-driven, single
   source of truth for the mobile UI). Kept as 0px so it never matches. */
@media (max-width: 0px) {

  /* ── App grid: drop the sidebar column ─────────────────────────────── */
  #app {
    grid-template-areas:
      "map"
      "cmdbar";
    grid-template-rows: 1fr 52px;
    grid-template-columns: 1fr;
  }

  /* ── Right sidebar becomes a slide-up bottom sheet ──────────────────── */
  #right-sidebar {
    display: none;
    position: fixed;
    bottom: 52px;           /* sits directly above the cmd bar */
    left: 0;
    right: 0;
    height: 32vh;
    max-height: 32vh;
    z-index: 90;
    border-left: none;
    border-top: 1px solid var(--hud-edge);
    border-right: none;
    overflow: hidden;
    animation: none;
  }
  #right-sidebar.mob-open {
    display: flex;
    animation: mob-slide-up 0.18s ease-out;
  }
  @keyframes mob-slide-up {
    from { transform: translateY(30px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
  }

  /* ── Command bar: two buttons side-by-side ───────────────────────────
     Left half: confirm-btn (SELECT A TERRITORY / DEPLOY / GAME ON / …)
     Right half: FORCES toggle. Everything else hidden. */
  #cmd-bar {
    display: flex !important;
    flex-direction: row;
    grid-template-rows: none;
    padding: 0;
    align-items: stretch;
  }

  /* cmd-state hosts confirm-btn; strip all its other clusters */
  .cmd-state {
    flex: 1;
    padding: 0;
    gap: 0;
    background: transparent;
    border: none;
    min-height: 0;
    height: auto;
  }
  .cmd-state > .hud-cluster { display: none; }
  .cmd-state > .hud-cluster:has(#confirm-btn) {
    display: flex;
    flex: 1;
    margin: 0 !important;
  }

  /* cmd-main hosts the FORCES toggle (inside cmd-meta); strip the rest */
  .cmd-main {
    flex: 1;
    padding: 0;
    gap: 0;
    min-height: 0;
  }
  .cmd-detail,
  .cmd-actions,
  .cmd-econ,
  .cmd-speed,
  .event-feed--docked {
    display: none !important;
  }
  .cmd-meta {
    width: 100%;
    padding: 0;
    gap: 0;
    flex: 1;
    display: flex;
    align-items: stretch;
  }

  /* Shared full-size button styling for both bottom-bar buttons */
  #confirm-btn,
  .mob-sidebar-btn {
    display: block;
    width: 100%;
    height: 100%;
    border: none;
    border-top: 1px solid var(--hud-edge);
    border-radius: 0;
    font-family: inherit;
    font-size: 12px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    padding: 0;
    cursor: pointer;
    transition: background 80ms, color 80ms, opacity 80ms;
  }
  /* Visual divider between the two buttons */
  .mob-sidebar-btn {
    border-left: 1px solid var(--hud-edge);
    background: color-mix(in srgb, var(--hud-fg) 12%, transparent);
    color: var(--hud-fg);
  }
  .mob-sidebar-btn:hover,
  .mob-sidebar-btn:active {
    background: color-mix(in srgb, var(--hud-fg) 22%, transparent);
  }
  /* confirm-btn keeps its own contextual colors via existing rules;
     here we just override sizing. Disabled state stays muted. */
  #confirm-btn:disabled {
    cursor: default;
    opacity: 0.55;
  }

  /* Hide all the other mob-tagged clusters too */
  .mob-hide,
  .mob-hide-flex { display: none !important; }

  /* ── EXPANDED cmd-bar ────────────────────────────────────────────────
     Tapping GAME ON during play adds .cmd-expanded to #cmd-bar. The bar
     grows out of its 52px row, stacks vertically, and reveals: DATE,
     unit detail, action buttons, econ stats, pause/speed controls, and
     the FORCES toggle at the bottom. Scrolls internally if very tall. */
  #app:has(#cmd-bar.cmd-expanded) {
    grid-template-rows: 1fr auto;
  }
  #cmd-bar.cmd-expanded {
    flex-direction: column;
    align-items: stretch;
    max-height: 70vh;
    overflow-y: auto;
  }

  /* cmd-state becomes a vertical block: DATE row + GAME ON row */
  #cmd-bar.cmd-expanded .cmd-state {
    flex-direction: column;
    flex: 0 0 auto;
    padding: 0;
  }
  /* Reveal the DATE cluster (and any other non-confirm, non-mob-hide cluster) */
  #cmd-bar.cmd-expanded .cmd-state > .hud-cluster {
    display: flex;
    width: 100%;
    padding: 6px 14px;
    margin: 0 !important;
    box-sizing: border-box;
    border-bottom: 1px solid var(--hud-edge);
  }
  /* Hide pure-branding "FieldOp // TACTICAL COMMAND" cluster on mobile */
  #cmd-bar.cmd-expanded .cmd-state > .hud-cluster:first-child {
    display: none;
  }
  /* The GAME ON button cluster: full 52px row, no border (button has its own) */
  #cmd-bar.cmd-expanded .cmd-state > .hud-cluster:has(#confirm-btn) {
    flex: 0 0 52px;
    padding: 0;
    border-bottom: none;
  }

  /* cmd-main: vertical stack of detail, actions, then cmd-meta */
  #cmd-bar.cmd-expanded .cmd-main {
    flex-direction: column;
    width: 100%;
    flex: 0 0 auto;
    padding: 0;
    gap: 0;
  }

  /* Reveal the items hidden in collapsed mode */
  #cmd-bar.cmd-expanded .cmd-detail,
  #cmd-bar.cmd-expanded .cmd-actions,
  #cmd-bar.cmd-expanded .cmd-econ,
  #cmd-bar.cmd-expanded .cmd-speed,
  #cmd-bar.cmd-expanded .event-feed--docked {
    display: flex !important;
    width: 100%;
    padding: 10px 14px;
    border-top: 1px solid var(--hud-edge);
    box-sizing: border-box;
  }
  /* Docked feed: full width when stacked, cap height so it scrolls */
  #cmd-bar.cmd-expanded .event-feed--docked {
    flex: 0 0 auto;
    border-right: none;
  }
  #cmd-bar.cmd-expanded .event-feed--docked .event-feed-list {
    max-height: 150px;
  }
  #cmd-bar.cmd-expanded .cmd-actions {
    flex-wrap: wrap;
    gap: 6px;
  }
  #cmd-bar.cmd-expanded .cmd-econ {
    gap: 8px;
    flex-wrap: wrap;
    font-size: 11px;
    align-items: center;
  }
  #cmd-bar.cmd-expanded .cmd-speed {
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
  }

  /* cmd-meta stacks: (cmd-econ, cmd-speed already styled above; here we
     restructure cmd-meta itself so the FORCES btn sits at the bottom) */
  #cmd-bar.cmd-expanded .cmd-meta {
    flex-direction: column;
    width: 100%;
    padding: 0;
    gap: 0;
  }
  #cmd-bar.cmd-expanded .mob-sidebar-btn {
    border-left: none;
    border-top: 1px solid var(--hud-edge);
    height: 52px;
    flex: 0 0 52px;
  }

  /* Chevron on GAME ON to indicate expand/collapse affordance */
  #cmd-bar:not(.cmd-expanded) #confirm-btn.playing::after {
    content: "  \25BE";  /* ▾ */
    margin-left: 8px;
  }
  #cmd-bar.cmd-expanded #confirm-btn.playing::after {
    content: "  \25B4";  /* ▴ */
    margin-left: 8px;
  }

  /* Speed buttons: compact */
  .cmd-speed {
    gap: 3px;
    flex-wrap: wrap;
  }
  .speed-btn {
    padding: 3px 5px;
    font-size: 9px;
    min-height: 28px;
  }
  .pause-btn {
    padding: 3px 7px;
    min-height: 28px;
  }

  /* Economy: smaller text */
  .cmd-econ {
    font-size: 10px;
    gap: 5px;
  }

  /* Sidebar contents: touch-friendly row heights */
  .gp-row {
    padding: 8px 10px;
    min-height: 44px;
  }
  .gp-toggle-btn {
    min-height: 38px;
  }
  .shop-card {
    padding: 10px;
    min-height: 52px;
  }
  .save-btn {
    min-height: 36px;
    padding: 6px 4px;
  }

  /* Placement panel cards: touch-friendly */
  .pp-card {
    padding: 10px 10px;
    min-height: 44px;
  }
  .pp-begin {
    min-height: 44px;
    font-size: 13px;
  }

  /* Scanline: skip on mobile (GPU cost) */
  .scanline { display: none; }

  /* Info panel: slightly larger on touch screens */
  #info-panel {
    font-size: 10px;
    min-width: 170px;
    padding: 10px 12px 12px;
  }
  .ip-title { font-size: 13px; }

  /* Mode overlay: stack cards vertically on narrow screens */
  .mode-modal-cards { flex-direction: column; }
  .mode-card { min-height: 100px; padding: 14px; }
}

/* ── Mode selection overlay ──────────────────────────────────────────────────
   Full-screen modal shown at game start. Dismissed when a mode is chosen.
   Sits above #app entirely (z-index 9999). */

.mode-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(2, 10, 18, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Share Tech Mono", "Courier New", monospace;
}

.mode-modal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  max-width: 920px;
  width: 92%;
}

.mode-modal-title {
  font-size: 22px;
  letter-spacing: 0.22em;
  color: #5cffa3;
  text-shadow: 0 0 18px #5cffa380;
}

.mode-modal-sub {
  font-size: 12px;
  letter-spacing: 0.28em;
  color: rgba(92, 255, 163, 0.55);
  text-transform: uppercase;
}

.mode-modal-cards {
  display: flex;
  gap: 20px;
  width: 100%;
}

.mode-card {
  flex: 1;
  background: rgba(92, 255, 163, 0.04);
  border: 1px solid rgba(92, 255, 163, 0.25);
  border-radius: 4px;
  color: #c0e8d0;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.14em;
  padding: 22px 18px;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: background 120ms, border-color 120ms, box-shadow 120ms;
}

.mode-card:hover {
  background: rgba(92, 255, 163, 0.10);
  border-color: rgba(92, 255, 163, 0.6);
  box-shadow: 0 0 20px rgba(92, 255, 163, 0.15);
}

.mode-card:active {
  background: rgba(92, 255, 163, 0.16);
}

.mode-card-icon {
  font-size: 26px;
  line-height: 1;
}

.mode-card-name {
  font-size: 14px;
  letter-spacing: 0.2em;
  color: #5cffa3;
  font-weight: bold;
}

.mode-card-desc {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: rgba(192, 232, 208, 0.65);
  line-height: 1.6;
  text-transform: none;
}

/* ═══════════════════════════════════════════════════════════════
   Game setup modal (player count + AI personalities)
   ═══════════════════════════════════════════════════════════════ */
.setup-modal {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 90%;
  max-width: 560px;
  background: rgba(8, 20, 16, 0.92);
  border: 1px solid rgba(92, 255, 163, 0.30);
  border-radius: 6px;
  box-shadow: 0 0 40px rgba(92, 255, 163, 0.12);
  padding: 28px 30px;
  font-family: "Share Tech Mono", "Courier New", monospace;
}
.setup-modal-title {
  font-size: 20px;
  letter-spacing: 0.20em;
  color: #5cffa3;
  text-shadow: 0 0 16px #5cffa380;
}
.setup-modal-sub {
  font-size: 11px;
  letter-spacing: 0.24em;
  color: rgba(92, 255, 163, 0.55);
  text-transform: uppercase;
  margin-top: -12px;
}
.setup-section { display: flex; flex-direction: column; gap: 10px; }
.setup-section-label {
  font-size: 11px;
  letter-spacing: 0.22em;
  color: #7fffb8;
}
.setup-section-hint {
  font-size: 9.5px;
  letter-spacing: 0.06em;
  color: rgba(192, 232, 208, 0.5);
  line-height: 1.5;
}
.setup-count { display: flex; gap: 10px; }
.setup-count-btn {
  flex: 1;
  font-family: inherit;
  font-size: 16px;
  letter-spacing: 0.1em;
  padding: 10px 0;
  background: rgba(92, 255, 163, 0.04);
  border: 1px solid rgba(92, 255, 163, 0.25);
  border-radius: 3px;
  color: #c0e8d0;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, box-shadow 120ms;
}
.setup-count-btn:hover {
  background: rgba(92, 255, 163, 0.10);
  border-color: rgba(92, 255, 163, 0.55);
}
.setup-count-btn.setup-count-btn--active {
  background: rgba(92, 255, 163, 0.18);
  border-color: #5cffa3;
  color: #5cffa3;
  box-shadow: 0 0 14px rgba(92, 255, 163, 0.20);
}
/* Word labels (PROPORTIONAL / BALANCED) need a smaller type size to fit. */
.setup-units-btn { font-size: 12px; letter-spacing: 0.06em; padding: 10px 6px; }
.setup-personalities { display: flex; flex-direction: column; gap: 8px; }
.setup-pers-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(92, 255, 163, 0.03);
  border: 1px solid rgba(92, 255, 163, 0.14);
  border-radius: 3px;
  padding: 8px 12px;
}
.setup-pers-swatch {
  width: 12px; height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}
.setup-pers-name {
  font-size: 12px;
  letter-spacing: 0.12em;
  min-width: 76px;
  font-weight: bold;
}
.setup-pers-select {
  margin-left: auto;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.06em;
  padding: 5px 8px;
  background: #0a1f16;
  border: 1px solid rgba(92, 255, 163, 0.3);
  border-radius: 2px;
  color: #c0e8d0;
  cursor: pointer;
  min-width: 150px;
}
.setup-pers-select:focus { outline: none; border-color: #5cffa3; }
.setup-pers-desc {
  font-size: 9px;
  letter-spacing: 0.04em;
  color: rgba(192, 232, 208, 0.5);
  flex-basis: 100%;
  line-height: 1.4;
}
.setup-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 4px;
}
.setup-btn {
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.14em;
  padding: 9px 20px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, box-shadow 120ms;
}
.setup-btn--ghost {
  background: transparent;
  border: 1px solid rgba(92, 255, 163, 0.25);
  color: rgba(192, 232, 208, 0.8);
}
.setup-btn--ghost:hover { border-color: rgba(92, 255, 163, 0.6); color: #c0e8d0; }
.setup-btn--go {
  background: rgba(92, 255, 163, 0.16);
  border: 1px solid #5cffa3;
  color: #5cffa3;
  font-weight: bold;
}
.setup-btn--go:hover {
  background: rgba(92, 255, 163, 0.26);
  box-shadow: 0 0 16px rgba(92, 255, 163, 0.25);
}

/* ── In-game pause menu (ESC) ─────────────────────────────────────────────── */
.game-menu-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(2, 10, 18, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Share Tech Mono", "Courier New", monospace;
}
.game-menu-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 320px;
  max-width: 90vw;
  padding: 28px 26px;
  background: rgba(8, 20, 16, 0.96);
  border: 1px solid rgba(92, 255, 163, 0.35);
  border-radius: 6px;
  box-shadow: 0 0 40px rgba(92, 255, 163, 0.14);
}
.game-menu-title {
  font-size: 18px;
  letter-spacing: 0.3em;
  color: #5cffa3;
  text-align: center;
  text-shadow: 0 0 16px #5cffa380;
  margin-bottom: 8px;
}
.game-menu-btn {
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.14em;
  padding: 12px 16px;
  background: rgba(92, 255, 163, 0.06);
  border: 1px solid rgba(92, 255, 163, 0.3);
  border-radius: 3px;
  color: #c0e8d0;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, box-shadow 120ms;
}
.game-menu-btn:hover {
  background: rgba(92, 255, 163, 0.16);
  border-color: #5cffa3;
  box-shadow: 0 0 14px rgba(92, 255, 163, 0.2);
}
.game-menu-btn--danger {
  border-color: rgba(255, 119, 85, 0.5);
  color: #ff9977;
}
.game-menu-btn--danger:hover {
  background: rgba(255, 119, 85, 0.16);
  border-color: #ff7755;
  box-shadow: 0 0 14px rgba(255, 119, 85, 0.2);
}
.game-menu-btn--ghost {
  background: transparent;
  border-color: rgba(192, 232, 208, 0.25);
  color: rgba(192, 232, 208, 0.8);
}
.game-menu-note {
  font-size: 10px;
  letter-spacing: 0.05em;
  color: #5cffa3;
  text-align: center;
  min-height: 12px;
}

/* ── Prominent faction-assignment panel (Regional / Custom selection) ──────── */
.setup-select-panel {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  width: min(680px, 94vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  padding: 14px 18px;
  background: rgba(8, 20, 16, 0.94);
  border: 1px solid rgba(92, 255, 163, 0.35);
  border-radius: 6px;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.5), 0 0 24px rgba(92, 255, 163, 0.12);
  font-family: "Share Tech Mono", "Courier New", monospace;
  pointer-events: auto;
}
.ssp-title {
  font-size: 14px;
  letter-spacing: 0.2em;
  color: #5cffa3;
  text-shadow: 0 0 12px #5cffa340;
}
.ssp-instr {
  font-size: 10.5px;
  letter-spacing: 0.05em;
  color: rgba(192, 232, 208, 0.7);
  text-align: center;
  line-height: 1.5;
}
.ssp-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.ssp-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--chip-color, #5cffa3);
  border-radius: 4px;
  color: #d8e3ea;
  font-size: 11px;
  letter-spacing: 0.1em;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 120ms, box-shadow 120ms, background 120ms;
}
.ssp-chip:hover { opacity: 0.85; }
.ssp-chip.ssp-chip--armed {
  opacity: 1;
  background: color-mix(in srgb, var(--chip-color, #5cffa3) 18%, transparent);
  box-shadow: 0 0 14px color-mix(in srgb, var(--chip-color, #5cffa3) 40%, transparent);
}
.ssp-chip-swatch {
  width: 11px; height: 11px; border-radius: 2px;
  background: var(--chip-color, #5cffa3);
  box-shadow: 0 0 6px var(--chip-color, #5cffa3);
  flex-shrink: 0;
}
.ssp-chip-name { font-weight: bold; color: var(--chip-color, #5cffa3); }
.ssp-chip-count {
  font-variant-numeric: tabular-nums;
  color: rgba(216, 227, 234, 0.75);
  font-size: 10px;
}
.ssp-begin {
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.16em;
  padding: 9px 24px;
  border-radius: 3px;
  background: rgba(92, 255, 163, 0.16);
  border: 1px solid #5cffa3;
  color: #5cffa3;
  font-weight: bold;
  cursor: pointer;
  transition: background 120ms, box-shadow 120ms, opacity 120ms;
}
.ssp-begin:hover:not(:disabled) {
  background: rgba(92, 255, 163, 0.28);
  box-shadow: 0 0 16px rgba(92, 255, 163, 0.25);
}
.ssp-begin:disabled { opacity: 0.4; cursor: default; }

/* ═══════════════════════════════════════════════════════════════
   v2econ — Game Panel: three-tab row (FORCES / RECRUIT / OIL MKT)
   ═══════════════════════════════════════════════════════════════ */

.gp-tab-row {
  display: flex;
  gap: 2px;
  padding: 4px 8px 0;
  border-bottom: 1px solid rgba(92,255,163,0.12);
  flex-shrink: 0;
}

.gp-tab-btn {
  flex: 1;
  padding: 5px 4px;
  background: transparent;
  border: 1px solid rgba(92,255,163,0.15);
  border-bottom: none;
  color: rgba(192,232,208,0.45);
  font-family: inherit;
  font-size: 9px;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border-radius: 3px 3px 0 0;
}

.gp-tab-btn:hover {
  background: rgba(92,255,163,0.06);
  color: rgba(192,232,208,0.80);
}

.gp-tab-btn--active {
  background: rgba(92,255,163,0.10);
  border-color: rgba(92,255,163,0.40);
  color: var(--gp-accent, #5cffa3);
}

/* ═══════════════════════════════════════════════════════════════
   v2econ — Oil Market Sidebar Panel
   ═══════════════════════════════════════════════════════════════ */

.gp-oil-view {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  padding-bottom: 8px;
}

/* Price header */
.oil-price-header {
  padding: 10px 12px 6px;
  border-bottom: 1px solid rgba(92,255,163,0.10);
}

.oil-price-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.oil-price-label {
  font-size: 9px;
  letter-spacing: 0.12em;
  color: rgba(192,232,208,0.45);
}

.oil-price-value {
  font-size: 22px;
  font-weight: bold;
  letter-spacing: 0.05em;
  line-height: 1;
}

.oil-price-trend {
  font-size: 11px;
  letter-spacing: 0.08em;
  font-weight: bold;
}

.oil-price-sub {
  font-size: 9px;
  letter-spacing: 0.10em;
  color: rgba(192,232,208,0.40);
  margin-top: 3px;
}

/* Sparkline */
.oil-sparkline-wrap {
  padding: 6px 10px 4px;
  border-bottom: 1px solid rgba(92,255,163,0.08);
}

.oil-sparkline {
  width: 100%;
  height: 52px;
  display: block;
}

.oil-sparkline-empty {
  font-size: 9px;
  color: rgba(192,232,208,0.30);
  text-align: center;
  padding: 10px 0;
  letter-spacing: 0.1em;
}

/* Section labels */
.oil-section-label {
  font-size: 8px;
  letter-spacing: 0.18em;
  color: rgba(192,232,208,0.35);
  padding: 8px 12px 3px;
}

/* Production rows */
.oil-prod-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px;
  font-size: 10px;
}

.oil-prod-faction {
  width: 44px;
  font-size: 9px;
  letter-spacing: 0.12em;
  font-weight: bold;
  flex-shrink: 0;
}

.oil-prod-val {
  flex: 1;
  color: rgba(192,232,208,0.55);
  font-size: 9px;
}

.oil-prod-income {
  color: rgba(192,232,208,0.80);
  font-size: 10px;
  font-weight: bold;
}

/* Conflict zones */
.oil-zones {
  padding: 2px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.oil-zone {
  display: flex;
  align-items: center;
  gap: 6px;
}

.oil-zone-name {
  width: 110px;
  font-size: 8px;
  letter-spacing: 0.10em;
  color: rgba(192,232,208,0.70);
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.oil-zone-bar-track {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}

.oil-zone-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.oil-zone-score {
  font-size: 9px;
  width: 22px;
  text-align: right;
  font-weight: bold;
  flex-shrink: 0;
}

.oil-no-conflict {
  font-size: 9px;
  letter-spacing: 0.10em;
  color: rgba(192,232,208,0.25);
  padding: 4px 0;
}

/* Reserves row */
.oil-reserves-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 6px;
}

.oil-reserves-val {
  font-size: 13px;
  font-weight: bold;
  color: #ffd755;
}

.oil-reserves-est {
  font-size: 9px;
  color: rgba(192,232,208,0.40);
  letter-spacing: 0.08em;
}

/* Slider section */
.oil-slider-section {
  padding: 4px 12px 0;
}

.oil-slider-labels {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.oil-slider-pct {
  font-size: 16px;
  font-weight: bold;
  color: #ffd755;
  letter-spacing: 0.05em;
}

.oil-slider-yield {
  font-size: 11px;
  color: rgba(192,232,208,0.70);
  letter-spacing: 0.06em;
}

.oil-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(255,215,85,0.18);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.oil-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffd755;
  cursor: pointer;
  border: 2px solid #04101a;
  box-shadow: 0 0 6px rgba(255,215,85,0.50);
}

.oil-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffd755;
  cursor: pointer;
  border: 2px solid #04101a;
}

.oil-slider-ends {
  display: flex;
  justify-content: space-between;
  font-size: 8px;
  color: rgba(192,232,208,0.30);
  letter-spacing: 0.08em;
  margin-top: 3px;
  margin-bottom: 6px;
}

/* Sell button */
.oil-sell-btn {
  margin: 4px 12px 8px;
  padding: 8px 12px;
  background: rgba(255,215,85,0.10);
  border: 1px solid rgba(255,215,85,0.35);
  color: #ffd755;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.14em;
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.15s, border-color 0.15s;
  width: calc(100% - 24px);
  text-align: center;
  font-weight: bold;
}

.oil-sell-btn:hover:not(:disabled) {
  background: rgba(255,215,85,0.20);
  border-color: rgba(255,215,85,0.65);
  box-shadow: 0 0 12px rgba(255,215,85,0.15);
}

.oil-sell-btn:disabled {
  opacity: 0.30;
  cursor: not-allowed;
}

/* ── Straits & Lanes panel ─────────────────────────────────────────────────── */

/* Toll income summary row */
.straits-toll-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 12px 5px;
}
.straits-toll-label {
  font-size: 10px;
  color: #667788;
  letter-spacing: 0.05em;
}
.straits-toll-val {
  font-size: 11px;
  color: #5cffa3;
  font-family: "Share Tech Mono", monospace;
}

/* Chokepoint grid */
.straits-cp-grid {
  padding: 0 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 8px;
}
.straits-cp-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.straits-cp-name {
  font-size: 9px;
  color: #99aabb;
  letter-spacing: 0.04em;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.straits-cp-owner {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  width: 36px;
  text-align: center;
}
.straits-cp-flow {
  font-size: 8px;
  color: #445566;
  width: 26px;
  text-align: right;
  font-family: "Share Tech Mono", monospace;
}

/* Lane tanker list */
.straits-lanes-list {
  padding: 0 12px 6px;
}
.straits-lane-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.straits-lane-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.straits-lane-name {
  font-size: 9px;
  color: #99aabb;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.straits-lane-count {
  font-size: 9px;
  font-family: "Share Tech Mono", monospace;
  color: #aabbcc;
  white-space: nowrap;
}

/* ─────────────────────────────────────────────────────────────────────
   Recent-events ticker (floats top-right of map)
   ───────────────────────────────────────────────────────────────────── */
.event-feed {
  position: absolute;
  top: 70px;
  right: 12px;
  width: 260px;
  max-width: 32vw;
  background: rgba(12, 22, 32, 0.86);
  border: 1px solid #2a4a5f;
  font-family: "Share Tech Mono", monospace;
  color: #d8e3ea;
  z-index: 50;
  pointer-events: auto;
}
.event-feed-header {
  font-size: 9px;
  letter-spacing: 1.5px;
  padding: 5px 9px;
  background: linear-gradient(180deg, #122636 0%, #0c1620 100%);
  border-bottom: 1px solid #2a4a5f;
  color: #5cffa3;
}
.event-feed-list {
  display: flex;
  flex-direction: column;
  max-height: 280px;
  overflow-y: auto;
}
.event-feed-item {
  display: flex;
  gap: 6px;
  padding: 5px 9px;
  font-size: 10px;
  line-height: 1.3;
  border-bottom: 1px solid rgba(42,74,95,0.4);
}
.event-feed-item:last-child { border-bottom: none; }
.event-feed-day {
  color: #5cffa3;
  font-weight: bold;
  flex-shrink: 0;
  min-width: 42px;
}
.event-feed-text {
  flex: 1;
  word-break: break-word;
}
.event-feed-item--major   { border-left: 3px solid #ff3344; padding-left: 6px; }
.event-feed-item--minor   { border-left: 3px solid #ffcc33; padding-left: 6px; }
.event-feed-item--info    { border-left: 3px solid #2a4a5f; padding-left: 6px; }
.event-feed-item--alert {
  background: rgba(255, 51, 68, 0.18);
  border-left: 3px solid #ff3344;
  padding-left: 6px;
  animation: event-flash 1.2s ease-out;
}
@keyframes event-flash {
  0%   { background: rgba(255, 51, 68, 0.55); }
  100% { background: rgba(255, 51, 68, 0.18); }
}

/* Mobile: collapse to a single line near the top so it doesn't crowd the map */
/* DISABLED: superseded by the body.fieldop-mobile layer (JS-driven, single
   source of truth for the mobile UI). Kept as 0px so it never matches. */
@media (max-width: 0px) {
  .event-feed { width: 50vw; max-width: 240px; top: 50px; right: 8px; }
  .event-feed-list { max-height: 130px; }
}

/* ─────────────────────────────────────────────────────────────────────
   Diplomacy modal
   ───────────────────────────────────────────────────────────────────── */
.diplo-modal {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  font-family: "Share Tech Mono", monospace;
}
.diplo-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(2, 8, 14, 0.78);
  backdrop-filter: blur(3px);
}
.diplo-modal-card {
  position: relative;
  z-index: 1;
  background: #0c1620;
  border: 1px solid #2a4a5f;
  box-shadow: 0 0 28px rgba(92, 255, 163, 0.18);
  width: min(880px, 92vw);
  max-height: 86vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.diplo-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  background: linear-gradient(180deg, #122636 0%, #0c1620 100%);
  border-bottom: 1px solid #2a4a5f;
}
.diplo-modal-title {
  font-size: 13px;
  letter-spacing: 1.5px;
  color: #5cffa3;
  text-transform: uppercase;
}
.diplo-modal-close {
  background: transparent;
  border: 1px solid #2a4a5f;
  color: #aabbcc;
  font-size: 13px;
  width: 28px; height: 28px;
  cursor: pointer;
  line-height: 1;
}
.diplo-modal-close:hover {
  color: #ff7788;
  border-color: #ff3344;
}
.diplo-modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  color: #d8e3ea;
  font-size: 11px;
}

.dipl-section { margin-bottom: 20px; }
.dipl-section-title {
  font-size: 10px;
  letter-spacing: 1.8px;
  color: #5cffa3;
  margin-bottom: 10px;
  text-transform: uppercase;
  border-bottom: 1px dashed #2a4a5f;
  padding-bottom: 4px;
}

/* Faction roster */
.dipl-faction-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.dipl-faction {
  background: #08121b;
  padding: 10px 12px;
  border-left: 4px solid #555;
}
.dipl-faction-name {
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.dipl-faction-persona {
  font-size: 9px;
  letter-spacing: 1.4px;
  color: #aabbcc;
  margin-bottom: 8px;
  padding: 2px 5px;
  display: inline-block;
  background: rgba(170, 187, 204, 0.08);
  border: 1px solid #2a4a5f;
  cursor: help;
}
.dipl-persona-editable {
  cursor: pointer;
  user-select: none;
}
.dipl-peace-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 6px 10px;
  font-family: "Share Tech Mono", monospace;
  font-size: 10px;
  letter-spacing: 1px;
  background: rgba(255, 204, 51, 0.10);
  border: 1px solid #ffcc33;
  color: #ffcc33;
  cursor: pointer;
  transition: all 0.15s ease;
}
.dipl-peace-btn:hover {
  background: rgba(255, 204, 51, 0.25);
}
.dipl-peace-accept {
  background: rgba(92, 255, 163, 0.12);
  border-color: #5cffa3;
  color: #5cffa3;
}
.dipl-peace-accept:hover {
  background: rgba(92, 255, 163, 0.25);
}
.dipl-peace-reject {
  background: rgba(255, 51, 68, 0.10);
  border-color: #ff3344;
  color: #ff7788;
  margin-top: 4px;
}
.dipl-peace-reject:hover {
  background: rgba(255, 51, 68, 0.22);
}
.dipl-alliance-btn {
  background: rgba(74, 168, 255, 0.10);
  border-color: #4aa8ff;
  color: #4aa8ff;
}
.dipl-alliance-btn:hover {
  background: rgba(74, 168, 255, 0.25);
}

/* Quick-action row: GIFT + TRIBUTE buttons side by side */
.dipl-quick-row {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}
.dipl-quick-btn {
  flex: 1;
  padding: 5px 6px;
  font-family: "Share Tech Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.8px;
  border: 1px solid #2a4a5f;
  cursor: pointer;
  background: #0c1620;
  color: #aabbcc;
  transition: all 0.15s ease;
}
.dipl-quick-gift {
  background: rgba(92, 255, 163, 0.08);
  border-color: rgba(92, 255, 163, 0.4);
  color: #5cffa3;
}
.dipl-quick-gift:hover {
  background: rgba(92, 255, 163, 0.20);
}
.dipl-quick-tribute {
  background: rgba(255, 204, 51, 0.08);
  border-color: rgba(255, 204, 51, 0.4);
  color: #ffcc33;
}
.dipl-quick-tribute:hover {
  background: rgba(255, 204, 51, 0.20);
}
.dipl-defeated-tag {
  display: inline-block;
  font-size: 8px;
  letter-spacing: 1.5px;
  padding: 1px 5px;
  margin-left: 6px;
  background: rgba(255, 51, 68, 0.18);
  border: 1px solid #ff3344;
  color: #ff3344;
  vertical-align: middle;
}
.dipl-faction--defeated {
  opacity: 0.55;
}
.dipl-faction--defeated .dipl-faction-name { text-decoration: line-through; }
.dipl-persona-editable:hover {
  background: rgba(92, 255, 163, 0.18);
  color: #5cffa3;
  border-color: #5cffa3;
}
.dipl-opinion-label {
  font-size: 9px;
  color: #aabbcc;
  letter-spacing: 0.6px;
  margin-bottom: 4px;
}
.dipl-opinion-track {
  height: 6px;
  background: #1a2833;
  position: relative;
  border: 1px solid #2a4a5f;
}
.dipl-opinion-fill {
  height: 100%;
  transition: width 0.3s ease;
}

/* Relations grid */
.dipl-relations {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
}
.dipl-relations th,
.dipl-relations td {
  border: 1px solid #2a4a5f;
  padding: 6px 8px;
  text-align: center;
  vertical-align: middle;
}
.dipl-relations thead th {
  background: #122636;
  font-weight: bold;
  letter-spacing: 1px;
  font-size: 10px;
}
.dipl-relations tbody th {
  background: #122636;
  text-align: right;
  letter-spacing: 1px;
  font-weight: bold;
  font-size: 10px;
}
.dipl-cell-label {
  font-size: 9px;
  letter-spacing: 0.6px;
}
.dipl-cell-score {
  font-size: 13px;
  font-weight: bold;
  margin-top: 2px;
}
.dipl-cell-self    { background: #08121b; color: #555; }
.dipl-cell-ally    { background: rgba(92, 255, 163, 0.15); color: #5cffa3; }
.dipl-cell-neutral { background: rgba(170, 187, 204, 0.08); color: #d8e3ea; }
.dipl-cell-tense   { background: rgba(255, 204, 51, 0.13); color: #ffcc33; }
.dipl-cell-war     { background: rgba(255, 51, 68, 0.18); color: #ff7788; }

/* Event log */
.dipl-event-empty {
  color: #aabbcc;
  font-style: italic;
  padding: 12px 0;
}
.dipl-event-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 220px;
  overflow-y: auto;
}
.dipl-event {
  padding: 6px 10px;
  background: #08121b;
  border-left: 3px solid #2a4a5f;
  font-size: 10px;
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.dipl-event-day {
  color: #5cffa3;
  font-weight: bold;
  flex-shrink: 0;
  min-width: 60px;
}
.dipl-event-text {
  color: #d8e3ea;
}
.dipl-event-major { border-left-color: #ff3344; }
.dipl-event-minor { border-left-color: #ffcc33; }
.dipl-event-info  { border-left-color: #2a4a5f; }

/* DIPLOMACY + NATIONS buttons styling matches existing top-bar buttons */
#diplo-btn,
#nation-btn {
  font-family: "Share Tech Mono", monospace;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 4px 10px;
  background: #122636;
  border: 1px solid #2a4a5f;
  color: #5cffa3;
  cursor: pointer;
}
#diplo-btn:hover,
#nation-btn:hover {
  background: #1a3344;
  border-color: #5cffa3;
}

/* ─────────────────────────────────────────────────────────────────────
   Nation modal — totals, policy sliders, per-country table
   ───────────────────────────────────────────────────────────────────── */
.nation-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}
.nation-total {
  background: #08121b;
  border-left: 3px solid #2a4a5f;
  padding: 8px 10px;
}
.nation-total-label {
  font-size: 9px;
  color: #aabbcc;
  letter-spacing: 0.8px;
  margin-bottom: 4px;
}
.nation-total-val {
  font-size: 14px;
  font-weight: bold;
}

.nation-policy {
  background: #08121b;
  padding: 10px 14px;
}
.nation-policy-row {
  display: grid;
  grid-template-columns: 110px 1fr 50px;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.nation-policy-row label {
  font-size: 10px;
  letter-spacing: 0.8px;
  color: #aabbcc;
}
.nation-policy-row input[type="range"] {
  width: 100%;
  accent-color: #5cffa3;
}
.nation-policy-row span {
  font-size: 12px;
  font-weight: bold;
  color: #d8e3ea;
  text-align: right;
}
.nation-policy-hint {
  font-size: 10px;
  color: #aabbcc;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #2a4a5f;
  line-height: 1.5;
}

.nation-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
}
.nation-table th,
.nation-table td {
  border: 1px solid #2a4a5f;
  padding: 6px 8px;
  text-align: left;
}
.nation-table thead th {
  background: #122636;
  font-size: 9px;
  letter-spacing: 1px;
  color: #5cffa3;
}
.nation-sent-track {
  display: inline-block;
  width: 80px;
  height: 5px;
  background: #1a2833;
  border: 1px solid #2a4a5f;
  vertical-align: middle;
  margin-right: 6px;
}
.nation-sent-fill {
  height: 100%;
}
.nation-sent-num {
  font-size: 10px;
  font-weight: bold;
}

/* Per-country tax / welfare inputs */
.nation-policy-input {
  width: 42px;
  background: #08121b;
  border: 1px solid #2a4a5f;
  color: #d8e3ea;
  font-family: "Share Tech Mono", monospace;
  font-size: 10px;
  padding: 2px 4px;
  text-align: right;
}
.nation-policy-input:focus {
  outline: none;
  border-color: #5cffa3;
  background: #0c1620;
}
.nation-pi--override {
  color: #ffcc33;
  border-color: rgba(255, 204, 51, 0.5);
}
.nation-revert-btn {
  margin-left: 4px;
  background: transparent;
  border: none;
  color: #aabbcc;
  font-size: 12px;
  cursor: pointer;
  padding: 0 2px;
}
.nation-revert-btn:hover {
  color: #5cffa3;
}

/* ── Base-building (BUILD tab) + inflation badge ─────────────────────────── */
.build-help {
  font-size: 10px;
  color: #aabbcc;
  letter-spacing: 0.4px;
  line-height: 1.4;
  margin: 6px 2px 8px;
}
.build-card { cursor: pointer; }
.build-card-desc {
  font-size: 9.5px;
  color: #9fb3c8;
  line-height: 1.45;
  margin: 3px 0 4px;
}
.shop-infl {
  margin-left: 8px;
  font-size: 9px;
  letter-spacing: 0.6px;
  color: #ffcc33;
  border: 1px solid rgba(255, 204, 51, 0.4);
  padding: 1px 5px;
  border-radius: 2px;
}

/* ── Tariff sliders in the NATIONS modal ─────────────────────────────────── */
.tariff-slider {
  width: 84px;
  vertical-align: middle;
  accent-color: #ff8855;
}
.tariff-val {
  display: inline-block;
  min-width: 30px;
  font-family: "Share Tech Mono", monospace;
  font-size: 10px;
  color: #ffcc33;
  margin-left: 4px;
}

/* ── Setup buttons: LOAD GAME + PAN/SELECT toggle (top cluster) ───────────── */
/* Base styling so these match the DIPLOMACY / NATIONS buttons instead of
   falling back to the unstyled browser default. */
#load-setup-btn,
#mode-toggle-btn {
  font-family: "Share Tech Mono", monospace;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 4px 12px;
  background: #122636;
  border: 1px solid #2a4a5f;
  color: #5cffa3;
  cursor: pointer;
  border-radius: 2px;
  transition: background 120ms, border-color 120ms, box-shadow 120ms;
}
#load-setup-btn:hover,
#mode-toggle-btn:hover {
  background: #1a3344;
  border-color: #5cffa3;
  box-shadow: 0 0 10px rgba(92, 255, 163, 0.18);
}
#load-setup-btn:active,
#mode-toggle-btn:active {
  background: #21404f;
}
/* PAN mode = green (default). SELECT mode = cyan accent. */
#mode-toggle-btn.mode-toggle--select {
  background: rgba(158, 236, 255, 0.18);
  border-color: #9eecff;
  color: #9eecff;
}
#mode-toggle-btn.mode-toggle--select:hover {
  background: rgba(158, 236, 255, 0.28);
  border-color: #9eecff;
  box-shadow: 0 0 10px rgba(158, 236, 255, 0.25);
}

/* ── Economy HUD panel (bottom-bar meta column) ──────────────────────────── */
.econ-head {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--hud-edge);
}
.econ-head .econ-hi { white-space: nowrap; }
.econ-head .hud-dim { letter-spacing: 0.06em; }

.econ-body {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.econ-box { flex: 1 1 0; min-width: 0; }
.econ-box-title {
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--hud-dim);
  margin-bottom: 3px;
}
.econ-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.econ-line .econ-k { color: var(--hud-dim); letter-spacing: 0.04em; }
.econ-pos { color: #5cffa3; }
.econ-neg { color: #ff7788; }
.econ-line--net {
  margin-top: 3px;
  padding-top: 3px;
  border-top: 1px solid var(--hud-edge);
  font-weight: 700;
}
.econ-line--net .econ-k { color: var(--hud-fg); }

.econ-fac-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
}
.econ-fac-table th {
  text-align: right;
  font-weight: 400;
  color: var(--hud-dim);
  letter-spacing: 0.06em;
  padding: 0 0 2px;
}
.econ-fac-table th:first-child { text-align: left; }
.econ-fac-table td {
  text-align: right;
  padding: 1px 0;
  white-space: nowrap;
}
.econ-fac-table td:first-child { text-align: left; color: var(--hud-fg); }
.econ-fac-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: baseline;
}
.econ-fac-you td { font-weight: 700; }
.econ-fac-dead { opacity: 0.4; }
.econ-fac-dead td:first-child { text-decoration: line-through; }
.econ-fac-note {
  font-size: 8px;
  color: var(--hud-dim);
  margin-top: 4px;
  letter-spacing: 0.03em;
}

/* ── Recent-events feed docked in the bottom bar (next to balances) ───────── */
.event-feed--docked {
  position: static;
  top: auto; right: auto;
  width: 250px;
  flex: 0 1 250px;
  max-width: none;
  margin: 0;
  min-height: 0;
  min-width: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  border: none;
  border-right: 1px solid var(--hud-edge);
  background: rgba(8, 16, 24, 0.5);
  z-index: auto;
}
.event-feed--docked .event-feed-list {
  max-height: none;
  flex: 1 1 auto;
  overflow-y: auto;
}


/* ══════════════════════════════════════════════════════════════════════════
   MOBILE UI LAYER  —  added by the mobile overhaul
   ----------------------------------------------------------------------------
   Everything below is gated behind `body.fieldop-mobile`, a class added by
   src/mobile.js only on touch / small-screen devices. Desktop never sees any
   of this. It supersedes the older `@media (max-width: 768px)` block (which
   stays as a no-JS fallback) by using higher-specificity body-prefixed rules.
   ════════════════════════════════════════════════════════════════════════ */

:root {
  /* Tunable mobile chrome heights (kept in sync with src/mobile.js). */
  --mob-bar-h: 58px;
  --mob-top-h: 34px;
  --mob-safe-b: env(safe-area-inset-bottom, 0px);
  --mob-safe-t: env(safe-area-inset-top, 0px);
}

/* Stop the whole document from rubber-band scrolling on iOS so the map owns
   all touch gestures. */
body.fieldop-mobile {
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── App grid: full-bleed map + a single bottom command bar ──────────────── */
body.fieldop-mobile #app {
  grid-template-areas:
    "map"
    "cmdbar";
  grid-template-rows: 1fr calc(var(--mob-bar-h) + var(--mob-safe-b));
  grid-template-columns: 1fr;
}
body.fieldop-mobile:has(#cmd-bar.cmd-expanded) #app {
  grid-template-rows: 1fr auto;
}

/* The map fills everything; canvases already inset:0 so they follow. */
body.fieldop-mobile .map-shell { grid-area: map; }
body.fieldop-mobile .scanline { display: none; }   /* GPU cost, no value on phone */

/* ════════════════════════════════════════════════════════════════════════
   TOP STATUS PILL  (#mob-topbar, built by mobile.js)
   ════════════════════════════════════════════════════════════════════════ */
.mob-topbar { display: none; }
body.fieldop-mobile.fieldop-playing .mob-topbar {
  display: flex;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(var(--mob-top-h) + var(--mob-safe-t));
  padding: var(--mob-safe-t) 12px 0;
  align-items: center;
  gap: 16px;
  z-index: 120;
  font-family: "Share Tech Mono", monospace;
  background: linear-gradient(180deg, rgba(3,17,10,0.96) 0%, rgba(3,17,10,0.78) 70%, transparent 100%);
  pointer-events: none;            /* never eat map taps */
  text-shadow: 0 1px 4px #000;
}
.mob-topbar .mtb-item { display: flex; align-items: baseline; gap: 6px; }
.mob-topbar .mtb-item i {
  font-style: normal;
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--hud-dim);
}
.mob-topbar .mtb-item b {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--hud-fg);
  font-variant-numeric: tabular-nums;
}
.mob-topbar .mtb-oil b { color: #ffd755; }

/* ════════════════════════════════════════════════════════════════════════
   FLOATING MAP CONTROLS  (.mob-map-controls, built by mobile.js)
   Recenter-on-forces + zoom, docked to the map's right edge, thumb height.
   ════════════════════════════════════════════════════════════════════════ */
.mob-map-controls { display: none; }
body.fieldop-mobile.fieldop-playing .mob-map-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: absolute;
  right: 12px;
  bottom: 18px;
  z-index: 110;
}
body.fieldop-mobile.mob-unit-selected .mob-map-controls {
  /* lift above the action sheet when a unit is selected */
  bottom: calc(40vh + 18px);
  transition: bottom 0.18s ease;
}
.mmc-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--hud-edge);
  background: rgba(4, 18, 12, 0.86);
  backdrop-filter: blur(4px);
  color: var(--hud-fg);
  font-family: "Share Tech Mono", monospace;
  font-size: 26px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.45), 0 0 0 1px rgba(92,255,163,0.08) inset;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}
.mmc-btn:active {
  background: rgba(92, 255, 163, 0.22);
  transform: scale(0.94);
}
.mmc-btn.mmc-recenter, #mmc-recenter {
  color: #ffd755;
  font-size: 22px;
  border-color: rgba(255, 215, 85, 0.45);
}

/* ════════════════════════════════════════════════════════════════════════
   BOTTOM COMMAND BAR  (collapsed: two big buttons)
   ════════════════════════════════════════════════════════════════════════ */
body.fieldop-mobile #cmd-bar {
  display: flex !important;
  flex-direction: row;
  grid-template-rows: none;
  padding: 0 0 var(--mob-safe-b);
  align-items: stretch;
  background: var(--hud-bg);
  border-top: 1px solid var(--hud-edge);
}

/* cmd-state hosts the contextual confirm/primary button; hide its other bits */
body.fieldop-mobile .cmd-state {
  flex: 1;
  padding: 0; gap: 0;
  background: transparent;
  border: none;
  min-height: 0; height: auto;
}
body.fieldop-mobile .cmd-state > .hud-cluster { display: none; }
body.fieldop-mobile .cmd-state > .hud-cluster:has(#confirm-btn) {
  display: flex; flex: 1; margin: 0 !important;
}

body.fieldop-mobile .cmd-main { flex: 1; padding: 0; gap: 0; min-height: 0; }

/* Collapsed: hide the dense desktop clusters */
body.fieldop-mobile .cmd-detail,
body.fieldop-mobile .cmd-actions,
body.fieldop-mobile .cmd-econ,
body.fieldop-mobile .cmd-speed,
body.fieldop-mobile .event-feed--docked,
body.fieldop-mobile .mob-hide,
body.fieldop-mobile .mob-hide-flex { display: none !important; }

body.fieldop-mobile .cmd-meta {
  width: 100%; padding: 0; gap: 0; flex: 1;
  display: flex; align-items: stretch;
}

/* The two full-height bottom buttons */
body.fieldop-mobile #confirm-btn,
body.fieldop-mobile .mob-sidebar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%; height: 100%;
  border: none;
  border-radius: 0;
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 80ms, color 80ms, opacity 80ms;
}
body.fieldop-mobile .mob-sidebar-btn {
  border-left: 1px solid var(--hud-edge);
  background: color-mix(in srgb, var(--hud-fg) 12%, transparent);
  color: var(--hud-fg);
}
body.fieldop-mobile .mob-sidebar-btn:active {
  background: color-mix(in srgb, var(--hud-fg) 26%, transparent);
}
body.fieldop-mobile #confirm-btn:disabled { cursor: default; opacity: 0.5; }

/* Chevron affordance on the GAME ON toggle */
body.fieldop-mobile #cmd-bar:not(.cmd-expanded) #confirm-btn.playing::after { content: "  \25B4"; margin-left: 8px; }
body.fieldop-mobile #cmd-bar.cmd-expanded #confirm-btn.playing::after        { content: "  \25BE"; margin-left: 8px; }

/* ════════════════════════════════════════════════════════════════════════
   EXPANDED COMMAND BAR  (GAME ON tapped → econ / speed / faction sheet)
   Compact, scrollable, never taller than ~62vh so the map stays visible.
   ════════════════════════════════════════════════════════════════════════ */
body.fieldop-mobile #cmd-bar.cmd-expanded {
  flex-direction: column;
  align-items: stretch;
  max-height: 62vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
body.fieldop-mobile #cmd-bar.cmd-expanded .cmd-state { flex-direction: column; flex: 0 0 auto; padding: 0; }
body.fieldop-mobile #cmd-bar.cmd-expanded .cmd-state > .hud-cluster {
  display: flex; width: 100%; padding: 8px 16px; margin: 0 !important;
  box-sizing: border-box; border-bottom: 1px solid var(--hud-edge);
}
body.fieldop-mobile #cmd-bar.cmd-expanded .cmd-state > .hud-cluster:first-child { display: none; }
body.fieldop-mobile #cmd-bar.cmd-expanded .cmd-state > .hud-cluster:has(#confirm-btn) {
  flex: 0 0 var(--mob-bar-h); padding: 0; border-bottom: none;
}
body.fieldop-mobile #cmd-bar.cmd-expanded .cmd-main { flex-direction: column; width: 100%; flex: 0 0 auto; padding: 0; gap: 0; }
body.fieldop-mobile #cmd-bar.cmd-expanded .cmd-econ,
body.fieldop-mobile #cmd-bar.cmd-expanded .cmd-speed,
body.fieldop-mobile #cmd-bar.cmd-expanded .event-feed--docked {
  display: flex !important;
  width: 100%; padding: 12px 16px;
  border-top: 1px solid var(--hud-edge);
  box-sizing: border-box;
}
body.fieldop-mobile #cmd-bar.cmd-expanded .cmd-econ  { flex-wrap: wrap; gap: 10px; font-size: 12px; align-items: center; }
body.fieldop-mobile #cmd-bar.cmd-expanded .cmd-speed { flex-wrap: wrap; gap: 8px; align-items: center; }
body.fieldop-mobile #cmd-bar.cmd-expanded .event-feed--docked { flex: 0 0 auto; border-right: none; }
body.fieldop-mobile #cmd-bar.cmd-expanded .event-feed--docked .event-feed-list { max-height: 150px; }
body.fieldop-mobile #cmd-bar.cmd-expanded .cmd-meta { flex-direction: column; width: 100%; padding: 0; gap: 0; }
body.fieldop-mobile #cmd-bar.cmd-expanded .mob-sidebar-btn {
  display: flex !important;
  border-left: none; border-top: 1px solid var(--hud-edge);
  height: var(--mob-bar-h); flex: 0 0 var(--mob-bar-h);
}

/* Bigger speed / pause controls for fingers */
body.fieldop-mobile .speed-btn { padding: 8px 12px; font-size: 12px; min-height: 40px; min-width: 40px; }
body.fieldop-mobile .pause-btn { padding: 8px 14px; min-height: 40px; }

/* ════════════════════════════════════════════════════════════════════════
   SELECTED-UNIT ACTION SHEET  (#mob-action-sheet, populated by mobile.js)
   Docked above the command bar; map stays visible above it.
   ════════════════════════════════════════════════════════════════════════ */
.mob-action-sheet { display: none; }
body.fieldop-mobile.mob-unit-selected .mob-action-sheet {
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--mob-bar-h) + var(--mob-safe-b));
  max-height: 40vh;
  z-index: 115;
  background: linear-gradient(180deg, rgba(6,20,14,0.97) 0%, rgba(3,14,9,0.98) 100%);
  border-top: 2px solid var(--hud-edge);
  box-shadow: 0 -6px 22px rgba(0,0,0,0.5);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: mob-sheet-up 0.16s ease-out;
}
@keyframes mob-sheet-up { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Unit card inside the sheet */
body.fieldop-mobile.mob-unit-selected #mob-action-sheet .cmd-detail {
  display: block !important;
  padding: 12px 16px 6px;
}
body.fieldop-mobile.mob-unit-selected #mob-action-sheet .cmd-idle { display: none !important; }
body.fieldop-mobile.mob-unit-selected #mob-action-sheet .cmd-unit-card { font-size: 12px; }

/* Action buttons: large, wrap into a comfortable grid */
body.fieldop-mobile.mob-unit-selected #mob-action-sheet .cmd-actions {
  display: flex !important;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 16px 14px;
}
body.fieldop-mobile.mob-unit-selected #mob-action-sheet .cmd-actions .cmd-btn {
  flex: 1 1 calc(50% - 8px);
  min-height: 46px;
  font-size: 12px;
  letter-spacing: 0.08em;
}

/* ════════════════════════════════════════════════════════════════════════
   FORCES BOTTOM SHEET  (#right-sidebar.mob-open)
   ════════════════════════════════════════════════════════════════════════ */
body.fieldop-mobile #right-sidebar {
  display: none;
  position: fixed;
  bottom: calc(var(--mob-bar-h) + var(--mob-safe-b));
  left: 0; right: 0;
  height: 46vh;
  max-height: 46vh;
  z-index: 95;
  border: none;
  border-top: 2px solid var(--hud-edge);
  box-shadow: 0 -6px 22px rgba(0,0,0,0.5);
  overflow: hidden;
}
body.fieldop-mobile #right-sidebar.mob-open {
  display: flex;
  animation: mob-sheet-up 0.18s ease-out;
}

/* Touch-friendly roster / shop / placement rows */
body.fieldop-mobile .gp-row      { padding: 10px 12px; min-height: 48px; }
body.fieldop-mobile .gp-toggle-btn { min-height: 42px; }
body.fieldop-mobile .shop-card   { padding: 12px; min-height: 56px; }
body.fieldop-mobile .save-btn    { min-height: 42px; padding: 8px 6px; }
body.fieldop-mobile .pp-card     { padding: 12px; min-height: 52px; }
body.fieldop-mobile .pp-begin    { min-height: 48px; font-size: 14px; }

/* ════════════════════════════════════════════════════════════════════════
   INFO PANEL + MODALS  — readable, thumb-sized on small screens
   ════════════════════════════════════════════════════════════════════════ */
body.fieldop-mobile #info-panel {
  font-size: 11px;
  min-width: 180px;
  max-width: 76vw;
  padding: 12px 14px 14px;
}
body.fieldop-mobile .ip-title { font-size: 14px; }

body.fieldop-mobile .mode-modal-cards { flex-direction: column; }
body.fieldop-mobile .mode-card { min-height: 92px; padding: 16px; }

body.fieldop-mobile .diplo-modal-card,
body.fieldop-mobile .nation-modal .diplo-modal-card { width: 96vw; max-height: 88vh; }
body.fieldop-mobile .diplo-modal-close { width: 38px; height: 38px; font-size: 16px; }
body.fieldop-mobile .game-menu-btn { min-height: 50px; font-size: 14px; }
body.fieldop-mobile .setup-count-btn { min-height: 48px; }
body.fieldop-mobile .setup-btn { min-height: 50px; }

/* Recenter / zoom controls hide while a full-screen overlay/modal is up. */
body.fieldop-mobile:has(.mode-overlay:not([style*="display:none"]):not([style*="display: none"])) .mob-map-controls,
body.fieldop-mobile:has(.mode-overlay:not([style*="display:none"]):not([style*="display: none"])) .mob-topbar { display: none; }

/* When the econ/stats sheet is open (GAME ON tapped), give it the floor:
   hide the unit action sheet and drop the floating controls back to base. */
body.fieldop-mobile:has(#cmd-bar.cmd-expanded) .mob-action-sheet { display: none !important; }
body.fieldop-mobile.mob-unit-selected:has(#cmd-bar.cmd-expanded) .mob-map-controls { bottom: 18px; }

/* The FORCES roster sheet also takes the floor over the action sheet + controls. */
body.fieldop-mobile:has(#right-sidebar.mob-open) .mob-action-sheet,
body.fieldop-mobile:has(#right-sidebar.mob-open) .mob-map-controls { display: none !important; }
