/* Lantern Walk — design system and screens (2026-11 rebuild).
   Tokens first, then base, components, screens. Light and dark via data-theme. */

:root {
  --bg: #f6f5f2; --surface: #ffffff; --surface-2: #eceae5;
  --ink: #16181d; --ink-2: #5b6170; --line: rgba(22, 24, 29, 0.12);
  --accent: #c2410c; --on-accent: #ffffff;
  --ok: #17603c; --ok-bg: #e1f3e8; --warn: #7a4d00; --warn-bg: #fbeed0; --err: #a3231b; --err-bg: #fde7e4;
  --r-s: 10px; --r-m: 16px; --r-l: 24px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px;
  --tap: 48px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --tabs-h: 58px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
[data-theme="dark"] {
  --bg: #0f1115; --surface: #191c23; --surface-2: #242832;
  --ink: #f1f2f4; --ink-2: #a2a9b6; --line: rgba(255, 255, 255, 0.14);
  --accent: #ff8a4c; --on-accent: #1a0d05;
  --ok: #7adba6; --ok-bg: #15352a; --warn: #f3c366; --warn-bg: #3a2e12; --err: #ff9a90; --err-bg: #401b18;
}

/* ─── Base ─── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: inherit; }
img { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.screen:focus { outline: none; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

#app { min-height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: calc(var(--safe-t) + var(--s-4)) var(--s-4) calc(var(--tabs-h) + var(--safe-b) + var(--s-5)); display: flex; flex-direction: column; gap: var(--s-4); }
.icon { display: inline-flex; flex: none; }

/* ─── Type ─── */
.page-title { font-size: 1.75rem; line-height: 1.15; letter-spacing: -0.02em; font-weight: 700; }
.page-sub, .lead { color: var(--ink-2); }
.lead { font-size: 1.05rem; }
.section-title { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-2); margin-top: var(--s-4); }
.eyebrow { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--accent); }
.note { font-size: 0.9rem; color: var(--ink-2); }
.note--ok { color: var(--ok); } .note--warn { color: var(--warn); } .note--center { text-align: center; margin-top: var(--s-5); }
.credit { font-size: 0.78rem; color: var(--ink-2); }
.page-head { display: grid; gap: var(--s-1); padding-top: var(--s-2); }
.stack { display: grid; gap: var(--s-4); }
.pad { padding: var(--s-4); display: grid; gap: var(--s-3); align-content: start; }

/* ─── Controls ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap); padding: 0 var(--s-5); border: 0; border-radius: 999px;
  font-weight: 600; font-size: 1rem; text-decoration: none; cursor: pointer; text-align: center;
}
.btn--block { width: 100%; }
.btn--primary { background: var(--ink); color: var(--bg); }
.btn--quiet { background: var(--surface-2); color: var(--ink); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; }
.linkbtn { display: inline-flex; align-items: center; gap: var(--s-2); min-height: var(--tap); padding: 0; border: 0; background: none; color: var(--ink-2); font-weight: 600; font-size: 0.95rem; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.linkbtn--center { justify-content: center; width: 100%; }
.icon-btn {
  width: 44px; height: 44px; flex: none; display: inline-grid; place-items: center;
  border: 0; border-radius: 50%; background: var(--surface-2); color: var(--ink); cursor: pointer; text-decoration: none;
}
.icon-btn--ghost { background: none; }
.icon-btn--solid { background: var(--ink); color: var(--bg); width: 48px; height: 48px; }
.icon-btn--float { position: absolute; top: calc(var(--safe-t) + var(--s-3)); left: var(--s-3); background: var(--surface); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25); }
.field {
  width: 100%; min-height: var(--tap); padding: var(--s-3) var(--s-4);
  border: 1.5px solid var(--line); border-radius: var(--r-s); background: var(--surface); color: var(--ink);
  font-size: 1rem;   /* 16px or more: iOS does not zoom on focus */
}
.field:focus { outline: none; border-color: var(--ink); }
textarea.field { resize: vertical; line-height: 1.4; }
.pill { display: inline-flex; align-items: center; width: fit-content; padding: 2px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; }
.pill--ok { background: var(--ok-bg); color: var(--ok); }
.pill--warn { background: var(--warn-bg); color: var(--warn); }
.pill--ink { background: var(--ink); color: var(--bg); }
.banner { padding: var(--s-3) var(--s-4); border-radius: var(--r-m); display: grid; gap: var(--s-1); }
.banner--ok { background: var(--ok-bg); color: var(--ok); }
.banner--warn { background: var(--warn-bg); color: var(--warn); }
.banner--err { background: var(--err-bg); color: var(--err); }
.seg { display: flex; gap: var(--s-1); padding: 3px; border-radius: 999px; background: var(--surface-2); }
.seg__btn { flex: 1; min-height: 40px; border: 0; border-radius: 999px; background: none; font-weight: 600; font-size: 0.9rem; color: var(--ink-2); cursor: pointer; }
.seg__btn[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18); }
.seg__btn--ok[aria-pressed="true"] { background: var(--ok-bg); color: var(--ok); }
.seg__btn--warn[aria-pressed="true"] { background: var(--warn-bg); color: var(--warn); }
.switch { appearance: none; -webkit-appearance: none; width: 52px; height: 32px; flex: none; border-radius: 999px; background: var(--surface-2); position: relative; cursor: pointer; transition: background 0.15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.15s; }
.switch:checked { background: var(--ok); }
.switch:checked::after { transform: translateX(20px); }

