:root {
  --bg: #14161a;
  --panel: #1e2128;
  --border: #2e333d;
  --text: #d8dce4;
  --accent: #e0a83c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

#topbar h1 { font-size: 18px; margin: 0; font-weight: 600; }
#topbar h1 span { color: var(--accent); }
#version-badge { font-size: 11px; opacity: 0.6; margin-left: 8px; font-weight: 400; color: var(--text); }

#controls { display: flex; align-items: center; gap: 12px; }
#controls select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
}
#controls input {
  width: 90px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
}
#controls button {
  background: var(--accent);
  color: #14161a;
  border: none;
  border-radius: 4px;
  padding: 6px 14px;
  font-weight: 600;
  cursor: pointer;
}
#controls button:disabled { opacity: 0.5; cursor: wait; }
#status { font-size: 13px; opacity: 0.8; min-width: 160px; }

/* Hex hover tooltip */
#hex-tooltip {
  position: fixed; z-index: 300; pointer-events: none;
  background: rgba(10,13,18,0.94); border: 1px solid var(--border);
  border-radius: 5px; padding: 7px 10px; font-size: 11px; line-height: 1.5;
  min-width: 140px; box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  display: none;
}
#hex-tooltip .tt-id {
  font-size: 13px; font-weight: 700; color: var(--accent);
  letter-spacing: 1px; cursor: pointer; pointer-events: all;
  display: flex; align-items: center; gap: 5px; margin-bottom: 4px;
}
#hex-tooltip .tt-id:hover { text-decoration: underline; }
#hex-tooltip .tt-row { display: flex; justify-content: space-between; gap: 12px; }
#hex-tooltip .tt-label { opacity: 0.5; }
#hex-tooltip .tt-sep { height: 1px; background: var(--border); margin: 5px 0; }
#hex-tooltip .tt-copy-hint { font-size: 9px; opacity: 0.35; margin-top: 3px; }
#hex-tooltip.copied .tt-id { color: #4caf50; }

/* City info card — a bigger cousin of #hex-tooltip, shown only while
   hovering a city hex (see main.js's _showCityCard). */
#city-card {
  position: fixed; z-index: 310; pointer-events: none;
  background: rgba(10,13,18,0.97); border: 2px solid var(--accent);
  border-radius: 8px; padding: 14px; font-size: 12px; line-height: 1.5;
  width: 280px; box-shadow: 0 10px 40px rgba(0,0,0,0.7);
  display: none;
}
#city-card .cc-header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; margin-bottom: 8px;
}
#city-card .cc-name { font-size: 17px; font-weight: 700; color: var(--accent); }
#city-card .cc-type  { font-size: 10px; opacity: 0.65; text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }
#city-card canvas#cc-map-canvas {
  display: block; width: 100%; height: auto; aspect-ratio: 1 / 1;
  border-radius: 5px; margin-bottom: 10px; border: 1px solid var(--border);
}
#city-card .cc-stats { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }
#city-card .cc-row { display: flex; justify-content: space-between; gap: 10px; }
#city-card .cc-label { opacity: 0.55; }
#city-card .cc-history-label {
  font-size: 10px; opacity: 0.5; text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 4px; border-top: 1px solid var(--border); padding-top: 8px;
}
#city-card .cc-history { display: flex; flex-direction: column; gap: 3px; font-size: 11px; }
#city-card .cc-history-row { display: flex; justify-content: space-between; gap: 8px; opacity: 0.85; }

