/* Monty's Memory Meadow — Design System */

/* ─── Variables ─────────────────────────────────────────────── */
:root {
  --primary: #376457;
  --primary-rgb: 55, 100, 87;
  --primary-container: #b7e7d7;
  --on-primary: #ccfdec;
  --on-primary-container: #29564a;

  --surface: #f3f7fb;
  --surface-container-low: #ecf1f6;
  --surface-container-lowest: #ffffff;
  --surface-container-high: #dde3e8;
  --surface-container-highest: #d7dee3;
  /* Used by the fallback parental gate, which builds its UI inline and has no
     access to the modal styles. */
  --border: #c8d1d6;

  --secondary-container: #e4d7fd;
  --on-secondary-container: #534968;
  --tertiary-container: #ffccbc;
  --on-tertiary-container: #664237;

  --on-surface: #2a2f32;
  --on-surface-variant: #575c60;
  --outline-variant: #a9aeb1;

  /* The Google Fonts may never arrive on an offline-first first run, so the
     fallback list names real system faces instead of a bare sans-serif —
     matching legal/legal.css. */
  --font-headline: 'Plus Jakarta Sans', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-body: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --radius-md: 0.75rem;
  --radius-lg: 1.5rem;
  --radius-xl: 2rem;
  --radius-full: 9999px;

  --shadow-card: 0 4px 12px rgba(42, 47, 50, 0.06);
  --shadow-modal: 0 20px 40px rgba(42, 47, 50, 0.12);

  /* Monty's paint box. The buttons are built from these five inks plus the
     two generated textures, so the whole control family can be re-tinted in
     one place. --ink is the drawn outline on every painted control; --gold is
     the star in Monty's hand and the keyline around the main action. */
  --ink: #1e3a31;
  --ink-soft: #2b4a3f;
  --cream: #fff6e0;
  --gold: #f6c453;
  --gold-soft: #ffe49a;
  --gold-deep: #c98a23;
  --gold-ink: #4a3510;

  /* Generated by scripts/generate-ui-art.py. A url() in a custom property
     resolves against this stylesheet, so the ../ prefix is correct here. */
  --btn-scale-light: url('../assets/ui/scale-light.png?v=4d2e14d392');
  --btn-scale-ink: url('../assets/ui/scale-ink.png?v=c3130ac297');
  --btn-sparkle: url('../assets/ui/sparkle.png?v=6249bf3235');
}

/* ─── Scenic Backgrounds ───────────────────────────────────────
   Same two fixed layers as the meadow: artwork at z-index -2, a contrast
   wash over it at z-index -1. In the playhouse the wash has two lives:

   - On text screens (home, toy box, badges, hub) it sits between the art and
     the UI so contrast holds however bright any patch of generated art turns
     out to be — the plate rules everywhere else still carry the text.
   - Inside a room, the interior artwork IS the play surface: hotspots bring
     their own outlined bubbles and activity controls sit on frosted plates,
     so the wash almost disappears rather than hazing the picture a child
     taps on.

   Rooms switch --bg-image per data-room; every screen switch stays in the
   screen rules below, so a new room is one token line plus one image. */

body {
    --bg-home: url('../assets/rooms/bg-playhouse.webp?v=0c3c67844d');
    --bg-hub: url('../assets/rooms/bg-playhouse.webp?v=0c3c67844d');
    --bg-living-room: url('../assets/rooms/bg-living-room.webp?v=8b76c3db3c');
    --bg-kitchen: url('../assets/rooms/bg-kitchen.webp?v=21144dfb77');
    --bg-bedroom: url('../assets/rooms/bg-bedroom.webp?v=1c1dcaf437');
    --bg-backyard: url('../assets/rooms/bg-backyard.webp?v=0fd430a4ef');
    --bg-bathroom: url('../assets/rooms/bg-bathroom.webp?v=c09421bdbc');
    --bg-image: var(--bg-home);

    /* Panel tokens. Interactive surfaces a child reads — toy chips, slot
       faces — stay opaque; everything that frames them takes an alpha. */
    --panel: rgba(255, 255, 255, 0.74);
    --panel-soft: rgba(255, 255, 255, 0.56);
    --panel-strong: rgba(255, 255, 255, 0.90);
    --glass-edge: rgba(255, 255, 255, 0.75);
}

body::before,
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
}

body::before {
    z-index: -2;
    background-image: var(--bg-image);
    /* The art is 1024 square and cover-fitted, so a portrait phone crops the
       sides and a landscape monitor crops the sky. The prompts keep furniture
       on the edges and the middle clear for exactly that reason. */
}

body::after {
    z-index: -1;
    background: linear-gradient(180deg,
        rgba(243, 247, 251, 0.52) 0%,
        rgba(243, 247, 251, 0.34) 45%,
        rgba(243, 247, 251, 0.50) 100%);
}

/* JS toggles the badge shelf, hunt banner and install prompt with the
   `hidden` attribute; the attribute only beats rules that set display. */
[hidden] { display: none !important; }

body[data-screen="home"],
body[data-screen="toybox"],
body[data-screen="badges"] { --bg-image: var(--bg-home); }
body[data-screen="hub"] { --bg-image: var(--bg-hub); }
body[data-screen="room"][data-room="living-room"] { --bg-image: var(--bg-living-room); }
body[data-screen="room"][data-room="kitchen"] { --bg-image: var(--bg-kitchen); }
body[data-screen="room"][data-room="bedroom"] { --bg-image: var(--bg-bedroom); }
body[data-screen="room"][data-room="backyard"] { --bg-image: var(--bg-backyard); }
body[data-screen="room"][data-room="bathroom"] { --bg-image: var(--bg-bathroom); }

/* A child taps the art itself in a room; the wash thins to a whisper. */
body[data-screen="room"]::after {
    background: linear-gradient(180deg,
        rgba(243, 247, 251, 0.12) 0%,
        rgba(243, 247, 251, 0.04) 45%,
        rgba(243, 247, 251, 0.14) 100%);
}

/* Room activity overlays (picnic, fort) dim the room behind them so the
   frosted plates read as a separate play surface. */
body[data-activity] .room-stage::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(42, 60, 52, 0.35);
    pointer-events: none;
    z-index: 1;
}

/* Frosted glass: the panel samples the artwork behind it — the meadow
   contract, restated because the Scenery section that declares it is the
   one this block swaps for the playhouse artwork. Framing panels only.
   The memory game's header, score and difficulty panels are pruned from
   the kept base (see PRUNE_SELECTORS), so they are absent here too. */
.victory-content,
.preview-scroll-container,
.settings-modal,
.install-prompt,
.game-footer {
    -webkit-backdrop-filter: blur(14px) saturate(1.08);
    backdrop-filter: blur(14px) saturate(1.08);
}

.card-grid,
.victory-content,
.settings-modal,
.install-prompt,
.game-footer {
    border: 1px solid var(--glass-edge);
}

/* The artwork carries the depth the page used to get from stacked surface
   colours, so panels keep their radius and a softer shadow instead of both. */
:root {
    --shadow-card: 0 4px 12px rgba(42, 47, 50, 0.10);
    --shadow-modal: 0 20px 40px rgba(42, 47, 50, 0.18);
}


/* ─── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100vh; /* Fallback for browsers that do not support Custom Properties */
  height: 100dvh;
  font-family: var(--font-body);
  color: var(--on-surface);
  line-height: 1.5;
  overflow: hidden; /* Prevent all scroll - game is contained */
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  padding: 0;
}

/* html keeps the flat surface as the root canvas colour: it is what shows
   during the frame before the artwork decodes, and what high-contrast modes
   fall back to. body must stay transparent or the scenery layers painted at
   z-index -1/-2 are hidden behind it. */
html { background: var(--surface); }
body { background: transparent; }

/* ─── Typography ─────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-headline);
  letter-spacing: -0.02em;
  color: var(--on-surface);
}
h1 { font-size: clamp(1.25rem, 4vw, 2rem);   font-weight: 700; }
h2 { font-size: clamp(1.25rem, 3vw, 1.75rem); font-weight: 600; }
h3 { font-size: clamp(1rem,   2.5vw, 1.25rem);font-weight: 600; }

/* ─── Loading Overlay ────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--primary-container);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20000;
  transition: opacity 0.5s ease-out, visibility 0.5s;
}
.loading-overlay.hidden { opacity: 0; visibility: hidden; }

.loader-content {
  text-align: center;
  color: var(--on-primary-container);
  padding: 2rem;
}

.loader-title {
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  margin-bottom: 2rem;
  color: var(--primary);
}

.spinner {
  font-size: clamp(2.5rem, 8vw, 4rem);
  margin-bottom: 1rem;
  animation: rotateScale 1.5s ease-in-out infinite;
  display: inline-block;
}

@keyframes rotateScale {
  0%   { transform: scale(1)   rotate(0deg); }
  50%  { transform: scale(1.2) rotate(180deg); }
  100% { transform: scale(1)   rotate(360deg); }
}

.loader-content p {
  font-family: var(--font-headline);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: clamp(0.75rem, 2vw, 1rem);
}

/* ─── Header ─────────────────────────────────────────────────── */

/* Hide header in home/victory screens to favor the brand masthead/hero */
#main-header {
  display: none;
}

body[data-screen="game"] #game-container {
  max-width: 100vw;
  padding: calc(0.25rem + var(--reserved-top)) 
           calc(0.5rem + env(safe-area-inset-right)) 
           calc(0.5rem + var(--reserved-bottom) + env(safe-area-inset-bottom)) 
           calc(0.5rem + env(safe-area-inset-left));
  overflow: hidden; /* Force no scrolling in game mode */
  overflow-x: hidden; /* Extra prevention of horizontal scroll */
}




/* The home screen scrolls instead of clipping.
   This rule used to be overflow: hidden so that iPad and desktop never saw a
   scrollbar — but a stack that is taller than its box still overflows when the
   overflow is hidden, it just does so at both ends, and the top end is
   unreachable: no scrollbar, no keyboard, nothing to drag. The masthead lost
   its top few pixels that way on an iPad portrait, and a 667x375 phone lost
   the top 14px of Play Now for good. With auto, the bar only appears when
   there is something to reach, and the two rules below keep the stack centred
   exactly as before whenever it fits. */
body[data-screen="home"] #game-container {
  overflow-y: auto;
  /* The world carousel scrolls horizontally inside its own track; the page
     itself must never gain a second horizontal scrollbar from the off-screen
     cards. */
  overflow-x: hidden;
  /* Centring has to come out of the scroller: auto margins centre a flex item
     that fits, whereas justify-content centres the one that does not too, which
     is the thing that puts part of the screen above the scroll origin. */
  justify-content: flex-start;
}

body[data-screen="home"] #home-screen.active {
  width: 100%;
  min-width: 0;
  height: auto;
  flex: 0 0 auto;
  margin: auto;
  justify-content: flex-start;
}

/* ─── Main Container ─────────────────────────────────────────── */
#game-container {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: calc(clamp(0.5rem, 1.5vh, 1.25rem) + var(--reserved-top)) 
           calc(clamp(1rem, 3vw, 2rem) + env(safe-area-inset-right)) 
           calc(clamp(0.5rem, 1.5vh, 1.25rem) + var(--reserved-bottom)) 
           calc(clamp(1rem, 3vw, 2rem) + env(safe-area-inset-left));
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}


/* ─── Screens ────────────────────────────────────────────────── */
.screen { display: none; animation: screenEnter 0.3s ease-out; height: 100%; }
.screen.active { display: flex; flex-direction: column; }
#home-screen.active, #victory-screen.active { justify-content: center; }

/* Transform only, no opacity: an ancestor with opacity < 1 becomes a backdrop
   root, so the frosted panels inside would sample nothing for the length of
   the fade and then pop to blurred when it ended. */
@keyframes screenEnter {
  from { transform: translateY(8px); }
  to   { transform: translateY(0); }
}

/* ─── Home Screen ────────────────────────────────────────────── */
.welcome-content {
  text-align: center;
  /* The home column is a flex item with auto side margins, so without an
     explicit width it sizes to its max-content — and the three carousel cards
     then widened it to 812px on a 390px phone. Width 100% keeps the column
     inside the screen and lets the carousel's own track scroll. */
  width: 100%;
  min-width: 0;
  padding: clamp(0.5rem, 3vh, 2rem) clamp(1rem, 5vw, 3rem);
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  max-width: 900px;
  margin: 0 auto;
}

.hero-brand {
  margin-bottom: clamp(0.75rem, 2.5vh, 1.5rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeInDown 0.8s cubic-bezier(0.23, 1, 0.32, 1);
}

/* The masthead is a drawn lockup rather than live text. The h1 still carries
   the name for assistive tech and search through the image's alt text, while
   the artwork keeps the lettering crisp and independent of any display font. */
.hero-heading {
  margin: 0;
  line-height: 0;
}

.hero-banner {
  display: block;
  width: clamp(18rem, 82vw, 36rem);
  max-width: 100%;
  height: auto;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.mascot-area {
  margin-bottom: clamp(0.5rem, 2.5vh, 1.5rem);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}

.mascot-image-wrapper {
  width: clamp(140px, 35vw, 280px);
  height: clamp(140px, 35vw, 280px);
  max-width: 35vh;
  max-height: 35vh;
  position: relative;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.5s;
  animation: float 4s ease-in-out infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}

/* The mascot breathes rather than bobs: a 6px vertical drift plus a 1.5deg
   sway. This keyframe was referenced for three releases without being defined,
   so the animation silently did nothing.
   6px drift on a 140-280px mascot is imperceptible, so it is safe under
   prefers-reduced-motion; the blanket rule in the reduced-motion block also
   turns it off. */
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-6px) rotate(-1.5deg); }
}

.mascot-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 20px 40px rgba(0,0,0,0.1));
  position: relative;
  z-index: 2;
}

/* Small, deliberate doorway from the game to the 3D showcase. It sits on the
   mascot corner so it never competes with Play, but still has a 44px target. */
.mascot-3d-link {
  position: absolute;
  right: -4px;
  bottom: 4px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: transparent;
  color: var(--primary);
  font-family: var(--font-headline, inherit);
  text-decoration: none;
  transition: transform 0.2s ease;
}

/* The 44px link stays the touch target; the visible pill is smaller so it
   does not dominate the mascot. */
.mascot-3d-link span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 18px rgba(55, 100, 87, 0.22);
  transition: background 0.2s ease;
}

/* Touch devices latch :hover, and this badge sits on the artwork where there is
   no second press to clear it — the lift would stick to Monty's face until the
   next tap. Same gating as every other control in this file. */
@media (hover: hover) and (pointer: fine) {
  .mascot-3d-link:hover {
    transform: translateY(-2px);
  }

  .mascot-3d-link:hover span {
    background: #ffffff;
  }
}

.mascot-3d-link:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

/* At the compact home sizes the mascot is only 76-90px wide and the badge
   covers its face. The footer's "3D Monty" link remains as the doorway. */
@media (max-height: 950px), (max-width: 600px) {
  .mascot-3d-link {
    display: none;
  }
}

.mascot-glow {
  position: absolute;
  width: 120%;
  height: 120%;
  background: radial-gradient(circle, var(--primary-container) 0%, transparent 70%);
  opacity: 0.6;
  filter: blur(40px);
  z-index: 1;
  animation: pulseGlow 4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1);   opacity: 0.4; }
  50%       { transform: scale(1.1); opacity: 0.7; }
}

/* Two gold glints in the air around Monty, drawn from the same sparkle as the
   primary button. They are decorative, sit outside the art's silhouette, and
   stop moving with the rest of the page under prefers-reduced-motion. */
.mascot-area::before,
.mascot-area::after {
  content: '';
  position: absolute;
  z-index: 3;
  width: clamp(9px, 2.4vw, 20px);
  height: clamp(9px, 2.4vw, 20px);
  background-image: var(--btn-sparkle);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  filter: drop-shadow(0 0 6px rgba(246, 196, 83, 0.4));
  pointer-events: none;
  animation: twinkle 3.8s ease-in-out infinite;
}

.mascot-area::before {
  top: 12%;
  left: 1%;
}

.mascot-area::after {
  /* Upper right, not lower right: that corner belongs to the 3D badge. */
  right: 2%;
  top: 15%;
  width: clamp(7px, 1.7vw, 13px);
  height: clamp(7px, 1.7vw, 13px);
  animation-delay: 0.9s;
  animation-duration: 4.6s;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.45; transform: scale(0.85) rotate(0deg); }
  50%      { opacity: 1;    transform: scale(1.08) rotate(12deg); }
}

/* At the compact mascot size the glints land on Monty's wing and foot rather
   than beside him, so they only appear once the art has room around it. */
@media (max-height: 950px) {
  .mascot-area::before,
  .mascot-area::after {
    display: none;
  }
}

.welcome-content.mode-difficulty .mascot-image-wrapper {
  width: clamp(100px, 25vw, 150px);
  height: clamp(100px, 25vw, 150px);
  margin-bottom: 0.5rem;
}

.welcome-content.mode-difficulty .hero-brand {
  margin-bottom: 1rem;
}

.hero-tagline {
  color: var(--on-surface-variant);
  margin-bottom: clamp(0.75rem, 3vh, 1.75rem);
  font-weight: 500;
  font-size: clamp(1rem, 3vw, 1.25rem);
  /* Full opacity: the 0.9 came from the flat-surface design, where it was a
     gentle tone. On a plate over artwork it only lightens the glyphs —
     measured 4.14:1 with it, 5.3:1 without. */
  opacity: 1;
  /* Caption plate: the rationale is in the Scenery section, the declarations
     live here so the class is not split across two rules in one file. */
  display: inline-block;
  max-width: 34ch;
  padding: 0.4rem 1rem;
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
  -webkit-backdrop-filter: blur(14px) saturate(1.08);
  backdrop-filter: blur(14px) saturate(1.08);
}


/* ─── Buttons ────────────────────────────────────────────────── */
/* The controls are painted objects from Monty's meadow, not stock pills: a
   mint scale plate for the main action, a cream belly plate for everything
   quieter, a gold keepsake for support. Each is four layers — a painted face,
   a faint dragon-scale field, a gold keyline, and a solid colour lip under the
   face — so the button has the heft of a toy block and the detail of a picture
   book. The texture and the sparkle are generated by
   scripts/generate-ui-art.py; everything else is CSS.

   One base for every action control: the same type family, icon geometry and
   springy release, so Play, a difficulty chip and Back feel like they came
   from the same toy. A variant only changes colour, elevation and padding. */
.btn-primary,
.btn-secondary,
.btn-difficulty,
.btn-back,
.btn-support {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-headline);
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  border-radius: 1.125rem;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  /* The spring is on the release: pressing still lands immediately, but the
     button squishes back rather than snapping. It is the one motion a child
     gets from every tap, including on a touchscreen. */
  transition:
    filter 0.2s ease,
    background-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.16s cubic-bezier(0.34, 1.56, 0.64, 1),
    transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Decorative glyphs are sized by the button, not by an inline style, so the
   icon and the label share one baseline and one gap on every control. */
.btn-primary > svg,
.btn-secondary > svg,
.btn-difficulty > svg,
.btn-back > svg,
.btn-support > svg {
  width: 1.15em;
  height: 1.15em;
  flex: 0 0 auto;
}

/* The base sets display, and an author display beats the UA rule behind the
   `hidden` attribute. Without this guard Play Now stays on screen after it is
   hidden — the same trap documented on .install-prompt. */
.btn-primary[hidden],
.btn-secondary[hidden],
.btn-difficulty[hidden],
.btn-back[hidden],
.btn-support[hidden] {
  display: none;
}

/* The main action: Monty's own mint, with the star from his wand twinkling at
   the two corners. Ink text, not cream: the face has to stay bright enough to
   feel like the meadow, and cream on mint measures 2.8:1. The dark ink reads
   at 6.5:1 and the heavy outline keeps the light button from dissolving into
   a pale panel. */
.btn-primary {
  --btn-depth: 4px;
  --btn-lip: #5aa87f;
  --btn-shadow:
    inset 0 0 0 2px rgba(255, 245, 210, 0.55),
    inset 0 2px 0 rgba(255, 255, 255, 0.65),
    inset 0 -5px 9px rgba(30, 90, 65, 0.16),
    0 var(--btn-depth) 0 var(--btn-lip),
    0 calc(var(--btn-depth) + 7px) 16px rgba(30, 68, 55, 0.28);
  --btn-shadow-press:
    inset 0 0 0 2px rgba(255, 245, 210, 0.5),
    inset 0 2px 0 rgba(255, 255, 255, 0.5),
    inset 0 -2px 6px rgba(30, 90, 65, 0.16),
    0 0 0 var(--btn-lip);
  min-height: 56px;
  padding: 0.85rem 1.5rem;
  border: 2px solid #17342b;
  border-radius: 1.25rem;
  font-size: clamp(0.95rem, 2.5vw, 1.125rem);
  color: var(--ink);
  cursor: pointer;
  background-color: #8bd2ab;
  background-image:
    var(--btn-sparkle),
    var(--btn-sparkle),
    var(--btn-scale-light),
    linear-gradient(180deg, #a8e0c0 0%, #8bd2ab 46%, #7cc79d 100%);
  background-repeat: no-repeat, no-repeat, repeat, no-repeat;
  background-position: right 14px top 9px, left 20px bottom 9px, 0 0, 0 0;
  background-size: 17px 17px, 10px 10px, 44px 30px, 100% 100%;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
  box-shadow: var(--btn-shadow);
}

/* The quiet action: a cream belly plate. Warm enough to separate from the
   frosted white panels, with the darkest ink available for the label. */
.btn-secondary {
  --btn-depth: 3px;
  --btn-lip: #ddc194;
  --btn-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.9),
    inset 0 2px 0 rgba(255, 255, 255, 0.8),
    inset 0 -4px 8px rgba(150, 115, 60, 0.12),
    0 var(--btn-depth) 0 var(--btn-lip),
    0 calc(var(--btn-depth) + 6px) 14px rgba(90, 80, 50, 0.18);
  --btn-shadow-press:
    inset 0 0 0 1px rgba(255, 255, 255, 0.85),
    inset 0 -2px 6px rgba(150, 115, 60, 0.14),
    0 0 0 var(--btn-lip);
  min-height: 56px;
  padding: 0.75rem 1.35rem;
  border: 2px solid rgba(30, 58, 49, 0.78);
  border-radius: 1.125rem;
  font-size: clamp(0.9rem, 2vw, 1rem);
  color: var(--ink-soft);
  cursor: pointer;
  background-color: #fff3d9;
  background-image:
    var(--btn-scale-ink),
    linear-gradient(180deg, #fffcf3 0%, #fff3d9 55%, #f8e4bd 100%);
  background-repeat: repeat, no-repeat;
  background-size: 44px 30px, 100% 100%;
  box-shadow: var(--btn-shadow);
}

/* Hover is a pointer affordance, not a press affordance. On a touchscreen the
   last touched style stays painted until something else is tapped, so an
   ungated hover rule leaves a button wearing its hover state long after the
   finger has left it. Every control hover in this file sits behind
   (hover: hover) and (pointer: fine); the shared press cue in the Button states
   section is what a touch device gets instead. */
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover {
    /* Brightening the already-light face would lower the ink contrast, so the
       lift is carried by the shadow and a very small saturation bump. */
    filter: saturate(1.05);
    transform: translateY(-1px);
  }
  .btn-secondary:hover {
    filter: brightness(1.02);
    transform: translateY(-1px);
  }
}

/* ─── Touch Target Enforcement (56px minimum for children) ─── */
button,
[role="button"],
input[type="checkbox"],
.btn-difficulty,
.btn-primary,
.btn-secondary,
.btn-back,
.btn-link,
.card {
  min-height: 56px;
  min-width: 56px;
}

/* Suppress the grey iOS tap flash and the double-tap zoom delay: the button's
   own press state is the feedback, not the browser's. */
button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}


.btn-large {
  padding: 0.95rem 2rem;
  border-radius: 1.35rem;
  font-size: clamp(1rem, 3vw, 1.25rem);
  /* The hero action should read as the biggest target on the screen, not as a
     pill that happens to be green: at 19rem it is nearly the full content
     width on a phone and stops growing on a tablet. */
  min-width: min(100%, 19rem);
  /* A slightly larger glint on the largest control, so the sparkle stays in
     proportion instead of shrinking into a speck. */
  background-position: right 18px top 11px, left 22px bottom 10px, 0 0, 0 0;
  background-size: 20px 20px, 11px 11px, 44px 30px, 100% 100%;
}

/* ─── Victory Screen ─────────────────────────────────────────── */
.victory-content {
  text-align: center;
  padding: clamp(0.75rem, 2vw, 2rem);
  background: var(--panel);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  max-width: min(900px, 95vw);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.5rem, 1.5vw, 1.5rem);
}

/* Side-by-side in landscape if height is limited */
@media (orientation: landscape) {
  .victory-content {
    flex-direction: row;
    text-align: left;
    padding: clamp(1rem, 2vw, 2rem);
  }
  
  .victory-image-wrapper {
    flex: 0 0 45%;
    margin-bottom: 0 !important;
  }
  
  .victory-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1rem;
  }

  /* The banner and stars are centred above it; a left-aligned label under
     them looked misplaced. */
  .victory-subtitle { text-align: center; }
}

.victory-image-wrapper {
  position: relative;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  transform-origin: center;
  width: 100%;
}

/* The animated Monty is transparent, so it floats over the meadow instead of
   sitting in the old bordered card. The glow replaces the card's shadow. */
.victory-image-glow {
  position: absolute;
  inset: 4%;
  z-index: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.9) 0%, rgba(183, 231, 215, 0.45) 46%, rgba(183, 231, 215, 0) 72%);
  filter: blur(4px);
  pointer-events: none;
}

.victory-image {
  width: 100%;
  max-width: clamp(200px, 40vw, 350px);
  height: auto;
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(55, 100, 87, 0.2);
  animation: victoryPop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.victory-image--monty {
  position: relative;
  z-index: 1;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  object-fit: contain;
}

@keyframes victoryPop {
  0%   { transform: scale(0.6) translateY(30px); opacity: 0; }
  100% { transform: scale(1)   translateY(0);    opacity: 1; }
}

/* Victory confetti. Pure CSS animation; the pieces are created in JS with
   per-piece position, colour, delay and duration as custom properties. */
.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9000;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -12vh;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  background: var(--piece-colour, var(--primary));
  opacity: 0;
  animation: confettiFall var(--piece-time, 2.6s) linear var(--piece-delay, 0s) forwards;
}

@keyframes confettiFall {
  0%   { opacity: 1; transform: translateY(0) rotate(0deg); }
  100% { opacity: 0; transform: translateY(110vh) rotate(720deg); }
}

/* Stat values count up on the victory screen; the pop marks each change. */
.stat-value.counting {
  animation: statPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* The in-game moves counter is a <strong>, which is inline, so transform
   needs it promoted to inline-block before the pop can apply. */
#moves-count {
  display: inline-block;
}

#moves-count.counting {
  animation: statPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes statPop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.stats-bento {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(0.5rem, 1.5vw, 1rem);
  margin-bottom: 0.5rem;
  width: 100%;
}


.stat-card {
  background: var(--panel-soft);
  padding: clamp(0.5rem, 1.5vw, 1rem) clamp(0.5rem, 1vw, 0.75rem);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  align-items: center;
  text-align: center;
}

.stat-label {
  font-size: clamp(0.7rem, 1.5vw, 0.875rem);
  color: var(--on-surface-variant);
  font-family: var(--font-body);
}

.stat-value {
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  font-weight: 700;
  color: var(--primary);
  font-family: var(--font-headline);
}

/* The win headline is a drawn prize ribbon, like the masthead. The h2 keeps
   the words for assistive tech and search through the image's alt text. */
.victory-title {
  margin: 0 0 0.25rem;
  line-height: 0;
}

