/* ============================================================
   IRON KINGDOM — Civilization-style 4X Strategy Game
   Medieval Parchment & Gold Theme
   ============================================================ */

/* ---- Google Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700;900&family=MedievalSharp&family=Inter:wght@300;400;500;600;700&display=swap');

/* ============================================================
   CSS CUSTOM PROPERTIES
   ============================================================ */
:root {
  /* Core palette — dark parchment/leather */
  --bg-dark: #1a1510;
  --bg-medium: #2a2218;
  --bg-parchment: #3a3020;
  --bg-parchment-light: #4a3f2e;
  --bg-overlay: rgba(26, 21, 16, 0.92);
  --bg-panel: rgba(42, 34, 24, 0.95);

  /* Gold accents */
  --gold: #d4a520;
  --gold-bright: #ffd700;
  --gold-dim: #9a7a18;
  --gold-glow: rgba(255, 215, 0, 0.4);

  /* Functional colors */
  --red-war: #cc3333;
  --red-war-bright: #ff4444;
  --blue-diplomacy: #3366cc;
  --blue-diplomacy-bright: #5588ee;
  --green-growth: #33aa33;
  --green-growth-bright: #44dd44;

  /* Era accent colors */
  --era-stone: #8b7355;
  --era-bronze: #cd7f32;
  --era-iron: #8a8a8a;
  --era-medieval: #7744aa;
  --era-renaissance: #3366cc;
  --era-industrial: #993333;

  /* Text */
  --text-primary: #e8dcc8;
  --text-secondary: #b0a48e;
  --text-dim: #7a7060;
  --text-gold: #d4a520;

  /* Borders */
  --border-gold: 1px solid #d4a520;
  --border-gold-thick: 2px solid #d4a520;
  --border-dark: 1px solid rgba(212, 165, 32, 0.25);
  --border-inner: 1px solid rgba(212, 165, 32, 0.12);

  /* Fonts */
  --font-display: 'Cinzel', 'MedievalSharp', 'Times New Roman', serif;
  --font-medieval: 'MedievalSharp', 'Cinzel', serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;

  /* Spacing */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;
  --sp-2xl: 48px;

  /* Radius */
  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 10px;

  /* Transitions */
  --t-fast: 150ms ease;
  --t-normal: 250ms ease;
  --t-slow: 500ms ease;

  /* Shadows */
  --shadow-panel: 0 4px 24px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(212, 165, 32, 0.1);
  --shadow-button: 0 2px 8px rgba(0, 0, 0, 0.5);
  --shadow-gold-glow: 0 0 20px rgba(255, 215, 0, 0.3);
  --shadow-text-gold: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-dark);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text-gold);
  letter-spacing: 0.03em;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-bright); }

/* Scrollbar — parchment theme */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ============================================================
   SHARED: BUTTONS — Parchment/Leather Look
   ============================================================ */
.btn,
.hud-btn,
.action-btn,
.diplo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  padding: 10px 22px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-primary);
  background: linear-gradient(180deg, #3e3428 0%, #2a2218 60%, #221c12 100%);
  border: var(--border-gold);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-button), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: all var(--t-fast);
  user-select: none;
  white-space: nowrap;
}

.btn:hover,
.hud-btn:hover,
.action-btn:hover,
.diplo-btn:hover {
  color: var(--gold-bright);
  border-color: var(--gold-bright);
  box-shadow: var(--shadow-button), var(--shadow-gold-glow);
  transform: translateY(-1px);
}

.btn:active,
.hud-btn:active,
.action-btn:active,
.diplo-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  background: linear-gradient(180deg, #2a2218 0%, #1a1510 100%);
}

.btn:disabled,
.action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-gold,
.btn--primary {
  background: linear-gradient(180deg, #5a4420 0%, #3a2c10 100%);
  border-color: var(--gold-bright);
  color: var(--gold-bright);
}

.btn--war,
.diplo-btn.war {
  border-color: var(--red-war);
  color: var(--red-war-bright);
}

.btn--war:hover,
.diplo-btn.war:hover {
  border-color: var(--red-war-bright);
  box-shadow: var(--shadow-button), 0 0 20px rgba(204, 51, 51, 0.3);
  background: rgba(204, 51, 51, 0.15);
}

.btn--diplomacy {
  border-color: var(--blue-diplomacy);
  color: var(--blue-diplomacy-bright);
}

.btn--diplomacy:hover {
  border-color: var(--blue-diplomacy-bright);
  box-shadow: var(--shadow-button), 0 0 20px rgba(51, 102, 204, 0.3);
}

.btn--growth {
  border-color: var(--green-growth);
  color: var(--green-growth-bright);
}

.btn--growth:hover {
  border-color: var(--green-growth-bright);
  box-shadow: var(--shadow-button), 0 0 20px rgba(51, 170, 51, 0.3);
}

.btn--large {
  padding: 14px 36px;
  font-size: 16px;
  border-radius: var(--radius-md);
}

.btn--small {
  padding: 6px 14px;
  font-size: 11px;
}

.btn--icon {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 16px;
}

.btn-outline {
  background: transparent;
  border: var(--border-gold);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--gold-bright);
  color: var(--gold-bright);
}

/* Active state for action buttons */
.action-btn.active {
  background: rgba(212, 165, 32, 0.2);
  border-color: var(--gold-bright);
  color: var(--gold-bright);
}

/* ============================================================
   SHARED: PANELS
   ============================================================ */
