:root {
  --bg: #5CD6C8;
  --text: #16324F;
  --text-secondary: #3F4F5C;
  --btn-bg: #0142AC;
  --btn-text: #FFFFFF;
  /* the universal layout stacks the pill above a row of small icons —
     reserves clearance up to the top of the pill (16mm bottom-offset +
     32px arrow-height shift + 66px pill height ≈ 158px), plus a margin */
  --btn-bar-height: 170px;
  /* real phones can reserve part of the bottom of the viewport for their
     own UI (the iPhone home-indicator bar, gesture nav, etc) — this reads
     that reserved height (0 on devices without one) so the button bar adds
     clearance automatically instead of ever sitting under it. Requires
     viewport-fit=cover on the <meta viewport> tag to report anything. */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* per-screen nudge applied to .btn-bar's resting position (see the
     .btn-bar overrides below) — pulled out to a variable, inherited from
     each screen section, so text positioned above the bar can account for
     the exact same offset instead of guessing at a fixed ratio. Every
     button is now the same simple pill/ring shape at the same bar
     position, so this should stay at 0px except for a screen with a
     genuine content reason to sit higher (see #screen-treasure-intro). */
  --bar-extra: 0px;
  /* distance from the very bottom of a wallpaper screen up to just above
     the button bar. Shared by that text block and by screen 1's flower
     photo, so both clear the button by the same amount. */
  --mid-clear: calc(5mm + var(--bar-extra) + var(--safe-bottom) + var(--btn-bar-height) + 3mm);
}

@font-face {
  font-family: "ParkVoyage Ink";
  src: url('ParkVoyage-Ink.ttf?v=2') format('truetype');
  font-weight: 400;
}

@font-face {
  font-family: "ParkVoyage Display";
  src: url('ParkVoyage-Display.ttf?v=2') format('truetype');
  font-weight: 400;
}

* { box-sizing: border-box; }

/* --- warm cream theme (screens 1-7, hub): swaps background + body copy
   over to the Ink flow font, trialled alongside the wreath-circle button --- */
.theme-cream {
  --bg: #FAF5EA;
  background: var(--bg);
}
.theme-cream .screen-text,
.theme-cream .screen-desc-plain,
.theme-cream .choice-pill,
.theme-cream .required-mark {
  font-family: "ParkVoyage Ink", serif;
}
.theme-cream .screen-text { font-weight: 400; }
.theme-cream .screen-text strong { font-weight: 400; }
.theme-cream .choice-pill { font-weight: 400; font-size: 18px; }

/* centre the body copy instead of left-justifying it. Screens 1, 4 sit
   their text over a photo with its own already-tuned position, so
   they're deliberately left out of this rule. */
#screen-0 .screen-text, #screen-2 .screen-text, #screen-3 .screen-text,
#screen-5 .screen-text, #screen-6 .screen-text, #screen-7 .screen-text,
#screen-0 .screen-desc-plain, #screen-2 .screen-desc-plain, #screen-3 .screen-desc-plain,
#screen-5 .screen-desc-plain, #screen-6 .screen-desc-plain, #screen-7 .screen-desc-plain {
  text-align: center;
}
/* balance line breaks everywhere in 0-7 so a lone word never wraps onto
   its own line, regardless of alignment */
#screen-0 .screen-text, #screen-1 .screen-text, #screen-2 .screen-text,
#screen-3 .screen-text, #screen-4 .screen-text, #screen-5 .screen-text,
#screen-6 .screen-text, #screen-7 .screen-text,
#screen-0 .screen-desc-plain, #screen-1 .screen-desc-plain, #screen-2 .screen-desc-plain,
#screen-3 .screen-desc-plain, #screen-4 .screen-desc-plain, #screen-5 .screen-desc-plain,
#screen-6 .screen-desc-plain, #screen-7 .screen-desc-plain {
  text-wrap: balance;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  color: var(--text);
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

/* cream-themed screens (1-7, hub) shouldn't show the teal page background
   anywhere — including the strip around the 480px card on wide viewports */
body:has(.screen.theme-cream.active),
.app:has(.screen.theme-cream.active) {
  background: #FAF5EA;
}

/* screen 2: match the leaf-friends photo's own teal instead of the warm
   cream used everywhere else */
