/* Layout and components. Colours and fonts come from tokens.css. */

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--backdrop); color: var(--ink); font-family: var(--font);
  -webkit-text-size-adjust: 100%; overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
body { position: fixed; inset: 0; touch-action: manipulation; }   /* no double-tap zoom */
button, input { font: inherit; color: inherit; }

/* The app box follows the visible viewport, so the panel sits right above the phone keyboard. */
#app { position: fixed; left: 0; right: 0; top: 0; height: 100%; overflow: hidden; }
#globe, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#overlay { touch-action: none; }
body:not(.ready) #panel { opacity: 0; }

#hud {
  position: absolute; left: 0; right: 0; top: 0; z-index: 2;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 6px;
  pointer-events: none;
}
#panel {
  position: absolute; z-index: 3; bottom: 0; left: 50%; transform: translateX(-50%);
  width: min(100%, 560px); max-height: 70%; overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 14px);
  background: var(--paper); border: var(--line) solid var(--ink); border-bottom: 0;
  border-radius: var(--panel-radius) var(--panel-radius) 0 0;
  box-shadow: 0 -5px 0 rgba(26, 35, 66, .07);
  transition: opacity .3s;
}
/* A small handle on top of the panel, like a sheet that can be pulled. Decorative. */
#panel::before { content: ''; display: block; width: 42px; height: 5px; margin: -6px auto 10px; border-radius: 3px; background: rgba(26, 35, 66, .16); }

/* ---------- type ---------- */