.victory-banner {
  display: block;
  width: min(34rem, 92vw);
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.victory-subtitle {
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  color: var(--on-surface-variant);
  margin-bottom: 1.5rem;
  font-weight: 500;
}

/* Star rating: unlit stars are pale outlines, earned ones turn gold. The pop
   in sequence only runs when motion is welcome. */
.victory-stars {
  display: flex;
  justify-content: center;
  gap: clamp(0.25rem, 1.5vw, 0.6rem);
  margin: 0.25rem 0 0.35rem;
  line-height: 0;
}

.victory-star {
  width: clamp(1.9rem, 6vh, 2.75rem);
  height: clamp(1.9rem, 6vh, 2.75rem);
  fill: rgba(255, 255, 255, 0.7);
  stroke: rgba(30, 58, 49, 0.35);
  stroke-width: 1.4;
  stroke-linejoin: round;
}

.victory-star.earned {
  fill: var(--gold);
  stroke: var(--gold-ink);
  filter: drop-shadow(0 2px 0 rgba(201, 138, 35, 0.5));
}

/* The middle star sits a touch higher, like a podium. */
.victory-star:nth-child(2) { transform: translateY(-0.3rem); }

@media (prefers-reduced-motion: no-preference) {
  .victory-star.earned {
    animation: starPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    animation-delay: calc(0.35s + var(--star-index, 0) * 0.28s);
  }
}

@keyframes starPop {
  0%   { transform: scale(0.2) rotate(-30deg); opacity: 0; }
  70%  { transform: scale(1.2) rotate(6deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.victory-star.earned:nth-child(2) { animation-name: starPopMiddle; }

@keyframes starPopMiddle {
  0%   { transform: translateY(-0.3rem) scale(0.2) rotate(-30deg); opacity: 0; }
  70%  { transform: translateY(-0.3rem) scale(1.2) rotate(6deg); opacity: 1; }
  100% { transform: translateY(-0.3rem) scale(1) rotate(0); opacity: 1; }
}

/* Best rating so far on the difficulty button. */
.diff-best {
  font-size: 0.75em;
  line-height: 1;
  letter-spacing: 0.08em;
  color: var(--gold-deep);
}

.victory-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ─── Install Prompt ─────────────────────────────────────────── */
.install-prompt {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-strong);
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  z-index: 9999;
  width: min(420px, 92vw);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  animation: slideUp 0.3s ease-out;
}

/* The prompt is a fixed overlay. It belongs on the home screen only: on the
   game, preview, victory and collection screens it would sit on top of the
   board or the action buttons. It reappears when the child returns home. */
body:not([data-screen="home"]) .install-prompt { display: none; }

/* `hidden` is a UA `display: none`, and an author rule beats a UA rule no
   matter what it says. Without this guard the `display: flex` above wins and
   the prompt is on screen even when it is meant to be hidden — which is why
   "Not Now" appeared to do nothing in Safari. */
.install-prompt[hidden] {
  display: none;
}

.install-steps {
  margin-top: 0.5rem;
  padding: 0.5rem 0.625rem;
  background: rgba(255, 255, 255, 0.55);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  color: var(--on-surface-variant);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.install-steps[hidden] { display: none; }
.install-step { display: flex; align-items: center; gap: 0.4rem; }
.install-step-sep { color: var(--outline-variant); }
.install-step-num {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: var(--radius-full);
  background: var(--primary-container);
  color: var(--on-primary-container);
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 0.75rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.install-content h3 { color: var(--primary); font-size: 1rem; }
.install-content p  { color: var(--on-surface-variant); font-size: 0.875rem; margin-top: 0.25rem; }

.install-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* ─── Offline Banner ──────────────────────────────────────────── */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--on-surface);
  color: var(--surface-container-lowest);
  padding: 0.75rem 1rem;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.offline-banner:not([hidden]) {
  display: flex;
}

/* ─── Update Banner ──────────────────────────────────────────── */
.update-banner {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary-container);
  color: var(--on-primary-container);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  z-index: 9999;
  width: min(400px, 90vw);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  animation: slideUp 0.3s ease-out;
}
.update-banner[hidden] {
  display: none;
}

/* The banner is fixed to the bottom of the viewport and would otherwise sit
   on top of the footer's Support button, legal links and copyright. Pad the
   footer so its content can scroll clear of the banner. */
body.update-banner-visible .game-footer {
  padding-bottom: calc(1.5rem + var(--reserved-bottom, 8rem));
}

/* Same reasoning for the install prompt: it is fixed to the bottom edge and
   covers the footer's Support button, legal links and copyright. The reserve
   is measured in js/pwa.js from the prompt's own rendered height, so it stays
   correct at every width.
   The home layout is already tight (20-40px of slack at 375x667), so the
   mascot shrinks to make room. Re-measure with scripts/responsive-check.mjs.
   */
body.install-prompt-visible .game-footer {
  padding-bottom: var(--install-prompt-reserve, 178px);
}
body.install-prompt-visible .mascot-image-wrapper {
  width: clamp(100px, 26vw, 200px);
  height: clamp(100px, 26vw, 200px);
  max-width: 26vh;
  max-height: 26vh;
}
body.install-prompt-visible .mascot-glow {
  width: clamp(120px, 30vw, 240px);
  height: clamp(120px, 30vw, 240px);
}
body.install-prompt-visible .hero-tagline { display: none; }
body[data-screen="home"].install-prompt-visible #game-container { overflow-y: auto; }

/* On the game screen the same banner covers playable cards — the board
   cannot scroll, so reserving its height is the only option. The container's
   padding-bottom is derived from --reserved-bottom above. */

/* The icon keeps its size and the message takes the slack, so at 375px the
   short message stays on one line or two instead of squeezing the icon to a dot. */
.update-icon {
  flex: 0 0 auto;
  width: 1.25em;
  height: 1.25em;
}

.update-text {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  font-weight: 600;
  line-height: 1.3;
}

.update-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Banner actions sit in a strip that must not grow: the shorter lip and
   tighter padding keep Reload/Later from making the update banner taller. */
.btn-small {
  --btn-depth: 2px;
  padding: 0.45rem 0.9rem;
  font-size: 0.8125rem;
  border-radius: 0.85rem;
}

/* A banner action is too narrow for the corner glints; keep the painted face
   and texture, drop the sparkles so they cannot sit on "Reload". */
.btn-primary.btn-small {
  background-image:
    var(--btn-scale-light),
    linear-gradient(180deg, #a8e0c0 0%, #8bd2ab 46%, #7cc79d 100%);
  background-repeat: repeat, no-repeat;
  background-position: 0 0, 0 0;
  background-size: 40px 28px, 100% 100%;
}

/* ─── Settings Modal ─────────────────────────────────────────── */
.settings-modal {
  /* The universal reset sets margin: 0 on everything, which also erased the
     UA dialog's `margin: auto` and pinned every modal to the top-left corner.
     Restore it so both the settings and leave dialogs are centred. */
  margin: auto;
  border: none;
  border-radius: var(--radius-xl);
  padding: clamp(1.25rem, 3vw, 2rem);
  max-width: 400px;
  max-height: 92dvh;
  width: 90%;
  background: var(--panel-strong);
  box-shadow: var(--shadow-modal);
  overflow-y: auto;
}
.settings-modal::backdrop {
  background: rgba(42, 47, 50, 0.5);
  backdrop-filter: blur(4px);
}

.modal-content h2 { margin-bottom: 1.5rem; color: var(--primary); }

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 0;
  border-bottom: 1px solid rgba(var(--primary-rgb), 0.15);
}
.setting-item:last-of-type { border-bottom: none; }
.setting-item label { font-weight: 500; color: var(--on-surface); }

/* Label and description stack on the left, control on the right. Without this
   wrapper the row had three flex children (label, checkbox, small) and
   space-between put the checkbox in the middle, squeezing the description
   into a narrow column. */
.setting-text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.setting-item small {
  display: block;
  color: var(--on-surface-variant);
  font-size: 0.75rem;
}

/* Toggles instead of bare checkboxes. The native input stays in the DOM — it
   carries the label association, the checked state and the 56px hit area —
   and is made transparent over a painted track. A checkbox drawn by the OS at
   56px read as a form control from another application. */
.toggle {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
}
.toggle input[type="checkbox"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.toggle input[type="checkbox"]:focus-visible { outline: none; }
.toggle-track {
  display: block;
  width: 50px;
  height: 30px;
  padding: 2.5px;
  box-sizing: border-box;
  border: 1.5px solid rgba(30, 58, 49, 0.45);
  border-radius: var(--radius-full);
  background: linear-gradient(180deg, #efe6d6 0%, #fbf4e8 100%);
  box-shadow:
    inset 0 2px 4px rgba(80, 65, 40, 0.18),
    0 1px 0 #ffffff;
  transition: background-color 0.2s ease;
}
.toggle-thumb {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fffdf5 0%, #ffe9ae 55%, #eab84c 100%);
  box-shadow:
    0 1px 3px rgba(80, 60, 20, 0.35),
    inset 0 0 0 1px rgba(150, 100, 20, 0.25);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toggle input:checked + .toggle-track {
  background-color: #3d7d63;
  background-image:
    var(--btn-scale-light),
    linear-gradient(180deg, #5daa83 0%, #3d7d63 100%);
  background-repeat: repeat, no-repeat;
  background-size: 36px 24px, 100% 100%;
  border-color: var(--ink);
}
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(20px); }
.toggle input:focus-visible + .toggle-track {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

/* Destructive actions get real buttons instead of link-styled text: the old
   pair wrapped mid-label and gave a child no pressed state to aim at. They
   stay secondary, not red, because the parental gate — not the colour — is
   what protects them. */
.setting-item--data {
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
}
.setting-label {
  font-weight: 500;
  color: var(--on-surface);
}
.reset-actions {
  display: flex;
  gap: 0.5rem;
}
.reset-actions .btn-secondary {
  flex: 1 1 0;
  min-width: 0;
  padding-inline: 0.5rem;
  font-size: 0.8rem;
}

.modal-actions { margin-top: 1.5rem; text-align: center; }

/* The one confirmation in the game. It reuses the settings dialog shell, but
   centres its copy and gives both choices equal width so "Keep Playing" reads
   as the way out and "Leave Game" as the deliberate one. */
.leave-modal { text-align: center; }
.leave-modal .modal-content h2 {
  margin-bottom: 0.5rem;
  text-align: center;
}
.leave-copy {
  margin: 0;
  color: var(--on-surface-variant);
  font-size: 0.95rem;
  line-height: 1.5;
}
.leave-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}
.leave-actions .btn-primary,
.leave-actions .btn-secondary {
  width: 100%;
  min-width: 0;
  /* Two equal columns leave less room than the full-width primary normally
     gets; trim the horizontal padding so both labels stay on one line down to
     a 375px phone. */
  padding-inline: 1rem;
}

/* A narrow primary — half a modal, a banner strip, the install card's
   two-button row — cannot afford corner glints: they land on the label. It
   keeps the painted face and the scale field, and drops the sparkles. */
.btn-primary.btn-compact {
  background-image:
    var(--btn-scale-light),
    linear-gradient(180deg, #a8e0c0 0%, #8bd2ab 46%, #7cc79d 100%);
  background-repeat: repeat, no-repeat;
  background-position: 0 0, 0 0;
  background-size: 44px 30px, 100% 100%;
}

.legal-links {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(var(--primary-rgb), 0.15);
  display: flex;
  gap: 1rem;
  justify-content: center;
  font-size: 0.875rem;
  flex-wrap: wrap;
}
.legal-links a { color: var(--on-surface-variant); text-decoration: none; }
@media (hover: hover) and (pointer: fine) {
  .legal-links a:hover { color: var(--primary); }
}

/* ─── Footer ─────────────────────────────────────────────────── */
.game-footer {
  margin-top: auto;
  padding: clamp(0.5rem, 1.5vh, 1.25rem) clamp(1rem, 3vw, 2rem);
  background: var(--panel-soft);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  flex-shrink: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

body[data-screen="game"] .game-footer,
body[data-screen="preview"] .game-footer,
body[data-screen="victory"] .game-footer,
body[data-screen="highScores"] .game-footer,
/* The badges collection is as tall as the leaderboard: with the footer in
   the flow its centred panel was 67px taller than the space left, which put
   the "My Badges" title above the top of a container that cannot scroll
   backwards. Hiding the footer (as the leaderboard already does) leaves the
   whole screen visible. */
body[data-screen="badges"] .game-footer {
  display: none;
}

.footer-content {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.footer-top {
  display: flex;
  justify-content: center;
  align-items: center;
}
.footer-top[hidden] { display: none; }

.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.footer-links a, .footer-links .btn-link {
  color: var(--on-surface-variant);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.2s;
}

/* The grown-up's Terms/Privacy doors measured 42x21 as bare text. They get
   the same 44px floor as every other control in the game. */
.footer-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

@media (hover: hover) and (pointer: fine) {
  .footer-links a:hover, .footer-links .btn-link:hover { color: var(--primary); }
}
.footer-links span { color: var(--outline-variant); user-select: none; }

.footer-copyright p {
  color: var(--on-surface-variant);
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.8;
}
.footer-copyright[hidden] { display: none; }

/* ─── Legal / Support Buttons ────────────────────────────────── */
/* A gold keepsake rather than a second green action. Support is a different
   kind of thing from Play, and gold is the one colour in Monty's palette that
   no other control uses, so it can afford to be the warmest thing on screen
   without competing with the game. */
.btn-support {
  --btn-depth: 3px;
  --btn-lip: #c07f1d;
  --btn-shadow:
    inset 0 0 0 1.5px rgba(255, 250, 220, 0.5),
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    inset 0 -3px 7px rgba(150, 100, 25, 0.14),
    0 var(--btn-depth) 0 var(--btn-lip),
    0 8px 14px rgba(150, 100, 25, 0.22);
  --btn-shadow-press:
    inset 0 0 0 1.5px rgba(255, 250, 220, 0.4),
    inset 0 2px 0 rgba(255, 255, 255, 0.4),
    0 0 0 var(--btn-lip);
  min-height: 56px;
  padding: 0.65rem 1.3rem;
  border: 2px solid #7a5312;
  border-radius: 1rem;
  font-size: 0.875rem;
  color: var(--gold-ink);
  cursor: pointer;
  background-color: #f7c65c;
  background-image:
    var(--btn-scale-light),
    linear-gradient(180deg, #ffe49a 0%, #f7c65c 55%, #efb03c 100%);
  background-repeat: repeat, no-repeat;
  background-size: 44px 30px, 100% 100%;
  box-shadow: var(--btn-shadow);
}

@media (hover: hover) and (pointer: fine) {
  .btn-support:hover {
    filter: brightness(1.03);
    transform: translateY(-1px);
  }
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  min-height: 56px;
  min-width: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (hover: hover) and (pointer: fine) {
  .btn-link:hover {
    color: var(--primary);
  }
}

/* ─── Button states ────────────────────────────────────────────
   One press cue, one focus ring and one disabled state for every control, so
   a child gets the same feel from Play, from a difficulty button and from a
   world chip.

   This section sits after the component rules on purpose. A media query adds no
   specificity, so these rules are settled by source order against the hover
   rules above them — a press has to outrank a hover lift, and the primary-fill
   focus ring has to outrank the plain focus outline in the Accessibility
   section below. */

/* The press is a physical push, not a shrink: the face travels down onto its
   lip and the cast shadow disappears. :active is deliberately not behind the
   hover query, because it is the only feedback a touchscreen gets. */
.btn-primary:active,
.btn-secondary:active,
.btn-difficulty:active,
.btn-support:active {
  transform: translateY(var(--btn-depth)) scale(0.99);
}
.btn-primary:active { box-shadow: var(--btn-shadow-press); }
.btn-secondary:active { box-shadow: var(--btn-shadow-press); }
.btn-support:active { box-shadow: var(--btn-shadow-press); }
.btn-difficulty:active {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -2px 5px rgba(60, 80, 65, 0.1),
    0 0 0 var(--egg-lip);
}
.btn-back:active {
  transform: translateY(var(--btn-depth));
  box-shadow: inset 0 1px 0 #ffffff, 0 0 0 var(--btn-lip);
}
.btn-link:active,
.pack-chip:active {
  transform: scale(0.97);
}

/* The filled actions now carry a painted face, so their focus ring needs to
   read on mint and on gold: a cream ring outside a dark ink edge. The ring is
   appended to the button's own shadow instead of replacing it, otherwise
   focusing Play Now would flatten the button. */
.btn-primary:focus-visible,
.btn-support:focus-visible {
  outline: 3px solid var(--cream);
  outline-offset: 2px;
}
.btn-primary:focus-visible {
  box-shadow: var(--btn-shadow), 0 0 0 2px #17342b;
}
.btn-support:focus-visible {
  box-shadow: var(--btn-shadow), 0 0 0 2px #7a5312;
}

/* The light controls take the ink ring: a green ring on a mint egg was a
   green ring on green. */
.btn-secondary:focus-visible,
.btn-difficulty:focus-visible,
.btn-back:focus-visible {
  outline-color: var(--ink);
}

/* A control that cannot be used must not look usable, must not take a press
   transform, and must not keep a hover colour it cannot act on. The class-based
   selectors cover the custom controls; the last two lines catch anything else
   that is a real button. */
.btn-primary:disabled, .btn-primary[aria-disabled="true"],
.btn-secondary:disabled, .btn-secondary[aria-disabled="true"],
.btn-difficulty:disabled, .btn-difficulty[aria-disabled="true"],
.btn-back:disabled, .btn-back[aria-disabled="true"],
.btn-support:disabled, .btn-support[aria-disabled="true"],
.btn-link:disabled, .btn-link[aria-disabled="true"],
.pack-chip:disabled, .pack-chip[aria-disabled="true"],
button:disabled,
button[aria-disabled="true"] {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
  transform: none;
}

/* ─── Accessibility ──────────────────────────────────────────── */
button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  /* The blanket rule above removes the travel time but not the travel: a
     control that still jumps 2px, or squeezes under a finger, is still motion.
     These states keep their colour change and lose the transform. */
  .btn-primary:hover,
  .btn-support:hover,
  .btn-difficulty:hover,
  .btn-secondary:hover,
  .btn-back:hover,
  .pack-chip:hover,
  .pack-arrow:hover,
  .score-row:hover,
  .btn-primary:active,
  .btn-secondary:active,
  .btn-difficulty:active,
  .btn-back:active,
  .btn-support:active,
  .btn-link:active,
  .pack-chip:active,
  .pack-arrow:active,
  .badge-tile:hover,
  .badge-tile:active,
  .badge-nav-btn:active {
    transform: none;
  }

  /* The medallion is the one badge element that scales on hover; without
     this the art would still lurch under the pointer. */
  .badge-tile:hover .badge-face {
    transform: none;
  }

  /* The arrows stay centred; only their colour changes. */
  .pack-arrow:hover,
  .pack-arrow:active {
    transform: translateY(-50%);
  }
}

@media (prefers-contrast: more) {
  :root { --primary: #000; --on-primary: #fff; }
  /* The painted faces keep their flat colour but lose the low-contrast scale
     field and gloss; every control then gets the same hard ink boundary. */
  .btn-primary,
  .btn-secondary,
  .btn-back,
  .btn-support,
  .btn-difficulty {
    background-image: none;
    border: 2px solid var(--ink);
    box-shadow: none;
  }
  /* A painted track needs a boundary in raised-contrast mode, just like the
     chips and badges. The 1px padding keeps the 22px thumb inside the box once
     the 2px border is added. */
  .toggle-track { border: 2px solid var(--on-surface); padding: 1px; }
  .toggle input:checked + .toggle-track {
    border-color: var(--primary);
    background-image: none;
  }
}

/* ── Badges ────────────────────────────────────────────────────
   Tonal layering only: the medallion ring is a box-shadow spread, not a
   border, so it matches the rest of the design system. */
.btn-badges {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.badge-count,
.badge-progress {
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
}

/* The count on the home screen is a tiny gold counter, matching the keepsake
   Support button; the collection's progress pill stays mint so it reads as
   part of the screen title. */
.badge-count {
  color: var(--gold-ink);
  background: linear-gradient(180deg, var(--gold-soft), #f2bb4e);
  border: 1px solid rgba(120, 80, 20, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.badge-progress {
  color: var(--on-primary-container);
  background: var(--primary-container);
}

.badge-progress[data-complete="true"] {
  color: var(--gold-ink);
  background: linear-gradient(180deg, var(--gold-soft), #f2bb4e);
  border: 1px solid rgba(120, 80, 20, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

/* The collection header: a thin gold progress rail under the title, so the
   six badges read as a set to complete rather than a loose grid. */
.badge-summary {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  max-width: 24rem;
  margin: 0.1rem auto 0;
}

.badge-meter {
  flex: 1 1 auto;
  height: 0.7rem;
  border-radius: var(--radius-full);
  background: rgba(var(--primary-rgb), 0.1);
  border: 1px solid rgba(30, 58, 49, 0.18);
  box-shadow: inset 0 2px 4px rgba(30, 58, 49, 0.1);
  overflow: hidden;
}

.badge-meter-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #e8a82f 0%, var(--gold) 55%, var(--gold-soft) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
  transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.badge-meter-label {
  flex: 0 0 auto;
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 0.76rem;
  color: var(--on-surface-variant);
  margin: 0;
}

.badge-hint {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--on-surface-variant);
}

.badge-shelf {
  width: 100%;
  background: rgba(228, 215, 253, 0.78);
  border-radius: var(--radius-lg);
  padding: clamp(0.75rem, 2vw, 1rem);
  margin-bottom: 0.75rem;
}

.badge-shelf-title {
  font-family: var(--font-headline);
  font-weight: 700;
  color: var(--on-secondary-container);
  margin: 0 0 0.5rem;
  text-align: center;
}

.badge-shelf-list,
.badges-list {
  display: grid;
  width: 100%;
  gap: 0.75rem;
}

.badge-shelf-list {
  /* Three badges max on the shelf; a 70px floor keeps them in one row even on
     a 375px-wide phone, where a 96px floor wrapped the shelf to two rows and
     pushed the victory buttons below the fold. */
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
}

.badges-list {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}


/* Six badges read better as two rows of three once there is room; at phone
   widths the two-column grid keeps its larger tap targets. */
@media (min-width: 700px) {
  .badges-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.badge-tile {
  display: flex;
  border-radius: var(--radius-lg);
  background: var(--panel-soft);
  text-align: center;
  transition:
    transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.18s ease,
    background-color 0.18s ease;
}

/* The generated medallion art carries its own gold ring, so the tile adds no
 * ring of its own — a CSS ring on top of the art's ring reads as a double. */
.badge-open {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  height: 100%;
  padding: 0.85rem 0.6rem;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.badge-open:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: -3px;
}

.badge-medallion {
  position: relative;
  display: block;
  width: clamp(64px, 20vw, 104px);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 32%, #ffffff 0%, var(--surface-container-low) 72%);
  box-shadow: 0 6px 14px rgba(55, 100, 87, 0.18);
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* A soft top light and a lower inner shade give the flat art the same painted
   bevel as the rest of the controls without drawing a second gold ring. */
.badge-medallion::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 9px 16px rgba(255, 255, 255, 0.14),
    inset 0 -10px 18px rgba(30, 58, 49, 0.12);
  z-index: 1;
}

.badge-face {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (hover: hover) and (pointer: fine) {
  .badge-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(30, 58, 49, 0.14);
  }
  .badge-tile:hover .badge-face {
    transform: scale(1.04);
  }
}

.badge-tile:active {
  transform: scale(0.985);
}

.badge-tile.earned .badge-medallion {
  box-shadow:
    0 6px 14px rgba(55, 100, 87, 0.18),
    0 0 0 3px rgba(255, 255, 255, 0.3);
}

.badge-tile.locked {
  background: rgba(var(--primary-rgb), 0.06);
}

.badge-tile.locked .badge-face {
  filter: grayscale(1) contrast(0.92);
  opacity: 0.32;
}

.badge-tile.locked .badge-medallion {
  background: var(--surface-container-low);
  box-shadow: inset 0 0 0 1px rgba(var(--primary-rgb), 0.12);
}

/* A lock seal on the corner of a locked medallion: the ghosted art says
   "not yet", the seal says why. It sits over the art's own ring, not over
   the character's face. */
.badge-lock {
  position: absolute;
  right: 4%;
  bottom: 4%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: max(14px, 26%);
  aspect-ratio: 1;
  border-radius: 50%;
  color: var(--gold-ink);
  background: linear-gradient(180deg, var(--cream) 0%, #ffe9ae 100%);
  border: 1.5px solid rgba(120, 80, 20, 0.4);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 2px 5px rgba(42, 47, 50, 0.22);
}

.badge-lock svg {
  width: 58%;
  height: 58%;
}

.badge-name {
  display: block;
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.2;
  color: var(--primary);
  margin: 0;
}

.badge-tile.locked .badge-name {
  color: var(--on-surface-variant);
}

.badge-blurb {
  display: block;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--on-surface-variant);
  margin: 0;
}

/* The collection's two actions sit side by side, like the victory row: on a
   667px-tall phone two stacked buttons are the difference between the set
   fitting and the last action hanging below the fold. */
#badges-screen .screen-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  width: 100%;
  max-width: 24rem;
  margin-inline: auto;
}

#badges-screen .screen-actions .btn-primary,
#badges-screen .screen-actions .btn-secondary {
  width: 100%;
  min-width: 0;
  padding-inline: 0.5rem;
  font-size: 0.9rem;
}

/* The shelf sits on the victory screen above the action buttons, so it is
 * deliberately smaller than the collection: three badges in a row leave the
 * buttons on the first screenful. */
.badge-shelf-list .badge-open {
  padding: 0.5rem 0.4rem;
  gap: 0.25rem;
}

.badge-shelf-list .badge-medallion {
  width: clamp(48px, 14vw, 64px);
}

.badge-shelf-list .badge-name {
  font-size: 0.8rem;
}

.badge-shelf-list .badge-blurb {
  font-size: 0.7rem;
}

.badge-shelf-list .badge-lock {
  border-width: 1px;
}

/* The shelf pops in; the collection grid does not, because a screen the
 * player navigates to should not animate at load. */
@media (prefers-reduced-motion: no-preference) {
  .badge-shelf-list .badge-tile {
    animation: badge-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }
  .badge-shelf-list .badge-tile:nth-child(2) { animation-delay: 0.12s; }
  .badge-shelf-list .badge-tile:nth-child(3) { animation-delay: 0.24s; }
  .badge-shelf-list .badge-tile:nth-child(4) { animation-delay: 0.36s; }
}

@keyframes badge-pop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ── Badge detail viewer ────────────────────────────────────── */
/* One dialog for the whole set. The face is the same art as the tile, at a
   size where a child can see the whole illustration, with the rule large
   enough to read and arrows to browse without going back to the grid. */
.badge-modal {
  max-width: 390px;
  width: min(92vw, 390px);
  padding: clamp(1rem, 3vw, 1.5rem);
}

.badge-detail {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.badge-detail-close {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--primary);
  background: rgba(var(--primary-rgb), 0.09);
  cursor: pointer;
}

.badge-detail-close svg {
  width: 22px;
  height: 22px;
}

@media (hover: hover) and (pointer: fine) {
  .badge-detail-close:hover {
    background: rgba(var(--primary-rgb), 0.16);
  }
}

.badge-detail-medallion {
  position: relative;
  width: clamp(148px, 54vw, 210px);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 32%, #ffffff 0%, var(--surface-container-low) 72%);
  box-shadow:
    0 14px 30px rgba(42, 47, 50, 0.18),
    0 0 0 5px rgba(255, 255, 255, 0.42);
}

.badge-detail-medallion::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -14px 26px rgba(30, 58, 49, 0.1);
}

.badge-detail-face {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.badge-detail-medallion.is-locked .badge-detail-face {
  filter: grayscale(1) contrast(0.92);
  opacity: 0.4;
}

.badge-detail-lock {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--gold-ink);
  background: rgba(243, 247, 251, 0.52);
}

.badge-detail-lock[hidden] {
  display: none;
}

.badge-detail-lock svg {
  width: 30%;
  height: 30%;
  filter: drop-shadow(0 2px 3px rgba(42, 47, 50, 0.25));
}

.badge-detail-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.9rem 0 0;
  padding: 0.24rem 0.8rem;
  border-radius: var(--radius-full);
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.badge-detail-status::before {
  content: '';
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
}

.badge-detail-status[data-state="earned"] {
  color: var(--gold-ink);
  background: linear-gradient(180deg, var(--gold-soft), #f2bb4e);
  border: 1px solid rgba(120, 80, 20, 0.35);
}

.badge-detail-status[data-state="locked"] {
  color: var(--on-surface-variant);
  background: var(--surface-container-low);
  border: 1px solid rgba(var(--primary-rgb), 0.18);
}

#badge-modal-title {
  margin: 0.5rem 0 0.25rem;
  font-size: clamp(1.35rem, 4.5vw, 1.65rem);
  color: var(--primary);
}

.badge-detail-blurb {
  margin: 0;
  max-width: 26ch;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--on-surface);
}

.badge-detail-hint {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--on-surface-variant);
}

.badge-detail-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  width: 100%;
  margin-top: 1rem;
}

.badge-nav-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(30, 58, 49, 0.28);
  color: var(--primary);
  background: var(--surface-container-lowest);
  box-shadow: 0 2px 0 rgba(30, 58, 49, 0.14);
  cursor: pointer;
}

.badge-nav-btn svg {
  width: 24px;
  height: 24px;
}

@media (hover: hover) and (pointer: fine) {
  .badge-nav-btn:hover {
    background: var(--primary-container);
  }
}

.badge-nav-btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

.badge-detail-position {
  min-width: 4.5rem;
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--on-surface-variant);
}

.badge-modal .modal-actions {
  width: 100%;
  margin-top: 1rem;
}

.badge-modal .modal-actions .btn-primary {
  min-width: 8rem;
}

@media (max-height: 700px) {
  .badge-detail-medallion { width: clamp(124px, 36vh, 170px); }
  .badge-detail-status { margin-top: 0.6rem; }
  #badge-modal-title { margin-top: 0.35rem; }
  .badge-detail-nav { margin-top: 0.7rem; }
  .badge-modal .modal-actions { margin-top: 0.7rem; }

  /* On a 667px-tall phone the collection needs the last few pixels back so
     the action row stays on screen; the badge labels keep the tiles clear. */
  #badges-screen .badge-hint { display: none; }
  #badges-screen .badges-list { gap: 0.45rem; }
  #badges-screen .badge-open { padding: 0.45rem 0.4rem; gap: 0.25rem; }
  #badges-screen .badge-name { font-size: 0.92rem; }
}

/* Landscape phones: the whole badge, its rule and its controls have to fit
   inside a 375px-tall viewport, so the hint gives way and the medallion uses
   the height that is left. The dialog can still scroll if a longer rule wraps
   to three lines. */
@media (max-height: 520px) {
  .badge-detail-medallion { width: clamp(96px, 28vh, 120px); }
  .badge-detail-status { margin-top: 0.4rem; padding: 0.18rem 0.65rem; font-size: 0.72rem; }
  #badge-modal-title { margin: 0.3rem 0 0.15rem; font-size: 1.2rem; }
  .badge-detail-blurb { font-size: 0.85rem; line-height: 1.35; }
  .badge-detail-hint { display: none; }
  .badge-detail-nav { margin-top: 0.55rem; gap: 0.7rem; }
  .badge-modal .modal-actions { margin-top: 0.55rem; }
  .badge-modal .modal-actions .btn-primary { padding: 0.45rem 0.8rem; }
}

/* ─── Landscape welcome layout ───────────────────────────────── */
/* In landscape the welcome stack is far taller than the viewport, so the
   mascot and the actions sit in two columns instead of one long column. */
@media (orientation: landscape) and (max-height: 820px) {
  .welcome-content {
    display: grid;
    grid-template-columns: minmax(150px, 260px) 1fr;
    gap: 0.75rem;
    align-items: center;
  }
  .hero-brand { grid-column: 1 / -1; margin-bottom: 0.4rem; }
  .mascot-area, .hero-tagline { grid-column: 1; margin-bottom: 0; }
  .btn-primary.btn-large,
  .btn-secondary.btn-badges,
  .world-chip { grid-column: 2; }
  /* The note is a direct child of the welcome grid (it moved out of the world
     card), so it has to opt into the second column too. Left on auto it lands
     in column 1, under the mascot, separated from the picker it explains.
     Match the world card's width so the two read as one picker. */
  .pack-season-note { grid-column: 2; width: min(100%, 23rem); }
  .mascot-image-wrapper { width: clamp(80px, 14vh, 180px); height: clamp(80px, 14vh, 180px); }
  .world-chip { margin-top: 0; }
  .difficulty-buttons { margin-top: 0.5rem; }
}

/* The footer is three stacked rows, which is a third of a landscape phone.
   Laying Support and the links side by side frees enough height for the home
   controls to start on screen instead of being scrolled under the footer. */
@media (orientation: landscape) and (max-height: 500px) {
  .game-footer { padding: 0.35rem 1rem; }
  .footer-content {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  .footer-top { flex: 0 0 auto; }
  .footer-links { justify-content: center; gap: 0.5rem; }
  .footer-copyright { display: none; }
  .btn-support {
    --btn-depth: 2px;
    padding: 0.4rem 0.9rem;
    font-size: 0.8rem;
  }
}

/* ─── Scenery and contrast ───────────────────────────────────────
   High contrast and forced-colors users asked for maximum separation, and a
   generated picture is the opposite of that: its local brightness does the
   work the surface ramp used to do. So the artwork and the wash come off, the
   panels go back to solid, and the OS palette takes over.

   Placed last on purpose. A media query contributes no specificity, so a
   `.game-footer` override up in the scenery section would lose to the
   plain `.game-footer` rule further down the file. */
@media (prefers-contrast: more), (forced-colors: active) {
  body { background: var(--surface); }
  body::before,
  body::after { display: none; }

  .card-grid,
  .victory-content,
  .preview-board,
  .settings-modal,
  .install-prompt,
  .game-footer,
  .stat-card,
  .badge-tile,
  .badge-tile.locked,
  .badge-shelf,
  .pack-chip,
  .hero-tagline,
  .score-row,
  .difficulty-tabs,
  .orientation-tabs,
  .install-steps {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: var(--surface-container-lowest);
  }

  /* Only the decorative glass edge comes off, and only from the elements that
     were given one — this list is exactly the one in the scenery section.
     `.pack-chip` and `.install-steps` are deliberately absent: the
     forced-colors block further up gives them real borders so a control keeps
     a boundary once the OS has replaced the background colours, and a blanket
     `border: none` across the whole list silently erased them again. */
  .card-grid,
  .victory-content,
  .settings-modal,
  .install-prompt,
  .game-footer {
    border: none;
  }

  @media (hover: hover) and (pointer: fine) {
    .score-row:hover,
    .pack-chip:hover { background: var(--surface-container-high); }
  }

  /* Re-stated, not newly invented: the chips carry these boundaries in normal
     mode too. They are repeated here because every panel in this block falls
     back to --surface-container-lowest, and the chip box must not change size
     between contrast modes — 2px unselected, 3px and primary once chosen. */
  .pack-chip { border: 2px solid var(--on-surface-variant); }
  .pack-chip[aria-checked="true"] { border-color: var(--primary); }

  /* The normal-mode world chip is the wrapper, with the card and play bar as
     two borderless faces. In raised-contrast/forced-colours the card gets its
     own boundary back so the world option remains a visible control rather
     than a tinted region inside the ticket. */
  .world-chip .pack-chip { border: 2px solid var(--on-surface-variant); }
  .world-chip .pack-chip[aria-checked="true"] { border: 2px solid var(--primary); }

  /* The chip base rule is declared after the early prefers-contrast block, so
     its texture and lip would otherwise win the cascade. Re-state them here,
     after every component. */
  .pack-chip,
  .pack-chip[aria-checked="true"] {
    background-image: none;
    box-shadow: none;
  }

  /* The gold keyline inside the frosted plate is decorative; high-contrast
     users get the flat surface and a real border instead. The world picker
     has no plate any more, so only the difficulty step is reset here. */

  /* Same collapse for badges: the tiles, the victory-screen shelf and the
     badges-screen panel all land on --surface-container-lowest, so each tile
     needs an edge of its own to read as a separate badge. */
  .badge-tile { border: 2px solid var(--on-surface-variant); }

  /* The viewer's icon-only controls keep a real edge once the generated
     surfaces are switched off. */
  .badge-detail-close,
  .badge-nav-btn {
    border: 2px solid var(--on-surface-variant);
    background: var(--surface-container-lowest);
  }
  .badge-detail-status { border: 2px solid var(--on-surface-variant); }
}

/* ─── 320px-wide phones ──────────────────────────────────────────
   The arrow gutter is a fixed 4rem on each side of the world card, and the
   56px thumbnail plus its 12px gap leave the label column only about 54px at
   320px. That clipped the world name itself once the eyebrow was hidden, so
   the decorative thumbnail and the gap give the name the room instead. The
   gutters do not move: the arrows still sit over empty padding. */
@media (max-width: 339px) {
  .pack-chip { gap: 0.5rem; }
  .pack-chip-thumb { width: 48px; height: 48px; }
  .pack-chip-name { font-size: 0.875rem; }
}

/* ─── Reduced transparency ───────────────────────────────────────
   A child who asks for less transparency keeps the meadow: the artwork and
   Monty stay, only the glass goes. Panel tokens turn opaque and the frosted
   surfaces lose their blur. Placed last so it wins the cascade over the
   component rules above, like the contrast block. */
@media (prefers-reduced-transparency: reduce) {
  body {
    --panel: var(--surface-container-lowest);
    --panel-soft: var(--surface-container-lowest);
    --panel-strong: var(--surface-container-lowest);
  }

  /* The frosted-glass list from the scenery section, plus the two menu
     panels and the modal scrim that carry their own blur. */
  .victory-content,
  .settings-modal,
  .install-prompt,
  .game-footer,
  .hero-tagline,
  .settings-modal::backdrop {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}


/* Monty's Playhouse — rooms, hotspots and activities.
   Concatenated INTO css/style.css by scripts/build-css.py (never loaded
   directly), after the kept meadow base, which owns the tokens, the button
   family, the glass system, badges, modals, banners and accessibility modes.
   Anything that re-tints or re-states a shared control is defined there,
   not duplicated here. */

/* ─── Stage ────────────────────────────────────────────────────
   Every play surface is one square stage, sized by vmin so a phone gets a
   big square and a desktop gets a framed picture. Hotspots, slots and
   overlays are positioned in stage percentages, so a room plays identically
   at any size — the artwork prompts keep the middle clear and the furniture
   on the edges for exactly this reason. */
.stage-frame {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    min-height: 0;
}

.stage {
    position: relative;
    width: min(96vw, 82vh);
    height: min(96vw, 82vh);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-modal);
    overflow: hidden;
    background: transparent;
}

#room-screen .stage {
    background-image: var(--bg-image);
    background-size: cover;
    background-position: center;
    border: 1px solid var(--glass-edge);
}

/* Inside a room the stage carries the art. The page-level backdrop is the
   same room enlarged, which read as a confusing duplicate behind the frame,
   so the page layers step back to a quiet tint instead. */
body[data-screen="room"]::before,
body[data-screen="room"]::after { display: none; }
html { background-color: var(--surface); }
body[data-screen="room"] { background-color: var(--surface-container-low); }

.stage-hub {
    background-image: url('../assets/rooms/bg-playhouse.webp?v=0c3c67844d');
    background-size: cover;
    background-position: center;
    border: 1px solid var(--glass-edge);
}

.stage-label {
    position: absolute;
    top: 3%;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(0.9rem, 2.6vw, 1.15rem);
    color: var(--ink);
    background: var(--panel-strong);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-edge);
    border-radius: var(--radius-full);
    padding: 0.35rem 1.1rem;
    pointer-events: none;
}

/* Only the matching room's furniture is visible. */
.room-furniture { position: absolute; inset: 0; display: none; }
body[data-screen="room"][data-room="living-room"] .room-furniture[data-room="living-room"],
body[data-screen="room"][data-room="kitchen"] .room-furniture[data-room="kitchen"],
body[data-screen="room"][data-room="bedroom"] .room-furniture[data-room="bedroom"],
body[data-screen="room"][data-room="backyard"] .room-furniture[data-room="backyard"] { display: block; }

/* ─── Hero wordmark ────────────────────────────────────────────
   The banner artwork carries the painted plaque, ribbons and flowers;
   the words are type, not outlines, so they stay crisp everywhere and
   live in the DOM for screen readers (the SVG itself is aria-hidden). */
.hero-brand {
    position: relative;
    width: min(92vw, 620px);
    margin: 0 auto 0.6rem;
}
.hero-banner { width: 100%; height: auto; display: block; }
.hero-heading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    pointer-events: none;
    padding-top: 0.4em;
}
.hero-heading-main {
    font-family: var(--font-headline);
    font-weight: 600;
    font-size: clamp(1rem, 4.2vw, 1.7rem);
    /* Painted gold on the pale banner sits at 2.2:1 — under the bar even for
       large text. A darker honey gold keeps the painted-title look while
       clearing it; the light shadow only lifts the glyph, never the sample. */
    color: #7a4f16;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
    line-height: 1.1;
}
.hero-heading-sub {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(1.7rem, 7.5vw, 3rem);
    letter-spacing: 0.02em;
    color: #285646;
    text-shadow:
        0 2px 0 rgba(255, 255, 255, 0.55),
        0 0 10px rgba(246, 196, 83, 0.35);
    line-height: 1.05;
}

.home-shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 0.75rem;
}
.home-shortcuts .btn-secondary { min-height: 56px; }

/* ─── Room chrome ────────────────────────────────────────────── */
.room-chrome {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem 0;
}
.room-title-plate {
    flex: 1;
    text-align: center;
}
.room-title-plate h2 {
    display: inline-block;
    font-family: var(--font-headline);
    font-size: clamp(1.05rem, 3.4vw, 1.4rem);
    color: var(--ink);
    background: var(--panel);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-edge);
    border-radius: var(--radius-full);
    padding: 0.4rem 1.4rem;
}
.hunt-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--gold-ink);
    background: linear-gradient(180deg, #ffe49a, #f6c453);
    border: 2px solid var(--ink);
    border-radius: var(--radius-full);
    padding: 0.35rem 0.9rem;
    min-height: 44px;
    box-shadow: var(--shadow-card);
}
.hunt-chip svg { width: 1.1em; height: 1.1em; }
.hunt-chip[hidden] { display: none; }

/* ─── Hub doors ──────────────────────────────────────────────── */
.door-hint {
    position: absolute;
    top: 30%;
    width: 17%;
    height: 34%;
    transform: translateX(-50%);
    background: transparent;
    border: 3px dashed rgba(255, 255, 255, 0.0);
    border-radius: 1.25rem 1.25rem 0.5rem 0.5rem;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) and (pointer: fine) {
    .door-hint:hover {
        border-color: rgba(246, 196, 83, 0.9);
        background: rgba(255, 255, 255, 0.12);
    }
}
.door-hint:focus-visible {
    border-color: var(--gold);
    background: rgba(255, 255, 255, 0.16);
    outline: 3px solid var(--on-primary);
    outline-offset: 3px;
}
.door-hint span {
    position: absolute;
    bottom: -14%;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    /* shrink-to-fit is capped at the 17% door column, so the pill border
       wrapped the middle of the label and let the ends float over the
       lawn. max-content paints the whole pill; the sizes are set so the
       widest neighbours ("Living Room" + "Kitchen") still clear each
       other's border. */
    width: max-content;
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(0.6rem, 1.8vw, 0.85rem);
    color: var(--ink);
    background: var(--panel-strong);
    border: 2px solid var(--ink);
    border-radius: var(--radius-full);
    padding: 0.25rem 0.55rem;
    box-shadow: var(--shadow-card);
}
.hub-actions {
    position: absolute;
    left: 50%;
    bottom: 5%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: max-content;
}
/* Once hunting has started, the banner (with its own "Keep hunting!" CTA)
   replaces the big hunt button: keeping both stacked the actions over the
   door labels on small stages. */
.hub-actions:has(.hunt-banner:not([hidden])) #hunt-btn { display: none; }

.hunt-banner {
    display: inline-flex;
    gap: 0.6rem;
    align-items: center;
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--gold-ink);
    background: linear-gradient(180deg, #ffe49a, #f6c453);
    border: 2px solid var(--ink);
    border-radius: var(--radius-full);
    padding: 0.4rem 1rem;
    cursor: pointer;
    box-shadow: var(--shadow-card);
}
.hunt-banner[hidden] { display: none; }
.hunt-banner-cta { color: var(--ink); text-decoration: underline; }

/* ─── Hotspots ─────────────────────────────────────────────────
   The hit area is invisible; the bubble is the invitation. Children find
   things by tapping around, so the bubble is always faintly visible —
   "explore" should reward exploring — and it brightens on hover, focus and
   while the Monty nudge is up. */
.hotspot,
.hunt-spot,
.activity-button {
    position: absolute;
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}
/* The cue is a small twinkle in the middle of the hit area, not an outline
   around it: a soft golden glow (::after) with a four-point sparkle on top
   (::before). Tap targets can sit close together without their cues
   overlapping, and the painted object stays in view. */
.hotspot::before,
.hotspot::after,
.hunt-spot::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    translate: -50% -50%;
    width: 2.2rem;
    height: 2.2rem;
    pointer-events: none;
}
.hotspot::after,
.hunt-spot::after {
    border-radius: 50%;
    background: radial-gradient(circle,
        rgba(255, 246, 201, 0.95) 0%,
        rgba(255, 215, 120, 0.6) 32%,
        rgba(246, 196, 83, 0.22) 58%,
        rgba(246, 196, 83, 0) 72%);
    animation: cue-glow 3.2s ease-in-out infinite;
    transition: opacity 0.25s ease, scale 0.25s ease;
}
.hotspot::before {
    z-index: 1;
    width: 1.1rem;
    height: 1.1rem;
    background: #fffdf0;
    clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
    animation: cue-sparkle 3.2s ease-in-out infinite;
    transition: opacity 0.25s ease;
}
.hotspot:nth-child(3n+2)::before, .hotspot:nth-child(3n+2)::after { animation-delay: -1.1s; }
.hotspot:nth-child(3n)::before, .hotspot:nth-child(3n)::after { animation-delay: -2.2s; }
@keyframes cue-glow {
    0%, 100% { opacity: 0.55; scale: 0.82; }
    50% { opacity: 1; scale: 1.12; }
}
@keyframes cue-sparkle {
    0%, 100% { opacity: 0.5; scale: 0.7; rotate: 0deg; }
    50% { opacity: 1; scale: 1.1; rotate: 20deg; }
}
/* Steady-opacity twins for the quiet hotspots, whose reveal state is "fully
   shown" rather than breathing in and out. */
@keyframes cue-bob {
    0%, 100% { scale: 0.88; }
    50% { scale: 1.15; }
}
@keyframes cue-spin {
    0%, 100% { scale: 0.8; rotate: 0deg; }
    50% { scale: 1.1; rotate: 20deg; }
}
@media (hover: hover) and (pointer: fine) {
    .hotspot:hover::after,
    .hunt-spot:hover::after { scale: 1.3; opacity: 1; }
}
.hotspot:focus-visible,
.hunt-spot:focus-visible,
.activity-button:focus-visible {
    outline: 3px solid var(--on-primary);
    outline-offset: 2px;
}
.hotspot:focus-visible::after,
.hunt-spot:focus-visible::after { scale: 1.3; opacity: 1; }

.hotspot:active::after { scale: 0.9; }

/* Scenery pop-outs: something comes out of what was tapped (popScenery in
   playhouse.js). --dir is 1 or -1 so they head into the room. Percentages in
   translate are of the sprite's own size. */
.scenery-pop {
    position: absolute;
    z-index: 7;
    height: auto;
    aspect-ratio: 1;
    object-fit: contain;
    pointer-events: none;
    transform: translate(-50%, -50%);
    animation-fill-mode: both;
    filter: drop-shadow(0 3px 3px rgba(30, 58, 49, 0.2));
}
.pop-fly { animation: pop-fly 2.4s ease-in-out both; }
@keyframes pop-fly {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(calc(0.6 * var(--dir)), 0.6); }
    12% { opacity: 1; transform: translate(calc(-50% + var(--dir) * 60%), -80%) scale(var(--dir), 1); }
    30% { transform: translate(calc(-50% + var(--dir) * 160%), -130%) scale(var(--dir), 0.8); }
    50% { transform: translate(calc(-50% + var(--dir) * 280%), -150%) scale(var(--dir), 1); }
    70% { transform: translate(calc(-50% + var(--dir) * 400%), -190%) scale(var(--dir), 0.8); }
    88% { opacity: 1; }
    100% { opacity: 0; transform: translate(calc(-50% + var(--dir) * 560%), -240%) scale(var(--dir), 1); }
}
.pop-fall { animation: pop-fall 2.2s ease-in both; }
@keyframes pop-fall {
    0% { opacity: 0; transform: translate(-50%, -50%) rotate(0deg); }
    10% { opacity: 1; }
    35% { transform: translate(calc(-50% + var(--dir) * 70%), 60%) rotate(calc(var(--dir) * 40deg)); }
    65% { transform: translate(calc(-50% - var(--dir) * 30%), 190%) rotate(calc(var(--dir) * -20deg)); }
    85% { opacity: 1; }
    100% { opacity: 0; transform: translate(calc(-50% + var(--dir) * 60%), 320%) rotate(calc(var(--dir) * 30deg)); }
}
.pop-rise { animation: pop-rise 1.8s ease-out both; }
@keyframes pop-rise {
    0% { opacity: 0; transform: translate(-50%, -30%) scale(0.4); }
    20% { opacity: 1; transform: translate(-50%, -80%) scale(1.1); }
    35% { transform: translate(-50%, -100%) scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -260%) scale(0.9); }
}
.pop-arc { animation: pop-arc 1.6s cubic-bezier(0.3, 0.7, 0.5, 1) both; }
@keyframes pop-arc {
    0% { opacity: 0; transform: translate(-50%, -50%) rotate(0deg) scale(0.5); }
    15% { opacity: 1; }
    45% { transform: translate(calc(-50% + var(--dir) * 120%), -240%) rotate(calc(var(--dir) * 200deg)) scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translate(calc(-50% + var(--dir) * 220%), -40%) rotate(calc(var(--dir) * 360deg)) scale(1); }
}
.pop-hop { animation: pop-hop 1.9s ease-in-out both; }
@keyframes pop-hop {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(calc(0.6 * var(--dir)), 0.6); }
    10% { opacity: 1; transform: translate(-50%, -50%) scale(var(--dir), 0.85); }
    30% { transform: translate(calc(-50% + var(--dir) * 70%), -170%) scale(var(--dir), 1.05); }
    45% { transform: translate(calc(-50% + var(--dir) * 140%), -50%) scale(var(--dir), 0.85); }
    65% { transform: translate(calc(-50% + var(--dir) * 210%), -170%) scale(var(--dir), 1.05); }
    85% { opacity: 1; transform: translate(calc(-50% + var(--dir) * 280%), -50%) scale(var(--dir), 0.9); }
    100% { opacity: 0; transform: translate(calc(-50% + var(--dir) * 300%), -50%) scale(var(--dir), 1); }
}
.pop-peek { animation: pop-peek 2.2s ease-in-out both; }
@keyframes pop-peek {
    0% { opacity: 0; transform: translate(-50%, 0%) scale(0.8); }
    18% { opacity: 1; transform: translate(-50%, -70%) scale(1); }
    30%, 70% { transform: translate(-50%, -60%) rotate(calc(var(--dir) * 6deg)); }
    50% { transform: translate(-50%, -62%) rotate(calc(var(--dir) * -6deg)); }
    85% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, 0%) scale(0.8); }
}
.pop-flutter { animation: pop-flutter 2.6s ease-in-out both; }
@keyframes pop-flutter {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5, 0.5); }
    10% { opacity: 1; transform: translate(-50%, -90%) scale(1, 1); }
    25% { transform: translate(calc(-50% + var(--dir) * 70%), -170%) scale(0.5, 1); }
    40% { transform: translate(calc(-50% + var(--dir) * 20%), -250%) scale(1, 1); }
    55% { transform: translate(calc(-50% + var(--dir) * 120%), -330%) scale(0.5, 1); }
    70% { transform: translate(calc(-50% + var(--dir) * 70%), -420%) scale(1, 1); }
    88% { opacity: 1; }
    100% { opacity: 0; transform: translate(calc(-50% + var(--dir) * 170%), -520%) scale(0.6, 1); }
}
.pop-fade { animation: pop-fade 2.4s ease-in-out both; }
@keyframes pop-fade {
    0% { opacity: 0; transform: translate(-50%, -20%) scale(0.6); }
    25%, 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -60%) scale(1.04); }
}

