:root {
  --bg: #0a0e17;
  --panel: rgba(12, 17, 28, 0.78);
  --panel-solid: #111725;
  --line: rgba(236, 228, 208, 0.12);
  --ink: #ece4d0;
  --ink-2: #d3cbb8;
  --muted: #9a9280;
  --gold: #e2a93d;
  --gold-soft: #f3d896;
  --parkway: #e2a93d;
  --expressway: #d9584a;
  --bridge: #e0865a;
  --park: #7fb77a;
  --housing: #b08ad6;
  --culture: #5fb8c4;
  --power: #7aa7e8;
  --office: #ece4d0;
  --cost: #ff5d6c;
  --unbuilt: #8f8a7f;
  --radius: 14px;
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold-soft); }
button { font: inherit; color: inherit; }

.app { position: fixed; inset: 0; }
#map { position: absolute; inset: 0; background: var(--bg); }
.leaflet-container { background: var(--bg); font-family: var(--sans); }
.leaflet-control-attribution {
  background: rgba(10, 14, 23, 0.6) !important;
  color: var(--muted) !important;
  font-size: 10px;
}
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-control-zoom { display: none; }
.leaflet-tile-pane { filter: saturate(0.75) brightness(0.85); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

/* Brand */
.brand {
  position: absolute; top: 16px; left: 16px; z-index: 500;
  padding: 10px 18px 12px;
  max-width: calc(100vw - 32px);
}
.kicker {
  display: block; font-size: 10.5px; font-weight: 600; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--gold);
}
.brand h1 {
  margin: 2px 0 0; font-family: var(--serif); font-weight: 600; font-size: 21px;
  letter-spacing: -0.01em; line-height: 1.2; white-space: nowrap;
}
.brand h1 small {
  font-weight: 400; font-size: 14px; color: var(--muted); margin-left: 8px; letter-spacing: -0.01em;
}

/* Nav */
.nav {
  position: absolute; top: 16px; right: 16px; z-index: 500;
  display: flex; gap: 2px; padding: 4px;
}
.nav button {
  background: none; border: 0; border-radius: 10px; padding: 8px 14px;
  color: var(--ink); cursor: pointer; font-size: 13px;
}
.nav button:hover, .nav button[aria-pressed="true"] { background: rgba(236, 228, 208, 0.08); color: var(--gold-soft); }

