/* Borders of Time: antique atlas at night. No webfonts, no third-party assets. */
:root {
  --ink: #07111f;
  --ink-2: #0c1b2f;
  --panel: rgba(9, 19, 34, 0.88);
  --panel-solid: #0b1829;
  --line: rgba(231, 214, 170, 0.18);
  --line-2: rgba(231, 214, 170, 0.34);
  --text: #f1e8d0;
  --muted: #a9a08a;
  --brass: #e2b857;
  --brass-hi: #ffd470;
  --danger: #ff7a45;
  --thumb: 26px;
  --tl-h: 168px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  background: radial-gradient(120% 90% at 50% 40%, #0e2038 0%, #07111f 60%, #040a14 100%);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
a { color: var(--brass-hi); }
kbd {
  font: 600 11px/1 var(--sans);
  padding: 2px 6px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 8px; top: -60px; z-index: 100; padding: 8px 12px;
  background: var(--brass); color: #1a1405; border-radius: 8px; text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 8px; }
:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 2px; }
.muted { color: var(--muted); }
.noscript { position: fixed; inset: 40% 10% auto; text-align: center; z-index: 100; }

#map { position: fixed; inset: 0; background: transparent; }
.maplibregl-canvas { outline: none; }
.maplibregl-ctrl-top-left { top: 64px; left: 6px; }
.maplibregl-ctrl-bottom-right { bottom: var(--tl-h); }
.maplibregl-ctrl-group {
  background: var(--panel) !important; border: 1px solid var(--line); border-radius: 10px !important;
  box-shadow: none !important; backdrop-filter: blur(8px);
}
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--line) !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(0.9) sepia(0.4); }
.maplibregl-ctrl-attrib {
  background: rgba(7, 17, 31, 0.7) !important; color: var(--muted) !important; font-size: 11px;
  border-radius: 10px 0 0 0;
}
.maplibregl-ctrl-attrib a { color: var(--brass-hi) !important; }
.maplibregl-ctrl-attrib-button { filter: invert(0.85); }

/* ------------------------------------------------------------ loading */
.loading {
  position: fixed; inset: 0; z-index: 90; display: grid; place-content: center; gap: 14px; justify-items: center;
  background: radial-gradient(120% 90% at 50% 40%, #0e2038 0%, #07111f 70%); transition: opacity 0.7s ease, visibility 0.7s;
  font-family: var(--serif); font-size: 18px; letter-spacing: 0.04em; color: var(--muted);
}
.loading.done { opacity: 0; visibility: hidden; pointer-events: none; }
.loading p { margin: 0; }
.loading-ring {
  width: 54px; height: 54px; border-radius: 50%; border: 2px dashed var(--brass); animation: spin 6s linear infinite;
  box-shadow: inset 0 0 18px rgba(226, 184, 87, 0.25);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ top bar */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 10px 14px; pointer-events: none;
  background: linear-gradient(to bottom, rgba(5, 11, 21, 0.78), rgba(5, 11, 21, 0));
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { flex: none; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5)); }
.brand-text h1 {
  margin: 0; font-family: var(--serif); font-weight: 600; font-size: 22px; letter-spacing: 0.02em; line-height: 1.1;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}