/* Find hex */
.find-hex-wrap { display: flex; gap: 4px; align-items: center; }
.find-hex-wrap input {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 4px 6px; border-radius: 4px; font: inherit; font-size: 12px;
}
.find-hex-wrap input:focus { outline: none; border-color: var(--accent); }
.find-hex-wrap input.flash-ok  { border-color: #4caf50 !important; }
.find-hex-wrap input.flash-err { border-color: #c41e3a !important; }

/* Overlay toggle buttons (Units / Names) */
.overlay-toggles { display: flex; gap: 4px; }
.ov-toggle {
  background: var(--bg) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 4px;
  padding: 5px 10px !important;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.15s, border-color 0.15s;
}
.ov-toggle.active {
  opacity: 1;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

/* AI settings button + badge */
#ai-settings-wrap { position: relative; display: flex; gap: 6px; }
#legend-btn, #settings-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
#legend-btn:hover, #settings-btn:hover { border-color: var(--accent); }
#settings-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s;
}
#settings-btn:hover { border-color: var(--accent); }
#ai-badge { opacity: 0.65; font-size: 11px; }
#ai-badge.ai-badge-warn { opacity: 1; color: #e0a832; font-weight: 700; }

/* Unit right-click context menu */
#unit-ctx-menu,
#enemy-ctx-menu {
  position: fixed;
  z-index: 1200;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  min-width: 170px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  display: none;
  flex-direction: column;
  gap: 1px;
  font-size: 12px;
}
#unit-ctx-menu .ctx-item,
#enemy-ctx-menu .ctx-item {
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 7px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
}
#unit-ctx-menu .ctx-item:hover:not(:disabled),
#enemy-ctx-menu .ctx-item:hover:not(:disabled) { background: rgba(224,168,60,0.12); color: var(--accent); }
#unit-ctx-menu .ctx-item:disabled,
#enemy-ctx-menu .ctx-item:disabled { opacity: 0.35; cursor: default; }
#unit-ctx-menu .ctx-sep,
#enemy-ctx-menu .ctx-sep { height: 1px; background: var(--border); margin: 3px 2px; }
#unit-ctx-menu .ctx-status,
#enemy-ctx-menu .ctx-status { padding: 6px 10px 4px; font-size: 11px; line-height: 1.5; color: #9aa; }
#unit-ctx-menu .ctx-status .ctx-unit-name,
#enemy-ctx-menu .ctx-status .ctx-unit-name { display: block; color: var(--text); font-size: 12px; font-weight: 600; margin-bottom: 2px; }
#unit-ctx-menu .ctx-status .ctx-move-val,
#enemy-ctx-menu .ctx-status .ctx-move-val { color: var(--accent); font-weight: 600; }
#unit-ctx-menu .ctx-status .ctx-blocked,
#enemy-ctx-menu .ctx-status .ctx-blocked { margin-top: 4px; color: #e05252; font-weight: 600; }
/* Tagged-target state on the enemy menu's toggle */
#enemy-ctx-menu .ctx-item.ctx-tagged { color: #ffc440; font-weight: 600; }
#enemy-ctx-menu .ctx-status .ctx-tag-note { margin-top: 4px; color: #ffc440; }

/* Hex right-click context menu (e.g. Deploy Assault Bridge) */
#hex-ctx-menu {
  position: fixed;
  z-index: 1200;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  min-width: 190px;
  max-width: 230px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  display: none;
  flex-direction: column;
  gap: 1px;
  font-size: 12px;
}
#hex-ctx-menu .ctx-status { padding: 6px 10px 4px; color: var(--dim, #9aa); font-size: 11px; line-height: 1.4; }
#hex-ctx-menu .ctx-item {
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 7px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
}
#hex-ctx-menu .ctx-item:hover:not(:disabled) { background: rgba(224,168,60,0.12); color: var(--accent); }
#hex-ctx-menu .ctx-item:disabled { opacity: 0.35; cursor: default; }

/* Training camp right-click context menu (place / remove confirmation) */
#camp-ctx-menu {
  position: fixed;
  z-index: 1200;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  min-width: 200px;
  max-width: 250px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  display: none;
  flex-direction: column;
  gap: 1px;
  font-size: 12px;
}
#camp-ctx-menu .ctx-status { padding: 6px 10px 4px; color: var(--dim, #9aa); font-size: 11px; line-height: 1.4; }
#camp-ctx-menu .ctx-item {
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 7px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
}
#camp-ctx-menu .ctx-item:hover:not(:disabled) { background: rgba(224,168,60,0.12); color: var(--accent); }
#camp-ctx-menu .ctx-item-danger { color: #e05252; }
#camp-ctx-menu .ctx-item-danger:hover:not(:disabled) { background: rgba(224,82,82,0.12); color: #e05252; }