#screen-2 { --bg: #B3E6E1; }
body:has(#screen-2.active),
.app:has(#screen-2.active) {
  background: #B3E6E1;
}

/* screen 0 (title card): soft mint-green instead of the original teal
   (background colour only -- badges, button and font are unchanged) */
#screen-0 { --bg: #D3E6C4; }
body:has(#screen-0.active),
.app:has(#screen-0.active) {
  background: #D3E6C4;
}

/* --- per-voyage section colours: each of the 5 hub choices gets its own
   badge colour, carried through as the background on every screen in that
   section that doesn't already show a full-bleed image --- */
.sec-riddles,
.sec-treasure,
.sec-creature,
.sec-poem,
.sec-dance {
  background: var(--bg);
}
.sec-riddles  { --bg: #C7D8EE; }
.sec-treasure { --bg: #FFCE60; }
.sec-creature { --bg: #F1DEFE; }
.sec-poem     { --bg: #D0CDA5; }
.sec-dance    { --bg: #CAE5C5; }

body:has(.screen.sec-riddles.active),  .app:has(.screen.sec-riddles.active)  { background: #C7D8EE; }
body:has(.screen.sec-treasure.active), .app:has(.screen.sec-treasure.active) { background: #FFCE60; }
body:has(.screen.sec-creature.active), .app:has(.screen.sec-creature.active) { background: #F1DEFE; }
body:has(.screen.sec-poem.active),     .app:has(.screen.sec-poem.active)     { background: #D0CDA5; }
body:has(.screen.sec-dance.active),    .app:has(.screen.sec-dance.active)    { background: #CAE5C5; }

/* --- hub menu: each voyage choice in the same hand-drawn short-pill
   frame as the Next buttons, colour-coded to match its voyage's badge
   colour exactly (no tint) via the fill layer. Selection is shown with
   an outline ring instead of a colour swap, since the fill is already
   at full strength. Scoped to #screen-hub (both on specificity and to
   avoid touching the unrelated .choice-pill colour pickers in the
   treasure hunt, which keep their own plain-pill styling further down
   the sheet). --- */
#screen-hub .choice-pill {
  position: relative;
  z-index: 0;
  width: min(92%, 340px);
  min-height: 52px;
  margin: 0 auto;
  display: block;
  background: none;
  color: var(--text);
  font-family: "ParkVoyage Ink", serif;
  font-weight: 400;
  font-size: 18px;
  text-align: center;
  border: none;
  padding: 14px 20px;
  cursor: pointer;
}
#screen-hub .choice-pill::before,
#screen-hub .choice-pill::after {
  content: '';
  position: absolute;
  inset: -14% -6%;
  z-index: -1;
}
#screen-hub .choice-pill::before {
  z-index: -2;
  -webkit-mask-image: url('ButtonShapes/pv_pill_short_fill.png');
  mask-image: url('ButtonShapes/pv_pill_short_fill.png');
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}
#screen-hub .choice-pill::after {
  background-image: url('ButtonShapes/pv_pill_short.png');
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
}
/* selection reads as a shade change on the fill itself, not an added
   ring/circle */
#screen-hub .choice-pill.selected::before {
  filter: brightness(0.82);
}
#screen-hub .choice-pill[data-choice="riddles"]::before   { background-color: #C7D8EE; }
#screen-hub .choice-pill[data-choice="park-hunt"]::before { background-color: #FFCE60; }
#screen-hub .choice-pill[data-choice="creature"]::before  { background-color: #F1DEFE; }
#screen-hub .choice-pill[data-choice="poem"]::before      { background-color: #D0CDA5; }
#screen-hub .choice-pill[data-choice="dance"]::before     { background-color: #CAE5C5; }
#screen-hub .choice-pill[data-choice="done-all"]::before  { background-color: #EAF5F0; }

/* --- audio play/pause toggle: small, subtle, sitting above the right edge
   of the big "next" button (which itself sits flush with the container's
   24px right padding, same as .btn-bar) --- */
.audio-control {
  position: fixed;
  /* lines up under the Next pill's own right edge, same pattern as
     .btn-back on the left — worked out on screen-1, now the universal
     default (see the exclusions below for the few screens that keep
     their older multi-button layout instead). */
  left: calc(50vw + min(32vw, 120px));
  right: auto;
  transform: translateX(-50%);
  bottom: calc(var(--bar-extra) + var(--safe-bottom) + 8px);
  z-index: 20;
}
/* goodchoice-quad (4-option) screens keep their original back+next row
   and the toggle's old side-margin position — only the drawn style
   (bare icons, no ring) changed, not the layout. badge-dual screens now
   use the universal position below the centred stack. */
.app:has(.goodchoice-quad.active) .audio-control {
  left: auto;
  right: calc(((100vw - 66px - min(64vw, 240px)) / 2) - 6px - 26px);
  transform: none;
  bottom: calc(16mm + var(--bar-extra) + var(--safe-bottom) + 20px);
}

.audio-control.is-hidden { display: none; }

.audio-hint {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--btn-bg);
  background: rgba(255, 255, 255, 0.6);
  padding: 5px 10px;
  border-radius: 10px;
  white-space: nowrap;
}

/* only the title card needs the reminder that tapping the triangle starts
   the audio (in case autoplay was blocked) */
.app:has(#screen-0.active) .audio-hint { display: block; }

.audio-toggle {
  position: relative;
  z-index: 0;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* bare icon, no ring/fill behind it — same treatment as .btn-back */
.audio-toggle svg { width: 20px; height: 20px; }
.audio-toggle .icon-sound { width: 20px; height: 26px; object-fit: contain; }

.btn-next.is-hidden { display: none; }

/* --- title card (screen 0): centred image, no text, Begin button gated
   on the intro audio finishing --- */
.title-card {
  justify-content: center;
  align-items: center;
  position: relative;
}
/* .title-swap stacks the title and the acknowledgement in the same grid
   cell so one can fade out while the other fades in, in place. (Used to
   carry a translateY(9vh) nudge to compensate for a large reserved
   button area pushing the flex-centred content up — the button is much
   smaller now, so that's no longer needed and was reading as "too low".) */
.title-swap {
  display: grid;
}
.title-swap > * {
  grid-area: 1 / 1;
}
.title-group {
  /* stays on screen until the last badge (title-badge-5: 3.6s delay + 8.8s
     duration = 12.4s) has settled, then fades */
  animation: titleFadeOut 1s ease-in-out 12.6s both;
}
.title-image {
  width: 80%;
  max-width: 420px;
  max-height: 50vh;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

/* "VOYAGE" is set live in the twig display font rather than baked into the
   title image, so it can share a font-face with the rest of the twig type */
.title-word-voyage {
  display: block;
  width: 80%;
  max-width: 420px;
  margin: 1vh auto 0;
  font-family: "ParkVoyage Display", sans-serif;
  font-weight: 400;
  font-size: clamp(46px, 15vw, 86px);
  line-height: 1;
  text-align: center;
  color: var(--text);
}
@keyframes titleFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* Acknowledgement of Country: fades in as the title fades out (once the
   badges have settled), a little before the Begin button appears */
.acknowledgement-text {
  opacity: 0;
  align-self: center;
  padding: 0 6%;
  animation: ackFadeIn 1.3s ease-in-out 13.4s both;
}
.acknowledgement-text p {
  margin: 0;
  font-family: "ParkVoyage Ink", serif;
  font-weight: 400;
  font-size: clamp(17px, 4.6vw, 21px);
  line-height: 1.55;
  text-align: center;
  color: var(--text);
}
@keyframes ackFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* "Tap to begin": phones block sound until the player has tapped, so the
   title shows on its own first and everything timed (badges drifting in,
   title -> acknowledgement swap, Begin button) waits, paused at its very
   start, until the tap adds .is-started (see script.js) — the title music
   then starts from that real tap. */
#screen-0:not(.is-started) .title-group,
#screen-0:not(.is-started) .acknowledgement-text,
#screen-0:not(.is-started) .title-badge {
  animation-play-state: paused;
}
#screen-0:not(.is-started) { cursor: pointer; }
#screen-0.is-started .tap-to-begin { display: none; }
.tap-to-begin {
  margin: 0;
  align-self: center;
  font-family: "ParkVoyage Ink", serif;
  font-weight: 400;
  font-size: clamp(26px, 7vw, 32px);
  line-height: 1.2;
  text-align: center;
  color: var(--text);
  animation: ackFadeIn 1s ease-in-out 1s both, tapPulse 2s ease-in-out 2s infinite;
}
@keyframes tapPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

/* --- title card: the 5 voyage badges drift in one by one, like pollen on
   the breeze, growing as they go, then settle in a ring around the title --- */
.title-badges {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.title-badge {
  position: absolute;
  width: 27vw;
  max-width: 132px;
  min-width: 90px;
  height: auto;
  opacity: 0;
  animation-timing-function: ease-in-out;
  animation-iteration-count: 1;
  animation-fill-mode: both;
  filter: drop-shadow(0 2px 4px rgba(22, 50, 79, 0.18));
}
/* scattered, uneven resting spots (not a neat row/arc) — clear of both
   the title/VOYAGE wordmark and the acknowledgement text that swaps in
   over it (both occupy roughly the vertical middle, ~35%-65%) */
.title-badge-1 { left: 16%; top: 18%; animation-name: pollenDrift1; animation-duration: 8s;   animation-delay: 0s; }
.title-badge-2 { left: 88%; top: 16%; animation-name: pollenDrift2; animation-duration: 8.6s; animation-delay: 0.9s; }
.title-badge-5 { left: 58%; top: 15%; animation-name: pollenDrift5; animation-duration: 8.8s; animation-delay: 3.6s; }
.title-badge-3 { left: 25%; top: 66%; animation-name: pollenDrift3; animation-duration: 9.2s; animation-delay: 1.8s; }
.title-badge-4 { left: 78%; top: 64%; animation-name: pollenDrift4; animation-duration: 8.2s; animation-delay: 2.7s; }

@keyframes pollenDrift1 {
  0%   { opacity: 0; transform: translate(calc(-50% - 110px), calc(-50% + 90px)) rotate(-22deg) scale(0.35); }
  12%  { opacity: 1; }
  30%  { transform: translate(calc(-50% + 68px), calc(-50% - 76px)) rotate(16deg) scale(0.7); }
  50%  { transform: translate(calc(-50% - 56px), calc(-50% + 44px)) rotate(-13deg) scale(0.85); }
  70%  { transform: translate(calc(-50% + 32px), calc(-50% - 28px)) rotate(9deg) scale(0.95); }
  88%  { transform: translate(calc(-50% - 14px), calc(-50% + 14px)) rotate(-4deg) scale(1); }
  100% { opacity: 1; transform: translate(-50%, -50%) rotate(0deg) scale(1); }
}
@keyframes pollenDrift2 {
  0%   { opacity: 0; transform: translate(calc(-50% + 96px), calc(-50% + 104px)) rotate(18deg) scale(0.35); }
  12%  { opacity: 1; }
  32%  { transform: translate(calc(-50% - 60px), calc(-50% - 60px)) rotate(-14deg) scale(0.7); }
  52%  { transform: translate(calc(-50% + 48px), calc(-50% + 36px)) rotate(11deg) scale(0.85); }
  72%  { transform: translate(calc(-50% - 28px), calc(-50% - 20px)) rotate(-7deg) scale(0.95); }
  88%  { transform: translate(calc(-50% + 12px), calc(-50% + 10px)) rotate(3deg) scale(1); }
  100% { opacity: 1; transform: translate(-50%, -50%) rotate(0deg) scale(1); }
}
@keyframes pollenDrift3 {
  0%   { opacity: 0; transform: translate(-50%, calc(-50% - 120px)) rotate(-16deg) scale(0.35); }
  12%  { opacity: 1; }
  28%  { transform: translate(calc(-50% + 72px), calc(-50% + 40px)) rotate(20deg) scale(0.7); }
  50%  { transform: translate(calc(-50% - 64px), calc(-50% - 32px)) rotate(-15deg) scale(0.85); }
  70%  { transform: translate(calc(-50% + 36px), calc(-50% + 20px)) rotate(10deg) scale(0.95); }
  88%  { transform: translate(calc(-50% - 14px), calc(-50% - 8px)) rotate(-4deg) scale(1); }
  100% { opacity: 1; transform: translate(-50%, -50%) rotate(0deg) scale(1); }
}
@keyframes pollenDrift4 {
  0%   { opacity: 0; transform: translate(calc(-50% - 92px), calc(-50% - 96px)) rotate(24deg) scale(0.35); }
  12%  { opacity: 1; }
  32%  { transform: translate(calc(-50% + 56px), calc(-50% + 64px)) rotate(-18deg) scale(0.7); }
  52%  { transform: translate(calc(-50% - 44px), calc(-50% - 40px)) rotate(12deg) scale(0.85); }
  72%  { transform: translate(calc(-50% + 24px), calc(-50% + 22px)) rotate(-8deg) scale(0.95); }
  88%  { transform: translate(calc(-50% - 10px), calc(-50% - 10px)) rotate(3deg) scale(1); }
  100% { opacity: 1; transform: translate(-50%, -50%) rotate(0deg) scale(1); }
}
@keyframes pollenDrift5 {
  0%   { opacity: 0; transform: translate(calc(-50% + 104px), calc(-50% - 80px)) rotate(-20deg) scale(0.35); }
  12%  { opacity: 1; }
  30%  { transform: translate(calc(-50% - 68px), calc(-50% + 60px)) rotate(15deg) scale(0.7); }
  50%  { transform: translate(calc(-50% + 52px), calc(-50% - 36px)) rotate(-11deg) scale(0.85); }
  70%  { transform: translate(calc(-50% - 30px), calc(-50% + 24px)) rotate(8deg) scale(0.95); }
  88%  { transform: translate(calc(-50% + 12px), calc(-50% - 10px)) rotate(-3deg) scale(1); }
  100% { opacity: 1; transform: translate(-50%, -50%) rotate(0deg) scale(1); }
}

/* Riddles badge screen + final screen: badge_tree.png sits behind the
   whole scene as a quiet decorative backdrop — the actual earned-badge
   indicator is still the swirl-in badge + collected cluster in front of
   it, unchanged. */
#screen-riddle-badge,
#screen-final,
#screen-creature-badge {
  position: relative;
  /* not overflow:hidden here — that was blocking the scroll safety-net
     below (.screen:has(.badge-award)) on exactly these three screens.
     The backdrop image is absolutely positioned with inset:0, so it
     stays within this box regardless; nothing actually needed clipping. */
}
.badge-award-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.16;
  z-index: 0;
  pointer-events: none;
}

/* --- badge award screens: the just-earned badge swirls in the same way
   the title-card badges do, then settles half-overlapping the top of the
   text card (like a wax seal). Any previously earned badges drift into a
   smaller cluster above it, reusing the same pollenDrift keyframes. --- */
.badge-award {
  position: relative;
  padding-top: 56px;
}
/* per-voyage badge screens only (screen-final positions its own badge
   row separately, fixed near the button, so doesn't need this): clears
   the badges (double-size now, sitting at top:-20px) with a visible gap
   before the card starts, instead of the card cutting across them — the
   badge just earned should read as the hero, not be half-hidden behind
   the text */
.badge-dual .badge-award {
  padding-top: 132px;
}
/* a plain evenly-spaced row hugging the top of the card — guaranteed
   never to overlap regardless of how many badges are collected (1-4),
   unlike the old per-slot absolute positions which could let one badge
   sit in front of another */
.badge-award-collected {
  position: absolute;
  top: -20px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  z-index: 1;
}
.badge-award-collected img {
  position: relative;
  width: 18vw;
  max-width: 62px;
  min-width: 44px;
  height: auto;
  border-radius: 50%;
  box-shadow: 0 3px 10px rgba(22, 50, 79, 0.25);
  border: 3px solid rgba(255, 255, 255, 0.9);
  opacity: 0;
}
.badge-slot-1 { animation-delay: 0s; }
.badge-slot-2 { animation-delay: 0.15s; }
.badge-slot-3 { animation-delay: 0.3s; }
.badge-slot-4 { animation-delay: 0.45s; }
.badge-slot-5 { animation-delay: 0.6s; }
@keyframes badgeSlotFadeIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.7); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* double size on every badge-award screen (matches screen-final) */
.badge-dual .badge-award-collected img {
  width: 36vw;
  max-width: 124px;
  min-width: 88px;
}
/* the just-earned badge (.badge-slot-new) stays hidden until the music
   actually starts (.fx-playing) — this used to be unconditional, so it
   swirled in the instant the screen loaded rather than with the music —
   then swirls into its row, timed to the actual length of
   PVoyager_RecieveBadge_MusicSting.mp3 (--badge-swirl-s, set in
   script.js once the file's real duration is known) so it lands as the
   music ends. Uses the gentler, small-radius badgeSwirlSettle (not
   screen-final's badgeSwirlSettleBig) — that one starts 420px off the
   top of the screen, which read as a multi-second gap between the sound
   starting and the badge actually coming into view on this tighter
   layout. The other already-earned badges (.badge-slot-other) wait
   until it settles, then pop in at the same size, so nothing ever sits
   "in front" of anything else. */
.badge-dual .badge-award-collected img.badge-slot-new {
  opacity: 0;
}
.badge-dual.fx-playing .badge-award-collected img.badge-slot-new {
  animation: badgeSwirlSettle var(--badge-swirl-s, 2.5s) ease-in-out both;
}
/* a gentle, contained version of the title screen's pollen-drift swirl —
   the full-screen version's swirl radius would carry a small row badge
   right off the card, so this keeps the same drifting/rotating feel at
   a scale that settles back into its own spot in the row */
@keyframes badgeSwirlSettle {
  0%   { opacity: 0; transform: translate(18px, -34px) rotate(-20deg) scale(0.4); }
  30%  { opacity: 1; transform: translate(-14px, 16px) rotate(14deg) scale(0.85); }
  55%  { transform: translate(10px, -10px) rotate(-9deg) scale(0.95); }
  78%  { transform: translate(-5px, 5px) rotate(5deg) scale(1.02); }
  100% { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
}
/* NOT gated on .fx-playing (unlike .badge-slot-new above) — .fx-playing
   gets removed at exactly this delay's own duration (see clearFxPlaying
   in script.js), so a rule that required it to still be present would
   have its trigger vanish the instant the delay elapsed, and the
   animation would never actually start. animation-delay alone is
   enough: it's set by script.js before the delay has elapsed, so the
   browser picks up the real value in time. */
.badge-dual .badge-award-collected img.badge-slot-other {
  animation: badgeSlotFadeIn 0.6s ease-out both;
  animation-delay: var(--badge-others-delay-s, 2.5s);
}
/* the title screen's own pollenDrift1-5 keyframes end on
   translate(-50%,-50%) — correct for a badge centred via left/top, but
   this badge sits in a flex row (position:relative), so reusing them
   verbatim would leave it permanently offset by half its own size once
   the swirl finished. This has the same big, dramatic drift/rotate/scale
   feel, just ending on translate(0,0) so it settles in its real row
   slot. Timed to PVoyager_FINALSCREEN.mp3's real length via
   --badge-swirl-s (set in script.js) so every badge lands as the music
   ends. */
/* rest position moves from hugging the top of the card down to just
   above the button bar (fixed, so it tracks there regardless of how
   tall the card's own text/badge-count content is) */
#screen-final .badge-award-collected {
  position: fixed;
  top: auto;
  bottom: 165px;
  z-index: 12;
}
#screen-final .badge-award-collected img {
  /* stay hidden and still until the music actually starts (.fx-playing) —
     this was unconditional before, so the badges swirled in the instant
     the screen loaded rather than in time with PVoyager_FINALSCREEN */
  opacity: 0;
}
#screen-final.fx-playing .badge-award-collected img {
  animation: badgeSwirlSettleBig var(--badge-swirl-s, 2.5s) ease-in-out both;
}
/* double size on the final screen specifically (badge-dual screens
   elsewhere keep the smaller shared size) */
#screen-final .badge-award-collected img {
  width: 36vw;
  max-width: 124px;
  min-width: 88px;
}
@keyframes badgeSwirlSettleBig {
  /* starts up near the top of the screen and drops all the way down
     into its resting row — a real "falling into place" motion rather
     than a small drift, timed to land as the music ends */
  0%   { opacity: 0; transform: translate(70px, -420px) rotate(-24deg) scale(0.3); }
  30%  { opacity: 1; transform: translate(-60px, -220px) rotate(18deg) scale(0.75); }
  55%  { transform: translate(45px, -70px) rotate(-13deg) scale(0.9); }
  78%  { transform: translate(-20px, 20px) rotate(7deg) scale(1.05); }
  90%  { transform: translate(6px, -6px) rotate(-2deg) scale(0.98); }
  100% { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
}
#screen-final .badge-award-collected img.badge-slot-2 { animation-delay: 0.15s; }
#screen-final .badge-award-collected img.badge-slot-3 { animation-delay: 0.3s; }
#screen-final .badge-award-collected img.badge-slot-4 { animation-delay: 0.45s; }
#screen-final .badge-award-collected img.badge-slot-5 { animation-delay: 0.6s; }
@keyframes badgeFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-6px) rotate(-3deg); }
}

/* superseded by .badge-slot-new above (same row, same size) */
.badge-award-main {
  display: none;
}

.frosted-card {
  position: relative;
  z-index: 1;
  background: rgba(250, 245, 234, 0.85);
  border-radius: 24px;
  padding: 18px 22px 20px;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

/* safety net: if a badge screen's content still runs taller than the
   viewport (e.g. a long collected-badges list on a short phone), let it
   scroll instead of silently hiding behind the fixed button bar */
.screen:has(.badge-award),
.screen:has(.choice-list--tags) {
  height: 100vh;
  overflow-y: auto;
  justify-content: flex-start;
}
.frosted-card .screen-text { margin: 0; }

/* final screen: black overlay that fades in once the badge dance ends,
   just before the credits page opens (see script.js) */
.fade-to-black {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 2s ease-in-out;
}
.fade-to-black.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.credits-link {
  display: block;
  text-align: center;
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--text);
  opacity: 0.7;
  text-decoration: underline;
}

.audio-toggle .icon-pause { display: none; width: 20px; height: 26px; object-fit: contain; }
.audio-toggle.is-playing .icon-sound { display: none; }
.audio-toggle.is-playing .icon-pause { display: block; }

.screen {
  display: none;
  min-height: 100vh;
  flex-direction: column;
  justify-content: center;
  padding: 32px 24px calc(var(--btn-bar-height) + 24px);
}

.screen.active { display: flex; }

/* plain cream text screens (0, 3, 7): cap height to the real viewport
   instead of letting the huge reserved button-bar padding grow the box
   taller than the screen, which pushed "centred" content up off-centre */
.theme-cream:not(.wallpaper):not(.split) {
  height: 100vh;
}
/* ...and nudge the text down toward the true middle of the visible area,
   since the huge reserved button space alone skews flex-centring high */
.theme-cream:not(.wallpaper):not(.split) .screen-text {
  transform: translateY(9vh);
}

.screen-text {
  white-space: pre-line;
  font-weight: 400;
  font-size: clamp(22px, 6.2vw, 28px);
  line-height: 1.32;
  color: var(--text);
  margin: 0 0 32px;
}

.screen-text strong { font-weight: 700; }

.screen-desc-plain {
  white-space: pre-line;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.4;
  color: var(--text-secondary);
  margin: -16px 0 28px;
}

/* --- fixed bottom button bar (back + next): sits a constant 5mm above
   the bottom of the device's own visible frame (plus its home-indicator
   safe area, so it never sits under that either), on every phone size —
   a physical unit rather than a guessed pixel value so it reads the same
   real-world distance regardless of screen density. --- */
.btn-bar {
  position: fixed;
  left: 50%;
  bottom: calc(16mm + var(--bar-extra) + var(--safe-bottom));
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 12px;
  padding: 16px 24px 0;
  box-sizing: border-box;
  z-index: 10;
}

/* every section uses this same base position (--bar-extra stays at its
   root default of 0px) except where a screen has a real content reason
   to sit higher (see #screen-treasure-intro below) — every button is now
   the same simple pill/ring shape, so there's no per-section shape size
   to compensate for any more. */

/* screen 4: the tree drawing shifted up 5mm — its own background is a
   flat peach, matched here as the screen's own background so the gap
   left at the bottom by the shift reads as a seamless continuation of
   the photo rather than a visible edge */
#screen-4 {
  background: #F7CCA2;
}
#screen-4 .bg-img {
  transform: translateY(-5mm);
}

