/* Goatascout Trail: every style. The house look (Fredoka, lavender #c9a5ef, sky #67adff, pink #ff7ac3, gold #ffd642,
   big rounded buttons >= 44 px, no emoji) on a parchment trail. Layouts: 1366x768 Chromebook, phone portrait and
   landscape. `html.calm` (Calm motion, or prefers-reduced-motion) stops decorative motion. */
@font-face {
  font-family: 'Fredoka'; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url('/assets/fonts/fredoka-v1.woff2') format('woff2');
}
:root {
  --lav: #c9a5ef; --lav-deep: #7a52a6; --sky: #67adff; --pink: #ff7ac3; --gold: #ffd642; --gold-deep: #b8771a;
  --plum: #35233f; --plum-2: #5b4468; --cream: #fff6e4; --paper: #f4e6c4; --ink: #5a3a1e; --forest: #2f6b3e;
  --panel: rgba(255, 248, 234, .97); --shadow: 0 10px 28px rgba(90, 50, 120, .22);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Fredoka', ui-rounded, 'Arial Rounded MT Bold', system-ui, sans-serif; font-weight: 500;
  color: var(--plum); background: var(--lav); overflow: hidden;
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--plum); outline-offset: 3px; box-shadow: 0 0 0 6px var(--gold); }
[hidden] { display: none !important; }
img, svg { -webkit-user-drag: none; }
.noscript { padding: 2rem; font-size: 1.2rem; }
.fatal { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; padding: 24px; }
h1, h2, h3 { line-height: 1.1; }