/* Scenery hotspots: every painted thing answers a tap, but only the toys and
   furniture wear the standing bubble, or the room would be all circles. The
   bubble shows on hover, focus and for a moment after a tap. */
.hotspot.quiet::before,
.hotspot.quiet::after { opacity: 0; animation: none; }
.hotspot.quiet:focus-visible::before,
.hotspot.quiet:focus-visible::after,
.hotspot.quiet.tapped::before,
.hotspot.quiet.tapped::after,
.room-reveal .hotspot.quiet::before,
.room-reveal .hotspot.quiet::after { opacity: 1; animation: cue-bob 3.2s ease-in-out infinite; }
.hotspot.quiet:focus-visible::before,
.hotspot.quiet.tapped::before,
.room-reveal .hotspot.quiet::before { animation-name: cue-spin; }
@media (hover: hover) and (pointer: fine) {
    .hotspot.quiet:hover::before,
    .hotspot.quiet:hover::after { opacity: 1; }
}

/* Lamp-and-friends toggles. */
.hotspot[aria-pressed="true"]::after {
    background: radial-gradient(circle,
        rgba(255, 246, 201, 1) 0%,
        rgba(246, 196, 83, 0.8) 38%,
        rgba(246, 196, 83, 0.3) 62%,
        rgba(246, 196, 83, 0) 74%);
}

/* The nudge glow. */
.hint-glow::after,
button.hint-glow {
    animation: hint-pulse 1.6s ease-in-out infinite;
}
.hint-glow::after { scale: 1.3; opacity: 1; }
button.hint-glow:not(.hotspot):not(.hunt-spot) {
    box-shadow: 0 0 0 4px rgba(246, 196, 83, 0.55), var(--shadow-card);
}
@keyframes hint-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.07); }
}