/* --- universal "Next" button: one simple hand-drawn pill, used
   everywhere (was 5 different organic shapes, one per section, each with
   its own bleed/inset tuning — this is the "easier to place" shape). Fill
   and frame share the exact same box, fill clipped to the pill's own
   traced inner boundary, ink frame drawn on top — same technique as every
   other hand-drawn asset in this app. --- */
.btn-next {
  position: relative;
  z-index: 0;
  background: none;
  border: none;
  color: var(--text);
  font-family: "ParkVoyage Ink", serif;
  font-weight: 400;
  cursor: pointer;
  min-height: 66px;
  flex: 0 0 auto;
  width: min(64vw, 240px);
  font-size: clamp(21px, 5.8vw, 27px);
  line-height: 1.2;
  padding: 14px 24px;
}
.btn-next::before,
.btn-next::after {
  content: '';
  position: absolute;
  inset: -14% -6%;
  z-index: -1;
}
.btn-next::before {
  z-index: -2;
  background-color: #EAF5F0;
  -webkit-mask-image: url('ButtonShapes/pv_pill_long_fill.png');
  mask-image: url('ButtonShapes/pv_pill_long_fill.png');
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}
.btn-next::after {
  /* the real drawn ink, used as-is (its own colour + texture + stroke
     weight) rather than flattened to a solid colour with a filter */
  background-image: url('ButtonShapes/pv_pill_long.png');
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
}
/* narrower multi-button rows (dual/quad stacks below) use the shorter
   pill, drawn closer to their own more compact proportions */