/* Army picker (Add to Army… submenu) */
#army-picker-menu {
  position: fixed;
  z-index: 1210;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  min-width: 170px;
  max-width: 230px;
  max-height: 260px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  display: none;
  flex-direction: column;
  gap: 1px;
  font-size: 12px;
}
#army-picker-menu .ctx-item {
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 7px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  width: 100%;
}
#army-picker-menu .ctx-item:hover:not(:disabled) { background: rgba(224,168,60,0.12); color: var(--accent); }
#army-picker-menu .ctx-item:disabled { opacity: 0.35; cursor: default; }
#army-picker-menu .ctx-status { padding: 6px 10px; color: #9aa; font-size: 11px; line-height: 1.4; }

/* Unit info modal (Move History / Unit History) */
#unit-info-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(10,13,18,0.75);
}
#unit-info-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 18px;
  max-height: 80vh;
  max-width: 460px;
  width: 90vw;
  overflow-y: auto;
  font-size: 12px;
}
#unit-info-title { font-weight: 700; color: var(--accent); font-size: 13px; margin-bottom: 10px; cursor: grab; user-select: none; }
#unit-info-title:active { cursor: grabbing; }
#unit-info-content { display: flex; flex-direction: column; gap: 6px; line-height: 1.5; }
#unit-info-content .ui-row { display: flex; justify-content: space-between; gap: 10px; }
#unit-info-content .ui-note { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); opacity: 0.6; font-size: 11px; }
#unit-info-close {
  margin-top: 14px;
  width: 100%;
  background: var(--border);
  border: none;
  color: var(--text);
  border-radius: 4px;
  padding: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

/* AI Settings dropdown panel */
#settings-panel {
  position: fixed;
  top: 44px;
  right: 12px;
  z-index: 300;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  width: 350px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Provider selector component (reusable) */
