:root {
  --ink: #201e1a;
  --ink-soft: #3f3a33;
  --muted: #716a60;
  --paper: #f4efe4;
  --paper-deep: #e9e0d1;
  --card: rgba(255, 252, 245, 0.94);
  --line: rgba(48, 42, 34, 0.2);
  --line-strong: rgba(48, 42, 34, 0.42);
  --accent: #a73c32;
  --accent-dark: #7f2c26;
  --saf: #547995;
  --rsf: #b5534e;
  --contested: #c59a3d;
  --success: #4c8061;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "DM Sans", Arial, sans-serif;
  --shadow: 0 24px 70px rgba(45, 37, 28, 0.18);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --story-panel: clamp(500px, 43vw, 620px);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
}

body {
  overflow-x: hidden;
}

button,
input,
a {
  font: inherit;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid #e4a72f;
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  transform: translateY(-150%);
  background: var(--ink);
  color: #fffaf0;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  transition: transform 180ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

#map {
  position: fixed;
  z-index: 0;
  inset: 0;
  left: var(--story-panel);
  background: #e7e1d6;
}

.map-shade {
  position: fixed;
  z-index: 1;
  inset: 0 auto 0 0;
  width: var(--story-panel);
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 28%, rgba(167, 60, 50, 0.07), transparent 34%),
    linear-gradient(180deg, rgba(32, 30, 26, 0.05), transparent 18%);
}

.paper-grain {
  position: fixed;
  z-index: 3;
  inset: 0;
  pointer-events: none;
  opacity: 0.26;
  mix-blend-mode: multiply;
  background-image:
    repeating-linear-gradient(0deg, rgba(40, 35, 29, 0.022) 0, rgba(40, 35, 29, 0.022) 1px, transparent 1px, transparent 4px),
    radial-gradient(circle at 17% 24%, rgba(167, 60, 50, 0.09), transparent 27%);
}

.masthead {
  position: fixed;
  z-index: 5;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: var(--story-panel);
  min-height: 72px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(244, 239, 228, 0.98), rgba(244, 239, 228, 0.82));
  backdrop-filter: blur(14px);
}

.masthead-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--serif);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.masthead-brand strong,
.masthead-brand small {
  display: block;
}