/* ---------- surfaces ---------- */
#game { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; background: #1d1630; touch-action: none; outline: none; }
#app { position: fixed; inset: 0; }
#layer { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
#layer > .view { pointer-events: auto; }
.view { position: absolute; inset: 0; }
html.in-flight #app { pointer-events: none; }
html.in-flight #app .view { background: transparent; }
.scrolls { overflow-y: auto; touch-action: pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.scrolls-x { overflow-x: auto; touch-action: pan-x; overscroll-behavior: contain; }

/* ---------- buttons ---------- */
.btn {
  min-height: 48px; border: 0; border-radius: 999px; padding: .6em 1.5em; font-size: 1.15rem; font-weight: 700; color: var(--plum);
  background: linear-gradient(#ffeaa6, #ffc84a 55%, #f0a92a);
  box-shadow: 0 5px 0 var(--gold-deep), 0 10px 22px rgba(120, 70, 20, .28), 0 2px 0 rgba(255, 255, 255, .8) inset;
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--gold-deep), 0 4px 10px rgba(120, 70, 20, .25); }
.btn[aria-disabled="true"] { filter: grayscale(.7); cursor: default; transform: none; }
.btn-soft { background: linear-gradient(#fff, #f3e6ff); box-shadow: 0 4px 0 #b99bd6, 0 8px 18px rgba(90, 50, 120, .18); }
.btn-soft:active { box-shadow: 0 1px 0 #b99bd6; }
.chip {
  min-height: 44px; border: 0; border-radius: 999px; padding: .4em 1.05em; font-size: 1rem; font-weight: 600;
  background: rgba(255, 255, 255, .9); color: var(--plum); box-shadow: 0 3px 10px rgba(90, 50, 120, .2);
  display: inline-flex; align-items: center; gap: .4em; text-decoration: none;
}
.chip[aria-disabled="true"] { opacity: .6; }
.wallet { display: inline-flex; align-items: center; gap: .35em; min-height: 44px; padding: .2em .9em .2em .4em; border-radius: 999px;
  background: rgba(255, 255, 255, .92); font-weight: 700; font-size: 1.2rem; box-shadow: 0 3px 10px rgba(90, 50, 120, .2); font-variant-numeric: tabular-nums; }
.cookie-svg { width: 30px; height: 30px; flex: none; }
.stars { display: inline-flex; gap: 2px; }
.star-svg { width: 22px; height: 22px; }
.notice { margin: 6px auto; padding: .4em 1em; border-radius: 12px; background: #fff3c4; color: #5a3a00; font-weight: 600; text-align: center; max-width: 40em; }
.toast { position: fixed; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); z-index: 40; max-width: min(92vw, 34em);
  background: var(--plum); color: #fff; padding: .6em 1.1em; border-radius: 14px; font-weight: 600; box-shadow: var(--shadow); text-align: center; }
.small { font-size: .95rem; color: var(--plum-2); }
.update-banner { position: absolute; top: calc(70px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 5; display: flex; gap: .6em; align-items: center;
  background: var(--plum); color: #fff; padding: .35em .5em .35em 1em; border-radius: 999px; box-shadow: var(--shadow); }

/* ---------- title: the flyover ---------- */
.screen-title { overflow: hidden; background: #241b45; }
.title-paint { position: absolute; inset: 0; overflow: hidden; }
.title-move { position: absolute; inset: 0; transform: scale(1.08); transform-origin: 50% 50%; will-change: transform;
  animation: title-settle 1.4s cubic-bezier(.16, 1, .3, 1) backwards, title-pan 90s ease-in-out 1.4s infinite alternate; }
.title-move img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 76% 42%; }
.title-no-paint .title-paint { background:
  radial-gradient(60% 45% at 25% 20%, rgba(255, 255, 255, .6), transparent 70%),
  radial-gradient(40% 30% at 80% 75%, rgba(255, 122, 195, .35), transparent 70%),
  linear-gradient(#9cc9ff 0%, #c9a5ef 55%, #ffd9c2 100%); }
.title-glint { position: absolute; translate: -50% -50%; pointer-events: none; border-radius: 50%; opacity: 0; mix-blend-mode: screen;
  background: radial-gradient(circle, rgba(255, 255, 255, .95) 0 14%, rgba(255, 244, 190, .6) 34%, transparent 66%);
  animation: title-glint 1.1s cubic-bezier(.2, .9, .3, 1) 1.25s backwards; }
.title-glint::before { content: ''; position: absolute; inset: 8%; background: #fff; clip-path: polygon(50% 0, 56% 44%, 100% 50%, 56% 56%, 50% 100%, 44% 56%, 0 50%, 44% 44%); }
.title-stage { position: absolute; inset: 0; }
.wordmark { position: absolute; left: 50%; top: calc(6% + var(--safe-t)); translate: -50% 0; margin: 0; width: min(46vw, 30vh * 2.57, 640px);
  filter: drop-shadow(0 10px 18px rgba(30, 15, 50, .4)); animation: title-wordmark 1.1s cubic-bezier(.16, 1, .3, 1) .15s backwards; }
.wordmark img { display: block; width: 100%; height: auto; }
.wordmark-text { display: flex; flex-direction: column; align-items: center; line-height: .95; text-align: center; }
.wm-a { font-size: clamp(2.6rem, 8vw, 5rem); font-weight: 700; color: var(--forest); text-shadow: 0 3px 0 #fff, 0 6px 14px rgba(53, 35, 63, .25); letter-spacing: .01em; }
.wm-b { font-size: clamp(1.6rem, 4.6vw, 2.8rem); font-weight: 700; color: var(--plum); background: var(--gold); padding: .05em .6em .1em; border-radius: 999px; margin-top: .15em; box-shadow: 0 4px 0 var(--gold-deep); }
.title-goat-slot { position: absolute; left: 19%; top: 50%; translate: -50% -50%; height: clamp(150px, 38vh, 300px); }
.title-goat { height: 100%; background-repeat: no-repeat; filter: drop-shadow(0 16px 16px rgba(30, 15, 50, .4));
  animation: title-goat-in 1.2s cubic-bezier(.16, 1, .3, 1) .2s backwards, bob 2.8s ease-in-out 1.4s infinite; }
.title-goat-drawn { aspect-ratio: 1; }
.title-goat-drawn svg { width: 100%; height: 100%; }
.patch-slot { position: absolute; left: 50%; top: 58%; translate: -50% -50%; }
.patch { position: relative; width: clamp(132px, 23vh, 180px); aspect-ratio: 1; border-radius: 50%; border: 0; padding: 0; display: grid; place-items: center;
  color: var(--cream); font-weight: 700; font-size: clamp(1.6rem, 5.2vh, 2.3rem); letter-spacing: .05em; text-transform: uppercase; line-height: 1;
  background: radial-gradient(circle at 38% 30%, #56a467 0, #3b7f4b 38%, #285a34 100%);
  box-shadow: 0 4px 0 #1d4528, 0 16px 30px rgba(30, 15, 20, .48), inset 0 2px 0 rgba(255, 255, 255, .2), inset 0 -10px 16px rgba(0, 0, 0, .2);
  transition: transform .12s, box-shadow .12s, filter .15s; animation: title-patch .7s cubic-bezier(.16, 1, .3, 1) .8s backwards; }
.patch-ring { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.patch-word { position: relative; text-shadow: 0 2px 0 #1d4528, 0 4px 8px rgba(0, 0, 0, .35); }
.patch:hover { filter: brightness(1.08); }
.patch:active { transform: scale(.95); box-shadow: 0 1px 0 #1d4528, 0 6px 14px rgba(30, 15, 20, .4), inset 0 2px 0 rgba(255, 255, 255, .2), inset 0 -6px 12px rgba(0, 0, 0, .2); }
.patch:focus-visible { outline: 4px solid #fff; outline-offset: 5px;
  box-shadow: 0 4px 0 #1d4528, 0 16px 30px rgba(30, 15, 20, .48), 0 0 0 11px rgba(255, 214, 66, .6), inset 0 2px 0 rgba(255, 255, 255, .2), inset 0 -10px 16px rgba(0, 0, 0, .2); }
.made-by { position: absolute; left: 50%; bottom: calc(54px + var(--safe-b)); translate: -50% 0; margin: 0; white-space: nowrap; font-size: .9rem; font-weight: 600; color: #fff;
  background: rgba(37, 27, 60, .72); padding: .25em .9em; border-radius: 999px; animation: title-fade .6s ease-out 1.1s backwards; }
.title-tabs { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; align-items: flex-end; gap: 10px;
  padding: 0 calc(12px + var(--safe-r)) var(--safe-b) calc(12px + var(--safe-l)); animation: title-fade .6s ease-out 1.1s backwards; }
.title-install:empty { display: none; }
.stitch { position: relative; min-height: 44px; display: inline-flex; align-items: center; padding: .4em 1.15em .55em; border: 0; border-radius: 16px 16px 0 0;
  font-weight: 700; font-size: 1rem; color: var(--ink); text-decoration: none; background: linear-gradient(#fffaf0, #f0e0bf);
  box-shadow: 0 -5px 16px rgba(30, 15, 50, .3), inset 0 0 0 2px #fffaf0; transition: background .15s, translate .12s; }
.stitch::before { content: ''; position: absolute; inset: 5px 5px 0; border: 2px dashed rgba(90, 58, 30, .42); border-bottom: 0; border-radius: 12px 12px 0 0; pointer-events: none; }
.stitch:hover { background: linear-gradient(#fff, #f7ead0); translate: 0 -2px; }
.stitch:active { translate: 0 1px; }
@keyframes title-settle { from { transform: scale(1.18); } to { transform: scale(1.08) translateX(-3%); } }
@keyframes title-pan { from { transform: scale(1.08) translateX(-3%); } to { transform: scale(1.08) translateX(3%); } }
@keyframes title-wordmark { from { opacity: 0; transform: translateY(-44px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes title-goat-in { from { transform: translateX(calc(-30vw - 120%)) rotate(-6deg); } to { transform: none; } }
@keyframes title-patch { from { opacity: 0; transform: translateY(44px) scale(.8); } to { opacity: 1; transform: none; } }
@keyframes title-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes title-glint { 0% { opacity: 0; transform: scale(0) rotate(0deg); } 30% { opacity: 1; transform: scale(1.25) rotate(25deg); } 100% { opacity: 0; transform: scale(.3) rotate(70deg); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
html.calm .title-glint { display: none; }
.screen-title:not(.is-ready) :is(.title-move, .wordmark, .title-goat, .patch, .made-by, .title-tabs, .title-glint) { animation-play-state: paused; }

/* ---------- map ---------- */
.screen-map { display: flex; flex-direction: column; background: linear-gradient(#a9d3ff, #c9a5ef); padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }
.map-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; flex-wrap: wrap; }
.map-nav { display: flex; gap: 8px; flex-wrap: wrap; }
.map-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 4px 12px; }
.map-frame { position: relative; aspect-ratio: 3 / 2; width: min(100%, calc((100vh - 170px) * 1.5)); width: min(100%, calc((100dvh - 170px) * 1.5)); border-radius: 22px; box-shadow: var(--shadow); }
.map-paper, .map-paint { position: absolute; inset: 0; border-radius: 22px; overflow: hidden; }
.map-paint img { width: 100%; height: 100%; object-fit: cover; }
.map-paper { background:
  radial-gradient(30% 22% at 22% 30%, rgba(160, 200, 120, .45), transparent 70%),
  radial-gradient(28% 30% at 70% 55%, rgba(190, 160, 110, .35), transparent 70%),
  radial-gradient(18% 14% at 88% 30%, rgba(120, 170, 220, .4), transparent 70%),
  radial-gradient(120% 100% at 50% 50%, #f8ecd0 55%, #e7cf9d 100%);
  border: 6px solid #e2c48c; }
.map-trail, .map-leaders { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.map-leaders { z-index: 1; }
.medal {
  position: absolute; transform: translate(-50%, -50%); width: clamp(76px, 9.5vw, 116px); padding: 4px 4px 6px; border: 0; border-radius: 18px;
  background: #fff8ea; box-shadow: 0 6px 16px rgba(90, 50, 40, .28); display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-height: 44px; z-index: 2;
}
.medal-face { width: clamp(46px, 5.6vw, 70px); aspect-ratio: 1; display: block; position: relative; }
.medal-face svg, .medal-face img { width: 100%; height: 100%; border-radius: 50%; }
.medal-badge { position: absolute; top: -6px; right: -6px; width: 34px; height: 34px; }
.medal-badge svg, .medal-badge img { width: 100%; height: 100%; }
.medal-name { font-size: .78rem; font-weight: 700; line-height: 1.05; text-align: center; color: var(--plum); }
.medal-years { font-size: .72rem; font-weight: 600; color: var(--ink); }
.medal-stars .star-svg { width: 15px; height: 15px; }
.medal-open { outline: 4px solid var(--gold); animation: glow 1.8s ease-in-out infinite; }
.medal-locked .medal-face, .medal-soon .medal-face { filter: grayscale(.9); opacity: .75; }
.medal-locked, .medal-soon { background: #efe8da; }
.medal-broken .medal-face { filter: grayscale(1); opacity: .45; }
.medal-broken { background: #e6e0d6; }
@keyframes glow { 0%, 100% { box-shadow: 0 6px 16px rgba(90, 50, 40, .28), 0 0 0 0 rgba(255, 214, 66, .7); } 50% { box-shadow: 0 6px 16px rgba(90, 50, 40, .28), 0 0 0 10px rgba(255, 214, 66, 0); } }
.map-walker, .rider { position: absolute; width: clamp(54px, 6vw, 82px); aspect-ratio: 1; transform: translate(-135%, -70%); pointer-events: none; z-index: 3; }
.map-walker svg { width: 100%; height: 100%; animation: bob 2.4s ease-in-out infinite; }
.rider { width: clamp(70px, 8vw, 110px); transform: translate(-50%, -80%); }
.rider .vehicle-svg, .rider > img:first-child { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 60%; }
.rider .hero-svg { position: absolute; left: 18%; bottom: 34%; width: 64%; height: 64%; }
.ribbon { list-style: none; margin: 0; padding: 6px 14px 10px; display: flex; gap: 6px; justify-content: center; }
.ribbon li { flex: none; padding: .25em .8em; border-radius: 999px; background: rgba(255, 255, 255, .6); color: var(--plum-2); font-weight: 600; font-size: .95rem; }
.ribbon li.reached { background: var(--forest); color: #fff; }
.ribbon li + li::before { content: ''; display: inline-block; width: 10px; height: 2px; background: currentColor; margin-right: 6px; vertical-align: middle; opacity: .6; }
.note-card { position: absolute; left: 50%; bottom: calc(64px + var(--safe-b)); transform: translateX(-50%); z-index: 10; width: min(92vw, 34em);
  background: var(--panel); border-radius: 20px; padding: 14px 18px; box-shadow: var(--shadow); text-align: center; }
.note-kicker { margin: 0 0 4px; font-weight: 700; color: var(--forest); }
.note-text { margin: 0 0 10px; font-size: 1.15rem; line-height: 1.35; }

/* ---------- camp ---------- */
.screen-camp { background: radial-gradient(70% 60% at 50% 100%, #ffb36b, transparent 70%), linear-gradient(#2b2f5e, #6b4f8c 60%, #c9a5ef); color: var(--plum);
  display: flex; flex-direction: column; padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }
.camp-head { padding: 10px 14px; }
.camp-main { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 0 14px 14px; }
.camp-who { display: flex; gap: 14px; align-items: center; background: var(--panel); padding: 10px 18px; border-radius: 20px; box-shadow: var(--shadow); }
.camp-portrait { width: 64px; height: 64px; flex: none; }
.camp-portrait svg, .camp-portrait img { width: 100%; height: 100%; border-radius: 50%; }
.camp-title { margin: 0; font-size: 1.5rem; }
.camp-person, .camp-place { margin: 2px 0 0; font-weight: 600; color: var(--plum-2); }
.camp-ask { margin: 6px 0 0; color: #fff; text-shadow: 0 2px 6px rgba(0, 0, 0, .35); font-size: 1.35rem; }
.supplies { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.supply { width: min(42vw, 250px); min-height: 44px; border: 0; border-radius: 22px; padding: 14px 12px 16px; background: var(--panel); box-shadow: 0 6px 0 #b99bd6, var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 4px; }
.supply:active { transform: translateY(4px); box-shadow: 0 2px 0 #b99bd6; }
.supply-last-pick { outline: 4px solid var(--gold); }
.supply-pic { width: min(24vw, 120px); aspect-ratio: 1; }
.supply-pic svg, .supply-pic img { width: 100%; height: 100%; }
.supply-name { font-size: 1.4rem; font-weight: 700; }
.supply-line { font-size: .98rem; color: var(--plum-2); line-height: 1.25; }
.supply-last { font-size: .85rem; font-weight: 700; color: var(--forest); }
.supply[aria-disabled="true"] { opacity: .7; }
.camp-status { margin: 0; min-height: 1.3em; color: #fff; font-weight: 600; text-shadow: 0 1px 4px rgba(0, 0, 0, .4); }
.chip.ready { background: #d6f5dc; }

/* ---------- result ---------- */
.screen-result { overflow-y: auto; background: radial-gradient(80% 60% at 50% 0%, #fff4c4, transparent 70%), linear-gradient(#ffd9c2, #c9a5ef); }
.result-main { min-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: calc(16px + var(--safe-t)) 16px calc(20px + var(--safe-b)); text-align: center; }
.result-kicker { margin: 0; font-weight: 700; color: var(--forest); text-transform: uppercase; letter-spacing: .08em; }
.result-title { margin: 0; font-size: clamp(1.8rem, 4vw, 2.6rem); }
.result-arrival { margin: 0; max-width: 36em; font-size: 1.1rem; }
.sash-strip { display: flex; gap: 8px; padding: 10px 18px; border-radius: 999px; background: linear-gradient(#d9b680, #c39a5b); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .4), var(--shadow); }
.sash-slot { width: clamp(40px, 6vw, 58px); aspect-ratio: 1; }
.sash-slot svg, .sash-slot img { width: 100%; height: 100%; }
.sash-slot.drop { animation: drop .9s cubic-bezier(.3, 1.5, .5, 1) .3s both; }
@keyframes drop { from { transform: translateY(-120px) scale(1.6) rotate(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }
.result-stars { display: flex; gap: 8px; }
.rstar { width: 52px; height: 52px; }
.rstar svg { width: 100%; height: 100%; }
.rstar.on { transform: scale(0); }
.rstar.on.pop { animation: pop .45s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
.result-cookies { margin: 0; display: flex; align-items: center; gap: .3em; font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.result-h { margin: 8px 0 0; font-size: 1.2rem; }
.fact-cards { list-style: none; margin: 0; padding: 0; display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; max-width: 900px; }
.fact-card { width: 150px; background: #fff; border-radius: 16px; padding: 8px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; animation: slidein .5s ease both; animation-delay: calc(1.6s + var(--i) * .18s); }
@keyframes slidein { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.fact-pic { aspect-ratio: 1; border-radius: 10px; background: #f3e9ff; display: grid; place-items: center; overflow: hidden; }
.fact-pic img { width: 100%; height: 100%; object-fit: cover; }
.fact-label { padding: 8px; font-weight: 700; color: var(--plum); font-size: 1rem; line-height: 1.2; }
.fact-cap { font-weight: 600; font-size: .95rem; line-height: 1.2; }
.tell { margin: 4px 0 0; max-width: 40em; }
.result-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }

/* ---------- overlays ---------- */
.overlay-card, .overlay-sheet { display: grid; place-items: center; background: rgba(35, 22, 48, .55); padding: calc(10px + var(--safe-t)) 10px calc(10px + var(--safe-b)); }
.card { width: min(92vw, 30em); background: var(--panel); border-radius: 24px; padding: 20px 22px; box-shadow: var(--shadow); text-align: center; }
.card h2 { margin: 0 0 6px; font-size: 1.6rem; }
.card-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.sheet { width: min(96vw, 860px); height: min(100%, 720px); background: var(--panel); border-radius: 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px 6px; }
.sheet-head h2 { margin: 0; font-size: 1.5rem; }
.sheet-body { flex: 1; min-height: 0; padding: 6px 18px 18px; }
.sheet-body h3 { margin: 16px 0 8px; font-size: 1.2rem; }
.tabs { display: flex; gap: 6px; padding: 0 16px 6px; flex-wrap: wrap; }
.tab { min-height: 44px; border: 0; border-radius: 999px; padding: .35em 1em; font-weight: 700; background: rgba(122, 82, 166, .12); }
.tab[aria-selected="true"] { background: var(--lav-deep); color: #fff; }
.empty { color: var(--plum-2); font-size: 1.05rem; }

/* journal */
.sash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; padding: 8px 0; }
.sash-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.sash-badge { width: 72px; height: 72px; }
.sash-badge svg, .sash-badge img { width: 100%; height: 100%; }
.sash-name { font-weight: 700; font-size: .95rem; }
.sash-wait { font-size: .9rem; color: var(--plum-2); }
.jstop { margin: 10px 0 18px; }
.jstop-head { display: flex; align-items: center; gap: 12px; }
.jstop-head h3 { margin: 0; }
.jstop-head p { margin: 2px 0 0; color: var(--plum-2); font-weight: 600; }
.jstop-face { width: 52px; height: 52px; flex: none; }
.jstop-face svg, .jstop-face img { width: 100%; height: 100%; border-radius: 50%; }
.jcards { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.jcard { background: #fff; border-radius: 16px; padding: 10px; box-shadow: 0 3px 10px rgba(90, 50, 120, .14); }
.jcard.unseen { background: rgba(255, 255, 255, .5); color: var(--plum-2); display: grid; place-items: center; min-height: 80px; text-align: center; }
.jcard-play { width: 100%; border: 0; background: none; padding: 0; display: flex; gap: 10px; align-items: center; text-align: left; min-height: 44px; }
.jcard-pic { width: 72px; height: 72px; flex: none; border-radius: 10px; background: #f3e9ff; display: grid; place-items: center; overflow: hidden; }
.jcard-pic img { width: 100%; height: 100%; object-fit: cover; }
.jcard-pic .fact-label { font-size: .8rem; padding: 4px; text-align: center; }
.jcard-cap { font-weight: 700; font-size: 1.05rem; }
.jcard-text { margin: 8px 0 4px; font-size: .98rem; line-height: 1.35; }
.jcard-tell, .jcard-count { margin: 4px 0 0; font-size: .92rem; color: var(--plum-2); }
.notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.note { display: flex; gap: 12px; align-items: center; background: #fff; border-radius: 16px; padding: 10px 14px; }
.note.unseen { background: rgba(255, 255, 255, .5); color: var(--plum-2); }
.note h3 { margin: 0 0 4px; font-size: 1.05rem; }
.note p { margin: 0; }
.note-veh { width: 72px; flex: none; }
.note-veh svg { width: 100%; }
.prompts { padding-left: 1.1em; line-height: 1.5; font-size: 1.05rem; }

/* outfits */
.outfit-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 18px; }
.outfit-preview { position: relative; width: 180px; height: 110px; display: flex; justify-content: flex-end; }
.outfit-preview .hero-svg { position: relative; width: 110px; height: 110px; }
.trail-sample { position: absolute; left: 0; top: 50%; width: 90px; height: 16px; border-radius: 8px; transform: translateY(-50%); opacity: .9; }
.items { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.item { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "sw name" "sw price" "act act"; gap: 2px 10px; align-items: center; background: #fff; border-radius: 16px; padding: 10px; }
.item.on { outline: 3px solid var(--gold); }
.swatch { grid-area: sw; width: 44px; height: 44px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(53, 35, 63, .2); }
.swatch.trail { border-radius: 12px; }
.item-name { grid-area: name; font-weight: 700; }
.item-price { grid-area: price; display: inline-flex; align-items: center; gap: .25em; font-weight: 600; color: var(--plum-2); }
.item-price .cookie-svg { width: 20px; height: 20px; }
.item .btn, .item .wearing { grid-area: act; margin-top: 6px; justify-self: stretch; text-align: center; }
.item .btn { font-size: 1rem; padding: .45em 1em; }
.wearing { font-weight: 700; color: var(--forest); padding: .6em; }

/* settings */
.toggles { display: grid; gap: 8px; }
.switch { min-height: 56px; width: 100%; border: 0; border-radius: 16px; background: #fff; padding: 8px 14px; display: grid; grid-template-columns: 1fr auto; grid-template-areas: "n s" "h s"; text-align: left; align-items: center; }
.sw-name { grid-area: n; font-weight: 700; font-size: 1.08rem; }
.sw-hint { grid-area: h; font-size: .92rem; color: var(--plum-2); }
.sw-state { grid-area: s; min-width: 64px; text-align: center; padding: .3em .8em; border-radius: 999px; background: #e9dff3; font-weight: 700; }
.switch[aria-checked="true"] .sw-state { background: var(--forest); color: #fff; }
.pace { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: #fff; border-radius: 16px; padding: 8px 14px; }
.pace .sw-hint { flex-basis: 100%; }
.seg { min-height: 44px; border: 0; border-radius: 999px; padding: .3em 1.1em; font-weight: 700; background: #e9dff3; }
.seg[aria-checked="true"] { background: var(--lav-deep); color: #fff; }
.code { width: 100%; font: 600 .9rem ui-monospace, Menlo, monospace; border-radius: 12px; border: 2px solid #d8c6ea; padding: 8px; margin: 6px 0; background: #fff; color: var(--plum); resize: vertical; }
.backup-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.restore-preview p { margin: 6px 0; }
.restore-preview .bad { color: #8a1f3d; font-weight: 700; }
.restore-preview .good { color: var(--forest); font-weight: 700; }

/* ---------- story ---------- */
/* The story overlay (DESIGN "The story"): the stop's painting pans behind (60 s, still under Calm motion), a parchment
   card at the top-left, the current sentence in a parchment band rising from the bottom edge like the stitched tabs.
   The page is a column (card, then band), so the band shrinks and scrolls before it could ever cover the card. */
.overlay-story { overflow: hidden; background: #241b45; }
.story-bg { position: absolute; inset: 0; overflow: hidden; }
.story-strip { position: absolute; top: 0; left: 0; height: 100%; min-width: 100%; display: flex; will-change: transform;
  animation: story-pan 60s ease-in-out infinite alternate; }
.story-strip img { flex: 1 0 auto; display: block; height: 100%; width: auto; object-fit: cover; }
.story-still .story-strip { animation: none; }
@keyframes story-pan { from { transform: translateX(0); } to { transform: translateX(calc(100vw - 100%)); } }
.story-no-paint { background:
  radial-gradient(120% 55% at 18% 104%, #6fae63 0 54%, transparent 55%),
  radial-gradient(110% 50% at 86% 104%, #9fd18a 0 54%, transparent 55%),
  radial-gradient(60% 45% at 25% 18%, rgba(255, 255, 255, .6), transparent 70%),
  linear-gradient(#9cc9ff 0%, #c9a5ef 55%, #ffd9c2 100%); }
.story-page { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: space-between; gap: 12px;
  padding: calc(12px + var(--safe-t)) calc(12px + var(--safe-r)) var(--safe-b) calc(12px + var(--safe-l)); }
.story-card { position: relative; flex: none; align-self: flex-start; display: flex; align-items: center; gap: 12px; max-width: min(100%, 30rem);
  padding: 10px 18px 10px 10px; border-radius: 22px; color: var(--ink); background: linear-gradient(#fffaf0, #f0e0bf);
  box-shadow: inset 0 0 0 2px #fffaf0, var(--shadow); }
.story-card::before { content: ''; position: absolute; inset: 5px; border: 2px dashed rgba(90, 58, 30, .42); border-radius: 17px; pointer-events: none; }
.story-portrait { flex: none; width: 64px; height: 64px; }
.story-portrait svg, .story-portrait img { width: 100%; height: 100%; border-radius: 50%; }
.story-kicker { margin: 0; font-size: .92rem; font-weight: 700; color: var(--forest); }
.story-title { margin: 0; font-size: clamp(1.2rem, 1rem + 1vw, 1.6rem); color: var(--plum); }
.story-person { margin: 2px 0 0; font-weight: 600; color: var(--plum-2); }
.story-band { position: relative; flex: 0 1 auto; min-height: 0; align-self: center; width: min(100%, 1000px);
  display: grid; grid-template-columns: minmax(0, max-content) auto; grid-template-areas: "dots dots" "text actions";
  justify-content: center; align-items: center; gap: 10px 26px; padding: 16px 26px 18px; border-radius: 24px 24px 0 0;
  color: var(--ink); background: linear-gradient(#fffaf0, #f0e0bf); box-shadow: 0 -5px 16px rgba(30, 15, 50, .3), inset 0 0 0 2px #fffaf0; }
.story-band::before { content: ''; position: absolute; inset: 6px 6px 0; border: 2px dashed rgba(90, 58, 30, .42); border-bottom: 0;
  border-radius: 19px 19px 0 0; pointer-events: none; }
.story-dots { grid-area: dots; list-style: none; margin: 0; padding: 0; display: flex; justify-content: center; gap: 10px; }
.story-dot { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--gold-deep); background: rgba(255, 255, 255, .6); }
.story-dot.on { background: var(--gold); box-shadow: 0 0 0 3px rgba(255, 214, 66, .45); }
.story-text { grid-area: text; margin: 0; max-width: 38ch; font-size: clamp(1.3rem, 1rem + 1.1vw, 2rem); font-weight: 600; line-height: 1.3; color: var(--plum); }
.story-actions { grid-area: actions; display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
.story-actions .chip, .story-actions .btn { justify-content: center; white-space: nowrap; min-width: 7.5em; }
.camp-ask-row { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 14px; }
.camp-story { font-weight: 700; }
.jstop-story { margin-left: auto; }
@media (max-width: 600px) {
  .story-band { grid-template-columns: minmax(0, 1fr); grid-template-areas: "dots" "text" "actions"; gap: 10px; padding: 14px 18px 16px; }
  .story-actions { flex-direction: row; justify-content: center; }
  .story-actions .chip, .story-actions .btn { min-width: 0; flex: 1 1 0; max-width: 12em; }
  .story-portrait { width: 52px; height: 52px; }
}
@media (max-height: 460px) {
  .story-page { gap: 8px; padding-top: calc(8px + var(--safe-t)); }
  .story-card { padding: 6px 14px 6px 6px; gap: 10px; }
  .story-portrait { width: 44px; height: 44px; }
  .story-kicker { font-size: .8rem; }
  .story-title { font-size: 1.15rem; }
  .story-person { font-size: .9rem; }
  .story-band { gap: 6px 22px; padding: 10px 22px 10px; }
  .story-text { font-size: 1.3rem; line-height: 1.25; }
  .story-dot { width: 11px; height: 11px; }
  .camp-ask-row { flex-basis: 100%; }
  .camp-ask-row .camp-ask { flex-basis: auto; }
}

/* ---------- phones ---------- */
@media (max-width: 600px) {
  .wordmark { width: min(66vw, 320px); top: calc(2.5% + var(--safe-t)); }
  .title-goat-slot { left: 44%; top: 47%; height: min(30vh, 60vw); }
  .patch-slot { top: 75%; }
  .map-bar { padding: 8px 10px; }
  .map-nav .chip { padding: .4em .8em; }
  .ribbon { justify-content: flex-start; }
  .medal { width: 66px; padding: 3px; }
  .medal-face { width: 44px; }
  .medal-name { font-size: .7rem; }
  .medal-years { display: none; }
  .supply { width: min(44vw, 200px); padding: 10px 8px; }
  .fact-card { width: calc(33.3% - 8px); padding: 5px; }
  .fact-label { font-size: .82rem; padding: 4px; }
  .fact-cap { font-size: .82rem; }
  .result-actions { order: 1; }
  .result-h, .fact-cards, .tell { order: 2; }
  .rstar { width: 44px; height: 44px; }
}
@media (max-height: 460px) {
  .wordmark { top: calc(4% + var(--safe-t)); width: min(44vw, 34vh * 2.57); }
  .wm-a { font-size: 2.4rem; } .wm-b { font-size: 1.4rem; }
  .title-goat-slot { left: 15%; top: 52%; height: 42vh; }
  .patch-slot { top: 61%; }
  .patch { width: clamp(104px, 31vh, 150px); font-size: clamp(1.3rem, 6.5vh, 1.9rem); }
  .made-by { bottom: calc(48px + var(--safe-b)); font-size: .8rem; }
  .stitch { padding: .25em 1em .4em; font-size: .92rem; }
  .map-bar { padding: 4px 10px; }
  .map-frame { width: min(100%, calc((100dvh - 120px) * 1.5)); }
  .ribbon { padding: 2px 10px 6px; }
  .medal { width: 64px; padding: 2px; }
  .medal-face { width: 38px; }
  .medal-years { display: none; }
  .camp-main { flex-direction: row; flex-wrap: wrap; align-content: center; gap: 8px 14px; }
  .camp-who { padding: 6px 12px; }
  .camp-ask { flex-basis: 100%; text-align: center; margin: 0; font-size: 1.1rem; }
  .supply { flex-direction: row; width: min(44vw, 330px); text-align: left; padding: 8px 12px; gap: 8px 10px; display: grid; grid-template-columns: auto 1fr; grid-template-areas: "p n" "p l" "p x"; }
  .supply-pic { grid-area: p; width: 72px; } .supply-name { grid-area: n; } .supply-line { grid-area: l; font-size: .9rem; } .supply-last { grid-area: x; }
  .sheet { height: 100%; }
  .result-main { gap: 6px; }
  .rstar { width: 40px; height: 40px; }
  .result-actions { order: 1; }
  .result-h, .fact-cards, .tell { order: 2; }
  .note-card { bottom: 8px; padding: 8px 14px; }
}

/* portrait phones: the 3:2 map keeps its full height and scrolls sideways (the current stop is scrolled into view) */
@media (max-aspect-ratio: 4/5) {
  .map-stage { display: flex; align-items: stretch; overflow-x: auto; overflow-y: hidden; touch-action: pan-x; overscroll-behavior: contain; padding: 4px 12px; }
  .map-frame { flex: 0 0 auto; height: 100%; width: auto; max-width: none; aspect-ratio: 3 / 2; }
  .map-bar { gap: 6px; }
}

/* ---------- calm motion ---------- */
html.calm *, html.calm *::before, html.calm *::after { animation: none !important; transition: none !important; }
html.calm .rstar.on { transform: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .rstar.on { transform: none; }
}