/* ─── Tabs ─── */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around; padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabs__item { flex: 1; height: var(--tabs-h); display: grid; place-items: center; align-content: center; gap: 2px; font-size: 0.7rem; font-weight: 600; color: var(--ink-2); text-decoration: none; }
.tabs__item[aria-current="page"] { color: var(--ink); }

/* ─── Cards (discover) ─── */
.card { display: block; overflow: hidden; border-radius: var(--r-l); background: var(--surface); text-decoration: none; border: 1px solid var(--line); }
.card:active { transform: scale(0.99); }
.card__media { position: relative; aspect-ratio: 16 / 9; background: var(--surface-2); }
.card__img { width: 100%; height: 100%; object-fit: cover; }
.card__pill { position: absolute; left: var(--s-3); bottom: var(--s-3); }
.card__body { padding: var(--s-3) var(--s-4) var(--s-4); display: grid; gap: var(--s-1); }
.card__title { font-size: 1.25rem; line-height: 1.2; letter-spacing: -0.01em; }
.card__facts { font-size: 0.9rem; color: var(--ink-2); margin-bottom: var(--s-1); }

/* ─── Maps ─── */
.map { background: var(--surface-2); z-index: 0; }
.map--route { height: 190px; border-radius: var(--r-m); overflow: hidden; }
.map--full { position: fixed; inset: 0 0 calc(var(--tabs-h) + var(--safe-b)) 0; }
.screen--map { padding: 0; max-width: none; }
[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.95) contrast(0.9); }
.leaflet-container { font: inherit; background: var(--surface-2); }
.leaflet-control-attribution { font-size: 10px; }
.route-line { stroke: var(--accent); fill: none; }
.marker { display: grid; place-items: center; border-radius: 50%; font-size: 12px; font-weight: 700; }
.marker--stop { width: 22px; height: 22px; background: var(--ink); color: var(--bg); border: 2px solid var(--bg); }
.marker--tour { width: 28px; height: 28px; background: var(--accent); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4); }
.marker--me { width: 18px; height: 18px; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(26, 115, 232, 0.22); }
.marker--target { width: 30px; height: 30px; background: var(--accent); border: 3px solid #fff; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); }

/* ─── Detail ─── */
.screen--detail, .screen--play { padding: 0; gap: 0; }
.hero { position: relative; aspect-ratio: 4 / 3; max-height: 42vh; width: 100%; background: var(--surface-2); }
.hero__img { width: 100%; height: 100%; object-fit: cover; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-2); }
.facts > div { padding: var(--s-3); border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); text-align: center; }
.facts dt { font-size: 0.75rem; color: var(--ink-2); order: 2; }
.facts dd { font-size: 1.2rem; font-weight: 700; }
.facts > div { display: flex; flex-direction: column; }
.meta { display: grid; gap: var(--s-2); font-size: 0.95rem; }
.meta li { display: flex; gap: var(--s-3); align-items: flex-start; }
.meta .icon { color: var(--ink-2); margin-top: 3px; }
.fold { border-top: 1px solid var(--line); }
.fold summary { min-height: var(--tap); display: flex; align-items: center; justify-content: space-between; font-weight: 600; cursor: pointer; list-style: none; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary::after { content: "+"; font-size: 1.3rem; color: var(--ink-2); }
.fold[open] summary::after { content: "–"; }
.bullets { display: grid; gap: var(--s-2); padding: 0 0 var(--s-4) 1.2em; list-style: disc; font-size: 0.95rem; color: var(--ink-2); }
ol.bullets { list-style: decimal; }
.cta {
  position: sticky; bottom: 0; z-index: 5; margin-top: auto;
  display: grid; gap: var(--s-2); padding: var(--s-3) var(--s-4) calc(var(--s-3) + var(--safe-b));
  background: linear-gradient(to top, var(--bg) 78%, transparent);
}
.cta--plain { position: static; background: none; }

/* ─── Play ─── */
.screen--play { height: 100dvh; flex: none; overflow: hidden; max-width: 560px; }
.playbar { display: flex; align-items: center; gap: var(--s-3); padding: calc(var(--safe-t) + var(--s-2)) var(--s-3) var(--s-2); }
.progress { flex: 1; display: flex; gap: 4px; }
.progress__seg { flex: 1; height: 5px; border-radius: 3px; background: var(--surface-2); }
.progress__seg.is-done { background: var(--ink); }
.progress__seg.is-now { background: var(--accent); }
.play { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.play--walk { overflow: hidden; }
.map--walk { flex: 1; min-height: 180px; }
.walksheet { position: relative; z-index: 2; margin-top: calc(-1 * var(--r-l)); padding: var(--s-4) var(--s-4) calc(var(--s-4) + var(--safe-b)); display: grid; gap: var(--s-3); background: var(--bg); border-radius: var(--r-l) var(--r-l) 0 0; box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.14); }
.walksheet__top { display: flex; justify-content: space-between; gap: var(--s-3); align-items: flex-start; }
.walk__distance { font-size: 2.4rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.walk__target { font-weight: 600; }
.walk__thumb { width: 84px; height: 84px; flex: none; object-fit: cover; border-radius: var(--r-m); }
.walk__clue { color: var(--ink-2); }
.walk__status { font-size: 0.9rem; color: var(--warn); min-height: 1.2em; }
.walk__status:empty { display: none; }
.photo__img { width: 100%; object-fit: cover; border-radius: var(--r-m); }
.photo__img--wide { border-radius: 0; aspect-ratio: 16 / 10; }
.story { font-size: 1.12rem; line-height: 1.65; }
.story__sentence { transition: background 0.2s; border-radius: 4px; }
.story__sentence.is-now { background: color-mix(in srgb, var(--accent) 22%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.audio { display: flex; align-items: center; gap: var(--s-3); }
.audio__track { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.audio__fill { height: 100%; width: 0; background: var(--ink); transition: width 0.3s; }
.puzzle__prompt { font-size: 1.35rem; line-height: 1.3; letter-spacing: -0.01em; font-weight: 700; }
.options { display: grid; gap: var(--s-2); }
.option { min-height: 56px; padding: var(--s-3) var(--s-4); text-align: left; border: 1.5px solid var(--line); border-radius: var(--r-m); background: var(--surface); font-weight: 600; cursor: pointer; }
.option:active { border-color: var(--ink); }
.option.is-wrong { opacity: 0.45; text-decoration: line-through; }
.answer { display: flex; gap: var(--s-2); }
.field--answer { flex: 1; min-width: 0; font-size: 1.2rem; font-weight: 600; }
.sequence { display: grid; gap: var(--s-1); padding-left: 1.4em; list-style: decimal; font-weight: 600; }
.sequence:empty { display: none; }
.hints { display: grid; gap: var(--s-2); padding: var(--s-3) var(--s-4) var(--s-3) calc(var(--s-4) + 1.2em); list-style: decimal; border-radius: var(--r-m); background: var(--surface-2); font-size: 0.95rem; }
.find { display: inline-flex; align-items: center; gap: var(--s-2); font-weight: 600; }
.done { text-align: center; justify-items: center; padding-top: var(--s-6); }
.done .stack { width: 100%; justify-items: center; margin-top: var(--s-4); }
.done__check { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 50%; background: var(--ok-bg); color: var(--ok); }
.done__stats { font-weight: 600; }
.gallery { width: 100%; display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-3); text-align: left; }
.gallery__item { display: grid; gap: var(--s-1); }
.gallery__img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-m); background: var(--surface-2); }
.gallery__title { font-size: 0.85rem; font-weight: 600; line-height: 1.3; }
.stars { display: flex; gap: var(--s-1); }
.star { width: 52px; height: 52px; display: grid; place-items: center; border: 0; background: none; color: var(--ink-2); cursor: pointer; }
.star.is-on { color: var(--accent); }
.star.is-on svg { fill: currentColor; }

/* ─── Sheet, rows, toast ─── */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, 0.45); }
.sheet { width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto; padding: var(--s-4) var(--s-4) calc(var(--s-5) + var(--safe-b)); display: grid; gap: var(--s-4); background: var(--bg); border-radius: var(--r-l) var(--r-l) 0 0; animation: sheet-in 0.22s ease-out; }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
.sheet__head { display: flex; align-items: center; justify-content: space-between; }
.sheet__title { font-size: 1.2rem; }
.rows, .group { display: grid; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.row { display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: 60px; padding: var(--s-3) var(--s-4); border: 0; border-top: 1px solid var(--line); background: none; text-align: left; cursor: pointer; }
.row:first-child { border-top: 0; }
.row .icon { color: var(--ink-2); }
.row__text { flex: 1; display: grid; }
.row__text small, .setting small { font-size: 0.85rem; color: var(--ink-2); display: block; }
.setting { display: grid; gap: var(--s-2); padding: var(--s-3) var(--s-4); border-top: 1px solid var(--line); }
.setting:first-child { border-top: 0; }
.setting--row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); cursor: pointer; }
.setting__label { font-weight: 600; }
.plain { display: grid; gap: var(--s-2); }
.plain li { display: flex; gap: var(--s-2); align-items: center; }
.plain .icon { color: var(--ok); }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--safe-b) + var(--s-4)); transform: translateX(-50%); z-index: 60; max-width: calc(100% - 2 * var(--s-4)); padding: var(--s-3) var(--s-4); border-radius: var(--r-m); background: var(--ink); color: var(--bg); font-size: 0.95rem; font-weight: 600; text-align: center; }
.empty { display: grid; gap: var(--s-4); padding: var(--s-6) 0; text-align: center; justify-items: center; }

