:root {
  color-scheme: dark;
  --bg: #0d1210;
  --panel: #141a16;
  --panel-2: #1b2320;
  --line: #2d3a30;
  --text: #eef5ef;
  --muted: #8fa48f;
  --green: #79d48b;
  --amber: #e0b760;
  --red: #e66f6a;
  --blue: #75b8e8;
  --ink: #0c0f0e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

h1, h2, h3, p {
  margin-top: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

h3 {
  margin-bottom: 10px;
  font-size: 0.82rem;
}

/* ─── Runtime warning ─────────────────────────────────────── */

.runtime-warning {
  padding: 14px 18px;
  background: #3b1c1c;
  border-bottom: 1px solid var(--red);
  color: #fff0f0;
  font-weight: 700;
}

.runtime-warning code {
  color: #ffffff;
}

/* ─── Modal overlay ───────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 10, 0.88);
  backdrop-filter: blur(8px);
}

.modal-overlay.hidden {
  display: none;
}

.modal-inner {
  max-width: 560px;
  width: calc(100% - 48px);
  padding: 40px;
  background: #131d15;
  border: 1px solid rgba(230, 111, 106, 0.55);
  border-radius: 12px;
  box-shadow: 0 0 80px rgba(230, 111, 106, 0.14), 0 24px 60px rgba(0, 0, 0, 0.7);
  animation: modal-in 0.22s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.modal-stamp {
  margin: 0 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--red);
}

.modal-title {
  margin-bottom: 14px;
  font-size: 1.65rem;
  line-height: 1.2;
  color: var(--text);
}

.modal-body {
  margin-bottom: 28px;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.97rem;
}

.modal-options {
  display: grid;
  gap: 10px;
}

/* ─── App wrapper ─────────────────────────────────────────── */

.app {
  width: min(1560px, 100%);
  margin: 0 auto;
  padding: 0 24px 24px;
}

/* ─── Sticky header ───────────────────────────────────────── */

.sticky-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding-top: 20px;
  padding-bottom: 14px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

/* ─── Topbar ──────────────────────────────────────────────── */

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-size: 0.75rem;
  color: var(--muted);
}

h1 {
  margin-bottom: 16px;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.95;
  letter-spacing: -0.01em;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.turn-card {
  display: grid;
  gap: 4px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: right;
  white-space: nowrap;
}

.turn-card span {
  font-size: 0.88rem;
  color: var(--muted);
}

.turn-card strong {
  font-size: 0.95rem;
}

.advance-btn {
  min-width: 150px;
  min-height: 52px;
  padding: 12px 22px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: var(--ink);
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.02em;
  transition: opacity 0.15s;
}

.advance-btn:hover:not(:disabled) {
  opacity: 0.88;
}

.advance-btn:disabled {
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
  opacity: 1;
}

/* ─── Dashboard metric strip ──────────────────────────────── */

.dashboard {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.metric {
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.metric-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 6px;
}

.metric strong {
  display: block;
  font-size: clamp(1.5rem, 2.5vw, 2.1rem);
  line-height: 1;
  margin-bottom: 6px;
}

.metric-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.metric-footer small {
  font-size: 0.72rem;
  color: var(--muted);
}

.metric-delta {
  font-size: 0.78rem;
  font-weight: 700;
}

.metric-delta.delta-up   { color: var(--green); }
.metric-delta.delta-down { color: var(--red); }
.metric-delta.delta-flat { color: var(--muted); }

/* Metric status classes */
.metric.status-good {
  border-color: rgba(121, 212, 139, 0.4);
}

.metric.status-warn {
  border-color: rgba(224, 183, 96, 0.5);
}

.metric.status-danger {
  border-color: rgba(230, 111, 106, 0.6);
  animation: metric-pulse 2s ease-in-out infinite;
}

@keyframes metric-pulse {
  0%, 100% { border-color: rgba(230, 111, 106, 0.4); box-shadow: none; }
  50%       { border-color: rgba(230, 111, 106, 0.9); box-shadow: 0 0 14px rgba(230, 111, 106, 0.2); }
}

/* ─── Three-column layout ─────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(460px, 1.3fr) minmax(260px, 0.75fr);
  gap: 16px;
  align-items: start;
  margin-top: 18px;
}

.left-column,
.center-column,
.right-column {
  display: grid;
  gap: 16px;
}

/* ─── Panel base ──────────────────────────────────────────── */

.panel {
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.subtle {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
  margin-bottom: 14px;
}

.status-badge {
  font-size: 0.75rem;
  padding: 3px 9px;
  border-radius: 4px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

/* ─── Budget panel ────────────────────────────────────────── */

.budget-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0 0;
}

.budget-col-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.revenue-col-title  { color: var(--blue); }
.spending-col-title { color: var(--amber); }

.slider-stack {
  display: grid;
  gap: 8px;
}

.policy-slider {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.policy-slider span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.88rem;
  color: #d4e0d4;
}

.policy-slider b {
  color: var(--blue);
  white-space: nowrap;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--green);
}

.budget-col-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.85rem;
}

.budget-col-total span   { color: var(--muted); }
.budget-col-total strong { font-size: 1rem; }

/* ─── Fixed cost rows ─────────────────────────────────────── */

.fixed-costs {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.fixed-cost-row {
  padding: 9px 14px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px dashed var(--line);
  border-radius: 6px;
}

.fixed-cost-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.fixed-cost-value {
  font-weight: 700;
  color: var(--amber);
  white-space: nowrap;
}

.fixed-cost-note {
  margin: 4px 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.75;
}

/* Balance bar */
.balance-section {
  margin: 14px 0;
}

.balance-track {
  position: relative;
  height: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.balance-bar {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 5px;
  transition: left 0.35s ease, width 0.35s ease, background 0.35s;
}

.balance-centre-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: rgba(238, 245, 239, 0.25);
  transform: translateX(-50%);
}

.balance-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--muted);
}

.balance-value {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text);
}

