* { box-sizing: border-box; }
:root {
  color-scheme: dark;
  --bg-canvas: #091118;
  --bg-chrome: #0f1923;
  --bg-panel: #121e29;
  --bg-card: #172634;
  --bg-card-hover: #1d3041;
  --bg-elevated: rgba(15, 25, 35, 0.9);
  --border: #243647;
  --border-strong: #354e66;
  --ink: #ecf2f7;
  --ink-soft: #b6c6d4;
  --muted: #7d93a8;
  --gold: #e0b354;
  --gold-soft: rgba(224, 179, 84, 0.16);
  --teal: #3bc4a8;
  --teal-soft: rgba(59, 196, 168, 0.16);
  --crimson: #e85d68;
  --crimson-soft: rgba(232, 93, 104, 0.16);
  --sky: #55a8f0;
  --sky-soft: rgba(85, 168, 240, 0.16);
  --violet: #b685f0;
  --violet-soft: rgba(182, 133, 240, 0.16);
  --emerald: #44c47d;
  --emerald-soft: rgba(68, 196, 125, 0.16);
  --amber: #f09c42;
  --amber-soft: rgba(240, 156, 66, 0.16);
  --radius: 8px;
  --radius-sm: 5px;
  --shadow-hud: 0 8px 28px rgba(0, 0, 0, 0.45);
  --sidebar-width: 400px;
}

[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
  font: 12.5px/1.45 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg-canvas);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, select, input {
  font: inherit;
  color: inherit;
  accent-color: var(--gold);
}
button {
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, opacity 120ms ease;
}
button:disabled { opacity: 0.32; cursor: default; }
button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, #map:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Top Command Bar */
#topbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 50px;
  padding: 6px 14px;
  background: linear-gradient(180deg, #13202d 0%, var(--bg-chrome) 100%);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.brand-mark { color: var(--gold); flex: none; }
#title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #f6f8fa;
}
#game-meta {
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding-left: 12px;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}
#winner-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--gold-soft);
  border: 1px solid rgba(224, 179, 84, 0.45);
  color: #f6d583;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* Civ Focus Strip */
#civ-strip {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  padding: 2px 0;
  scrollbar-width: none;
}
#civ-strip::-webkit-scrollbar { display: none; }
.civ-pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(23, 38, 52, 0.85);
  border: 1px solid var(--border);
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
.civ-pill:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  color: var(--ink);
}
.civ-pill.active {
  background: rgba(224, 179, 84, 0.13);
  border-color: var(--civ-color, var(--gold));
  color: #ffffff;
  font-weight: 650;
  box-shadow: 0 0 0 1px var(--civ-color, var(--gold)) inset;
}
.civ-pill.dead { opacity: 0.48; text-decoration: line-through; }
.civ-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.25);
}
.civ-pill-badge {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-soft);
}
.civ-pill.active .civ-pill-badge {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}
.civ-pill-badge.has-combat {
  background: var(--crimson-soft);
  color: #ff99a1;
}
.civ-minor-select {
  flex: none;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(23, 38, 52, 0.85);
  color: var(--ink-soft);
  font-size: 11px;
  max-width: 155px;
}
.civ-minor-select:hover { border-color: var(--border-strong); color: var(--ink); }
.civ-minor-select.active {
  border-color: var(--gold);
  color: #fff;
  background: rgba(224, 179, 84, 0.12);
}

.topbar-right {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.mode-btn {
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 550;
  white-space: nowrap;
}
.mode-btn:hover { background: var(--bg-card-hover); color: var(--ink); border-color: var(--border-strong); }
.mode-btn[aria-pressed="true"] {
  background: rgba(224, 179, 84, 0.24);
  border-color: var(--gold);
  color: #ffe9a8;
  box-shadow: 0 0 0 1px rgba(224, 179, 84, 0.35) inset;
}
.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--ink-soft);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--bg-card-hover); color: var(--ink); }

