:root {
  color-scheme: dark;
  --ink: #e8e2d3;
  --muted: #9ca69f;
  --dim: #68746f;
  --ground: #0b1212;
  --panel: rgba(19, 29, 28, 0.92);
  --panel-high: #182422;
  --line: rgba(231, 221, 194, 0.12);
  --line-strong: rgba(231, 221, 194, 0.22);
  --copper: #dd7f48;
  --gold: #d2ad54;
  --teal: #62a6a0;
  --danger: #d66c5d;
  --good: #79aa78;
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--ground);
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% -10%, rgba(85, 119, 102, 0.18), transparent 34rem),
    radial-gradient(circle at 90% 0%, rgba(156, 92, 51, 0.11), transparent 30rem),
    var(--ground);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

.paper-noise {
  position: fixed;
  z-index: 100;
  inset: 0;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
}

.masthead,
.dashboard,
footer {
  width: min(1540px, calc(100% - 48px));
  margin-inline: auto;
}

.masthead {
  display: flex;
  align-items: end;
  justify-content: space-between;
  min-height: 154px;
  padding: 38px 0 26px;
  border-bottom: 1px solid var(--line-strong);
}

.eyebrow,
.kicker {
  margin: 0 0 5px;
  color: var(--copper);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

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

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(46px, 6vw, 78px);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 0.86;
}

h2 {
  margin-bottom: 0;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 400;
  letter-spacing: -0.02em;
}

h3 {
  margin-bottom: 3px;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 400;
}

.world-clock {
  display: grid;
  justify-items: end;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
}

.world-clock strong {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 400;
}

.live-mark {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--good);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.live-mark i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 4px rgba(121, 170, 120, 0.12);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  50% { box-shadow: 0 0 0 7px rgba(121, 170, 120, 0); }
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 20px;
  padding: 22px 0 42px;
}

.atlas-column,
.dispatch-column {
  display: grid;
  align-content: start;
  gap: 20px;
  min-width: 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: rgba(15, 23, 22, 0.68);
}

.metric {
  position: relative;
  min-width: 0;
  padding: 14px 17px 16px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric span {
  display: block;
  overflow: hidden;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.metric strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(20px, 2.1vw, 30px);
  font-weight: 400;
  letter-spacing: -0.03em;
  text-overflow: ellipsis;
}

.metric em {
  position: absolute;
  top: 14px;
  right: 14px;
  color: var(--teal);
  font-family: var(--mono);
  font-size: 9px;
  font-style: normal;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(25, 37, 35, 0.94), rgba(15, 23, 22, 0.94));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.13);
}

.panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  min-height: 74px;
  padding: 16px 19px;
  border-bottom: 1px solid var(--line);
}

.atlas-heading {
  gap: 24px;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px 13px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.map-legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.swatch {
  width: 8px;
  height: 8px;
  border-radius: 1px;
}

.swatch.plains { background: #4f6952; }
.swatch.forest { background: #263f36; }
.swatch.hills { background: #6a6554; }
.swatch.desert { background: #87714b; }

.map-stage {
  position: relative;
  height: clamp(480px, 62vh, 690px);
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 44%, rgba(67, 101, 95, 0.11), transparent 60%),
    #0c1719;
}

#world-map,
#history-chart {
  display: block;
  width: 100%;
  height: 100%;
}

#world-map {
  cursor: crosshair;
}

.map-hint {
  position: absolute;
  right: 14px;
  bottom: 9px;
  margin: 0;
  color: rgba(232, 226, 211, 0.42);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  pointer-events: none;
  text-transform: uppercase;
}

.map-tooltip {
  position: absolute;
  z-index: 2;
  min-width: 130px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  background: rgba(9, 15, 15, 0.94);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  pointer-events: none;
}

.map-tooltip strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 400;
}

.history-panel {
  height: 230px;
}

.history-panel .panel-heading {
  min-height: 70px;
}

#history-chart {
  height: 159px;
}

.quiet {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
}

.inspector-panel {
  min-height: 282px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 282px;
  padding: 40px;
  text-align: center;
}

.empty-state .compass {
  color: var(--gold);
  font-size: 25px;
}

.empty-state h2 {
  margin: 8px 0 5px;
}

.empty-state p {
  max-width: 240px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.inspector-head {
  padding: 18px 19px 15px;
  border-bottom: 1px solid var(--line);
}

.inspector-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.inspector-title p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.nation-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
}

.nation-chip i,
.nation-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.capital-badge {
  padding: 4px 7px;
  border: 1px solid rgba(210, 173, 84, 0.35);
  color: var(--gold);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.inspector-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}

.mini-stat {
  padding: 11px 12px;
  border-right: 1px solid var(--line);
}

.mini-stat:last-child {
  border-right: 0;
}

.mini-stat span,
.market-row span {
  display: block;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mini-stat strong {
  display: block;
  margin-top: 2px;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 400;
}

.market-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  padding: 1px;
  background: var(--line);
}

.market-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  padding: 10px 12px;
  background: var(--panel-high);
}

.market-row strong {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
}

.market-row small {
  color: var(--muted);
  font-size: 10px;
}

.health-bars {
  display: grid;
  gap: 8px;
  padding: 12px 14px 15px;
}

.bar-row {
  display: grid;
  grid-template-columns: 78px 1fr 35px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
}

.bar-track {
  height: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.07);
}

.bar-track i {
  display: block;
  height: 100%;
  background: var(--teal);
}

.nation-list {
  display: grid;
}

.nation-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 14px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
}

.nation-row:last-child {
  border-bottom: 0;
}

.nation-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-family: var(--serif);
  font-size: 15px;
}

.nation-row strong {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
}

.nation-row small {
  grid-column: 1 / -1;
  color: var(--dim);
  font-size: 9px;
}

.event-list {
  max-height: 520px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  scrollbar-color: var(--line-strong) transparent;
}

.event-item {
  position: relative;
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 11px;
  padding: 14px 15px;
  border-bottom: 1px solid var(--line);
  cursor: default;
}

.event-item[data-settlement] {
  cursor: pointer;
}

.event-item:hover {
  background: rgba(255, 255, 255, 0.018);
}

.event-year {
  padding-top: 2px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
}

.event-copy strong {
  display: block;
  margin-bottom: 3px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.25;
}

.event-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.event-item::before {
  position: absolute;
  top: 18px;
  left: 8px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--dim);
  content: "";
}

.event-item.danger::before { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.event-item.good::before { background: var(--good); }

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 0 32px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

  .map-legend {
    display: none;
  }
}

@media (max-width: 820px) {
  .masthead,
  .dashboard,
  footer {
    width: min(100% - 28px, 680px);
  }

  .masthead {
    min-height: 125px;
    padding-top: 28px;
  }

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

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

  .inspector-panel,
  .chronicle-panel {
    grid-column: 1 / -1;
  }

  .nations-panel {
    grid-column: 1 / -1;
  }

  .map-stage {
    height: min(68vw, 520px);
    min-height: 360px;
  }
}

@media (max-width: 560px) {
  .masthead {
    align-items: start;
  }

  .world-clock {
    margin-top: 4px;
  }

  .world-clock > span:last-child {
    display: none;
  }

  .world-clock strong {
    font-size: 17px;
  }

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

  .metric:nth-child(2) {
    border-right: 0;
  }

  .metric:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .atlas-heading {
    min-height: 66px;
  }

  .map-stage {
    min-height: 330px;
  }

  footer {
    display: grid;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
