/* ══════════════════════════════════════════════════════════
   NUCLEAR WAR 2026  ·  Visual Stylesheet
   Dark military / post-apocalyptic theme with neon accents
   ══════════════════════════════════════════════════════════ */

:root {
  --bg:          #050510;
  --bg2:         #0a0a22;
  --panel:       rgba(4, 12, 30, 0.92);
  --panel2:      rgba(0, 20, 50, 0.85);
  --neon-cyan:   #00eeff;
  --neon-red:    #ff2244;
  --neon-green:  #00ff88;
  --neon-yellow: #ffe000;
  --neon-orange: #ff8800;
  --text:        #d0e8ff;
  --text-bright: #ffffff;
  --text-mid:    #a8c8e8;
  --text-dim:    #6080a0;
  --border:      rgba(0, 200, 255, 0.25);
  --glow-c:      0 0 18px rgba(0,238,255,0.55);
  --glow-r:      0 0 18px rgba(255,34,68,0.6);
  --glow-g:      0 0 18px rgba(0,255,136,0.5);
  --glow-y:      0 0 18px rgba(255,224,0,0.6);
  --action-panel-h: 168px;  /* height of action panel + small gap; used by bottom HUD corners */
  --teletype-h: 30px;       /* permanent teletype bar at screen bottom */
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', Courier, monospace;
  user-select: none;
}

/* ── SCREENS ──────────────────────────────────────── */
.screen {
  position: fixed; inset: 0;
  display: none;
  background: radial-gradient(ellipse at 50% 40%, #0c0c30 0%, var(--bg) 70%);
  overflow: hidden;
}
.screen.active { display: flex; flex-direction: column; align-items: center; justify-content: center; }
#screen-game.active { display: block; }
#screen-victory.active { display: flex; flex-direction: column; align-items: center; justify-content: center; }
/* Leader select needs to scroll on small screens */
#screen-leader-select.active {
  justify-content: flex-start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 0 max(20px, env(safe-area-inset-bottom));
}

/* ── STARFIELD ────────────────────────────────────── */
.stars-layer {
  position: absolute; inset: 0;
  pointer-events: none; z-index: 0;
}
.star {
  position: absolute;
  background: white;
  border-radius: 50%;
  animation: twinkle var(--d, 3s) infinite ease-in-out alternate;
}
@keyframes twinkle {
  from { opacity: var(--lo, 0.2); }
  to   { opacity: var(--hi, 1.0); }
}

/* ══════════════════════════════════════════════════
   TITLE SCREEN
   ══════════════════════════════════════════════════ */
.title-container {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; text-align: center; padding: 20px;
}