.panel,
.overlay-panel {
  background: var(--bg-panel);
  border: var(--border-gold);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(8px);
}

.overlay-panel {
  padding: var(--sp-lg);
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  min-width: 600px;
}

.overlay-panel h2 {
  color: var(--gold-bright);
  margin-bottom: var(--sp-md);
  font-size: 1.4rem;
  border-bottom: 1px solid rgba(212, 165, 32, 0.25);
  padding-bottom: 10px;
  text-shadow: var(--shadow-text-gold);
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-md) var(--sp-lg);
  border-bottom: var(--border-dark);
}

.panel__title {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--text-gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.panel__body {
  padding: var(--sp-md) var(--sp-lg);
}

.panel__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-sm);
  padding: var(--sp-md) var(--sp-lg);
  border-top: var(--border-dark);
}

/* Divider — gold gradient line */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
  margin: var(--sp-md) 0;
}

/* ============================================================
   SHARED: PROGRESS / HP BAR
   ============================================================ */
.bar,
.unit-hp-bar {
  position: relative;
  height: 8px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(212, 165, 32, 0.2);
  border-radius: 4px;
  overflow: hidden;
}

.unit-hp-bar {
  width: 120px;
  height: 6px;
  margin-top: 4px;
}

.bar__fill,
.unit-hp-fill {
  height: 100%;
  border-radius: 3px;
  transition: width var(--t-normal);
}