/* ─── Hunt spots ─────────────────────────────────────────────── */
.hunt-spot::before { content: none; }
.hunt-spot.searched { cursor: default; }
.hunt-spot.searched::after,
.hunt-spot.found::after {
    left: 8%;
    top: 8%;
    translate: none;
    width: 84%;
    height: 84%;
    animation: none;
    opacity: 1;
}
.hunt-spot.searched::after {
    border: 3px dotted rgba(90, 70, 50, 0.4);
    background: rgba(120, 95, 70, 0.18);
    scale: 0.8;
}
.hunt-spot.searched::before { opacity: 0; }
.hunt-spot.found { cursor: pointer; }
.hunt-spot.found::after {
    border: 3px solid var(--gold);
    background: rgba(255, 244, 214, 0.35);
}
.hunt-spot.found::before { opacity: 0; }
.found-toy-img {
    position: absolute;
    inset: 6%;
    width: 88%;
    height: 88%;
    object-fit: contain;
    border-radius: 50%;
    background: var(--cream);
    border: 2px solid var(--ink);
    box-shadow: var(--shadow-card);
    pointer-events: none;
}
.found-bounce .found-toy-img { animation: toy-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes toy-pop {
    0% { transform: scale(0.2) rotate(-14deg); }
    70% { transform: scale(1.15) rotate(4deg); }
    100% { transform: scale(1) rotate(0); }
}

/* ─── Activity buttons ───────────────────────────────────────── */
.activity-button::before {
    content: attr(aria-label);
    position: absolute;
    left: 50%;
    bottom: -16%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(0.72rem, 2vw, 0.95rem);
    color: var(--ink);
    background: linear-gradient(180deg, #ffe49a, #f6c453);
    border: 2px solid var(--ink);
    border-radius: var(--radius-full);
    padding: 0.3rem 0.9rem;
    box-shadow: var(--shadow-card);
    opacity: 0.92;
}
/* No outline: a soft golden halo breathes behind the painted object, and the
   label pill below it says what it does. */
.activity-button {
    border: 0;
    border-radius: 1.4rem;
}
.activity-button::after {
    content: '';
    position: absolute;
    inset: -8%;
    border-radius: 50%;
    background: radial-gradient(ellipse at 50% 50%,
        rgba(255, 238, 166, 0.5) 0%,
        rgba(255, 215, 120, 0.22) 45%,
        rgba(246, 196, 83, 0) 72%);
    pointer-events: none;
    animation: activity-halo 3.4s ease-in-out infinite;
}
@keyframes activity-halo {
    0%, 100% { opacity: 0.45; scale: 0.94; }
    50% { opacity: 1; scale: 1.06; }
}
@media (hover: hover) and (pointer: fine) {
    .activity-button:hover::after { opacity: 1; scale: 1.1; animation: none; }
}
/* Reduced motion keeps the glow, just still. */
@media (prefers-reduced-motion: reduce) {
    .hotspot::before, .hotspot::after, .hunt-spot::after, .activity-button::after,
    .room-reveal .hotspot.quiet::before, .room-reveal .hotspot.quiet::after { animation: none; }
}
.activity-button:active { transform: scale(0.97); }

/* ─── Activity overlays ──────────────────────────────────────── */
.activity-overlay {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    flex-direction: column;
    padding: 0.9rem 0.9rem 0.7rem;
    background: radial-gradient(120% 90% at 50% 30%, rgba(30, 58, 49, 0.25), rgba(30, 58, 49, 0.45));
    opacity: 1;
    transition: opacity 0.25s ease;
}
.activity-overlay[hidden] { display: none; }
.activity-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.4rem;
}
.activity-title {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(1rem, 3.4vw, 1.35rem);
    color: var(--ink);
    background: var(--panel-strong);
    border: 1px solid var(--glass-edge);
    border-radius: var(--radius-full);
    padding: 0.35rem 1.1rem;
}
.activity-close { min-height: 44px; }

/* Picnic blanket: painted in CSS (a gingham plate) so the drop zone can
   scale with the stage and stay readable on every backdrop. */
.picnic-scene { position: relative; flex: 1; display: flex; align-items: flex-end; justify-content: center; }
.picnic-blanket {
    position: relative;
    width: min(74%, 340px);
    aspect-ratio: 1.35;
    border-radius: 18px;
    transform: rotate(-2deg);
    background:
        repeating-linear-gradient(45deg, rgba(214, 96, 78, 0.20) 0 14px, transparent 14px 28px),
        repeating-linear-gradient(-45deg, rgba(214, 96, 78, 0.20) 0 14px, transparent 14px 28px),
        var(--cream);
    border: 3px solid var(--ink);
    box-shadow: 0 14px 28px rgba(20, 40, 32, 0.35);
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 4%;
    padding: 7%;
}
.slot {
    border: 3px dashed rgba(30, 58, 49, 0.45);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}
.fort-slot {
    position: absolute;
    width: 17%;
    height: 13%;
    border: 3px dashed rgba(30, 58, 49, 0.45);
    border-radius: 40% 45% 42% 48% / 46% 40% 50% 44%;
    background: rgba(255, 255, 255, 0.45);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
    padding: 0;
    z-index: 2;
}
.slot.slot-ask, .fort-slot.slot-ask {
    border-color: var(--gold-deep);
    background: rgba(246, 196, 83, 0.35);
}
.slot.drop-aim, .fort-slot.drop-aim {
    border-style: solid;
    border-color: var(--gold);
    background: rgba(246, 196, 83, 0.5);
    transform: scale(1.12);
}
.slot.filled, .fort-slot.filled {
    border: 3px solid var(--ink);
    background: var(--cream);
    box-shadow: var(--shadow-card);
    animation: toy-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.slot img, .fort-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
    pointer-events: none;
}

/* Fort frame: an illustrated quilt tent over two chairs. The cushion slots
   sit on the quilt and leave the dark doorway free for Monty to peek out. */
.fort-scene {
    position: relative;
    flex: 1 1 0;
    min-height: 0;
    aspect-ratio: 1;
    align-self: center;
    max-width: 100%;
}
.fort-frame {
    position: absolute;
    inset: 0;
    padding: 0;
    border: 0;
    background: url('../assets/props/fort-frame.webp?v=4946c158d6') center bottom / contain no-repeat;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.fort-frame:disabled { cursor: default; }
.fort-frame:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 4px; }
/* Steps one and two show the bare chairs; the quilt drops over them in step two. */
.fort-stage-chairs .fort-frame, .fort-stage-quilt .fort-frame {
    background-image: url('../assets/props/fort-chairs.webp?v=09dd59863a');
    filter: drop-shadow(0 0 10px rgba(246, 196, 83, 0.8));
}
.fort-stage-lights .fort-frame { filter: drop-shadow(0 0 10px rgba(246, 196, 83, 0.8)); }
.fort-stage-chairs .fort-slot, .fort-stage-quilt .fort-slot { visibility: hidden; pointer-events: none; }
.fort-stage-chairs #fort-tray, .fort-stage-quilt #fort-tray { opacity: 0.35; pointer-events: none; }
.fort-bump { animation: fort-bump 0.4s ease; }
.fort-drop { animation: fort-drop 0.5s cubic-bezier(0.34, 1.3, 0.64, 1); }
@keyframes fort-bump { 0%, 100% { transform: scale(1); } 40% { transform: scale(0.94, 1.03); } }
@keyframes fort-drop { 0% { transform: translateY(-14%); opacity: 0.4; } 100% { transform: translateY(0); opacity: 1; } }
.fort-slot { width: 19%; height: 15%; }
.fort-slot[data-index="0"] { left: 10%; top: 64%; }
.fort-slot[data-index="1"] { right: 10%; top: 64%; }
.fort-slot[data-index="2"] { left: 20%; top: 38%; }
.fort-slot[data-index="3"] { right: 20%; top: 38%; }
/* `translate`, not `transform`: the pop and drop-aim scales would drop it. */
.fort-slot[data-index="4"] { left: 50%; top: 17%; translate: -50% 0; }
.fort-monty {
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 30%;
    transform: translateX(-50%) translateY(30%);
    z-index: 3;
    filter: drop-shadow(0 8px 14px rgba(20, 40, 32, 0.4));
}
.fort-monty.peek { animation: fort-peek 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
@keyframes fort-peek {
    0% { transform: translateX(-50%) translateY(60%) scale(0.7); opacity: 0; }
    100% { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
}
.fort-lights { position: absolute; left: 4%; top: 2%; width: 92%; pointer-events: none; z-index: 3; opacity: 0; transition: opacity 0.8s ease; }
.fort-lit .fort-lights { opacity: 1; }
.star-glow { position: absolute; left: -35%; top: -35%; width: 170%; max-width: none; pointer-events: none; z-index: -1; animation: dry-pop 0.5s ease; }
.fort-lit .fort-frame { filter: drop-shadow(0 0 14px rgba(246, 196, 83, 0.9)); }

/* Picnic Monty sits at the foot of the blanket for the feast. */
.picnic-monty {
    position: absolute;
    right: 6%;
    bottom: 2%;
    width: 26%;
    filter: drop-shadow(0 8px 14px rgba(20, 40, 32, 0.4));
}
.picnic-monty[hidden] { display: none; }
.picnic-monty.munch { animation: munch 1.3s ease-in-out; }
@keyframes munch {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(-4deg) scale(1.05); }
    55% { transform: rotate(3deg) scale(0.98); }
    80% { transform: rotate(-2deg) scale(1.03); }
}

/* Tray + chips */
.tray-row {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    align-items: center;
}
.tray-hint {
    font-size: 0.85rem;
    color: var(--ink);
    background: var(--panel);
    border-radius: var(--radius-full);
    padding: 0.25rem 0.9rem;
    /* On big stages the pill floats over the lower fort slots; it is a
       caption, not a control, so taps must fall through to the cushion
       targets behind it. */
    pointer-events: none;
}
.chip-tray {
    display: grid;
    grid-template-columns: repeat(auto-fit, 72px);
    justify-content: center;
    gap: 0.4rem;
    padding: 0.45rem 0.5rem;
    background: var(--panel);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-edge);
    border-radius: var(--radius-lg);
    max-width: 100%;
}
/* Chips are sized off the stage box (min(96vw,82vh)) so five chips always
   share one row inside the tray — a horizontally scrolling tray reads as
   "no more cushions" to a five-year-old, and hidden options are exactly
   what this tray is made of. Names truncate with ellipsis rather than
   hanging outside their chip. */
.chip {
    flex: 0 1 auto;
    /* Inside the tray grid the cell (72px) sizes the chip; the vw/vh term
       keeps free-floating chips (scene previews) sensible on their own. */
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    background: transparent;
    border: 0;
    padding: 0.15rem;
    cursor: grab;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    border-radius: var(--radius-md);
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.chip:active { cursor: grabbing; }
.chip img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid var(--ink);
    background: var(--cream);
    box-shadow: var(--shadow-card);
    pointer-events: none;
}
.chip-name {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--ink);
    background: var(--panel-strong);
    border-radius: var(--radius-full);
    padding: 0.05rem 0.45rem;
    white-space: nowrap;
    /* The names are the read-aloud handle for pre-readers, so they never
       truncate at food length: the tray cell (72px) is sized to fit the
       longest word, and the pill fills the cell. Phones use 52px cells
       with a tighter pill — see the compact override below. */
    width: 100%;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Wide viewports: the stage is big, but the overlay column still only
   has room for ONE tray row — auto-fit wrapped the picnic to two rows
   and pushed the yum button off the stage. So the tray splits into the
   exact number of chips (like on phones), just roomier, and the names
   stop truncating ("Strawb..."). */
@media (min-width: 900px) {
    .chip-tray { gap: 0.6rem; padding: 0.7rem; }
    #picnic-tray { grid-template-columns: repeat(7, minmax(0, 1fr)); }
    #fort-tray { grid-template-columns: repeat(8, minmax(0, 1fr)); }
    #picnic-tray .chip, #fort-tray .chip { min-width: 0; }
    /* Names sit on one line inside the ~56px inner chip width: 0.6rem
       clears the longest tray label ("Sandwich"; berries show as
       'Berry', fully in the aria-label). */
    .chip { padding: 0.3rem; }
    .chip-name { font-size: 0.6rem; padding: 0.08rem 0.15rem; }
    .tray-hint { font-size: 1rem; max-width: 46ch; }
}

/* Phones: the tray must stay one row high so the blanket keeps its room,
   so cells shrink. The picnic tray has exactly seven foods and must never
   wrap — the stage column is full at that point — so it gets seven even
   tracks at 1fr. The longest food name ("strawberry") still fits the
   glyph box at this size, so phones let it overflow the padding box
   instead of eliding. */
@media (max-width: 480px) {
    .chip-tray { grid-template-columns: repeat(auto-fit, 50px); gap: 0.3rem; }
    .chip-name {
        font-size: 0.55rem;
        padding: 0.05rem 0.25rem;
        overflow: visible;
        text-overflow: clip;
    }
    #picnic-tray {
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 0.15rem;
        padding: 0.3rem;
    }
    #picnic-tray .chip { min-width: 0; }
    #picnic-tray .chip-name { font-size: 0.52rem; padding: 0.04rem 0.15rem; }

    /* Phone portrait: the stage column has to hold the blanket, the hint,
       the whole food tray and the yum button. A width-driven blanket keeps
       its 1.35 aspect and can outgrow the scene, so here the height leads:
       width is recomputed from the same ratio. */
    .picnic-blanket { height: min(130px, calc(min(96vw, 74vh) - 231px)); width: auto; aspect-ratio: 1.35 / 1; }
    .tray-row { gap: 0.25rem; }
    #picnic-done-btn { min-height: 52px; }

    /* Phones: eight cushions will not share one row with labels, and the
       fort needs a real frame to build inside. The tray drops to unlabeled
       one-row chips (the art identifies each cushion; the slot pulse shows
       where it goes), the redundant hint hides, and the scene keeps a floor
       so the fort keeps its shape. Slots stay square and the apex cushion
       stays under the bunting line. */
    #fort-tray { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 0.15rem; padding: 0.3rem; }
    #fort-tray .chip { min-width: 0; }
    #fort-tray .chip-name { display: none; }
    #fort-hint { display: none; }
    #fort-reset-btn { min-height: 44px; }
    .fort-scene { min-height: 180px; }
    .fort-slot { width: 14%; height: auto; aspect-ratio: 1; }
    .fort-slot[data-index="4"] { top: 22%; }
}
.chip.carried { transform: scale(1.12); }
.chip.carried img { outline: 3px solid var(--gold); outline-offset: 2px; }
.chip:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; }
.chip-shake { animation: chip-shake 0.4s ease; }
@keyframes chip-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px) rotate(-3deg); }
    75% { transform: translateX(5px) rotate(3deg); }
}
.chip-ghost {
    position: fixed;
    z-index: 300;
    width: 72px;
    height: 72px;
    transform: translate(-50%, -55%) rotate(-6deg);
    pointer-events: none;
    filter: drop-shadow(0 10px 14px rgba(20, 40, 32, 0.45));
}
.chip-ghost img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; border: 2px solid var(--ink); }

/* ─── Hint bubble, toast, sparkles ───────────────────────────── */
.hint-bubble {
    position: absolute;
    left: 4%;
    bottom: 4%;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 72%;
    background: var(--panel-strong);
    border: 2px solid var(--ink);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 0.4rem;
    padding: 0.4rem 0.8rem 0.4rem 0.4rem;
    box-shadow: var(--shadow-card);
    animation: bubble-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.hint-bubble[hidden] { display: none; }
.hint-monty { width: 46px; height: 46px; object-fit: cover; border-radius: 50%; border: 2px solid var(--ink); }
.hint-bubble p { font-size: 0.86rem; font-weight: 600; color: var(--ink); }
@keyframes bubble-in {
    0% { transform: translateY(12px) scale(0.85); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* While an activity overlay is open, its title line owns the top of the
   stage — the toast drops below it instead of covering the buttons. */
body[data-activity] .toast { top: calc(4% + 2.7rem); }

/* The room's ambient hint bubble points at room affordances. While an
   overlay is open it only shimmers behind the tray and the done button,
   so it steps aside — its job is done once the activity is on screen.
   Same for the activity buttons themselves: seen through the frosted
   overlay their gold labels ghosted behind the done button like a
   broken double CTA. */
body[data-activity] .hint-bubble { display: none; }
body[data-activity] .activity-button { visibility: hidden; }

.toast {
    position: absolute;
    top: 4%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 6;
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(0.85rem, 2.8vw, 1.05rem);
    color: var(--ink);
    background: var(--panel-strong);
    border: 2px solid var(--ink);
    border-radius: var(--radius-full);
    padding: 0.45rem 1.2rem;
    box-shadow: var(--shadow-card);
    animation: bubble-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toast[hidden] { display: none; }
.toast-find { background: linear-gradient(180deg, #ffe49a, #f6c453); }

.sparkle-fx {
    position: absolute;
    width: 16px;
    height: 16px;
    margin: -8px;
    background: url('../assets/ui/sparkle.png?v=6249bf3235') center / contain no-repeat;
    pointer-events: none;
    z-index: 5;
    animation: sparkle 0.85s ease-out forwards;
}
@keyframes sparkle {
    0% { transform: scale(0.3) rotate(0deg); opacity: 0; }
    35% { transform: scale(1.15) rotate(60deg); opacity: 1; }
    100% { transform: scale(0.7) rotate(140deg) translateY(-14px); opacity: 0; }
}

/* ─── Furniture effect animations ────────────────────────────── */
.fx-bounce { animation: fx-bounce 0.9s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes fx-bounce {
    0%, 100% { transform: translateY(0) scale(1, 1); }
    30% { transform: translateY(-7%) scale(1.04, 0.92); }
    55% { transform: translateY(2%) scale(0.97, 1.05); }
    75% { transform: translateY(-3%) scale(1.02, 0.97); }
}
.fx-topple { animation: fx-topple 1s ease-in forwards; }
@keyframes fx-topple {
    0% { transform: rotate(0); }
    20% { transform: rotate(-6deg); }
    100% { transform: rotate(38deg) translate(6%, 4%); }
}
.fx-wobble { animation: fx-wobble 0.8s ease; }
@keyframes fx-wobble {
    0%, 100% { transform: rotate(0); }
    20% { transform: rotate(6deg); }
    45% { transform: rotate(-5deg); }
    70% { transform: rotate(3deg); }
}
.fx-tuck { animation: fx-tuck 1.1s ease; }
@keyframes fx-tuck {
    0%, 100% { transform: translateY(0); }
    40% { transform: translateY(-4%); }
}
.fx-swing { animation: fx-swing 1.2s ease; transform-origin: 50% 0%; }
@keyframes fx-swing {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(9deg); }
    60% { transform: rotate(-7deg); }
    85% { transform: rotate(3deg); }
}
.fx-dig { animation: fx-dig 0.7s ease; }
@keyframes fx-dig {
    0%, 100% { transform: translateY(0); }
    30% { transform: translateY(8%) scaleY(0.9); }
    60% { transform: translateY(-6%) scaleY(1.05); }
}
.fx-roll { animation: fx-roll 1s ease; }
@keyframes fx-roll {
    0% { transform: translateX(0) rotate(0); }
    100% { transform: translateX(38%) rotate(14deg); }
}

/* Lamp and nightlight glows (the toggle classes live on the stage). */
.lit .hotspot[aria-pressed="true"]::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 120%;
    width: 240%;
    height: 240%;
    transform: translate(-50%, -50%);
    translate: none;
    clip-path: none;
    animation: none;
    background: radial-gradient(circle, rgba(255, 231, 148, 0.5) 0 18%, rgba(255, 231, 148, 0.16) 40%, transparent 70%);
    pointer-events: none;
}
#room-stage.lit { box-shadow: inset 0 0 0 2px var(--glass-edge); }
/* A lit lamp washes the room from a layer over the furniture, below the
   characters. A filter on the furniture layer was redrawn on every frame
   anything inside it moved (1.5-6x the cost of an unlit room, measured). */
.room-furniture::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.35s ease;
}
.room-furniture[data-room="living-room"]::after {
    background: radial-gradient(circle at 90% 26%, rgba(255, 231, 148, 0.3), rgba(255, 231, 148, 0.1) 35%, rgba(255, 231, 148, 0) 70%);
}
.room-furniture[data-room="bedroom"]::after {
    background: radial-gradient(circle at 30% 26%, rgba(203, 184, 240, 0.22), rgba(26, 30, 74, 0.26) 30%, rgba(26, 30, 74, 0.3) 80%);
}
#room-stage.lit .room-furniture::after,
#room-stage.nightlight .room-furniture::after { opacity: 1; }
.nightlight .hotspot[aria-pressed="true"]::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 320%;
    height: 320%;
    transform: translate(-50%, -50%);
    translate: none;
    clip-path: none;
    animation: none;
    background: radial-gradient(circle, rgba(203, 184, 240, 0.55) 0 20%, transparent 60%);
    pointer-events: none;
}
.fridge-open .hotspot[aria-pressed="true"]::after {
    background: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0%, rgba(183, 231, 215, 0.7) 45%, rgba(183, 231, 215, 0) 72%);
}

/* ─── Toy box grid ───────────────────────────────────────────── */
.collection-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    max-width: 860px;
    width: 100%;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    min-height: 0;
}
.collection-title {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-headline);
    font-size: clamp(1.15rem, 4vw, 1.6rem);
    color: var(--ink);
    background: var(--panel);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-edge);
    border-radius: var(--radius-full);
    padding: 0.45rem 1.4rem;
}
.collection-title .title-star { width: 1.2em; height: 1.2em; }
.badge-progress { font-size: 0.8em; color: var(--on-surface-variant); }
.badges-list {
    max-width: 860px;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    align-content: start;
    padding: 0.6rem;
    background: var(--panel-soft);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-edge);
    border-radius: var(--radius-lg);
}
.toybox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 0.6rem;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    /* Panels now fill the column; without this, align-content's default
       `normal` (= stretch) drags the auto rows to full height and the
       square tiles turn into portraits on tablets. */
    align-content: start;
    padding: 0.5rem;
    background: var(--panel-soft);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-edge);
    border-radius: var(--radius-lg);
}
.toy-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.4rem 0.3rem;
    border-radius: var(--radius-md);
}
.toy-medallion { position: relative; width: clamp(56px, 13vw, 76px); aspect-ratio: 1; }
.toy-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; border: 2px solid var(--ink); background: var(--cream); box-shadow: var(--shadow-card); }
.toy-tile.mystery .toy-img { filter: grayscale(1) brightness(0.85); opacity: 0.38; }
.toy-mystery-mark {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: 1.6rem;
    color: var(--on-surface-variant);
    pointer-events: none;
}
.toy-name { font-size: 0.72rem; font-weight: 600; color: var(--ink); text-align: center; }
.screen-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: center; }

/* New-badge toast: a small slide-in at the bottom of the room that gets out
   of the way by itself. It never takes the screen or the pointer — only the
   chip catches a tap — so a drag or a build in progress is not interrupted.
   Tapping the chip opens the badge book. */
.badge-toast {
    position: fixed;
    left: 50%;
    /* Clears the Back and toy-chest buttons along the bottom of the room. */
    bottom: calc(5.25rem + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 30;
    max-width: 94vw;
    pointer-events: none;
}
.badge-toast[hidden] { display: none; }
.badge-toast.badge-toast-in { animation: badge-toast-rise 0.45s cubic-bezier(0.34, 1.4, 0.64, 1); }
@keyframes badge-toast-rise {
    from { transform: translate(-50%, 140%); opacity: 0; }
    to   { transform: translate(-50%, 0);    opacity: 1; }
}
.badge-toast-list { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }
.badge-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    max-width: 100%;
    padding: 0.2rem 0.7rem 0.2rem 0.25rem;
    font: inherit;
    color: var(--ink);
    text-align: left;
    background: linear-gradient(180deg, #ffe49a, #f6c453);
    border: 2px solid var(--gold-deep);
    border-radius: var(--radius-full);
    cursor: pointer;
    pointer-events: auto;
    box-shadow: var(--shadow-card);
    animation: chip-pop 0.5s 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes chip-pop { from { transform: scale(0.6); opacity: 0; } to { transform: none; opacity: 1; } }
.badge-chip-face {
    flex: 0 0 auto;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    object-fit: cover;
}
.badge-chip-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.badge-chip-kicker { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-chip-name { font-family: var(--font-headline); font-weight: 700; font-size: 0.95rem; overflow-wrap: anywhere; }

/* ─── Short viewports ────────────────────────────────────────── */
@media (max-height: 950px) {
    .stage { width: min(96vw, 74vh); height: min(96vw, 74vh); }
    .hero-brand { margin-bottom: 0.3rem; }
    .home-shortcuts { margin-top: 0.4rem; gap: 0.5rem; }
    .toybox-grid { max-height: 56vh; }
    .mascot-image-wrapper { width: clamp(64px, 12vh, 110px); height: clamp(64px, 12vh, 110px); }
}
@media (orientation: landscape) and (max-height: 520px) {
    /* ~390px of height total: chrome + square stage + footer must fit it.
       The page is overflow:hidden, so what does not fit is cut, not scrolled.
       Touch targets stay at the 56px design floor — instead the footer and
       chrome give up padding, and the stage shrinks. */
    .stage { width: min(52vw, 60vh); height: min(52vw, 60vh); }
    .room-chrome { padding-top: 0.1rem; gap: 0.3rem; }
    .room-title-plate { padding: 0.25rem 0.9rem; font-size: 1rem; }
    .room-screen { gap: 0.1rem; }
    .game-footer { padding: 0.15rem 1rem 0.25rem; gap: 0.3rem; }
    /* Landscape phones: the stage shrinks to ~230px, so four full room
       names would collide. Labels scale down; even "Living Room" +
       "Kitchen" pills clear each other by a few px. */
    .door-hint span { font-size: 0.52rem; padding: 0.1rem 0.35rem; }
    .door-hint[data-room="living-room"] span { font-size: 0.5rem; padding: 0.1rem 0.3rem; }
    .game-footer .footer-links, .game-footer .footer-copy { font-size: 0.7rem; }
    .activity-overlay {
        padding: 0.3rem 0.5rem;
        flex-direction: row;
        flex-wrap: wrap;
        align-content: center;
        gap: 0.3rem;
        overflow: hidden;
    }
    .activity-topline { flex: 1 1 100%; margin-bottom: 0; gap: 0.4rem; }
    .activity-title { font-size: 0.9rem; padding: 0.2rem 0.7rem; }
    .activity-close { min-height: 38px; padding: 0.2rem 0.8rem; }
    .tray-hint { display: none; }
    .picnic-scene, .fort-scene {
        flex: 0 0 auto;
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 0;
    }
    /* Height-anchored caps (stage == 60vh here, and topline+padding leave
       ~66% of it for the row → 29vh): a height-derived width cannot feed
       back through the aspect ratio the way a width-derived height did. */
    .picnic-blanket {
        width: min(calc(29vh * 1.35), 172px);
        height: auto;
        aspect-ratio: 1.35;
    }
    .fort-frame { width: min(29vh, 152px); height: auto; aspect-ratio: 1; }
    /* Eight 56px cushions in three columns run three rows deep and push the
       reset button off a 375px-tall screen; four columns keep it to two. */
    #fort-tray { grid-template-columns: repeat(4, auto); }
    .tray-row {
        flex: 1 1 26%;
        display: flex;
        align-items: center;
        gap: 0.35rem;
        min-width: 0;
    }
    .chip-tray {
        display: grid;
        grid-template-columns: repeat(3, auto);
        grid-auto-rows: auto;
        justify-content: center;
        align-content: center;
        flex: 1 1 auto;
        min-width: 0;
    }
    .chip { width: min(24px, min(7vh, 42px)); width: clamp(24px, 7vh, 42px); }
    .chip-name { display: none; }
    .tray-row .btn-primary, .tray-row .btn-secondary {
        min-height: 40px;
        min-width: 0;
        align-self: center;
        font-size: 0.78rem;
        padding: 0.25rem 0.7rem;
    }
}

/* ─── A11y modes for the new surfaces ────────────────────────── */
@media (prefers-contrast: more), (forced-colors: active) {
    .stage,
    #room-screen .stage,
    .stage-hub,
    .activity-overlay,
    .hint-bubble,
    .toast,
    .hunt-chip,
    .hunt-banner,
    .toybox-grid,
    .chip-tray,
    .tray-hint,
    .room-title-plate h2,
    .collection-title,
    .door-hint span,
    .activity-button::before,
    .stage-tool,
    .album-modal,
    .album-tile,
    .album-empty,
    .mail-modal,
    .mail-content,
    .day-modal,
    .day-content,
    .winddown-modal,
    .winddown-content,
    .profile-modal,
    .profile-input,
    .profile-row,
    .profile-avatar,
    .profile-chip,
    .room-picture,
    .story-modal,
    .story-art,
    .story-card,
    .journal-modal,
    .journal-stat,
    .journal-chip,
    .music-modal,
    .music-stage,
    .music-instrument,
    .music-mode,
    .voice-caption,
    .setting-select {
        background: var(--surface-container-lowest);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
    .stage, #room-screen .stage, .stage-hub { background-image: none; }
    /* Night is a look, not a contrast decision: raised modes stay full-bright. */
    body[data-time="night"] #hub-stage,
    body[data-time="night"][data-screen="hub"]::before { filter: none; }
    /* Victory card and the collection panels are my own overrides of the
       meadow's raised-mode rules, so they restate them: opaque Canvas, no
       blur, and a CanvasText edge — the OS palette supplies the colours in
       forced-colours mode. */
    .victory-content,
    .badge-chip,
    .stage-label,
    #badges-list,
    .toy-tile,
    .badge-tile,
    .room-title-plate {
        background: Canvas;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        border: 2px solid CanvasText;
    }
    .door-hint { border-width: 2px; }
    .btn-primary { border-color: var(--ink); }
    /* Furniture visibility stays with the body[data-room] attribute rules —
       they are already attribute-based and survive the OS palette; forcing
       display here would stack all four rooms' hotspots on top of each
       other. */
    .hotspot::after, .hunt-spot::after { background: Highlight; }
    .hotspot::before { background: HighlightText; }
    .sparkle-fx { display: none; }
    .fx-bounce, .fx-topple, .fx-wobble, .fx-tuck, .fx-swing, .fx-dig, .fx-roll,
    .picnic-monty.munch, .fort-monty.peek, .found-bounce .found-toy-img { animation: none !important; }
}

/* ═══════════════════════════════════════════════════════════════
   The dollhouse: actors, props, drop zones, chest and dress-up
   ═══════════════════════════════════════════════════════════════ */

/* A fifth room joins the stage. */
body[data-screen="room"][data-room="bathroom"] .room-furniture[data-room="bathroom"] { display: block; }

/* Furniture sprite layers sit between the painted room and the actors. */
.prop-layer {
    position: absolute;
    height: auto;
    pointer-events: none;
    z-index: 1;
    filter: drop-shadow(0 4px 6px rgba(30, 58, 49, 0.18));
}
.layer-lamp-on,
.layer-fridge-open,
.layer-bed-down,
.layer-wardrobe-open,
.layer-garden-grown,
.layer-bubbles { display: none; }

.lit .layer-lamp-on { display: block; }
.lit .layer-lamp-off { display: none; }
.fridge-open .layer-fridge-open { display: block; }
.fridge-open .layer-fridge-closed { display: none; }
.blanket-down .layer-bed-down { display: block; }
.wardrobe-open .layer-wardrobe-open { display: block; }
.wardrobe-open .layer-wardrobe-closed { display: none; }
.garden-grown .layer-garden-grown { display: block; }
.garden-grown .layer-garden-empty { display: none; }
.bubbles .layer-bubbles { display: block; }

/* Actors and props. The layer itself is inert so taps fall through to the
   room; each actor re-enables pointer events. Buttons and hunt spots are
   painted above this layer (z-index 8), so a character can never steal a
   hunt tap target. */
.room-cushion {
    position: absolute;
    left: 3%;
    top: 82%;
    z-index: 3;
    width: 14%;
    min-width: 56px;
    min-height: 56px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    display: none;
}
body[data-room="living-room"] .room-cushion,
body[data-room="bedroom"] .room-cushion { display: block; }
.room-cushion img {
    display: block;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 6px 8px rgba(30, 58, 49, 0.25));
}
.room-cushion:focus-visible {
    outline: 3px solid var(--on-primary);
    outline-offset: 2px;
    border-radius: 50%;
}
.room-cushion--pop { animation: cushion-pop 0.5s ease-out; }
@keyframes cushion-pop {
    0% { transform: scale(1); }
    40% { transform: scale(1.1) rotate(-2deg); }
    100% { transform: scale(1); }
}
.room-wash {
    position: absolute;
    inset: 0;
    z-index: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.45s ease;
}
.room-wash[data-wash="peach"] {
    background: #ffb488;
    mix-blend-mode: soft-light;
    opacity: 0.55;
}
.room-wash[data-wash="mint"] {
    background: #7fe0b4;
    mix-blend-mode: soft-light;
    opacity: 0.5;
}
.room-wash[data-wash="lavender"] {
    background: #b9a4ff;
    mix-blend-mode: soft-light;
    opacity: 0.5;
}
.room-picture-layer {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}
.room-picture {
    position: absolute;
    z-index: 2;
    min-width: 44px;
    min-height: 44px;
    padding: 3px;
    border: 3px solid #f6e1b7;
    outline: 1px solid rgba(30, 58, 49, 0.45);
    border-radius: 3px;
    background: #fff8e6;
    box-shadow: 0 4px 10px rgba(30, 58, 49, 0.25);
    cursor: pointer;
    pointer-events: auto;
    transform-origin: top left;
}
.room-picture img { display: block; width: 100%; height: auto; border-radius: 1px; }
.room-picture:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; }
.stage-actor-layer {
    position: absolute;
    inset: 0;
    /* No z-index: no stacking context, so characters and props can sit at
       their own depths relative to the room's buttons (see below). */
    pointer-events: none;
}
.stage-actor,
.stage-prop {
    position: absolute;
    width: 30%;
    aspect-ratio: 1;
    transform: translate(-50%, -92%);
    padding: 0;
    border: 0;
    background: transparent;
    pointer-events: auto;
    touch-action: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    cursor: grab;
    transition: left 0.5s cubic-bezier(0.22, 0.9, 0.36, 1),
                top 0.5s cubic-bezier(0.22, 0.9, 0.36, 1);
}
.stage-actor--friend { width: 25%; }
/* The shadow sits on the picture, not the actor: the held toy bobs forever,
   and inside a filtered actor it redrew the shadow on every frame. */
.stage-actor .actor-img { filter: drop-shadow(0 6px 6px rgba(30, 58, 49, 0.22)); }
.stage-actor.dragging .actor-img { filter: drop-shadow(0 16px 14px rgba(30, 58, 49, 0.28)); }
.stage-prop {
    width: 15%;
    transform: translate(-50%, -96%);
    filter: drop-shadow(0 4px 4px rgba(30, 58, 49, 0.22));
}
.stage-actor-img,
.actor-img,
.prop-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
    -webkit-user-drag: none;
}
.stage-actor.dragging,
.stage-prop.dragging {
    transition: none;
    cursor: grabbing;
    transform: translate(-50%, -92%) scale(1.06);
}
.stage-prop.dragging {
    transform: translate(-50%, -96%) scale(1.1);
    filter: drop-shadow(0 16px 14px rgba(30, 58, 49, 0.28));
}
.stage-actor:focus-visible,
.stage-prop:focus-visible {
    outline: 3px solid var(--on-primary);
    outline-offset: 4px;
    border-radius: 40%;
}
.stage-actor.keyboard-carried {
    outline: 3px dashed var(--gold);
    outline-offset: 6px;
    border-radius: 40%;
}
.actor-outfit { position: absolute; inset: 0; pointer-events: none; }
.outfit-layer {
    position: absolute;
    height: auto;
    pointer-events: none;
    filter: drop-shadow(0 2px 3px rgba(30, 58, 49, 0.25));
}
/* The cape hangs behind Monty (the actor is its own stacking context); only
   the collar and star clasp, the top of the same sprite, show in front. */
.outfit-cape-back { z-index: -1; }
.outfit-cape-collar { clip-path: inset(0 0 69% 0); }
.actor-held { position: absolute; inset: 0; pointer-events: none; }
.held-prop {
    position: absolute;
    width: 26%;
    transform: translate(-50%, -50%) rotate(-10deg);
    padding: 0;
    border: 0;
    background: transparent;
    pointer-events: auto;
    cursor: pointer;
}
.held-prop img { width: 100%; height: auto; display: block; filter: drop-shadow(0 3px 3px rgba(30, 58, 49, 0.22)); }
.stage-actor--monty .held-prop { animation: held-bob 2.4s ease-in-out infinite; }

/* Drop zones only appear while something is being carried. */
.stage-zone {
    position: absolute;
    border-radius: 24%;
    border: 3px dashed rgba(255, 255, 255, 0.55);
    background: radial-gradient(circle, rgba(255, 244, 214, 0.22), rgba(255, 244, 214, 0.04));
    opacity: 0;
    transform: scale(0.96);
    transition: opacity 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
    pointer-events: none;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 4%;
}
.actors-dragging .stage-zone { opacity: 0.5; transform: scale(1); }
/* On the way into a room the places to play show themselves for a moment
   (Playhouse._revealRoom), labels and all. */
.room-reveal .stage-zone { opacity: 0.6; transform: scale(1); }
.actors-dragging .stage-zone.zone-aim {
    opacity: 1;
    border-color: var(--gold);
    border-style: solid;
    background: radial-gradient(circle, rgba(255, 224, 130, 0.38), rgba(255, 224, 130, 0.08));
    box-shadow: 0 0 24px rgba(246, 196, 83, 0.55);
}
.stage-zone-label {
    font-family: var(--font-headline);
    font-size: clamp(0.55rem, 1.5vw, 0.8rem);
    color: var(--ink);
    background: var(--panel-strong);
    border-radius: var(--radius-full);
    padding: 0.1rem 0.5rem;
    /* Neighbouring zones (counter and sink) sit close; wrap, never collide. */
    max-width: 100%;
    text-align: center;
    line-height: 1.15;
}

/* A container with something inside wears a count badge. Tapping the badge
   tips the contents out onto the floor. */
.stage-container {
    position: absolute;
    z-index: 8;
    transform: translate(-50%, -50%);
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: var(--radius-full);
    border: 2px solid var(--gold);
    background: var(--panel-strong);
    color: var(--ink);
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1;
    box-shadow: var(--shadow-card);
    cursor: pointer;
    pointer-events: auto;
}
.stage-container:focus-visible {
    outline: 3px solid var(--on-primary);
    outline-offset: 2px;
}
.stage-container-count { display: block; }

/* Photo tools: small round buttons on the stage, so a pre-reader can take a
   picture or open the album without leaving the room. They sit in a row along
   the bottom edge: the top corners hold the living-room lamp, the kitchen
   hanging lamp and the bathroom shelf duck, which were unreachable under them. */
.stage-photo-tools {
    position: absolute;
    bottom: 0.4rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 12;
    display: flex;
    flex-direction: row;
    gap: 0.4rem;
}
.stage-tool {
    position: relative;
    width: 44px;
    height: 44px;
    padding: 0;
    display: grid;
    place-items: center;
    border: 2px solid var(--gold);
    border-radius: 50%;
    background: var(--panel-strong);
    color: var(--ink);
    box-shadow: var(--shadow-card);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.stage-tool svg { width: 22px; height: 22px; fill: currentColor; }
.stage-tool:active { transform: scale(0.94); }
.stage-tool:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; }
.stage-tool-count {
    position: absolute;
    top: -7px;
    right: -7px;
    min-width: 20px;
    height: 20px;
    padding: 0 4px;
    border-radius: var(--radius-full);
    background: var(--gold);
    color: var(--ink);
    border: 1px solid var(--ink);
    font-family: var(--font-headline);
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

/* A camera flash; the snapshot itself reads the DOM, so it never catches it. */
#room-stage::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 20;
    pointer-events: none;
    background: #fff;
    opacity: 0;
    transition: opacity 0.45s ease;
}
#room-stage.stage-flash::before {
    opacity: 0.85;
    transition-duration: 0.06s;
}

