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

:root {
  --bg: #0b0f1a;
  --bg-panel: #0f1525;
  --bg-card: #151d30;
  --bg-hover: #1c2844;
  --bg-selected: #1e3055;
  --border: #1e2d4a;
  --border-light: #2a3d5e;
  --text: #c8d4e6;
  --text-dim: #6b7a94;
  --text-bright: #eaf0fa;
  --gold: #d4a843;
  --gold-dim: #9a7a30;
  --gold-bright: #f0c850;
  --accent: #4a8ee6;
  --tier1: #6b7a94;
  --tier2: #4a8ee6;
  --tier3: #d4a843;
  --tier4: #d05040;
  --tier5: #a855f7;
  --positive: #3ec97a;
  --negative: #e05252;
  --warning: #e0a030;
  --economic: #3ec97a;
  --military: #e05252;
  --diplomatic: #4a8ee6;
  --cooperative: #38b2ac;
  --expansionist: #e07030;
  --isolationist: #6b7a94;
  --reformist: #a855f7;
  --industrial: #d4a843;
  --institutional: #60a5fa;
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: 'Georgia', 'Times New Roman', serif;
  background: var(--bg);
  color: var(--text);
}

/* SCREENS */
.screen { display: none; height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

/* BUTTONS */
.btn {
  padding: 0.6rem 1.4rem;
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
  letter-spacing: 0.02em;
}
.btn:hover { background: var(--bg-hover); border-color: var(--gold-dim); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn:disabled:hover { background: var(--bg-card); border-color: var(--border-light); }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.8rem; }
.btn-gold {
  background: linear-gradient(135deg, var(--gold-dim), var(--gold));
  border-color: var(--gold);
  color: #1a1000;
  font-weight: 600;
}
.btn-gold:hover { background: linear-gradient(135deg, var(--gold), var(--gold-bright)); }
.btn-gold:disabled { background: var(--bg-card); border-color: var(--border-light); color: var(--text-dim); }

/* ═══════════════════════════════════════
   INTRO SCREEN
   ═══════════════════════════════════════ */
.intro-bg {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(212,168,67,0.06) 0%, transparent 60%),
    radial-gradient(ellipse at center, #111828 0%, #0b0f1a 70%);
}
.intro-content {
  max-width: 640px;
  text-align: center;
  padding: 2rem;
}
.intro-title {
  font-size: 3.2rem;
  font-weight: 400;
  color: var(--gold);
  letter-spacing: 0.04em;
  margin-bottom: 0.3rem;
  font-family: 'Georgia', serif;
}
.intro-subtitle {
  font-size: 1rem;
  color: var(--text-dim);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-family: system-ui, sans-serif;
  margin-bottom: 2.5rem;
}
.intro-text {
  text-align: left;
  margin-bottom: 2rem;
  line-height: 1.7;
  font-size: 0.95rem;
  color: var(--text);
}
.intro-text p { margin-bottom: 0.8rem; }
.intro-text strong { color: var(--gold); }
.intro-stats-preview {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
}
.intro-stat-item { text-align: center; }
.intro-stat-icon { font-size: 1.5rem; margin-bottom: 0.2rem; }
.intro-stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  font-family: system-ui, sans-serif;
}

/* ═══════════════════════════════════════
   TOP BAR
   ═══════════════════════════════════════ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.2rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: 48px;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 0.6rem; }
.topbar-flag { font-size: 1.3rem; }
.topbar-nation {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-bright);
  font-family: system-ui, sans-serif;
}
.topbar-year {
  font-size: 1.4rem;
  font-weight: 300;
  color: var(--gold);
  letter-spacing: 0.08em;
  font-family: 'Georgia', serif;
}

/* TIER BADGES */
.tier-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.tier-1 { background: var(--tier1); color: white; }
.tier-2 { background: var(--tier2); color: white; }
.tier-3 { background: var(--tier3); color: #1a1000; }
.tier-4 { background: var(--tier4); color: white; }
.tier-5 { background: var(--tier5); color: white; }

/* ═══════════════════════════════════════
   GAME LAYOUT (3-column)
   ═══════════════════════════════════════ */
.game-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 320px 1fr 280px;
  overflow: hidden;
}