.bar--hp .bar__fill        { background: linear-gradient(90deg, #33aa33, #55cc55); }
.bar--hp-medium .bar__fill { background: linear-gradient(90deg, #cc9933, #ddaa44); }
.bar--hp-low .bar__fill    { background: linear-gradient(90deg, #cc3333, #dd4444); }
.bar--xp .bar__fill        { background: linear-gradient(90deg, #3366cc, #5588ee); }
.bar--production .bar__fill { background: linear-gradient(90deg, #cd7f32, #dda040); }
.bar--growth .bar__fill    { background: linear-gradient(90deg, #33aa33, #55cc55); }
.bar--culture .bar__fill   { background: linear-gradient(90deg, #7744aa, #9966cc); }
.bar--science .bar__fill   { background: linear-gradient(90deg, #3366cc, #5588ee); }

.bar--large { height: 14px; border-radius: 7px; }

.bar__label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* ============================================================
   SHARED: RESOURCE ICONS
   ============================================================ */
.resource-icon {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
}

.resource-icon--gold       { color: #ffd700; }
.resource-icon--science    { color: #5588ee; }
.resource-icon--culture    { color: #9966cc; }
.resource-icon--food       { color: #55cc55; }
.resource-icon--production { color: #dda040; }
.resource-icon--faith      { color: #dddddd; }

/* ============================================================
   SHARED: TOOLTIP
   ============================================================ */
.tooltip {
  position: absolute;
  z-index: 9999;
  padding: var(--sp-sm) var(--sp-md);
  background: var(--bg-dark);
  border: var(--border-gold);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-primary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--t-fast);
}

.tooltip--visible { opacity: 1; }

/* ============================================================
   GAME CANVAS CONTAINER
   ============================================================ */
#gameCanvas,
.game-canvas {
  display: block;
  cursor: grab;
}

#gameCanvas.grabbing { cursor: grabbing; }

#gameContainer {
  display: none;
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* ============================================================
   MAIN GAME HUD — TOP BAR
   ============================================================ */
#topHud,
.hud__top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 var(--sp-md);
  background: linear-gradient(180deg, rgba(26, 21, 16, 0.95) 0%, rgba(26, 21, 16, 0.80) 100%);
  border-bottom: 1px solid rgba(212, 165, 32, 0.3);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  z-index: 10;
  font-size: 0.85rem;
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 18px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: rgba(212, 165, 32, 0.06);
}

.hud-icon {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.hud-label {
  color: var(--text-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hud-val {
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#hudTurn,
.hud__turn-number {
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
}

#hudEra,
.hud__era-name {
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 0.8rem;
  margin-left: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hud-spacer { flex: 1; }

/* HUD resource-specific colors */
.hud-item.gold .hud-val   { color: #ffd700; }
.hud-item.science .hud-val { color: #88bbee; }
.hud-item.culture .hud-val { color: #bb88ee; }
.hud-item.food .hud-val    { color: #77dd77; }

/* ---- End Turn Button ---- */
#endTurnBtn,
.hud__end-turn {
  padding: 8px 28px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #1a1510;
  background: linear-gradient(180deg, #ffd700 0%, #d4a520 50%, #b8920e 100%);
  border: 2px solid #ffd700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--t-fast);
  box-shadow: 0 2px 12px rgba(255, 215, 0, 0.3);
  margin-left: 6px;
}

#endTurnBtn:hover,
.hud__end-turn:hover {
  background: linear-gradient(180deg, #ffe44d 0%, #ffd700 50%, #d4a520 100%);
  box-shadow: 0 2px 20px rgba(255, 215, 0, 0.5);
  transform: translateY(-1px);
}

#endTurnBtn:active,
.hud__end-turn:active {
  transform: translateY(0);
  box-shadow: 0 1px 6px rgba(255, 215, 0, 0.2);
}

.hud__end-turn--waiting {
  animation: pulse-gold 1.5s ease-in-out infinite;
}

@keyframes pulse-gold {
  0%, 100% { box-shadow: 0 2px 12px rgba(255, 215, 0, 0.3); }
  50%      { box-shadow: 0 2px 24px rgba(255, 215, 0, 0.6); }
}

/* ---- AI Portraits in HUD ---- */
.ai-portraits {
  display: flex;
  gap: 4px;
  margin-left: 12px;
}

.ai-portrait {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(212, 165, 32, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--t-fast);
  background: rgba(42, 34, 24, 0.8);
  color: var(--text-secondary);
}

.ai-portrait:hover {
  transform: scale(1.15);
  border-color: var(--gold);
}

.ai-portrait.at-war {
  border-color: var(--red-war);
  box-shadow: 0 0 8px rgba(204, 51, 51, 0.5);
}

.ai-portrait.allied {
  border-color: var(--green-growth);
  box-shadow: 0 0 6px rgba(51, 170, 51, 0.3);
}

/* ============================================================
   MAIN GAME HUD — BOTTOM PANEL
   ============================================================ */
#bottomHud,
.hud__bottom-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 280px;
  height: 80px;
  background: linear-gradient(0deg, rgba(26, 21, 16, 0.95) 0%, rgba(26, 21, 16, 0.80) 100%);
  border-top: 1px solid rgba(212, 165, 32, 0.3);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-md);
  z-index: 10;
}

/* Unit info in bottom panel */
#unitInfo,
.hud__selected-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.unit-portrait,
.hud__selected-icon {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  border: 2px solid rgba(212, 165, 32, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: rgba(26, 21, 16, 0.8);
}

.unit-details,
.hud__selected-details {
  flex: 1;
}

.unit-name,
.hud__selected-name {
  font-family: var(--font-display);
  color: var(--gold-bright);
  font-size: 0.95rem;
  font-weight: 700;
}

.unit-stats,
.hud__selected-type {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-top: 2px;
}

.action-buttons,
.hud__action-buttons {
  display: flex;
  gap: 6px;
  align-items: center;
}

.action-btn {
  padding: 8px 14px;
  font-size: 0.8rem;
  font-family: var(--font-body);
}

/* ============================================================
   MINIMAP
   ============================================================ */
#minimapContainer,
.hud__minimap {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 280px;
  height: 200px;
  background: rgba(26, 21, 16, 0.95);
  border-top: 1px solid rgba(212, 165, 32, 0.3);
  border-left: 1px solid rgba(212, 165, 32, 0.3);
  z-index: 10;
  overflow: hidden;
}

#minimapCanvas,
.hud__minimap-canvas {
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.hud__minimap-viewport {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.6);
  pointer-events: none;
}

/* ============================================================
   HEX GRID HIGHLIGHTS
   ============================================================ */
.hex-highlight--selected { filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.6)); }
.hex-highlight--hover    { filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.3)); }
.hex-highlight--move     { filter: drop-shadow(0 0 4px rgba(51, 170, 51, 0.5)); }
.hex-highlight--attack   { filter: drop-shadow(0 0 4px rgba(204, 51, 51, 0.5)); }

/* ============================================================
   OVERLAYS — Base
   ============================================================ */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.overlay.active { display: flex; }

.overlay-close {
  position: absolute;
  top: var(--sp-md);
  right: var(--sp-lg);
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color var(--t-fast);
}

.overlay-close:hover { color: var(--gold-bright); }

@keyframes overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ============================================================
   CITY SCREEN
   ============================================================ */
.city-screen {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  animation: overlay-in 300ms ease;
}

/* City header */
.city-header {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  margin-bottom: var(--sp-md);
}

.city-name {
  font-family: var(--font-display);
  color: var(--gold-bright);
  font-size: 1.3rem;
  font-weight: 900;
  text-shadow: var(--shadow-text-gold);
}

.city-pop {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* City yields row */
.city-yields {
  display: flex;
  gap: var(--sp-md);
  margin-bottom: var(--sp-md);
}

.city-yield {
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: rgba(212, 165, 32, 0.06);
  border: var(--border-inner);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

/* Buildings section */
.city-buildings { margin-bottom: var(--sp-md); }

.city-buildings h3 {
  color: var(--text-gold);
  font-size: 1rem;
  margin-bottom: var(--sp-sm);
  font-family: var(--font-display);
}

.building-tag {
  display: inline-block;
  padding: 4px 10px;
  margin: 2px;
  background: rgba(212, 165, 32, 0.08);
  border: var(--border-dark);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-secondary);
  transition: all var(--t-fast);
}

.building-tag:hover {
  border-color: var(--gold);
  background: rgba(212, 165, 32, 0.15);
}

/* Build queue */
.build-queue h3 {
  color: var(--text-gold);
  font-size: 1rem;
  margin-bottom: var(--sp-sm);
  font-family: var(--font-display);
}

.build-current {
  padding: 12px;
  background: rgba(212, 165, 32, 0.08);
  border: 1px solid var(--gold);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  color: var(--gold-bright);
  font-size: 0.9rem;
  font-family: var(--font-display);
  text-shadow: var(--shadow-text-gold);
}

.build-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.build-option {
  padding: 10px 12px;
  border: var(--border-dark);
  border-radius: var(--radius-md);
  background: rgba(42, 34, 24, 0.6);
  cursor: pointer;
  transition: all var(--t-fast);
}

.build-option:hover {
  border-color: var(--gold);
  background: rgba(212, 165, 32, 0.1);
  box-shadow: 0 0 8px rgba(212, 165, 32, 0.15);
}

.build-option .bo-name {
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
}

.build-option .bo-cost {
  color: var(--text-dim);
  font-size: 0.75rem;
}

/* Build option type indicators */
.build-option--unit    { border-left: 3px solid var(--red-war); }
.build-option--building { border-left: 3px solid var(--blue-diplomacy); }
.build-option--wonder  { border-left: 3px solid var(--gold-bright); }

/* ============================================================
   TECH TREE
   ============================================================ */
#techTreePanel,
.tech-tree__scroll {
  min-width: 800px;
  max-width: 95vw;
}

.tech-tree {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  flex-direction: column;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  animation: overlay-in 300ms ease;
}

.tech-tree__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-md) var(--sp-xl);
  background: rgba(42, 34, 24, 0.98);
  border-bottom: 1px solid rgba(212, 165, 32, 0.3);
}

.tech-tree__title {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--gold-bright);
  text-shadow: var(--shadow-text-gold);
}

.tech-tree__current {
  font-size: 13px;
  color: var(--text-secondary);
}

.tech-tree__current-name {
  color: var(--text-gold);
  font-weight: 600;
}

.tech-tree__scroll {
  flex: 1;
  overflow-x: auto;
  overflow-y: auto;
  padding: var(--sp-xl);
}

.tech-tree__grid {
  display: flex;
  gap: var(--sp-xl);
  min-width: max-content;
  padding-bottom: var(--sp-xl);
}

/* Era labels */
.tech-era-label,
.tech-tree__era-header {
  font-family: var(--font-display);
  color: var(--text-dim);
  font-size: 0.85rem;
  margin: var(--sp-md) 0 var(--sp-sm);
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--radius-sm);
}

/* Era-specific headers */
.tech-tree__era-header--stone,
.tech-era-label.stone       { background: rgba(139, 115, 85, 0.15); color: var(--era-stone); border: 1px solid rgba(139, 115, 85, 0.3); }
.tech-tree__era-header--bronze,
.tech-era-label.bronze      { background: rgba(205, 127, 50, 0.12); color: var(--era-bronze); border: 1px solid rgba(205, 127, 50, 0.3); }
.tech-tree__era-header--iron,
.tech-era-label.iron        { background: rgba(138, 138, 138, 0.12); color: var(--era-iron); border: 1px solid rgba(138, 138, 138, 0.3); }
.tech-tree__era-header--medieval,
.tech-era-label.medieval    { background: rgba(119, 68, 170, 0.12); color: var(--era-medieval); border: 1px solid rgba(119, 68, 170, 0.3); }
.tech-tree__era-header--renaissance,
.tech-era-label.renaissance { background: rgba(51, 102, 204, 0.12); color: var(--era-renaissance); border: 1px solid rgba(51, 102, 204, 0.3); }
.tech-tree__era-header--industrial,
.tech-era-label.industrial  { background: rgba(153, 51, 51, 0.12); color: var(--era-industrial); border: 1px solid rgba(153, 51, 51, 0.3); }

/* Tech grid */
.tech-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-sm);
}

/* Tech nodes */
.tech-node {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 10px 14px;
  background: rgba(42, 34, 24, 0.8);
  border: var(--border-gold);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--t-fast);
  min-width: 140px;
  position: relative;
}

.tech-node:hover {
  border-color: var(--gold-bright);
  box-shadow: var(--shadow-gold-glow);
  transform: translateY(-1px);
}

.tech-node.researched,
.tech-node--researched {
  border-color: var(--green-growth);
  background: rgba(51, 170, 51, 0.1);
  box-shadow: 0 0 6px rgba(51, 170, 51, 0.15);
}

.tech-node.available,
.tech-node--available {
  border-color: var(--gold);
  background: rgba(212, 165, 32, 0.1);
}

.tech-node.researching,
.tech-node--current {
  border-color: var(--blue-diplomacy-bright);
  background: rgba(51, 102, 204, 0.12);
  box-shadow: 0 0 12px rgba(51, 102, 204, 0.3);
  animation: pulse-research 2s ease-in-out infinite;
}

@keyframes pulse-research {
  0%, 100% { box-shadow: 0 0 8px rgba(51, 102, 204, 0.2); }
  50%      { box-shadow: 0 0 18px rgba(51, 102, 204, 0.5); }
}

.tech-node.locked,
.tech-node--locked {
  background: rgba(26, 21, 16, 0.6);
  border-color: rgba(212, 165, 32, 0.15);
  opacity: 0.45;
  cursor: not-allowed;
}

.tech-node.locked:hover,
.tech-node--locked:hover {
  transform: none;
  box-shadow: none;
  border-color: rgba(212, 165, 32, 0.15);
}

.tech-node__icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
}

.tech-node .tn-name,
.tech-node__name {
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
}

.tech-node .tn-cost,
.tech-node__cost {
  color: var(--text-dim);
  font-size: 0.75rem;
}

.tech-node .tn-unlocks {
  color: var(--green-growth);
  font-size: 0.7rem;
  margin-top: 2px;
}

/* Tech tree connection lines */
.tech-tree__connections {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.tech-tree__connections line {
  stroke: rgba(212, 165, 32, 0.25);
  stroke-width: 2;
}

.tech-tree__connections line.researched {
  stroke: var(--gold);
  stroke-width: 2;
}

/* ============================================================
   DIPLOMACY SCREEN
   ============================================================ */
.diplomacy {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  flex-direction: column;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  animation: overlay-in 300ms ease;
}

.diplomacy__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-md) var(--sp-xl);
  background: rgba(42, 34, 24, 0.98);
  border-bottom: 1px solid rgba(51, 102, 204, 0.4);
}

.diplomacy__title {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--blue-diplomacy-bright);
  text-shadow: 0 0 10px rgba(51, 102, 204, 0.4);
}

/* Diplomacy leader cards */
.diplo-leaders {
  display: flex;
  gap: var(--sp-md);
  margin-bottom: 20px;
}

.diplo-leader {
  flex: 1;
  padding: var(--sp-md);
  border: var(--border-dark);
  border-radius: var(--radius-md);
  background: rgba(42, 34, 24, 0.6);
  cursor: pointer;
  text-align: center;
  transition: all var(--t-fast);
}

.diplo-leader:hover {
  border-color: rgba(212, 165, 32, 0.5);
  background: rgba(42, 34, 24, 0.8);
}

.diplo-leader.selected {
  border-color: var(--gold);
  background: rgba(212, 165, 32, 0.1);
  box-shadow: 0 0 10px rgba(212, 165, 32, 0.15);
}

.diplo-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  margin: 0 auto var(--sp-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
  border: 2px solid rgba(212, 165, 32, 0.4);
  background: rgba(0, 0, 0, 0.3);
}

.diplo-name {
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-display);
  font-weight: 700;
}

.diplo-status {
  font-size: 0.75rem;
  margin-top: 4px;
}

.diplo-status.friendly { color: var(--green-growth-bright); }
.diplo-status.neutral  { color: #ccaa33; }
.diplo-status.hostile  { color: var(--red-war-bright); }

/* Relationship meter */
.diplomacy__relationship {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  margin-top: 8px;
}

.diplomacy__relationship-bar {
  flex: 1;
  height: 6px;
  background: linear-gradient(90deg, var(--red-war), #cc9933, var(--green-growth));
  border-radius: 3px;
  position: relative;
}

.diplomacy__relationship-marker {
  position: absolute;
  top: -3px;
  width: 12px;
  height: 12px;
  background: white;
  border: 2px solid var(--bg-dark);
  border-radius: 50%;
  transform: translateX(-50%);
  transition: left var(--t-normal);
}

/* Diplomacy actions */
.diplo-actions {
  display: flex;
  gap: var(--sp-sm);
  flex-wrap: wrap;
}

.diplo-btn {
  padding: 10px 20px;
  font-size: 0.9rem;
}

/* Trade interface */
.diplomacy__trade {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--sp-lg);
  padding: var(--sp-lg);
  background: rgba(0, 0, 0, 0.3);
  border: var(--border-dark);
  border-radius: var(--radius-md);
  margin-top: var(--sp-lg);
}

.diplomacy__trade-title {
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--text-gold);
  text-transform: uppercase;
  margin-bottom: var(--sp-md);
  text-align: center;
}

.diplomacy__trade-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--gold);
}

.diplomacy__trade-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px var(--sp-sm);
  border-bottom: var(--border-inner);
  cursor: pointer;
  transition: background var(--t-fast);
}

.diplomacy__trade-item:hover {
  background: rgba(212, 165, 32, 0.1);
}

/* ============================================================
   UNIT INFO PANEL (floating)
   ============================================================ */
.unit-panel {
  position: absolute;
  bottom: 100px;
  left: var(--sp-md);
  width: 240px;
  pointer-events: auto;
}

.unit-panel__portrait {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  margin-bottom: var(--sp-md);
}

.unit-panel__icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: rgba(0, 0, 0, 0.4);
  border: var(--border-gold);
  border-radius: var(--radius-sm);
}

.unit-panel__name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-gold);
}

.unit-panel__class {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.unit-panel__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
}

.unit-panel__stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.unit-panel__stat-icon {
  width: 16px;
  text-align: center;
  color: var(--text-dim);
}

.unit-panel__stat-value {
  font-weight: 600;
  color: var(--text-primary);
  margin-left: auto;
}

/* ============================================================
   TURN NOTIFICATION
   ============================================================ */
.turn-notification {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 900;
  pointer-events: none;
  text-align: center;
}

.turn-notification__turn {
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 900;
  color: var(--gold-bright);
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.6), 0 0 60px rgba(255, 215, 0, 0.3);
  opacity: 0;
  animation: turn-flash 2s ease forwards;
}

@keyframes turn-flash {
  0%   { opacity: 0; transform: scale(0.8); }
  15%  { opacity: 1; transform: scale(1.1); }
  30%  { transform: scale(1); }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1) translateY(-20px); }
}

/* Era change celebration */
.turn-notification__era {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  opacity: 0;
  animation: era-celebration 4s ease forwards;
}

.turn-notification__era--stone       { color: var(--era-stone); text-shadow: 0 0 40px rgba(139, 115, 85, 0.5); }
.turn-notification__era--bronze      { color: var(--era-bronze); text-shadow: 0 0 40px rgba(205, 127, 50, 0.5); }
.turn-notification__era--iron        { color: var(--era-iron); text-shadow: 0 0 40px rgba(180, 180, 180, 0.5); }
.turn-notification__era--medieval    { color: var(--era-medieval); text-shadow: 0 0 40px rgba(119, 68, 170, 0.5); }
.turn-notification__era--renaissance { color: var(--era-renaissance); text-shadow: 0 0 40px rgba(51, 102, 204, 0.5); }
.turn-notification__era--industrial  { color: var(--era-industrial); text-shadow: 0 0 40px rgba(153, 51, 51, 0.5); }

@keyframes era-celebration {
  0%   { opacity: 0; transform: scale(0.5); letter-spacing: 0.5em; }
  20%  { opacity: 1; transform: scale(1.15); }
  35%  { transform: scale(1); letter-spacing: 0.15em; }
  75%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1) translateY(-30px); }
}

.turn-notification__era-subtitle {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--text-secondary);
  margin-top: var(--sp-sm);
  opacity: 0;
  animation: fade-in-delayed 4s ease forwards;
}

@keyframes fade-in-delayed {
  0%, 20% { opacity: 0; }
  40%     { opacity: 1; }
  75%     { opacity: 1; }
  100%    { opacity: 0; }
}

/* ============================================================
   VICTORY / DEFEAT SCREEN
   ============================================================ */
#victoryOverlay,
.endgame {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(8px);
}

#victoryOverlay.active,
.endgame.active {
  display: flex;
}

#victoryOverlay h1,
.endgame__title {
  font-family: var(--font-display);
  font-size: 4rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin-bottom: var(--sp-md);
}

.endgame__title--victory,
#victoryOverlay h1 {
  color: var(--gold-bright);
  text-shadow:
    0 0 20px rgba(255, 215, 0, 0.8),
    0 0 40px rgba(255, 215, 0, 0.5),
    0 0 80px rgba(255, 215, 0, 0.3);
  animation: victory-glow 2s ease-in-out infinite;
}

@keyframes victory-glow {
  0%, 100% {
    text-shadow:
      0 0 20px rgba(255, 215, 0, 0.8),
      0 0 40px rgba(255, 215, 0, 0.5),
      0 0 80px rgba(255, 215, 0, 0.3);
  }
  50% {
    text-shadow:
      0 0 30px rgba(255, 215, 0, 1),
      0 0 60px rgba(255, 215, 0, 0.7),
      0 0 120px rgba(255, 215, 0, 0.4);
  }
}

.endgame__title--defeat {
  color: var(--red-war-bright);
  text-shadow:
    0 0 20px rgba(204, 51, 51, 0.8),
    0 0 40px rgba(204, 51, 51, 0.5),
    0 0 80px rgba(204, 51, 51, 0.3);
  animation: defeat-pulse 2s ease-in-out infinite;
}

@keyframes defeat-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.7; }
}

#victoryOverlay p,
.endgame__condition {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--sp-xl);
}