.btn-stack .btn-next::before,
.btn-stack--quad .btn-next::before {
  -webkit-mask-image: url('ButtonShapes/pv_pill_short_fill.png');
  mask-image: url('ButtonShapes/pv_pill_short_fill.png');
}
.btn-stack .btn-next::after,
.btn-stack--quad .btn-next::after {
  background-image: url('ButtonShapes/pv_pill_short.png');
}
/* stacked buttons sit close together (10-14px gaps) — the default -30%
   vertical bleed (tuned for a single full-width pill) made adjacent
   buttons' ink visually overlap, so tighten it just for stacks */
.btn-stack .btn-next::before,
.btn-stack .btn-next::after,
.btn-stack--quad .btn-next::before,
.btn-stack--quad .btn-next::after {
  inset: -12% -6%;
}

/* --- universal "Back" button: one simple hand-drawn ring with a
   hand-drawn chevron baked into its ink (see ButtonShapes/back_button_*),
   replacing the plain white circle + generic vector arrow. --- */
/* bare icon, no ring/border/fill — just the drawn arrow itself */
.btn-back {
  position: relative;
  z-index: 0;
  flex: 0 0 32px;
  width: 32px;
  min-height: 32px;
  align-self: center;
  background-color: transparent;
  background-image: url('ButtonShapes/pv_icon_back.png');
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  color: var(--text);
  border: none;
  cursor: pointer;
}
.btn-back svg { display: none; }

.btn-back.is-hidden { display: none; }

.btn-back:active,
.btn-next:active { opacity: 0.85; }

/* --- stack layout (screens 1, 2, 4) --- */
.image-frame { margin: 0 0 32px; }
.image-frame img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 42vh;
  margin: 0 auto;
}

