:root {
  --ink: #f4f1ea;
  --ink-soft: rgba(244, 241, 234, 0.72);
  --ink-faint: rgba(244, 241, 234, 0.45);
  --space: #03050b;
  --glass: rgba(10, 14, 26, 0.58);
  --glass-strong: rgba(10, 14, 26, 0.78);
  --line: rgba(255, 255, 255, 0.12);
  --accent: #ffb86b;          /* sunrise amber */
  --accent-2: #7fd4ff;        /* atmosphere blue */
  --beacon: #ffcf8a;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(.2, .7, .1, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--space);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* ---------- Space & map ---------- */
#stars, #map, .vignette { position: fixed; inset: 0; }
#stars { width: 100%; height: 100%; z-index: 0; transition: opacity 2s; }
#map { z-index: 1; background: transparent; }
.maplibregl-canvas { outline: none; }
.vignette {
  z-index: 2; pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55) 100%),
    linear-gradient(to bottom, rgba(0,0,0,.35), transparent 18%, transparent 70%, rgba(0,0,0,.45));
}
.maplibregl-ctrl-attrib { background: rgba(0,0,0,.35) !important; color: var(--ink-faint); font-size: 10px; }
.maplibregl-ctrl-attrib a { color: var(--ink-soft) !important; }
.maplibregl-ctrl-attrib-button { filter: invert(1); }
.maplibregl-ctrl-bottom-right { z-index: 3; }

/* ---------- Intro ---------- */
.intro {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-content: center; text-align: center; gap: 10px;
  padding: 24px; pointer-events: none;
  transition: opacity 1.6s var(--ease), transform 2.4s var(--ease), filter 1.6s;
}
.intro.gone { opacity: 0; transform: scale(1.08); filter: blur(6px); }
.eyebrow {
  margin: 0; font-size: 11px; letter-spacing: .32em; text-transform: uppercase; color: var(--ink-faint);
  animation: rise 1.6s .2s var(--ease) both;
}
.wordmark {
  margin: 0; font-family: var(--serif); font-weight: 300;
  font-size: clamp(56px, 13vw, 148px); letter-spacing: -0.035em; line-height: .95;
  background: linear-gradient(180deg, #fff 30%, #ffd9a8 75%, #ff9f5a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 60px rgba(255, 184, 107, .15);
  animation: rise 2s .35s var(--ease) both;
}
.tagline {
  margin: 4px 0 0; font-family: var(--serif); font-style: italic; font-weight: 300;
  font-size: clamp(17px, 2.4vw, 22px); color: var(--ink-soft);
  animation: rise 2s .7s var(--ease) both;
}
.status {
  margin: 28px 0 0; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 13px; color: var(--ink-faint); letter-spacing: .04em;
  animation: rise 2s 1.1s var(--ease) both;
}
.pulse-dot, .signal-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0 rgba(255,184,107,.6); animation: ping 1.8s infinite;
}
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(255,184,107,.55); } 80%,100% { box-shadow: 0 0 0 12px rgba(255,184,107,0); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- HUD top ---------- */
.hud-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 8;
  display: flex; align-items: center; gap: 16px;
  padding: max(16px, env(safe-area-inset-top)) 20px 16px;
  pointer-events: none; opacity: 0; transition: opacity 1.4s 0.6s;
}
body.flying .hud-top, body.landed .hud-top { opacity: 1; }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--serif); font-size: 18px; color: var(--ink); }
.brand svg { color: var(--accent); }
.signal {
  display: flex; align-items: center; gap: 8px; margin-left: auto;
  font-size: 12px; color: var(--ink-soft); padding: 6px 12px; border-radius: 99px;
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(12px);
}
.signal.precise .signal-dot { background: #7dffb0; animation: none; box-shadow: 0 0 10px #7dffb0; }
.coords { font-size: 12px; color: var(--ink-soft); padding: 6px 12px; border-radius: 99px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(12px); }

/* ---------- Title card ---------- */
.title-card {
  position: fixed; left: 0; right: 0; top: 20vh; z-index: 7; text-align: center; pointer-events: none;
  padding: 0 16px;
}
.title-kicker {
  margin: 0 0 6px; font-size: 11px; letter-spacing: .34em; text-transform: uppercase; color: var(--accent);
  text-shadow: 0 1px 12px rgba(0,0,0,.8);
}
.title-main {
  margin: 0; font-family: var(--serif); font-weight: 300; font-size: clamp(36px, 7vw, 84px);
  letter-spacing: -0.03em; line-height: 1; text-shadow: 0 2px 30px rgba(0,0,0,.65), 0 0 2px rgba(0,0,0,.6);
}
.title-card .title-kicker, .title-card .title-main { opacity: 0; transform: translateY(10px); filter: blur(8px); transition: all 1.1s var(--ease); }
.title-card.show .title-kicker, .title-card.show .title-main { opacity: 1; transform: none; filter: none; }
.title-card.show .title-main { transition-delay: .12s; }

.milestone {
  position: fixed; left: 50%; bottom: calc(120px + var(--safe-b)); z-index: 7; transform: translateX(-50%);
  font-size: 13px; color: var(--ink-soft); letter-spacing: .03em; text-align: center; max-width: calc(100% - 32px);
  padding: 8px 16px; border-radius: 99px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(12px);
  opacity: 0; transition: opacity .8s, transform .8s var(--ease); pointer-events: none;
}
.milestone.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* ---------- Altimeter ---------- */
.altimeter {
  position: fixed; left: 22px; top: 50%; transform: translateY(-50%); z-index: 6;
  display: flex; align-items: center; gap: 14px; pointer-events: none;
  opacity: 0; transition: opacity 1.2s;
}
body.flying .altimeter, body.landed .altimeter { opacity: 1; }
.alt-track { position: relative; width: 2px; height: min(52vh, 440px); background: linear-gradient(to bottom, rgba(127,212,255,.0), rgba(127,212,255,.45) 15%, rgba(255,184,107,.55) 85%, rgba(255,184,107,0)); }
.alt-marks { position: absolute; inset: 0; }
.alt-mark { position: absolute; left: 8px; transform: translateY(-50%); font-size: 10px; color: var(--ink-faint); white-space: nowrap; letter-spacing: .04em; transition: color .6s; }
.alt-mark::before { content: ""; position: absolute; left: -12px; top: 50%; width: 6px; height: 1px; background: var(--ink-faint); }
.alt-mark.passed { color: var(--ink-soft); }
.alt-needle { position: absolute; left: -5px; width: 12px; height: 12px; transform: translateY(-50%); }
.alt-needle span { display: block; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px var(--accent), 0 0 0 4px rgba(255,184,107,.18); }
.alt-readout { display: flex; flex-direction: column; position: absolute; left: 0; bottom: -54px; white-space: nowrap; }
.alt-readout .label { font-size: 10px; letter-spacing: .3em; text-transform: uppercase; color: var(--ink-faint); }
.alt-readout .value { font-size: 18px; color: var(--ink); }

/* ---------- Beacon marker ---------- */
.beacon { position: relative; width: 22px; height: 22px; pointer-events: none; }
.beacon .core { position: absolute; inset: 5px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px var(--beacon), 0 0 22px 6px rgba(255,207,138,.85); }
.beacon .ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--beacon); animation: beacon 3s infinite var(--ease); opacity: 0; }
.beacon .ring:nth-child(2) { animation-delay: 1s; }
.beacon .ring:nth-child(3) { animation-delay: 2s; }
@keyframes beacon { 0% { transform: scale(.6); opacity: .9; } 100% { transform: scale(6); opacity: 0; } }
.beacon-inner { position: absolute; inset: 0; }
.beacon-inner.arrive { animation: arrive 1.4s var(--ease) both; }
@keyframes arrive { from { transform: scale(0); } 60% { transform: scale(1.5); } to { transform: scale(1); } }