h1, h2, p { margin: 0; }
.brand { text-align: center; }
.brand h1 { margin: 0; line-height: 0; }
/* The name as a sticker (screens.js wordmark): white and accent letters with a thick ink outline and drop. */
.wordmark { display: block; height: 50px; width: auto; max-width: 100%; margin: 0 auto; overflow: visible; }
.wordmark text { font-family: var(--font); font-weight: 700; font-size: 43px; letter-spacing: .4px; stroke: var(--ink); stroke-width: 8.5px; stroke-linejoin: round; paint-order: stroke fill; }
.wordmark .shadow, .wordmark .shadow tspan { fill: var(--ink); }
.wordmark .face .w1 { fill: #fff; }
.wordmark .face .w2 { fill: var(--accent); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small { font-size: 14px; color: var(--muted); }
.caps { text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.prompt { font-size: 22px; font-weight: 700; line-height: 1.18; }
.prompt.compact { font-size: 17px; }

/* ---------- buttons and inputs ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; min-height: 48px;
  font-size: 18px; font-weight: 600;
  background: var(--card); color: var(--ink); border: var(--line) solid var(--ink); border-radius: var(--radius);
  box-shadow: 0 var(--lift) 0 var(--ink); cursor: pointer;
  transition: transform .06s, box-shadow .06s;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.big { width: 100%; font-size: 21px; min-height: 56px; }
.btn.small { min-height: 48px; padding: 10px 16px; font-size: 17px; }
.link { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font-size: inherit; }

.answer-row { display: flex; gap: 8px; margin-top: 10px; }
.answer {
  flex: 1; min-width: 0; min-height: 48px; padding: 10px 14px;
  font-size: 18px;               /* 16px or more stops iOS from zooming in */
  background: var(--card); border: var(--line) solid var(--ink); border-radius: var(--radius);
  outline: none;
}
.answer:focus { box-shadow: 0 0 0 3px rgba(255, 90, 79, .35); }
.answer::placeholder { color: rgba(26, 35, 66, .42); font-weight: 400; }
.field .answer { color: var(--ink); font-weight: 500; }
.answer:disabled { opacity: .5; }

.feedback { margin-top: 10px; font-size: 16px; font-weight: 500; min-height: 1.3em; color: var(--muted); }
.feedback.good { color: var(--good-ink); }
.feedback.bad { color: var(--bad-ink); }
.feedback .hint { color: var(--muted); font-weight: 400; font-size: 14px; }
.km-badge {
  display: inline-block; margin-left: 2px; padding: 1px 10px; border-radius: 999px;
  background: var(--good); color: #fff; font-weight: 700; white-space: nowrap;
  border: 2px solid var(--ink); box-shadow: 0 2px 0 var(--ink); animation: pop .4s cubic-bezier(.2, .8, .2, 1) both;
}
.km-badge.zero { background: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  padding: 3px 10px; border-radius: 999px; font-size: 14px; font-weight: 500;
  background: var(--card); border: 2px solid var(--ink);
}
.chip.mine { background: var(--accent); color: var(--accent-ink); }
.chips.found { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.chips.found:empty { display: none; }
.chips.found .chip { flex: none; }

.actions:not(:empty) { margin-top: 14px; }
.actions .btn { width: 100%; }
.btn.next .icon { display: grid; flex: none; }
.btn.next .icon svg { width: 22px; height: 22px; }
.btn.next b { font-weight: 700; }
.btn.next .arrow { margin-left: 2px; }

/* ---------- top bar during play ---------- */

.play-hud {
  max-width: 560px; margin: 0 auto; padding: 8px 12px 10px; pointer-events: auto;
  background: var(--paper); border: var(--line) solid var(--ink); border-radius: 18px; box-shadow: 0 3px 0 var(--ink);
}
.hud-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.hud-stop { font-size: 15px; font-weight: 500; }
.hud-stop b { font-size: 22px; font-weight: 700; }
.hud-stop > span { display: block; font-size: 13px; color: var(--muted); }
.hud-num { display: flex; align-items: center; gap: 2px; }
.sound-toggle {
  display: inline-flex; align-items: center; gap: 6px; padding: 0; margin: 0 0 0 6px;
  width: 30px; height: 30px; justify-content: center; border-radius: 50%;
  background: none; border: 0; color: var(--muted); cursor: pointer;
}
.sound-toggle svg { width: 20px; height: 20px; }
.sound-toggle[aria-pressed="true"] { color: var(--ink); }
/* Round-ended buttons under Start and on the result screen: Friends, My results, Sound. */
.home-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
.pill, .sound-toggle.pill {
  display: inline-flex; align-items: center; gap: 5px; width: auto; height: 38px; padding: 0 12px 0 9px; margin: 0;
  border-radius: 999px; border: 2px solid var(--ink); background: var(--card); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.pill .icon { display: grid; }
.pill svg { width: 18px; height: 18px; }
.sound-toggle.pill { border-color: rgba(26, 35, 66, .25); background: transparent; color: var(--muted); }
.sound-toggle.pill[aria-pressed="true"] { border-color: var(--ink); background: var(--card); color: var(--ink); }
.pill:active { transform: translateY(1px); }
.hud-timer {
  min-width: 54px; height: 40px; padding: 0 10px; border-radius: 999px;
  display: grid; place-items: center; font-size: 26px; font-weight: 700;
  background: var(--card); border: var(--line) solid var(--ink); box-shadow: 0 3px 0 var(--ink);
  font-variant-numeric: tabular-nums;
}
.hud-timer.idle { opacity: 0; }
.hud-timer.low { background: var(--bad); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.hud-km { display: grid; justify-items: end; gap: 5px; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hud-total { display: inline-block; transform-origin: right center; }
/* Today's route: seven dots on a dashed line, coloured by how each stop went (colours: SHARE.score). */
.hud-route { position: relative; display: flex; gap: 5px; align-items: center; }
.hud-route::before { content: ''; position: absolute; left: 4px; right: 4px; top: 50%; border-top: 2px dashed rgba(26, 35, 66, .28); }
.hud-route i {
  position: relative; width: 10px; height: 10px; border-radius: 50%; box-sizing: border-box;
  background: var(--paper); border: 2px solid rgba(26, 35, 66, .3);
  transition: transform .25s, box-shadow .25s;
}
.hud-route i.done { border-color: var(--ink); }
.hud-route i.now { border-color: var(--ink); background: var(--card); transform: scale(1.3); box-shadow: 0 0 0 2.5px rgba(255, 90, 79, .45); }
@media (max-width: 350px) { .hud-route { gap: 3px; } .hud-route i { width: 9px; height: 9px; } }
.hud-bar { height: 6px; margin-top: 8px; border-radius: 3px; background: rgba(26, 35, 66, .15); overflow: hidden; }
.hud-bar i { display: block; height: 100%; background: var(--ink); transform-origin: left; transition: transform .1s linear; }

/* ---------- questions ---------- */

.q.waiting .choices, .q.waiting .answer-row, .q.waiting .lock-row { opacity: .45; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.choice {
  min-height: 54px; padding: 8px 10px; font-size: 17px; font-weight: 600; line-height: 1.15;
  background: var(--card); border: var(--line) solid var(--ink); border-radius: var(--radius);
  box-shadow: 0 var(--lift) 0 var(--ink); cursor: pointer;
}
.choice:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.choice:disabled { cursor: default; }
.q.waiting .choice:disabled { opacity: 1; }
.choice { position: relative; }
.choice.right { background: var(--good); color: #fff; }
.choice.wrong { background: var(--bad); color: #fff; }
/* A small sticker on the answer: a tick on the right one, a cross on a wrong pick. */
.choice.right::after, .choice.wrong::after {
  position: absolute; top: -9px; right: -7px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: 14px; font-weight: 700; line-height: 1;
  background: #fff; color: var(--ink); border: 2px solid var(--ink); animation: pop .35s cubic-bezier(.2, .8, .2, 1) both;
}
.choice.right::after { content: '✓'; color: var(--good-ink); }
.choice.wrong::after { content: '✗'; color: var(--bad-ink); }
.choice.picked { outline: 3px solid var(--ink); outline-offset: 2px; }

.q-image { display: block; margin: 12px auto 0; }
.q-image.flag { width: min(62%, 220px); aspect-ratio: 4 / 3; border: var(--line) solid var(--ink); border-radius: 12px; object-fit: cover; background: #fff; box-shadow: 0 var(--lift) 0 var(--ink); }
.q-image.outline { width: min(48%, 170px); aspect-ratio: 1; }
.q-image.outline svg { width: 100%; height: 100%; display: block; }
.q-image.outline .shape { fill: #7bd35c; stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; }

.answers { margin-top: 6px; }
.answers .small { margin-top: 8px; }

.circle-score { margin-top: 4px; font-size: 16px; }
/* The goal on circles, straight lines and lights out: how much is needed, and a bar towards it. */
.goal { margin-top: 6px; }
.goal-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 16px; }
.goal-text b { font-size: 18px; }
.goal-km { font-size: 14px; color: var(--muted); white-space: nowrap; }
.goal-km b { color: var(--ink); }
.goal-bar { height: 9px; margin-top: 5px; border-radius: 5px; background: rgba(26, 35, 66, .1); border: 1.5px solid rgba(26, 35, 66, .35); overflow: hidden; }
.goal-bar i { display: block; width: 0; height: 100%; background: var(--accent); transition: width .35s ease-out; }
.goal.maxed .goal-bar { border-color: var(--good-ink); }
.goal.maxed .goal-bar i { background: var(--good); }
.max-badge { display: inline-block; margin-left: 8px; padding: 0 8px; border-radius: 999px; background: var(--good); color: #fff; border: 2px solid var(--ink); font-size: 12px; font-weight: 700; vertical-align: 2px; animation: pop .4s cubic-bezier(.2, .8, .2, 1) both; }
.q-circle .feedback { margin-top: 4px; }
.missed { margin-top: 8px; }

.lock-row { display: flex; gap: 8px; margin-top: 12px; }
.q-lights .btn.skip { flex: none; }
.lock-row .btn.primary { flex: 1; }
.lock-row .zoom { width: 52px; padding: 0; font-size: 26px; font-weight: 700; }

/* ---------- home and results ---------- */

.home .tagline { font-size: 18px; font-weight: 500; line-height: 1.3; }
.rules { margin: 12px 0 14px; }
.facts { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); }
.facts li { display: grid; justify-items: center; padding: 2px 4px; text-align: center; }
.facts li + li { border-left: 2px dashed rgba(26, 35, 66, .18); }
.facts b { font-size: 22px; font-weight: 700; line-height: 1.1; }
.facts span { font-size: 13px; color: var(--muted); }
.facts-note { margin-top: 8px; font-size: 14px; line-height: 1.35; color: var(--muted); text-align: center; }
.facts-note b { color: var(--ink); font-weight: 600; }
.home-head { text-align: left; }
.home-title { font-size: 23px; font-weight: 700; line-height: 1.15; }
.home-sub { margin-top: 3px; font-size: 16px; color: var(--muted); }
.btn.start .icon { display: grid; }
.btn.start svg { width: 24px; height: 24px; stroke-width: 2; transform: rotate(45deg); }
.credits { margin-top: 12px; font-size: 12px; color: var(--muted); text-align: center; }
.credits a { color: inherit; }
.dev { margin-top: 10px; font-size: 13px; color: var(--muted); text-align: center; }

#panel:has(.results) { max-height: 60%; }
.results .total { margin-top: 2px; font-size: 18px; }
.results .total b { font-size: 34px; font-weight: 700; }
.results .pct { font-size: 17px; font-weight: 500; color: var(--muted); }
.meter { position: relative; height: 18px; margin: 12px 16px 14px 0; border-radius: 9px; border: 2.5px solid var(--ink); background: var(--card); }
.meter i { display: block; height: 100%; border-radius: 6px; background: repeating-linear-gradient(-45deg, var(--accent) 0 8px, #ff786e 8px 16px); }
/* A small plane rides at the end of the bar. */
.meter-plane { position: absolute; top: 50%; transform: translate(-50%, -50%); display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--paper); border: 2.5px solid var(--ink); color: var(--ink); }
.meter-plane svg { width: 18px; height: 18px; stroke-width: 2; transform: rotate(90deg); }
.stops { list-style: none; margin: 0; padding: 0; }
.stops > li { border-top: 1.5px dashed rgba(26, 35, 66, .2); }
/* Each stop is a button that opens it again (review.js). The number is coloured like the share card. */
.stops .row {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 2px; margin: 0;
  background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: 12px;
}
.stops .row:disabled { cursor: default; }
.stops .row:not(:disabled):active { background: rgba(26, 35, 66, .06); }
.stops .num {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; box-sizing: border-box;
  background: var(--accent); color: var(--ink); border: 2px solid var(--ink); font-weight: 700; font-size: 14px;
}
.stops .what { flex: 1; font-weight: 500; line-height: 1.15; }
.stops .what small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.stops .km { font-weight: 600; font-variant-numeric: tabular-nums; }
.stops .km.zero { color: var(--muted); }
.stops .chev { flex: none; width: 8px; height: 8px; margin: 0 4px 0 2px; border-right: 2.5px solid var(--muted); border-bottom: 2.5px solid var(--muted); transform: rotate(45deg) translate(-2px, -2px); transition: transform .2s; }
.stops .row:disabled .chev { visibility: hidden; }
.stops > li.open .chev { transform: rotate(225deg) translate(-2px, -2px); }
.stops > li.open { background: var(--card); border-radius: 14px; border-top-color: transparent; box-shadow: 0 0 0 2px var(--ink); margin: 4px 0; }
.stops > li.open + li { border-top-color: transparent; }
.review { padding: 0 12px 12px 48px; animation: fade-up .3s ease-out; }
.review-q { font-weight: 600; line-height: 1.25; }
.review-line { margin-top: 5px; font-size: 15px; line-height: 1.35; }
.review-line .label { color: var(--muted); }
.review-line.small { font-size: 13px; color: var(--muted); margin-top: 8px; }
.review .chips { margin-top: 4px; }
.review .chip { font-size: 13px; }
.review-image { margin-bottom: 8px; }
.review-image .q-image { margin: 0; }
.review-image .q-image.flag { width: 92px; }
.review-image .q-image.outline { width: 70px; }
.mark { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font-size: 12px; font-weight: 700; color: #fff; vertical-align: 1px; }
.mark.ok { background: var(--good); }
.mark.no { background: var(--bad); }
.review-order { list-style: decimal; margin: 6px 0 0; padding-left: 20px; font-size: 15px; }
.review-order li { margin: 3px 0; }
.review-order .name { font-weight: 600; }
.review-order .lat { margin: 0 6px; color: var(--muted); font-size: 13px; }
.results .beat { min-height: 1.3em; margin: -2px 0 12px; font-size: 16px; }
.results .beat:empty { min-height: 0; margin: 0; }
.results .beat b { font-weight: 700; }
.results .beat small { display: block; font-size: 13px; color: var(--muted); }
.results .hint { margin: 2px 0 4px; }
.next { margin-top: 12px; text-align: center; font-size: 15px; color: var(--muted); }
.countdown { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

/* Short screens (phone keyboard open): tighten the panel so the circle keeps its room.
   main.js sets .short from the visible viewport height, which media queries cannot see on iOS. */
.short #panel { padding-top: 10px; }
.short .prompt { font-size: 18px; }
.short .q-circle .prompt { display: none; }
.short .hud-bar { margin-top: 5px; }

/* ---------- friends, streak, my results ---------- */

.streak { display: flex; align-items: center; gap: 6px; margin: 8px 0 2px; font-size: 15px; font-weight: 600; color: var(--bad-ink); }
.streak .icon { display: grid; color: var(--accent); }
.streak svg { width: 20px; height: 20px; }
.streak.lit .icon svg { fill: rgba(255, 90, 79, .25); }
.results .streak { margin: -4px 0 12px; }
.notice { margin-top: 8px; padding: 8px 12px; border-radius: 12px; background: var(--card); border: 2px solid var(--good); font-size: 15px; font-weight: 500; }

.panel-top { display: flex; align-items: center; gap: 8px; margin: -4px 0 8px -6px; }
.back-btn { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--ink); cursor: pointer; }
.back-btn svg { width: 24px; height: 24px; stroke-width: 2.6; }
.back-btn:active { background: rgba(26, 35, 66, .08); }
.note { margin-top: 14px; line-height: 1.4; }

.group { margin-top: 12px; padding: 12px; border: 2px solid var(--ink); border-radius: 16px; background: var(--card); box-shadow: 0 3px 0 var(--ink); }
.group.fresh { box-shadow: 0 0 0 4px rgba(47, 191, 113, .35); }
.group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.group-head h3 { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.btn.invite { flex: none; min-height: 40px; padding: 6px 12px; font-size: 15px; gap: 6px; }
.btn.invite .icon, .btn .icon { display: grid; }
.btn.invite svg { width: 18px; height: 18px; }
.group-tip { margin-top: 8px; font-size: 14px; color: var(--good-ink); font-weight: 500; }
.standings { list-style: none; margin: 10px 0 0; padding: 0; }
.standings li { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-top: 1.5px dashed rgba(26, 35, 66, .18); font-size: 15px; }
.standings li:first-child { border-top: 0; }
.standings li.me { font-weight: 600; }
.standings .rank { flex: none; width: 18px; text-align: center; font-weight: 700; color: var(--muted); }
.standings .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.standings .who small { color: var(--muted); font-weight: 400; }
.standings .km { flex: none; font-weight: 600; font-variant-numeric: tabular-nums; }
.squares { flex: none; display: inline-flex; gap: 2px; }
.squares i { width: 9px; height: 9px; border-radius: 2px; border: 1.5px solid var(--ink); }
.waiting { margin-top: 6px; }
.group-status:empty { display: none; }
.group-status { margin-top: 6px; }
.link-field { width: 100%; margin-top: 6px; font-size: 16px; min-height: 40px; }
.leave { margin-top: 8px; font-size: 13px; color: var(--muted); }

.friends-today { margin: 0 0 12px; }
.friends-today:empty { display: none; }
.friends-today > .caps { margin-bottom: -2px; }
.friends-invite { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 2px dashed rgba(26, 35, 66, .35); border-radius: 16px; }
.friends-invite > .icon { display: grid; flex: none; }
.friends-invite > .icon svg { width: 26px; height: 26px; }
.friends-invite > div { flex: 1; line-height: 1.25; }
.friends-invite .btn { flex: none; min-height: 40px; }
.friends-empty p { margin-top: 6px; line-height: 1.4; }
.new-group { margin-top: 14px; }
.new-group > .btn { width: 100%; }
.group-new h3 { margin: 0 0 4px; font-size: 18px; }
.group-form { display: grid; gap: 10px; margin-top: 8px; }
.field { display: grid; gap: 4px; font-size: 14px; font-weight: 600; color: var(--muted); }
.group-form .feedback { margin: 0; min-height: 0; }
.group-form .feedback:empty { display: none; }
.join .prompt { margin: 2px 0 4px; font-size: 26px; overflow-wrap: anywhere; }
.join .group-form { margin-top: 14px; }
.skip { display: block; margin: 12px auto 0; color: var(--muted); font-size: 15px; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.tile { position: relative; padding: 10px 12px; border: 2px solid var(--ink); border-radius: 14px; background: var(--card); box-shadow: 0 3px 0 var(--ink); }
.tile b { display: block; font-size: 24px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile span { font-size: 13px; color: var(--muted); }
.tile .icon { position: absolute; top: 8px; right: 8px; color: var(--accent); }
.tile .icon svg { width: 20px; height: 20px; }
.best { margin-top: 10px; font-size: 15px; }
.chart-title { margin-top: 14px; }
.chart { margin: 6px 0 0; }
.day-chart { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.day-chart .grid { stroke: rgba(26, 35, 66, .18); stroke-width: 1; stroke-dasharray: 3 4; }
.day-chart .axis { stroke: rgba(26, 35, 66, .45); stroke-width: 1; }
.day-chart .avg { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 2 3; opacity: .55; }
.day-chart .tick { font-size: 9px; fill: var(--muted); font-family: var(--font); paint-order: stroke; stroke: var(--paper); stroke-width: 3px; stroke-linejoin: round; }
.day-chart .tick.end { text-anchor: end; }
.day-chart .bar { fill: var(--accent); }
.day-chart .none { fill: rgba(26, 35, 66, .3); }
.day-chart .hit { fill: transparent; cursor: pointer; }
.day-chart .day.picked .bar { fill: #c93a31; }
.day-chart .day.picked .none { fill: var(--ink); }
.chart-caption { margin-top: 4px; min-height: 1.3em; }

/* ---------- sharing ---------- */

.share { margin: 4px 0 12px; }
.share-preview { display: block; width: 100%; max-width: 360px; margin: 12px auto 0; border: var(--line) solid var(--ink); border-radius: 14px; }
.share-actions { display: flex; gap: 10px; margin-top: 12px; }
.share-actions .btn { flex: 1; text-decoration: none; color: var(--ink); }
.share-status { margin-top: 8px; text-align: center; }
.chip.more { background: transparent; border-style: dashed; }

/* ---------- plain pages (privacy) ---------- */

/* Plain pages (privacy, admin) scroll like normal web pages: the document scrolls, not the body.
   (A body that is its own scroll box, with overscroll-behavior: none, swallows the swipe on phones.) */
html.doc, html.doc body { height: auto; overflow: visible; position: static; overscroll-behavior: auto; touch-action: auto; }
/* Long pages scroll: just the dot grid (the sun rays would repeat down the page). */
html.doc, html.doc body { background: radial-gradient(rgba(26, 35, 66, .085) 1.3px, transparent 1.5px) 0 0 / 22px 22px, var(--bg); }
.doc main { max-width: 640px; margin: 0 auto; padding: 28px 20px 48px; }
.doc .card { background: var(--paper); border: var(--line) solid var(--ink); border-radius: var(--panel-radius); padding: 22px 20px; box-shadow: 0 var(--lift) 0 var(--ink); }
.doc h1 { font-size: 28px; margin-bottom: 4px; }
.doc h2 { font-size: 19px; margin: 22px 0 6px; }
.doc p, .doc li { font-size: 16px; line-height: 1.5; }
.doc p + p { margin-top: 8px; }
.doc ul { padding-left: 20px; margin: 6px 0; }
.doc a { color: var(--ink); }
.doc code { font-size: 14px; background: rgba(26, 35, 66, .08); padding: 1px 6px; border-radius: 6px; word-break: break-all; }
.doc .back { display: inline-block; margin-bottom: 14px; font-weight: 600; }

/* ---------- intro cards ---------- */

.intro .prompt { margin-top: 2px; }
.intro-head { display: flex; align-items: center; gap: 12px; }
.intro-icon {
  flex: none; width: 54px; height: 54px; display: grid; place-items: center; border-radius: 16px;
  background: var(--card); border: 2.5px solid var(--ink); box-shadow: 0 var(--lift) 0 var(--ink); color: var(--ink);
}
.intro-icon svg { width: 30px; height: 30px; }
/* The animated "how it works" demo on the lights-out intro card (screens.js lightsDemo). */
.demo { display: flex; gap: 14px; align-items: center; margin: 12px 0 2px; padding: 12px; border-radius: 18px; background: #10162c; border: 2.5px solid var(--ink); box-shadow: 0 var(--lift) 0 var(--ink); }
.demo-map { flex: none; width: 96px; height: auto; }
.demo-map .ctx { fill: #26304f; }
.demo-map .land { fill: #34416a; stroke: #10162c; stroke-width: .9; transition: fill .3s; }
.demo-map .land.lit { fill: #ffd84d; filter: drop-shadow(0 0 5px #ffd84d); }
.demo-map .land.right { fill: #2fbf71; }
.demo-map .land.skipped { fill: #8790a6; }
.demo-side { flex: 1; min-width: 0; color: #fff; }
.demo-label { font-size: 12px; color: rgba(255, 255, 255, .7); }
.demo-input { display: flex; align-items: center; height: 38px; margin-top: 4px; padding: 0 10px; border-radius: 12px; background: #fff; color: var(--ink); border: 2px solid var(--ink); font-size: 17px; font-weight: 600; }
.demo-input .caret { width: 2px; height: 20px; margin-left: 1px; background: var(--ink); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.demo-skip { display: inline-block; margin-top: 8px; padding: 2px 12px; border-radius: 999px; border: 2px solid rgba(255, 255, 255, .5); font-size: 13px; font-weight: 600; color: rgba(255, 255, 255, .85); transition: background .15s; }
.demo-skip.press { background: #fff; color: var(--ink); }
.demo-note { margin-top: 6px; min-height: 1.3em; font-size: 15px; font-weight: 600; color: rgba(255, 255, 255, .85); }
.demo-note.good { color: #74e3a8; }
.intro-what { margin-top: 8px; font-size: 18px; font-weight: 500; line-height: 1.3; }
.intro-rule { margin: 8px 0 16px; font-size: 15px; line-height: 1.4; color: var(--muted); }

.suggest {
  display: inline-block; margin-left: 2px; padding: 2px 10px; border-radius: 999px; cursor: pointer;
  font-size: 15px; font-weight: 600; color: var(--ink); background: var(--card); border: 2px solid var(--ink);
}

/* ---------- north to south ---------- */

.order { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; align-items: start; }
.order-pool { display: grid; gap: 8px; }
.order.revealed { grid-template-columns: 1fr; }
.order.revealed .order-pool { display: none; }
.order-pool .choice { min-height: 46px; }
.order-slots { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.slot {
  display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 6px 10px; cursor: pointer;
  border: var(--line) dashed var(--ink); border-radius: var(--radius); background: transparent;
}
.slot.filled { border-style: solid; background: var(--card); }
.slot .rank { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 700; background: var(--ink); color: #fff; }
.slot .name { flex: 1; font-weight: 600; line-height: 1.1; }
.slot:not(.filled) .name { color: var(--muted); font-weight: 500; font-size: 14px; }
.slot .lat { font-size: 13px; color: var(--muted); }
.slot.right { background: var(--good); color: #fff; border-style: solid; }
.slot.wrong { background: var(--bad); color: #fff; border-style: solid; }
.slot.right .lat, .slot.wrong .lat { color: #fff; }

/* ---------- home: today's round ---------- */

.brand-date {
  display: inline-block; margin-top: 2px; padding: 2px 11px; border-radius: 999px;
  background: var(--paper); border: 2px solid var(--ink); font-size: 13px; font-weight: 600; color: var(--ink);
}
.today { position: relative; list-style: none; display: flex; justify-content: space-between; gap: 6px; margin: 14px 0 4px; padding: 0; }
/* The seven stops sit on a dashed route line, like the route on the globe. */
.today::before { content: ''; position: absolute; left: 7%; right: 7%; top: 20px; border-top: 3px dashed var(--accent); }
.today li { position: relative; flex: 1; display: grid; justify-items: center; gap: 3px; }
.today .icon {
  width: 100%; max-width: 44px; aspect-ratio: 1; display: grid; place-items: center; border-radius: 12px;
  background: var(--card); border: 2px solid var(--ink); box-shadow: 0 3px 0 var(--ink); color: var(--ink);
}
.today .n { font-size: 12px; font-weight: 600; color: var(--muted); }
.today li.done .icon { background: var(--good); color: #fff; }

/* ---------- life and motion ---------- */

@keyframes drop-in { 0% { transform: translateY(-24px) scale(.9); opacity: 0; } 60% { transform: translateY(4px) scale(1.03); opacity: 1; } 100% { transform: none; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); opacity: 1; } 100% { transform: none; } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.03); } }
@keyframes globe-in { from { opacity: 0; } to { opacity: 1; } }

.ready .brand h1 { animation: drop-in .7s cubic-bezier(.2, .8, .2, 1) both; }
.ready .brand-date { animation: rise .5s .2s ease-out both; }
.ready .home > * { animation: rise .5s ease-out both; }
.ready .home > :nth-child(2) { animation-delay: .08s; }
.ready .home > :nth-child(3) { animation-delay: .16s; }
.ready .home > :nth-child(4) { animation-delay: .24s; }
.ready .today li { animation: pop .45s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(.25s + var(--i) * .06s); }
.ready .start { animation: rise .5s .3s ease-out both, breathe 2.6s 1.2s ease-in-out infinite; }
.ready .start:active { animation: none; }
#globe, #overlay { animation: globe-in .8s ease-out both; }

/* During play: the top bar drops in once, each new stop's card slides up, the question fades in,
   finished stops fill their dot with a pop, and the km counter gives a little bump. */
@keyframes panel-in { from { translate: 0 56px; opacity: .4; } to { translate: 0 0; opacity: 1; } }
@keyframes fade-up { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes dot-fill { 0% { transform: scale(.4); } 55% { transform: scale(1.7); } 100% { transform: scale(1); } }
@keyframes bump { 40% { transform: scale(1.14); } }
.play-hud { animation: drop-in .55s cubic-bezier(.2, .8, .2, 1) backwards; }
#panel.slide-in { animation: panel-in .42s cubic-bezier(.2, .8, .2, 1) backwards; }
.q.arrive .prompt { animation: fade-up .4s ease-out backwards; }
.q.arrive .q-image-box > * { animation: pop .45s .08s cubic-bezier(.2, .8, .2, 1) backwards; }
.q.arrive .choices > *, .q.arrive .order-pool > * { animation: rise .35s ease-out backwards; }
.q.arrive .choices > :nth-child(1), .q.arrive .order-pool > :nth-child(1) { animation-delay: .1s; }
.q.arrive .choices > :nth-child(2), .q.arrive .order-pool > :nth-child(2) { animation-delay: .15s; }
.q.arrive .choices > :nth-child(3), .q.arrive .order-pool > :nth-child(3) { animation-delay: .2s; }
.q.arrive .choices > :nth-child(4), .q.arrive .order-pool > :nth-child(4) { animation-delay: .25s; }
.hud-route i.fresh { animation: dot-fill .5s cubic-bezier(.2, .8, .2, 1); }
.hud-total.bump { animation: bump .45s ease-out; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- this week's table in a group ---------- */
.seg { display: flex; gap: 4px; margin-top: 10px; padding: 3px; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper); }
.seg-btn { flex: 1; min-height: 36px; border: 0; border-radius: 9px; background: none; font: inherit; font-size: 15px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg-btn[aria-pressed="true"] { background: var(--ink); color: #fff; }
.seg-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.week-table .head { padding: 0 0 2px; font-size: 12px; font-weight: 600; color: var(--muted); }
.week-table .head .km { font-weight: 600; }
.week-table .km { width: 64px; text-align: right; }
.week-table .days { flex: none; display: inline-flex; gap: 3px; }
.week-table .days i { width: 12px; height: 12px; border-radius: 3px; border: 1.5px solid rgba(26, 35, 66, .4); font-style: normal; }
.week-table .days i.on { background: var(--ink); border-color: var(--ink); }
.week-table .days i.now { box-shadow: 0 0 0 2px rgba(255, 90, 79, .45); }
.week-table .days i.later { border-style: dashed; border-color: rgba(26, 35, 66, .22); }
.week-table .head .days i { border: 0; box-shadow: none; text-align: center; line-height: 12px; font-size: 10px; }
.week-table .head .days i.now { color: var(--accent); }
.week-note { margin-top: 8px; line-height: 1.35; }
.week-last { margin-top: 4px; }
.week-last b { color: var(--ink); }

/* ---------- challenge a friend ---------- */
.challenge-banner { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 12px; border: 2px solid var(--ink); border-radius: 16px; background: var(--card); box-shadow: 0 3px 0 var(--ink); }
.challenge-banner > .icon, .challenge-head > .icon { display: grid; flex: none; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--bg); border: 2px solid var(--ink); }
.challenge-banner > .icon svg, .challenge-head > .icon svg { width: 20px; height: 20px; fill: var(--accent); }
.challenge-banner > div { flex: 1; line-height: 1.3; }
.challenge-banner p { margin: 2px 0 0; }
.challenge { margin: 0 0 12px; padding: 12px; border: 2px solid var(--ink); border-radius: 16px; background: var(--card); box-shadow: 0 3px 0 var(--ink); }
.challenge-head { display: flex; align-items: center; gap: 10px; }
.challenge-head h3 { flex: 1; margin: 0; font-size: 18px; font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.challenge-head .btn { flex: none; min-height: 40px; padding: 6px 12px; font-size: 15px; gap: 6px; }
.challenge-head .btn svg { width: 18px; height: 18px; }
.challenge .verdict { margin: 8px 0 0; font-size: 20px; font-weight: 700; }
.challenge > .small { margin-top: 6px; line-height: 1.35; }
.challenge-form { margin-top: 10px; }
.challenge-make { margin: 0 0 12px; }
.challenge-make > .btn { width: 100%; }
.challenge-make > .btn svg { fill: var(--accent); }
.challenge-make .challenge-what { margin-top: 6px; text-align: center; line-height: 1.35; }
.challenge-make .feedback:empty { display: none; }
.challenge-make .challenge-head { margin-top: 2px; }
.challenges-theirs:empty, .challenges-mine:empty { display: none; }