.brand-text p { margin: 1px 0 0; font-size: 12px; color: var(--muted); text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7); }
.tools { display: flex; gap: 8px; flex: none; }
.tool {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 19px; backdrop-filter: blur(8px);
  font-size: 13px; font-weight: 500; transition: background 0.15s, border-color 0.15s;
}
.tool:hover { border-color: var(--line-2); background: rgba(20, 38, 64, 0.92); }
.tool[aria-expanded="true"] { border-color: var(--brass); }
.tool svg, .icon-btn svg {
  width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ------------------------------------------------------------ timeline */
.timeline {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 12px clamp(14px, 2.6vw, 34px) calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(5, 11, 21, 0.97) 60%, rgba(7, 17, 31, 0.86));
  border-top: 1px solid var(--line); backdrop-filter: blur(12px);
}
.tl-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; }
.tl-readout { min-width: 0; }
.year-big {
  font-family: var(--serif); font-weight: 500; font-size: clamp(30px, 5.4vw, 58px); line-height: 1; letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums; text-shadow: 0 0 28px rgba(226, 184, 87, 0.25); white-space: nowrap;
}
.year-sub { margin-top: 5px; font-size: 12.5px; color: var(--muted); }
.tl-controls { display: flex; align-items: center; gap: 12px; flex: none; }
.play {
  width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--brass); cursor: pointer; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #35507a, #14253f); transition: transform 0.12s, background 0.15s;
}
.play:hover { transform: scale(1.06); background: radial-gradient(circle at 35% 30%, #44649a, #1a3050); }
.play svg { width: 22px; height: 22px; fill: var(--brass-hi); }
.play[data-state="paused"] .i-pause, .play[data-state="playing"] .i-play { display: none; }
.speeds { display: inline-flex; border: 1px solid var(--line-2); border-radius: 18px; overflow: hidden; }
.speed {
  border: 0; background: transparent; padding: 7px 11px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--muted);
  min-width: 38px;
}
.speed + .speed { border-left: 1px solid var(--line); }
.speed[aria-pressed="true"] { background: rgba(226, 184, 87, 0.2); color: var(--brass-hi); }

.tl-track { position: relative; height: 84px; margin-top: 6px; }
.tl-marks { position: absolute; left: 0; right: 0; top: 0; height: 14px; }
.tl-mark {
  position: absolute; top: 0; transform: translateX(-50%); font-size: 10.5px; color: var(--muted); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.tl-rail {
  position: absolute; top: 31px; left: calc(var(--thumb) / 2); right: calc(var(--thumb) / 2); height: 4px; border-radius: 2px;
  background: rgba(231, 214, 170, 0.2);
}
.tl-progress {
  height: 100%; width: calc(var(--f, 0) * 100%); background: linear-gradient(90deg, #7a5f23, var(--brass)); border-radius: 2px;
}
.tl-ticks { position: absolute; left: 0; right: 0; top: 24px; height: 18px; pointer-events: none; }
.tl-tick {
  position: absolute; top: 3px; width: 1px; height: 12px; background: rgba(231, 214, 170, 0.5); transform: translateX(-50%);
}
.tl-tick.shown { background: var(--brass-hi); top: 0; height: 18px; width: 2px; }
.tl-dots { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.tl-dot {
  position: absolute; top: 22px; width: 10px; height: 10px; padding: 0; border-radius: 50%; transform: translateX(-50%);
  background: var(--brass-hi); border: 2px solid #0a1424; cursor: pointer; pointer-events: auto;
  box-shadow: 0 0 0 1px rgba(255, 212, 112, 0.65);
}
.tl-dot.imp-3 { width: 13px; height: 13px; top: 20px; background: #ffb066; box-shadow: 0 0 8px rgba(255, 160, 80, 0.85), 0 0 0 1px rgba(255, 180, 100, 0.9); }
.tl-dot:hover { transform: translateX(-50%) scale(1.5); z-index: 2; }
.tl-range {
  -webkit-appearance: none; appearance: none; position: absolute; left: 0; right: 0; top: 20px; width: 100%; height: 30px;
  margin: 0; background: transparent; cursor: pointer; z-index: 3; touch-action: pan-y;
}
.tl-range:focus { outline: none; }
.tl-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--brass-hi), 0 2px 10px rgba(0, 0, 0, 0.6); }
.tl-range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--brass-hi), 0 2px 10px rgba(0, 0, 0, 0.6); }
.tl-range::-webkit-slider-runnable-track { height: 30px; background: transparent; }
.tl-range::-moz-range-track { height: 30px; background: transparent; }
.tl-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: var(--thumb); height: var(--thumb); margin-top: 2px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff1c2, var(--brass) 70%); border: 3px solid #0a1424;
  box-shadow: 0 0 0 2px var(--brass), 0 3px 12px rgba(0, 0, 0, 0.7);
}
.tl-range::-moz-range-thumb {
  width: calc(var(--thumb) - 6px); height: calc(var(--thumb) - 6px); border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff1c2, var(--brass) 70%); border: 3px solid #0a1424;
  box-shadow: 0 0 0 2px var(--brass), 0 3px 12px rgba(0, 0, 0, 0.7);
}
.tl-eras { position: absolute; left: 0; right: 0; top: 56px; height: 24px; }
.tl-era {
  position: absolute; top: 0; height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden;
  border-left: 1px solid rgba(7, 17, 31, 0.9); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(241, 232, 208, 0.82);
  white-space: nowrap; user-select: none;
}
.tl-era span { flex: none; }
.tl-era:first-child { border-left: 0; border-radius: 6px 0 0 6px; }
.tl-era:last-child { border-radius: 0 6px 6px 0; }
.era-paleo { background: #3a2f27; }
.era-neo { background: #3d4a2f; }
.era-bronze { background: #6a4a26; }
.era-iron { background: #4b3b5d; }
.era-medieval { background: #2f4a63; }
.era-early { background: #35536a; }
.era-modern { background: #2c5a52; }

/* ------------------------------------------------------------- legend */
.legend {
  position: fixed; left: 12px; bottom: calc(var(--tl-h) + 12px); z-index: 15; width: 292px;
  max-height: max(120px, calc(100dvh - var(--tl-h) - 160px)); display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(10px); overflow: hidden;
}
.legend-head {
  display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 10px 14px; border: 0; background: transparent;
  cursor: pointer; text-align: left;
}
.legend-title { font-family: var(--serif); font-size: 16px; letter-spacing: 0.03em; }
.chev { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; transition: transform 0.2s; }
.legend.collapsed .chev { transform: rotate(180deg); }
.legend-body { overflow: auto; padding: 0 14px 12px; overscroll-behavior: contain; }
.legend.collapsed .legend-body { display: none; }
.legend ul { list-style: none; margin: 0; padding: 0; }
.keys li { display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; line-height: 1.35; padding: 2px 0; color: #d9d0b8; }
.keys b { color: var(--text); font-weight: 600; }
.key { flex: 0 0 30px; height: 14px; margin-top: 2px; border-radius: 3px; }
.key-colour { background: linear-gradient(90deg, #4a74d3 0 25%, #e0a63c 25% 50%, #d56d82 50% 75%, #7d9d5c 75%); opacity: 0.85; }
.key-solid { height: 0; border-top: 2px solid #e9dcb8; margin-top: 8px; border-radius: 0; }
.key-dash { height: 0; border-top: 2px dashed #e9dcb8; margin-top: 8px; border-radius: 0; }
.key-contested {
  border: 1px dashed #ff8a50; background: repeating-linear-gradient(135deg, rgba(255, 112, 64, 0.95) 0 2px, rgba(255, 90, 42, 0.15) 2px 5px);
}
.key-land { background: #575141; border: 1px solid rgba(214, 196, 150, 0.35); }
.legend-sub {
  margin: 10px 0 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.12em; color: var(--brass);
}
.powers li + li { margin-top: 2px; }
.power {
  display: grid; grid-template-columns: 16px 1fr auto; align-items: center; gap: 9px; width: 100%; padding: 4px 8px; text-align: left;
  border: 1px solid transparent; border-radius: 8px; background: transparent; cursor: pointer; font-size: 12.5px;
}
.power:hover { background: rgba(255, 255, 255, 0.06); }
.power[aria-pressed="true"] { border-color: var(--brass); background: rgba(226, 184, 87, 0.12); }
.power-name { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.25; overflow-wrap: anywhere; }
.power-area { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); }
.legend-hint { margin: 8px 0 0; font-size: 11.5px; color: var(--muted); }

/* ------------------------------------------------------------- panels */
.panel, .popover {
  position: fixed; z-index: 25; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); backdrop-filter: blur(12px); box-shadow: 0 14px 50px rgba(0, 0, 0, 0.55); outline: none;
}
.panel { top: 64px; right: 12px; bottom: auto; max-height: calc(100dvh - var(--tl-h) - 78px); width: min(400px, calc(100vw - 24px)); }
.about-panel { width: min(520px, calc(100vw - 24px)); }
.popover { top: 64px; right: 12px; width: min(380px, calc(100vw - 24px)); max-height: calc(100dvh - var(--tl-h) - 90px); }
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px 14px 10px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-titles { min-width: 0; }
.panel h2 { margin: 2px 0 0; font-family: var(--serif); font-size: 24px; font-weight: 600; line-height: 1.15; overflow-wrap: anywhere; }
.panel h3 { margin: 18px 0 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.12em; color: var(--brass); }
.kicker { margin: 0; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.12em; color: var(--brass); }
.panel-body { overflow: auto; padding: 14px 18px 18px; overscroll-behavior: contain; flex: 1; }
.icon-btn {
  flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line);
  background: transparent; cursor: pointer; color: var(--muted);
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 4px 0 0; }
.facts dt { color: var(--muted); font-size: 12.5px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.cert { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 2px; vertical-align: -1px; }
.cert-1 { background: transparent; border: 2px dashed #e9dcb8; }
.cert-2 { background: transparent; border: 2px dotted #e9dcb8; }
.cert-3 { background: #e9dcb8; }
.note {
  margin: 0 0 12px; padding: 9px 11px; font-size: 12.5px; border-radius: 8px; background: rgba(127, 179, 217, 0.1);
  border: 1px solid rgba(127, 179, 217, 0.25);
}
.note.warn { background: rgba(255, 122, 69, 0.1); border-color: rgba(255, 122, 69, 0.35); }
.event-text { margin: 0 0 8px; font-size: 14.5px; line-height: 1.55; }
.wiki-row { margin: 14px 0 0; }
.near, .claimants { list-style: none; padding: 0; margin: 0; }
.near li + li { margin-top: 4px; }
.claimants li { padding: 4px 0 4px 14px; position: relative; }
.claimants li::before { content: ""; position: absolute; left: 0; top: 11px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }
.linkish { background: none; border: 0; padding: 2px 0; cursor: pointer; text-align: left; color: #e8dcc0; }
.linkish:hover { color: var(--brass-hi); text-decoration: underline; }
.btn {
  border: 1px solid var(--line-2); background: rgba(255, 255, 255, 0.05); padding: 8px 16px; border-radius: 10px; cursor: pointer;
  font-weight: 500;
}
.btn:hover:not(:disabled) { border-color: var(--brass); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-primary { background: var(--brass); color: #1b1505; border-color: var(--brass); font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--brass-hi); }
.prose p, .prose li { font-size: 13.5px; line-height: 1.55; }
.prose ul { padding-left: 18px; margin: 6px 0; }
.prose li + li { margin-top: 6px; }
.sources { list-style: none; padding-left: 0 !important; }

.tours-list { list-style: none; margin: 0; padding: 10px; overflow: auto; }
.tours-list li + li { margin-top: 6px; }
.tour-item {
  display: grid; gap: 2px; width: 100%; padding: 11px 14px; text-align: left; cursor: pointer; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03);
}
.tour-item:hover { border-color: var(--brass); background: rgba(226, 184, 87, 0.08); }
.tour-item-title { font-family: var(--serif); font-size: 17px; }
.tour-item-sub { font-size: 12.5px; color: #d9d0b8; }
.tour-item-meta { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }

.tour-card {
  position: fixed; z-index: 24; left: 50%; bottom: calc(var(--tl-h) + 14px); transform: translateX(-50%);
  width: min(560px, calc(100vw - 24px)); padding: 14px 18px 14px; background: var(--panel); border: 1px solid var(--brass);
  border-radius: var(--radius); backdrop-filter: blur(12px); box-shadow: 0 14px 50px rgba(0, 0, 0, 0.55);
}
.tour-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.tour-card h2 { margin: 2px 0 0; font-family: var(--serif); font-size: 19px; font-weight: 600; }
.tour-caption { margin: 8px 0 12px; font-size: 14.5px; line-height: 1.55; }
.tour-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tour-count { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

.toast {
  position: fixed; z-index: 40; top: 64px; left: 50%; transform: translateX(-50%); width: min(470px, calc(100vw - 24px));
  padding: 14px 44px 14px 18px; background: rgba(14, 26, 44, 0.96); border: 1px solid var(--brass); border-radius: var(--radius);
  box-shadow: 0 14px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(226, 184, 87, 0.2); pointer-events: auto;
}
.toast.in { animation: toast-in 0.4s cubic-bezier(0.2, 0.9, 0.3, 1); }
.toast h2 { margin: 2px 0 4px; font-family: var(--serif); font-size: 18px; font-weight: 600; }
.toast p { margin: 0; }
.toast #toast-text { font-size: 13.5px; color: #e4dac0; }
.toast .icon-btn { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; }
/* a failure that stays until dismissed: above the event toast, with a Retry button */
.notice {
  position: fixed; z-index: 45; top: 64px; left: 50%; transform: translateX(-50%); width: min(470px, calc(100vw - 24px));
  padding: 12px 14px 12px 18px; align-items: center; gap: 12px; background: rgba(40, 16, 14, 0.97); border: 1px solid #e08a6a;
  border-radius: var(--radius); box-shadow: 0 14px 50px rgba(0, 0, 0, 0.6);
}
.notice:not([hidden]) { display: flex; }
.notice p { margin: 0; flex: 1; font-size: 14px; line-height: 1.45; }
.notice .btn { flex: none; }
.notice .icon-btn { flex: none; width: 30px; height: 30px; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -14px); } to { opacity: 1; transform: translate(-50%, 0); } }

.tooltip {
  position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; max-width: 280px; padding: 5px 10px;
  background: rgba(7, 15, 27, 0.95); border: 1px solid var(--line-2); border-radius: 7px; font-size: 12.5px; font-weight: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ------------------------------------------------------ event markers */
.ev-marker { position: relative; width: 26px; height: 26px; padding: 0; border: 0; background: none; cursor: pointer; }
.ev-dot {
  position: absolute; inset: 8px; border-radius: 50%; background: var(--brass-hi); border: 2px solid #07111f;
  box-shadow: 0 0 8px rgba(255, 212, 112, 0.9);
}
.ev-marker.imp-3 .ev-dot { inset: 6px; background: #ffb066; box-shadow: 0 0 10px rgba(255, 150, 70, 0.95); }
.ev-pulse {
  position: absolute; inset: 3px; border-radius: 50%; border: 2px solid rgba(255, 212, 112, 0.85); animation: pulse 2.2s ease-out infinite;
}
.ev-marker.imp-3 .ev-pulse { border-color: rgba(255, 160, 80, 0.9); }
.ev-marker:hover .ev-dot, .ev-marker:focus-visible .ev-dot { transform: scale(1.35); }
@keyframes pulse { 0% { transform: scale(0.6); opacity: 0.95; } 100% { transform: scale(2.1); opacity: 0; } }

/* ----------------------------------------------------------- responsive */
@media (max-width: 720px) {
  :root { --thumb: 28px; }
  .topbar { padding: 8px 10px; }
  .brand-mark { width: 26px; height: 26px; }
  .brand-text h1 { font-size: 17px; }
  .brand-text p { display: none; }
  .tool { width: 40px; height: 40px; padding: 0; justify-content: center; border-radius: 50%; }
  .tool span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .maplibregl-ctrl-top-left { top: 58px; }
  .maplibregl-ctrl-group button { width: 34px; height: 34px; }
  .timeline { padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); }
  .year-big { font-size: clamp(26px, 8.4vw, 36px); }
  .year-sub { font-size: 11.5px; margin-top: 3px; }
  .tl-controls { gap: 8px; }
  .play { width: 42px; height: 42px; }
  .speed { padding: 6px 8px; min-width: 32px; font-size: 12px; }
  .tl-track { height: 78px; }
  .tl-mark.hide-sm { display: none; }
  .tl-dot.imp-2 { display: none; } /* keep the 366px track readable: only the big moments */
  .legend { left: 8px; width: min(310px, calc(100vw - 16px)); max-height: 46dvh; }
  .legend.collapsed { width: auto; }
  .legend-head { gap: 10px; }
  .panel, .popover {
    top: auto; left: 0; right: 0; bottom: var(--tl-h); width: auto; max-height: 50dvh; border-radius: 16px 16px 0 0; border-bottom: 0;
  }
  .about-panel { width: auto; }
  .tour-card { bottom: calc(var(--tl-h) + 8px); width: calc(100vw - 16px); }
  html[data-panel] .tour-card { display: none; }
  html[data-panel] .legend { display: none; }
  .toast, .notice { top: 56px; }
}
@media (max-width: 380px) {
  .tl-controls .speeds { display: none; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .year-big { font-size: 28px; }
  .tl-track { height: 52px; }
  .tl-eras { display: none; } /* the era bands cost 24 px a phone held sideways cannot spare */
  .timeline { padding-top: 8px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  .ev-pulse, .loading-ring, .toast.in { animation: none; }
  .loading { transition: none; }
}