.endgame__stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-lg);
  margin-bottom: var(--sp-2xl);
  padding: var(--sp-xl);
  background: rgba(42, 34, 24, 0.6);
  border: var(--border-gold);
  border-radius: var(--radius-lg);
}

.endgame__stat { text-align: center; }

.endgame__stat-value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--gold-bright);
}

.endgame__stat-label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}

.endgame__actions {
  display: flex;
  gap: var(--sp-lg);
}

#victoryOverlay button {
  padding: 14px 36px;
  border: 2px solid var(--gold-bright);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #5a4420 0%, #3a2c10 100%);
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--t-fast);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#victoryOverlay button:hover {
  box-shadow: var(--shadow-gold-glow);
  transform: translateY(-2px);
}

/* ============================================================
   TITLE SCREEN
   ============================================================ */
.title-screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at center, rgba(58, 48, 32, 0.4) 0%, transparent 70%),
    var(--bg-dark);
  overflow: hidden;
}

/* Animated parchment map background */
.title-screen__bg {
  position: absolute;
  inset: -50px;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 40px,
      rgba(212, 165, 32, 0.03) 40px,
      rgba(212, 165, 32, 0.03) 41px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 40px,
      rgba(212, 165, 32, 0.03) 40px,
      rgba(212, 165, 32, 0.03) 41px
    );
  opacity: 0.5;
  animation: map-drift 30s linear infinite;
}