/* --- placeholder for images not yet supplied --- */
.image-pending {
  background: rgba(44, 74, 115, 0.12);
  color: #2C4A73;
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-frame .image-pending {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
}
.split-image.image-pending {
  width: 100%;
  height: 34vh;
  min-height: 220px;
}

/* --- circle layout (screen 3) --- */
.circle-frame {
  width: 62%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto 32px;
}
.circle-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* screen 3's source photo has a plain white background that needs to
   blend into the page; other circle-framed photos (e.g. the creature
   badge) already have their own background and should render as-is. */
.circle-frame--blend img { mix-blend-mode: multiply; }

/* --- wallpaper layout (screen 5) --- */
.screen.wallpaper {
  padding: 0;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.screen.wallpaper .bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

/* screen 1: the source photo (752x676) was being cover-cropped to fill the
   whole screen, which pushed its dark flower centre down past the gap
   between the two text boxes. Shown at its own width-driven aspect ratio
   instead (smaller, uncropped) and nudged so the flower centre lines up
   between the boxes; the page's own background is matched to the photo's
   pale yellow so the un-covered top/bottom strips read as one continuous
   backdrop rather than a visible seam. */
#screen-1 {
  background: #fffec3;
}
/* universal: shift the whole button composition (pill/stack + back +
   sound icon) up by the height of the nav arrow, since it was sitting
   too close to the bottom edge. Set on .app rather than each screen —
   the audio toggle lives outside the screen section in the DOM, so it
   needs a shared ancestor to inherit --bar-extra from. goodchoice-quad
   keeps its own old row layout, so it's excluded here. */
.app:not(:has(.goodchoice-quad.active)) {
  --bar-extra: 32px;
}
#screen-1 .bg-img {
  inset: auto;
  top: 195px;
  left: 0;
  width: 100%;
  height: calc(100vh - var(--mid-clear) - 195px);
  object-fit: contain;
}
.screen.wallpaper .wallpaper-content {
  position: relative;
  z-index: 1;
  padding: 0 24px;
}

/* screen 1: heading pinned near the top; screen 4: single line pinned near
   the top so it doesn't sit over the tree */
.screen.wallpaper .wallpaper-content--top {
  position: absolute;
  top: 48px;
  left: 24px;
  right: 24px;
}

/* screen 1 only: nudge its top text box down (6mm, then another 3mm) */
#screen-1 .wallpaper-content--top {
  top: calc(48px + 6mm + 3mm);
}

/* screen 1: second block anchored just above the button bar, using the
   same --mid-clear distance as --btn-bar-height (root var.css), so it
   stays in sync if the button's reserved height ever changes. */
.screen.wallpaper .wallpaper-content--mid {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: var(--mid-clear);
}
.screen.wallpaper .wallpaper-content--mid.has-card {
  background: rgba(250, 245, 234, 0.5);
}

/* screen 1: the top line ("Welcome to PARK VOYAGE!") shows immediately;
   the second box (card background + "We are the kids of Tarwin..." text)
   only appears once the screen's audio (~5.6s) has finished, rather than
   competing with it */
#screen-1 .wallpaper-content--mid {
  opacity: 0;
  animation: ackFadeIn 1s ease-in-out 5.6s both;
}

/* screen 2: two separately-cropped, true-transparency leaf friends
   (Leaf_Friends.png, split apart cleanly — no more jagged manual cutout
   edges from the old S2_leaf_left.png). Both are positioned as percentages
   of a shared stage box sized to their combined bounds in the source photo,
   so they line up correctly at any screen width. The smiling leaf (left)
   waves; the sunglasses leaf (right) stays still. */
.leaf-stage {
  position: absolute;
  top: 10%;
  left: 2%;
  width: 96%;
  aspect-ratio: 987 / 759;
  z-index: 0;
}
.leaf-stage .leaf-shades {
  position: absolute;
  left: 55.3%;
  top: 11.1%;
  width: 44.2%;
  height: auto;
  display: block;
}
.leaf-stage .leaf-wave {
  position: absolute;
  left: 0.5%;
  top: 0.7%;
  width: 48%;
  height: auto;
  transform-origin: 50% 78%;
}
/* the wave only plays once the narration ends and the music sting
   starts (see loadAudioForScreen/.fx-playing in script.js) — stays
   still, in its resting pose, while the narration is being read out */
#screen-2.fx-playing .leaf-stage .leaf-wave {
  animation: leafWave 3.4s ease-in-out infinite;
}
@keyframes leafWave {
  0%, 100% { transform: rotate(0deg); }
  22%      { transform: rotate(-7deg); }
  50%      { transform: rotate(0deg); }
  74%      { transform: rotate(9deg); }
}

/* text sits low, clear of the image above it — same geometry-based formula
   as --mid above, just with a 6mm clearance gap instead of 3mm (an extra
   +3mm nudge up on top of the usual gap) */
.screen.wallpaper .wallpaper-content--bottom {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: calc(var(--mid-clear) + 3mm);
}

/* screen 2: no card now that the text sits directly on the teal, so it can
   afford to run a little bigger */
.screen-text--lg {
  font-size: clamp(25px, 7vw, 32px);
}

/* soft frosted card behind overlaid text, for images busier than screen 5's
   pale pollen photo */
.screen.wallpaper .wallpaper-content.has-card {
  background: rgba(250, 245, 234, 0.85);
  border-radius: 24px;
  padding: 24px 24px 28px;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.screen.wallpaper .wallpaper-content.has-card .screen-text { margin: 0; }


/* --- split layout (screens 6, 7) --- */
.screen.split { padding: 0; }
.split-image {
  width: 100%;
  height: 34vh;
  min-height: 220px;
  object-fit: cover;
  object-position: center 75%;
  display: block;
}
.split-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px 24px calc(var(--btn-bar-height) + 24px);
  min-height: 0;
}

/* screens with a scrollable list (hub, clue picker) need their header to
   stay pinned above the list, not centred with it — and the screen itself
   needs a hard height cap (not just min-height) so the list scrolls
   internally instead of growing the whole page taller than the viewport */
.split-body:has(.choice-list),
.screen:has(.choice-list),
.screen:has(.clue-grid) {
  justify-content: flex-start;
  height: 100vh;
}

.split-image--center { object-position: center center; }

/* the Squiggly Tree pencil sketch has a plain white background that needs
   to blend into the page, like screen 3's circle photo. */
.split-image--blend { mix-blend-mode: multiply; }

/* --- hub menu choice list (screen 7.1) --- */
.required-mark {
  font-weight: 700;
  color: var(--text);
}

.choice-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 40px;
  margin: 8px 0 -40px;
  -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 40px), transparent 100%);
  mask-image: linear-gradient(to bottom, black calc(100% - 40px), transparent 100%);
}

.choice-pill {
  flex: 0 0 auto;
  width: 100%;
  background: rgba(255, 255, 255, 0.28);
  color: #2C4A73;
  font-family: inherit;
  font-weight: 700;
  font-size: 16px;
  text-align: left;
  border: none;
  border-radius: 12px;
  padding: 18px 20px;
  cursor: pointer;
}

.choice-pill.selected {
  background: var(--btn-bg);
  color: var(--btn-text);
}

/* --- Treasure Hunt colour tags: a 2-column grid of the hand-drawn
   ink-framed colour swatches instead of a column of text pills --- */
.choice-list--tags {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  overflow: visible;
  mask-image: none;
  -webkit-mask-image: none;
  margin: 8px auto 0;
  padding-bottom: 0;
  /* capped rather than filling the full screen width — with 3 rows,
     letting each tag grow as large as the screen allows meant the grid
     was often taller than a phone viewport, forcing a scroll to reach
     the buttons below it */
  width: 100%;
  max-width: 260px;
}
.choice-pill--tag {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  cursor: pointer;
  transition: transform 0.15s ease-out;
}
.choice-pill--tag img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
/* selection reads as a lift + glow around the tag itself, since the ink
   frame is already baked into the image */
.choice-pill--tag.selected {
  background: none;
  color: inherit;
  transform: scale(1.06);
  filter: drop-shadow(0 4px 14px rgba(22, 50, 79, 0.45));
}

/* --- riddle screens (short-text input, no image) --- */
.riddle-screen {
  justify-content: center;
}