/* Main Workspace */
#workspace {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}
#map-workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg-canvas);
}
#map-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}
#map {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  background: radial-gradient(circle at 50% 45%, #112536 0%, #09121a 82%);
}
#map.dragging { cursor: grabbing; }
#map-canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.map-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
}

/* Floating Map HUD */
.map-hud {
  background: var(--bg-elevated);
  border: 1px solid rgba(53, 78, 102, 0.72);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hud);
  backdrop-filter: blur(8px);
}
#map-layers {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 6;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 4px;
  max-width: calc(100% - 260px);
}
.layer-chip {
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}
.layer-chip:hover { color: var(--ink); background: rgba(255, 255, 255, 0.06); }
.layer-chip.active {
  background: rgba(59, 196, 168, 0.18);
  border-color: rgba(59, 196, 168, 0.42);
  color: #c5f4e8;
}
.layer-chip[data-layer="actions"].active {
  background: var(--gold-soft);
  border-color: rgba(224, 179, 84, 0.48);
  color: #f8dfa0;
}

#zoom {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
}
#zoom button {
  height: 26px;
  min-width: 26px;
  padding: 0 7px;
  border-radius: 5px;
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 600;
}
#zoom button:hover { background: rgba(255, 255, 255, 0.09); color: #fff; }
#zoom-level {
  min-width: 38px;
  text-align: center;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
#zoom-civ {
  border-left: 1px solid var(--border);
  margin-left: 2px;
  padding-left: 9px !important;
  color: #f0cc7d !important;
}

/* Action Stepper Top Callout */
#action-banner {
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 12px;
  border-color: rgba(224, 179, 84, 0.65);
  max-width: min(560px, calc(100% - 28px));
}
.banner-step {
  flex: none;
  font-size: 10.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: #f6d583;
}
.banner-text {
  font-size: 12px;
  font-weight: 550;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.banner-controls {
  flex: none;
  display: flex;
  align-items: center;
  gap: 2px;
}
.banner-controls button {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  color: var(--ink-soft);
  font-size: 12px;
}
.banner-controls button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); color: #fff; }

/* Bottom Left Minimap & Hover Readout */
#bottom-left-hud {
  position: absolute;
  left: 10px;
  bottom: 12px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  pointer-events: none;
}
#bottom-left-hud > * { pointer-events: auto; }
#minimap-wrap {
  overflow: hidden;
  padding: 0;
}
.minimap-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 7px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.minimap-head button {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  color: var(--muted);
  line-height: 1;
}
.minimap-head button:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
#minimap-wrap.collapsed .minimap-head { border-bottom: 0; }
#minimap-wrap.collapsed #minimap-canvas { display: none; }
#minimap-canvas {
  display: block;
  cursor: crosshair;
  background: #0a1520;
}
#hover-hud {
  padding: 5px 10px;
  font-size: 11.5px;
  color: var(--ink);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  max-width: min(520px, calc(100vw - 440px));
}
.hud-sep { color: var(--border-strong); }

/* Pinned Tile Details Card */
#tile-card {
  position: absolute;
  right: 10px;
  bottom: 12px;
  z-index: 9;
  width: 318px;
  max-width: calc(100% - 20px);
  max-height: min(440px, calc(100% - 76px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-color: rgba(224, 179, 84, 0.5);
}
.tile-card-bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px 6px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(23, 38, 52, 0.92);
}
#tile-card-title {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
}
#tile-close {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  font-size: 17px;
  line-height: 1;
  color: var(--muted);
}
#tile-close:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
#tile-panel {
  flex: 1;
  overflow-y: auto;
  padding: 11px 12px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
