:root {
  --bg: #ffffff;
  --surface: #fafafb;
  --ink: #111114;
  --muted: #66666e;
  --line: #e4e4e9;
  --fog: #ececf0;
  --fog-line: #d9d9e0;
  --purple: #4b1f6f;
  --purple-ink: #ffffff;
  --purple-soft: #f1ebf6;
  --amber: #8a5a00;
  --amber-soft: #fff4dc;
  --radius: 14px;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", var(--font-body);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--font-body);
}
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; border-radius: 6px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(255,255,255,.94); backdrop-filter: blur(8px); z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 50%; background: var(--purple); box-shadow: 0 0 0 4px var(--purple-soft); }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.topnav { display: flex; gap: 18px; font-weight: 500; font-size: 15px; }
.topnav a { text-decoration: none; color: var(--muted); }
.topnav a:hover, .topnav a[aria-current="page"] { color: var(--ink); }

.preview-banner {
  background: var(--amber-soft); color: var(--amber); font-size: 13px; text-align: center; padding: 6px 16px;
}

main { max-width: 1080px; margin: 0 auto; padding: 24px 16px 48px; outline: none; }
.loading { color: var(--muted); }

h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.02em; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(32px, 6vw, 56px); font-weight: 700; }
h2 { font-size: 22px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 700; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--purple); margin: 0 0 8px; }
.muted { color: var(--muted); }

/* ---------- Hero + search ---------- */
.hero { padding: 24px 0 8px; }
.hero h1 .accent { color: var(--purple); }
.hero p.lede { font-size: 18px; color: var(--muted); max-width: 560px; margin: 14px 0 22px; }

.search { position: relative; max-width: 620px; }
.search input {
  width: 100%; font-size: 17px; padding: 16px 18px 16px 48px;
  border: 2px solid var(--ink); border-radius: 999px; background: var(--bg);
}
.search input:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 4px var(--purple-soft); }
.search svg { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--muted); }
.results {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 10;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(17,17,20,.12); list-style: none; margin: 0; padding: 6px; max-height: 360px; overflow: auto;
}
.results[hidden] { display: none; }
.results li a {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 10px; text-decoration: none;
}
.results li a:hover, .results li a.active { background: var(--purple-soft); }
.results .r-title { font-weight: 600; }
.results .r-meta { font-size: 13px; color: var(--muted); white-space: nowrap; }
.results .empty { padding: 12px 14px; color: var(--muted); }

/* ---------- Layout ---------- */
.grid-2 { display: grid; gap: 20px; grid-template-columns: 1fr; margin-top: 32px; }
@media (min-width: 860px) { .grid-2 { grid-template-columns: 1.15fr 1fr; align-items: start; } }

.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; background: var(--bg); }
.card + .card { margin-top: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }

