/* ===== AI Dominion — Dark neon theme ===== */
:root {
  --bg: #070b12;
  --bg2: #0d1420;
  --panel: #111a28;
  --panel2: #162033;
  --border: rgba(0, 230, 200, 0.18);
  --text: #e8f4ff;
  --muted: #7a8fa8;
  --accent: #00e6c8;
  --accent2: #5b8cff;
  --danger: #ff4d6d;
  --warn: #ffb020;
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "SF Mono", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

.screen {
  position: absolute;
  inset: 0;
}

/* ===== Start screen ===== */
#start-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(0, 230, 200, 0.15), transparent),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(91, 140, 255, 0.12), transparent),
    var(--bg);
}

.start-panel {
  width: min(520px, 94vw);
  background: linear-gradient(160deg, var(--panel), var(--bg2));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.2rem 2rem 1.6rem;
  box-shadow: 0 0 60px rgba(0, 230, 200, 0.08), 0 24px 48px rgba(0,0,0,0.45);
  position: relative;
  overflow: hidden;
}

.logo-block { text-align: center; margin-bottom: 1.6rem; position: relative; }

.logo-glow {
  position: absolute;
  inset: -40% 10% auto;
  height: 80px;
  background: radial-gradient(ellipse, rgba(0,230,200,0.35), transparent 70%);
  pointer-events: none;
}

h1 {
  font-size: 2.4rem;
  letter-spacing: 0.18em;
  font-weight: 800;
  background: linear-gradient(90deg, #00e6c8, #5b8cff, #c084fc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
}

.tagline {
  color: var(--muted);
  margin-top: 0.4rem;
  font-size: 0.95rem;
}

.setup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.setup-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font-size: 0.95rem;
  outline: none;
}
select:focus { border-color: var(--accent); }

.faction-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.fp-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.55rem;
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.85rem;
}
.fp-item.active { border-color: var(--accent); background: rgba(0,230,200,0.08); }
.fp-item.unused { opacity: 0.35; }
.fp-swatch {
  width: 14px; height: 14px; border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.25);
  flex-shrink: 0;
}

.setup-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
  cursor: pointer;
  color: var(--muted);
}
.toggle-row input { accent-color: var(--accent); }

.credits {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.75rem;
  color: var(--muted);
  opacity: 0.7;
}

/* ===== Buttons ===== */
.btn {
  border: none;
  border-radius: 10px;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, #00c9b1, #00a8e8);
  color: #041018;
  box-shadow: 0 0 24px rgba(0, 230, 200, 0.25);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 0 32px rgba(0,230,200,0.4); }

.btn-lg { width: 100%; padding: 0.85rem; font-size: 1rem; letter-spacing: 0.04em; }

.btn-secondary {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  width: 100%;
}
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border); }

/* ===== Game layout ===== */
#game-screen {
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.top-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 1rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand {
  font-weight: 800;
  letter-spacing: 0.14em;
  font-size: 0.85rem;
  color: var(--accent);
}

.phase-pills { display: flex; gap: 0.35rem; flex: 1; justify-content: center; }

.pill {
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: rgba(255,255,255,0.03);
  border: 1px solid transparent;
}
.pill.active {
  color: #041018;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
  box-shadow: 0 0 16px rgba(0,230,200,0.35);
}

.game-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-areas: "side map";
  min-height: 0;
  position: relative;
}

.side-panel {
  grid-area: side;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  min-height: 0;
}

.sheet-chrome { display: none; }
.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
  flex: 1;
}

.map-wrap { grid-area: map; }

.mobile-action-dock { display: none; }