/* Clock panel */
.clock {
  position: absolute; top: 96px; left: 16px; z-index: 500;
  width: 330px; max-height: calc(100vh - 96px - 140px);
  padding: 16px 18px 14px; overflow: hidden; display: flex; flex-direction: column;
}
.clock-month { font-size: 13px; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold-soft); }
.clock-year { font-family: var(--serif); font-weight: 300; font-size: 64px; line-height: 1; letter-spacing: -0.03em; margin: 2px 0 6px; font-variant-numeric: tabular-nums; }
.clock-meta { font-size: 12px; color: var(--muted); }
.clock-meta .dot { margin: 0 4px; }
.clock-meta .num { color: var(--gold); font-weight: 600; }
.clock-body { overflow-y: auto; padding-right: 4px; scrollbar-width: thin; scrollbar-color: rgba(236,228,208,0.2) transparent; }
.chapter { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.chapter-n { font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.chapter h3 { margin: 4px 0 6px; font-family: var(--serif); font-weight: 500; font-size: 19px; color: var(--gold-soft); line-height: 1.2; }
.chapter p { margin: 0; color: var(--ink-2); }
.event { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.event:not([hidden]) + .chapter { opacity: 0.75; }
.event-date { font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.event-date::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; background: var(--evt, var(--gold)); vertical-align: 0; }
.event h4 { margin: 4px 0 6px; font-family: var(--serif); font-weight: 500; font-size: 17px; line-height: 1.25; }
.event p { margin: 0 0 6px; color: var(--ink-2); }
.event-src { font-size: 11.5px; }
.event-src a { color: var(--muted); text-decoration: underline dotted; text-underline-offset: 2px; }
.event-src a:hover { color: var(--gold-soft); }
.event-nav { display: flex; gap: 6px; margin-top: 8px; }
.event-nav button { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; color: var(--muted); cursor: pointer; font-size: 11.5px; }
.event-nav button:hover { color: var(--gold-soft); border-color: var(--gold); }
.clock-expand { display: none; }

/* Legend */
#key-btn { }
.legend {
  position: absolute; left: 16px; bottom: 132px; z-index: 500; padding: 12px 14px; width: 250px;
}
.legend ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 4px; font-size: 12px; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 10px; }
.sw { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.sw-parkway { background: var(--parkway); }
.sw-expressway { background: var(--expressway); }
.sw-bridge { background: var(--bridge); }
.sw-park { background: var(--park); }
.sw-housing { background: var(--housing); }
.sw-culture { background: var(--culture); }
.sw-power { background: var(--power); }
.sw-office { background: var(--office); transform: rotate(45deg); border-radius: 2px; width: 10px; height: 10px; }
.sw-cost { background: none; border: 2px solid var(--cost); }
.sw-unbuilt { background: none; border: 2px dashed var(--unbuilt); }
.legend-note { margin: 10px 0 0; font-size: 11px; color: var(--muted); }

/* Timeline */
.timeline {
  position: absolute; left: 16px; right: 16px; bottom: 16px; z-index: 500;
  height: 104px; padding: 10px 16px 8px 14px; display: flex; gap: 14px; align-items: stretch;
}
.transport { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; flex: none; }
.play {
  width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--gold); color: #1a1408;
  display: grid; place-items: center; cursor: pointer; box-shadow: 0 0 0 4px rgba(226, 169, 61, 0.15);
}
.play:hover { background: var(--gold-soft); }
.speed { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 1px 8px; font-size: 11px; color: var(--muted); cursor: pointer; }
.speed:hover { color: var(--gold-soft); }
.track { flex: 1; min-width: 0; position: relative; cursor: pointer; touch-action: none; }
#tl-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.tl-chapter { fill: rgba(236, 228, 208, 0.06); stroke: rgba(236, 228, 208, 0.12); }
.tl-chapter.active { fill: rgba(226, 169, 61, 0.14); stroke: rgba(226, 169, 61, 0.5); }
.tl-chapter-label { font-size: 10.5px; fill: var(--ink); font-weight: 500; pointer-events: none; }
.tl-tick { stroke-width: 2; opacity: 0.35; }
.tl-tick.past { opacity: 1; }
.tl-tick.current { stroke-width: 3; }
.tl-axis { stroke: rgba(226, 169, 61, 0.55); stroke-width: 2; }
.tl-axis-future { stroke: rgba(236, 228, 208, 0.15); stroke-width: 2; }
.tl-year { font-size: 10.5px; fill: var(--ink); font-weight: 500; }
.tl-head-line { stroke: var(--gold); stroke-width: 1.5; }
.tl-head { fill: var(--gold); stroke: #1a1408; stroke-width: 2; cursor: grab; }
.tl-head:active { cursor: grabbing; }
.tl-hit { fill: transparent; }

/* Markers */
.mk { position: relative; }
.mk i {
  position: absolute; left: 50%; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px;
  border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px rgba(10, 14, 23, 0.8), 0 0 12px rgba(0,0,0,0.5);
  transition: transform 0.25s ease, opacity 0.4s ease; opacity: 0; transform: scale(0.4);
}
.mk.on i { opacity: 1; transform: scale(1); }
.mk.current i { transform: scale(1.4); box-shadow: 0 0 0 2px rgba(10, 14, 23, 0.8), 0 0 0 8px color-mix(in srgb, var(--c) 30%, transparent); }
.mk.current::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border-radius: 50%; border: 1px solid var(--c); opacity: 0.7; animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse { 0% { transform: scale(0.4); opacity: 0.8; } 100% { transform: scale(1.3); opacity: 0; } }
.mk-parkway { --c: var(--parkway); }
.mk-expressway { --c: var(--expressway); }
.mk-bridge { --c: var(--bridge); }
.mk-park { --c: var(--park); }
.mk-housing { --c: var(--housing); }
.mk-culture { --c: var(--culture); }
.mk-power { --c: var(--power); }
.mk-office { --c: var(--office); }
.mk-office i { border-radius: 2px; transform: rotate(45deg) scale(0.4); width: 10px; height: 10px; margin: -5px 0 0 -5px; }
.mk-office.on i { transform: rotate(45deg) scale(1); }
.mk-office.current i { transform: rotate(45deg) scale(1.4); }
.mk-cost { --c: var(--cost); }
.mk-cost i { background: none; border: 2px solid var(--c); }
.mk-unbuilt { --c: var(--unbuilt); }
.mk-unbuilt i { background: none; border: 2px dashed var(--c); }
.mk-label {
  position: absolute; left: 12px; top: -7px; white-space: nowrap; font-family: var(--serif); font-size: 12px;
  color: var(--ink); text-shadow: 0 0 4px #000, 0 0 8px #000; opacity: 0; transition: opacity 0.4s; pointer-events: none;
}
.mk.on .mk-label { opacity: 0.85; }
.mk.current .mk-label { opacity: 1; color: var(--gold-soft); }
.mk.lbl-hidden .mk-label { opacity: 0; }
.leaflet-tooltip.mk-tip {
  background: var(--panel-solid); color: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  font-family: var(--serif); font-size: 13px; padding: 4px 10px; box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
.leaflet-tooltip.mk-tip::before { display: none; }
.route { transition: opacity 0.6s; }

/* Modals */
.modal { position: fixed; inset: 0; z-index: 900; background: rgba(5, 8, 14, 0.7); display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card {
  width: min(720px, 100%); max-height: min(82vh, 900px); background: var(--panel-solid); border: 1px solid var(--line);
  border-radius: var(--radius); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-card header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.modal-card h2 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 22px; }
.close { background: none; border: 0; font-size: 24px; color: var(--muted); cursor: pointer; line-height: 1; }
.close:hover { color: var(--ink); }
.modal-body { overflow-y: auto; padding: 8px 20px 20px; }
.prose p { color: var(--ink-2); font-size: 14px; line-height: 1.6; }
.prose h3 { font-family: var(--serif); font-weight: 500; font-size: 18px; color: var(--gold-soft); margin: 18px 0 4px; }
.chron-chapter { font-family: var(--serif); font-size: 17px; color: var(--gold-soft); margin: 16px 0 6px; font-weight: 500; }
.chron-chapter span { font-family: var(--sans); font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-right: 10px; }
.chron-item { display: grid; grid-template-columns: 86px 1fr; gap: 10px; align-items: baseline; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 6px 8px; cursor: pointer; color: var(--ink); }
.chron-item:hover { background: rgba(236, 228, 208, 0.06); }
.chron-item .d { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chron-item .t { font-family: var(--serif); font-size: 14.5px; }
.chron-item .t::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--evt); margin-right: 8px; vertical-align: 1px; }

/* Phone */
@media (max-width: 720px) {
  body { font-size: 12.5px; }
  .brand { top: 10px; left: 10px; right: 10px; padding: 8px 14px 10px; }
  .brand h1 { font-size: 17px; white-space: normal; }
  .brand h1 small { font-size: 12px; margin-left: 6px; }
  .nav { top: auto; bottom: 108px; right: 10px; left: auto; }
  .nav button { padding: 7px 11px; font-size: 12px; }
  .clock { top: 78px; left: 10px; width: 210px; padding: 10px 12px 8px; max-height: 40vh; }
  .clock-month { font-size: 11px; }
  .clock-year { font-size: 40px; margin-bottom: 2px; }
  .clock-meta { font-size: 11px; }
  .clock-body { display: none; }
  .clock.expanded { width: calc(100vw - 20px); max-height: min(58vh, calc(100vh - 78px - 120px)); }
  .clock.expanded .clock-body { display: block; }
  .clock-expand { display: block; background: none; border: 0; padding: 4px 0 0; color: var(--gold-soft); font-size: 11.5px; text-align: left; cursor: pointer; }
  .chapter h3 { font-size: 16px; }
  .event h4 { font-size: 15px; }
  .legend { left: 10px; bottom: 108px; width: 200px; padding: 10px 12px; }
  .legend ul { gap: 2px; font-size: 11px; }
  .legend-note { display: none; }
  .timeline { left: 10px; right: 10px; bottom: 10px; height: 92px; padding: 8px 10px 6px 8px; gap: 8px; }
  .play { width: 40px; height: 40px; }
  .tl-chapter-label { font-size: 9px; }
  .tl-year { font-size: 9.5px; }
  .mk-label { display: none; }
  .modal-card { max-height: 88vh; }
  .chron-item { grid-template-columns: 70px 1fr; }
}

/* ===== v2: HUD, rich card, secrets, toasts, missions ===== */
.hud { margin-top: 6px; display: grid; gap: 4px; }
.hud-row { display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 8px; font-size: 11px; }
.hud-k { color: var(--muted); letter-spacing: 0.14em; text-transform: uppercase; font-size: 9.5px; font-weight: 600; }
.hud-v { color: var(--ink-2); font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.meter { display: flex; gap: 2px; height: 8px; }
.meter i { flex: 1; background: rgba(236, 228, 208, 0.1); border-radius: 2px; transition: background 0.3s; }
.meter i.on { background: var(--gold); box-shadow: 0 0 6px rgba(226, 169, 61, 0.6); }
.bar { height: 6px; background: rgba(236, 228, 208, 0.1); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--park); border-radius: 3px; transition: width 0.4s ease; }
.bar-secret i { background: var(--gold-soft); }
.clock-meta { margin-top: 4px; }

.event-photo { margin: 0 0 8px; border-radius: 10px; overflow: hidden; background: #000; }
.event-photo img { display: block; width: 100%; max-height: 170px; object-fit: cover; }
.event-photo figcaption { font-size: 10px; color: var(--muted); padding: 3px 8px; background: rgba(0,0,0,0.5); }
.event-photo figcaption a { color: var(--muted); text-decoration: none; }
.event-photo figcaption a:hover { color: var(--gold-soft); }
.facts { list-style: none; margin: 0 0 8px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.facts li { background: rgba(236, 228, 208, 0.05); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; display: flex; flex-direction: column; min-width: 0; }
.facts span { font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); line-height: 1.3; }
.facts b { font-family: var(--serif); font-weight: 500; font-size: 14px; color: var(--gold-soft); line-height: 1.25; }
.event-wow { border-left: 2px solid var(--evt, var(--gold)); padding-left: 8px; color: var(--ink) !important; font-style: italic; }
.event-wow::before { content: "Did you know · "; font-style: normal; font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

.shape { cursor: pointer; transition: opacity 0.5s, stroke-width 0.3s; }
.leaflet-interactive.shape:hover { filter: brightness(1.25); }

.mk.found i::after { content: ""; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px; border-radius: 50%; background: #0a0e17; }
.mk-find { --c: var(--gold-soft); }
.mk-find i {
  display: grid; place-items: center; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
  background: #1a1408; border: 1.5px solid var(--c); color: var(--c); font: 700 10px/1 var(--sans); font-style: normal;
  animation: twinkle 2.4s ease-in-out infinite;
}
.mk-find.on i { opacity: 1; transform: scale(1); }
.mk-find.found i { animation: none; background: var(--c); color: #1a1408; }
.mk-find.found i::after { display: none; }
.mk-find .mk-label { opacity: 0 !important; }
.mk-find.found .mk-label { opacity: 0.85 !important; }
.mk-find.current .mk-label { opacity: 1 !important; }
@keyframes twinkle { 0%, 100% { box-shadow: 0 0 0 0 rgba(243, 216, 150, 0.0); } 50% { box-shadow: 0 0 0 6px rgba(243, 216, 150, 0.25); } }
.sw-find { background: #1a1408; border: 1.5px solid var(--gold-soft); }

.toasts { position: absolute; right: 16px; bottom: 136px; z-index: 800; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  background: var(--panel-solid); border: 1px solid var(--line); border-left: 3px solid var(--tc); border-radius: 10px;
  padding: 8px 14px; box-shadow: 0 10px 30px rgba(0,0,0,0.45); transform: translateX(24px); opacity: 0; transition: transform 0.3s ease, opacity 0.3s ease;
  max-width: 300px; display: flex; flex-direction: column;
}
.toast.in { transform: none; opacity: 1; }
.toast-k { font-size: 9.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--tc); font-weight: 600; }
.toast-t { font-family: var(--serif); font-size: 14.5px; color: var(--ink); }
.toast.big { border-width: 1px 1px 1px 4px; padding: 12px 18px; }
.toast.big .toast-t { font-size: 18px; color: var(--gold-soft); }

.mission { position: absolute; top: 96px; right: 16px; z-index: 500; width: 300px; padding: 12px 16px; display: flex; flex-direction: column; gap: 2px; }
.mission[hidden] { display: none; }
.mission b { font-family: var(--serif); font-weight: 500; font-size: 17px; color: var(--gold-soft); }
.mission span:not(.kicker) { color: var(--ink-2); font-size: 12px; }
.mission-btns { display: flex; gap: 6px; margin-top: 8px; }
.mission-btns button { border: 0; border-radius: 8px; padding: 6px 12px; cursor: pointer; background: var(--gold); color: #1a1408; font-weight: 600; font-size: 12px; }
.mission-btns button.quiet { background: none; border: 1px solid var(--line); color: var(--muted); font-weight: 400; }
.mission-btns button:hover { filter: brightness(1.1); }

.modal-lead { color: var(--ink-2); margin: 10px 0 12px; }
.mission-item { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; width: 100%; text-align: left; background: rgba(236, 228, 208, 0.04); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; cursor: pointer; color: var(--ink); }
.mission-item:hover { border-color: var(--gold); background: rgba(226, 169, 61, 0.08); }
.mission-item.done { border-color: rgba(127, 183, 122, 0.5); }
.mi-t { font-family: var(--serif); font-size: 17px; color: var(--gold-soft); }
.mi-t em { font-style: normal; font-size: 11px; color: var(--park); margin-left: 6px; }
.mi-b { grid-column: 1; color: var(--ink-2); font-size: 12.5px; }
.mi-n { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: 11px; color: var(--muted); white-space: nowrap; }
h3.sub { font-family: var(--serif); font-weight: 500; font-size: 18px; color: var(--gold-soft); margin: 18px 0 8px; }
.ach { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.ach li { border: 1px dashed var(--line); border-radius: 8px; padding: 7px 10px; display: flex; flex-direction: column; opacity: 0.7; }
.ach li.got { border: 1px solid var(--gold); background: rgba(226, 169, 61, 0.1); opacity: 1; }
.ach b { font-family: var(--serif); font-weight: 500; font-size: 14px; }
.ach li.got b::before { content: "★ "; color: var(--gold); }
.ach span { font-size: 11px; color: var(--muted); }
.modal-foot { font-size: 11.5px; color: var(--muted); margin: 14px 0 0; }
button.link { background: none; border: 0; padding: 0; color: var(--gold-soft); text-decoration: underline dotted; cursor: pointer; font-size: inherit; }

@media (max-width: 720px) {
  .hud { gap: 3px; }
  .hud-row { grid-template-columns: 44px 1fr auto; font-size: 10.5px; gap: 6px; }
  .hud-v { min-width: 44px; }
  .clock { width: 230px; }
  .clock-meta { display: none; }
  .event-photo img { max-height: 130px; }
  .facts { grid-template-columns: 1fr 1fr; gap: 4px; }
  .facts b { font-size: 13px; }
  .toasts { right: 10px; left: 10px; bottom: 150px; align-items: stretch; }
  .app.mission-on .toasts { bottom: 200px; }
  .toast { max-width: none; }
  .mission { top: auto; bottom: 108px; left: 10px; right: 10px; width: auto; padding: 8px 12px; }
  .app.mission-on .nav { display: none; }
  .mission b { font-size: 15px; }
  .mission-btns { margin-top: 6px; }
  .nav { flex-wrap: wrap; justify-content: flex-end; max-width: calc(100vw - 20px); }
  .nav button { padding: 6px 9px; font-size: 11.5px; }
}