.sp-provider-selector {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0;
}
.sp-provider-selector-label {
  font-size: 11px;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: var(--text);
}
.sp-provider-selector-radios {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sp-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.6;
}
.sp-provider-nudge {
  font-size: 11px;
  line-height: 1.5;
  color: #e0a832;
  background: rgba(224,168,60,0.1);
  border: 1px solid rgba(224,168,60,0.3);
  border-radius: 4px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.sp-providers { display: flex; flex-direction: column; gap: 6px; }
.sp-radio {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}
.sp-tag {
  margin-left: auto;
  font-size: 10px;
  opacity: 0.45;
  background: var(--bg);
  border-radius: 3px;
  padding: 1px 5px;
}
.sp-tag-rec { opacity: 0.85; color: #e0a832; }
.sp-row { display: flex; flex-direction: column; gap: 6px; }
.sp-label { font-size: 11px; opacity: 0.55; }
.sp-input {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 12px;
}
.sp-select {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 12px;
}
.sp-refresh {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
  transition: border-color 0.15s;
}
.sp-refresh:hover { border-color: var(--accent); }
.sp-hint { font-size: 10px; opacity: 0.4; line-height: 1.5; }
.sp-link {
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 1px dotted currentColor;
}
.sp-link:hover { opacity: 0.8; }

/* "key saved" indicator on each provider radio. Empty by default — settings.js
   fills in text + an `ok` / `none` class, so a provider with no key stored just
   renders nothing rather than a distracting red badge. */
.sp-keystate {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}
.sp-keystate.ok {
  color: #6cc06c;
  background: rgba(108, 192, 108, 0.12);
}
.sp-keystate.none { opacity: 0.3; }
.sp-save {
  background: var(--accent);
  color: #0a0d12;
  border: none;
  border-radius: 4px;
  padding: 8px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.sp-save:hover { opacity: 0.88; }
.sp-actions { display: flex; gap: 8px; }
.sp-test {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.sp-test:hover { border-color: var(--accent); }
.sp-test:disabled { opacity: 0.4; cursor: wait; }
.sp-test-result {
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 4px;
  line-height: 1.5;
}
.sp-test-result.ok  { background: rgba(80,180,80,0.12);  color: #6dca6d; border: 1px solid rgba(80,180,80,0.3); }
.sp-danger-btn {
  width: 100%;
  background: #c43e3e;
  color: #ffffff;
  border: none;
  border-radius: 4px;
  padding: 8px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(196,62,62,0.3);
  transition: background 0.15s, box-shadow 0.15s;
}
.sp-danger-btn:hover { background: #d84b4b; box-shadow: 0 4px 12px rgba(196,62,62,0.5); }
.sp-test-result.err { background: rgba(220,70,70,0.12);  color: #e07070; border: 1px solid rgba(220,70,70,0.3); }

/* ===== Simulation Clock Bar ===== */
#clock-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 5px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  flex-shrink: 0;
}

#sim-clock {
  display: flex;
  gap: 10px;
  font-family: Consolas, monospace;
  font-size: 14px;
  font-weight: 600;
  min-width: 160px;
}
#sim-month { color: var(--accent); }
#sim-day   { opacity: 0.7; }

#sim-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
#sim-play {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
#sim-play:hover { border-color: var(--accent); color: var(--accent); }

@keyframes sim-play-pulse {
  0%, 100% {
    background: var(--bg);
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 0 0 rgba(224,168,60,0.7);
    transform: scale(1);
  }
  50% {
    background: var(--accent);
    color: #0a0d12;
    border-color: var(--accent);
    box-shadow: 0 0 0 12px rgba(224,168,60,0);
    transform: scale(1.18);
  }
}
#sim-play.sim-play-pulse {
  font-weight: 700;
  animation: sim-play-pulse 1s ease-in-out infinite;
}

#clock-reinforce-countdown {
  font-size: 11px;
  opacity: 0.6;
  white-space: nowrap;
  margin-left: 4px;
}

#day-countdown-display {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  margin-left: 2px;
}

#sim-phase {
  margin-left: auto;
  font-size: 12px;
  opacity: 0.5;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

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

#map-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

#map-canvas {
  display: block;
  background: #0a0d12;
  cursor: grab;
}
#map-canvas:active { cursor: grabbing; }

#sidebar {
  width: 280px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
  overflow: visible;
  transition: width 0.2s ease, border-color 0.2s ease;
}
#sidebar.collapsed {
  width: 0;
  border-left-color: transparent;
}
#sidebar.collapsed #sidebar-inner { display: none; }

#sidebar-inner {
  padding: 12px 16px;
  overflow-y: auto;
  height: 100%;
  box-sizing: border-box;
}

#sidebar-toggle {
  position: absolute;
  top: 50%;
  left: -15px;
  transform: translateY(-50%);
  width: 22px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 6px 0 0 6px;
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
  opacity: 0.7;
  z-index: 5;
  transition: opacity 0.15s;
}
#sidebar-toggle:hover { opacity: 1; border-color: var(--accent); color: var(--accent); }