.riddle-screen .screen-desc-plain {
  margin: 24px 0 40px;
}

.riddle-input {
  width: 100%;
  border: none;
  background: transparent;
  background-image: url('Images/twig_dash.png');
  background-repeat: no-repeat;
  background-position: left bottom 2px;
  background-size: 100% 26px;
  font-family: inherit;
  text-align: center;
  font-size: 60px;
  color: var(--text);
  padding: 8px 0 20px;
  outline: none;
}

.riddle-input::placeholder {
  color: #7FB8B0;
  font-size: 20px;
}

/* --- Riddles / Treasure Hunt / Creature / Poem / Dance: Ink flow font for
   body copy, twig capital font for section headings ("RIDDLE 1", "TREASURE
   HUNT CLUE 1", etc). Font only — these sections keep their existing teal
   background and plain pill buttons (no cream theme, no twig button). --- */
.theme-ink .screen-text,
.theme-ink .screen-desc-plain,
.theme-ink .riddle-input,
.theme-ink .choice-pill,
.theme-ink .tile-label,
.theme-ink .required-mark {
  font-family: "ParkVoyage Ink", serif;
}
.theme-ink .screen-text { font-weight: 400; }
.theme-ink .screen-text strong { font-weight: 400; }
.theme-ink .choice-pill { font-weight: 400; }

/* --- Riddles: centred, slightly larger body copy (readability on phone) --- */
.sec-riddles .screen-text,
.sec-riddles .section-heading {
  text-align: center;
}
.sec-riddles .screen-text {
  font-size: clamp(24px, 7vw, 30px);
}
/* the reserved bottom space for the button (much taller than the top
   padding) skews simple flex-centring high while the heading is on its
   own (screen-riddle-1..6, before the clue text reveals) — nudge down
   toward the true middle of the visible area, then rise back out of the
   way as the clue text fades in below it (same 1s/5s timing as that
   text's own ackFadeIn, so they move together instead of overlapping). */
.sec-riddles .section-heading {
  animation: sectionHeadingRise 1s ease-in-out 5s both;
}
@keyframes sectionHeadingRise {
  from { transform: translateY(7vh); }
  to   { transform: translateY(0); }
}

/* screen-riddles-intro: the welcome line shows immediately, the
   instruction line fades in 5s later */
.riddle-intro-delayed {
  opacity: 0;
  animation: ackFadeIn 1s ease-in-out 5s both;
}

/* each riddle screen: "RIDDLE N" shows immediately (it's not part of
   this rule), audio autoplays on load same as always, and the riddle
   text + answer input fade in 5s later so kids see the title, hear the
   audio start, then get the text as reinforcement rather than everything
   landing on screen at once */
/* the clue paragraph collapses to zero height (not just invisible) while
   waiting to reveal, so "RIDDLE N" sits centred in the screen on its own
   for that first 5s instead of pushed up by reserved space for text
   that isn't shown yet */
#screen-riddle-1 .screen-text,
#screen-riddle-2 .screen-text,
#screen-riddle-3 .screen-text,
#screen-riddle-4 .screen-text,
#screen-riddle-5 .screen-text,
#screen-riddle-6 .screen-text {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  animation: riddleTextReveal 1s ease-in-out 5s both;
}
@keyframes riddleTextReveal {
  from { opacity: 0; max-height: 0; }
  to   { opacity: 1; max-height: 500px; }
}
#screen-riddle-1 .riddle-input,
#screen-riddle-2 .riddle-input,
#screen-riddle-3 .riddle-input,
#screen-riddle-4 .riddle-input,
#screen-riddle-5 .riddle-input,
#screen-riddle-6 .riddle-input {
  opacity: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  animation: riddleInputReveal 1s ease-in-out 5s both;
}
@keyframes riddleInputReveal {
  from { opacity: 0; max-height: 0; padding-top: 0; padding-bottom: 0; }
  to   { opacity: 1; max-height: 120px; padding-top: 8px; padding-bottom: 20px; }
}
/* ...and the "See the answer" button can't be pressed until the riddle text is in: it's there
   from the start, faded and untappable, and turns full colour at 5s -- the same look as every
   other held button (see setButtonHold / applyTimedHolds in script.js). */

/* Screen 2 "Our park wants to talk with you.": the text sits just under the leaf friends (it was
   pinned near the bottom of the screen, leaving a big gap under the leaves on taller phones). The
   leaf stage is 10% down, 96% of the screen width wide, at a 987:759 ratio. */
#screen-2 .wallpaper-content--bottom {
  bottom: auto;
  top: calc(10% + min(100vw, 480px) * 0.96 * 759 / 987 + 18px);
}

/* Voyage menu: the options sit centred in the space between the heading and the back-arrow row
   (they were packed up under the heading). The menu has no Next pill, so it only reserves room for
   the back-arrow row. Auto margins (not justify-content) so a long list on a short phone still
   scrolls from its top. */
#screen-hub .split-body {
  padding-bottom: calc(88px + var(--safe-bottom) + var(--bar-extra));
}
#screen-hub .choice-list > :first-child { margin-top: auto; }
#screen-hub .choice-list > :last-child { margin-bottom: auto; }

/* same "heading first, text 5s later" pattern for the treasure hunt clues */
#screen-treasure-clue-1 .screen-text,
#screen-treasure-clue-2 .screen-text,
#screen-treasure-clue-3 .screen-text,
#screen-treasure-clue-4 .screen-text,
#screen-treasure-clue-5 .screen-text,
#screen-treasure-clue-6 .screen-text {
  opacity: 0;
  animation: ackFadeIn 1s ease-in-out 5s both;
}

/* screen-creature-materials-intro: image shows immediately full-bleed,
   the text card fades in over it 5s later (same pattern as above) */
#screen-creature-materials-intro .wallpaper-content {
  opacity: 0;
  animation: ackFadeIn 1s ease-in-out 5s both;
}

/* held buttons (faded while the screen's narration/text plays out, or until an answer is typed --
   see setButtonHold in script.js) ease up to full colour rather than snapping */
.btn-next.is-holdable {
  transition: opacity 0.6s ease;
}

/* screen-dance-intro: audio plays first, text fades in 5s later (same
   pattern used throughout — see the riddle/treasure-clue comments above) */
#screen-dance-intro .screen-text,
/* screen-dance-big-tree: just a plain fade-in, same timing */
#screen-dance-big-tree .screen-text {
  opacity: 0;
  animation: ackFadeIn 1s ease-in-out 5s both;
}

/* screen-4: "The park invites you to voyage!" was landing at the same
   time as its own narration, competing with it — its audio (~4.9s) now
   finishes before the whole card (background + text) fades in together,
   rather than the box sitting there empty while just the text appears */
#screen-4 .wallpaper-content--top {
  opacity: 0;
  animation: ackFadeIn 1s ease-in-out 5s both;
}

/* screen-dance-shape-might-be: first line ("Look around at our park.
   Notice all the shapes here.") is there from the start; the second
   line (the shape examples) fades in ~3s later, timed to the natural
   pause in the audio right before it starts listing them — then both
   fade out together at 9s as before */
#screen-dance-shape-might-be .screen-text {
  animation: ackFadeOut 1s ease-in-out 9s both;
}
#screen-dance-shape-might-be .screen-text.screen-text--shape-examples {
  animation: shapesTextInOut 10s ease-in-out both;
}
@keyframes shapesTextInOut {
  0%   { opacity: 0; }
  30%  { opacity: 0; }
  40%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { opacity: 0; }
}

/* screen-poem-thing: the opening lines show immediately; "My thing is a . . ."
   and its answer field only appear once the audio (~7.1s) has finished,
   rather than sitting there waiting to be filled in before it's introduced */
#screen-poem-thing .poem-thing-prompt {
  opacity: 0;
  animation: ackFadeIn 1s ease-in-out 7.1s both;
}
@keyframes ackFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* each riddle gets its own subtle gradient, all sampled from the same
   S13 painted-purple-sky photo (now also used on screen-riddles-sit) so
   the six feel like a related set rather than one flat colour repeated */