.budget-secondary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.secondary-stat {
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.secondary-stat span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.secondary-stat strong {
  font-size: 1.05rem;
}

/* ─── Department bars ─────────────────────────────────────── */

.stack-list {
  display: grid;
  gap: 8px;
}

.dept-item {
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.dept-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.dept-item-head strong {
  font-size: 0.9rem;
}

.dept-backlog {
  font-size: 0.75rem;
  color: var(--muted);
}

.dept-backlog.backlog-high { color: var(--red); }
.dept-backlog.backlog-med  { color: var(--amber); }

.dept-bar-wrap {
  height: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.dept-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease, background-color 0.4s;
}

.dept-bar-fill.bar-good    { background: var(--green); }
.dept-bar-fill.bar-warn    { background: var(--amber); }
.dept-bar-fill.bar-danger  { background: var(--red); }

.dept-condition-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.73rem;
  color: var(--muted);
}

.condition-status.good   { color: var(--green); }
.condition-status.warn   { color: var(--amber); }
.condition-status.danger { color: var(--red); }

/* ─── Voter bars ──────────────────────────────────────────── */

.voter-item {
  padding: 10px 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.voter-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 7px;
}

.voter-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.voter-approval {
  font-size: 0.78rem;
  font-weight: 700;
}

.voter-approval.low  { color: var(--red); }
.voter-approval.mid  { color: var(--amber); }
.voter-approval.high { color: var(--green); }

.voter-bar-wrap {
  height: 6px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 5px;
}

.voter-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease, background-color 0.4s;
}

.voter-bar-fill.approval-low    { background: var(--red); }
.voter-bar-fill.approval-mid    { background: var(--amber); }
.voter-bar-fill.approval-high   { background: var(--green); }

.voter-meta {
  font-size: 0.72rem;
  color: var(--muted);
}

/* ─── Mandate list ────────────────────────────────────────── */

.mandate-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.mandate-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color 0.3s;
}

.mandate-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 50%;
  border: 2px solid var(--line);
  position: relative;
  transition: background 0.3s, border-color 0.3s;
}

.mandate-item.passed .mandate-icon {
  background: var(--green);
  border-color: var(--green);
}

.mandate-item.passed .mandate-icon::after {
  content: '';
  position: absolute;
  top: 2px; left: 4px;
  width: 6px; height: 4px;
  border-left: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: rotate(-45deg);
}

.mandate-item.failed .mandate-icon {
  border-color: rgba(230, 111, 106, 0.6);
}

.mandate-item.passed { border-color: rgba(121, 212, 139, 0.3); }
.mandate-item.failed { border-color: rgba(230, 111, 106, 0.25); }

.mandate-text strong {
  display: block;
  font-size: 0.88rem;
  margin-bottom: 2px;
}

.mandate-text span {
  font-size: 0.75rem;
  color: var(--muted);
}

.mandate-text small {
  display: block;
  font-size: 0.72rem;
  color: #6a8a6a;
  margin-top: 2px;
  font-style: italic;
}

/* ─── Policies ────────────────────────────────────────────── */

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 12px;
}

.tab {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.88rem;
  transition: border-color 0.15s, color 0.15s;
}

.tab:hover { color: var(--text); }

.tab.active {
  border-color: var(--green);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(121, 212, 139, 0.3);
}

.policy-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.policy-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color 0.2s;
}

.policy-card.enacted {
  border-color: rgba(121, 212, 139, 0.5);
}

.policy-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.policy-card-head strong {
  font-size: 0.9rem;
  line-height: 1.3;
}

.policy-card-head span {
  font-size: 0.78rem;
  color: var(--amber);
  white-space: nowrap;
}

.policy-card p {
  margin: 0;
  font-size: 0.82rem;
  color: #c8d8c8;
  line-height: 1.45;
  flex: 1;
}

.policy-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--muted);
}

.policy-card button {
  width: 100%;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--green);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.85rem;
  transition: opacity 0.15s;
}

.policy-card button:hover:not(:disabled) {
  opacity: 0.85;
}

.policy-card button:disabled {
  background: var(--panel);
  color: var(--muted);
  border-color: var(--line);
  cursor: not-allowed;
  opacity: 1;
}