/* LEFT: Globe Panel */
.globe-panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg);
  overflow: hidden;
}
.globe-wrapper {
  flex: 1;
  position: relative;
  min-height: 0;
  overflow: hidden;
}
#globe-canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.globe-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem;
  pointer-events: none;
}
.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.mini-stat {
  background: var(--bg-panel);
  padding: 0.5rem;
  text-align: center;
}
.mini-stat-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-bright);
  font-family: system-ui, sans-serif;
}
.mini-stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-family: system-ui, sans-serif;
}
.mini-stat-bar {
  height: 3px;
  background: var(--border);
  margin-top: 0.3rem;
  border-radius: 2px;
  overflow: hidden;
}
.mini-stat-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* CENTER: Event Panel */
.center-panel {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 1.5rem 2rem;
}
.event-panel, .report-panel { max-width: 640px; width: 100%; margin: 0 auto; }

.event-era {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--gold-dim);
  font-family: system-ui, sans-serif;
  margin-bottom: 0.5rem;
}
.event-title {
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--text-bright);
  margin-bottom: 0.75rem;
  line-height: 1.3;
}
.event-desc {
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.65;
  margin-bottom: 1.5rem;
}
.event-options { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1.5rem; }

.option-card {
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}
.option-card:hover { border-color: var(--border-light); background: var(--bg-hover); }
.option-card.selected { border-color: var(--gold); background: var(--bg-selected); }
.option-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}
.option-category {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
  font-family: system-ui, sans-serif;
  font-weight: 600;
}
.cat-economic { background: rgba(62,201,122,0.15); color: var(--economic); }
.cat-military { background: rgba(224,82,82,0.15); color: var(--military); }
.cat-diplomatic { background: rgba(74,142,230,0.15); color: var(--diplomatic); }
.cat-cooperative { background: rgba(56,178,172,0.15); color: var(--cooperative); }
.cat-expansionist { background: rgba(224,112,48,0.15); color: var(--expansionist); }
.cat-isolationist { background: rgba(107,122,148,0.15); color: var(--isolationist); }
.cat-reformist { background: rgba(168,85,247,0.15); color: var(--reformist); }
.cat-industrial { background: rgba(212,168,67,0.15); color: var(--industrial); }
.cat-institutional { background: rgba(96,165,250,0.15); color: var(--institutional); }

.option-label {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-bright);
}
.option-desc {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
  line-height: 1.4;
}
.option-effects { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.effect-chip {
  font-size: 0.68rem;
  padding: 0.1rem 0.35rem;
  border-radius: 2px;
  font-family: system-ui, sans-serif;
  font-weight: 500;
}
.effect-chip.pos { background: rgba(62,201,122,0.12); color: var(--positive); }
.effect-chip.neg { background: rgba(224,82,82,0.12); color: var(--negative); }
.effect-chip.neutral { background: rgba(212,168,67,0.12); color: var(--warning); }

.btn-enact { width: 100%; padding: 0.8rem; font-size: 1rem; }

/* REPORT */
.report-panel.hidden { display: none; }
.report-title {
  font-size: 1.2rem;
  color: var(--gold);
  margin-bottom: 1rem;
  font-weight: 400;
}
.report-section { margin-bottom: 1.2rem; }
.report-section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  font-family: system-ui, sans-serif;
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}
.report-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  font-size: 0.88rem;
}
.report-icon { font-size: 0.7rem; width: 1rem; text-align: center; }
.report-icon.up { color: var(--positive); }
.report-icon.down { color: var(--negative); }
.report-icon.dot { color: var(--text-dim); }

.report-reaction {
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.5rem;
  background: var(--bg-card);
  border-left: 3px solid var(--border-light);
  border-radius: 0 3px 3px 0;
  font-size: 0.85rem;
}
.report-reaction .reaction-nation { color: var(--gold); font-weight: 500; }

/* ═══════════════════════════════════════
   RIGHT: DASHBOARD
   ═══════════════════════════════════════ */
