:root {
  color-scheme: dark;
  --ink: #f4eddc;
  --muted: #b7b9aa;
  --paper: #17221e;
  --deep: #0b1110;
  --line: rgba(244, 237, 220, .17);
  --gold: #f3c66a;
  --rust: #e99670;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--deep); scroll-behavior: smooth; }
body { margin: 0; min-width: 300px; color: var(--ink); background: radial-gradient(circle at 50% -20%, #34483d 0, var(--deep) 52%); }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, .map-wrap:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }

.world-shell { position: relative; min-height: calc(100vh - 46px); overflow: hidden; }
.world { width: min(1500px, 100%); margin: 0 auto; padding: clamp(18px, 3vw, 42px); }
.masthead { position: relative; z-index: 3; width: min(750px, 79%); margin-bottom: -11.5rem; pointer-events: none; }
.eyebrow { margin: 0 0 .6rem; color: var(--gold); font-size: .7rem; font-weight: 760; letter-spacing: .18em; text-transform: uppercase; }
h1 { max-width: 700px; margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.25rem, 5.7vw, 5.6rem); font-weight: 400; letter-spacing: -.055em; line-height: .9; text-wrap: balance; text-shadow: 0 4px 30px #08110d; }
.lede { max-width: 590px; margin: 1rem 0 0; color: #dfddcd; font-family: Georgia, serif; font-size: clamp(1rem, 1.55vw, 1.35rem); line-height: 1.4; text-wrap: balance; }

.map-wrap { position: relative; width: min(910px, 100%); min-height: 510px; margin-inline: auto; border-radius: 34px; background: #15241f; box-shadow: 0 28px 80px rgba(0,0,0,.55), inset 0 0 0 1px var(--line); overflow: hidden; }
.map { display: block; width: 100%; min-height: 510px; aspect-ratio: 1000 / 720; }
.mountain { fill: #d5d8c7; }
.mountain.far { opacity: .13; }
.mountain.near { opacity: .08; }
.ridge { fill: #0d1714; opacity: .52; }
.ridge.west { stroke: #75bd93; stroke-opacity: .12; }
.ridge.east { stroke: #70bde2; stroke-opacity: .1; }
.river { fill: none; stroke: url(#water); stroke-width: 23; stroke-linecap: round; filter: drop-shadow(0 0 12px rgba(112,189,226,.22)); }
.coast { fill: #5ba3bd; opacity: .22; }
.terrain-labels text { fill: #e9ebdd; opacity: .19; font-size: 11px; font-weight: 800; letter-spacing: .22em; text-anchor: middle; }

.settlement { cursor: pointer; transition: opacity .35s ease; }
.settlement .halo { fill: none; stroke: var(--site); stroke-width: 2; opacity: .25; }
.settlement.selected .halo { opacity: .9; stroke-width: 3; filter: url(#glow); }
.settlement .disc { fill: #12201b; stroke: var(--site); stroke-width: 3; }
.settlement:hover .disc, .settlement.selected .disc { stroke-width: 5; }
.settlement .pulse { fill: var(--site); opacity: .8; }
.settlement .name { fill: #fff9e8; font-family: Georgia, serif; font-size: 22px; text-anchor: middle; paint-order: stroke; stroke: #0e1714; stroke-width: 5px; }
.settlement .word { fill: var(--site); font-size: 15px; font-style: italic; font-weight: 700; text-anchor: middle; paint-order: stroke; stroke: #0e1714; stroke-width: 4px; }
.settlement .meta { fill: #d0d3c5; font-size: 10px; font-weight: 700; letter-spacing: .12em; text-anchor: middle; text-transform: uppercase; paint-order: stroke; stroke: #0e1714; stroke-width: 4px; }
.contact { fill: none; stroke-linecap: round; stroke-width: 3; opacity: .8; stroke-dasharray: 4 11; animation: travel 2.4s linear infinite; }
.contact.migration { stroke-width: 8; stroke-dasharray: 1 13; opacity: .5; }
.contact.borrowing { stroke: #f3c66a; }
.contact.migration { stroke: #e99670; }
@keyframes travel { to { stroke-dashoffset: -30; } }

.time-mark { position: absolute; right: clamp(18px, 3vw, 44px); top: clamp(18px, 3vw, 35px); display: grid; justify-items: end; color: rgba(244,237,220,.72); }
.time-mark span { font-size: .62rem; font-weight: 800; letter-spacing: .2em; }
.time-mark strong { color: rgba(244,237,220,.18); font-family: Georgia, serif; font-size: clamp(4rem, 10vw, 9rem); font-weight: 400; line-height: .82; }
.map-fallback { position: absolute; inset: auto 20px 20px; padding: 18px; border: 1px solid #c7856c; border-radius: 8px; background: #2d1714; }

.chronicle { position: relative; z-index: 4; display: grid; grid-template-columns: auto auto auto minmax(220px, 1fr); gap: 10px; align-items: center; width: min(900px, calc(100% - 34px)); margin: -34px auto 0; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: rgba(12,19,17,.9); box-shadow: 0 14px 40px rgba(0,0,0,.38); backdrop-filter: blur(13px); }
.chronicle button, .ledger-button, .seed-row button { border: 1px solid var(--line); background: rgba(255,255,255,.045); cursor: pointer; transition: background .2s ease, border-color .2s ease, transform .2s ease; }
.chronicle button:hover, .ledger-button:hover, .seed-row button:hover { border-color: rgba(243,198,106,.65); background: rgba(243,198,106,.1); }
.round { width: 42px; height: 42px; border-radius: 50%; font-size: 1.2rem; }
.play { min-height: 42px; padding: 0 16px; border-radius: 22px; white-space: nowrap; }
.play span { display: inline-block; margin-right: 6px; font-size: .75rem; }
.play[aria-pressed="true"] span { transform: rotate(90deg); }
.generation-slider { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; color: var(--muted); font-size: .77rem; font-weight: 700; letter-spacing: .04em; }
.generation-slider strong { color: var(--ink); }
input[type="range"] { width: 100%; accent-color: var(--gold); }

.reveal-strip { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 20px; align-items: center; width: min(1180px, 94%); margin: 26px auto 0; padding: 6px 0 20px; }
.event-copy { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: baseline; }
.event-copy span { grid-row: 1 / 3; align-self: start; padding-top: 4px; color: var(--rust); font-size: .63rem; font-weight: 850; letter-spacing: .16em; }
.event-copy strong { font-family: Georgia, serif; font-size: clamp(1rem, 1.55vw, 1.3rem); font-weight: 400; }
.event-copy small { margin-top: 4px; color: var(--muted); line-height: 1.4; }
.ledger-button { padding: 14px 18px; border-radius: 5px; font-weight: 750; }
.ledger-button span { color: var(--gold); }

.ledger { position: fixed; z-index: 12; top: 0; right: 0; width: min(620px, 100%); height: 100dvh; padding: clamp(20px, 4vw, 44px); overflow-y: auto; border-left: 1px solid var(--line); background: #121a18; box-shadow: -25px 0 80px rgba(0,0,0,.55); transform: translateX(103%); visibility: hidden; transition: transform .48s cubic-bezier(.2,.85,.2,1), visibility .48s; }
.ledger.open { transform: translateX(0); visibility: visible; }
.ledger-head { display: flex; justify-content: space-between; gap: 20px; align-items: start; }
.ledger h2 { margin: 0; font-family: Georgia, serif; font-size: clamp(2.2rem, 5vw, 4rem); font-weight: 400; letter-spacing: -.04em; }
.close { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: transparent; font-size: 1.8rem; cursor: pointer; }
.ledger-intro { max-width: 500px; color: var(--muted); line-height: 1.55; }
.word-tabs { display: flex; gap: 6px; margin: 24px 0 16px; padding-bottom: 8px; overflow-x: auto; }
.word-tab { flex: 0 0 auto; min-width: 66px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 4px; background: transparent; cursor: pointer; }
.word-tab strong, .word-tab small { display: block; }
.word-tab strong { font-family: Georgia, serif; font-size: 1.05rem; }
.word-tab small { color: var(--muted); font-size: .66rem; }
.word-tab.selected { color: #17221e; border-color: var(--gold); background: var(--gold); }
.word-tab.selected small { color: #4e4228; }
.proto-card { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: baseline; padding: 17px 20px; border-block: 1px solid var(--line); }
.proto-card span, .argument span { color: var(--gold); font-size: .63rem; font-weight: 850; letter-spacing: .15em; }
.proto-card strong { font-family: Georgia, serif; font-size: 2rem; font-weight: 400; }
.proto-card em { color: var(--muted); }
.descendants { margin: 10px 0 24px; }
.descendant { position: relative; display: grid; grid-template-columns: 1.2fr .8fr 1fr; gap: 10px; align-items: center; min-height: 66px; padding: 10px 12px 10px 22px; border-bottom: 1px solid var(--line); }
.descendant::before { position: absolute; left: 0; width: 4px; height: 70%; border-radius: 4px; background: var(--site); content: ""; }
.descendant .place { font-size: .75rem; font-weight: 800; }
.descendant .form { font-family: Georgia, serif; font-size: 1.65rem; }
.descendant .meaning { color: var(--muted); font-size: .8rem; text-align: right; }
.descendant .borrowed { color: var(--gold); font-size: .65rem; font-weight: 750; }
.descendant details { grid-column: 1 / -1; }
.descendant summary { color: #aeb4a8; font-size: .7rem; cursor: pointer; }
.history { margin: 9px 0 2px; padding-left: 18px; color: #c7c9bd; font-size: .72rem; line-height: 1.6; }
.argument { padding: 18px 20px; border: 1px solid rgba(243,198,106,.28); background: rgba(243,198,106,.055); }
.argument p { margin: 9px 0 0; font-family: Georgia, serif; font-size: 1.05rem; line-height: 1.52; }
.seed-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: end; margin-top: 24px; }
.seed-row label { display: grid; gap: 5px; color: var(--muted); font-size: .72rem; }
.seed-row input { min-width: 80px; padding: 9px; color: var(--ink); border: 1px solid var(--line); border-radius: 3px; background: #0b1210; }
.seed-row button { min-height: 38px; padding: 0 11px; border-radius: 3px; font-size: .72rem; }
.seed-row small { grid-column: 1 / -1; color: #858d83; line-height: 1.4; }

.keys { display: flex; justify-content: center; gap: 24px; min-height: 46px; padding: 12px 20px; color: #7f8980; border-top: 1px solid rgba(255,255,255,.08); background: #080d0c; font-size: .68rem; }
kbd { min-width: 20px; margin-right: 3px; padding: 2px 5px; color: #c7c9bd; border: 1px solid #3c4641; border-radius: 3px; background: #111815; box-shadow: 0 1px #000; text-align: center; }
.noscript { position: fixed; z-index: 20; inset: auto 20px 20px; padding: 16px; border: 1px solid #d68e72; background: #341b17; }

@media (max-width: 760px) {
  .world { padding: 14px; }
  .masthead { width: calc(100% - 22px); margin: 10px 11px -2.3rem; }
  h1 { font-size: clamp(2.2rem, 12vw, 3.5rem); }
  .lede { width: 85%; font-size: .95rem; }
  .map-wrap { min-height: 530px; border-radius: 24px; }
  .map { width: auto; height: 590px; margin-left: 50%; transform: translateX(-50%); }
  .time-mark { right: 14px; top: 15px; }
  .chronicle { grid-template-columns: auto 1fr auto; width: calc(100% - 18px); margin-top: -25px; }
  .play { padding: 0 10px; }
  .generation-slider { grid-column: 1 / -1; grid-template-columns: auto 1fr; }
  .reveal-strip { grid-template-columns: 1fr; width: calc(100% - 26px); }
  .ledger-button { width: 100%; }
  .descendant { grid-template-columns: 1fr .7fr; }
  .descendant .meaning { grid-column: 1 / -1; text-align: left; }
  .seed-row { grid-template-columns: 1fr 1fr; }
  .seed-row label { grid-column: 1 / -1; }
  .keys { gap: 12px; justify-content: flex-start; overflow-x: auto; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .contact { stroke-dasharray: none; }
}