/* ─── Monty's Album ─────────────────────────────────────────── */
.album-modal {
    width: min(92vw, 620px);
    max-height: min(90vh, 860px);
    padding: 0;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-xl);
    background: var(--surface-container-lowest);
    color: var(--on-surface);
    box-shadow: var(--shadow-modal);
}
.album-modal::backdrop {
    background: rgba(24, 38, 32, 0.55);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}
.album-content {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 1rem;
    max-height: inherit;
    overflow-y: auto;
}
.album-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.album-title {
    margin: 0;
    font-family: var(--font-headline);
    font-size: clamp(1.1rem, 3vw, 1.5rem);
    color: var(--ink);
}
.album-latest {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}
.album-latest[hidden] { display: none; }
.album-photo-wrap { position: relative; display: inline-flex; max-width: 100%; }
.album-latest .album-photo-wrap > img {
    width: min(100%, 420px);
    height: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-edge);
    box-shadow: var(--shadow-card);
}
.album-photo--stickers { cursor: crosshair; }
.album-photo-wrap img,
.album-sticker-choice img,
.album-tile img {
    -webkit-user-drag: none;
    user-select: none;
    -webkit-touch-callout: none;
}
.album-sticker-layer { position: absolute; inset: 0; pointer-events: none; touch-action: none; }
.album-sticker-layer img {
    pointer-events: auto;
    cursor: grab;
    touch-action: none;
    position: absolute;
    width: 14%;
    height: auto;
    transform: translate(-50%, -50%);
    filter: drop-shadow(0 2px 4px rgba(30, 58, 49, 0.3));
}
.album-sticker-tools { display: flex; justify-content: center; gap: 0.5rem; }
.album-sticker-tools[hidden] { display: none; }
.album-sticker-tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem; }
.album-sticker-tray[hidden] { display: none; }
.album-sticker-choice {
    width: 44px;
    height: 44px;
    padding: 3px;
    border: 2px solid var(--glass-edge);
    border-radius: 50%;
    background: var(--panel-soft);
    cursor: pointer;
}
.album-sticker-choice img { width: 100%; height: 100%; object-fit: contain; }
.album-sticker-choice[aria-pressed="true"] {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(246, 196, 83, 0.3);
}
.album-sticker-choice:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; }
.album-caption {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--on-surface-variant);
}
.album-empty {
    margin: 0.2rem 0;
    padding: 1rem;
    text-align: center;
    color: var(--on-surface-variant);
    background: var(--panel-soft);
    border-radius: var(--radius-lg);
}
.album-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 0.5rem;
}
.album-tile {
    padding: 0;
    overflow: hidden;
    aspect-ratio: 1;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    background: var(--panel-soft);
    cursor: pointer;
}
.album-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-tile--current { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(246, 196, 83, 0.35); }
.album-tile:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; }
.album-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
.album-actions .btn-primary,
.album-actions .btn-secondary { min-height: 44px; }
.album-wall-note {
    margin: 0;
    font-size: 0.82rem;
    color: var(--on-surface-variant);
    text-align: center;
}

/* Monty's mailbox: a small envelope on the hub, with a dot when a letter
   is waiting. The letter itself is a cream card. */
.hub-mail {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    z-index: 12;
}
.hub-night {
    position: absolute;
    top: 0.6rem;
    left: 0.6rem;
    z-index: 12;
}
.hub-story {
    position: absolute;
    bottom: 0.9rem;
    left: 0.6rem;
    z-index: 12;
}
.hub-music {
    position: absolute;
    bottom: 0.9rem;
    right: 0.6rem;
    z-index: 12;
}
#night-btn .icon-sun { display: none; }
body[data-time="night"] #night-btn .icon-moon { display: none; }
body[data-time="night"] #night-btn .icon-sun { display: block; }

/* Moonlit play: the house and its rooms dim, while the menus stay bright. */
#hub-stage { transition: filter 0.45s ease; }
body[data-time="night"] #hub-stage {
    filter: brightness(0.58) saturate(0.72) hue-rotate(-12deg);
}
/* A room dims under its night-tint layer, raised over everything on the
   stage (characters stack by their height, up to 96), rather than with a
   filter on the whole stage: that filter was redrawn on every frame anything
   in the room moved (about 2x the cost, measured). */
body[data-time="night"] #room-stage::after {
    z-index: 100;
    opacity: 1;
    background: rgba(14, 18, 52, 0.4);
}
body[data-time="night"] #room-stage.night::after {
    background: radial-gradient(circle at 22% 30%, rgba(255, 226, 148, 0.12), rgba(16, 20, 58, 0.58) 70%);
}
@media (prefers-contrast: more), (forced-colors: active) {
    /* Night is a look, not a contrast decision: only Monty's bed keeps its tint. */
    body[data-time="night"] #room-stage::after {
        z-index: 3;
        opacity: 0;
        background: radial-gradient(circle at 22% 30%, rgba(255, 226, 148, 0.18), rgba(24, 30, 78, 0.5) 70%);
    }
    body[data-time="night"] #room-stage.night::after { opacity: 1; }
}
body[data-time="night"][data-screen="room"] { background-color: #232a44; }
body[data-time="night"][data-screen="hub"]::before {
    filter: brightness(0.5) saturate(0.72) hue-rotate(-12deg);
}
/* The page wash becomes a deep night sky around the lit stage. */
body[data-time="night"][data-screen="hub"]::after {
    background: linear-gradient(180deg,
        rgba(10, 14, 38, 0.62) 0%,
        rgba(16, 22, 58, 0.48) 45%,
        rgba(10, 14, 38, 0.62) 100%);
}
.mail-dot {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--gold);
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(30, 58, 49, 0.3);
}
/* Monty's day chart: a wall chart with one picture card per room. */
.hub-day {
    position: absolute;
    top: 0.6rem;
    left: 3.6rem;
    z-index: 12;
}
.day-modal {
    width: min(92vw, 440px);
    max-height: min(92vh, 680px);
    padding: 0;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-xl);
    background: var(--surface-container-lowest);
    color: var(--on-surface);
    box-shadow: var(--shadow-modal);
}
.day-modal::backdrop { background: rgba(24, 38, 32, 0.55); }
.day-content {
    overflow-y: auto;
    max-height: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.1rem;
    text-align: center;
}
.day-monty { width: 72px; height: 72px; flex: none; object-fit: contain; }
.day-title {
    margin: 0;
    font-family: var(--font-headline);
    font-size: clamp(1.15rem, 3.4vw, 1.55rem);
    color: var(--ink);
}
.day-list {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 0.5rem;
}
.day-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    padding: 0.45rem 0.3rem;
    border: 2px dashed var(--glass-edge);
    border-radius: var(--radius-lg, 16px);
    background: var(--surface-container-low, #fbf6ea);
    opacity: 0.8;
}
.day-card--done {
    border: 2px solid var(--gold);
    background: var(--panel-strong);
    opacity: 1;
}
.day-card-icon { width: 44px; height: 44px; object-fit: contain; }
.day-card:not(.day-card--done) .day-card-icon { filter: grayscale(0.6); }
.day-card-label { font-family: var(--font-headline); font-weight: 700; color: var(--ink); }
.day-card-verb { font-size: 0.75rem; color: var(--on-surface-variant); }
.day-card-tick {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--gold);
    color: var(--ink);
    font-weight: 800;
    border: 2px solid #fff;
}
.day-card-tick:empty { display: none; }
.day-text { margin: 0; font-size: 0.95rem; color: var(--on-surface-variant); }

.mail-modal {
    width: min(92vw, 420px);
    max-height: min(90vh, 620px);
    padding: 0;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-xl);
    background: var(--surface-container-lowest);
    color: var(--on-surface);
    box-shadow: var(--shadow-modal);
}
.mail-modal::backdrop { background: rgba(24, 38, 32, 0.55); }
.mail-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    padding: 1.1rem;
    text-align: center;
}
.mail-title {
    margin: 0;
    font-family: var(--font-headline);
    font-size: clamp(1.15rem, 3.4vw, 1.55rem);
    color: var(--ink);
}
.mail-gift-img {
    width: 112px;
    height: 112px;
    object-fit: contain;
    filter: drop-shadow(0 6px 8px rgba(30, 58, 49, 0.18));
}
.mail-gift-name {
    margin: 0;
    font-family: var(--font-headline);
    font-weight: 700;
    color: var(--ink);
}
.mail-text {
    margin: 0 0 0.35rem;
    color: var(--on-surface-variant);
}
.mail-content .btn-primary { min-width: 140px; min-height: 44px; }

/* Parent-set wind-down: a select in Settings and a calm end-of-play card. */
.setting-select {
    min-height: 44px;
    min-width: 124px;
    padding: 0.4rem 0.6rem;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-md);
    background: var(--panel-strong);
    color: var(--ink);
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
}
.setting-select:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; }

.winddown-modal {
    width: min(92vw, 430px);
    max-height: min(90vh, 640px);
    padding: 0;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-xl);
    background: var(--surface-container-lowest);
    color: var(--on-surface);
    box-shadow: var(--shadow-modal);
}
.winddown-modal::backdrop { background: rgba(24, 38, 32, 0.6); }
.winddown-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    padding: 1.1rem;
    text-align: center;
}
.winddown-monty {
    width: min(46vw, 160px);
    height: auto;
    filter: drop-shadow(0 8px 12px rgba(30, 58, 49, 0.2));
}
.winddown-title {
    margin: 0;
    font-family: var(--font-headline);
    font-size: clamp(1.2rem, 3.4vw, 1.6rem);
    color: var(--ink);
}
.winddown-text {
    margin: 0 0 0.4rem;
    color: var(--on-surface-variant);
}
.winddown-actions {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    width: 100%;
    max-width: 240px;
}
.winddown-actions .btn-primary,
.winddown-actions .btn-secondary { min-height: 44px; }
@media (min-width: 520px) {
    .winddown-actions { flex-direction: row; justify-content: center; max-width: none; }
}

/* ─── Cosy corner (breathing) activity ─────────────────────── */
.calm-overlay {
    background: radial-gradient(120% 90% at 50% 0%, rgba(30, 50, 60, 0.35), rgba(18, 30, 40, 0.72));
}
.calm-scene {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    border-radius: var(--radius-xl);
    background: radial-gradient(circle at 50% 40%, #cfe3dd, #a8c7c2 55%, #7fa6a7);
}
.calm-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 45%, rgba(255, 248, 220, 0.5), transparent 55%);
}
.calm-breath {
    position: absolute;
    left: 50%;
    top: 42%;
    z-index: 1;
    width: 46%;
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
}
/* Apple-Breathe style: six soft translucent petals that overlap at rest,
   bloom outwards as we breathe in and fold back as we breathe out. */
.calm-petal {
    position: absolute;
    left: 25%;
    top: 25%;
    width: 50%;
    height: 50%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.55), rgba(190, 232, 224, 0.28) 75%);
    mix-blend-mode: screen;
    box-shadow: 0 0 18px rgba(255, 255, 255, 0.25);
    transform: rotate(var(--a)) translateY(0) scale(0.7);
    transition: transform 5s cubic-bezier(0.45, 0, 0.55, 1);
}
.calm-petal:nth-child(1) { --a: 0deg; }
.calm-petal:nth-child(2) { --a: 60deg; }
.calm-petal:nth-child(3) { --a: 120deg; }
.calm-petal:nth-child(4) { --a: 180deg; }
.calm-petal:nth-child(5) { --a: 240deg; }
.calm-petal:nth-child(6) { --a: 300deg; }
.calm-core {
    position: absolute;
    left: 38%;
    top: 38%;
    width: 24%;
    height: 24%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    filter: blur(6px);
    transition: opacity 5s ease-in-out;
}
.calm-breath--in .calm-petal {
    transform: rotate(var(--a)) translateY(-32%) scale(1);
    transition-duration: 4s;
}
.calm-breath--out .calm-petal {
    transform: rotate(var(--a)) translateY(0) scale(0.7);
    transition-duration: 5s;
}
.calm-breath--in .calm-core { opacity: 0.35; transition-duration: 4s; }
.calm-monty {
    position: absolute;
    left: 38%;
    bottom: 0;
    z-index: 2;
    height: 46%;
    filter: drop-shadow(0 5px 8px rgba(30, 58, 49, 0.25));
}
.calm-cushion {
    position: absolute;
    left: 28%;
    bottom: 1%;
    z-index: 1;
    width: 30%;
    opacity: 0.95;
}
.calm-actions { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }
.calm-actions .btn-primary { min-height: 44px; padding-inline: 1.4rem; }
.calm-actions .tray-hint { margin: 0; text-align: center; }

/* ─── Tea party activity ────────────────────────────────────── */
.tea-overlay {
    background: radial-gradient(120% 90% at 50% 0%, rgba(80, 50, 40, 0.25), rgba(45, 25, 20, 0.6));
}
.tea-scene {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    border-radius: var(--radius-xl);
    background:
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.55) 0 5px, transparent 6px) 0 0 / 32px 32px,
        linear-gradient(180deg, #f7e7d6, #efd3c2 70%, #e6b89c);
}
.tea-monty {
    position: absolute;
    left: 1%;
    bottom: 18%;
    z-index: 4;
    height: 46%;
    filter: drop-shadow(0 5px 8px rgba(30, 58, 49, 0.25));
}
.tea-friend {
    position: absolute;
    z-index: 4;
    width: 22%;
    height: 48%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tea-friend-img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 5px 8px rgba(30, 58, 49, 0.22)); }
.tea-friend:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; border-radius: 50%; }
.tea-plate-treat {
    position: absolute;
    left: 50%;
    bottom: -10%;
    width: 34px;
    height: 34px;
    padding: 3px;
    border: 2px solid #e4c19b;
    border-radius: 50%;
    background: #fffaf0;
    object-fit: contain;
    transform: translateX(-50%);
    box-shadow: 0 3px 6px rgba(70, 40, 20, 0.3);
}
.tea-plate-treat[hidden] { display: none; }
.tea-friend--served .tea-friend-img { animation: tea-nod 0.5s ease-out; }
.tea-table {
    position: absolute;
    left: -5%;
    right: -5%;
    bottom: 0;
    z-index: 3;
    height: 32%;
    border-top: 6px solid #e4c19b;
    border-radius: 50% 50% 0 0 / 22% 22% 0 0;
    background: linear-gradient(180deg, #c08b60, #96603d);
    box-shadow: inset 0 8px 16px rgba(255, 255, 255, 0.25);
}
.tea-table::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 36%;
    border-radius: inherit;
    background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.5) 0 12px, transparent 12px 24px);
    opacity: 0.6;
}
.tea-cup { position: absolute; z-index: 4; width: 11%; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(30, 58, 49, 0.25)); }
.tea-pot { position: absolute; z-index: 4; width: 14%; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(30, 58, 49, 0.25)); }
.tea-tray { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.45rem; }
.tea-treat {
    display: grid;
    place-items: center;
    min-height: 64px;
    padding: 0.25rem;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-lg);
    background: var(--panel-soft);
    cursor: pointer;
}
.tea-treat img { width: 44px; height: 44px; object-fit: contain; }
.tea-treat--on { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(246, 196, 83, 0.3); }
.tea-treat:disabled { opacity: 0.4; cursor: default; }
.tea-treat:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; }
@keyframes tea-nod {
    0%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* ─── Meadow walk activity ──────────────────────────────────── */
.meadow-overlay {
    background: radial-gradient(120% 90% at 50% 0%, rgba(30, 80, 60, 0.3), rgba(20, 50, 40, 0.65));
}
.meadow-scene {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    border-radius: var(--radius-xl);
    background: linear-gradient(180deg, #bfe3f7 0%, #e9f6ff 55%, #cfeac0 100%);
}
.meadow-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.meadow-monty {
    position: absolute;
    left: 40%;
    bottom: 2%;
    z-index: 3;
    height: 34%;
    filter: drop-shadow(0 5px 8px rgba(30, 58, 49, 0.25));
}
.meadow-find {
    position: absolute;
    z-index: 4;
    width: 15%;
    min-width: 56px;
    min-height: 56px;
    padding: 4px;
    border: 0;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, filter 0.2s ease;
}
.meadow-find img {
    width: 100%;
    height: auto;
    max-height: 56px;
    object-fit: contain;
    filter: drop-shadow(0 3px 5px rgba(30, 58, 49, 0.25));
}
.meadow-find:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; border-radius: 50%; }
.meadow-find--found { transform: scale(1.12); filter: drop-shadow(0 0 10px #ffec8a); }
.meadow-find--found img { filter: drop-shadow(0 0 12px #fff3b0); }
.meadow-find:disabled { cursor: default; }

/* ─── Puppet show activity ──────────────────────────────────── */
.puppets-overlay { background: rgba(14, 8, 16, 0.94); }
.puppet-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    border: 4px solid #7a4a2e;
    border-radius: var(--radius-xl);
    background: #1a0f1c;
    contain: paint;
}
.puppet-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.puppet-spot { position: absolute; bottom: 0; width: 30%; height: 64%; }
.puppet-spot[data-spot="0"] { left: 11%; }
.puppet-spot[data-spot="1"] { left: 35%; }
.puppet-spot[data-spot="2"] { left: 59%; }
.puppet-performer {
    position: absolute;
    left: 50%;
    bottom: -4%;
    width: 100%;
    height: auto;
    z-index: 3;
    transform: translateX(-50%);
    animation: puppet-rise 0.5s cubic-bezier(0.34, 1.4, 0.64, 1);
}
.puppet-performer[hidden] { display: none; }
@keyframes puppet-rise {
    0% { transform: translateX(-50%) translateY(70%); opacity: 0; }
    100% { transform: translateX(-50%) translateY(0); opacity: 1; }
}
.puppet-curtain {
    position: absolute;
    top: 0;
    width: 22%;
    height: 100%;
    z-index: 4;
    object-fit: fill;
    transition: transform 0.9s ease;
    pointer-events: none;
}
.puppet-curtain--left { left: -6%; }
.puppet-curtain--right { right: -6%; transform: scaleX(-1); }
.puppet-closed .puppet-curtain--left { transform: translateX(125%); }
.puppet-closed .puppet-curtain--right { transform: scaleX(-1) translateX(125%); }
.puppet-valance { position: absolute; top: -1%; left: -2%; width: 104%; height: auto; z-index: 5; pointer-events: none; }
.puppet-bubble {
    position: absolute;
    left: 50%;
    top: 0;
    z-index: 6;
    width: 150%;
    margin: 0;
    padding: 0.4rem 0.6rem;
    border: 2px solid #7a4a2e;
    border-radius: 14px;
    background: #fff8e6;
    color: #3a2a1e;
    font-family: var(--font-headline);
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.25;
    text-align: center;
    transform: translateX(-50%);
}
.puppet-bubble[hidden] { display: none; }
.puppet-bubble::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -8px;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: #7a4a2e;
    border-bottom: 0;
}
.puppet-sets { display: flex; justify-content: center; gap: 0.45rem; }
.puppet-set {
    width: 64px;
    height: 46px;
    padding: 0;
    overflow: hidden;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-md);
    background: none;
    cursor: pointer;
}
.puppet-set img { width: 100%; height: 100%; object-fit: cover; display: block; }
.puppet-set[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(246, 196, 83, 0.4); }
.puppet-choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
.puppet-choice {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    min-height: 62px;
    padding: 0.25rem;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-lg);
    background: var(--panel-soft);
    color: var(--ink);
    font-family: var(--font-headline);
    font-size: 0.74rem;
    font-weight: 700;
    cursor: pointer;
}
.puppet-choice img { width: 40px; height: 40px; object-fit: contain; }
.puppet-choice--on { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(246, 196, 83, 0.3); }
.puppet-choice:focus-visible, .puppet-set:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; }
@keyframes puppet-pop {
    0% { opacity: 0; transform: translateX(-50%) translateY(12px) scale(0.9); }
    100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* ─── Living room: blocks, the fort as a play space, puppet audience ───
   What the games leave behind sits in the room as sprite layers, hidden
   until the child has earned them (the flag, the shelf, a stack of blocks). */
.layer-fort-flag { left: 49%; top: 45%; width: 10%; }
.layer-puppet-shelf { left: 21%; top: 6%; width: 15%; }
.layer-blocks-stack {
    left: 79%;
    top: 22%;
    width: 9%;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
}
.layer-blocks-stack img { width: 62%; height: auto; margin-top: -26%; }
.layer-blocks-stack img:first-child { margin-top: 0; }
/* Its label rides to the left of the basket: "Read a story" sits right under it. */
.activity-button.blocks::before { left: auto; right: 100%; bottom: auto; top: 10%; transform: none; }
body[data-activity] .layer-fort-flag,
body[data-activity] .layer-puppet-shelf,
body[data-activity] .layer-blocks-stack { visibility: hidden; }
/* A friend in the fort makes it glow, the same warm light as the fairy lights. */
.fort-occupied .layer-fort-tent.is-built { filter: drop-shadow(0 0 12px rgba(246, 196, 83, 0.9)); }

.blocks-scene {
    --bw: 14vmin;
    --bw: calc(100cqh / 6.1);
    position: relative;
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    container-type: size;
}
.blocks-scene::before {
    content: '';
    position: absolute;
    left: 8%;
    right: 8%;
    bottom: 1%;
    height: 12%;
    border-radius: 50%;
    background: rgba(255, 233, 205, 0.55);
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.45);
}
.blocks-tower {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    min-width: max(var(--bw), 64px);
    min-height: max(var(--bw), 64px);
    margin-bottom: 4%;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    transform-origin: 50% 100%;
    -webkit-tap-highlight-color: transparent;
}
.blocks-tower:empty {
    border: 3px dashed rgba(255, 255, 255, 0.8);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.25);
}
.blocks-tower:focus-visible, .blocks-pile:focus-visible, .blocks-chip:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 3px; }
.blocks-tower.away { visibility: hidden; }
.blocks-block {
    width: var(--bw);
    height: var(--bw);
    margin-top: -6%;
    pointer-events: none;
    filter: drop-shadow(0 3px 4px rgba(30, 58, 49, 0.3));
}
.blocks-block:last-child { animation: blocks-plop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }
.blocks-tower.wobble { animation: blocks-wobble 0.9s ease-in-out; }
@keyframes blocks-plop { 0% { transform: translateY(-60%) scale(0.9); opacity: 0.4; } 100% { transform: none; opacity: 1; } }
@keyframes blocks-wobble {
    0%, 100% { transform: rotate(0); }
    20% { transform: rotate(var(--wobble, 2deg)); }
    45% { transform: rotate(calc(var(--wobble, 2deg) * -0.8)); }
    70% { transform: rotate(calc(var(--wobble, 2deg) * 0.4)); }
}
.blocks-tower.tipping .blocks-block { animation: blocks-tumble 0.9s ease-in forwards; }
.blocks-tower.tipping .blocks-block:nth-child(odd) { --tx: -90%; --rot: -50deg; }
.blocks-tower.tipping .blocks-block:nth-child(even) { --tx: 90%; --rot: 50deg; }
.blocks-tower.tipping .blocks-block:nth-child(2) { animation-delay: 0.05s; }
.blocks-tower.tipping .blocks-block:nth-child(3) { animation-delay: 0.1s; }
.blocks-tower.tipping .blocks-block:nth-child(4) { animation-delay: 0.15s; }
.blocks-tower.tipping .blocks-block:nth-child(5) { animation-delay: 0.2s; }
.blocks-tower.tipping .blocks-block:nth-child(6) { animation-delay: 0.25s; }
@keyframes blocks-tumble { to { transform: translate(var(--tx, 60%), 60%) rotate(var(--rot, 40deg)); opacity: 0; } }
.blocks-pile {
    position: absolute;
    left: 50%;
    bottom: 3%;
    z-index: 2;
    width: calc(var(--bw) * 2.3);
    min-width: 88px;
    aspect-ratio: 1;
    translate: -50% 0;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
}
.blocks-pile[hidden] { display: none; }
.blocks-pile img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.blocks-pile.pop { animation: blocks-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes blocks-pop { 0% { scale: 0.4; opacity: 0; } 100% { scale: 1; opacity: 1; } }
.blocks-tray { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.4rem; }
.blocks-chip {
    min-width: 64px;
    min-height: 64px;
    padding: 0.2rem;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-md);
    background: var(--panel-strong);
    box-shadow: var(--shadow-card);
    cursor: pointer;
    touch-action: none;
    transition: transform 0.15s ease;
}
.blocks-chip:active { transform: scale(0.94); }
.blocks-chip img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
@media (max-width: 520px) {
    .blocks-tray { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 700px) and (min-height: 700px) {
    .blocks-chip { min-height: 88px; }
}
@media (max-height: 460px) {
    .blocks-tray { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .blocks-chip { min-width: 0; min-height: 52px; }
}
@media (prefers-reduced-motion: reduce) {
    .blocks-block, .blocks-tower, .blocks-pile, .puppet-guest { animation: none !important; }
    .blocks-tower.tipping .blocks-block { opacity: 0; transition: opacity 0.2s ease; }
}

/* The fort once it is built: a flag to fly, and Monty already cosy inside. */
.fort-flag {
    position: absolute;
    left: 41%;
    top: -6%;
    width: 24%;
    z-index: 4;
    pointer-events: none;
    transform-origin: 50% 100%;
    animation: fort-flag-wave 3s ease-in-out infinite;
}
.fort-flag[hidden] { display: none; }
@keyframes fort-flag-wave { 0%, 100% { rotate: -2deg; } 50% { rotate: 2deg; } }
.fort-flag-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    padding: 0.2rem;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-full);
    background: var(--panel-strong);
    box-shadow: var(--shadow-card);
    cursor: pointer;
}
.fort-done .fort-flag-btn { display: inline-flex; }
.fort-flag-btn img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.fort-flag-btn.is-on { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(246, 196, 83, 0.4); }
.fort-flag-btn:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .fort-flag { animation: none; } }