.dashboard-panel {
  border-left: 1px solid var(--border);
  background: var(--bg-panel);
  overflow-y: auto;
  padding: 1rem;
}
.panel-heading {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  font-family: system-ui, sans-serif;
  font-weight: 600;
  margin-bottom: 0.75rem;
  margin-top: 1.2rem;
}
.panel-heading:first-child { margin-top: 0; }

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
  font-size: 0.85rem;
  font-family: system-ui, sans-serif;
}
.stat-label { color: var(--text-dim); display: flex; align-items: center; gap: 0.3rem; }
.stat-label-icon { font-size: 0.75rem; }
.stat-value { font-weight: 600; color: var(--text-bright); }
.stat-bar-wrap {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 0.2rem;
  margin-bottom: 0.4rem;
}
.stat-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* Relations */
.relation-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  font-size: 0.82rem;
  font-family: system-ui, sans-serif;
}
.relation-flag { font-size: 1rem; }
.relation-name { flex: 1; color: var(--text); }
.relation-value { font-weight: 600; font-size: 0.8rem; }
.relation-value.friendly { color: var(--positive); }
.relation-value.neutral { color: var(--warning); }
.relation-value.hostile { color: var(--negative); }
.relation-bar-wrap {
  width: 60px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}
.relation-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* Norms in dashboard */
.norm-chip {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  margin: 0.15rem;
  font-size: 0.72rem;
  font-family: system-ui, sans-serif;
  border-radius: 3px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.norm-chip.unlocked { border-color: var(--gold-dim); color: var(--gold); background: rgba(212,168,67,0.08); }
.norm-empty {
  font-size: 0.82rem;
  color: var(--text-dim);
  font-style: italic;
}

/* ═══════════════════════════════════════
   MODALS
   ═══════════════════════════════════════ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  max-width: 600px;
  width: 92%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-large { max-width: 860px; }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.1rem; font-weight: 400; color: var(--gold); }
.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.2rem;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.2rem; }

/* Skill Tree */
.skill-tree-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.8rem;
}
.skill-branch {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.8rem;
}
.skill-branch-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 0.6rem;
  font-family: system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.skill-node {
  padding: 0.35rem 0.5rem;
  margin-bottom: 0.3rem;
  font-size: 0.78rem;
  font-family: system-ui, sans-serif;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
}
.skill-node.unlocked {
  border-color: var(--gold-dim);
  color: var(--gold);
  background: rgba(212,168,67,0.06);
}
.skill-node.available {
  border-color: var(--accent);
  color: var(--accent);
  cursor: pointer;
}
.skill-node.available:hover { background: rgba(74,142,230,0.1); }

/* Tier Change Modal */
.modal-tier-change, .modal-norm-unlock {
  text-align: center;
  padding: 2.5rem 2rem;
  max-width: 440px;
}
.tier-change-arrow { font-size: 2.5rem; margin-bottom: 0.5rem; }
.tier-change-title { font-size: 1.4rem; font-weight: 400; margin-bottom: 0.5rem; }
.tier-change-desc { color: var(--text-dim); margin-bottom: 1.5rem; line-height: 1.5; font-size: 0.92rem; }

.norm-unlock-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.norm-unlock-title { font-size: 1.3rem; color: var(--gold); margin-bottom: 0.3rem; }
.norm-unlock-desc { color: var(--text-dim); margin-bottom: 1.5rem; font-size: 0.9rem; line-height: 1.5; }

/* Rankings */
.ranking-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  font-family: system-ui, sans-serif;
}
.ranking-row.player { color: var(--gold); }
.ranking-rank { width: 1.5rem; text-align: right; color: var(--text-dim); font-size: 0.8rem; }
.ranking-flag { font-size: 1rem; }
.ranking-name { flex: 1; }
.ranking-score { color: var(--text-dim); font-size: 0.8rem; }

/* ═══════════════════════════════════════
   SCROLLBARS
   ═══════════════════════════════════════ */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */
@media (max-width: 960px) {
  .game-layout { grid-template-columns: 1fr; }
  .globe-panel { display: none; }
  .dashboard-panel { border-left: none; border-top: 1px solid var(--border); max-height: 200px; }
}