#sidebar h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 1px; opacity: 0.7; }
#hex-info, #world-stats { font-size: 13px; line-height: 1.6; }
.hint { opacity: 0.5; font-style: italic; }
#hex-info table, #world-stats table { width: 100%; border-collapse: collapse; }
#hex-info td, #world-stats td { padding: 2px 0; }
#hex-info td:last-child, #world-stats td:last-child { text-align: right; font-family: Consolas, monospace; }
ul.combat-log { margin: 4px 0; padding-left: 18px; font-size: 12px; line-height: 1.7; opacity: 0.9; }
#combat-log { font-size: 12px; }
.combat-entry { border-bottom: 1px solid var(--border); padding: 6px 0; }
.combat-entry:last-child { border-bottom: none; }
.combat-entry .ce-header { font-weight: 600; color: var(--accent); margin-bottom: 3px; }
.combat-entry ul { margin: 0; padding-left: 16px; line-height: 1.6; opacity: 0.85; }
.combat-entry .ce-outcome { font-size: 11px; opacity: 0.55; margin-top: 2px; }

/* ===== Orders button ===== */
.orders-btn {
  background: rgba(224,168,60,0.12);
  color: var(--accent);
  border: 1px solid rgba(224,168,60,0.35);
  border-radius: 4px;
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  margin-left: 8px;
}
.orders-btn:hover { background: rgba(224,168,60,0.22); border-color: var(--accent); }
.orders-btn.orders-locked {
  background: rgba(106,193,105,0.12);
  color: #6ac169;
  border-color: rgba(106,193,105,0.4);
}
.orders-btn.orders-locked:hover { background: rgba(106,193,105,0.22); border-color: #6ac169; }

/* ===== Phase III Directive Overlay ===== */
#directive-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(10,13,18,0.75);
  display: block;
  padding: 16px;
}

#directive-panel {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: 540px;
  overflow: hidden;
  animation: setupFadeIn 0.2s ease;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  cursor: grab;
}
#directive-panel.dragging { cursor: grabbing; }
#directive-panel .dp-drag-handle {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 8px;
  background: linear-gradient(to bottom, var(--accent), transparent);
  cursor: grab;
  opacity: 0;
  transition: opacity 0.2s;
}
#directive-panel:hover .dp-drag-handle { opacity: 0.3; }
#directive-panel.dragging .dp-drag-handle { opacity: 1; }

.dp-screen {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
}

.dp-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.dp-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
}
.dp-month { font-size: 12px; opacity: 0.5; font-family: Consolas, monospace; }

.dp-faction-bar { font-size: 13px; font-weight: 600; }
.dp-label { font-size: 12px; opacity: 0.55; }

.dp-textarea {
  width: 100%;
  min-height: 110px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
}
.dp-textarea:focus { outline: none; border-color: var(--accent); }

.dp-echo {
  background: var(--bg);
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  font-size: 12px;
  opacity: 0.75;
  border-radius: 0 4px 4px 0;
  font-style: italic;
}

.dp-qlist { display: flex; flex-direction: column; gap: 10px; }
.dp-qitem { display: flex; flex-direction: column; gap: 4px; }
.dp-qlabel { font-size: 13px; opacity: 0.85; line-height: 1.5; }
.dp-qinput {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 13px;
}
.dp-qinput:focus { outline: none; border-color: var(--accent); }

.dp-plan {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.7;
}