@keyframes map-drift {
  0%   { transform: translate(0, 0); }
  100% { transform: translate(40px, 40px); }
}

.title-screen__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.7) 100%);
  pointer-events: none;
}

.title-screen__content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: title-fade-in 1.5s ease;
}

@keyframes title-fade-in {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.title-screen__logo {
  font-family: var(--font-display);
  font-size: 80px;
  font-weight: 900;
  color: var(--gold-bright);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  text-shadow:
    0 0 20px rgba(255, 215, 0, 0.6),
    0 0 40px rgba(255, 215, 0, 0.3),
    0 4px 0 #8a6a10,
    0 5px 0 #6a5010,
    0 6px 12px rgba(0, 0, 0, 0.6);
  margin-bottom: var(--sp-sm);
  animation: logo-shimmer 4s ease-in-out infinite;
}

@keyframes logo-shimmer {
  0%, 100% {
    text-shadow:
      0 0 20px rgba(255, 215, 0, 0.6),
      0 0 40px rgba(255, 215, 0, 0.3),
      0 4px 0 #8a6a10,
      0 5px 0 #6a5010,
      0 6px 12px rgba(0, 0, 0, 0.6);
  }
  50% {
    text-shadow:
      0 0 30px rgba(255, 215, 0, 0.8),
      0 0 60px rgba(255, 215, 0, 0.4),
      0 4px 0 #8a6a10,
      0 5px 0 #6a5010,
      0 6px 12px rgba(0, 0, 0, 0.6);
  }
}

.title-screen__subtitle {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4em;
  margin-bottom: var(--sp-2xl);
}

.title-screen__menu {
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  width: 280px;
}

.title-screen__menu .btn {
  width: 100%;
  padding: 16px;
  font-size: 15px;
  justify-content: center;
}

.title-screen__branding {
  position: absolute;
  bottom: var(--sp-xl);
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
#loginScreen,
.login {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at center, rgba(58, 48, 32, 0.3) 0%, transparent 70%),
    linear-gradient(135deg, var(--bg-dark) 0%, #2a2218 50%, var(--bg-dark) 100%);
}

#loginScreen h1 {
  font-family: var(--font-display);
  font-size: 3.5rem;
  color: var(--gold-bright);
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.4);
  margin-bottom: 8px;
  letter-spacing: 4px;
}