.player-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem;
  background: var(--panel2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.pc-color {
  width: 36px; height: 36px; border-radius: 10px;
  border: 2px solid rgba(255,255,255,0.3);
  box-shadow: 0 0 12px currentColor;
}
.pc-name { font-weight: 700; font-size: 1.05rem; }
.pc-meta { font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; }

.stat-block {
  text-align: center;
  padding: 0.65rem;
  background: rgba(0,230,200,0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stat-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.stat-value { font-size: 2rem; font-weight: 800; color: var(--accent); font-family: var(--mono); }

.action-stack { display: flex; flex-direction: column; gap: 0.4rem; }

.selection-info {
  padding: 0.6rem 0.7rem;
  background: var(--bg2);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.06);
  font-size: 0.82rem;
  line-height: 1.4;
}
.selection-info.si-dismissed { display: none; }
.si-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.si-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0;
}
.btn-si-close {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}
.btn-si-close:hover { color: var(--text); border-color: var(--accent); }

.dice-panel {
  padding: 0.6rem;
  background: var(--bg2);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.06);
}
.dice-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.dice-row { display: flex; gap: 0.75rem; }
.dice-group { flex: 1; }
.dice-label { font-size: 0.7rem; color: var(--muted); display: block; margin-bottom: 0.25rem; }
.dice-faces { display: flex; gap: 0.25rem; flex-wrap: wrap; min-height: 28px; }
.die {
  width: 26px; height: 26px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.85rem;
  font-family: var(--mono);
}
.die.atk { background: #ff4d6d; color: #fff; }
.die.def { background: #5b8cff; color: #fff; }
.die.win { box-shadow: 0 0 8px currentColor; outline: 2px solid #fff; }
.combat-result {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: var(--muted);
  min-height: 1.2em;
}

.log-panel { flex: 1; min-height: 100px; display: flex; flex-direction: column; }
.log-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.log-list {
  flex: 1;
  overflow-y: auto;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--muted);
  max-height: 160px;
}
.log-list .log-entry { padding: 0.2rem 0; border-bottom: 1px solid rgba(255,255,255,0.04); }
.log-list .log-entry.combat { color: #ffb0be; }
.log-list .log-entry.conquer { color: var(--accent); }
.log-list .log-entry.turn { color: var(--accent2); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.leg-item {
  display: flex; align-items: center; gap: 0.3rem;
  font-size: 0.68rem; color: var(--muted);
}
.leg-swatch { width: 10px; height: 10px; border-radius: 3px; }

/* ===== Map ===== */
.map-wrap {
  position: relative;
  background:
    radial-gradient(ellipse at 30% 40%, rgba(0,80,100,0.2), transparent 50%),
    radial-gradient(ellipse at 70% 60%, rgba(40,40,100,0.15), transparent 50%),
    #060a10;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#world-map {
  width: 100%;
  height: 100%;
  max-height: calc(100dvh - 48px);
  touch-action: manipulation;
}

.territory {
  stroke: rgba(0, 230, 200, 0.35);
  stroke-width: 1.5;
  cursor: pointer;
  transition: filter 0.15s, stroke-width 0.15s, stroke 0.15s;
  filter: brightness(0.92);
  touch-action: manipulation;
}
.territory-hit {
  fill: transparent;
  stroke: none;
  cursor: pointer;
  touch-action: manipulation;
  pointer-events: all;
}
.territory:hover {
  filter: brightness(1.15);
  stroke: #fff;
  stroke-width: 2;
}
.territory.selected {
  stroke: #fff;
  stroke-width: 2.5;
  filter: brightness(1.2) drop-shadow(0 0 6px rgba(255,255,255,0.5));
}
.territory.valid-target {
  stroke: var(--warn);
  stroke-width: 2.5;
  animation: pulse-stroke 1s ease-in-out infinite;
}
.territory.owned-highlight {
  stroke: var(--accent);
  stroke-width: 2;
}

@keyframes pulse-stroke {
  0%, 100% { stroke-opacity: 1; }
  50% { stroke-opacity: 0.45; }
}

.t-label {
  fill: #fff;
  font-size: 10px;
  font-weight: 700;
  pointer-events: none;
  text-anchor: middle;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  font-family: var(--font);
}
.t-armies {
  fill: #fff;
  font-size: 13px;
  font-weight: 800;
  pointer-events: none;
  text-anchor: middle;
  font-family: var(--mono);
  paint-order: stroke;
  stroke: rgba(0,0,0,0.75);
  stroke-width: 3px;
}

.continent-label {
  fill: rgba(0, 230, 200, 0.35);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-anchor: middle;
  pointer-events: none;
  text-transform: uppercase;
}

.tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(10, 16, 28, 0.95);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  font-size: 0.8rem;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  max-width: 220px;
  line-height: 1.35;
}
.tooltip strong { color: var(--accent); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.modal {
  background: linear-gradient(160deg, var(--panel), var(--bg2));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  width: min(400px, 92vw);
  box-shadow: 0 0 40px rgba(0,230,200,0.15);
}
.modal h2 { margin-bottom: 0.5rem; font-size: 1.3rem; }
.modal p { color: var(--muted); margin-bottom: 1rem; line-height: 1.45; font-size: 0.95rem; }
.modal-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }
.modal-actions .btn { min-width: 80px; }
#modal-extra { margin-bottom: 1rem; }
.army-picker {
  display: flex; align-items: center; gap: 0.75rem; justify-content: center;
}
.army-picker input[type=range] { flex: 1; accent-color: var(--accent); }
.army-picker .ap-val {
  font-family: var(--mono); font-size: 1.4rem; font-weight: 800; color: var(--accent); min-width: 2ch;
}

/* AI thinking banner */
.ai-banner {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(91,140,255,0.2);
  border: 1px solid rgba(91,140,255,0.5);
  color: #a8c4ff;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-size: 0.8rem;
  z-index: 15;
  pointer-events: none;
}

/* ===== Phase banner (attack / fortify cue; non-blocking) ===== */
.phase-banner {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  max-width: min(520px, calc(100% - 1.5rem));
  padding: 0.45rem 0.55rem 0.45rem 0.9rem;
  background: rgba(10, 16, 28, 0.88);
  border: 1px solid rgba(255, 176, 32, 0.55);
  border-radius: 999px;
  color: #ffe2a8;
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  pointer-events: none; /* map stays tappable underneath */
  backdrop-filter: blur(6px);
}
.phase-banner #phase-banner-text { pointer-events: none; }
.btn-banner-clear {
  pointer-events: auto;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--text);
  width: 28px;
  height: 28px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  flex-shrink: 0;
}
.btn-banner-clear:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 900px) {
  :root {
    --sheet-peek: 56px;
    --dock-h: 52px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
  }

  #game-screen {
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  .top-bar {
    flex-wrap: wrap;
    gap: 0.45rem;
    padding: 0.45rem 0.65rem;
    padding-top: max(0.45rem, env(safe-area-inset-top, 0px));
  }
  .brand { font-size: 0.72rem; }
  .phase-pills {
    order: 3;
    flex: 1 1 100%;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.1rem;
  }
  .phase-pills::-webkit-scrollbar { display: none; }
  .pill { padding: 0.28rem 0.65rem; font-size: 0.68rem; white-space: nowrap; }
  .win-meter { margin-left: auto; }
  .wm-bar { width: 64px; }
  .resource-bar { padding: 0.35rem 0.55rem; gap: 0.35rem; }
  .res { min-width: 0; padding: 0.3rem 0.55rem; gap: 0.3rem; }
  .res-name { display: none; }

  .game-layout {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    grid-template-areas: "map";
    min-height: 0;
    overflow: hidden;
  }

  /* Map fills the playable viewport; sheet peeks only at bottom chrome */
  .map-wrap {
    grid-area: map;
    z-index: 1;
    padding-bottom: calc(var(--sheet-peek) + var(--dock-h) + var(--safe-bottom));
    overflow: hidden;
    touch-action: manipulation;
  }

  #world-map {
    max-height: none;
    height: 100%;
    width: 100%;
  }

  .territory {
    stroke-width: 2.25;
  }
  .territory.valid-target,
  .territory.selected {
    stroke-width: 3.25;
  }

  /* Sticky phase actions — outside transformed sheet so always tappable */
  .mobile-action-dock {
    display: flex;
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(var(--sheet-peek) + var(--safe-bottom));
    z-index: 35;
    gap: 0.4rem;
    padding: 0.35rem 0.65rem;
    justify-content: center;
    flex-wrap: wrap;
    pointer-events: none;
    background: linear-gradient(to top, rgba(7,11,18,0.92), rgba(7,11,18,0));
  }
  .mobile-action-dock:not(:has(.btn:not(.hidden))),
  .mobile-action-dock.dock-empty {
    display: none;
  }
  .mobile-action-dock .btn {
    pointer-events: auto;
    min-height: 44px;
    min-width: 120px;
    width: auto;
    flex: 1 1 auto;
    max-width: 220px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  }

  /* Hide in-sheet action stack on mobile — dock mirrors it */
  .side-panel .action-stack { display: none; }

  /* Bottom sheet — only bottom chrome; never covers map center when collapsed */
  .side-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    grid-area: unset;
    max-height: min(52vh, 380px);
    padding: 0 0.75rem calc(0.65rem + var(--safe-bottom));
    border-right: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -12px 40px rgba(0,0,0,0.45);
    transform: translateY(0);
    transition: transform 0.28s ease, max-height 0.28s ease;
    overflow: hidden;
    background: var(--panel);
    overscroll-behavior: contain;
  }

  .side-panel.collapsed {
    transform: translateY(calc(100% - var(--sheet-peek) - var(--safe-bottom)));
    max-height: calc(var(--sheet-peek) + var(--safe-bottom) + 8px);
    overflow: hidden;
  }

  .sheet-chrome {
    display: block;
    flex-shrink: 0;
    padding-top: 0.25rem;
  }
  .sheet-handle {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 0.35rem 0.5rem 0.45rem;
    min-height: 44px;
    font-family: inherit;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
  .sheet-grabber {
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255,255,255,0.28);
  }
  .sheet-toggle-label { opacity: 0.85; }

  .sheet-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: 0.25rem;
    flex: 1;
    min-height: 0;
  }
  .side-panel.collapsed .sheet-body {
    visibility: hidden;
    pointer-events: none;
  }

  .btn-si-close { display: inline-flex; align-items: center; justify-content: center; }

  .selection-info {
    /* Compact card inside sheet only — never a map overlay */
    position: relative;
  }

  .phase-banner {
    top: 8px;
    font-size: 0.74rem;
    padding: 0.4rem 0.45rem 0.4rem 0.75rem;
  }

  .ai-banner { top: 52px; }

  .btn, .btn-build {
    min-height: 40px;
  }
}