.nuke-symbol {
  font-size: clamp(60px, 10vw, 110px);
  animation: nukeRotate 8s linear infinite, nukeGlow 2s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 30px var(--neon-red));
}
@keyframes nukeRotate { to { transform: rotate(360deg); } }
@keyframes nukeGlow {
  from { filter: drop-shadow(0 0 20px var(--neon-red)); }
  to   { filter: drop-shadow(0 0 50px #ff6600) brightness(1.3); }
}

.title-main {
  font-size: clamp(36px, 7vw, 80px);
  font-weight: 900;
  letter-spacing: 0.15em;
  background: linear-gradient(135deg, var(--neon-red), var(--neon-yellow), var(--neon-red));
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradShift 3s ease infinite;
  text-shadow: none;
}
@keyframes gradShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.title-year {
  font-size: clamp(24px, 5vw, 55px);
  color: var(--neon-cyan);
  letter-spacing: 0.5em;
  text-shadow: var(--glow-c);
  animation: flicker 5s infinite;
}
@keyframes flicker {
  0%,19%,21%,23%,25%,54%,56%,100% { opacity: 1; }
  20%,22%,24%,55% { opacity: 0.4; }
}

.title-tagline {
  font-size: clamp(12px, 2vw, 18px);
  color: var(--text-dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.title-buttons {
  display: flex; gap: 16px; flex-wrap: wrap; justify-content: center;
  margin-top: 16px;
}

.title-credit {
  font-size: 11px; color: #445566;
  margin-top: 8px; letter-spacing: 0.06em;
}
.title-version {
  font-size: 10px; color: var(--text-dim);
  margin-top: 4px; letter-spacing: 0.1em;
  font-family: 'Courier New', monospace;
  text-shadow: 0 0 8px rgba(0, 180, 255, 0.4);
}

/* ── BUTTONS ──────────────────────────────────────── */
.btn-primary {
  padding: 14px 34px;
  font-family: inherit;
  font-size: clamp(14px, 2vw, 18px);
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #000;
  background: linear-gradient(135deg, var(--neon-red), #ff6600);
  border: none; border-radius: 4px;
  cursor: pointer;
  box-shadow: var(--glow-r), inset 0 1px 0 rgba(255,255,255,0.2);
  transition: transform 0.12s, box-shadow 0.12s;
  text-transform: uppercase;
}
.btn-primary:hover {
  transform: scale(1.06);
  box-shadow: 0 0 30px rgba(255,34,68,0.85), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  padding: 12px 28px;
  font-family: inherit;
  font-size: clamp(13px, 1.8vw, 16px);
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--neon-cyan);
  background: transparent;
  border: 2px solid var(--neon-cyan);
  border-radius: 4px;
  cursor: pointer;
  box-shadow: var(--glow-c);
  transition: all 0.15s;
  text-transform: uppercase;
}
.btn-secondary:hover {
  background: rgba(0,238,255,0.12);
  box-shadow: 0 0 28px rgba(0,238,255,0.7);
}

.pulse {
  animation: pulsate 1.8s ease-in-out infinite;
}
@keyframes pulsate {
  0%,100% { box-shadow: var(--glow-r); }
  50%      { box-shadow: 0 0 40px rgba(255,34,68,0.9), 0 0 80px rgba(255,100,0,0.5); }
}

/* ── HOW TO PLAY MODAL ────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.75);
  animation: fadeIn 0.2s ease;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--panel);
  border: 1px solid var(--neon-cyan);
  border-radius: 8px;
  padding: 30px 36px;
  max-width: 520px; width: 90%;
  box-shadow: var(--glow-c);
}
.modal-box h3 {
  color: var(--neon-cyan);
  font-size: 22px; letter-spacing: 0.1em;
  text-shadow: var(--glow-c);
  margin-bottom: 18px;
}
.modal-box ul {
  list-style: none; padding: 0;
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 22px;
}
.modal-box li { font-size: 14px; color: var(--text); line-height: 1.45; }

/* ══════════════════════════════════════════════════
   LEADER SELECT SCREEN
   ══════════════════════════════════════════════════ */
.select-header {
  position: relative; z-index: 1;
  text-align: center; margin-bottom: 18px;
}
.select-header h2 {
  font-size: clamp(18px, 3.5vw, 32px);
  color: var(--neon-yellow);
  text-shadow: var(--glow-y);
  letter-spacing: 0.12em;
}
.select-sub { color: var(--text); font-size: 13px; margin-top: 4px; }

.leader-grid {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  width: 94%; max-width: 1300px;
  max-height: none;
  padding: 6px;
}

.leader-card {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  display: flex; flex-direction: column;
}
.leader-card:hover,
.leader-card.card-touched {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 0 28px var(--card-color, rgba(0,200,255,0.5));
  border-color: var(--card-color, var(--neon-cyan));
}

.leader-portrait {
  width: 100%; aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 80px;
  position: relative;
  overflow: hidden;
}
.leader-portrait svg {
  width: 100%; height: 100%;
}
.portrait-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 60%, var(--bg) 100%);
}

.leader-info {
  padding: 12px 14px;
  flex: 1;
  display: flex; flex-direction: column; gap: 4px;
}
.leader-name {
  font-size: clamp(13px, 1.6vw, 16px);
  font-weight: 700;
  letter-spacing: 0.06em;
}
.leader-nation {
  font-size: 11px;
  color: var(--text-mid);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.leader-desc {
  font-size: 11px;
  color: var(--text);
  font-style: italic;
  margin-top: 4px;
  line-height: 1.4;
}
.leader-stats {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 8px;
}
.stat-chip {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 3px;
  padding: 2px 6px;
  font-size: 11px;
  white-space: nowrap;
}

.btn-choose {
  margin: 10px 14px 14px;
  padding: 9px 0;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  border: none; border-radius: 4px;
  cursor: pointer;
  background: var(--card-color, var(--neon-cyan));
  color: #000;
  transition: opacity 0.15s, transform 0.12s;
}
.btn-choose:hover { opacity: 0.85; transform: scale(1.03); }

.btn-back {
  position: relative; z-index: 1;
  margin-top: 14px;
  padding: 8px 22px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-mid);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-back:hover { color: var(--neon-cyan); border-color: var(--neon-cyan); }

/* ── LEADER SELECT FOOTER & OPPONENT CONTROLS ─────────── */
.select-footer {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 14px;
  margin-top: 12px; flex-wrap: wrap; justify-content: center;
}

.opponent-controls {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 14px;
  background: rgba(0,238,255,0.06);
  border: 1px solid rgba(0,238,255,0.2);
  border-radius: 6px;
  flex-wrap: wrap; justify-content: center;
  margin-bottom: 8px;
}
.opponent-controls.hidden { display: none; }
.opponent-status {
  font-size: 12px; letter-spacing: 0.08em;
  color: var(--text); white-space: nowrap;
}
.btn-sm {
  padding: 6px 14px !important;
  font-size: 12px !important;
}

/* Leader card state: chosen as human */
.leader-card.card-human-pick {
  border-color: var(--neon-cyan) !important;
  box-shadow: 0 0 22px rgba(0,238,255,0.55), inset 0 0 10px rgba(0,238,255,0.08);
  transform: translateY(-3px) scale(1.03);
}
/* Leader card state: picked as AI opponent */
.leader-card.card-ai-pick {
  border-color: var(--neon-red) !important;
  box-shadow: 0 0 18px rgba(255,34,68,0.45), inset 0 0 8px rgba(255,34,68,0.08);
}
/* Leader card state: not available (human already chosen this) */
.leader-card.card-unavailable {
  opacity: 0.38;
  filter: grayscale(0.7);
  pointer-events: none;
}
.card-pick-badge {
  position: absolute; top: 6px; right: 8px;
  font-size: 11px; font-weight: 700;
  padding: 2px 6px; border-radius: 3px;
  letter-spacing: 0.06em; pointer-events: none;
}

/* ══════════════════════════════════════════════════
   GAME SCREEN
   ══════════════════════════════════════════════════ */
#game-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  transition: opacity 0.35s ease;
}

/* ── PICK-MODE / MAP-MODE TOGGLE ─────────────────────── */
/* map-mode: canvas full brightness, HUD hidden (during resolution/animation) */
/* pick-mode: canvas dimmed, HUD cards visible at map-matching positions      */
#screen-game.map-mode  #game-canvas { opacity: 1; }
#screen-game.pick-mode #game-canvas { opacity: 0.25; }
/* Action panel is now a slide-up overlay; no display:none toggle needed */

/* Constellation overlay SVG (shown only in pick-mode) */
#hud-constellation {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 9;
  opacity: 0;
  transition: opacity 0.35s ease;
}
#screen-game.pick-mode #hud-constellation { opacity: 1; }

/* ── NATIONS HUD (pick-mode overlay) ─────────────────── */
.nations-hud {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 10;
  /* HUD is invisible by default; pick-mode makes it appear */
  opacity: 0;
  transition: opacity 0.35s ease;
}
#screen-game.pick-mode .nations-hud { opacity: 1; pointer-events: auto; }

.nation-hud-card {
  position: absolute;
  pointer-events: auto;
  display: flex; align-items: center; gap: 5px;
  padding: 5px 8px;
  background: rgba(2, 6, 18, 0.92);
  border: 1px solid transparent;
  border-radius: 6px;
  /* Smooth repositioning when pick-mode activates */
  transition: border-color 0.3s, opacity 0.35s ease;
  min-width: 140px;
  max-width: 175px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  /* Cards are centered on their map coordinate via JS-set transform */
  transform: translate(-50%, -50%);
}
/* Dim dead nation cards slightly (not fully hidden) */
.nation-hud-card.dead {
  opacity: 0.3;
  filter: grayscale(1);
}
.nation-hud-card.human-player {
  border-color: var(--neon-cyan) !important;
  box-shadow: inset 0 0 10px rgba(0,238,255,0.12),
              0 0 18px rgba(0,238,255,0.18);
}

/* Legacy corner-position classes kept so nothing breaks if JS is slow to run */
.hud-pos-tc { top: 4px; left: 50%; }
.hud-pos-tl { top: 4px; left: 4px; }
.hud-pos-tr { top: 4px; right: 4px; }
.hud-pos-bl { bottom: var(--action-panel-h, 168px); left: 4px; }
.hud-pos-br { bottom: var(--action-panel-h, 168px); right: 4px; }

.hud-emoji { font-size: 22px; }
.hud-portrait {
  /* 15% smaller at standard iOS viewport (~390 px), grows to 46 px at 1200 px */
  width:  clamp(31px, calc(24px + 1.85vw), 46px);
  height: clamp(31px, calc(24px + 1.85vw), 46px);
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
  border: 1px solid rgba(255,255,255,0.2);
  flex-shrink: 0;
}
.hud-name {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 80px;
}
.hud-pop-wrap { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 60px; }
.hud-pop-label { font-size: 10px; color: var(--text-mid); font-weight: 600; }
.hud-pop-bar-bg {
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}
.hud-pop-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease, background-color 0.4s ease;
}