#loginScreen .subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 40px;
  font-family: var(--font-display);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.login-box,
.login__card {
  background: var(--bg-panel);
  border: var(--border-gold-thick);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 380px;
  box-shadow: var(--shadow-panel), var(--shadow-gold-glow);
}

.login-box h3 {
  color: var(--gold-bright);
  font-family: var(--font-display);
  margin-bottom: 20px;
  text-align: center;
  text-shadow: var(--shadow-text-gold);
}

/* Medieval themed inputs */
.login-box input,
.login__input,
.settings__input,
.admin__input {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(212, 165, 32, 0.3);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.login-box input:focus,
.login__input:focus,
.settings__input:focus,
.admin__input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(212, 165, 32, 0.15);
}

.login-box input::placeholder,
.login__input::placeholder {
  color: var(--text-dim);
}

.login-box button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  margin-bottom: 8px;
  transition: all var(--t-fast);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.login-box .btn-gold {
  background: linear-gradient(180deg, #ffd700 0%, #d4a520 50%, #b8920e 100%);
  color: #1a1510;
  border: 2px solid #ffd700;
}

.login-box .btn-gold:hover {
  background: linear-gradient(180deg, #ffe44d 0%, #ffd700 50%, #d4a520 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(255, 215, 0, 0.3);
}

.login-box .btn-outline {
  background: transparent;
  border: var(--border-gold);
  color: var(--text-secondary);
}

.login-box .btn-outline:hover {
  border-color: var(--gold-bright);
  color: var(--gold-bright);
}

.login-msg {
  text-align: center;
  font-size: 0.85rem;
  margin-top: 8px;
  min-height: 20px;
}

.login-msg.error { color: var(--red-war-bright); }
.login-msg.ok    { color: var(--green-growth-bright); }

.jh-brand,
.login__branding {
  margin-top: 40px;
  color: var(--text-dim);
  font-size: 0.8rem;
  font-family: var(--font-display);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.login__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: var(--sp-xs);
}

.login__error {
  font-size: 12px;
  color: var(--red-war-bright);
  margin-top: var(--sp-sm);
}

/* ============================================================
   SETTINGS SCREEN
   ============================================================ */
.settings {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  animation: overlay-in 300ms ease;
}

.settings__card {
  width: 480px;
  max-height: 80vh;
  overflow-y: auto;
}

.settings__group {
  margin-bottom: var(--sp-lg);
}

.settings__group-title {
  font-family: var(--font-display);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-gold);
  margin-bottom: var(--sp-md);
}

.settings__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-sm) 0;
  border-bottom: var(--border-inner);
}