/* The audience sits in front of the theatre and claps after the bow. */
.puppet-audience {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -2%;
    z-index: 7;
    display: flex;
    justify-content: center;
    gap: 5%;
    pointer-events: none;
}
.puppet-guest { width: 16%; max-width: 72px; height: auto; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.45)); }
.clapping .puppet-guest--monty { animation: guest-cheer 0.6s ease-in-out 4; }
.clapping .puppet-guest--bunny { animation: guest-hop 0.7s ease-in-out 3; }
.clapping .puppet-guest--hedgehog { animation: guest-roll 0.9s ease-in-out 2; }
@keyframes guest-cheer { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-10%) scale(1.06); } }
@keyframes guest-hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-22%); } }
@keyframes guest-roll { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-12deg) translateX(8%); } }

/* ─── Bedroom: bedtime choices, saved looks, the peek under the bed ─── */
.layer-sleep-toy { left: 8%; top: 22%; width: 13%; }
.layer-sleep-toy.is-plain { left: 10%; top: 26%; width: 8%; rotate: -14deg; }
.layer-valance-lift { left: 0; top: 35%; width: 27%; z-index: 2; }
.layer-peeker { left: 11%; top: 47%; width: 9%; z-index: 3; }
body[data-activity] .layer-sleep-toy,
body[data-activity] .layer-valance-lift,
body[data-activity] .layer-peeker { visibility: hidden; }
.layer-valance-lift.lift { animation: valance-lift 0.5s ease-out; }
.layer-peeker.peek { animation: peeker-peek 0.7s cubic-bezier(0.34, 1.4, 0.64, 1); }
@keyframes valance-lift { 0% { transform: translateY(-4%); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes peeker-peek { 0% { transform: translateX(-60%) scale(0.7); opacity: 0; } 100% { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    .layer-valance-lift.lift, .layer-peeker.peek { animation: none; }
}

.bedtime-choices { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem 0.9rem; }
.bedtime-choices[hidden] { display: none; }
.bedtime-friends[hidden] { display: none; }
.bedtime-pick[hidden] { display: none; }
.bedtime-pick { display: flex; justify-content: center; gap: 0.4rem; }
.bedtime-pick-chip {
    width: 64px;
    height: 64px;
    padding: 0.2rem;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-md);
    background: var(--panel-strong);
    box-shadow: var(--shadow-card);
    cursor: pointer;
    transition: transform 0.15s ease;
}
.bedtime-pick-chip img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.bedtime-pick-chip[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(246, 196, 83, 0.4); transform: translateY(-2px); }
.bedtime-pick-chip:focus-visible, .bedtime-friend:focus-visible, .outfit-slot:focus-visible, .outfit-tool:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; }
.bedtime-friends { display: flex; justify-content: center; gap: 0.6rem; }
.bedtime-friend {
    width: 72px;
    height: 72px;
    padding: 0.15rem;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.16);
    cursor: pointer;
}
.bedtime-friend img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.bedtime-friend.is-tucked { border-color: var(--sage, #86c4a0); }
@media (min-width: 700px) and (min-height: 700px) {
    .bedtime-pick-chip { width: 88px; height: 88px; }
    .bedtime-friend { width: 88px; height: 88px; }
}

.outfit-tools { display: flex; align-items: center; justify-content: center; gap: 0.4rem; width: 100%; }
.outfit-slots { display: flex; gap: 0.4rem; }
.outfit-slot, .outfit-tool {
    position: relative;
    width: 64px;
    height: 64px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    transition: transform 0.15s ease;
}
.outfit-slot:active, .outfit-tool:active { transform: scale(0.93); }
.outfit-slot-frame { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.outfit-portrait { position: absolute; left: 17%; top: 17%; width: 66%; height: 66%; overflow: hidden; border-radius: 50%; pointer-events: none; }
.outfit-portrait-inner { position: absolute; left: -22%; top: -2%; width: 144%; aspect-ratio: 1; }
.outfit-portrait-inner > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.outfit-portrait-inner .outfit-layer { position: absolute; }
.outfit-tool {
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-full);
    background: var(--panel-strong);
    box-shadow: var(--shadow-card);
}
.outfit-tool img { width: 78%; height: 78%; object-fit: contain; pointer-events: none; }
.outfit-tool svg { width: 52%; height: 52%; fill: var(--gold-deep, #d99a1f); stroke: var(--ink); stroke-width: 1.4; stroke-linejoin: round; }
@media (min-width: 700px) and (min-height: 700px) {
    .outfit-slot, .outfit-tool { width: 88px; height: 88px; }
}
@media (max-height: 560px) {
    .outfit-slot, .outfit-tool { width: 52px; height: 52px; }
}

/* ─── Star-gazing activity ────────────────────────────────────
   The six wish stars are the whole toy here, so they are drawn as big
   painted gold stars with a soft halo and a tappable ring, not as small
   text glyphs. The new night artwork is a 1:1 backyard with a shallow sky;
   zooming into its upper-left crops the tree out of the right-hand stars
   and gives the sky enough depth for a proper constellation. */
.stars-overlay {
    background: radial-gradient(120% 90% at 50% 0%, rgba(12, 26, 48, 0.92), rgba(8, 16, 32, 0.97));
}
.stars-scene {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    border-radius: var(--radius-xl);
    background: linear-gradient(180deg, #0b1830 0%, #1b3556 55%, #24444a 100%);
    -webkit-touch-callout: none;
    user-select: none;
}
.stars-scene::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(180deg, rgba(8, 16, 32, 0) 55%, rgba(8, 16, 32, 0.18) 75%, rgba(8, 16, 32, 0.08));
    pointer-events: none;
}
.stars-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: left top;
    transform: scale(1.55);
    transform-origin: left top;
}
.star-button {
    position: absolute;
    left: var(--star-x, 50%);
    top: var(--star-y, 50%);
    z-index: 3;
    width: clamp(56px, 12%, 82px);
    aspect-ratio: 1;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    transform: translate(-50%, -50%);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
/* One constellation across the sky. The six targets are spaced 16.4% apart
   so their 56px hit areas never overlap on a phone; the y wobble keeps it
   feeling hand-painted rather than a row of buttons. */
.star-button[data-star="1"] { --star-x: 9%; --star-y: 14%; --star-delay: 0s; }
.star-button[data-star="2"] { --star-x: 25.4%; --star-y: 11%; --star-delay: 0.55s; }
.star-button[data-star="3"] { --star-x: 41.8%; --star-y: 15%; --star-delay: 1.1s; }
.star-button[data-star="4"] { --star-x: 58.2%; --star-y: 12%; --star-delay: 1.65s; }
.star-button[data-star="5"] { --star-x: 74.6%; --star-y: 16%; --star-delay: 0.85s; }
.star-button[data-star="6"] { --star-x: 91%; --star-y: 13%; --star-delay: 1.4s; }
/* The halo is what makes the star read as a button from across the room;
   the ring is a quiet, always-visible "tap me" outline. */
.star-button::before,
.star-button::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    /* Not opacity: the halo and ring animations own it, and an opacity
       transition still running when a star lit kept its ring animation on
       the main thread, restyling every frame (measured). */
    transition: border-color 0.2s ease;
}
.star-button::before {
    inset: -10%;
    background: radial-gradient(circle,
        rgba(255, 238, 166, 0.38) 0%,
        rgba(255, 223, 120, 0.16) 46%,
        rgba(255, 223, 120, 0) 72%);
    animation: star-halo 2.8s ease-in-out infinite;
    animation-delay: var(--star-delay, 0s);
}
.star-button::after {
    inset: 5%;
    border: 2px solid rgba(255, 244, 196, 0.46);
    opacity: 0.8;
    animation: star-ring 3.2s ease-in-out infinite;
    animation-delay: var(--star-delay, 0s);
}
.star-button__shape {
    position: absolute;
    inset: 17%;
    background:
        radial-gradient(circle at 36% 28%, #fffdf3 0 12%, rgba(255, 253, 243, 0) 34%),
        linear-gradient(155deg, #fff6c9 0%, #ffe49a 34%, #f6c453 70%, #dfa42c 100%);
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    /* No drop-shadow here: clip-path applies after filter, so a glow on the
       star itself is clipped away unseen, yet animating it repainted every
       frame. The halo (::before) is the glow. */
    transition: transform 0.16s ease;
}
@media (hover: hover) and (pointer: fine) {
    .star-button:hover .star-button__shape {
        transform: scale(1.16) rotate(7deg);
    }
    .star-button:hover::after {
        opacity: 1;
        border-color: rgba(255, 248, 210, 0.9);
    }
}
.star-button:active .star-button__shape {
    transform: scale(0.9);
    transition-duration: 0.06s;
}
.star-button:focus-visible { outline: none; }
.star-button:focus-visible::after {
    opacity: 1;
    border-color: #fff6c9;
    box-shadow: 0 0 0 5px rgba(255, 246, 201, 0.4);
}
/* A wish already made stays bright and keeps a slow halo, so the child can
   see at a glance how many stars are still waiting. */
.star-button--lit .star-button__shape {
    background:
        radial-gradient(circle at 36% 28%, #ffffff 0 18%, rgba(255, 255, 255, 0) 42%),
        linear-gradient(155deg, #fffdf0 0%, #fff0b4 40%, #ffd97a 76%, #f2ba45 100%);
    transform: scale(1.12);
}
@media (hover: hover) and (pointer: fine) {
    .star-button--lit:hover .star-button__shape {
        transform: scale(1.24) rotate(7deg);
    }
}
.star-button--lit:active .star-button__shape {
    transform: scale(0.95);
}
.star-button--lit::before {
    background: radial-gradient(circle,
        rgba(255, 246, 201, 0.55) 0%,
        rgba(255, 226, 130, 0.24) 46%,
        rgba(255, 226, 130, 0) 72%);
    animation: star-halo 2.4s ease-in-out infinite;
    animation-delay: var(--star-delay, 0s);
}
.star-button--lit::after {
    border-color: rgba(255, 250, 220, 0.95);
    opacity: 1;
    animation: star-lit-ring 2.4s ease-in-out infinite;
    animation-delay: var(--star-delay, 0s);
}
@keyframes star-halo {
    0%, 100% { transform: scale(0.9); opacity: 0.55; }
    50% { transform: scale(1.14); opacity: 1; }
}
@keyframes star-ring {
    0%, 100% { transform: scale(0.92); opacity: 0.34; }
    50% { transform: scale(1.05); opacity: 0.72; }
}
@keyframes star-lit-ring {
    0%, 100% { transform: scale(0.96); opacity: 0.6; }
    50% { transform: scale(1.12); opacity: 1; }
}
/* Tap feedback: a ring blooms out of the star, sparks fly, and a tiny wish
   word floats up. All three are generated by the activity and remove
   themselves, so they never pile up in the scene. */
.stars-wish-burst {
    position: absolute;
    z-index: 4;
    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    border: 2px solid rgba(255, 246, 201, 0.9);
    border-radius: 50%;
    pointer-events: none;
    animation: stars-wish-burst 0.6s ease-out forwards;
}
@keyframes stars-wish-burst {
    0% { transform: scale(0.35); opacity: 0.95; }
    100% { transform: scale(2.8); opacity: 0; }
}
.stars-spark {
    position: absolute;
    z-index: 4;
    width: 9px;
    height: 9px;
    margin: -4.5px 0 0 -4.5px;
    background: radial-gradient(circle at 40% 35%, #fffdf5, #ffe49a 55%, #f6c453 100%);
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    filter: drop-shadow(0 0 4px rgba(255, 240, 170, 0.9));
    pointer-events: none;
    animation: stars-spark-fly 0.85s ease-out forwards;
}
@keyframes stars-spark-fly {
    0% { transform: translate(0, 0) scale(0.4) rotate(0deg); opacity: 0; }
    20% { opacity: 1; }
    100% { transform: translate(var(--dx, 0), var(--dy, -30px)) scale(0.1) rotate(var(--spin, 90deg)); opacity: 0; }
}
.stars-wish-whisper {
    position: absolute;
    z-index: 5;
    transform: translate(-50%, -50%);
    pointer-events: none;
    white-space: nowrap;
    padding: 0.18rem 0.62rem;
    border: 1px solid rgba(201, 138, 35, 0.55);
    border-radius: var(--radius-full);
    background: rgba(255, 248, 220, 0.95);
    box-shadow: 0 0 16px rgba(255, 243, 176, 0.8);
    color: var(--gold-ink);
    font-family: var(--font-headline);
    font-size: clamp(0.72rem, 2.4vmin, 0.95rem);
    font-weight: 700;
    animation: stars-wish-whisper 1.1s ease-out forwards;
}
@keyframes stars-wish-whisper {
    0% { opacity: 0; transform: translate(-50%, -30%) scale(0.8); }
    20% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -175%) scale(1); }
}
/* The prompt below the scene is part of the invitation: a warm gold pill,
   not just another quiet caption. */
#stars-hint {
    border: 1px solid rgba(201, 138, 35, 0.45);
    background: rgba(255, 246, 201, 0.94);
    color: var(--gold-ink);
    font-weight: 700;
    box-shadow: 0 0 18px rgba(255, 243, 176, 0.35);
}
#stars-hint::before {
    content: '✦';
    margin-right: 0.35rem;
    color: var(--gold-deep);
}
@media (forced-colors: active) {
    /* The star is the control: keep its gold fill legible and give it a
       system-coloured outline so Windows high contrast can still see it. */
    .star-button__shape { forced-color-adjust: none; }
    .star-button::after { border-color: CanvasText; opacity: 1; }
}
/* Landscape phones put this overlay in a short, wide row. Give the scene the
   whole row instead of letting it collapse, zoom further into the sky, and
   fold the six stars into a 3x2 constellation that still has separate taps. */
@media (orientation: landscape) and (max-height: 520px) {
    .stars-overlay {
        display: grid;
        grid-template-rows: auto minmax(0, 1fr);
        align-content: stretch;
        gap: 0.3rem;
    }
    .stars-overlay .activity-topline { margin-bottom: 0; }
    .stars-overlay .stars-scene {
        width: 100%;
        height: 100%;
        min-height: 0;
    }
    .stars-overlay .tray-row { display: none; }
    .stars-overlay .stars-bg { transform: scale(2.35); }
    .stars-overlay .star-button {
        width: 56px;
        min-width: 56px;
        height: 56px;
        min-height: 56px;
    }
    .stars-overlay .star-button[data-star="1"] { --star-x: 16%; --star-y: 16%; }
    .stars-overlay .star-button[data-star="2"] { --star-x: 50%; --star-y: 12%; }
    .stars-overlay .star-button[data-star="3"] { --star-x: 84%; --star-y: 16%; }
    .stars-overlay .star-button[data-star="4"] { --star-x: 16%; --star-y: 56%; }
    .stars-overlay .star-button[data-star="5"] { --star-x: 50%; --star-y: 52%; }
    .stars-overlay .star-button[data-star="6"] { --star-x: 84%; --star-y: 56%; }
    .stars-overlay .stars-monty { height: 26%; }
    .stars-overlay .stars-teddy { height: 12%; }
    .stars-overlay .stars-cushion { width: 16%; opacity: 0.8; }
}
/* On the narrowest portrait phones a single row of six 56px targets cannot
   fit without their hit areas touching. Fold the constellation into two
   staggered rows while keeping every star in the sky band. */
@media (max-width: 384px) {
    .star-button[data-star="1"] { --star-x: 16%; --star-y: 16%; }
    .star-button[data-star="2"] { --star-x: 50%; --star-y: 12%; }
    .star-button[data-star="3"] { --star-x: 84%; --star-y: 16%; }
    .star-button[data-star="4"] { --star-x: 16%; --star-y: 46%; }
    .star-button[data-star="5"] { --star-x: 50%; --star-y: 42%; }
    .star-button[data-star="6"] { --star-x: 84%; --star-y: 46%; }
}
.stars-monty {
    position: absolute;
    left: 42%;
    bottom: 1%;
    z-index: 2;
    height: 42%;
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.35));
}
.stars-teddy {
    position: absolute;
    left: 67%;
    bottom: 3%;
    z-index: 2;
    height: 18%;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}
.stars-cushion {
    position: absolute;
    left: 30%;
    bottom: 1%;
    z-index: 1;
    width: 24%;
    opacity: 0.9;
}
.shooting-star {
    position: absolute;
    top: 12%;
    left: -20%;
    z-index: 4;
    width: 92px;
    height: 2px;
    background: linear-gradient(90deg, #fff6c9, rgba(255, 246, 201, 0));
    transform: rotate(12deg);
    animation: shooting-star 1.8s ease-out;
}
.shooting-star[hidden] { display: none; }
@keyframes shooting-star {
    0% { left: -20%; top: 10%; opacity: 0; }
    15% { opacity: 1; }
    100% { left: 110%; top: 36%; opacity: 0; }
}

/* ─── Play journal ──────────────────────────────────────────── */
.journal-modal {
    width: min(92vw, 560px);
    max-height: min(92vh, 760px);
    padding: 0;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-xl);
    background: var(--surface-container-lowest);
    color: var(--on-surface);
    box-shadow: var(--shadow-modal);
}
.journal-modal::backdrop { background: rgba(24, 38, 32, 0.55); }
.journal-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    max-height: inherit;
    overflow-y: auto;
}
.journal-head {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding-bottom: 0.4rem;
    background: var(--surface-container-lowest);
}
.journal-player { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.journal-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.7);
    border: 2px solid var(--glass-edge);
}
.journal-kicker {
    margin: 0;
    font-family: var(--font-headline);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--on-surface-variant);
}
.journal-title {
    margin: 0;
    font-family: var(--font-headline);
    font-size: clamp(1.1rem, 3.2vw, 1.4rem);
    color: var(--ink);
}
.journal-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
.journal-stat {
    padding: 0.55rem 0.65rem;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-lg);
    background: var(--panel-soft);
}
.journal-stat-value {
    margin: 0;
    font-family: var(--font-headline);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ink);
}
.journal-stat-label {
    margin: 0.1rem 0 0;
    font-family: var(--font-headline);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--on-surface-variant);
}
.journal-stat-hint { margin: 0.1rem 0 0; font-size: 0.75rem; color: var(--on-surface-variant); }
.journal-badges { display: flex; flex-wrap: wrap; gap: 0.35rem; min-height: 1.5rem; }
.journal-chip {
    padding: 0.25rem 0.55rem;
    border: 1.5px solid var(--gold);
    border-radius: var(--radius-full);
    background: var(--panel-strong);
    color: var(--ink);
    font-family: var(--font-headline);
    font-size: 0.75rem;
    font-weight: 700;
}
.journal-empty { margin: 0; font-size: 0.8rem; color: var(--on-surface-variant); }
.journal-section-title {
    margin: 0 0 0.1rem;
    font-family: var(--font-headline);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--on-surface-variant);
}
.journal-players { display: flex; flex-direction: column; gap: 0.4rem; }
.journal-players[hidden] { display: none; }
.journal-player-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-lg);
    background: var(--panel-soft);
}
.journal-player-row--active { border-color: var(--gold); }
.journal-player-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--glass-edge);
}
.journal-player-body { flex: 1; min-width: 0; }
.journal-player-heading { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.journal-player-name {
    margin: 0;
    font-family: var(--font-headline);
    font-weight: 700;
    color: var(--ink);
}
.journal-player-tag {
    margin-left: 0.35rem;
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-full);
    background: var(--gold);
    color: #3a2a1e;
    font-size: 0.65rem;
}
.journal-player-meta { margin: 0.05rem 0 0; font-size: 0.72rem; color: var(--on-surface-variant); }
.journal-player-when { font-size: 0.7rem; color: var(--on-surface-variant); white-space: nowrap; }
.journal-tips { display: flex; flex-direction: column; gap: 0.25rem; }
.journal-tips[hidden] { display: none; }
.journal-tip-list {
    margin: 0;
    padding-left: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.8rem;
    line-height: 1.35;
    color: var(--on-surface-variant);
}
.journal-tip-list li::marker { color: var(--gold); }
.journal-note {
    margin: 0;
    text-align: center;
    font-size: 0.72rem;
    color: var(--on-surface-variant);
}

/* ─── Captions ──────────────────────────────────────────────── */
.voice-caption {
    position: fixed;
    left: 50%;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 0.9rem);
    transform: translateX(-50%);
    z-index: 70;
    max-width: min(92vw, 640px);
    padding: 0.55rem 0.9rem;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-lg);
    background: rgba(255, 251, 240, 0.97);
    color: var(--ink);
    font-family: var(--font-headline);
    font-size: clamp(0.85rem, 2.6vw, 1rem);
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
    box-shadow: var(--shadow-card);
    pointer-events: none;
}
.voice-caption[hidden] { display: none; }

/* ─── Backyard weather ──────────────────────────────────────── */
.weather-overlay {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: none;
    overflow: hidden;
    pointer-events: none;
    /* Drops fall by the overlay's own height (cqh) on a transform. Animating
       top laid out and repainted the room on every frame (about 70 layouts a
       second, measured). */
    container-type: size;
}
body[data-screen="room"][data-room="backyard"][data-weather="rain"] .weather-overlay,
body[data-screen="room"][data-room="backyard"][data-weather="snow"] .weather-overlay { display: block; }
body[data-weather="rain"] .weather-overlay {
    background: linear-gradient(180deg, rgba(95, 125, 155, 0.34), rgba(95, 125, 155, 0.1) 45%, rgba(80, 110, 140, 0.04));
}
body[data-weather="snow"] .weather-overlay {
    background: linear-gradient(180deg, rgba(225, 238, 250, 0.3), rgba(230, 240, 250, 0.1) 50%, rgba(230, 240, 250, 0.04));
}
.weather-drop, .weather-flake {
    position: absolute;
    top: -12%;
    display: none;
    pointer-events: none;
}
body[data-weather="rain"] .weather-drop {
    display: block;
    width: 2px;
    height: 14px;
    border-radius: 1px;
    background: rgba(205, 230, 255, 0.85);
    transform: rotate(8deg);
    animation-name: weather-fall;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}
body[data-weather="snow"] .weather-flake {
    display: block;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 3px rgba(255, 255, 255, 0.9);
    animation-name: weather-drift;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}
@keyframes weather-fall {
    0% { transform: translateY(0) rotate(8deg); opacity: 0; }
    12% { opacity: 0.9; }
    100% { transform: translateY(124cqh) rotate(8deg); opacity: 0.1; }
}
@keyframes weather-drift {
    0% { transform: translate(0, 0); opacity: 0; }
    12% { opacity: 0.95; }
    50% { transform: translate(7px, 60cqh); }
    100% { transform: translate(-5px, 120cqh); opacity: 0.15; }
}
.weather-flake { top: -10%; }
/* Browsers without container units keep the old falling motion. */
@supports not (height: 1cqh) {
    @keyframes weather-fall {
        0% { top: -12%; opacity: 0; }
        12% { opacity: 0.9; }
        100% { top: 112%; opacity: 0.1; }
    }
    @keyframes weather-drift {
        0% { top: -10%; transform: translateX(0); opacity: 0; }
        12% { opacity: 0.95; }
        50% { transform: translateX(7px); }
        100% { top: 110%; transform: translateX(-5px); opacity: 0.15; }
    }
}
.weather-rainbow {
    position: absolute;
    display: none;
    top: 3%;
    left: 50%;
    z-index: 8;
    width: 46%;
    max-width: 260px;
    transform: translateX(-50%);
    pointer-events: none;
    filter: drop-shadow(0 6px 10px rgba(30, 58, 49, 0.2));
    animation: weather-rainbow-in 4.5s ease-in-out forwards;
}
body[data-screen="room"][data-room="backyard"] .weather-rainbow { display: block; }
@keyframes weather-rainbow-in {
    0% { opacity: 0; transform: translateX(-50%) scale(0.8); }
    12% { opacity: 1; }
    75% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) scale(1.03); }
}
.weather-puddles {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: none;
    pointer-events: none;
}
body[data-screen="room"][data-room="backyard"][data-weather="rain"] .weather-puddles { display: block; }
.weather-puddle {
    position: absolute;
    min-width: 56px;
    min-height: 44px;
    padding: 0;
    border: 1px solid rgba(120, 160, 190, 0.55);
    border-radius: 50%;
    background: radial-gradient(ellipse at 50% 45%, rgba(180, 220, 245, 0.85), rgba(90, 140, 180, 0.45) 70%);
    box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.4);
    pointer-events: auto;
    cursor: pointer;
}
.weather-puddle::after {
    content: '';
    position: absolute;
    left: 18%;
    top: 22%;
    width: 38%;
    height: 20%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.38);
    pointer-events: none;
}
.weather-puddle--splash { animation: puddle-splash 0.65s ease-out; }
@keyframes puddle-splash {
    0% { transform: scale(1); }
    30% { transform: scale(1.12); }
    100% { transform: scale(1); }
}
.weather-btn {
    position: absolute;
    top: 0.6rem;
    left: 0.6rem;
    z-index: 15;
    display: none;
}
body[data-screen="room"][data-room="backyard"] .weather-btn { display: grid; }
.weather-icon { display: none; width: 24px; height: 24px; }
body[data-weather="sunny"] .weather-icon--sun,
body[data-weather="rain"] .weather-icon--rain,
body[data-weather="snow"] .weather-icon--snow { display: block; }

/* ─── Music time ────────────────────────────────────────────── */
.music-modal {
    width: min(92vw, 520px);
    max-height: min(92vh, 760px);
    padding: 0;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-xl);
    background: var(--surface-container-lowest);
    color: var(--on-surface);
    box-shadow: var(--shadow-modal);
}
.music-modal::backdrop { background: rgba(24, 38, 32, 0.55); }
.music-content {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 1rem;
    max-height: inherit;
    overflow-y: auto;
}
.music-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.music-title {
    margin: 0;
    font-family: var(--font-headline);
    font-size: clamp(1.15rem, 3.4vw, 1.5rem);
    color: var(--ink);
}
.music-modes { display: flex; gap: 0.4rem; }
.music-mode {
    flex: 1;
    min-height: 44px;
    padding: 0.35rem 0.5rem;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-full);
    background: var(--panel-soft);
    color: var(--ink);
    font-family: var(--font-headline);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
}
.music-mode--on { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(246, 196, 83, 0.3); }
.music-mode:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; }
.music-stage {
    position: relative;
    height: min(30vh, 230px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 0.5rem;
    overflow: hidden;
    border-radius: var(--radius-lg);
    background: radial-gradient(circle at 50% 25%, #fff8e6, #f7e7c5 70%);
}
.music-monty { height: 76%; object-fit: contain; filter: drop-shadow(0 8px 10px rgba(30, 58, 49, 0.25)); }
.music-friend { height: 30%; object-fit: contain; filter: drop-shadow(0 5px 8px rgba(30, 58, 49, 0.2)); }
.music-friend--left { margin-bottom: 6%; margin-left: 4%; }
.music-friend--right { margin-bottom: 3%; margin-right: 2%; }
.music-note {
    position: absolute;
    z-index: 3;
    font-size: 1.3rem;
    color: var(--gold);
    text-shadow: 0 1px 3px rgba(30, 58, 49, 0.35);
    pointer-events: none;
    animation: music-float 1s ease-out forwards;
}
.music-hint {
    margin: 0;
    min-height: 1.2rem;
    text-align: center;
    font-family: var(--font-headline);
    font-weight: 700;
    color: var(--on-surface-variant);
}
.music-instruments { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.45rem; }
.music-instrument {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: 92px;
    padding: 0.35rem;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-lg);
    background: var(--panel-soft);
    color: var(--ink);
    font-family: var(--font-headline);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
}
.music-instrument img { width: 52px; height: 52px; object-fit: contain; display: block; }
.music-instrument:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; }
.music-progress { display: flex; justify-content: center; gap: 0.4rem; min-height: 14px; }
.music-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1.5px solid rgba(30, 58, 49, 0.3);
    background: #f6eedf;
}
.music-dot--on { border-color: var(--gold); background: var(--gold); }
.music-stage--playing .music-monty { animation: music-bounce 0.46s ease-out; }
.music-stage--playing .music-friend { animation: music-bounce 0.46s ease-out 0.05s; }
.music-instrument--hit { animation: music-pulse 0.42s ease-out; }

@keyframes music-bounce {
    0%, 100% { transform: translateY(0) rotate(0); }
    35% { transform: translateY(-8%) rotate(-2deg); }
    70% { transform: translateY(-3%) rotate(2deg); }
}
@keyframes music-pulse {
    0%, 100% { transform: scale(1); }
    40% { transform: scale(1.07); }
}
@keyframes music-float {
    0% { opacity: 0.9; transform: translateY(0) rotate(-6deg); }
    100% { opacity: 0; transform: translateY(-44px) rotate(8deg); }
}

/* ─── Story time ────────────────────────────────────────────── */
.story-modal {
    /* The global margin reset would pin a modal dialog to the top-left. */
    margin: auto;
    width: min(92vw, 560px);
    max-height: min(92vh, 860px);
    padding: 0;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-xl);
    background: var(--surface-container-lowest);
    color: var(--on-surface);
    box-shadow: var(--shadow-modal);
}
.story-modal::backdrop { background: rgba(24, 38, 32, 0.55); }
.story-content {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 1rem;
    max-height: inherit;
    overflow-y: auto;
}
.story-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.story-head-actions { display: flex; align-items: center; gap: 0.4rem; }
.story-shelf { display: flex; flex-direction: column; gap: 0.75rem; }
.story-shelf[hidden], .story-reader[hidden] { display: none; }
.story-head-actions .btn-small { min-height: 44px; min-width: 44px; }
/* One big picture-led row per book: a large cover, a big title, and a play
   badge so it reads as "tap to hear this one". */