/* ── PHASE BANNER (only visible during player input) ──── */
.phase-banner {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  padding: 4px 22px;
  background: rgba(0,0,0,0.7);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px; letter-spacing: 0.15em; color: var(--neon-cyan);
  text-shadow: var(--glow-c);
  z-index: 10;
  pointer-events: none;
}
.phase-banner.pb-hidden { display: none; }

/* ── ACTION COMMENTARY BANNER (shown during turn resolution, overlays action panel) ── */
.action-commentary {
  position: absolute; bottom: var(--teletype-h); top: auto; left: 0; right: 0;
  height: 160px;
  display: flex; align-items: center; justify-content: center;
  z-index: 22;
  padding: 10px 28px;
  background: rgba(0, 0, 0, 0.93);
  border-top: 2px solid rgba(255,255,255,0.35);
  font-size: 14px; line-height: 1.55;
  letter-spacing: 0.03em;
  color: #ffffff;
  text-align: center;
  pointer-events: none;
  animation: toastInAction 0.30s ease;
}
.action-commentary.hidden { display: none; }
.action-commentary.ac-standby {
  animation: acStandbyPulse 2.4s ease infinite;
  opacity: 0.55;
}
.action-commentary.ac-good { color: #ffffff; border-top-color: rgba(255,255,255,0.35); }
.action-commentary.ac-bad  { color: #ffffff; border-top-color: rgba(255,255,255,0.35); }
.action-commentary.ac-info { color: #ffffff; border-top-color: rgba(255,255,255,0.35); }

@keyframes toastInAction {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes acStandbyPulse {
  0%, 100% { opacity: 0.40; }
  50%       { opacity: 0.65; }
}

/* ── ACTION PANEL (slide-up overlay — hidden off-screen by default) ──────── */
.action-panel {
  position: absolute; bottom: var(--teletype-h); left: 0; right: 0;
  height: 160px;
  display: flex; gap: 0;
  background: rgba(2, 6, 18, 0.96);
  border-top: 2px solid var(--border);
  z-index: 20;
  /* Off-screen by default; slides up in pick-mode */
  transform: translateY(calc(100% + var(--teletype-h)));
  transition: transform 0.35s ease;
}
/* Slide into view when it's the player's turn */
#screen-game.pick-mode .action-panel {
  transform: translateY(0);
}

.player-portrait-area {
  width: 90px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-right: 1px solid var(--border);
  padding: 6px;
  font-size: 42px;
  position: relative;
  overflow: hidden;
}
.player-portrait-area svg { width: 100%; height: 100%; }
.player-portrait-label {
  position: absolute; bottom: 4px; left: 0; right: 0;
  text-align: center; font-size: 9px;
  color: var(--text-dim); letter-spacing: 0.08em;
}

.action-buttons-area {
  flex: 1;
  display: flex; flex-direction: column;
  padding: 8px 12px;
  overflow: hidden;
}
.action-title {
  font-size: 11px; color: var(--neon-yellow);
  letter-spacing: 0.12em;
  margin-bottom: 6px;
  text-shadow: var(--glow-y);
}
.action-buttons {
  display: flex; flex-wrap: wrap; gap: 6px;
  overflow-y: auto;
}

/* Individual action button */
.act-btn {
  padding: 7px 12px;
  font-family: inherit;
  font-size: clamp(10px, 1.2vw, 13px);
  font-weight: 700;
  letter-spacing: 0.07em;
  border: 1px solid;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
  transition: all 0.15s;
  white-space: nowrap;
  text-transform: uppercase;
}
.act-btn.attack {
  color: var(--neon-red); border-color: var(--neon-red);
}
.act-btn.attack:hover {
  background: rgba(255,34,68,0.18); box-shadow: var(--glow-r);
}
.act-btn.build {
  color: var(--neon-green); border-color: var(--neon-green);
}
.act-btn.build:hover {
  background: rgba(0,255,136,0.12); box-shadow: var(--glow-g);
}
.act-btn.spy {
  color: var(--neon-yellow); border-color: var(--neon-yellow);
}
.act-btn.spy:hover {
  background: rgba(255,224,0,0.12); box-shadow: var(--glow-y);
}
.act-btn.pass {
  color: var(--text-dim); border-color: rgba(100,120,150,0.4);
}
.act-btn.pass:hover { background: rgba(255,255,255,0.06); }

/* Secret weapon button */
.act-btn.secret {
  color: #bb88ff; border-color: #bb88ff;
  background: rgba(160,80,255,0.08);
}
.act-btn.secret:hover {
  background: rgba(160,80,255,0.22); box-shadow: 0 0 18px rgba(160,80,255,0.5);
}

/* Warp speed toggle */
.act-btn.warp {
  color: var(--text-dim); border-color: rgba(100,120,150,0.4);
  font-size: clamp(9px,1vw,11px);
}
.act-btn.warp:hover { background: rgba(255,224,0,0.08); }
.act-btn.warp.warp-on {
  color: var(--neon-yellow); border-color: var(--neon-yellow);
  background: rgba(255,224,0,0.1);
  box-shadow: var(--glow-y);
}

.act-btn:disabled {
  opacity: 0.3; cursor: not-allowed;
  filter: grayscale(0.8);
}
/* Weapon-requirement not met: still clickable (triggers error feedback) */
.act-btn.unavailable {
  opacity: 0.25; cursor: not-allowed;
  filter: grayscale(0.85);
}
.act-btn.unavailable:hover { background: rgba(255,34,68,0.06); }

/* §4: Deploy carrier button — amber/orange, distinct from attack (red) */
.act-btn.deploy {
  color: #ffaa00; border-color: #ffaa00;
  background: rgba(255,170,0,0.06);
}
.act-btn.deploy:hover {
  background: rgba(255,170,0,0.18); box-shadow: 0 0 14px rgba(255,170,0,0.45);
}

/* §4/§10: Carrier deployed banner in the action area */
.carrier-banner {
  width: 100%;
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: clamp(10px,1.1vw,12px);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffaa00;
  border: 1px solid #ffaa0066;
  border-radius: 4px;
  background: rgba(255,170,0,0.08);
  text-shadow: 0 0 10px #ffaa0088;
  animation: carrierPulse 1.2s ease-in-out infinite alternate;
}
@keyframes carrierPulse {
  from { opacity: 0.75; }
  to   { opacity: 1.0;  }
}

/* ── DIPLOMACY PANEL ─────────────────────────────────────── */
/* #diplomacy-strip lives in the HTML above #action-panel, not inside its
   flex row, so it never competes for space with the action buttons. */
#diplomacy-strip {
  position: absolute;
  bottom: 190px;   /* sits directly above the 160 px action panel + 30 px teletype bar */
  left: 0; right: 0;
}
.diplomacy-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-top: 1px solid var(--border);
  background: rgba(2, 6, 18, 0.88);
  font-size: 10px;
  min-height: 26px;
  overflow-x: auto;
}
.diplo-label {
  color: var(--text-mid);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 600;
}
.diplo-entry {
  display: flex;
  align-items: center;
  gap: 3px;
  opacity: 1;
  white-space: nowrap;
}
.diplo-entry.diplo-dead { opacity: 0.3; }
.diplo-bar-bg {
  width: 32px; height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}
.diplo-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}