@media (max-width: 480px) {
  :root {
    --sheet-peek: 52px;
    --dock-h: 48px;
  }
  .side-panel {
    max-height: min(48vh, 320px);
  }
  .side-panel.collapsed {
    max-height: calc(var(--sheet-peek) + var(--safe-bottom) + 8px);
  }
  .pc-name { font-size: 0.95rem; }
  .stat-value { font-size: 1.55rem; }
  .build-menu { gap: 0.25rem; }
  .btn-build { font-size: 0.78rem; padding: 0.45rem 0.6rem; min-height: 42px; }
  .phase-banner {
    max-width: calc(100% - 1rem);
    border-radius: 14px;
    flex-wrap: nowrap;
  }
  .mobile-action-dock .btn {
    min-width: 0;
    font-size: 0.85rem;
  }
  .start-panel { padding: 1.5rem 1.1rem 1.2rem; }
  h1 { font-size: 1.7rem; letter-spacing: 0.12em; }
  .setup-grid { grid-template-columns: 1fr; }
}

/* Coarse pointers: larger hit feedback */
@media (pointer: coarse) {
  .territory:active {
    filter: brightness(1.25);
    stroke: #fff;
    stroke-width: 3;
  }
}

/* ===== Hybrid economy UI additions ===== */
.subtag {
  font-size: 0.78rem;
  color: var(--accent2);
  margin-top: 0.35rem;
  letter-spacing: 0.04em;
}