.policy-card.enacted button {
  background: transparent;
  color: var(--green);
  border-color: rgba(121, 212, 139, 0.4);
}

/* ─── Dilemma choice buttons ──────────────────────────────── */

.choice {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 14px 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.choice:hover {
  border-color: rgba(230, 111, 106, 0.7);
  background: rgba(230, 111, 106, 0.06);
}

.choice strong {
  font-size: 0.95rem;
}

.choice span {
  font-size: 0.82rem;
  color: var(--muted);
}

/* ─── Briefing log ────────────────────────────────────────── */

.log-panel {
  display: flex;
  flex-direction: column;
}

.brief-note {
  margin-bottom: 12px;
}

.event-log {
  display: grid;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.event {
  padding: 12px 14px;
  background: var(--panel-2);
  border-left: 3px solid var(--blue);
  border-radius: 0 6px 6px 0;
  line-height: 1.45;
}

.event.warning { border-left-color: var(--amber); }
.event.danger  { border-left-color: var(--red); background: rgba(230, 111, 106, 0.05); }
.event.good    { border-left-color: var(--green); }

.event strong {
  display: block;
  font-size: 0.88rem;
  margin-bottom: 4px;
}

.event-body {
  font-size: 0.82rem;
  color: #c0d0c0;
}

.event-turn {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 5px;
}

/* ─── Save actions ────────────────────────────────────────── */

.save-actions {
  display: flex;
  gap: 6px;
}

.save-actions button {
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.82rem;
  transition: color 0.15s, border-color 0.15s;
}

.save-actions button:hover {
  color: var(--text);
  border-color: var(--muted);
}

/* ─── Chart section ───────────────────────────────────────── */

.chart-section {
  margin-top: 16px;
}

.chart-section h2 {
  margin-bottom: 14px;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #111614;
  border: 1px solid var(--line);
  border-radius: 8px;
}

/* ─── Footer ──────────────────────────────────────────────── */

.notes {
  padding: 16px 0 4px;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ─── Responsive ──────────────────────────────────────────── */

@media (max-width: 1300px) {
  .dashboard {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .left-column,
  .right-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .app {
    padding: 0 14px 20px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .topbar-controls {
    width: 100%;
    justify-content: space-between;
    margin-bottom: 0;
  }

  .advance-btn {
    flex: 1;
  }

  .dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .budget-split {
    grid-template-columns: 1fr;
  }

  .tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .policy-list {
    grid-template-columns: 1fr;
  }

  .left-column,
  .right-column {
    grid-template-columns: 1fr;
  }
}

/* ─── Newspaper intro modal ─────────────────────────────── */

.intro-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.intro-overlay.hidden {
  display: none;
}

.newspaper {
  background: #f5f0e8;
  color: #1a1a1a;
  max-width: 580px;
  width: 92%;
  padding: 2rem 2.5rem 1.75rem;
  border: 2px solid #1a1a1a;
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.6);
}

.newspaper-header {
  margin-bottom: 0.75rem;
}

.newspaper-rule {
  border: none;
  border-top: 1px solid #1a1a1a;
  margin: 0.3rem 0;
}

.newspaper-rule.thick {
  border-top-width: 3px;
}

.newspaper-masthead {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  font-weight: bold;
  text-align: center;
  letter-spacing: 0.04em;
  margin: 0.4rem 0;
}

.newspaper-edition {
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0.2rem 0;
}

.newspaper-headline {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.65rem;
  font-weight: bold;
  line-height: 1.15;
  text-align: center;
  margin: 0.75rem 0 0.5rem;
}

.newspaper-subhead {
  font-style: italic;
  text-align: center;
  font-size: 0.88rem;
  border-top: 1px solid #1a1a1a;
  border-bottom: 1px solid #1a1a1a;
  padding: 0.4rem 0;
  margin-bottom: 1rem;
}

.newspaper-body {
  columns: 2;
  column-gap: 1.5rem;
  font-size: 0.84rem;
  line-height: 1.55;
  font-family: Georgia, "Times New Roman", serif;
}

.newspaper-body p {
  margin: 0 0 0.75rem;
  break-inside: avoid;
}

.take-office-btn {
  display: block;
  width: 100%;
  margin-top: 1.5rem;
  padding: 0.75rem;
  background: #1a1a1a;
  color: #f5f0e8;
  border: none;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  font-family: system-ui, sans-serif;
  font-weight: 600;
  transition: background 0.15s;
}

.take-office-btn:hover {
  background: #333;
}

/* ─── Slider effect tags ─────────────────────────────────── */

.slider-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}

.effect-tag {
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 3px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.6;
}

.effect-tag.positive {
  background: rgba(121, 212, 139, 0.15);
  color: #79d48b;
}

.effect-tag.negative {
  background: rgba(230, 111, 106, 0.15);
  color: #e66f6a;
}

/* ─── World outcome log entries ─────────────────────────── */

.event.world {
  border-left-color: #4a9fa5;
  background: rgba(74, 159, 165, 0.07);
}

.event.world .event-body {
  color: #a8c8cc;
}