/* ── ERROR SHAKE ──────────────────────────────────────────── */
@keyframes errShake {
  0%,100% { transform: translateX(0); }
  15%  { transform: translateX(-8px); }
  30%  { transform: translateX( 8px); }
  45%  { transform: translateX(-6px); }
  60%  { transform: translateX( 6px); }
  75%  { transform: translateX(-3px); }
  90%  { transform: translateX( 3px); }
}
#screen-game.err-shake { animation: errShake 0.45s ease; }

/* ── TURN SPEECH PANEL ────────────────────────────────────── */
#turn-speech {
  position: absolute;
  left: 0; right: 0;
  bottom: var(--teletype-h);
  height: 160px;
  z-index: 25;
  min-width: 0;
  max-width: 100%;
  background: rgba(6, 10, 24, 0.97);
  border: none;
  border-top: 1.5px solid var(--neon-cyan);
  border-radius: 0;
  padding: 12px 20px 12px 16px;
  display: flex; flex-direction: row; align-items: center; gap: 14px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(0);
  transition: opacity 0.3s ease;
  box-shadow: 0 -4px 28px rgba(0,200,255,0.18);
}
#turn-speech.ts-visible {
  opacity: 1;
}
.ts-portrait {
  width: 72px;
  height: 86px;
  flex-shrink: 0;
  border-radius: 5px;
  overflow: hidden;
  border: 1.5px solid currentColor;
  background: rgba(0,0,0,0.4);
}
.ts-portrait svg { width: 100%; height: 100%; display: block; }
.ts-content {
  display: flex; flex-direction: column; gap: 5px;
  flex: 1; min-width: 0;
}
.ts-leader {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
}
.ts-quote {
  font-size: 14px; line-height: 1.55;
  color: #ffffff; font-style: italic;
  font-weight: 700;
}