.settings__label {
  font-size: 14px;
  color: var(--text-secondary);
}

.settings__value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  min-width: 40px;
  text-align: right;
}

/* Slider (range input) — gold thumb */
.settings__slider,
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 180px;
  height: 6px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(212, 165, 32, 0.2);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.settings__slider::-webkit-slider-thumb,
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: linear-gradient(180deg, #ffd700, #d4a520);
  border: 2px solid #ffd700;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: box-shadow var(--t-fast);
}

.settings__slider::-webkit-slider-thumb:hover,
input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 2px 10px rgba(255, 215, 0, 0.4);
}

.settings__slider::-moz-range-thumb,
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: linear-gradient(180deg, #ffd700, #d4a520);
  border: 2px solid #ffd700;
  border-radius: 50%;
  cursor: pointer;
}

/* Select dropdown */
.settings__select,
select {
  padding: 8px var(--sp-md);
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(212, 165, 32, 0.3);
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  min-width: 140px;
}

.settings__select:focus,
select:focus {
  border-color: var(--gold);
}

.settings__select option,
select option {
  background: var(--bg-dark);
  color: var(--text-primary);
}

/* ============================================================
   ADMIN PANEL
   ============================================================ */
#adminBar,
.admin {
  position: absolute;
  top: 48px;
  left: 0;
  right: 0;
  background: rgba(40, 10, 10, 0.95);
  border-bottom: 1px solid var(--red-war);
  padding: 6px 12px;
  display: none;
  z-index: 15;
  gap: 6px;
  align-items: center;
}

#adminBar.active,
.admin.active {
  display: flex;
}

.admin__card {
  width: 520px;
  max-height: 80vh;
  overflow-y: auto;
}

.admin .panel__header {
  border-bottom-color: rgba(204, 51, 51, 0.4);
}

.admin .panel__title {
  color: var(--red-war-bright);
}