.story-card {
    position: relative;
    display: grid;
    grid-template-columns: minmax(112px, 40%) 1fr;
    grid-template-rows: 1fr 1fr;
    align-items: center;
    column-gap: 0.85rem;
    min-height: 140px;
    padding: 0.5rem 4rem 0.5rem 0.5rem;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-lg);
    background: var(--panel-soft);
    color: var(--ink);
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.12s ease;
}
.story-card:active { transform: scale(0.97); }
.story-card:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; }
.story-card img {
    grid-row: 1 / 3;
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, #fff8e6, #f3f7fb);
}
.story-card--night img { background: linear-gradient(180deg, #26344d, #3d5470); }
.story-card-title { grid-column: 2; grid-row: 1; align-self: end; font-family: var(--font-headline); font-weight: 800; font-size: 1.25rem; line-height: 1.15; }
.story-card-sub { grid-column: 2; grid-row: 2; align-self: start; padding-top: 0.25rem; font-size: 0.95rem; color: var(--on-surface-variant); }
.story-card-play {
    position: absolute;
    top: 50%;
    right: 0.7rem;
    width: 44px;
    height: 44px;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 1.1rem;
    padding-left: 3px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
.story-reader { display: flex; flex-direction: column; gap: 0.55rem; }
.story-book {
    margin: 0;
    font-family: var(--font-headline);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--on-surface-variant);
}
.story-art {
    aspect-ratio: 4 / 3;
    max-height: min(44vh, 380px);
    width: 100%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, #fff8e6, #f3f7fb);
}
.story-art img { width: 100%; height: 100%; object-fit: cover; }
.story-art--night { background: linear-gradient(180deg, #26344d, #3d5470); }
.story-title {
    margin: 0;
    font-family: var(--font-headline);
    font-size: clamp(1.15rem, 3.4vw, 1.5rem);
    color: var(--ink);
}
.story-text { margin: 0; color: var(--ink); font-size: 1.05rem; line-height: 1.55; }
.story-actions { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.story-actions .btn-primary,
.story-actions .btn-secondary { min-height: 44px; }
.story-counter {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--on-surface-variant);
}
.story-actions .btn-secondary:disabled { opacity: 0.45; cursor: not-allowed; }

/* ─── Players ───────────────────────────────────────────────── */
.profile-chip {
    position: fixed;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 30;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 56px;
    max-width: 52vw;
    padding: 0.25rem 0.8rem 0.25rem 0.3rem;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-full);
    background: var(--panel-strong);
    color: var(--ink);
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: var(--shadow-card);
    cursor: pointer;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}
.profile-chip-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--glass-edge);
}
.profile-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-chip:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; }

.profile-modal {
    width: min(92vw, 520px);
    max-height: min(90vh, 720px);
    padding: 0;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-xl);
    background: var(--surface-container-lowest);
    color: var(--on-surface);
    box-shadow: var(--shadow-modal);
}
.profile-modal::backdrop { background: rgba(24, 38, 32, 0.55); }
.profile-content {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding: 1rem;
    max-height: inherit;
    overflow-y: auto;
}
.profile-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.profile-title {
    margin: 0;
    font-family: var(--font-headline);
    color: var(--ink);
    font-size: clamp(1.15rem, 3.2vw, 1.5rem);
}
.profile-list { display: flex; flex-direction: column; gap: 0.5rem; }
.profile-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 56px;
    padding: 0.35rem 0.7rem;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-lg);
    background: var(--panel-soft);
    color: var(--ink);
    font-family: var(--font-headline);
    font-weight: 700;
    cursor: pointer;
    text-align: left;
}
.profile-row--active { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(246, 196, 83, 0.3); }
.profile-row:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; }
.profile-row-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.7);
}
.profile-row-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-row-tag { font-size: 0.72rem; color: var(--on-surface-variant); }
.profile-manage-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 44px;
}
.profile-manage-row .profile-row-name { flex: 1; }
.profile-manage-actions { display: flex; flex-shrink: 0; gap: 0.3rem; }
.profile-manage-actions .btn-secondary { min-height: 44px; padding: 0 0.6rem; }
.profile-remove { min-height: 44px; }

.profile-add {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.6rem;
    border: 1px dashed var(--glass-edge);
    border-radius: var(--radius-lg);
}
.profile-add[hidden] { display: none; }
.profile-label { font-family: var(--font-headline); font-weight: 700; color: var(--ink); }
.profile-input {
    min-height: 44px;
    padding: 0.4rem 0.6rem;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-md);
    background: var(--panel-strong);
    color: var(--ink);
    font-family: var(--font-body, system-ui, sans-serif);
    font-size: 1rem;
}
.profile-input:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; }
.profile-avatars {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
    gap: 0.4rem;
}
.profile-avatar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    min-height: 72px;
    padding: 0.3rem;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    background: var(--panel-soft);
    color: var(--ink);
    font-family: var(--font-headline);
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
}
.profile-avatar[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(246, 196, 83, 0.3); }
.profile-avatar:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; }
.profile-avatar img { width: 40px; height: 40px; object-fit: contain; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.profile-actions .btn-primary,
.profile-actions .btn-secondary { min-height: 44px; }

/* Hidden until the stage has room actors; the tutorial points at Monty. */
.drag-tutorial {
    position: absolute;
    left: 50%;
    top: 22%;
    transform: translateX(-50%);
    z-index: 24;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.6rem 1rem;
    background: var(--panel-strong);
    border: 2px solid var(--ink);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    pointer-events: none;
}
.drag-tutorial p {
    margin: 0;
    font-family: var(--font-headline);
    font-weight: 700;
    color: var(--ink);
}
.tutorial-hand {
    font-size: 1.8rem;
    animation: tutorial-drag 1.8s ease-in-out infinite;
}

/* The night tint and bath effect live on the stage, below the actors. */
#room-stage::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.6s ease;
    background: radial-gradient(circle at 22% 30%, rgba(255, 226, 148, 0.18), rgba(24, 30, 78, 0.5) 70%);
}
#room-stage.night::after { opacity: 1; }
#room-stage.night { box-shadow: inset 0 0 0 2px rgba(155, 169, 255, 0.55); }

.actor-swinging .actor-img { animation: fx-swing 2.4s ease-in-out infinite; transform-origin: 50% -10%; }

/* Toy chest trail and tray */
.chest-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 44px;
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--ink);
    background: var(--panel-strong);
    border: 2px solid var(--ink);
    border-radius: var(--radius-full);
    padding: 0.35rem 0.85rem;
    box-shadow: var(--shadow-card);
}
/* The chest is a picture, not a word: pre-readers find it by the wooden
   chest and their own toy peeking out. The lid lifts while the tray is open. */
.chest-art {
    position: relative;
    display: inline-block;
    width: 2.6rem;
    height: 2.3rem;
    flex-shrink: 0;
}
.chest-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}
.chest-lid {
    transform-box: view-box;
    transform-origin: 6px 26px;
    transition: transform 0.25s ease;
}
.chest-btn[aria-expanded="true"] .chest-lid { transform: rotate(-24deg) translateY(-2px); }
/* The peeking toy is drawn between the chest body and the lid, so the closed
   lid hides all but its top and the open lid shows it sitting in the chest. */
.chest-peek {
    transform-box: view-box;
    transition: transform 0.25s ease;
    pointer-events: none;
}
.chest-btn[aria-expanded="true"] .chest-peek { transform: translateY(-4px); }
.chest-flash { animation: chest-flash 1.2s ease; }
.toy-chest-tray {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    max-height: 52%;
    overflow-y: auto;
    padding: 0.6rem 0.7rem 0.7rem;
    /* No backdrop blur: the panel is 90% opaque already, and the blur was
       redone on every frame anything under it moved (3-4x the compositing
       cost of a closed chest, measured). */
    background: var(--panel-strong);
    border-top: 2px solid var(--ink);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -10px 30px rgba(30, 58, 49, 0.22);
}
.chest-tray-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.chest-tray-actions { display: flex; gap: 0.4rem; }
.chest-empty-hint { margin: 0.2rem 0 0.4rem; font-size: 0.85rem; color: var(--on-surface-variant); }
.toy-chest-tray .chip-tray {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    padding-bottom: 0.3rem;
    /* The chest panel under it is opaque enough; a second blur here was
       redone on every frame Monty or a toy moved over the chest. */
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}
.chest-chip--food .chip-img { transform: scale(0.92); }

/* Hub door picture cues + the fifth door on the porch side */
.door-icon {
    position: absolute;
    left: 50%;
    top: 24%;
    width: 44%;
    height: auto;
    transform: translateX(-50%);
    filter: drop-shadow(0 3px 3px rgba(30, 58, 49, 0.25));
    pointer-events: none;
}
.door-hint--side { top: 34%; height: 30%; }
.door-hint--side .door-icon { width: 52%; top: 18%; }
.door-hint--side span { bottom: -18%; }

/* ── Activities: bedtime, garden, bath, dress-up ─────────────── */
.bedtime-scene {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    flex: 1;
    min-height: 0;
    padding: 0.4rem;
}
.bedtime-monty {
    position: relative;
    width: min(42%, 280px);
    aspect-ratio: 1;
    border: 0;
    background: transparent;
    padding: 0;
}
.bedtime-monty img { width: 100%; height: 100%; object-fit: contain; }
.bedtime-steps {
    display: grid;
    grid-template-columns: repeat(2, minmax(74px, 1fr));
    gap: 0.5rem;
    max-width: 320px;
}
.bedtime-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    min-height: 74px;
    padding: 0.35rem;
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--ink);
    background: var(--panel-strong);
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-md);
}
.bedtime-step img { width: 52px; height: 52px; object-fit: contain; }
.bedtime-step.step-next { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(246, 196, 83, 0.3); animation: hint-pulse 1.8s ease-in-out infinite; }
.bedtime-step.step-done { opacity: 0.55; border-color: var(--sage, #86c4a0); }
#bedtime-overlay.bedtime-night {
    background: linear-gradient(180deg, rgba(30, 34, 76, 0.92), rgba(18, 24, 54, 0.97));
}
#bedtime-overlay.bedtime-night .activity-title,
#bedtime-overlay.bedtime-night .tray-hint { color: #f6f0ff; }
#bedtime-overlay.bedtime-night .bedtime-step { background: rgba(255, 255, 255, 0.16); color: #f6f0ff; }

.garden-scene {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 0.4rem;
    flex: 1;
    min-height: 0;
    padding: 0.5rem 2.2rem 0.5rem 0.5rem;
}
.garden-plot {
    position: relative;
    width: 30%;
    max-width: 210px;
    aspect-ratio: 1;
    border: 2px dashed transparent;
    border-radius: var(--radius-md);
    background: transparent;
    padding: 0;
}
.garden-plot:hover, .garden-plot:focus-visible { border-color: var(--gold); }
.garden-plot img { width: 100%; height: auto; object-fit: contain; }
.garden-plot .plot-plant {
    position: absolute;
    left: 50%;
    bottom: 34%;
    width: 74%;
    transform: translateX(-50%);
    animation: none;
}
.garden-plot.plot-grow .plot-plant { animation: plot-grow 0.6s ease; }
.garden-can {
    position: absolute;
    right: 0.4rem;
    bottom: 0.6rem;
    width: 20%;
    max-width: 120px;
    transform: rotate(-8deg);
}
.garden-can.watering { animation: can-tip 2.4s ease-in-out infinite; }

.bath-scene {
    position: relative;
    flex: 1;
    min-height: 0;
    margin: 0.2rem auto;
    width: min(88%, 560px);
}
.bath-toy { position: absolute; z-index: 3; width: 13%; pointer-events: none; animation: bath-bob 3.2s ease-in-out infinite; }
.bath-toy--ball { left: 44%; bottom: 40%; }
.bath-toy--boat { left: 8%; bottom: 44%; width: 15%; animation-delay: -1.1s; }
.bath-toy--fish { left: 30%; bottom: 36%; animation-delay: -2.2s; }
.bath-rim { position: absolute; z-index: 5; width: 10%; pointer-events: none; }
.bath-rim--sponge { left: 74%; bottom: 8%; }
.bath-rim--soap { left: 86%; bottom: 8%; }
.bath-scene.bath-dry .bath-toy { opacity: 0.6; }
@keyframes bath-bob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-6px) rotate(3deg); } }
.bath-monty {
    position: absolute;
    left: 6%;
    bottom: 18%;
    width: 56%;
    z-index: 2;
}
.bath-foam {
    position: absolute;
    left: 2%;
    bottom: 22%;
    width: 64%;
    z-index: 3;
    pointer-events: none;
}
.bath-tub-front {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 72%;
    z-index: 4;
    pointer-events: none;
}
.bath-duck {
    position: absolute;
    left: 56%;
    right: auto;
    bottom: 30%;
    width: 16%;
    z-index: 3;
    padding: 0;
    border: 0;
    background: transparent;
    transform: translateY(-40px);
    opacity: 0;
    transition: transform 0.4s ease, opacity 0.3s ease;
}
.bath-duck.duck-in { transform: translateY(0); opacity: 1; }
.bath-duck img { width: 100%; }
.bath-tap {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: transparent;
    border: 0;
}
.bath-bubble {
    position: absolute;
    cursor: pointer;
    pointer-events: auto;
    width: 8%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #ffffff, rgba(200, 230, 255, 0.55) 60%, rgba(180, 210, 255, 0.25));
    border: 1px solid rgba(255, 255, 255, 0.8);
    animation: bath-bubble 1.2s ease forwards;
    pointer-events: none;
    z-index: 5;
}
.bath-scene.bath-dry .bath-monty { animation: shake-dry 0.6s ease 2; }

.dressup-scene {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dressup-preview-box {
    position: relative;
    isolation: isolate;
    width: min(52vh, 44vw, 300px);
    aspect-ratio: 1;
}
.dressup-preview-box > img,
.dressup-preview-box > span { position: absolute; inset: 0; width: 100%; height: 100%; }
.dressup-preview-box > img { object-fit: contain; }
.dressup-preview-box > span { pointer-events: none; }
.dressup-preview-box .outfit-layer { position: absolute; }
.dressup-scene + .tray-row { flex-wrap: wrap; }

/* Animation vocabulary */
@keyframes actor-pop { 0% { transform: translate(-50%, -92%) scale(1); } 40% { transform: translate(-50%, -92%) scale(1.08); } 100% { transform: translate(-50%, -92%) scale(1); } }
.actor-pop { animation: actor-pop 0.42s ease; }
@keyframes prop-pop { 0%, 100% { transform: translate(-50%, -96%) scale(1); } 50% { transform: translate(-50%, -96%) scale(1.16); } }
.prop-pop { animation: prop-pop 0.38s ease; }
@keyframes prop-bounce { 0%, 100% { transform: translate(-50%, -96%); } 30% { transform: translate(-50%, -120%); } 60% { transform: translate(-50%, -96%) scaleY(0.92); } }
.prop-bounce { animation: prop-bounce 0.85s ease; }
.prop-float { animation: prop-float 2.6s ease-in-out infinite; }
@keyframes prop-float { 0%, 100% { transform: translate(-50%, -96%); } 50% { transform: translate(-50%, -108%) rotate(4deg); } }
@keyframes held-bob { 0%, 100% { transform: translate(-50%, -50%) rotate(-10deg); } 50% { transform: translate(-50%, -58%) rotate(-4deg); } }
@keyframes chest-flash { 0%, 100% { transform: scale(1); } 35% { transform: scale(1.12); box-shadow: 0 0 0 6px rgba(246, 196, 83, 0.5); } }
@keyframes tutorial-drag { 0%, 100% { transform: translate(-18px, 6px); } 50% { transform: translate(18px, -2px); } }
@keyframes plot-grow { 0% { transform: translateX(-50%) scale(0.6); } 70% { transform: translateX(-50%) scale(1.08); } 100% { transform: translateX(-50%) scale(1); } }
@keyframes can-tip { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(-24deg) translateY(-4px); } }
@keyframes bath-bubble { 0% { transform: translateY(20px) scale(0.4); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(-70px) scale(1.15); opacity: 0; } }
@keyframes shake-dry { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }

/* Keep the new surfaces legible in the OS accessibility modes. */
@media (prefers-contrast: more), (forced-colors: active) {
    .stage-actor,
    .stage-prop,
    .stage-container,
    .stage-tool,
    .album-modal,
    .album-tile,
    .mail-modal,
    .day-modal,
    .winddown-modal,
    .profile-modal,
    .profile-chip,
    .profile-row,
    .profile-avatar,
    .profile-input,
    .room-picture,
    .story-modal,
    .music-modal,
    .music-stage,
    .music-instrument,
    .music-mode,
    .voice-caption,
    .setting-select,
    .chest-btn,
    .toy-chest-tray,
    .bedtime-step,
    .garden-plot,
    .bath-scene,
    .drag-tutorial {
        background: Canvas;
        border: 2px solid CanvasText;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
    .stage-actor, .stage-prop, .bedtime-monty, .garden-plot, .bath-tap { border: 0; }
    .stage-zone { border-color: CanvasText; background: Canvas; }
    .actor-img, .prop-img, .outfit-layer, .bath-monty, .bath-foam, .bath-tub-front,
    .bedtime-monty img, .plot-plant, .garden-can, .door-icon,
    .layer-lamp-on, .layer-lamp-off, .layer-fridge-open, .layer-fridge-closed,
    .layer-bed-down, .layer-wardrobe-open, .layer-wardrobe-closed {
        forced-color-adjust: none;
    }
    .bedtime-step.step-next { border-color: Highlight; }
}

@media (prefers-reduced-motion: reduce) {
    .stage-actor, .stage-prop { transition: none; }
    .room-wash { transition: none; }
    .room-cushion--pop { animation: none !important; }
    .stage-actor.dragging, .stage-prop.dragging,
    .actor-pop, .prop-pop, .prop-bounce, .prop-float, .held-prop,
    .actor-swinging .actor-img, .tutorial-hand, .chest-flash,
    .garden-plot.plot-grow .plot-plant, .garden-can.watering,
    .bath-bubble, .bath-scene.bath-dry .bath-monty,
    .music-note, .music-instrument--hit,
    .music-stage--playing .music-monty,
    .music-stage--playing .music-friend,
    .weather-drop, .weather-flake,
    .bedtime-step.step-next { animation: none !important; }
    .weather-drop, .weather-flake { display: none !important; }
    .weather-rainbow { animation: none !important; opacity: 1; }
    .weather-puddle--splash { animation: none !important; }
    .shooting-star { animation: none !important; }
    .puppet-performer { animation: none !important; }
    .star-button__shape, .star-button::before, .star-button::after { animation: none !important; }
    .star-button__shape { transition: none !important; }
    .star-button:active .star-button__shape { transform: none; }
    .stars-wish-burst, .stars-spark { display: none !important; }
    .stars-wish-whisper { animation: none !important; opacity: 1; }
    .meadow-find { transition: none; }
    .tea-friend--served .tea-friend-img { animation: none !important; }
    .calm-petal, .calm-core { transition: opacity 1.5s ease-in-out !important; }
    .calm-petal { transform: rotate(var(--a)) translateY(-22%) scale(0.85) !important; opacity: 0.55; }
    .calm-breath--in .calm-petal { opacity: 0.95; }
    /* A pop-out still appears, so the tap still answers, but it only fades. */
    .scenery-pop { animation: pop-fade 1.6s ease-in-out both !important; }
    .stage-zone, #room-stage::after { transition: none; }
    #hub-stage { transition: none; }
    .stage-tool:active { transform: none; }
    #room-stage::before { transition: none; }
}

@media (max-width: 700px), (max-height: 700px) {
    .stage-actor { width: 34%; }
    .stage-actor--friend { width: 28%; }
    .stage-prop { width: 17%; }
    .toy-chest-tray { max-height: 58%; }
    .bedtime-scene { gap: 0.4rem; }
    .bedtime-monty { width: 44%; }
    .bedtime-steps { grid-template-columns: repeat(2, minmax(64px, 1fr)); gap: 0.35rem; }
    .bedtime-step { min-height: 62px; font-size: 0.72rem; }
    .bedtime-step img { width: 42px; height: 42px; }
    .garden-scene { padding-right: 1.6rem; }
    .chest-btn { font-size: 0.8rem; padding: 0.3rem 0.6rem; }
}

/* Stacking inside the stage: furniture hotspots sit under characters (so a
   character can stand on the couch), while hunt spots and activity buttons
   stay above them so a dropped toy never hides a tap target. Overlays and the
   chest tray always win. */
.hotspot { z-index: 2; }
.hunt-spot, .activity-button { z-index: 8; }
/* Characters ride above the activity buttons and search spots, so a button can
   never swallow a tap meant for Monty or a friend; toys stay beneath them, so
   a toy dropped on a search spot cannot hide it. */
.stage-actor { z-index: 9; }
.stage-prop { z-index: 4; }
.activity-overlay { z-index: 20; }
/* The photo buttons and their album count sit under the translucent overlay;
   hide them while an activity is open so the count never peeks out by All done. */
body[data-activity] .stage-photo-tools { visibility: hidden; }
.hint-bubble, .toast { z-index: 22; }
.drag-tutorial { z-index: 24; }

/* The tutorial is toggled with the `hidden` attribute; the flex rule above
   must not outrank it. */
.drag-tutorial[hidden] { display: none; }
.layer-bubbles-small { display: none; }
.bubbles .layer-bubbles-small { display: block; }
.bath-tub-back {
    position: absolute;
    left: 0;
    bottom: 2%;
    width: 78%;
    z-index: 1;
    pointer-events: none;
}
.bath-towel {
    position: absolute;
    right: 2%;
    top: 8%;
    width: 26%;
    z-index: 5;
    transform: rotate(6deg);
}

/* Five doors along the verandah: 12.5% hit areas touch edge to edge (44px on
   the narrowest phone) so their hit areas never stack, and the label pills
   alternate above/below so five full names never overlap. Tighter labels on
   phones. */
.door-hint {
    width: 12.5%;
    top: 26%;
    height: 30%;
}
.door-hint .door-icon { width: 86%; top: 16%; }
.door-hint span { bottom: -24%; }
.door-hint--above span { bottom: auto; top: -22%; }
@media (max-width: 700px) {
    .door-hint span { font-size: 0.56rem; padding: 0.22rem 0.4rem; }
}

/* Dress-up preview: leave room above the actor's hat for the overlay title. */
.dressup-scene { padding-top: 7%; }
.dressup-preview-box { width: min(38vh, 40vw, 250px); }
@media (max-width: 700px) {
    .dressup-scene { padding-top: 9%; }
}

/* A newly found toy arcs across the room into the Toy Chest button. */
.flying-toy {
    position: fixed;
    width: 60px;
    height: 60px;
    object-fit: contain;
    z-index: 9999;
    pointer-events: none;
    filter: drop-shadow(0 6px 8px rgba(30, 58, 49, 0.35));
}

/* The room title must never wrap: the chest and hunt chips share its line. */
.room-title-plate h2 { white-space: nowrap; }
@media (max-width: 480px) {
    .chest-btn { padding: 0.3rem 0.5rem; gap: 0.25rem; }
    .chest-label { display: none; }
    .room-title-plate h2 { padding: 0.35rem 0.9rem; font-size: 1rem; }
}

/* Activity overlays own the stage: the free-play actor would otherwise show
   through the overlay next to the activity's own Monty. */
body[data-activity] .stage-actor-layer { visibility: hidden; }

/* Dress-up preview has to clear the title above and the tray below. */
.dressup-scene { padding-top: 10%; }
.dressup-preview-box { width: min(38vw, 200px, 30vh); }

/* Final dress-up fit: 12% of the stage clears the title, and the preview is
   sized so the hat's overflow stays inside that gap. */
.dressup-scene { padding-top: 12%; }
.dressup-preview-box { width: min(30vw, 160px, 22vh); }

/* Dress-up on a phone: title row holds Mirror, the tray is chips only, and
   the preview fits in the remaining band. */
#dressup-overlay .activity-topline { flex-wrap: nowrap; }
#dressup-overlay .activity-title { font-size: clamp(0.9rem, 3vw, 1.2rem); }
#dressup-overlay .tray-row { gap: 0.3rem; }
#dressup-overlay .tray-hint { font-size: 0.72rem; }
@media (max-width: 480px) {
    #dressup-overlay .activity-title { white-space: nowrap; }
    #dressup-overlay .btn-small { padding: 0.3rem 0.5rem; font-size: 0.75rem; }
}

#dressup-overlay .dressup-scene { padding-top: 6%; }
#dressup-overlay .dressup-preview-box { width: min(26vw, 140px, 20vh); }

/* A strawberry picked in the garden is marked in the picnic tray. */
.chip.garden-berry {
    box-shadow: 0 0 0 3px rgba(246, 196, 83, 0.85), 0 0 18px rgba(246, 196, 83, 0.55);
}

/* The global button family enforces a 56px minimum, which is right for pills
   but wrong for a percentage-positioned hotspot at the edge of the stage.
   Hotspots keep a 44px child-sized target, then their own width wins. */
.hotspot,
.hunt-spot,
.activity-button {
    min-width: 44px;
    min-height: 44px;
}

/* Badge toast on a short landscape phone: Back and the toy chest sit along
   the top here, so the toast drops low. */
@media (max-height: 520px) {
    .badge-toast { bottom: max(0.5rem, env(safe-area-inset-bottom)); }
    .badge-chip { min-height: 44px; }
}

/* ─── Rooms on portrait phones ───────────────────────────────
   The room art is square and every hotspot, zone and actor is placed in
   percentages of that square, so the stage stays square and can only be as
   wide as the phone. Instead of spending the spare height on the support
   footer, a room gets the whole screen: title on top, the stage edge to edge
   just under it, a thumb dock with big picture buttons at the bottom, and the
   space between becomes the toy chest shelf, so opening the chest no longer
   covers the room. */
body[data-screen="room"] .game-footer { display: none; }

@media (orientation: portrait) and (max-width: 700px) {
    #room-screen.active {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        grid-template-rows: auto auto minmax(0, 1fr) auto;
        align-items: center;
    }
    #room-screen .room-chrome { display: contents; }
    #room-screen .room-title-plate { grid-area: 1 / 1 / 2 / 4; padding: 0.6rem 1rem 0; }
    #room-screen .stage-frame { grid-area: 2 / 1 / 3 / 4; padding: 0.35rem; }
    #room-screen .stage {
        width: min(calc(100vw - 0.7rem), calc(100svh - 12rem));
        height: min(calc(100vw - 0.7rem), calc(100svh - 12rem));
    }
    #room-back-btn {
        grid-area: 4 / 1;
        justify-self: start;
        min-height: 64px;
        margin: 0 0 max(1rem, env(safe-area-inset-bottom)) 1rem;
        padding: 0.5rem 1.1rem;
    }
    #room-hunt-chip { grid-area: 4 / 2; min-height: 56px; margin-bottom: max(1rem, env(safe-area-inset-bottom)); }
    #toy-chest-btn {
        grid-area: 4 / 3;
        justify-self: end;
        min-height: 72px;
        min-width: 84px;
        justify-content: center;
        margin: 0 1rem max(1rem, env(safe-area-inset-bottom)) 0;
        padding: 0.4rem 0.9rem;
        border-radius: 1.4rem;
    }
    #toy-chest-btn .chest-art { width: 3.6rem; height: 3.2rem; }
    /* The shelf: fixed between the stage and the dock (the stage clips its
       children, a fixed box escapes that). Drops onto it still return a toy. */
    #room-screen .toy-chest-tray {
        position: fixed;
        left: 0.5rem;
        right: 0.5rem;
        bottom: calc(72px + 1.5rem + env(safe-area-inset-bottom));
        max-height: max(7.5rem, calc(100svh - 100vw - 11.5rem));
        border: 2px solid var(--ink);
        border-radius: var(--radius-lg);
    }
    body[data-activity] #room-screen .toy-chest-tray { display: none; }
}

/* The bathroom's own rubber ducky: a squeaky tub-side friend that is always
   there, not a hunt reward or a hidden step. */
.bath-ducky {
    position: absolute;
    left: 27%;
    top: 36%;
    width: 11%;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    z-index: 3;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.bath-ducky img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 3px 4px rgba(30, 58, 49, 0.3));
}
.bath-ducky:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 3px; border-radius: 50%; }
.bath-ducky.quack img { animation: duck-quack 0.55s ease; }
@keyframes duck-quack {
    0%, 100% { transform: rotate(0) translateY(0); }
    30% { transform: rotate(-14deg) translateY(-6px); }
    65% { transform: rotate(10deg) translateY(-2px); }
}

/* The bath-overlay duck is on the rim from the start; adding it is a tap,
   not a reward hidden behind three bubble taps. */
.bath-duck { transform: none; opacity: 1; }
.bath-duck.duck-in img { animation: duck-quack 0.55s ease; }
.bath-duck.duck-peek img { animation: duck-quack 0.55s ease; }


/* A bubble can be tapped to pop it, not only waited out. */
.bath-bubble-pop {
    animation: none !important;
    transform: scale(1.45);
    opacity: 0;
    transition: transform 0.18s ease, opacity 0.18s ease;
}