#tile-panel h2 { margin: 0 0 2px; font-size: 14.5px; font-weight: 650; }
.tile-coordinate { font-variant-numeric: tabular-nums; margin-bottom: 8px; }
#tile-panel table { border-collapse: collapse; width: 100%; font-size: 11.5px; margin-top: 6px; }
#tile-panel th { text-align: left; font-weight: 500; color: var(--muted); padding: 4px 10px 4px 0; width: 36%; vertical-align: top; }
#tile-panel td { padding: 4px 0; color: var(--ink); }
#tile-panel tr + tr { border-top: 1px solid rgba(36, 54, 71, 0.65); }
.tile-entity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 7px;
  margin-top: 4px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(36, 54, 71, 0.8);
  font-size: 11.5px;
}
.tile-entity-btn {
  width: 100%;
  text-align: left;
  padding: 5px 7px;
  margin-top: 4px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(36, 54, 71, 0.8);
  font-size: 11.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.tile-entity-btn:hover { background: var(--bg-card-hover); border-color: var(--border-strong); }

/* Bottom Playback & Timeline Deck */
#timectl {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  min-height: 62px;
  background: linear-gradient(180deg, var(--bg-chrome) 0%, #0b141c 100%);
  border-top: 1px solid var(--border);
  z-index: 12;
}
.time-transport {
  flex: none;
  display: flex;
  align-items: center;
  gap: 3px;
}
.time-transport button, .time-civ-nav button {
  height: 30px;
  min-width: 30px;
  padding: 0 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.time-transport button:hover:not(:disabled), .time-civ-nav button:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  color: #fff;
}
.play-btn {
  width: 34px !important;
  background: var(--gold-soft) !important;
  border-color: rgba(224, 179, 84, 0.55) !important;
  color: #f8dfa0 !important;
}
.play-btn:hover { background: rgba(224, 179, 84, 0.28) !important; }
.play-btn.playing {
  background: var(--crimson-soft) !important;
  border-color: rgba(232, 93, 104, 0.6) !important;
  color: #ff9fa7 !important;
}
.speed-btn {
  min-width: 36px !important;
  font-variant-numeric: tabular-nums;
  color: var(--gold) !important;
}
.time-divider {
  width: 1px;
  height: 26px;
  background: var(--border);
  flex: none;
}
.time-civ-nav {
  flex: none;
  display: flex;
  align-items: center;
  gap: 5px;
}
.action-stepper {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
}
.action-stepper button {
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  height: 28px;
}
#step-label {
  padding: 0 8px !important;
  min-width: 84px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  border-left: 1px solid var(--border) !important;
  border-right: 1px solid var(--border) !important;
}
#step-label.stepping {
  background: var(--gold-soft) !important;
  color: #f8dfa0 !important;
}
.time-scrubber {
  flex: 1;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.scrubber-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
}
#turn-label {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.timeline-hover-info {
  color: var(--gold);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scrubber-track {
  position: relative;
  height: 24px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
#timeline-spark {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  width: 100%;
  height: 15px;
  pointer-events: none;
}
#turn-slider {
  position: relative;
  z-index: 2;
  width: 100%;
  margin: 0;
  height: 14px;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
#turn-slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(125, 147, 168, 0.35);
}
#turn-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid #0f1923;
  box-shadow: 0 0 0 1px rgba(224, 179, 84, 0.65);
}
#turn-slider::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(125, 147, 168, 0.35);
}
#turn-slider::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid #0f1923;
}

/* Sidebar Resizer & Inspector */
#sidebar-resizer {
  flex: none;
  width: 5px;
  cursor: col-resize;
  background: var(--border);
  transition: background-color 120ms ease;
}
#sidebar-resizer:hover, #sidebar-resizer.active { background: var(--gold); }