/* ── LEADER OUTBURST BUBBLE ───────────────────────────────── */
.leader-card { position: relative; }
.leader-bubble {
  position: absolute;
  top: 10px; right: -10px;
  background: rgba(6, 10, 24, 0.96);
  border: 1.5px solid transparent;
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 11px; line-height: 1.4;
  color: #e8f2ff; font-style: italic;
  pointer-events: none;
  z-index: 20;
  max-width: 170px;
  animation: lbFade 3s ease forwards;
}
@keyframes lbFade {
  0%  { opacity: 0; transform: scale(0.8); }
  12% { opacity: 1; transform: scale(1);   }
  78% { opacity: 1; transform: scale(1);   }
  100%{ opacity: 0; transform: scale(0.9); }
}

/* ── LEADER CARD BLINK ON OUTBURST ───────────────────────── */
@keyframes cardOutburstBlink {
  0%   { box-shadow: none; }
  20%  { box-shadow: 0 0 22px var(--card-color, rgba(0,200,255,0.8)), 0 0 6px var(--card-color, rgba(0,200,255,0.5)) inset; }
  40%  { box-shadow: none; }
  65%  { box-shadow: 0 0 18px var(--card-color, rgba(0,200,255,0.6)); }
  100% { box-shadow: none; }
}
.leader-card.card-outburst {
  animation: cardOutburstBlink 1s ease;
}