/* ─── Scouting (author tool) ─── */
.scout { display: grid; gap: var(--s-3); margin-top: var(--s-4); padding: var(--s-4); border: 1.5px dashed var(--warn); border-radius: var(--r-m); }
.scout__title { font-size: 0.8rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--warn); }
.scout h4 { font-size: 0.95rem; margin-top: var(--s-2); }
.scout__claim { display: grid; gap: var(--s-2); padding: var(--s-3); border-radius: var(--r-s); background: var(--surface-2); font-size: 0.95rem; }
.scout__thumb img { width: 96px; height: 96px; object-fit: cover; border-radius: var(--r-s); }

/* ─── Photo viewer and credits ─── */
.photo__zoom, .hero__zoom, .walk__thumbbtn { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.hero__zoom { height: 100%; }
.walk__thumbbtn { width: auto; flex: none; }
.viewer { position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; background: #000; color: #fff; }
.viewer__stage { flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; touch-action: none; cursor: grab; }
.viewer__img { max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; will-change: transform; }
.viewer__close { position: absolute; top: calc(var(--safe-t) + var(--s-3)); right: var(--s-3); background: rgba(0, 0, 0, 0.6); color: #fff; }
.viewer__foot { display: grid; gap: var(--s-1); padding: var(--s-3) var(--s-4) calc(var(--s-3) + var(--safe-b)); font-size: 0.8rem; color: rgba(255, 255, 255, 0.75); text-align: center; }
.viewer__foot .credit, .viewer__foot .credit a { color: rgba(255, 255, 255, 0.75); }
.credit a { color: inherit; }
.credits { display: grid; gap: var(--s-3); padding-bottom: var(--s-3); }
.credits li { display: flex; gap: var(--s-3); align-items: center; }
.credits img { width: 56px; height: 42px; flex: none; object-fit: cover; border-radius: 6px; }
/* ─── Legal texts ─── */
.legal { display: grid; gap: var(--s-3); margin-top: var(--s-4); overflow-wrap: anywhere; }
.legal__h { font-size: 1.1rem; margin-top: var(--s-4); }
.legal__tabs { display: flex; gap: var(--s-2); margin-top: var(--s-4); }
.legal__tabs .pill { text-decoration: none; background: var(--surface-2); color: var(--ink); }
.legal__tabs .pill[aria-current="page"] { background: var(--ink); color: var(--bg); }
a.row { color: inherit; text-decoration: none; }
/* ─── Group mode ─── */
.group__code { font-size: 2.4rem; font-weight: 800; letter-spacing: 0.18em; text-align: center; font-variant-numeric: tabular-nums; }
.group__players { display: grid; gap: var(--s-2); }
.group__players li { display: flex; align-items: center; gap: var(--s-2); }
.group__players small { color: var(--ink-2); }
.field--code { text-align: center; font-size: 1.5rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; }
.playbar__group { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 var(--s-3); border: 0; border-radius: 999px; background: var(--surface-2); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
.choice { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); cursor: pointer; }
.choice input { margin-top: 4px; width: 20px; height: 20px; flex: none; accent-color: var(--ink); }
.choice span { display: grid; gap: 2px; }
.choice small { color: var(--ink-2); }
.standings { display: grid; gap: var(--s-2); width: 100%; }
.standings li { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r-m); background: var(--surface-2); }
.standings li.is-you { outline: 2px solid var(--ink); }
.standings__place { width: 1.5em; font-weight: 800; }
.standings__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.credits--text li { display: block; font-size: 0.875rem; color: var(--ink-2); }
.walk__cluerow { display: flex; gap: var(--s-3); align-items: flex-start; }
.walk__cluerow .walk__clue { flex: 1; }
.talk { display: grid; gap: var(--s-1); padding: var(--s-3) var(--s-4); border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); }
.check { display: flex; align-items: center; gap: var(--s-3); min-height: var(--tap); font-size: 0.95rem; }
.check input { width: 22px; height: 22px; flex: none; accent-color: var(--ink); }