/* each riddle (question + both its answer screens) gets its own flat
   colour, picked by hand rather than sampled this time — riddle 6 is
   intentionally left on its original S13-sampled gradient since no colour
   was given for it yet */
#screen-riddle-1, #screen-riddle-answer-1, #screen-riddle-answer-1-incorrect {
  background: #FAF5EA;
}
#screen-riddle-2, #screen-riddle-answer-2, #screen-riddle-answer-2-incorrect {
  background: #D7B45D;
}
#screen-riddle-3, #screen-riddle-answer-3, #screen-riddle-answer-3-incorrect {
  background: #EAF5F0;
}
#screen-riddle-4, #screen-riddle-answer-4, #screen-riddle-answer-4-incorrect {
  background: #6A9F67;
}
#screen-riddle-5, #screen-riddle-answer-5, #screen-riddle-answer-5-incorrect {
  background: #B5BAD9;
}
#screen-riddle-6, #screen-riddle-answer-6, #screen-riddle-answer-6-incorrect {
  background: #EBAB7D;
}

/* screen-riddles-intro: welcome text above the riddle badge, on the plain
   section colour instead of a full-bleed photo */
.intro-badge-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.intro-badge-img {
  width: 42vw;
  max-width: 180px;
  margin-top: 28px;
  border-radius: 50%;
  box-shadow: 0 6px 18px rgba(22, 50, 79, 0.25);
  border: 4px solid rgba(255, 255, 255, 0.9);
}

/* every clue screen gets its own background, distinct from the rest of
   the section's gold */
#screen-treasure-clue-1, #screen-treasure-clue-2, #screen-treasure-clue-3,
#screen-treasure-clue-4, #screen-treasure-clue-5, #screen-treasure-clue-6 {
  background: #C4E8E0;
}

/* centred body copy, matching Riddles, instead of left-justified */
.sec-treasure .screen-text,
.sec-treasure .section-heading,
.sec-creature .screen-text,
.sec-creature .section-heading,
.sec-poem .screen-text,
.sec-poem .section-heading,
.sec-dance .screen-text,
.sec-dance .section-heading {
  text-align: center;
}
/* Treasure Hunt clues: same heading-alone centring + rise-out-of-the-way
   animation as Riddles (see .sec-riddles .section-heading above) — the
   clue title sits alone for 5s before the clue text fades in below it. */
.sec-treasure .section-heading {
  animation: sectionHeadingRise 1s ease-in-out 5s both;
}

/* two-button stacks (badge screens) get more breathing room, same as the
   quad "good choice" stacks already do */
.sec-treasure .btn-stack {
  gap: 18px;
}

/* treasure hunt colour-tag screens: the 3-row tag grid is tall enough
   that the fixed-position button bar sat over its bottom row on most
   phone heights, even after shrinking the buttons. Same fix as the
   "good choice" quad screens (.btn-bar--quad above): let the bar flow
   naturally right after the grid instead of pinning it to the bottom,
   so there's never an overlap regardless of screen height. */
.screen:has(.choice-list--tags) {
  padding: 20px 24px;
}
.screen:has(.choice-list--tags) .screen-text {
  margin: 0 0 12px;
}
.screen:has(.choice-list--tags) .btn-bar--dual {
  position: static;
  transform: none;
  width: 100%;
  max-width: none;
  margin-top: 14px;
  padding: 0;
}
.screen:has(.choice-list--tags) .btn-stack {
  gap: 6px;
}
.screen:has(.choice-list--tags) .btn-stack .btn-next {
  min-height: 44px;
  width: min(56vw, 210px);
  padding: 8px 18px;
  font-size: clamp(13px, 3.6vw, 16px);
}

/* the new Map.png already has its own solid gold backdrop matching the
   section colour, so no white card behind it any more (that was only
   needed for the old transparent version) — just a soft inset frame */
.treasure-photo-frame {
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 0 0 3px rgba(22, 50, 79, 0.1);
  margin: 0 auto 28px;
  max-width: 320px;
}
.treasure-photo-frame img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 38vh;
  object-fit: cover;
}

/* screen-treasure-intro: Map.png as a full-bleed background (the actual
   drawing sits in the lower portion of the source image, so it naturally
   reads as a feature down the bottom of the screen). The OK button is
   pulled out of the normal bottom bar and pinned just under the intro
   text instead of down over the drawing — Back stays behind at the
   standard position (screens 0-7), since only OK needs to move. */
#screen-treasure-intro .btn-next {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: 330px;
}

/* --- Park Dance finale: the whole tree drawing sways as one piece from
   its own base (transform-origin at the bottom, like a trunk rooted in
   the ground) instead of being cut into separate leaf/leg layers — no
   seams, nothing to break. The person moves with it since they're part
   of the same drawing. Two of the existing leaf friend cutouts dance in
   the grass in front, at 4x their original size. */
.dance-finale {
  position: relative;
  overflow: hidden;
}
.dance-scene {
  position: relative;
  width: 100%;
  max-width: 430px;
  aspect-ratio: 1414 / 2000;
  max-height: 66vh;
  margin: 0 auto;
}
.dance-tree-whole {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform-origin: 50% 100%;
}
@keyframes danceTreeSway {
  0%, 100% { transform: rotate(0deg); }
  50%      { transform: rotate(-2.5deg); }
}
.dance-friend {
  position: absolute;
  width: 46%;
  height: auto;
  bottom: 3%;
}
.dance-friend-smile {
  left: -10%;
  transform-origin: 50% 100%;
}
.dance-friend-shades {
  right: -8%;
  width: 40%;
  transform-origin: 50% 100%;
}
/* the tree sway and dancing friends only start once the narration ends
   and the music plays (see loadAudioForScreen/.fx-playing in
   script.js) — they hold still, in their resting pose, while the
   narration is being read out */
#screen-dance-wow-loved.fx-playing .dance-tree-whole {
  animation: danceTreeSway 4.5s ease-in-out infinite;
}
#screen-dance-wow-loved.fx-playing .dance-friend-smile {
  animation: danceFriendMove 1.8s ease-in-out infinite;
}
#screen-dance-wow-loved.fx-playing .dance-friend-shades {
  animation: danceFriendMove 1.8s ease-in-out infinite 0.5s;
}
@keyframes danceFriendMove {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  25%      { transform: rotate(-8deg) translateY(-4%); }
  50%      { transform: rotate(0deg) translateY(0); }
  75%      { transform: rotate(8deg) translateY(-4%); }
}

/* --- Riddles: a correct answer sits inside the "twig star leaf" shape,
   masked from a light card colour so the hand-drawn silhouette reads as a
   badge behind the text --- */
.answer-correct-frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 577.7 / 544.3;
  padding: 70px 60px;
  box-sizing: border-box;
}
.answer-correct-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  /* riddle screens use several different background colours (some very
     close to this card's own cream — #screen-riddle-answer-1's #FAF5EA
     was an exact match, making the star completely invisible there), so
     it can't rely on colour contrast alone: a shadow keeps it visible
     against any of them, plain white reads more distinctly than cream */
  background-color: rgba(255, 255, 255, 0.95);
  filter: drop-shadow(0 5px 16px rgba(22, 50, 79, 0.3));
  -webkit-mask-image: url('ButtonShapes/twig_star_leaf_tight.svg');
  mask-image: url('ButtonShapes/twig_star_leaf_tight.svg');
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}
/* riddle 1: an inky light blue instead of the shared white */
#screen-riddle-answer-1 .answer-correct-frame::before {
  background-color: #A9CBEA;
}
.answer-correct-frame .screen-text {
  position: relative;
  z-index: 1;
  margin: 0;
}


.section-heading {
  display: block;
  font-family: "ParkVoyage Display", sans-serif;
  font-weight: 400;
  font-size: clamp(28px, 8vw, 40px);
  letter-spacing: 0.02em;
  margin: 0 0 16px;
  color: var(--text);
  /* the Display font's own glyph set is capitals-only — any lowercase
     letter falls back to plain sans-serif, which is what made this
     look "unstyled" on headings typed in sentence case (unlike
     "RIDDLE 1" etc, already typed in caps in the HTML) */
  text-transform: uppercase;
}