.dp-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}
.dp-btn-sec {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.15s;
}
.dp-btn-sec:hover { opacity: 1; }
.dp-btn-pri {
  background: var(--accent);
  color: #0a0d12;
  border: none;
  border-radius: 4px;
  padding: 8px 18px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.dp-btn-pri:hover  { opacity: 0.88; }
.dp-btn-pri:disabled { opacity: 0.4; cursor: wait; }

.dp-error {
  margin: 0 24px 16px;
  padding: 8px 12px;
  background: rgba(220,70,70,0.12);
  color: #e07070;
  border: 1px solid rgba(220,70,70,0.3);
  border-radius: 4px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.dp-error-action {
  background: #e07070;
  color: #1a0d0d;
  border: none;
  border-radius: 3px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.dp-error-action:hover { opacity: 0.85; }

/* ===== Phase I Setup Overlay ===== */
#setup-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(10, 13, 18, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 16px;
}

.setup-screen {
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 960px;
  animation: setupFadeIn 0.25s ease;
}

@keyframes setupFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.setup-title { text-align: center; }
.setup-title h1 { font-size: 28px; color: var(--accent); margin: 0 0 6px; }
.setup-title p  { color: var(--text); opacity: 0.5; margin: 0; font-size: 14px; }

/* Map size grid */
.mapsize-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 780px;
}

.mapsize-card {
  position: relative;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 22px 18px;
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.mapsize-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 12px 32px rgba(0,0,0,0.55);
}

/* Proportional glyph: a filled block sized to the preset's share of the
   Large map, so the size difference reads at a glance. */
.ms-glyph {
  width: 78px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ms-glyph i {
  display: block;
  background: var(--accent);
  opacity: 0.32;
  border-radius: 2px;
}
.mapsize-card:hover .ms-glyph i { opacity: 0.6; }

.ms-name  { font-size: 18px; font-weight: 700; letter-spacing: 0.5px; }
.ms-powers { font-size: 12px; opacity: 0.75; line-height: 1.6; }
.ms-dims  { font-size: 11px; opacity: 0.45; letter-spacing: 0.5px; }
.ms-desc  { font-size: 11px; opacity: 0.55; line-height: 1.6; }

.ms-training-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #1a1508;
  background: var(--accent);
  border-radius: 3px;
  padding: 3px 6px;
}

.ms-tutorial-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--accent);
  background: rgba(224,168,60,0.12);
  border: 1px solid rgba(224,168,60,0.4);
  border-radius: 3px;
  padding: 3px 6px;
}

.mapsize-training-header {
  text-align: center;
  margin-top: 8px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  width: 100%;
  max-width: 780px;
}
.mapsize-training-header h2 { font-size: 16px; margin: 0 0 4px; opacity: 0.85; }
.mapsize-training-header p  { font-size: 12px; opacity: 0.5; margin: 0; }

.mapsize-grid-training {
  max-width: 540px;
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 640px) {
  .mapsize-grid { grid-template-columns: 1fr; }
  .mapsize-grid-training { grid-template-columns: 1fr; }
}

/* Faction grid */
.faction-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  width: 100%;
}

.faction-card {
  background: var(--panel);
  border: 2px solid;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  flex-direction: column;
}
.faction-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.55);
}

.fc-top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
}
.fc-emblem { flex-shrink: 0; }
.fc-identity { flex: 1; }
.fc-name     { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.fc-doctrine { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 600; }
.fc-desc  { padding: 0 16px 12px; font-size: 12px; opacity: 0.65; line-height: 1.65; flex: 1; }
.fc-stats {
  display: flex;
  gap: 14px;
  padding: 8px 16px;
  font-size: 11px;
  opacity: 0.5;
  border-top: 1px solid var(--border);
}
.fc-btn {
  display: block;
  width: calc(100% - 24px);
  margin: 10px 12px 12px;
  padding: 9px;
  border: none;
  border-radius: 4px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  color: #0a0d12;
  letter-spacing: 0.5px;
  transition: opacity 0.15s;
}
.fc-btn:hover { opacity: 0.85; }

/* Army builder */
.army-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.back-btn {
  align-self: flex-start;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.back-btn:hover { opacity: 1; }

.army-hdr { display: flex; align-items: center; gap: 14px; }
.army-fname    { font-size: 20px; font-weight: 700; }
.army-subtitle { font-size: 12px; opacity: 0.5; margin-top: 3px; }

.budget-bar  { height: 6px; background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden; }
.budget-fill { height: 100%; border-radius: 3px; transition: width 0.2s ease; }
.budget-text { font-size: 11px; opacity: 0.5; margin-top: 5px; text-align: right; }

#army-rows { display: flex; flex-direction: column; gap: 0; }

.army-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.army-row:last-child { border-bottom: none; }

.ar-label { font-weight: 600; font-size: 13px; }
.ar-cost  { font-size: 11px; opacity: 0.42; margin-top: 1px; }

.ar-controls { display: flex; align-items: center; gap: 6px; }
.ar-btn {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 4px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s, border-color 0.15s;
}
.ar-btn:disabled { opacity: 0.22; cursor: not-allowed; }
.ar-btn:not(:disabled):hover { border-color: var(--accent); color: var(--accent); }

.ar-count { min-width: 30px; text-align: center; font-weight: 700; font-size: 15px; }
.ar-total { font-size: 12px; opacity: 0.55; min-width: 48px; text-align: right; }
.ar-min   { font-size: 10px; opacity: 0.32; min-width: 38px; text-align: right; }

.army-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 4px;
}
.army-total { font-size: 12px; opacity: 0.48; }
.deploy-btn {
  background: var(--accent);
  color: #0a0d12;
  border: none;
  border-radius: 4px;
  padding: 10px 22px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: opacity 0.15s;
}
.deploy-btn:hover:not(:disabled) { opacity: 0.88; }
.deploy-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.auto-deploy-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.auto-deploy-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Legend Modal */
#legend-overlay {
  position: fixed;
  inset: 0;
  z-index: 140;
  background: rgba(10,13,18,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

#legend-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-width: 520px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

.legend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--panel);
}

