:root {
  color-scheme: light;
  --paper: #f6f3e9;
  --surface: #fcfaf3;
  --ink: #192e27;
  --muted: #536057;
  --rule: #c9cbbd;
  --river-a: #12646e;
  --river-b: #9f431f;
  --path-a: #85e8f4;
  --path-b: #ffad79;
  --divide: #ffedaa;
  --sans: "Instrument Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  --serif: "Spectral", "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { min-width: 280px; margin: 0; }
button, input { font: inherit; }
button, a, summary, label { -webkit-tap-highlight-color: transparent; }
button, summary, label { cursor: pointer; }
button { color: inherit; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible, #map:focus-visible {
  outline: 3px solid #a35425;
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
h1, h2, h3, p, dl, dt, dd { margin: 0; }
.shell { width: min(1060px, calc(100% - 80px)); margin-inline: auto; }
.masthead { border-bottom: 1px solid var(--rule); }
.masthead-inner { display: flex; align-items: center; justify-content: space-between; min-height: 51px; }
.index-link, #lang { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); }
.index-link { gap: .65em; text-decoration: none; font-weight: 650; font-size: .85rem; }
.back-arrow { font-size: 1.15rem; font-weight: 400; line-height: 1; }
#lang { background: transparent; border: 0; padding: 0 .2em; font-size: .81rem; }
.index-link:hover, #lang:hover { color: var(--river-a); }
main { padding-bottom: max(28px, env(safe-area-inset-bottom)); }
.page-title { padding-block: clamp(18px, 2vw, 26px) clamp(15px, 1.8vw, 22px); }
.region {
  display: flex; align-items: center; gap: .65em;
  font-size: .79rem; font-weight: 680; letter-spacing: .08em; color: #46594a;
}
.ridge-mark {
  display: inline-block; width: 23px; height: 13px; background: #50694e;
  clip-path: polygon(0 98%, 34% 15%, 48% 46%, 65% 0, 100% 98%, 90% 98%, 65% 25%,
    49% 70%, 34% 39%, 9% 98%);
}
h1 {
  margin: 8px 0 0; font: 700 clamp(2rem, 4.3vw, 3.25rem)/1.12 var(--serif);
  letter-spacing: -.045em; text-wrap: balance;
}
.atlas {
  display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(270px, 1fr);
  gap: clamp(24px, 4.6vw, 62px); align-items: start;
}
.map-panel, .routes { min-width: 0; }
.map-toolbar, .map-instruction, .map-caption, .routes-head, .sample-button {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.map-toolbar { flex-wrap: wrap; padding-bottom: 4px; }
.map-instruction { justify-content: start; min-height: 31px; padding-bottom: 6px; }
.drop-selector { display: inline-flex; gap: 3px; }
.drop-select {
  --drop-ink: var(--river-a);
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  min-height: 44px; padding: 3px 13px; border: 1px solid transparent; border-radius: 5px;
  font-weight: 660; font-size: .85rem; background: transparent;
}
.drop-a { --drop-ink: var(--river-a); --map-ink: #17656e; --map-ring: var(--path-a); }
.drop-b { --drop-ink: var(--river-b); --map-ink: #944322; --map-ring: var(--path-b); }
.drop-select[aria-pressed="true"] {
  background: var(--surface); border-color: var(--drop-ink); color: var(--drop-ink);
  box-shadow: inset 0 -2px var(--drop-ink);
}
.drop-select:not([aria-pressed="true"]):hover { background: #e9e8dd; }
.drop-dot {
  width: 10px; height: 13px; display: inline-block; background: var(--drop-ink);
  border-radius: 66% 34% 67% 33% / 68% 32% 68% 32%; transform: rotate(-28deg);
}
.ridge-toggle {
  display: flex; align-items: center; gap: 7px; position: relative;
  font-weight: 600; font-size: .82rem; min-height: 44px;
}
.ridge-toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; left: 0; top: 0; margin: 0; cursor: pointer; }
.ridge-switch {
  display: inline-flex; align-items: center; width: 30px; height: 18px; padding: 2px;
  background: #bfbcaf; border: 1px solid #898b7d; border-radius: 12px;
}
.ridge-switch::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: #fffdf4; }
.ridge-toggle input:checked + .ridge-switch { background: #485e41; border-color: #485e41; justify-content: flex-end; }
.ridge-toggle:has(input:disabled) { opacity: .55; cursor: default; }
.ridge-toggle input:disabled { cursor: default; }
.ridge-toggle input:focus-visible + .ridge-switch { outline: 3px solid #a35425; outline-offset: 3px; }

.map-frame { border: 1px solid #7e8773; background: #829676; box-shadow: 0 3px 10px #283f2724; }
#map {
  position: relative; isolation: isolate; container-type: inline-size; width: 100%; aspect-ratio: 1120 / 1146;
  overflow: hidden; cursor: crosshair; touch-action: none; user-select: none; -webkit-user-select: none;
}
#relief, #water-layer { position: absolute; inset: 0; display: block; width: 100%; height: 100%; pointer-events: none; }
#relief { object-fit: fill; -webkit-user-drag: none; }
/* 底图的经纬范围覆盖整个图框，水路、分界线和雨滴须使用同一范围。 */
#water-layer { overflow: hidden; }
#water-layer path { stroke-linecap: round; stroke-linejoin: round; }
.ridge-line, .flow-line, .flow-casing { fill: none; vector-effect: non-scaling-stroke; }
.ridge-line {
  stroke: var(--divide); stroke-width: 2.3; stroke-dasharray: 6 4;
  filter: drop-shadow(0 1px 1px #222c20) drop-shadow(0 -1px 1px #222c20);
}
.flow-line { stroke-width: 3.2px; }
.flow-a { stroke: var(--path-a); }
.flow-b { stroke: var(--path-b); }
.flow-casing { stroke: #26382e; stroke-width: 5.5px; opacity: .76; }
.flow-line.is-tracing { stroke-dasharray: 1; animation: flow-draw 1.05s ease-out both; }
@keyframes flow-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
.meet-point { fill: #fffae8; stroke: #214f42; paint-order: stroke fill; stroke-width: 6px; }
.map-label {
  font: 630 28px var(--sans); paint-order: stroke fill; stroke: #263b2f;
  stroke-width: 4px; stroke-linejoin: round; fill: #fffbed;
}
.map-label.minor { font-weight: 510; font-size: 24px; }
.stream-line {
  fill: none; stroke: #c4e2dc; stroke-width: 1px; opacity: .76;
  vector-effect: non-scaling-stroke;
}
.cross-point { fill: #a54c24; stroke: #fff1b5; stroke-width: 5px; paint-order: stroke fill; }
.map-north, #distance-scale {
  position: absolute; z-index: 1; pointer-events: none; color: #fffbea;
  text-shadow: 0 1px 3px #13251f, 0 0 2px #13251f;
}
.map-north { display: grid; justify-items: center; gap: 3px; top: 12px; right: 14px; font: 700 .72rem var(--mono); }
.map-north i { width: 12px; height: 20px; background: linear-gradient(90deg,#faf8e6 50%,#344436 50%); clip-path: polygon(50% 0,100% 100%,50% 77%,0 100%); }
#distance-scale { bottom: 13px; left: 13px; width: 13%; text-align: center; font: 650 .68rem/1.1 var(--mono); }
#distance-scale i { display: block; height: 5px; margin-top: 2px; border: solid #fffbea; border-width: 0 1.5px 2px; filter: drop-shadow(0 1px 1px #172419); }
.map-pin {
  position: absolute; z-index: 3; transform: translate(-50%, -50%); display: grid; place-items: center;
  width: 44px; height: 44px; border: 0; background: transparent; padding: 0; touch-action: none;
  cursor: grab; border-radius: 50%;
}
.map-pin span {
  display: grid; place-items: center; width: 27px; height: 27px; border-radius: 50%;
  background: var(--map-ink); border: 2px solid #fff9e8; color: white; font: 750 13px/1 var(--mono);
  box-shadow: 0 0 0 1px #27372f, 0 2px 3px #172b25ad;
}
#map[data-active="a"] #pin-a, #map[data-active="b"] #pin-b { z-index: 4; }
#map[data-active="a"] #pin-a span, #map[data-active="b"] #pin-b span {
  box-shadow: 0 0 0 2px var(--map-ink), 0 0 0 4px var(--map-ring), 0 2px 6px #142b24bd;
}
.map-pin:active { cursor: grabbing; }
.map-caption { flex-wrap: wrap; justify-content: flex-start; align-items: baseline; row-gap: 4px; margin-block: 10px 4px; }
#map-hint { flex: 1 1 220px; font-size: .85rem; line-height: 1.6; color: var(--ink); }
#map-legend { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: .76rem; line-height: 1.6; }
.ridge-key { width: 21px; height: 6px; border: 1px solid #66664c; border-radius: 4px; background: repeating-linear-gradient(to right,#ffe8a0 0 6px,#566742 6px 10px); }
.inline-button { border: 0; background: transparent; color: var(--river-a); min-height: 44px; padding: 0 .4em; text-decoration: underline; }

.routes { margin-top: 79px; border-top: 2px solid #475846; }
.routes-head { min-height: 62px; border-bottom: 1px solid var(--rule); }
.routes-head h2 { font: 700 clamp(1.25rem,2.5vw,1.65rem)/1.2 var(--serif); }
.replay { display: inline-flex; align-items: center; gap: 4px; border: none; background: transparent; min-height: 44px; padding: 3px 0 3px 8px; font-size: .82rem; font-weight: 630; }
.replay span:first-child { font-size: 1.16rem; }
.destination { padding: 16px 0 18px; border-bottom: 1px solid var(--rule); }
.destination dt { display: flex; align-items: center; gap: 8px; color: var(--drop-ink); font-size: .78rem; font-weight: 700; }
.route-key {
  width: 22px; height: 22px; display: inline-grid; place-items: center; background: var(--drop-ink);
  color: #fff; border-radius: 50%; font: 650 .73rem/1 var(--mono);
}
.destination dd { margin: 6px 0 0 30px; font-size: clamp(.96rem,1.8vw,1.12rem); font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
#outcome { padding: 19px 17px; margin-block: 17px 9px; background: #e6ebdd; border-left: 3px solid #61714e; }
#outcome[data-state="meet"] { background: #dcece4; border-left-color: #38705a; }
#outcome[data-state="split"] { background: #efe8d6; border-left-color: #a97b3c; }
#outcome h3 { font: 700 clamp(1.1rem,2vw,1.45rem)/1.38 var(--serif); }
#outcome p { margin-top: 5px; font-size: .85rem; line-height: 1.6; color: #425246; }
#move-note:not([hidden]) { margin-top: 9px; padding-top: 8px; border-top: 1px solid #51694f38; color: var(--ink); font-weight: 620; }
.sample-button {
  width: 100%; padding: 8px 2px; min-height: 44px; border: 0; background: transparent;
  text-align: left; color: #315c50; font-size: .88rem; font-weight: 650;
}
.sample-button:hover, .replay:not(:disabled):hover { color: #7b411e; }
#credits { border-top: 1px solid var(--rule); margin-top: 26px; color: var(--muted); }
#credits summary { display: list-item; padding: 13px 0; min-height: 44px; font-size: .8rem; font-weight: 620; }
.source-copy { max-width: 56em; padding-bottom: 14px; font-size: .82rem; line-height: 1.65; }
.source-copy p + p { margin-top: .35em; }
.source-copy a { color: #315c50; text-underline-offset: 2px; }

@media (max-width: 760px) {
  .shell { width: min(590px, calc(100% - 32px)); }
  .masthead-inner { min-height: 47px; }
  .page-title { padding-block: 17px 11px; }
  h1 { margin-top: 5px; }
  .atlas { grid-template-columns: minmax(0,1fr); gap: 16px; }
  .map-toolbar { padding-bottom: 1px; }
  .map-caption { margin-top: 6px; }
  .map-label { font-size: 34px; }
  .map-label.minor { font-size: 30px; }
  .routes { margin-top: 0; }
  .routes-head { min-height: 49px; }
  .destinations { display: grid; grid-template-columns: 1fr 1fr; }
  .destination { min-width: 0; padding: 10px 6px 12px 0; }
  .destination + .destination { padding-left: 12px; border-left: 1px solid var(--rule); }
  .destination dd { margin: 5px 0 0; }
  #outcome { padding: 13px 14px; margin: 13px 0 2px; }
  #credits { margin-top: 16px; }
}
@media (max-width: 360px) {
  .shell { width: calc(100% - 24px); }
  .drop-select { gap: 6px; padding-inline: 9px; }
  h1 { font-size: 1.85rem; }
}
@media (prefers-reduced-motion: reduce) {
  .flow-line.is-tracing { animation: none; stroke-dasharray: none; }
}