.masthead-brand strong {
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.masthead-brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.masthead-context {
  margin: 0;
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.masthead-context span {
  padding: 0 0.25em;
  color: var(--accent);
}

#story {
  position: relative;
  z-index: 2;
  width: var(--story-panel);
  padding: 0 34px 16vh 28px;
}

.step {
  display: flex;
  min-height: 100vh;
  scroll-margin-top: 88px;
  flex-direction: column;
  justify-content: center;
  opacity: 0.36;
  transform: translateY(12px);
  transition: opacity 500ms ease, transform 700ms var(--ease);
}

.step.active {
  opacity: 1;
  transform: translateY(0);
}

.hero {
  min-height: 100svh;
  padding: 14vh 0 10vh;
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 1.15rem;
  color: var(--accent);
  font-size: 0.71rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero-meta span + span {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.hero-meta span + span::before {
  width: 28px;
  height: 1px;
  content: "";
  background: currentColor;
}

h1,
h2 {
  margin: 0.45rem 0 1.15rem;
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: -0.038em;
  line-height: 0.98;
  text-wrap: balance;
}

h1 {
  max-width: 640px;
  font-size: clamp(3.8rem, 7vw, 6.25rem);
}

h2 {
  font-size: clamp(2.25rem, 4.1vw, 3.35rem);
  line-height: 1.02;
}

.dek {
  max-width: 590px;
  margin: 0;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: clamp(1.08rem, 1.9vw, 1.34rem);
  font-weight: 600;
  line-height: 1.5;
}

.hero-metrics {
  display: grid;
  max-width: 610px;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin-top: 2rem;
  border: 1px solid var(--line);
  background: var(--line);
}

.hero-metrics div {
  min-height: 106px;
  padding: 14px;
  background: rgba(248, 244, 235, 0.82);
}

.hero-metrics strong {
  display: block;
  color: var(--accent);
  font-family: var(--serif);
  font-size: clamp(1.8rem, 3.3vw, 2.5rem);
  line-height: 1;
}

.hero-metrics span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.35;
}

.hero-source {
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.66rem;
}

.scroll-cue {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 13px;
  min-height: 44px;
  margin-top: 2.3rem;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-decoration: none;
  text-transform: uppercase;
}

.scroll-arrow {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 1rem;
  transition: transform 250ms var(--ease), background-color 250ms ease, color 250ms ease;
}

.scroll-cue:hover .scroll-arrow {
  transform: translateY(4px);
  background: var(--accent);
  color: var(--paper);
}

.eyebrow,
.chapter {
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.card {
  position: relative;
  min-height: auto;
  margin: 66vh 0;
  padding: 30px 34px 32px;
  overflow: hidden;
  border: 1px solid rgba(45, 38, 30, 0.22);
  border-radius: 1px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(0.9);
}

.card::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  content: "";
  background: linear-gradient(90deg, var(--accent) 0 74px, rgba(167, 60, 50, 0.16) 74px 100%);
}

.card::after {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 10px;
  height: 10px;
  border-top: 1px solid var(--line-strong);
  border-right: 1px solid var(--line-strong);
  content: "";
}

.card h2 {
  max-width: 560px;
  font-size: clamp(2.2rem, 3.7vw, 3.05rem);
}

.card p,
.card li {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.card p {
  max-width: 57ch;
}

.story-copy {
  margin-bottom: 1rem;
  color: var(--ink-soft) !important;
  font-family: var(--serif);
  font-size: 1.04rem !important;
  font-weight: 600;
  line-height: 1.58 !important;
}

.data-highlight {
  padding: 0 0.12em;
  background: linear-gradient(transparent 58%, rgba(167, 60, 50, 0.2) 58%);
  color: var(--accent-dark);
  font-weight: 700;
}

.data-highlight.contested-text {
  background-image: linear-gradient(transparent 58%, rgba(197, 154, 61, 0.28) 58%);
  color: #765a17;
}

.data-highlight.return-text {
  background-image: linear-gradient(transparent 58%, rgba(76, 128, 97, 0.24) 58%);
  color: #356347;
}

.data-highlight.water-text {
  background-image: linear-gradient(transparent 58%, rgba(47, 131, 174, 0.22) 58%);
  color: #256987;
}

.card ol {
  padding-left: 1.25rem;
}

.card li {
  margin: 0.85rem 0;
  padding-left: 0.35rem;
}

.card li::marker {
  color: var(--accent);
  font-weight: 700;
}

.sources,
.caveat {
  font-size: 0.81rem !important;
}

.sources {
  display: block;
  margin-top: 1.35rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  color: var(--muted) !important;
  font-weight: 700;
  line-height: 1.45 !important;
}

.sources a {
  color: var(--accent-dark);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.map-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 1.3rem;
  padding: 12px 14px;
  border: 1px solid rgba(167, 60, 50, 0.18);
  background: rgba(167, 60, 50, 0.06);
  font-size: 0.78rem !important;
  line-height: 1.45 !important;
}

.map-note span {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 1rem;
}

.card-stat {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 14px;
  margin-top: 1.3rem;
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  background: rgba(167, 60, 50, 0.07);
}

.card-stat strong {
  color: var(--accent);
  font-family: var(--serif);
  font-size: 2.2rem;
  line-height: 1;
}

.card-stat span {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.return-stat {
  border-left-color: var(--success);
  background: rgba(76, 128, 97, 0.08);
}

.return-stat strong {
  color: var(--success);
}

.mini-chart {
  margin: 1.15rem 0 0;
  padding: 15px 16px 13px;
  border: 1px solid rgba(167, 60, 50, 0.2);
  background: rgba(255, 252, 245, 0.72);
}

.mini-chart figcaption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.mini-chart figcaption span {
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mini-chart figcaption small {
  color: var(--muted);
  font-size: 0.62rem;
}

.bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 42px;
  align-items: center;
  gap: 9px;
  min-height: 24px;
  color: var(--muted);
  font-size: 0.65rem;
}

.bar-row i {
  position: relative;
  display: block;
  height: 7px;
  overflow: hidden;
  background: rgba(167, 60, 50, 0.1);
}

.bar-row i::after {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--value);
  content: "";
  background: linear-gradient(90deg, var(--accent-dark), #c7685d);
}

.bar-row strong {
  color: var(--accent-dark);
  font-size: 0.66rem;
  text-align: right;
}

.contested-chart {
  border-color: rgba(197, 154, 61, 0.28);
}

.contested-chart .bar-row i {
  background: rgba(197, 154, 61, 0.12);
}

.contested-chart .bar-row i::after {
  background: linear-gradient(90deg, #8f6b19, var(--contested));
}

.contested-chart .bar-row strong {
  color: #765a17;
}

.split-values {
  display: flex;
  height: 62px;
  gap: 2px;
}

.split-values div {
  display: flex;
  width: var(--share);
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  padding: 10px 12px;
  background: var(--accent-dark);
  color: #fffaf0;
}

.split-values div + div {
  background: #be655b;
}

.split-values strong {
  font-family: var(--serif);
  font-size: 1.22rem;
  line-height: 1;
}

.split-values span {
  margin-top: 4px;
  overflow: hidden;
  font-size: 0.61rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.return-meaning {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  text-align: center;
}

.return-meaning div {
  min-height: 64px;
  padding: 10px;
  border: 1px solid rgba(76, 128, 97, 0.22);
  background: rgba(76, 128, 97, 0.07);
}

.return-meaning span,
.return-meaning strong {
  display: block;
}

.return-meaning span {
  color: var(--muted);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.return-meaning strong {
  margin-top: 5px;
  color: #356347;
  font-family: var(--serif);
  font-size: 1rem;
}

.return-meaning i {
  color: var(--accent);
  font-family: var(--serif);
  font-size: 1.5rem;
  font-style: normal;
  font-weight: 700;
}

.return-note {
  margin: 10px 0 0;
  color: var(--ink-soft) !important;
  font-size: 0.73rem !important;
  font-weight: 600;
  line-height: 1.45 !important;
}

.dam-sequence {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 1.1rem;
}

.dam-sequence::before {
  position: absolute;
  z-index: 0;
  top: 13px;
  right: 10%;
  left: 10%;
  height: 2px;
  content: "";
  background: #5aa1c5;
}

.dam-sequence span {
  position: relative;
  z-index: 1;
  padding-top: 28px;
  color: var(--muted);
  font-size: 0.61rem;
  font-weight: 700;
  text-align: center;
}

.dam-sequence span::before {
  position: absolute;
  top: 7px;
  left: 50%;
  width: 12px;
  height: 12px;
  transform: translateX(-50%) rotate(45deg);
  border: 2px solid #fff;
  background: #2f83ae;
  box-shadow: 0 0 0 1px #256987;
  content: "";
}

.caveat {
  margin-top: 1.7rem;
  padding: 14px 16px;
  border-left: 3px solid var(--contested);
  background: rgba(197, 154, 61, 0.09);
}

.metric-grid {
  display: grid;
  grid-template-columns: 0.82fr 1.18fr;
  gap: 1px;
  margin-top: 24px;
  background: var(--line);
  border: 1px solid var(--line);
}

.metric-grid div {
  min-height: 118px;
  padding: 18px;
  background: rgba(248, 244, 235, 0.88);
}

.metric-grid strong {
  display: block;
  color: var(--accent);
  font-family: var(--serif);
  font-size: 2.35rem;
  line-height: 1;
}

.metric-grid span {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.4;
}

footer {
  padding: 8vh 0 12vh;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.55;
}

.legend {
  position: fixed;
  z-index: 6;
  top: 16px;
  right: 16px;
  width: 210px;
  overflow: hidden;
  border: 1px solid rgba(255, 250, 240, 0.15);
  background: rgba(32, 30, 26, 0.94);
  box-shadow: 0 16px 48px rgba(30, 25, 20, 0.2);
  color: rgba(255, 250, 240, 0.72);
  font-size: 0.65rem;
  backdrop-filter: blur(14px);
  max-height: calc(100vh - 86px);
  overflow-y: auto;
}

.legend-heading {
  display: flex;
  width: 100%;
  min-height: 39px;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid rgba(255, 250, 240, 0.14);
  color: #fffaf0;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.legend-heading span {
  color: rgba(255, 250, 240, 0.46);
  font-size: 0.47rem;
  letter-spacing: 0.08em;
}

.legend-content {
  padding: 0 12px 11px;
}

.legend-title {
  margin: 2px 0 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 250, 240, 0.14);
  color: rgba(255, 250, 240, 0.52);
  font-size: 0.57rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.legend-context .legend-title {
  margin-top: 11px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}

.legend-short {
  display: none;
}

.legend-swatch {
  width: 19px;
  height: 9px;
  border: 1px solid rgba(255, 250, 240, 0.32);
}

.legend-bubble {
  display: inline-block;
  width: 17px;
  height: 17px;
  border: 1.5px solid #fffaf0;
  border-radius: 50%;
  background: rgba(167, 60, 50, 0.78);
  box-shadow: 0 0 0 3px rgba(167, 60, 50, 0.16);
}

.legend-route {
  display: inline-block;
  width: 21px;
  height: 0;
  border-top: 2px dashed #e8a39a;
}

.legend-route.return {
  border-top-color: #84bd9a;
}

.legend-dam {
  display: inline-block;
  width: 11px;
  height: 11px;
  transform: rotate(45deg);
  border: 2px solid #d9f0fa;
  background: #2f83ae;
}

.legend-swatch.saf {
  background: rgba(84, 121, 149, 0.82);
}

.legend-swatch.rsf {
  background: rgba(181, 83, 78, 0.82);
}

.legend-swatch.contested {
  background: repeating-linear-gradient(135deg, rgba(197, 154, 61, 0.9) 0 3px, rgba(197, 154, 61, 0.18) 3px 6px);
}

.legend-swatch.active-front {
  border-color: #d4a640;
  background: repeating-linear-gradient(135deg, rgba(212, 166, 64, 0.95) 0 3px, rgba(255, 252, 242, 0.18) 3px 6px);
}

.legend-line {
  display: inline-block;
  width: 22px;
  height: 0;
}

.legend-line.river {
  border-top: 3px solid #56a3cb;
}

.legend-line.border {
  border-top: 3px solid #fffaf0;
}

.terrain-control {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 9px;
  margin-top: 9px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 250, 240, 0.14);
  color: #fffaf0;
  cursor: pointer;
  font-weight: 600;
}

.terrain-control input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.legend-note {
  margin: 6px 0 0;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 250, 240, 0.14);
  line-height: 1.4;
}

.legend-credit {
  margin: 6px 0 0;
  color: rgba(255, 250, 240, 0.45);
  font-size: 0.56rem;
  line-height: 1.4;
}

.story-progress {
  position: fixed;
  z-index: 6;
  bottom: 18px;
  left: 28px;
  display: grid;
  width: min(310px, calc(100vw - 56px));
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: rgba(244, 239, 228, 0.93);
  box-shadow: 0 8px 28px rgba(45, 37, 28, 0.12);
  backdrop-filter: blur(12px);
}

.reader-zoom {
  position: fixed;
  z-index: 7;
  right: 16px;
  bottom: 52px;
  display: grid;
  grid-template-columns: 38px auto 38px;
  min-height: 38px;
  overflow: hidden;
  border: 1px solid rgba(255, 250, 240, 0.18);
  background: rgba(32, 30, 26, 0.94);
  box-shadow: 0 8px 24px rgba(30, 25, 20, 0.18);
}

.reader-zoom button {
  min-width: 38px;
  min-height: 38px;
  border: 0;
  border-right: 1px solid rgba(255, 250, 240, 0.14);
  background: transparent;
  color: #fffaf0;
  cursor: pointer;
  font-weight: 700;
}

.reader-zoom button:last-child {
  border-right: 0;
}

.reader-zoom button:hover {
  background: rgba(255, 250, 240, 0.1);
}

.reader-zoom .zoom-reset {
  padding: 0 12px;
  color: rgba(255, 250, 240, 0.72);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.progress-index,
.progress-title {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.progress-index {
  color: var(--accent);
}

.progress-title {
  max-width: 95px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-track {
  height: 2px;
  overflow: hidden;
  background: rgba(32, 30, 26, 0.16);
}

#progress-fill {
  display: block;
  width: calc(100% / 7);
  height: 100%;
  transform-origin: left center;
  background: var(--accent);
  transition: width 500ms var(--ease);
}

.status {
  position: fixed;
  z-index: 5;
  right: 16px;
  bottom: 16px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 245, 0.92);
  box-shadow: 0 5px 18px rgba(42, 37, 31, 0.1);
  color: var(--muted);
  font-size: 0.66rem;
  backdrop-filter: blur(10px);
}

.status.loaded::before {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--success);
  content: "";
}

.status.fallback::before {
  background: var(--contested);
}

.marker {
  width: 15px;
  height: 15px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(36, 33, 29, 0.52), 0 2px 6px rgba(36, 33, 29, 0.28);
  cursor: pointer;
  transition: transform 250ms var(--ease), box-shadow 250ms ease;
}

.marker.saf { background: var(--saf); }
.marker.rsf { background: var(--rsf); }
.marker.contested { background: var(--contested); }
.marker.humanitarian { background: var(--success); }
.marker.civilian { background: var(--ink-soft); }

.marker.focused {
  transform: scale(1.55);
  box-shadow: 0 0 0 2px #fff, 0 0 0 5px rgba(167, 60, 50, 0.5), 0 3px 9px rgba(36, 33, 29, 0.32);
}

.dam-marker {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
}

.dam-marker[hidden] {
  display: none;
}

.dam-marker .marker.dam {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  transform: rotate(45deg);
  border: 2px solid #fff;
  border-radius: 2px;
  background: #2f83ae;
}

.dam-marker.focused .marker.dam {
  transform: rotate(45deg) scale(1.55);
}

.dam-label {
  padding: 3px 5px;
  border: 1px solid rgba(32, 30, 26, 0.18);
  background: rgba(255, 252, 245, 0.88);
  box-shadow: 0 2px 8px rgba(32, 30, 26, 0.12);
  color: var(--ink-soft);
  font-size: 0.61rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1;
  white-space: nowrap;
}

.maplibregl-popup-content {
  max-width: 260px;
  border: 1px solid var(--line);
  border-radius: 1px;
  background: #fffdf8;
  box-shadow: 0 12px 36px rgba(42, 37, 31, 0.2);
  color: var(--ink);
  font-family: var(--sans);
}

.maplibregl-popup-content p {
  color: var(--muted);
  line-height: 1.45;
}

.maplibregl-popup-tip {
  border-top-color: #fffdf8 !important;
}

.maplibregl-ctrl-top-right {
  top: 76px;
}

@media (max-width: 900px) {
  :root {
    --story-panel: min(520px, 58vw);
  }

  .masthead {
    width: var(--story-panel);
  }

  #story {
    width: var(--story-panel);
  }

  .masthead-context {
    display: none;
  }

  h1 {
    font-size: clamp(3.6rem, 8vw, 5.5rem);
  }
}

@media (max-width: 700px) {
  :root {
    --story-panel: 100%;
    --mobile-map-height: clamp(260px, 40svh, 360px);
    --mobile-safe-top: env(safe-area-inset-top, 0px);
    --mobile-safe-right: env(safe-area-inset-right, 0px);
    --mobile-safe-left: env(safe-area-inset-left, 0px);
    --mobile-header-height: calc(62px + var(--mobile-safe-top));
  }

  #map {
    z-index: 4;
    top: var(--mobile-header-height);
    bottom: auto;
    left: 0;
    height: var(--mobile-map-height);
    border-bottom: 1px solid rgba(45, 38, 30, 0.34);
    box-shadow: 0 14px 34px rgba(45, 37, 28, 0.16);
  }

  .masthead {
    z-index: 8;
    width: 100%;
    min-height: var(--mobile-header-height);
    padding: calc(10px + var(--mobile-safe-top)) max(16px, var(--mobile-safe-right)) 10px max(16px, var(--mobile-safe-left));
    background: rgba(244, 239, 228, 0.95);
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  #story {
    width: 100%;
    padding-top: calc(var(--mobile-header-height) + var(--mobile-map-height) + 58px);
    padding-right: max(16px, var(--mobile-safe-right));
    padding-left: max(16px, var(--mobile-safe-left));
    background: var(--paper);
  }

  .map-shade {
    display: none;
  }

  .paper-grain {
    z-index: 5;
    opacity: 0.11;
  }

  .hero {
    min-height: auto;
    justify-content: flex-start;
    margin: 0;
    padding: 18px 0 15vh;
    background: var(--paper);
  }

  .hero-metrics {
    margin-top: 1.35rem;
  }

  .hero-metrics div {
    min-height: 94px;
    padding: 12px 10px;
  }

  .hero-metrics strong {
    font-size: 1.75rem;
  }

  .hero-metrics span {
    font-size: 0.61rem;
  }

  .step {
    scroll-margin-top: calc(var(--mobile-header-height) + var(--mobile-map-height) + 54px);
    opacity: 1;
    transform: none;
  }

  .hero-meta {
    flex-wrap: wrap;
    gap: 6px;
    max-width: 290px;
    margin-bottom: 0.85rem;
    font-size: 0.62rem;
  }

  .hero-meta span + span::before {
    width: 16px;
  }

  h1 {
    max-width: 560px;
    font-size: clamp(3.1rem, 14.5vw, 4.7rem);
    line-height: 0.94;
  }

  .dek {
    max-width: 36ch;
    font-size: 1.05rem;
    line-height: 1.47;
  }

  .scroll-cue {
    margin-top: 1.45rem;
  }

  .card {
    z-index: 2;
    margin: 0 0 18vh;
    padding: 26px 22px 28px;
    background: #fffaf0;
    box-shadow: 0 12px 32px rgba(45, 37, 28, 0.1);
    backdrop-filter: none;
  }

  h2 {
    font-size: clamp(2.05rem, 9.2vw, 2.8rem);
  }

  .story-copy {
    font-size: 0.97rem !important;
    line-height: 1.52 !important;
  }

  .mini-chart {
    padding: 12px;
  }

  .mini-chart figcaption {
    margin-bottom: 9px;
  }

  .bar-row {
    grid-template-columns: 76px 1fr 38px;
    min-height: 22px;
  }

  .card-stat {
    margin-top: 0.95rem;
    padding: 11px 12px;
  }

  .card-stat strong {
    font-size: 1.9rem;
  }

  .map-note {
    margin-top: 0.95rem;
    padding: 10px 12px;
  }

  .sources {
    margin-top: 1rem;
    padding-top: 0.75rem;
  }

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

  .metric-grid div {
    min-height: 100px;
  }

  .legend {
    z-index: 9;
    top: calc(var(--mobile-header-height) + 6px);
    right: max(12px, var(--mobile-safe-right));
    left: max(12px, var(--mobile-safe-left));
    width: auto;
    max-height: none;
    overflow: hidden;
    background: rgba(32, 30, 26, 0.96);
  }

  .legend-heading {
    min-height: 44px;
    padding: 0 168px 0 9px;
    font-size: 0.54rem;
  }

  .legend-heading span {
    display: none;
  }

  .legend-content {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 8px;
    padding: 5px 8px 7px;
  }

  .legend-title,
  .legend-context .legend-title {
    margin: 0 0 3px;
    padding: 0;
    border: 0;
    font-size: 0.44rem;
  }

  .legend-items {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
  }

  .legend-context .legend-items {
    grid-template-columns: repeat(3, 1fr);
  }

  .legend-row {
    flex-direction: column;
    gap: 3px;
    margin: 0;
    text-align: center;
  }

  .legend-long {
    display: none;
  }

  .legend-short {
    display: inline;
    font-size: 0.46rem;
    line-height: 1;
  }

  .legend-bubble {
    width: 13px;
    height: 13px;
  }

  .legend-route {
    width: 18px;
  }

  .legend-swatch {
    width: 18px;
    height: 8px;
  }

  .legend-dam {
    width: 9px;
    height: 9px;
  }

  .legend-note,
  .legend-credit,
  .terrain-control {
    display: none;
  }

  .story-progress {
    z-index: 9;
    top: calc(var(--mobile-header-height) + var(--mobile-map-height));
    bottom: auto;
    left: 0;
    width: 100%;
    min-height: 44px;
    padding: 9px max(16px, var(--mobile-safe-right)) 9px max(16px, var(--mobile-safe-left));
    border-width: 0 0 1px;
    background: rgba(244, 239, 228, 0.98);
    box-shadow: 0 8px 24px rgba(45, 37, 28, 0.1);
    backdrop-filter: none;
  }

  .reader-zoom {
    z-index: 10;
    top: calc(var(--mobile-header-height) + 7px);
    right: max(13px, var(--mobile-safe-right));
    bottom: auto;
    grid-template-columns: 44px auto 44px;
    min-height: 44px;
    border: 0;
    box-shadow: none;
  }

  .reader-zoom button {
    min-width: 44px;
    min-height: 44px;
  }

  .reader-zoom .zoom-reset {
    padding: 0 8px;
    font-size: 0.5rem;
  }

  .status {
    display: none;
  }

  .maplibregl-ctrl-top-right {
    top: 128px;
  }

  .maplibregl-ctrl-bottom-right {
    bottom: 4px;
  }

  footer {
    padding-bottom: max(10vh, env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 390px) {
  h1 {
    font-size: 2.95rem;
  }

  .card {
    padding-right: 21px;
    padding-left: 21px;
  }

  .progress-title {
    max-width: 78px;
  }

  .reader-zoom .zoom-reset {
    padding: 0 7px;
  }
}

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