/* --- badge screens: two stacked actions (choose another voyage /
   finish), consistent across all 5 voyages — stacked vertically,
   centred as one group at the same width as the usual single pill, with
   Back and audio pulled below it at that group's own edges (same
   pattern as the universal single-pill screens, see .btn-back /
   .audio-control below). --- */
/* room reserved under the content for the two stacked buttons (+ Back/audio row below them):
   the stack reaches ~256px up from the bottom of the screen, plus whatever the phone itself
   reserves at the bottom (home indicator etc) — so on short phones the award message can scroll
   fully clear of the buttons instead of ending up behind them */
.badge-dual { --btn-bar-height: calc(248px + var(--bar-extra) + var(--safe-bottom)); }
.btn-bar--dual { align-items: flex-end; justify-content: center; }
.btn-stack {
  flex: 0 0 auto;
  width: min(64vw, 240px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.btn-stack .btn-next { flex: 0 0 auto; }
/* .btn-next--secondary intentionally has no styling of its own — every
   button shares the exact same hand-drawn pill fill, primary or not. */

/* --- treasure hunt "good choice" screens (clues 1-5): four small stacked
   options instead of one OK button, so they need even more reserved
   height. Smaller/lighter than the two-button badge stack since these are
   secondary wayfinding options, not a primary next-step decision. The
   height variable has to live on the .screen itself (not .btn-bar), since
   .screen's own padding and the audio toggle's position only inherit
   custom properties from ancestors, not from their own children. --- */
/* the four options now flow directly under the text instead of being
   pinned to the bottom of the screen — with four buttons that fixed
   layout left a big empty gap between the question and the first option.
   Text sits close to the top so the zigzag of circles below has room. */
.goodchoice-quad {
  justify-content: flex-start;
  padding-top: 24px;
  padding-bottom: 40px;
}
.btn-bar--quad {
  position: static;
  transform: none;
  width: 100%;
  max-width: none;
  margin-top: 24px;
  padding: 0;
  align-items: flex-start;
}
/* four small pills in a zigzag (alternating left/right) instead of a
   straight vertical stack of full-width rectangles */
.btn-stack--quad {
  gap: 14px;
}
.btn-stack--quad .btn-next {
  align-self: flex-start;
  flex: 0 0 auto;
  width: min(58vw, 210px);
  min-height: 48px;
  padding: 10px 20px;
  font-size: clamp(12px, 3.4vw, 15px);
  line-height: 1.15;
}
.btn-stack--quad .btn-next:nth-child(even) { align-self: flex-end; }
.btn-stack--quad .btn-next:first-child {
  width: min(56vw, 200px);
  font-size: clamp(14px, 3.8vw, 17px);
}

/* --- recall placeholders (blank until answered): the same hand-drawn
   twig dash as the answer input line, everywhere it's used --- */
.recall {
  display: inline-block;
  min-width: 90px;
  padding-bottom: 6px;
  background-image: url('Images/twig_dash.png');
  background-repeat: no-repeat;
  background-position: center bottom;
  background-size: 80px 18px;
}

/* --- Park Poem generated poem screen: the badge shown large behind the
   recalled answers, each stitched into its own short line (see
   setLine() in script.js) rather than raw-concatenated text --- */
/* the recall words can run to any length the player typed, so this
   screen scrolls instead of centring (which pushed overflow behind the
   fixed button bar) — same safety-net pattern used for badge screens */
.poem-display-screen.notice-screen {
  /* the recall text can run long enough to actually reach the bottom
     here, so this screen scrolls rather than centres (see below) — the
     universal --btn-bar-height default already accounts for the real
     button size now, no override needed */
  height: 100vh;
  overflow-y: auto;
  justify-content: flex-start;
  padding-top: 48px;
}
.poem-display-stage {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.poem-display-badge {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 420px);
  height: auto;
  z-index: 0;
  pointer-events: none;
}
.poem-display-lines {
  position: relative;
  z-index: 1;
  max-width: 90vw;
}
.poem-line {
  font-weight: 400;
  margin: 0;
  min-height: 0;
  line-height: 1.6;
  background: rgba(250, 245, 234, 0.85);
  border-radius: 14px;
  padding: 20px 18px;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* the four recalled answers stand out from the surrounding poem text, but
   only modestly — at 3x size they broke the reading flow and forced a lot
   of scrolling */
.poem-recall {
  font-size: 1.3em;
  font-weight: 700;
}

/* --- disabled continue button (hub, picker) --- */
.btn-next.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}

/* --- short plain-text notice screens (e.g. "Good choice. Try another?") --- */
.notice-screen {
  justify-content: center;
}

/* --- treasure hunt clue picker grid (screen-treasure-picker) --- */
.clue-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 8px 0 -40px;
  padding-bottom: 40px;
  -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 40px), transparent 100%);
  mask-image: linear-gradient(to bottom, black calc(100% - 40px), transparent 100%);
}

.clue-tile {
  background: rgba(255, 255, 255, 0.28);
  border: none;
  border-radius: 14px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.clue-tile .tile-img {
  aspect-ratio: 3 / 3.6;
  background: rgba(44, 74, 115, 0.18);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #2C4A73;
}

.clue-tile .tile-label {
  font-weight: 700;
  font-size: 15px;
  color: #2C4A73;
  line-height: 1.25;
}

.clue-tile.selected { background: var(--btn-bg); }
.clue-tile.selected .tile-img { background: rgba(255, 255, 255, 0.22); color: #FFFFFF; }
.clue-tile.selected .tile-label { color: #FFFFFF; }

/* --- Treasure Hunt colour questions: "wrong answer" popup --- */
.wrong-choice-popup {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(22, 50, 79, 0.4);
}
.wrong-choice-popup.is-visible { display: flex; }
.wrong-choice-card {
  background: rgba(250, 245, 234, 0.97);
  border-radius: 24px;
  padding: 32px 28px 28px;
  max-width: 300px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 30px rgba(22, 50, 79, 0.3);
}
.wrong-choice-card p {
  font-family: "ParkVoyage Ink", serif;
  font-size: 26px;
  color: var(--text);
  margin: 0 0 24px;
}
.wrong-choice-card .btn-next {
  position: relative;
  width: min(50vw, 160px);
  margin: 0 auto;
}

/* --- universal layout (worked out and proven on screen-1): the Next
   pill sits alone on its own row, centred to both sides; Back (left)
   and the sound/pause icon (right) sit on the row underneath, each
   lined up under the pill's own edge rather than centred as a pair. --- */
.btn-back {
  position: fixed;
  /* .btn-back is nested inside .btn-bar, which has its own transform —
     that makes .btn-bar (not the viewport) the containing block for
     this fixed element, on BOTH axes. "50%" here is 50% of the bar's
     own (already correctly-centred, cap-respecting) width, which is
     exactly the pill's own horizontal centre — using "50vw" instead
     would only coincidentally line up on a viewport exactly as wide as
     the app itself, and drift apart on any wider window. */
  left: calc(50% - min(32vw, 120px));
  transform: translateX(-50%);
  /* same reasoning vertically: "bottom" here is measured from .btn-bar's
     own bottom edge. .btn-bar's own bottom is 16mm + bar-extra +
     safe-bottom from the true viewport bottom — the bar-extra and
     safe-bottom terms cancel out algebraically (they shift .btn-bar's
     edge and this element's offset from it by the same amount), leaving
     a plain constant. Including them here (an earlier mistake) silently
     cancelled out any change to --bar-extra, which is why raising it
     failed to actually move this element. */
  bottom: calc(8px - 16mm);
}
/* goodchoice-quad (4-option) screens keep Back in its original spot in
   the row — only its drawn style (bare arrow, no ring) changed, not the
   layout. badge-dual screens now use the universal fixed position below
   the centred stack (see .btn-stack above), same as everywhere else. */
.goodchoice-quad .btn-back {
  position: relative;
  left: auto;
  transform: none;
  bottom: auto;
}
/* screen 6's photo runs dark right where the icons sit, so the usual
   navy ink is hard to see there — flip it light just on this screen */
#screen-6 .btn-back,
.app:has(#screen-6.active) .audio-toggle img {
  filter: brightness(0) invert(1) drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45));
}