/* ---------- Landing card ---------- */
.card {
  position: fixed; z-index: 9; right: 20px; bottom: calc(96px + var(--safe-b));
  width: min(400px, calc(100vw - 32px));
  padding: 22px 22px 18px; border-radius: 22px;
  background: var(--glass-strong); border: 1px solid var(--line);
  backdrop-filter: blur(22px) saturate(140%); -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: 0 30px 80px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.06);
  animation: cardIn 1.2s var(--ease) both;
}
.card[hidden] { display: none; }
@keyframes cardIn { from { opacity: 0; transform: translateY(24px) scale(.98); } to { opacity: 1; transform: none; } }
.card-handle { display: none; }
.card-kicker { margin: 0; font-size: 11px; letter-spacing: .3em; text-transform: uppercase; color: var(--accent); }
.card-place { margin: 6px 0 2px; font-family: var(--serif); font-weight: 400; font-size: 30px; letter-spacing: -0.02em; line-height: 1.1; }
.card-sub { margin: 0 0 16px; color: var(--ink-soft); font-size: 14px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; border-radius: 14px; overflow: hidden; background: var(--line); }
.fact { background: rgba(10,14,26,.6); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fact .k, .antipode .k { font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-faint); }
.fact .v { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.poem { margin: 16px 2px 0; font-family: var(--serif); font-style: italic; font-weight: 300; font-size: 15.5px; line-height: 1.55; color: var(--ink-soft); }
.poem b { font-style: normal; font-weight: 500; color: var(--ink); font-family: var(--mono); font-size: 13.5px; }
.precision { margin-top: 16px; display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 14px; background: rgba(255,184,107,.08); border: 1px solid rgba(255,184,107,.25); }
.precision[hidden] { display: none; }
.precision-text { display: flex; flex-direction: column; font-size: 12.5px; color: var(--ink-soft); line-height: 1.4; }
.precision-text strong { color: var(--ink); font-weight: 600; font-size: 13px; }
.antipode { margin-top: 14px; display: flex; flex-direction: column; gap: 2px; }
.antipode[hidden] { display: none; }
.link { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; color: var(--accent-2); font-size: 14px; }
.link:hover { text-decoration: underline; }

.btn { border: 0; cursor: pointer; border-radius: 99px; padding: 9px 16px; font-weight: 600; font-size: 13px; white-space: nowrap; transition: transform .2s, filter .2s; }
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-accent { background: linear-gradient(135deg, #ffcf8a, #ff9b55); color: #23140a; }

/* ---------- Dock ---------- */
.dock {
  position: fixed; z-index: 9; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translateX(-50%);
  display: flex; gap: 2px; padding: 6px; border-radius: 20px;
  background: var(--glass-strong); border: 1px solid var(--line);
  backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
  animation: dockIn 1s .3s var(--ease) both; max-width: calc(100vw - 32px);
}
.dock[hidden] { display: none; }
@keyframes dockIn { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }
.dock-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 58px;
  padding: 8px 8px 6px; border: 0; border-radius: 14px; background: transparent; cursor: pointer;
  color: var(--ink-soft); font-size: 10.5px; letter-spacing: .03em; transition: background .2s, color .2s;
}
.dock-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.dock-btn:hover { background: rgba(255,255,255,.07); color: var(--ink); }
.dock-btn[aria-pressed="true"] { color: var(--accent); background: rgba(255,184,107,.1); }
.dock-btn:focus-visible, .btn:focus-visible, .link:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
#btn-sound[aria-pressed="false"] .wave { opacity: .25; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 20; left: 50%; top: 76px; transform: translate(-50%, -10px);
  padding: 10px 18px; border-radius: 99px; background: var(--glass-strong); border: 1px solid var(--line);
  backdrop-filter: blur(16px); font-size: 13px; opacity: 0; pointer-events: none; transition: all .5s var(--ease);
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- About ---------- */
.about {
  border: 1px solid var(--line); border-radius: 22px; padding: 28px; max-width: min(480px, calc(100vw - 32px));
  background: rgba(12, 16, 28, .92); color: var(--ink); backdrop-filter: blur(20px);
  box-shadow: 0 40px 120px rgba(0,0,0,.6);
}
.about::backdrop { background: rgba(0,0,0,.5); backdrop-filter: blur(3px); }
.about h2 { margin: 0 0 4px; font-family: var(--serif); font-weight: 300; font-size: 34px; }
.about h3 { margin: 18px 0 4px; font-size: 11px; letter-spacing: .25em; text-transform: uppercase; color: var(--accent); }
.about p { margin: 0; color: var(--ink-soft); font-size: 14px; }
.about .btn { margin-top: 22px; }
kbd { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: var(--ink); }

/* ---------- Small screens ---------- */
@media (max-width: 720px) {
  .coords { display: none; }
  .hud-top { padding-left: 16px; padding-right: 16px; }
  .altimeter { left: 14px; }
  .alt-track { height: 34vh; }
  .alt-mark { font-size: 9px; }
  .title-card { top: 16vh; }
  .card {
    left: 16px; right: 16px; width: auto; bottom: calc(86px + var(--safe-b));
    padding: 10px 18px 16px; max-height: 58vh; overflow-y: auto;
  }
  .card-handle { display: block; width: 100%; height: 18px; background: none; border: 0; cursor: pointer; padding: 0; margin-bottom: 6px; }
  .card-handle span { display: block; width: 38px; height: 4px; margin: 0 auto; border-radius: 4px; background: var(--ink-faint); }
  .card.collapsed .card-body, .card.collapsed .card-sub { display: none; }
  .card-place { font-size: 24px; }
  .dock { left: 16px; right: 16px; bottom: calc(30px + var(--safe-b)); transform: none; justify-content: space-between; animation: none; }
  .card { bottom: calc(100px + var(--safe-b)); }
  .card.collapsed { padding-bottom: 12px; }
  .dock-btn { min-width: 0; flex: 1; padding: 8px 2px 6px; }
  .milestone { bottom: calc(96px + var(--safe-b)); }
  body.landed .altimeter { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .3s !important; }
}
.alt-mark[hidden] { display: none; }