/* Garden stages: the soil bed stays put and the seed/growth is drawn on top. */
.plot-plant--1 { width: 34% !important; bottom: 42% !important; }
.plot-plant--2 { width: 50% !important; bottom: 36% !important; }
.plot-plant--3 { width: 64% !important; bottom: 34% !important; }
.plot-plant--4 { width: 78% !important; bottom: 30% !important; }

/* The update banner is fixed to the bottom of the viewport, which is exactly
   where the portrait room's thumb dock lives. Rooms keep the play controls
   clear: the banner reappears on the hub or home screen. */
body[data-screen="room"] .update-banner { display: none; }

/* After the towel, the wet bath pose is replaced by Monty standing on the
   floor wrapped in the towel; he is visibly out of the tub. */
.bath-monty-dry {
    position: absolute;
    left: 58%;
    bottom: 3%;
    width: 34%;
    z-index: 5;
    filter: drop-shadow(0 6px 10px rgba(20, 40, 32, 0.35));
    animation: dry-pop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes dry-pop {
    0% { transform: translateY(14%) scale(0.75); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}
.bath-scene.bath-dry .bath-duck { opacity: 0.9; }

/* The added duck moves from the rim into the water behind the front lip. */
.bath-duck { transition: left 0.35s ease, bottom 0.35s ease, transform 0.35s ease, opacity 0.3s ease; }
.bath-duck.duck-in { left: 56%; bottom: 40%; }

/* The room's tub-side duck would otherwise show through the translucent bath
   overlay as a second duck outside the tub. */
body[data-activity="bath"] #bathroom-duck { visibility: hidden; }

/* The added duck floats in the water, not on the rim. It sits above the tub
   front so the foam and the lip cannot hide it. */
.bath-duck { z-index: 6; }
.bath-duck.duck-in { left: 12%; bottom: 40%; width: 13%; }


/* The duck is the next step once the bath is full: make it visibly ready. */
.bath-duck.ready {
    filter: drop-shadow(0 0 8px rgba(246, 196, 83, 0.95));
    animation: duck-ready 1.2s ease-in-out infinite;
}
@keyframes duck-ready {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-4px) scale(1.06); }
}

/* The towel sits on the floor next to the bath once the duck is in; it is the
   last tap, not a button in the tray. */
.bath-towel-prop {
    position: absolute;
    left: 81%;
    bottom: 7%;
    width: 17%;
    padding: 0;
    border: 0;
    background: transparent;
    z-index: 7;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    filter: drop-shadow(0 5px 8px rgba(20, 40, 32, 0.32));
}
.bath-towel-prop img { width: 100%; height: auto; display: block; }
.bath-towel-prop:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 3px; border-radius: var(--radius-md); }
.bath-towel-prop[hidden] { display: none; }

/* ── Bespoke back controls ──────────────────────────────────────
   The playhouse back buttons are little painted signposts, not the browser's
   default grey button. The room one points back to the yard; the collection
   ones carry Monty's paw. */
.btn-back.back-plank {
    --btn-depth: 4px;
    --btn-lip: #c49a4f;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 1.05rem 0.5rem 0.55rem;
    min-width: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 18% 22%, rgba(255, 255, 255, 0.9), transparent 42%),
        linear-gradient(180deg, #fff9e8 0%, #f7e7bf 100%);
    border: 2px solid var(--ink);
    border-radius: 1.15rem;
    box-shadow:
        inset 0 1px 0 #ffffff,
        0 4px 0 var(--btn-lip),
        0 8px 16px rgba(30, 58, 49, 0.16);
    font-family: var(--font-headline);
    font-size: 1rem;
    letter-spacing: 0.01em;
    cursor: pointer;
    white-space: nowrap;
}
.btn-back.back-plank:hover {
    filter: brightness(1.03);
    transform: translateY(-1px);
}
.btn-back.back-plank:active {
    transform: translateY(var(--btn-depth));
    box-shadow: inset 0 1px 0 #ffffff, 0 0 0 var(--btn-lip);
}
.btn-back .back-icon {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    flex: 0 0 auto;
    border-radius: 50%;
    border: 2px solid var(--ink);
    background:
        radial-gradient(circle at 35% 25%, #ffffff 0%, #dff3e6 55%, #bfe5d1 100%);
    box-shadow: inset 0 -2px 0 rgba(30, 58, 49, 0.12);
}
.btn-back .back-icon svg {
    width: 1.55rem;
    height: 1.55rem;
    overflow: visible;
}
.btn-back .back-label { line-height: 1; }

.back-home {
    gap: 0.5rem;
    padding-left: 0.5rem;
}
.back-home-icon {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    flex: 0 0 auto;
    border: 2px solid var(--ink);
    border-radius: 50%;
    box-shadow: inset 0 -2px 0 rgba(30, 58, 49, 0.12);
}
.back-home--peach .back-home-icon {
    background: radial-gradient(circle at 35% 25%, #ffffff 0%, #ffe1cf 55%, #ffc9a9 100%);
}
.back-home--lavender .back-home-icon {
    background: radial-gradient(circle at 35% 25%, #ffffff 0%, #eee2ff 55%, #d8c2ff 100%);
}
.back-home-icon svg { width: 1.55rem; height: 1.55rem; }
.back-home-label { line-height: 1.1; }
.back-home:hover .back-home-icon { transform: rotate(-6deg); }
.back-home-icon { transition: transform 0.18s ease; }

/* A fridge is tall and narrow: the target stays full-height and the cue sits
   at the door handle. */
.hotspot.fridge-hotspot::before,
.hotspot.fridge-hotspot::after { top: 32%; }

/* The open-fridge art is chunkier than the painted fridge behind it; narrow it
   so the appliance does not visibly grow when the door opens. */
.layer-fridge-open {
    transform: scaleX(0.72);
    transform-origin: left bottom;
}

/* The painted living-room lamp stays put; switching it on adds a warm pool of
   light over the shade instead of pasting a second lamp on top of it. */
.lamp-glow {
    position: absolute;
    left: 84%;
    top: 14%;
    width: 17%;
    height: 24%;
    z-index: 2;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(ellipse at 50% 34%,
        rgba(255, 235, 170, 0.98) 0%,
        rgba(255, 205, 105, 0.55) 34%,
        rgba(255, 185, 70, 0.18) 58%,
        rgba(255, 180, 60, 0) 74%);
    /* No blur: the gradient already fades out, and a filtered layer re-ran
       the blur on every frame of the warm pulse. */
    transition: opacity 0.35s ease;
}
.lit .lamp-glow { opacity: 1; animation: lamp-warm 2.4s ease-in-out infinite; }
/* Opacity only: animating filter forced style and compositing work on every
   frame of an otherwise still room (about 100x the idle cost, measured). */
@keyframes lamp-warm {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.84; }
}

/* On short portrait phones the toy-chest sheet used to spend its whole height
   on the helper copy, leaving the toy chips below the visible box. Hide the
   copy there so the toys themselves are always reachable. */
@media (orientation: portrait) and (max-height: 720px) {
    #room-screen .toy-chest-tray {
        max-height: 10.5rem;
    }
    #room-screen .toy-chest-tray .tray-hint {
        display: none;
    }
    #room-screen .toy-chest-tray .chest-tray-head {
        min-height: 44px;
    }
}

/* The toy chest is a horizontal scroll strip, not a wrapping grid: a second
   wrapped row fell below the sheet and its toys could not be tapped. */
#room-screen .toy-chest-tray .chip-tray {
    display: flex;
    flex-wrap: nowrap;
    grid-template-columns: none;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
}
#room-screen .toy-chest-tray .chip {
    flex: 0 0 auto;
}

#room-screen .toy-chest-tray .chip {
    width: 72px;
    min-width: 72px;
}
@media (max-width: 480px) {
    #room-screen .toy-chest-tray .chip-tray { gap: 0.25rem; }
    #room-screen .toy-chest-tray .chip {
        width: 44px;
        min-width: 44px;
    }
}

/* ─── Reduced transparency ───────────────────────────────────────
   The meadow base already turns the panel tokens opaque; these are the
   playhouse surfaces that carry their own blur. Rooms, Monty and the props
   stay: the setting asks for less glass, not less playhouse. Last in the
   file so it outranks every frosted rule above. */
@media (prefers-reduced-transparency: reduce) {
    .stage-label,
    .room-title-plate h2,
    .chip-tray,
    .collection-title,
    .badges-list,
    .toybox-grid,
    .profile-chip,
    .album-modal::backdrop {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

.reset-actions { flex-wrap: wrap; }

/* ── Brush teeth: Monty at the basin, six brushes and a rinse ───── */
.teeth-scene {
    position: relative;
    flex: 1 1 0;
    min-height: 0;
    aspect-ratio: 1;
    align-self: center;
    max-width: 100%;
}
.teeth-paste { position: absolute; left: 2%; bottom: 4%; width: 16%; pointer-events: none; z-index: 2; }
.teeth-sparkle { position: absolute; left: 62%; top: 22%; width: 22%; pointer-events: none; z-index: 3; animation: dry-pop 0.5s ease; }
.teeth-monty {
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 86%;
    transform: translateX(-50%);
    filter: drop-shadow(0 8px 12px rgba(20, 40, 32, 0.35));
    z-index: 1;
}
.teeth-monty[hidden] { display: none; }
#teeth-monty-clean { animation: dry-pop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1); }
.teeth-zone {
    position: absolute;
    left: 30%;
    top: 24%;
    width: 40%;
    height: 32%;
    z-index: 3;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.teeth-zone.scrub { animation: teeth-scrub 0.35s ease; }
@keyframes teeth-scrub {
    0%, 100% { transform: translateX(0) rotate(0); }
    25% { transform: translateX(-5px) rotate(-3deg); }
    75% { transform: translateX(5px) rotate(3deg); }
}
.teeth-foam {
    position: absolute;
    width: var(--size, 6%);
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fff, #e8f6ff 70%);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.9);
    pointer-events: none;
    z-index: 2;
    animation: dry-pop 0.3s ease;
}
.teeth-cup {
    position: absolute;
    left: 74%;
    bottom: 4%;
    width: 26%;
    padding: 0;
    border: 0;
    background: transparent;
    z-index: 4;
    cursor: pointer;
    filter: drop-shadow(0 5px 8px rgba(20, 40, 32, 0.32));
}
.teeth-cup[hidden] { display: none; }
.teeth-cup img { width: 100%; height: auto; display: block; }
.teeth-cup.ready {
    filter: drop-shadow(0 0 8px rgba(246, 196, 83, 0.95));
    animation: duck-ready 1.2s ease-in-out infinite;
}
.teeth-cup:focus-visible, .teeth-zone:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 3px; }
body[data-activity="teeth"] .activity-button { visibility: hidden; }
@media (prefers-reduced-motion: reduce) {
    .teeth-zone.scrub, .teeth-cup.ready, #teeth-monty-clean, .teeth-foam, .teeth-sparkle, .bath-toy { animation: none !important; }
}

/* ── Bedtime: the brushing wiggle, and a label that stays on stage ── */
.bedtime-monty.brushing img { animation: teeth-scrub 0.4s ease 4; }
.activity-button.calm::before { left: auto; right: 0; transform: none; }
@media (prefers-reduced-motion: reduce) {
    .bedtime-monty.brushing img { animation: none !important; }
}

/* Blanket down: the painted quilt is covered by a bare sheet, cut to the
   painted mattress, with the quilt folded at the foot. */
.layer-bed-down {
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    filter: none;
    background:
        radial-gradient(ellipse at 28% 32%, rgba(255, 255, 255, 0.55), transparent 62%),
        linear-gradient(180deg, transparent 55%, rgba(120, 90, 60, 0.22) 100%),
        repeating-linear-gradient(115deg, transparent 0 26px, rgba(150, 120, 85, 0.09) 26px 29px),
        linear-gradient(125deg, #f8f0df 0%, #efe3cb 60%, #e2d3b6 100%);
    clip-path: polygon(0.0% 28.3%, 16.4% 28.7%, 20.9% 30.3%, 24.1% 40.4%, 19.1% 44.1%, 15.6% 48.2%, 12.2% 54.1%, 9.8% 56.3%, 2.9% 58.8%, 2.7% 39.3%, 0.0% 37.8%);
}
.layer-bed-down img {
    position: absolute;
    left: 2.5%;
    top: 38.5%;
    width: 19%;
    height: auto;
    filter: drop-shadow(0 3px 4px rgba(60, 40, 80, 0.3));
}

.story-art img.story-page-in { animation: story-page-in 0.45s ease; }
@keyframes story-page-in {
    0% { opacity: 0; transform: scale(1.03); }
    100% { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
    .story-art img.story-page-in { animation: none; }
}

/* ── Kitchen: the toy oven and the picnic blanket live in the room ───── */
.layer-picnic-blanket { left: 40%; top: 60%; width: 28%; }
.layer-toy-oven { left: 41%; top: 36%; width: 19%; }
/* The activities draw their own copies; the room's would show through. */
body[data-activity] .layer-picnic-blanket,
body[data-activity] .layer-toy-oven { visibility: hidden; }

/* ── Bake cupcakes ───────────────────────────────────────────────── */
.bake-scene {
    position: relative;
    flex: 1 1 0;
    min-height: 0;
    aspect-ratio: 1.15;
    align-self: center;
    max-width: 100%;
}
.bake-monty {
    position: absolute;
    left: -3%;
    bottom: 0;
    width: 40%;
    z-index: 1;
    filter: drop-shadow(0 8px 12px rgba(20, 40, 32, 0.35));
}
.bake-monty[hidden], .bake-oven img[hidden], .bake-tray[hidden], .bake-slot[hidden] { display: none; }
#bake-monty-eat { animation: dry-pop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1); }
.bake-bowl, .bake-oven, .bake-slot, .bake-ing, .bake-deco {
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.bake-bowl { position: absolute; left: 34%; top: 38%; width: 34%; z-index: 2; transition: opacity 0.3s ease; }
.bake-bowl.bake-dim { opacity: 0.3; }
.bake-bowl img, .bake-tray img { width: 100%; height: auto; display: block; }
.bake-oven { aspect-ratio: 1; }
.bake-oven img { width: 100%; height: 100%; object-fit: contain; object-position: center bottom; display: block; position: relative; filter: drop-shadow(0 6px 10px rgba(20, 40, 32, 0.3)); }
.bake-oven { position: absolute; left: 66%; top: 18%; width: 34%; z-index: 2; }
.bake-oven.ready { filter: drop-shadow(0 0 9px rgba(246, 196, 83, 0.95)); animation: duck-ready 1.2s ease-in-out infinite; }
.bake-oven.ready img { filter: none; }
/* Baking glows from a layer behind the oven whose opacity pulses: animating
   a drop-shadow filter repainted the oven on every frame. */
.bake-oven::before {
    content: '';
    position: absolute;
    inset: -8%;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(circle, rgba(255, 160, 60, 0.7) 0%, rgba(255, 160, 60, 0.3) 45%, rgba(255, 160, 60, 0) 70%);
}
.bake-oven.baking { animation: bake-shake 0.9s ease-in-out infinite; }
.bake-oven.baking::before { animation: bake-glow 0.9s ease-in-out infinite; }
@keyframes bake-glow {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 1; }
}
@keyframes bake-shake {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(1px); }
}
.bake-tray { position: absolute; left: 30%; top: 42%; width: 42%; z-index: 3; }
.bake-slot { position: absolute; width: 27%; aspect-ratio: 1; border-radius: 50%; }
/* The tray rests inside the open oven until it is dragged out. */
.bake-tray.in-oven { left: 70%; top: 27%; width: 26%; z-index: 3; filter: drop-shadow(0 0 6px rgba(246, 196, 83, 0.9)); }
.bake-tray.in-oven .bake-slot { pointer-events: none; }
/* The empty tray waits beside the bowl for the batter, then goes to the oven from there. */
.bake-tray.on-counter { left: 58%; top: 50%; width: 40%; }
.bake-tray:not([hidden]) img { -webkit-user-drag: none; user-select: none; }
.bake-tray, .bake-ing, .bake-deco, .bake-bowl { touch-action: none; -webkit-user-select: none; user-select: none; }
.bake-tray, .bake-ing, .bake-deco, .bake-bowl, .bake-oven { -webkit-touch-callout: none; }
.bake-scene img, .bake-shelf img { -webkit-user-drag: none; }
.bake-lifted { opacity: 0.35; }
.bake-ghost {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 10000;
    pointer-events: none;
    filter: drop-shadow(0 10px 14px rgba(20, 40, 32, 0.4));
}
.bake-ghost img { width: 100%; height: 100%; object-fit: contain; display: block; transform: scale(1.12); }
.bake-ghost--pour img { transform: scale(1.1) rotate(32deg); }
/* What has gone into the bowl: each ingredient is its own layer in the mixture. */
.bake-contents { position: absolute; inset: 0; pointer-events: none; --mix: 0; }
.bake-contents[hidden] { display: none; }
.bake-mixture { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.bake-layer, .bake-batter, .bake-swirl { transform-box: fill-box; transform-origin: center; }
.bake-layer { opacity: 0; transform: scale(0.4) translateY(-10px); transition: opacity 0.35s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
.bake-layer.on { opacity: calc(1 - var(--mix) * 0.85); transform: none; }
.bake-batter { opacity: var(--mix); transition: opacity 0.4s ease; }
.bake-swirl { opacity: 0; transform: rotate(calc(var(--mix) * 540deg)); transition: transform 0.4s ease, opacity 0.3s ease; }
.bake-contents[data-count="4"] .bake-swirl { opacity: 1; }
/* The ingredient itself tips over the bowl, then a puff marks where it landed. */
.bake-bowl .bake-drop {
    position: absolute;
    left: 34%;
    top: -14%;
    width: 30%;
    height: 30%;
    object-fit: contain;
    animation: bake-tip 0.6s ease-in forwards;
}
@keyframes bake-tip {
    0% { transform: translateY(0) rotate(0); opacity: 1; }
    55% { transform: translateY(40%) rotate(40deg); opacity: 1; }
    100% { transform: translateY(95%) rotate(55deg) scale(0.6); opacity: 0; }
}
.bake-puff {
    position: absolute;
    width: 9%;
    height: 9%;
    border-radius: 50%;
    background: var(--puff, #fff);
    opacity: 0;
    animation: bake-puff 0.8s ease-out forwards;
    animation-delay: 0.35s;
}
@keyframes bake-puff {
    0% { opacity: 0.9; transform: translate(0, 0) scale(0.4); }
    100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.6); }
}
.bake-slot[data-slot="0"] { left: 4%; top: 32%; }
.bake-slot[data-slot="1"] { left: 36%; top: 32%; }
.bake-slot[data-slot="2"] { left: 68%; top: 32%; }
.bake-slot:focus-visible, .bake-ing:focus-visible, .bake-deco:focus-visible, .bake-bowl:focus-visible, .bake-oven:focus-visible {
    outline: 3px solid var(--on-primary);
    outline-offset: 2px;
}
.bake-frosting { position: absolute; left: 0; top: -10%; width: 100%; pointer-events: none; animation: dry-pop 0.35s ease; }
.bake-topping { position: absolute; left: 30%; top: -30%; width: 40%; pointer-events: none; animation: dry-pop 0.35s ease 0.1s backwards; }
.bake-topping--sprinkles { left: 18%; top: -4%; width: 64%; }
.bake-wiggle { animation: teeth-scrub 0.35s ease; }
.bake-stirring { animation: bake-stir 0.4s ease; }
@keyframes bake-stir {
    0% { transform: rotate(0); }
    25% { transform: rotate(-6deg) translateX(-3px); }
    75% { transform: rotate(6deg) translateX(3px); }
    100% { transform: rotate(0); }
}
.bake-shelf {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}
.bake-shelf[hidden] { display: none; }
.bake-ing, .bake-deco {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-md);
    background: var(--panel-strong);
    border: 2px solid var(--glass-edge);
    box-shadow: var(--shadow-card);
    transition: transform 0.2s ease, opacity 0.2s ease, border-color 0.2s ease;
}
.bake-ing img, .bake-deco img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.bake-ing:disabled { opacity: 0.3; cursor: default; transform: scale(0.9); }
.bake-deco[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(246, 196, 83, 0.4); transform: translateY(-3px); }
.bake-divider { width: 2px; height: 36px; background: var(--glass-edge); border-radius: 2px; }
body[data-activity="bake"] .activity-button { visibility: hidden; }
@media (prefers-reduced-motion: reduce) {
    .bake-drop, .bake-puff, .bake-oven.ready, .bake-oven.baking, .bake-oven.baking::before, .bake-wiggle, .bake-stirring, .bake-frosting, .bake-topping, #bake-monty-eat { animation: none !important; }
}

/* ── Living room props: the fort tent and the puppet theatre stand in the room ── */
.layer-fort-tent { left: 40%; top: 50%; width: 26%; }
.layer-puppet-theatre { left: 68%; top: 34%; width: 20%; }
body[data-activity] .layer-fort-tent,
body[data-activity] .layer-puppet-theatre { visibility: hidden; }
body[data-activity="puppets"] .activity-button, body[data-activity="fort"] .activity-button { visibility: hidden; }
/* Activity overlays are painted on their own layer so the room beneath is not re-composited. */
.activity-overlay { contain: layout paint; }
@media (prefers-reduced-motion: reduce) {
    .fort-bump, .fort-drop, .puppet-performer, .puppet-curtain { animation: none !important; transition: none !important; }
}
.activity-button.story::before { left: auto; right: 0; bottom: auto; top: -22%; transform: none; }

/* The global `* { margin: 0 }` reset removes the automatic centring every
   modal dialog gets from the browser, pinning it to the top-left corner. */
dialog { margin: auto; }

/* Snow: the backyard really is under snow, not just tinted with flakes. */
body[data-screen="room"][data-room="backyard"][data-weather="snow"] {
    --bg-image: url('../assets/rooms/bg-backyard-snow.webp?v=39d79749f2');
}
body[data-weather="snow"] .weather-overlay {
    background: linear-gradient(180deg, rgba(225, 238, 250, 0.14), rgba(230, 240, 250, 0) 55%);
}

/* ─── Backyard: seeds, vase, sandbox, wheelbarrow, wish sky ───── */
.seed-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0 0.5rem;
}
.seed-packets { display: flex; gap: 0.5rem; }
.seed-packet {
    width: 72px;
    min-height: 88px;
    padding: 4px;
    background: var(--panel-strong);
    border: 3px solid var(--glass-edge);
    border-radius: var(--radius-md);
    cursor: pointer;
    touch-action: manipulation;
}
.seed-packet img { width: 100%; height: 100%; object-fit: contain; display: block; }
.seed-packet--on { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(246, 196, 83, 0.3); }
.seed-packet:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; }

/* The bloom sprite is orange-gold; a hue turn gives the other two colours. */
.garden-plot .plot-plant--4[data-bloom="red"] { filter: hue-rotate(-24deg) saturate(1.25); }
.garden-plot .plot-plant--4[data-bloom="yellow"] { filter: hue-rotate(14deg); }
.garden-plot .plot-plant--4[data-bloom="purple"] { filter: hue-rotate(250deg); }

.garden-vase {
    position: relative;
    width: 84px;
    flex: 0 0 auto;
}
.garden-vase img { width: 100%; height: auto; display: block; }
.garden-vase__flowers {
    position: absolute;
    left: 0;
    right: 0;
    top: -4px;
    display: flex;
    justify-content: center;
    gap: 2px;
    flex-wrap: wrap;
}
.vase-bloom {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(30, 58, 49, 0.35);
}
.vase-bloom--red { background: #e8564b; }
.vase-bloom--yellow { background: #f6c453; }
.vase-bloom--purple { background: #9a78d6; }
.garden-vase__count {
    position: absolute;
    left: 50%;
    bottom: -4px;
    transform: translateX(-50%);
    padding: 0 8px;
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--ink);
    background: var(--panel-strong);
    border-radius: 999px;
    white-space: nowrap;
}

.sandbox-scene, .barrow-scene {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    border-radius: var(--radius-xl);
    user-select: none;
    -webkit-touch-callout: none;
}
.sandbox-scene {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #bfe3f2 0%, #d9eed2 62%, #efd9a0 100%);
}
.sandbox-pile {
    position: relative;
    width: min(70%, 380px);
    max-height: 100%;
    aspect-ratio: 1;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    touch-action: none; /* a swipe digs; it must not scroll the page */
    --dug: 0;
}
.sandbox-pile img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform-origin: 50% 90%;
    transform: scale(calc(1 - var(--dug) * 0.28), calc(1 - var(--dug) * 0.4));
    transition: transform 0.2s ease;
    pointer-events: none;
}
.sandbox-pile:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; border-radius: var(--radius-md); }
.sandbox-monty {
    position: absolute;
    left: 3%;
    bottom: 4%;
    width: min(24%, 140px);
    pointer-events: none;
}
.sandbox-find {
    position: absolute;
    left: 50%;
    top: 12%;
    width: min(34%, 190px);
    transform: translateX(-50%);
    pointer-events: none;
    filter: drop-shadow(0 0 14px #fff3b0);
}
.sandbox-find img { width: 100%; height: auto; display: block; }
.sandbox-find--pop { animation: sandbox-pop 0.8s cubic-bezier(0.2, 0.9, 0.3, 1) both; }
/* Rises out of the sand, overshoots, then settles with a small bounce. */
@keyframes sandbox-pop {
    0% { transform: translate(-50%, 70%) scale(0.4); opacity: 0; }
    45% { transform: translate(-50%, -14%) scale(1.15); opacity: 1; }
    65% { transform: translate(-50%, 4%) scale(0.96); }
    82% { transform: translate(-50%, -3%) scale(1.03); }
    100% { transform: translate(-50%, 0) scale(1); opacity: 1; }
}
.sandbox-shovel {
    position: absolute;
    z-index: 4;
    width: min(26%, 150px);
    height: auto;
    margin: -78% 0 0 -30%;
    transform-origin: 30% 90%;
    pointer-events: none;
}
.sandbox-shovel--dig { animation: sandbox-shovel 0.45s ease-in-out; }
/* Tips forward, scoops down into the sand, then flicks back up. */
@keyframes sandbox-shovel {
    0% { transform: rotate(-12deg) translateY(-10px); }
    40% { transform: rotate(24deg) translateY(16px); }
    70% { transform: rotate(-22deg) translateY(-14px); }
    100% { transform: rotate(-12deg) translateY(-10px); }
}
.sand-sparkle {
    position: absolute;
    z-index: 5;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    background: #fff3b0;
    clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
    pointer-events: none;
    animation: sand-sparkle 0.85s ease-out forwards;
}
@keyframes sand-sparkle {
    0% { transform: translate(0, 0) scale(0.4); opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) scale(1.2) rotate(90deg); opacity: 0; }
}
.sand-grain {
    position: absolute;
    z-index: 3;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e9c46a;
    pointer-events: none;
    animation: sand-grain 0.65s ease-out forwards;
}
@keyframes sand-grain {
    to { transform: translate(var(--dx), var(--dy)); opacity: 0; }
}
.sandbox-shelf, .barrow-shelf { display: flex; gap: 0.5rem; align-items: center; }
.sandbox-shelf span {
    position: relative;
    width: 56px;
    height: 56px;
    background: var(--panel-strong);
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-md);
}
.sandbox-shelf span[hidden] { display: none; }
.sandbox-shelf img { width: 100%; height: 100%; object-fit: contain; }
.sandbox-shelf b {
    position: absolute;
    right: -6px;
    bottom: -6px;
    min-width: 22px;
    padding: 0 5px;
    font-family: var(--font-headline);
    font-size: 0.8rem;
    text-align: center;
    color: var(--ink);
    background: var(--gold);
    border-radius: 999px;
}

.barrow-scene {
    background: #d9eed2 url('../assets/rooms/bg-backyard-barrow.webp?v=5ca113439a') center bottom / cover no-repeat;
}
.barrow-cart {
    position: absolute;
    left: var(--cart-x, 8%);
    bottom: 8%;
    width: min(34%, 240px);
    min-height: 56px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    transition: left 0.65s ease-in-out;
    touch-action: manipulation;
}
.barrow-cart img { width: 100%; height: auto; display: block; pointer-events: none; }
.barrow-cart:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; border-radius: var(--radius-md); }
.barrow-spill {
    position: absolute;
    bottom: 6%;
    width: 9%;
    max-width: 56px;
    pointer-events: none;
    transform: rotate(var(--spin, 0deg));
    animation: barrow-drop 0.5s ease-in;
}
@keyframes barrow-drop {
    from { transform: translateY(-120%) rotate(var(--spin, 0deg)); opacity: 0; }
    to { transform: translateY(0) rotate(var(--spin, 0deg)); opacity: 1; }
}
.barrow-cargo {
    width: 72px;
    height: 72px;
    padding: 6px;
    background: var(--panel-strong);
    border: 3px solid var(--glass-edge);
    border-radius: var(--radius-md);
    cursor: pointer;
    touch-action: manipulation;
}
.barrow-cargo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.barrow-cargo:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; }

/* The seasonal meadow treat sits quietly among the five friends. */
.meadow-find--season[hidden] { display: none; }

/* Wish sky: the constellation lines and the word under each lit star. */
.stars-lines {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.stars-lines line {
    stroke: rgba(255, 236, 138, 0.75);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 4 5;
    vector-effect: non-scaling-stroke;
}
.star-word {
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    padding: 0 6px;
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: 0.72rem;
    color: #fff8d6;
    text-shadow: 0 1px 3px rgba(8, 16, 32, 0.9);
    white-space: nowrap;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .barrow-cart { transition: none; }
    .sandbox-find--pop, .barrow-spill, .sand-grain, .sandbox-shovel--dig, .sand-sparkle { animation: none; }
    .sandbox-shovel, .sand-sparkle { display: none; }
    .sandbox-pile img { transition: none; }
}
