/* ===== Reset / base ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, sans-serif;
  background:
    radial-gradient(1200px 600px at 20% -10%, #15284a 0%, transparent 60%),
    radial-gradient(900px 500px at 95% 10%, #2b1b3d 0%, transparent 55%),
    #0b1020;
  color: #e6ecff;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.45;
}

code { font-family: "JetBrains Mono", "Fira Code", Menlo, monospace; font-size: 0.92em; }
button { font: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; }

/* ===== Top bar ===== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid #1f2a4a;
  background: rgba(10, 14, 30, 0.7);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 {
  font-size: 18px;
  letter-spacing: 0.02em;
  font-weight: 650;
}
.coin {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #f6c86a, #b8782b);
  color: #1a1406;
  border-radius: 50%;
  font-weight: 800;
  box-shadow: 0 2px 0 #6e4610, 0 0 0 2px rgba(246,200,106,0.15);
}
.subtitle { color: #8ea0c9; font-size: 12px; margin-left: 4px; }

.topbar-right { display: flex; gap: 8px; }

button.primary {
  background: linear-gradient(180deg, #4c7dff, #2d59df);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  box-shadow: 0 2px 0 #1a38a1, 0 8px 24px rgba(76,125,255,0.25);
  transition: transform 0.05s;
}
button.primary:hover { filter: brightness(1.1); }
button.primary:active { transform: translateY(1px); }
button.primary:disabled { opacity: 0.4; cursor: not-allowed; }

button.ghost {
  background: transparent;
  color: #c0cdf0;
  border: 1px solid #2d3c68;
  padding: 8px 14px;
  border-radius: 8px;
}
button.ghost:hover { background: #182448; color: white; }

/* ===== Layout ===== */
.layout {
  display: grid;
  grid-template-columns: 300px 1fr 320px;
  gap: 18px;
  padding: 18px;
  max-width: 1600px;
  margin: 0 auto;
}
@media (max-width: 1200px) {
  .layout { grid-template-columns: 1fr; }
}