#sidebar {
  flex: none;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-panel);
}
#player-summary {
  flex: none;
  padding: 13px 15px 11px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025) 0%, transparent 100%);
}
.civ-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.civ-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.civ-swatch {
  width: 4px;
  height: 30px;
  border-radius: 999px;
  flex: none;
}
.civ-header-top h2 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.civ-subtitle {
  color: var(--muted);
  font-size: 11px;
  margin-top: 1px;
}
.score-pill {
  flex: none;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.score-pill small {
  display: block;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.score-pill strong { font-size: 14px; color: var(--gold); }

.summary-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 10px 0 8px;
}
.metric-box {
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid rgba(36, 54, 71, 0.8);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px;
}
.metric-box span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.metric-box strong {
  font-size: 13.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

/* Yield Badges */
.yields {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}
.yield {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.yield.y0 { background: rgba(68, 196, 125, 0.14); color: #7ee3a8; border-color: rgba(68, 196, 125, 0.25); }
.yield.y1 { background: rgba(240, 156, 66, 0.14); color: #f6ba77; border-color: rgba(240, 156, 66, 0.25); }
.yield.y2 { background: rgba(224, 179, 84, 0.16); color: #f7da88; border-color: rgba(224, 179, 84, 0.28); }
.yield.y3 { background: rgba(85, 168, 240, 0.15); color: #8ac8fa; border-color: rgba(85, 168, 240, 0.28); }
.yield.y4 { background: rgba(182, 133, 240, 0.15); color: #d3b3fa; border-color: rgba(182, 133, 240, 0.28); }
.yield.y5 { background: rgba(176, 196, 222, 0.14); color: #d4e3f5; border-color: rgba(176, 196, 222, 0.25); }

/* Tabs */
#panel-tabs {
  flex: none;
  display: flex;
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-chrome);
  gap: 2px;
}
#panel-tabs button {
  flex: 1;
  padding: 9px 4px;
  font-size: 11.5px;
  font-weight: 550;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  white-space: nowrap;
}
#panel-tabs button:hover { color: var(--ink); background: rgba(255, 255, 255, 0.03); }
#panel-tabs button[aria-selected="true"] {
  color: var(--gold);
  font-weight: 650;
  border-bottom-color: var(--gold);
}
#panel-tabs [data-count] {
  margin-left: 3px;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  padding: 0 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-soft);
}

#panel-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px 18px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

h3 {
  font-size: 10.5px;
  margin: 14px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 650;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
h3:first-child { margin-top: 0; }
.sub { color: var(--muted); font-size: 11px; }
.empty-state { color: var(--muted); font-size: 12px; padding: 18px 8px; text-align: center; }
.chip {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

/* Actions Panel */
#actions-toolbar {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 8px;
}
.seg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}
.seg-group {
  display: inline-flex;
  padding: 2px;
  border-radius: 6px;
  background: var(--bg-chrome);
  border: 1px solid var(--border);
}
.seg-btn {
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 550;
  color: var(--muted);
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active {
  background: var(--bg-card-hover);
  color: #fff;
}
.small-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.small-toggle input { margin: 0; }
.search-input {
  width: 100%;
  padding: 6px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-chrome);
  color: var(--ink);
  font-size: 11.5px;
}
.search-input::placeholder { color: var(--muted); }
.unit-filter-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 9px;
  border-radius: 6px;
  background: var(--teal-soft);
  border: 1px solid rgba(59, 196, 168, 0.45);
  color: #b7f5e6;
  font-size: 11.5px;
}
.unit-filter-banner button {
  color: #fff;
  font-weight: 700;
  padding: 0 5px;
}

#actions-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}
.cat-chip {
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-chrome);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 550;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.cat-chip:hover { color: var(--ink); border-color: var(--border-strong); }
.cat-chip.empty-cat:not(.active) { opacity: 0.45; }
.cat-chip.active {
  background: var(--gold-soft);
  border-color: rgba(224, 179, 84, 0.55);
  color: #f8dfa0;
}
.cat-chip span { font-variant-numeric: tabular-nums; opacity: 0.78; }

.action-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chronicle-turn-header {
  position: sticky;
  top: -12px;
  z-index: 2;
  padding: 5px 8px;
  margin: 6px 0 2px;
  border-radius: 5px;
  background: rgba(15, 25, 35, 0.96);
  border: 1px solid var(--border);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--gold);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chronicle-turn-header:first-child { margin-top: 0; }

.action-card {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--cat-color, var(--border-strong));
  color: var(--ink);
}
.action-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  border-left-color: var(--cat-color, var(--gold));
}
.action-card.spotlight {
  background: rgba(224, 179, 84, 0.14);
  border-color: rgba(224, 179, 84, 0.72);
  border-left-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(224, 179, 84, 0.35) inset;
}
.action-card.major { background: rgba(29, 46, 63, 0.92); }
.action-card.routine { opacity: 0.76; }
.action-card.cat-combat { --cat-color: var(--crimson); }
.action-card.cat-move { --cat-color: var(--sky); }
.action-card.cat-city { --cat-color: var(--gold); }
.action-card.cat-build { --cat-color: var(--emerald); }
.action-card.cat-progress { --cat-color: var(--violet); }
.action-card.cat-diplomacy { --cat-color: var(--amber); }
.action-card.cat-trade { --cat-color: var(--teal); }
.action-card.cat-unit { --cat-color: #6ea8d6; }
.action-card.cat-world { --cat-color: #d6856e; }

.action-icon {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  color: var(--cat-color, var(--ink-soft));
  margin-top: 1px;
}
.action-body { flex: 1; min-width: 0; }
.action-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}
.action-title {
  font-size: 12px;
  font-weight: 550;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.action-step-num {
  flex: none;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.action-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
}
.pill-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pill-kill { background: var(--crimson-soft); color: #ff99a1; }
.pill-incoming { background: var(--amber-soft); color: #ffd099; }
.pill-major { background: var(--gold-soft); color: #f6d583; }
.pill-civ {
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink-soft);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 550;
}

/* Cards, Progress Bars, Grids */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.info-card {
  padding: 10px 11px;
  border-radius: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  min-width: 0;
}
.info-card-title {
  font-size: 13px;
  font-weight: 650;
  color: var(--ink);
  margin: 2px 0 4px;
}
.progress-wrap {
  margin-top: 6px;
}
.progress-bar {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--sky);
}
.progress-fill.civic { background: var(--violet); }
.progress-fill.prod { background: var(--amber); }
.progress-fill.hp { background: var(--emerald); }
.progress-fill.hp-low { background: var(--crimson); }
.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.panel-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag {
  padding: 3px 7px;
  border-radius: 5px;
  background: var(--bg-chrome);
  border: 1px solid var(--border);
  font-size: 10.5px;
  color: var(--ink-soft);
}
.entity-list { display: flex; flex-direction: column; gap: 7px; }
.entity-card {
  border-radius: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  overflow: hidden;
}
.entity-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  color: var(--ink);
}
.entity-btn:hover { background: var(--bg-card-hover); }
.row-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}
.count-badge {
  flex: none;
  font-size: 10.5px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.war-status, .damaged { color: #ff8f97 !important; }
.status-pill {
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-soft);
}
.status-pill.acted { background: var(--sky-soft); color: #9ad0ff; }
.status-pill.combat { background: var(--crimson-soft); color: #ff99a1; }
.status-pill.built { background: var(--emerald-soft); color: #8ce9b5; }
.unit-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  border-top: 1px solid rgba(36, 54, 71, 0.7);
  background: rgba(15, 25, 35, 0.45);
  font-size: 10.5px;
}
.link-btn {
  color: var(--gold);
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 4px;
}
.link-btn:hover { background: var(--gold-soft); }
details.compact-details {
  padding: 6px 11px;
  border-top: 1px solid rgba(36, 54, 71, 0.7);
  font-size: 11px;
  color: var(--ink-soft);
}
details.compact-details summary { cursor: pointer; color: var(--muted); }
details.compact-details[open] summary { margin-bottom: 5px; color: var(--ink-soft); }

/* Diplomacy Rows */
.diplo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 11.5px;
}
.diplo-row + .diplo-row { margin-top: 5px; }
.diplo-state {
  font-size: 10px;
  font-weight: 650;
  padding: 2px 6px;
  border-radius: 999px;
  text-transform: uppercase;
}
.diplo-state.war { background: var(--crimson-soft); color: #ff99a1; }
.diplo-state.ally { background: var(--teal-soft); color: #96f2de; }
.diplo-state.denounced { background: var(--amber-soft); color: #ffc88a; }
.diplo-state.peace { background: rgba(255, 255, 255, 0.08); color: var(--ink-soft); }
.diplo-state.unmet { background: transparent; color: var(--muted); }

/* Standings & Chart */
.chart-box {
  padding: 10px;
  border-radius: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.chart-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.chart-metric-btn {
  padding: 3px 7px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 550;
  color: var(--muted);
  background: var(--bg-chrome);
  border: 1px solid var(--border);
}
.chart-metric-btn:hover { color: var(--ink); }
.chart-metric-btn.active {
  background: var(--gold-soft);
  border-color: rgba(224, 179, 84, 0.55);
  color: #f8dfa0;
}
#trend-canvas {
  display: block;
  width: 100%;
  height: 170px;
  cursor: pointer;
}
.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.standings-table th {
  text-align: right;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 6px 5px;
  border-bottom: 1px solid var(--border);
}
.standings-table th:first-child, .standings-table td:first-child { text-align: left; }
.standings-table tbody tr {
  cursor: pointer;
  border-bottom: 1px solid rgba(36, 54, 71, 0.55);
}
.standings-table tbody tr:hover { background: var(--bg-card-hover); }
.standings-table tbody tr.focused { background: rgba(224, 179, 84, 0.12); }
.standings-table td { padding: 7px 5px; }

/* Shortcuts Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(5, 10, 16, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-card {
  width: 440px;
  max-width: 100%;
  border-radius: 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-chrome);
}
.modal-head h2 { margin: 0; font-size: 14px; color: var(--gold); }
#shortcuts-close {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  font-size: 18px;
  color: var(--muted);
}
#shortcuts-close:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.shortcuts-grid {
  padding: 14px;
  display: grid;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-soft);
}
kbd {
  display: inline-block;
  min-width: 22px;
  text-align: center;
  padding: 1px 6px;
  margin-right: 4px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: #fff;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 11px;
}

/* Responsive Breakpoints */
@media (max-width: 1080px) {
  :root { --sidebar-width: 340px; }
  .time-civ-nav { display: none; }
}
@media (max-width: 760px) {
  body { overflow: auto; height: auto; min-height: 100%; }
  #topbar { flex-wrap: wrap; }
  #game-meta { display: none; }
  #workspace { flex-direction: column; }
  #map-workspace { flex: none; height: 60dvh; min-height: 360px; }
  #sidebar-resizer { display: none; }
  #sidebar { width: 100%; min-height: 420px; border-top: 1px solid var(--border); }
  #panel-content { overflow: visible; }
  #minimap-wrap { display: none; }
  #tile-card { right: 8px; left: 8px; width: auto; bottom: 68px; }
}

.replay-empty-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 15, 24, 0.92);
  padding: 24px;
}

.replay-empty-overlay[hidden] {
  display: none;
}

.replay-drop-box {
  width: min(440px, 92vw);
  padding: 28px 24px;
  border-radius: 12px;
  border: 1.5px dashed rgba(224, 179, 84, 0.45);
  background: rgba(18, 26, 39, 0.96);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.replay-drop-box.dragover {
  border-color: #f5be36;
  background: rgba(30, 42, 60, 0.98);
}

.replay-drop-box h2 {
  margin: 0;
  font-size: 17px;
  color: #f3e6c8;
}

.replay-drop-box p {
  margin: 0;
  font-size: 13px;
  color: #9fb0c8;
  line-height: 1.5;
}

.replay-drop-box p.err {
  color: #f87171;
}