/* Event log */
.event-log {
  width: 240px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 6px 10px;
  overflow: hidden;
}
.event-log-title {
  font-size: 11px; letter-spacing: 0.12em;
  color: var(--text-mid); margin-bottom: 5px;
  text-transform: uppercase; font-weight: 700;
}
.event-log-entries {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 3px;
  scroll-behavior: smooth;
}
.event-log-entries::-webkit-scrollbar { width: 4px; }
.event-log-entries::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.log-entry {
  font-size: 11px; line-height: 1.4;
  padding: 2px 4px;
  border-left: 2px solid transparent;
  animation: logFade 0.3s ease;
}
@keyframes logFade { from { opacity: 0; transform: translateX(6px); } }
.log-attack { border-left-color: var(--neon-red); color: #ff9aaa; }
.log-build  { border-left-color: var(--neon-green); color: #98ffcc; }
.log-prop   { border-left-color: var(--neon-yellow); color: #ffe898; }
.log-event  { border-left-color: var(--neon-cyan); color: #98e8ff; }
.log-death  { border-left-color: #ff00ff; color: #ff98ff; }
.log-turn   { color: var(--text-mid); font-style: italic; }

/* ── TARGET OVERLAY ──────────────────────────────── */
.target-overlay {
  position: absolute; inset: 0;
  z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  animation: fadeIn 0.18s ease;
}
.target-overlay.hidden { display: none; }
.target-panel {
  background: var(--panel);
  border: 1px solid var(--neon-red);
  border-radius: 8px;
  padding: 22px 28px;
  box-shadow: var(--glow-r);
  min-width: 300px; max-width: 90%;
}
.target-panel h3 {
  color: var(--neon-red);
  font-size: 18px; letter-spacing: 0.1em;
  margin-bottom: 16px;
  text-shadow: var(--glow-r);
}
.target-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.target-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 5px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: all 0.15s;
}
.target-btn:hover {
  background: rgba(255,34,68,0.15);
  border-color: var(--neon-red);
}
.target-btn-emoji { font-size: 22px; }
.target-btn-info { display: flex; flex-direction: column; gap: 2px; text-align: left; }
.target-btn-name { font-weight: 700; }
.target-btn-pop  { font-size: 11px; color: var(--text-dim); }
.btn-cancel {
  padding: 8px 20px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-cancel:hover { color: var(--neon-cyan); border-color: var(--neon-cyan); }

/* ── CITY SELECTOR OVERLAY ─────────────────────────── */
.city-selector-overlay {
  position: absolute; inset: 0;
  z-index: 21;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.78);
  animation: fadeIn 0.18s ease;
}
.city-selector-overlay.hidden { display: none; }
.city-selector-panel {
  background: var(--panel);
  border: 1px solid var(--neon-yellow);
  border-radius: 8px;
  padding: 22px 28px 18px;
  box-shadow: 0 0 30px rgba(255, 204, 0, 0.25);
  width: min(580px, 92%);
  display: flex; flex-direction: column; gap: 14px;
}
.city-selector-panel h3 {
  color: var(--neon-yellow);
  font-size: 16px; letter-spacing: 0.1em;
  text-shadow: 0 0 12px rgba(255,204,0,0.5);
  margin: 0;
}
.city-selector-grid {
  position: relative;
  height: 220px;
  background: rgba(0, 60, 120, 0.18);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
}
.city-sel-btn {
  position: absolute;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  transition: all 0.15s;
  min-width: 72px;
}
.city-sel-btn:hover:not(:disabled) {
  background: rgba(255, 204, 0, 0.18);
  border-color: var(--neon-yellow);
  box-shadow: 0 0 12px rgba(255,204,0,0.3);
}
.city-sel-btn:disabled,
.city-sel-dead {
  opacity: 0.4;
  cursor: not-allowed;
}
.city-sel-icon  { font-size: 22px; line-height: 1; }
.city-sel-name  { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; white-space: nowrap; }
.city-sel-pop   { font-size: 10px; color: var(--neon-cyan); font-weight: 600; }

/* ── AI OVERLAY ──────────────────────────────────── */
.ai-overlay {
  position: absolute; inset: 0;
  z-index: 18;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.ai-overlay.hidden { display: none; }
.ai-panel {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 20px 36px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--glow-c);
}
.ai-spinner {
  font-size: 36px;
  animation: spinForward 1s linear infinite;
  color: var(--neon-cyan);
  text-shadow: var(--glow-c);
}
@keyframes spinForward { to { transform: rotate(360deg); } }
#ai-text { font-size: 14px; color: var(--neon-cyan); letter-spacing: 0.1em; }

/* ── EVENT TOAST ─────────────────────────────────── */
.event-toast {
  position: absolute;
  bottom: calc(var(--teletype-h) + 12px); left: 50%; transform: translateX(-50%);
  z-index: 30;
  padding: 12px 28px;
  background: rgba(0,0,0,0.85);
  border: 1px solid var(--neon-cyan);
  border-radius: 6px;
  font-size: 14px; letter-spacing: 0.06em;
  color: var(--neon-cyan);
  box-shadow: var(--glow-c);
  animation: toastIn 0.39s ease;
  text-align: center;
}
.event-toast.hidden { display: none; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ══════════════════════════════════════════════════
   VICTORY SCREEN
   ══════════════════════════════════════════════════ */
#victory-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
.victory-container {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; text-align: center; padding: 24px;
}
.victory-icon {
  font-size: clamp(60px, 10vw, 100px);
  animation: victoryBounce 1s ease infinite alternate;
  filter: drop-shadow(0 0 40px var(--neon-yellow));
}
@keyframes victoryBounce {
  from { transform: scale(1); }
  to   { transform: scale(1.18) rotate(10deg); }
}
.victory-title {
  font-size: clamp(40px, 8vw, 80px);
  font-weight: 900;
  letter-spacing: 0.15em;
  background: linear-gradient(135deg, var(--neon-yellow), var(--neon-orange), var(--neon-red));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
}
.victory-leader {
  font-size: clamp(18px, 3vw, 28px);
  font-weight: 700;
  letter-spacing: 0.1em;
}
.victory-msg {
  font-size: clamp(13px, 1.8vw, 16px);
  color: var(--text-dim);
  max-width: 600px;
  line-height: 1.6;
}
.victory-stats {
  display: flex; gap: 16px; flex-wrap: wrap; justify-content: center;
  margin: 6px 0;
}
.vstat {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 10px 18px;
  font-size: 13px;
}
.vstat span { color: var(--neon-cyan); font-size: 18px; font-weight: 700; }

/* ── SHARED UTILITIES ────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes shake {
  0%,100% { transform: translate(0,0) rotate(0); }
  15%  { transform: translate(-6px, 3px) rotate(-1deg); }
  30%  { transform: translate(5px, -4px) rotate(1deg); }
  45%  { transform: translate(-4px, 5px) rotate(-0.5deg); }
  60%  { transform: translate(6px, -2px) rotate(0.5deg); }
  75%  { transform: translate(-3px, 3px) rotate(-0.5deg); }
}
.screenshake { animation: shake 0.45s ease; }

/* ── RESPONSIVE ADJUSTMENTS ──────────────────────── */
@media (max-width: 700px) {
  .action-panel { height: 190px; }
  .action-commentary { height: 190px; }
  .event-log    { display: none; }
  .player-portrait-area { width: 70px; font-size: 36px; }
  #turn-speech { height: 190px; }
}

@media (max-width: 500px) {
  .leader-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 98%;
  }
  .select-header { margin-bottom: 10px; }
  .leader-portrait { font-size: 52px; }
  .leader-desc { font-size: 10px; }
}

/* ── LARGE-SCREEN ADJUSTMENTS (≥1200 px) ─────────── */
@media (min-width: 1200px) {
  /* Action panel & narration: taller to give more narrative room */
  :root { --action-panel-h: 208px; }
  .action-panel     { height: 200px; }
  .action-commentary{ height: 200px; }
  #turn-speech      { height: 200px; }

  /* Narration panel content: larger portrait + bigger quote text */
  .ts-portrait { width: 88px; height: 106px; }
  .ts-quote    { font-size: 16px; }
  .ts-leader   { font-size: 11px; }

  /* HUD nation cards: wider and more spacious */
  .nation-hud-card {
    min-width: 180px;
    max-width: 230px;
    padding: 7px 12px;
    gap: 7px;
  }
  .hud-name     { font-size: 13px; max-width: 100px; }
  .hud-emoji    { font-size: 27px; }
  .hud-pop-label{ font-size: 11px; }
  .hud-pop-bar-bg{ height: 7px; }
}

/* ── NEW: INDICATOR LIGHTS (§13) ──────────────── */
.ind-light {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  flex-shrink: 0;
}
.ind-green {
  background: #00ff88;
  box-shadow: 0 0 5px #00ff88;
}
.ind-red {
  background: #ff2244;
  box-shadow: 0 0 5px #ff2244;
}
.act-tip { opacity: 0.65; font-size: 0.85em; }

/* ── NEW: CITY TIER ICONS IN HUD (§5) ──────────── */
.hud-cities {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.hud-city {
  font-size: 12px;
  cursor: default;
  line-height: 1;
}
.hud-city.dead { opacity: 0.35; }

/* ── NEW: ATTITUDE INDICATOR ON HUD CARDS (§2) ───────── */
.hud-attitude {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 3px;
  cursor: default;
  line-height: 1;
}
.hud-att-face {
  font-size: 13px;
  line-height: 1;
}
.hud-att-num {
  font-size: 10px;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  opacity: 0.9;
}
.hud-att-num.diplo-benevolent { color: #00e5ff; }
.hud-att-num.diplo-friendly   { color: #00ff88; }
.hud-att-num.diplo-neutral    { color: #ffcc00; }
.hud-att-num.diplo-unfriendly { color: #ff8800; }
.hud-att-num.diplo-hostile    { color: #ff2244; }

/* ── NEW: DIPLOMACY 5-FACE BARS (§2) ────────────── */
.diplo-bar.diplo-benevolent { background: #00e5ff; }
.diplo-bar.diplo-friendly   { background: #00ff88; }
.diplo-bar.diplo-neutral    { background: #ffcc00; }
.diplo-bar.diplo-unfriendly { background: #ff8800; }
.diplo-bar.diplo-hostile    { background: #ff2244; }

/* ── NEW: HIGH SCORE LIST (§11) ────────────────── */
.victory-highscores {
  margin: 10px auto;
  max-width: 460px;
  text-align: left;
}
.hs-title {
  color: var(--neon-yellow);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-align: center;
  margin-bottom: 6px;
}
.hs-list {
  list-style: none;
  padding: 0; margin: 0;
  font-family: 'Courier New', monospace;
  font-size: 12px;
}
.hs-entry {
  display: flex;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 4px 0;
}
.hs-rank   { color: var(--neon-yellow); width: 24px; text-align: right; }
.hs-name   { flex: 1; color: var(--text); }
.hs-score  { color: var(--neon-cyan); font-weight: 700; }
.hs-detail { color: var(--text-dim); font-size: 10px; }

/* ── NEW: TELETYPE FONT + SCANLINES ON LOG PANEL (§13) ─── */
.event-log-entries {
  font-family: 'Courier New', Courier, monospace;
  position: relative;
}
.event-log-entries::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 4px
  );
  pointer-events: none;
  border-radius: inherit;
}

/* ── TURN-START CONTINENT SPOTLIGHT (§27) ────────────────── */
#turn-spotlight {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 24;
  opacity: 0;
  transition: opacity 0.45s ease-out;
}
#turn-spotlight.spotlight-in  { opacity: 1; }
#turn-spotlight.spotlight-out {
  opacity: 0;
  transition: opacity 0.75s ease-in;
}

/* ── TELETYPE STATUS BAR ───────────────────────────────────── */
#teletype-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: var(--teletype-h);
  background: #001810;
  border-top: 1px solid #004422;
  z-index: 25;
  display: flex;
  align-items: center;
  padding: 0 14px;
  overflow: hidden;
  pointer-events: none;
  font-family: 'Courier New', Courier, monospace;
  font-size: 11px;
  color: #00cc66;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.tt-cursor {
  display: inline-block;
  width: 7px; height: 11px;
  background: #00cc66;
  margin-left: 2px;
  animation: ttBlink 0.75s step-end infinite;
  vertical-align: bottom;
  flex-shrink: 0;
}
@keyframes ttBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}