.legend-header h2 { margin: 0; font-size: 16px; font-weight: 700; }

.legend-close {
  background: none;
  border: none;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.legend-close:hover { opacity: 1; }

.legend-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.legend-section h3 {
  margin: 0 0 8px 0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
}

.legend-item {
  font-size: 13px;
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-swatch {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.3);
  flex-shrink: 0;
}

/* ===== Auth controls (Supabase / Google) ===== */
#auth-wrap { display: flex; }
#signin-btn, #signout-btn, #feedback-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s;
}
#signin-btn:hover, #signout-btn:hover, #feedback-btn:hover { border-color: var(--accent); }
#user-chip { display: inline-flex; align-items: center; gap: 6px; }
#user-email::before { content: "● "; color: #4caf50; }

/* Signed-out nudge: pulse the sign-in button and point a callout at it.
   Both are removed the moment the player signs in or dismisses the callout
   (see _showSignInNudge in js/main.js). */
@keyframes signin-nudge-pulse {
  0%, 100% {
    background: var(--bg);
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 0 0 rgba(224,168,60,0.7);
  }
  50% {
    background: var(--accent);
    color: #0a0d12;
    border-color: var(--accent);
    box-shadow: 0 0 0 10px rgba(224,168,60,0);
  }
}
#signin-btn.signin-nudge {
  font-weight: 700;
  animation: signin-nudge-pulse 1.6s ease-in-out infinite;
}

#signin-nudge-callout {
  position: fixed;
  z-index: 190;
  max-width: 300px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.7);
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
  animation: fadeInUp 0.35s ease-out;
}
#signin-nudge-callout .snc-arrow {
  position: absolute;
  top: -7px;
  width: 12px;
  height: 12px;
  background: var(--panel);
  border-left: 1px solid var(--accent);
  border-top: 1px solid var(--accent);
  transform: rotate(45deg);
}
#signin-nudge-callout .snc-title {
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 5px;
  letter-spacing: 0.5px;
}
#signin-nudge-callout .snc-dismiss {
  margin-top: 10px;
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--text);
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
}
#signin-nudge-callout .snc-dismiss:hover { border-color: var(--accent); color: var(--accent); }

/* ===== Jupiter Heavy Space Publisher Splash ===== */
@keyframes jhsLogoIn {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ===== Startup Cinematic Sequence ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse-accent {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

@keyframes atr-dir-pulse {
  0%, 100% { opacity: 0.35; }
  50%       { opacity: 0.65; }
}
.atr-dir-pending {
  animation: atr-dir-pulse 1.4s ease-in-out infinite;
}

#startup-overlay {
  animation: fadeInUp 0.6s ease-out;
}

#startup-countdown {
  animation: pulse-accent 2s ease-in-out infinite;
}