.resource-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  justify-content: center;
  flex-wrap: wrap;
}

.res {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  min-width: 120px;
}
.res-icon { font-size: 0.95rem; }
.res-name { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.res-val { font-family: var(--mono); font-weight: 800; font-size: 1.05rem; margin-left: auto; color: var(--accent); }

.res[data-res="power"] .res-val { color: #ffd166; }
.res[data-res="compute"] .res-val { color: #5b8cff; }
.res[data-res="talent"] .res-val { color: #c084fc; }
.res[data-res="capital"] .res-val { color: #00e6c8; }

.win-meter {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.7rem;
  color: var(--muted);
}
.wm-label { letter-spacing: 0.06em; white-space: nowrap; }
.wm-bar {
  width: 90px; height: 8px;
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  overflow: hidden;
}
.wm-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5b8cff, #00e6c8);
  border-radius: 4px;
  transition: width 0.35s ease;
}
.wm-val { font-family: var(--mono); color: var(--text); min-width: 4.5ch; }

.build-menu {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.5rem;
  background: var(--bg2);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.06);
}
.bm-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.15rem;
}
.btn-build {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  width: 100%;
  text-align: left;
  font-size: 0.8rem;
  padding: 0.4rem 0.65rem;
}
.btn-build:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-build:disabled { opacity: 0.35; }
.btn-poach { border-color: rgba(255,77,109,0.35) !important; }
.btn-poach:hover:not(:disabled) { border-color: var(--danger) !important; color: var(--danger) !important; }

.bldg-icon {
  pointer-events: none;
  font-size: 9px;
}

.si-body .meta-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.15rem 0;
}
.si-body .meta-k { color: var(--muted); }
.si-body .bldgs { margin-top: 0.35rem; color: var(--accent); font-size: 0.78rem; }

.ai-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(91,140,255,0.22);
  border: 1px solid rgba(91,140,255,0.5);
  color: #a8c4ff;
  padding: 0.4rem 1.1rem;
  border-radius: 999px;
  font-size: 0.8rem;
  z-index: 15;
  pointer-events: none;
}

/* ===== Nation tension ===== */
.tension-panel {
  padding: 0.5rem;
  background: var(--bg2);
  border-radius: 10px;
  border: 1px solid rgba(255,77,109,0.2);
}
.tension-list { display: flex; flex-direction: column; gap: 0.3rem; max-height: 120px; overflow-y: auto; }
.tn-row {
  display: grid;
  grid-template-columns: 64px 1fr 28px;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
}
.tn-name { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tn-bar {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}
.tn-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
  background: #5b8cff;
}
.tn-fill.hot { background: #ffb020; }
.tn-fill.critical { background: #ff4d6d; box-shadow: 0 0 6px rgba(255,77,109,0.5); }
.tn-val { font-family: var(--mono); text-align: right; color: var(--text); }

.territory.nationalized {
  fill: #3a3a48 !important;
  stroke: #ff4d6d !important;
  stroke-dasharray: 4 3;
}
.territory.disabled-bldg { opacity: 0.85; }