/* ---------- Stats + bars ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 28px; }
.stat { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat-value { font-family: var(--font-display); font-size: 28px; font-weight: 700; }
.stat-label { font-size: 13px; color: var(--muted); }

.bar { height: 10px; background: var(--fog); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--purple); border-radius: 999px; transition: width .4s ease; }
.bar.big { height: 14px; }
.bar-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.bar-row strong { color: var(--ink); font-weight: 600; }

/* ---------- Map ---------- */
.map-wrap { position: relative; }
.map { width: 100%; height: auto; display: block; border-radius: 10px; background: var(--surface); }
.map .land { fill: var(--bg); stroke: var(--ink); stroke-width: 3; }
.map .region { transition: opacity .6s ease; }
.map .fog { fill: url(#fog-hatch); }
.map .region.revealed .fog { opacity: 0; }
.map .region-label { font: 600 22px var(--font-body); fill: var(--muted); letter-spacing: .04em; text-transform: uppercase; opacity: 0; transition: opacity .6s ease; }
.map .region.revealed .region-label { opacity: 1; }
.map .road { fill: none; stroke: var(--fog-line); stroke-width: 6; stroke-linecap: round; }
.map .pin-done { fill: var(--muted); }
.map .pin-next { fill: var(--purple); }
.map .pin-pulse { fill: none; stroke: var(--purple); stroke-width: 3; transform-box: fill-box; transform-origin: center; animation: pulse 2s ease-out infinite; }
@keyframes pulse { from { transform: scale(.6); opacity: .9; } to { transform: scale(2.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .map .pin-pulse { animation: none; } }
.map-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); margin-top: 12px; }
.map-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.map-legend .l-next::before { background: var(--purple); }
.map-legend .l-done::before { background: var(--muted); }
.map-legend .l-fog::before { background: var(--fog); border: 1px solid var(--fog-line); border-radius: 2px; }
.map-note { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

/* ---------- Mission list ---------- */
.mission-list { list-style: none; margin: 0; padding: 0; }
.mission-list li + li { border-top: 1px solid var(--line); }
.mission-link { display: grid; grid-template-columns: 32px 1fr auto; gap: 12px; align-items: center; padding: 14px 4px; text-decoration: none; }
.mission-link:hover .m-title { color: var(--purple); }
.m-num { font-family: var(--font-display); font-weight: 700; color: var(--muted); text-align: center; }
.m-title { font-weight: 600; }
.m-sub { font-size: 13px; color: var(--muted); }
.m-score { width: 84px; }
.m-score .bar { height: 6px; }
.m-score small { display: block; text-align: right; font-size: 12px; color: var(--muted); margin-top: 4px; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; background: var(--fog); color: var(--muted); }
.tag.done { background: var(--ink); color: #fff; }
.tag.next { background: var(--purple); color: #fff; }
.tag.missable { background: var(--amber-soft); color: var(--amber); }

.toggle-row { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); margin: 10px 0 18px; }
.toggle-row input { width: 18px; height: 18px; accent-color: var(--purple); }

/* ---------- Mission page ---------- */
.back { display: inline-block; font-size: 14px; color: var(--muted); text-decoration: none; margin-bottom: 18px; }
.back:hover { color: var(--ink); }
.mission-head h1 { font-size: clamp(30px, 5vw, 46px); }
.mission-head .objective { font-size: 18px; color: var(--muted); margin: 10px 0 0; }
.mission-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.stop-sign {
  margin: 26px 0 0; padding: 18px 20px; border-radius: var(--radius);
  background: var(--purple); color: var(--purple-ink);
}
.stop-sign h2 { font-size: 20px; }
.stop-sign p { margin: 6px 0 14px; opacity: .85; }
.stop-sign .bar { background: rgba(255,255,255,.2); }
.stop-sign .bar > span { background: #fff; }
.stop-sign .bar-row, .stop-sign .bar-row strong { color: #fff; }

.checklist { list-style: none; margin: 0; padding: 0; }
.check-item { display: grid; grid-template-columns: 28px 1fr; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.check-item:last-child { border-bottom: 0; }
.check-item input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--purple); cursor: pointer; }
.check-item label { font-weight: 600; cursor: pointer; }
.check-item.ticked label { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--purple); }
.check-item .why { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.check-item .chips { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.spoiler-veil {
  margin-top: 6px; padding: 10px 12px; border: 1px dashed var(--fog-line); border-radius: 10px;
  background: var(--surface); font-size: 14px; color: var(--muted); cursor: pointer; text-align: left; width: 100%;
}
.spoiler-veil:hover { border-color: var(--purple); color: var(--purple); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px; border-radius: 999px; border: 2px solid var(--ink); background: var(--ink); color: #fff;
  font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--purple); border-color: var(--purple); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--purple-soft); border-color: var(--purple); color: var(--purple); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.linklike { background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; color: inherit; }

/* ---------- Video ---------- */
.video-box { aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: var(--ink); position: relative; }
.video-box iframe { width: 100%; height: 100%; border: 0; display: block; }
.video-gate {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: var(--ink); color: #fff; border: 0; cursor: pointer; text-align: center; padding: 16px;
}
.video-gate .play { width: 56px; height: 56px; border-radius: 50%; background: var(--purple); display: grid; place-items: center; }
.video-gate small { opacity: .7; }
.video-empty { aspect-ratio: 16 / 9; border-radius: 10px; border: 1px dashed var(--fog-line); display: grid; place-items: center; color: var(--muted); text-align: center; padding: 16px; background: var(--surface); }

/* ---------- Journeys ---------- */
.journeys { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.journey { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.journey h3 { margin-bottom: 4px; }
.journey p { margin: 0 0 12px; font-size: 14px; color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.stepper button {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-size: 20px; line-height: 1;
}
.stepper button:hover { border-color: var(--purple); color: var(--purple); }
.stepper output { font-family: var(--font-display); font-weight: 700; font-size: 18px; min-width: 72px; text-align: center; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 24px 16px 40px; text-align: center; font-size: 13px; color: var(--muted); }
.footer p { margin: 6px auto; max-width: 720px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 999px; font-size: 14px; z-index: 50;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
}

@media (max-width: 520px) {
  .stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat { padding: 12px; }
  .stat-value { font-size: 22px; }
  .topnav { gap: 14px; }
  .card { padding: 16px; }
}