.sidebar, .controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.main {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ===== Panels ===== */
.panel {
  background: linear-gradient(180deg, rgba(22,30,58,0.9), rgba(16,22,44,0.9));
  border: 1px solid #263358;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.03) inset, 0 12px 24px rgba(0,0,0,0.25);
}
.panel h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8ea0c9;
  margin-bottom: 10px;
  font-weight: 600;
}
.panel-hint { color: #9fb0d8; font-size: 12.5px; margin: 0 0 10px 0; }

/* ===== Scenarios ===== */
.scenarios {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.scenario-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #131b36;
  border: 1px solid #2a3863;
  border-radius: 8px;
  padding: 10px 12px;
  color: #dbe5ff;
  text-align: left;
  transition: all 0.15s;
}
.scenario-btn:hover { border-color: #4c7dff; background: #182448; }
.scenario-btn.active {
  background: linear-gradient(90deg, #1f3b86, #1b2a5a);
  border-color: #4c7dff;
  box-shadow: 0 0 0 1px #4c7dff inset;
}
.scenario-btn .tag {
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #2a3863;
  color: #cadcff;
}

.scenario-brief {
  margin-top: 12px;
  padding: 12px;
  background: #0d142a;
  border-radius: 8px;
  border: 1px dashed #2d3c68;
  font-size: 13px;
  color: #c6d2ef;
}
.scenario-brief .brief-title { font-weight: 600; color: #fff; margin-bottom: 6px; }

/* ===== Objectives ===== */
.objectives { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.objectives li {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 10px;
  background: #0e1530;
  border: 1px solid #233054;
  border-radius: 6px;
  font-size: 13px;
}
.objectives li.done { border-color: #3b9c6d; background: #123a29; color: #bce9d3; }
.objectives li.failed { border-color: #a04040; background: #3a1919; color: #f1c0c0; }
.obj-icon { min-width: 16px; margin-top: 1px; }

/* ===== Events ===== */
.event-log { max-height: 260px; display: flex; flex-direction: column; }
.events {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}
.event {
  padding: 8px 10px;
  background: #0e1530;
  border-left: 3px solid #4c7dff;
  border-radius: 4px;
  font-size: 12.5px;
  color: #d6deef;
}
.event.good { border-color: #3b9c6d; }
.event.bad  { border-color: #d06060; }
.event.warn { border-color: #e0a64c; }
.event .tstamp { color: #7a8ab0; font-size: 11px; margin-right: 6px; }

/* ===== KPIs ===== */
.kpis {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}
@media (max-width: 960px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
.kpi {
  background: linear-gradient(180deg, rgba(22,30,58,0.9), rgba(16,22,44,0.9));
  border: 1px solid #263358;
  border-radius: 10px;
  padding: 10px 12px;
}
.kpi-label { color: #8ea0c9; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-value { font-size: 22px; font-weight: 700; margin-top: 3px; color: #fff; font-variant-numeric: tabular-nums; }
.kpi-value.up { color: #e58a8a; }
.kpi-value.down { color: #8ae5b5; }

/* ===== Charts ===== */
.charts { display: flex; flex-direction: column; gap: 14px; }
.chart-card {
  background: linear-gradient(180deg, rgba(22,30,58,0.9), rgba(16,22,44,0.9));
  border: 1px solid #263358;
  border-radius: 12px;
  padding: 12px 14px;
}
.chart-title {
  font-size: 13px;
  color: #dbe5ff;
  font-weight: 600;
  margin-bottom: 6px;
}
.chart-title .muted { color: #8ea0c9; font-weight: 400; margin-left: 6px; font-size: 12px; }
svg { width: 100%; height: auto; display: block; }
.legend {
  font-size: 12px;
  color: #a4b4db;
  margin-top: 6px;
  display: flex; gap: 18px; flex-wrap: wrap;
}
.dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 6px;
}
.dot-pg { background: #f6c86a; }
.dot-pf { background: #4c7dff; }
.dot-y  { background: #8ae5b5; }
.dot-c  { background: #c594f5; }
.dot-sg { background: #f58aa6; }

/* ===== Policy controls ===== */
.lever { margin-bottom: 14px; }
.lever label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: #dbe5ff;
  margin-bottom: 5px;
  font-weight: 600;
}
.lever-row { display: flex; align-items: center; gap: 10px; }
.lever-val {
  min-width: 42px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #fff;
  font-weight: 700;
}
.lever-hint { color: #8ea0c9; font-size: 11.5px; margin-top: 3px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #1b274b;
  border-radius: 999px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  background: linear-gradient(180deg, #6d98ff, #3057d5);
  border: 2px solid #9fbaff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(76,125,255,0.5);
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  background: #4c7dff;
  border: 2px solid #9fbaff;
  border-radius: 50%;
  cursor: pointer;
}

.state-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.state-table td { padding: 6px 0; border-bottom: 1px solid #1c2748; color: #cad3ed; }
.state-table tr:last-child td { border-bottom: none; }
.state-table td:last-child { text-align: right; font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; }
.state-pos { color: #8ae5b5 !important; }
.state-neg { color: #e58a8a !important; }

.advance {
  display: flex;
  justify-content: stretch;
}
.advance button { width: 100%; padding: 14px; font-size: 15px; }

/* ===== End banner ===== */
.end-banner {
  padding: 16px;
  border-radius: 12px;
  font-size: 15px;
  text-align: center;
  border: 1px solid #2a3863;
  background: #0e1530;
}
.end-banner.win { border-color: #3b9c6d; background: linear-gradient(90deg, #123a29, #174a34); }
.end-banner.lose { border-color: #a04040; background: linear-gradient(90deg, #3a1919, #4a1e1e); }
.end-banner .end-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.end-banner button { margin-top: 10px; }

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  z-index: 100;
}
.modal-inner {
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
  background: #121a36;
  border: 1px solid #2d3c68;
  border-radius: 14px;
  padding: 28px;
  position: relative;
  box-shadow: 0 20px 80px rgba(0,0,0,0.6);
}
.modal-inner h2 { margin-bottom: 10px; }
.modal-inner h3 { margin: 18px 0 6px; color: #cadcff; font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; }
.modal-inner ul { padding-left: 18px; }
.modal-inner li { margin-bottom: 6px; color: #d2dbf5; }
.modal-close {
  position: absolute;
  top: 10px; right: 10px;
  background: transparent; border: none;
  color: #9fb0d8;
  font-size: 26px;
  line-height: 1;
  padding: 4px 10px;
  border-radius: 6px;
}
.modal-close:hover { background: #22305a; color: white; }
.muted { color: #8ea0c9; }
.tiny { font-size: 11.5px; }
.hidden { display: none !important; }

/* ===== Gazette ===== */
.gazette { display: flex; flex-direction: column; gap: 10px; }
.gazette-headline {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  color: #fff;
  padding: 10px 12px;
  background: #0d1428;
  border-radius: 8px;
  border-left: 4px solid #4c7dff;
  min-height: 56px;
  transition: border-color 0.4s, background 0.4s;
}
.gazette-headline.regime-overhang  { border-color: #f6a84c; background: #1a0e00; }
.gazette-headline.regime-deflation { border-color: #e05050; background: #1a0808; }
.gazette-headline.regime-anchored  { border-color: #3b9c6d; background: #071a11; }
.gazette-headline.regime-crisis    { border-color: #ff3b3b; background: #300; animation: pulse-crisis 0.6s infinite; }

@keyframes pulse-crisis {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,60,60,0); }
  50%      { box-shadow: 0 0 0 8px rgba(255,60,60,0.35); }
}

.gazette-quote {
  margin: 0;
  padding: 8px 12px;
  background: #0f1730;
  border-left: 3px solid #3a4a80;
  border-radius: 4px;
  font-style: italic;
  font-size: 12.5px;
  color: #c0cde8;
}
.gazette-history summary {
  cursor: pointer;
  color: #8ea0c9;
  font-size: 12px;
  padding: 4px 0;
}

/* ===== Bars row ===== */
.bars-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 10px;
}
.bar-card {
  background: linear-gradient(180deg, rgba(22,30,58,0.9), rgba(16,22,44,0.9));
  border: 1px solid #263358;
  border-radius: 10px;
  padding: 10px 12px;
}
.bar-label {
  font-size: 11px;
  color: #8ea0c9;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.bar-label span { color: #fff; font-weight: 700; }
.bar-track {
  height: 8px;
  background: #1b274b;
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(.4,0,.2,1);
}
.tension-fill { background: linear-gradient(90deg, #e05050, #ff0000); }
.happy-fill   { background: linear-gradient(90deg, #3b9c6d, #7ee8b5); }
.score-fill   { background: linear-gradient(90deg, #4c7dff, #9fc3ff); }

/* ===== Regime badge ===== */
.regime-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: #263358;
  color: #c0cde8;
  transition: background 0.3s, color 0.3s;
}
.regime-badge.anchored  { background: #1a4030; color: #7ee8b5; }
.regime-badge.overhang  { background: #3d2200; color: #ffc566; }
.regime-badge.deflation { background: #3a1010; color: #ff9999; }
.regime-badge.crisis    { background: #5a0000; color: #ff4444; animation: pulse-crisis 0.5s infinite; }

/* ===== KPI pulse animation ===== */
@keyframes kpi-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.kpi-value.pop { animation: kpi-pop 0.35s ease-out; }

/* ===== Achievement toast ===== */
.toast-area {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}
.toast {
  background: linear-gradient(135deg, #1f3b86, #2e5adb);
  color: white;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 32px rgba(76,125,255,0.4);
  animation: toast-in 0.4s ease-out, toast-out 0.4s ease-in 3.6s forwards;
  border: 1px solid #4c7dff;
}
@keyframes toast-in  { from { transform: translateX(120px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to   { transform: translateX(120px); opacity: 0; } }

/* ===== Score display on end banner ===== */
.end-grade {
  font-size: 64px;
  font-weight: 900;
  line-height: 1;
  margin: 8px 0;
  font-variant-numeric: tabular-nums;
}
.end-grade.A { color: #7ee8b5; }
.end-grade.B { color: #a0c8ff; }
.end-grade.C { color: #ffc566; }
.end-grade.D { color: #ff9999; }
.end-grade.F { color: #ff4444; }

/* ===== Tooltips ===== */
.tooltip {
  position: fixed;
  max-width: 280px;
  background: #1a2448;
  border: 1px solid #3d5494;
  color: #d8e4ff;
  font-size: 12.5px;
  line-height: 1.55;
  padding: 9px 13px;
  border-radius: 9px;
  z-index: 500;
  pointer-events: none;
  box-shadow: 0 10px 32px rgba(0,0,0,0.55), 0 1px 0 rgba(255,255,255,0.05) inset;
}
[data-tip], .tip-wrap, .tip-cell {
  cursor: help;
  text-decoration: underline dotted rgba(160,185,255,0.45);
  text-underline-offset: 3px;
}
/* Don't underline whole containers — only explicit text-bearing tip elements */
.kpi[data-tip],
.lever[data-tip],
.bar-card[data-tip] {
  text-decoration: none;
}
.kpi[data-tip] .kpi-label,
.lever[data-tip] label {
  text-decoration: underline dotted rgba(160,185,255,0.45);
  text-underline-offset: 3px;
}