.admin__warning {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  background: rgba(204, 51, 51, 0.1);
  border: 1px solid rgba(204, 51, 51, 0.3);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--red-war-bright);
  margin-bottom: var(--sp-lg);
}

.admin__section {
  margin-bottom: var(--sp-lg);
}

.admin__section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: var(--sp-sm);
}

.admin-btn,
.admin__cheat-btn {
  padding: 4px 12px;
  border: 1px solid var(--red-war);
  border-radius: var(--radius-sm);
  background: rgba(204, 51, 51, 0.12);
  color: var(--red-war-bright);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
}

.admin-btn:hover,
.admin__cheat-btn:hover {
  background: rgba(204, 51, 51, 0.3);
  box-shadow: 0 0 8px rgba(204, 51, 51, 0.2);
}

.admin__row {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  margin-bottom: var(--sp-sm);
}

.admin__row label {
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 100px;
}

/* ============================================================
   NOTIFICATIONS / TOASTS
   ============================================================ */
#notifications,
.notifications {
  position: absolute;
  top: 52px;
  right: 12px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
  max-width: 340px;
}

.notif,
.notification {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  background: var(--bg-panel);
  border: var(--border-dark);
  box-shadow: var(--shadow-panel);
  pointer-events: auto;
  animation: notifIn 0.3s ease, notifOut 0.5s ease 3s forwards;
  max-width: 300px;
}

.notif.gold,
.notification--gold   { border-left: 3px solid var(--gold); color: var(--gold-bright); }
.notif.science,
.notification--science { border-left: 3px solid var(--blue-diplomacy); color: #88bbee; }
.notif.war,
.notification--war    { border-left: 3px solid var(--red-war); color: #ee6666; }
.notif.city,
.notification--growth { border-left: 3px solid var(--green-growth); color: #66cc66; }
.notif.info,
.notification--info   { border-left: 3px solid var(--era-medieval); color: #aa88cc; }

.notification__title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-gold);
  margin-bottom: 4px;
}

.notification__body {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

@keyframes notifIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes notifOut {
  from { opacity: 1; }
  to   { opacity: 0; transform: translateY(-10px); }
}

/* ============================================================
   LOADING / TRANSITION
   ============================================================ */
.loading {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-dark);
}

.loading__spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(212, 165, 32, 0.2);
  border-top-color: var(--gold-bright);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: var(--sp-lg);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading__text {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  animation: loading-dots 1.5s ease-in-out infinite;
}

@keyframes loading-dots {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
  .city-screen {
    flex-direction: column;
  }

  .city-screen__info,
  .city-screen__yields {
    width: 100%;
    max-height: 30vh;
  }

  .endgame__stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .diplomacy__body,
  .diplo-leaders {
    flex-direction: column;
  }

  .overlay-panel {
    min-width: auto;
    width: 90vw;
  }

  .diplomacy__trade {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .title-screen__logo {
    font-size: 48px;
  }

  .title-screen__subtitle {
    font-size: 13px;
    letter-spacing: 0.2em;
  }

  .title-screen__menu {
    width: 220px;
  }

  #loginScreen h1 {
    font-size: 2.5rem;
  }

  #topHud,
  .hud__top-bar {
    flex-wrap: wrap;
    height: auto;
    padding: var(--sp-sm) var(--sp-md);
    gap: var(--sp-sm);
  }

  .hud-item {
    margin-right: 8px;
  }

  #minimapContainer,
  .hud__minimap {
    width: 160px;
    height: 120px;
  }

  #bottomHud,
  .hud__bottom-panel {
    right: 160px;
    flex-direction: column;
    height: auto;
    padding: var(--sp-sm);
  }

  .endgame__title,
  #victoryOverlay h1 {
    font-size: 3rem;
  }

  .endgame__stats {
    grid-template-columns: 1fr 1fr;
    padding: var(--sp-md);
  }

  .login-box,
  .login__card {
    width: 90%;
    max-width: 380px;
  }

  .settings__card,
  .admin__card {
    width: 90%;
    max-width: 480px;
  }

  .overlay-panel {
    min-width: auto;
    padding: var(--sp-md);
  }

  .build-options {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .title-screen__logo {
    font-size: 36px;
    letter-spacing: 0.08em;
  }

  #loginScreen h1 {
    font-size: 2rem;
  }

  .hud-item {
    padding: 2px 6px;
    font-size: 0.75rem;
  }

  .hud-icon {
    width: 14px;
    height: 14px;
  }

  #endTurnBtn,
  .hud__end-turn {
    padding: 6px 16px;
    font-size: 12px;
  }

  .endgame__title,
  #victoryOverlay h1 {
    font-size: 2.2rem;
  }

  .tech-grid {
    flex-direction: column;
  }

  .tech-node {
    min-width: auto;
    width: 100%;
  }
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.hidden     { display: none !important; }
.invisible  { visibility: hidden; }
.no-select  { user-select: none; }
.no-pointer { pointer-events: none; }
.pointer    { pointer-events: auto; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.text-gold  { color: var(--gold-bright); }
.text-red   { color: var(--red-war-bright); }
.text-blue  { color: var(--blue-diplomacy-bright); }
.text-green { color: var(--green-growth-bright); }
.text-dim   { color: var(--text-dim); }

.fade-in    { animation: fade-in 300ms ease; }
.slide-up   { animation: slide-up 300ms ease; }
.slide-down { animation: slide-down 300ms ease; }

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slide-down {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}
