/* StimRoom — smooth custom UI. Soft glass surfaces, slow drifting color, gentle easing.
   Nothing flashes. Every animation stops in "Still" mode and when the device asks for reduced motion. */
/* Quiet Gallery (design: ChatGPT, direction B, picked by Jacob; tablet layout: ChatGPT; build notes: Gemini).
   Deep navy by default, precise 1px borders, no drop shadows and no blur. Light colors are one tap away in Settings. */
:root {
  --bg: #EDF0F6;
  --surface: #FFFFFF;
  --surface-solid: #FFFFFF;
  --surface-2: #F4F6FB;
  --ink: #171F32;
  --muted: #4D5872;
  --line: #D5DDEA;
  --accent: #414DA4;
  --accent-ink: #FFFFFF;
  --glow: rgba(65, 77, 164, .12);
  --lavender: #DEDFF5; --lavender-deep: #414DA4; --sage: #D5E8DF; --sky: #D6E4F5; --sand: #EFE5D2; --rose: #F1DCE6;
  --shadow-sm: none; --shadow: none; --shadow-lift: none;
  --radius: 20px;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --font: "Geist", "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --gutter: 16px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #101622;
  --surface: #192236;
  --surface-solid: #192236;
  --surface-2: #1F2A42;
  --ink: #F4F6FF;
  --muted: #C4CEE4;
  --line: #39465E;
  --accent: #BBC5FF;
  --accent-ink: #151D36;
  --glow: rgba(187, 197, 255, .14);
  --lavender: #2C2D55; --lavender-deep: #BBC5FF; --sage: #1E3A33; --sky: #1F3550; --sand: #3A3326; --rose: #3A2738;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--font); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 12px; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 10px; }
.skip:focus { top: 12px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* ---------- Ambient background: three soft color clouds drifting very slowly ---------- */
.ambient { position: fixed; inset: -20vmax; z-index: -1; pointer-events: none; overflow: hidden; }
.ambient i { position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; filter: blur(70px); opacity: .55; }
.ambient i:nth-child(1) { background: var(--lavender); left: 5%; top: 0; animation: drift1 48s var(--ease) infinite alternate; }
.ambient i:nth-child(2) { background: var(--sage); right: 0; top: 25%; animation: drift2 56s var(--ease) infinite alternate; }
.ambient i:nth-child(3) { background: var(--rose); left: 30%; bottom: -10%; animation: drift3 64s var(--ease) infinite alternate; }
@keyframes drift1 { to { transform: translate(12vmax, 8vmax) scale(1.1); } }
@keyframes drift2 { to { transform: translate(-10vmax, 10vmax) scale(.95); } }
@keyframes drift3 { to { transform: translate(8vmax, -12vmax) scale(1.08); } }

/* Gentle page entrance */
main { animation: rise .7s var(--ease) both; }
@keyframes rise { from { transform: translateY(10px); } to { transform: none; } }

/* ---------- Header ---------- */
.top {
  position: sticky; top: 0; z-index: 20; max-width: 1080px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.top::before {
  content: ""; position: absolute; inset: 6px 8px; z-index: -1; border-radius: 22px;
  background: var(--surface); backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 20px; letter-spacing: -.01em; padding-left: 6px; }
.brand-mark { width: 34px; height: 34px; }
.mark-bg { fill: var(--lavender-deep); }
.mark-a { fill: #C6DBC2; }
.mark-b { fill: #F6F1EA; }
.controls { display: flex; gap: 6px; padding-right: 4px; }
.ctl {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 999px;
  border: 1px solid transparent; background: transparent; cursor: pointer; font-size: 15px; font-weight: 650; color: var(--muted);
  transition: background-color .3s var(--ease), color .3s var(--ease), border-color .3s var(--ease);
}
.ctl:hover { background: var(--line); color: var(--ink); }
.ctl svg { width: 18px; height: 18px; flex: none; }
.ctl[aria-pressed="true"] { background: var(--glow); color: var(--ink); border-color: var(--line); }
.ctl-icon { width: 44px; padding: 0; justify-content: center; }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

/* ---------- Home ---------- */
.hero { max-width: 1080px; margin: 0 auto; padding: 48px 28px 26px; text-align: center; }
.hero h1 { font-size: clamp(32px, 5.4vw, 56px); line-height: 1.06; letter-spacing: -.03em; font-weight: 800; max-width: 20ch; margin: 0 auto; text-wrap: balance; }
h1, .hero p, .lead { text-wrap: balance; }
.hero p { margin: 14px auto 0; font-size: clamp(17px, 2vw, 20px); color: var(--muted); max-width: 40ch; }
.tiles { max-width: 1080px; margin: 0 auto; padding: 12px 20px 44px; display: grid; gap: 18px; grid-template-columns: repeat(3, minmax(0, 1fr)); list-style: none; }
.tile {
  position: relative; display: grid; gap: 4px; align-content: end; min-height: 230px; padding: 20px; border-radius: var(--radius);
  text-decoration: none; color: var(--ink); overflow: hidden; isolation: isolate;
  background: var(--tile, var(--lavender)); box-shadow: var(--shadow);
  transition: transform .45s var(--ease), box-shadow .45s var(--ease);
}
.tile::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, transparent 40%, rgba(255, 255, 255, .35)); }
:root[data-theme="dark"] .tile::after { background: linear-gradient(180deg, transparent 40%, rgba(0, 0, 0, .25)); }
.tile:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); }
.tile:active { transform: translateY(-1px) scale(.99); }
.tile svg { position: absolute; top: 16px; right: 16px; width: 54%; max-width: 150px; height: auto; z-index: -1; opacity: .9; transition: transform .8s var(--ease); }
.tile:hover svg { transform: rotate(-4deg) scale(1.04); }
.tile strong { font-size: 22px; letter-spacing: -.01em; }
.tile span { color: var(--muted); font-size: 15px; }
.t-colors { --tile: var(--lavender); }
.t-ripples { --tile: var(--sky); }
.t-bubbles { --tile: var(--sage); }
.t-sand { --tile: var(--sand); }
.t-sounds { --tile: var(--rose); }
.t-silly { --tile: var(--lavender); }
.art-line { fill: none; stroke: var(--ink); stroke-opacity: .28; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.art-fill { fill: var(--surface-solid); fill-opacity: .7; }
.art-soft { fill: var(--ink); fill-opacity: .08; }

/* "Get the app" card */
.install {
  max-width: 720px; margin: 0 auto 26px; padding: 16px 18px; display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center;
  border-radius: 24px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.install-icon svg { width: 52px; height: 52px; display: block; }
.install h2 { font-size: 18px; }
.install p { color: var(--muted); font-size: 15px; }
@media (max-width: 560px) { .install { grid-template-columns: auto 1fr; margin: 0 14px 22px; } .install .btn { grid-column: 1 / -1; } }

/* Running as an installed app: respect the phone's notch and home bar */
@media (display-mode: standalone) {
  .top { padding-top: max(12px, env(safe-area-inset-top)); }
  .foot { padding-bottom: max(34px, env(safe-area-inset-bottom)); }
}

/* Home picture tiles: the real thing on every tile, one or two words, one big button each */
.hero-kid { padding: 34px 20px 18px; }
.ptiles { max-width: 1080px; margin: 0 auto; padding: 6px 20px 40px; display: grid; gap: 18px; grid-template-columns: repeat(3, minmax(0, 1fr)); list-style: none; }
.ptile {
  display: grid; gap: 10px; padding: 10px 10px 14px; border-radius: 30px; text-decoration: none; color: var(--ink);
  background: var(--surface-solid); border: 1px solid var(--line); box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  transition: transform .18s var(--ease), box-shadow .3s var(--ease);
}
.ptile strong { font-size: clamp(19px, 2.3vw, 24px); font-weight: 800; text-align: center; letter-spacing: -.01em; }
.pic { position: relative; display: block; aspect-ratio: 1; border-radius: 22px; overflow: hidden; background: #ddd; isolation: isolate; }
.pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.pic .pic-press { opacity: 0; }
.ptile.touched .pic-press, .ptile:active .pic-press { opacity: 1; }
@media (hover: hover) { .ptile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); } }
.ptile:active, .ptile.touched { transform: scale(.97); }
.pic-glow { background: radial-gradient(circle at 50% 50%, #8E2BFF 0%, #4B10A8 55%, #12061F 100%); }
.glow-core { position: absolute; inset: 14%; border-radius: 50%;
  background: radial-gradient(circle at 45% 42%, #FFE3FA 0%, #FF5AD9 22%, #C42BFF 48%, rgba(122, 28, 255, 0) 72%);
  transition: transform .5s var(--ease), filter .5s var(--ease); }
.ptile.touched .glow-core, .ptile:active .glow-core { transform: scale(1.18); filter: brightness(1.2) saturate(1.15); }
.pic-water .ring { position: absolute; left: 50%; top: 50%; width: 30%; aspect-ratio: 1; border-radius: 50%; transform: translate(-50%, -50%) scale(.2);
  border: 3px solid rgba(255, 255, 255, .85); box-shadow: 0 0 10px rgba(255, 255, 255, .6), inset 0 0 8px rgba(255, 255, 255, .5); opacity: 0; }
.ptile.touched .ring { animation: tileRing .9s cubic-bezier(.2, .7, .3, 1) forwards; }
@keyframes tileRing { 0% { transform: translate(-50%, -50%) scale(.2); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(2.6); opacity: 0; } }
@media (max-width: 560px) { .hero-kid { padding: 10px 16px 10px; } .hero-kid h1 { font-size: 26px; } .ptile strong { font-size: 18px; } }
@media (max-width: 860px) { .ptiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 4px 14px 30px; } .ptile { border-radius: 24px; padding: 8px 8px 12px; gap: 8px; } .pic { border-radius: 18px; } }

.about { max-width: 720px; margin: 0 auto; padding: 0 24px 40px; text-align: center; color: var(--muted); font-size: 16px; display: grid; gap: 8px; }
.about h2 { color: var(--ink); font-size: 20px; }

/* ---------- Activity pages ---------- */
.activity { max-width: 1080px; margin: 0 auto; padding: 14px 20px 30px; display: grid; gap: 14px; }
.head-row { display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.activity h1 { font-size: clamp(28px, 4vw, 38px); line-height: 1.1; font-weight: 800; letter-spacing: -.02em; }
.activity .lead { color: var(--muted); font-size: 17px; margin-top: 4px; }
.back {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px 0 10px; border-radius: 999px; width: max-content;
  color: var(--ink); text-decoration: none; font-weight: 650; font-size: 15px; background: var(--surface); border: 1px solid var(--line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: background-color .3s var(--ease);
}
.back:hover { background: var(--surface-solid); }
.back svg { width: 18px; height: 18px; }

.stage {
  position: relative; width: 100%; height: min(70vh, 640px); border-radius: 30px; overflow: hidden; touch-action: none;
  background: var(--surface-solid); box-shadow: var(--shadow); border: 1px solid var(--line);
}
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
/* Floating glass control bar inside the stage */
.dock {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 2;
  display: flex; gap: 8px; align-items: center; padding: 8px; border-radius: 999px; max-width: calc(100% - 24px); flex-wrap: wrap; justify-content: center;
  background: var(--surface); backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-solid); font-weight: 700; font-size: 16px; cursor: pointer; touch-action: manipulation; color: var(--ink);
  transition: transform .3s var(--ease), background-color .3s var(--ease), box-shadow .3s var(--ease);
}
.btn:hover { box-shadow: var(--shadow-sm); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.note { font-size: 15px; color: var(--muted); }

/* Custom sliders */
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 44px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 10px; border-radius: 99px; background: var(--track, var(--line)); }
input[type="range"]::-moz-range-track { height: 10px; border-radius: 99px; background: var(--track, var(--line)); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; margin-top: -9px; border-radius: 50%; background: var(--surface-solid); border: 3px solid var(--accent); box-shadow: var(--shadow-sm); }
input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-solid); border: 3px solid var(--accent); }
.slider { display: grid; gap: 2px; min-width: 220px; font-size: 14px; font-weight: 650; color: var(--muted); padding: 0 8px; }
.slider .row { display: flex; justify-content: space-between; }
.hue-track { --track: linear-gradient(90deg, hsl(0 32% 80%), hsl(60 32% 80%), hsl(120 32% 80%), hsl(180 32% 80%), hsl(240 32% 80%), hsl(300 32% 80%), hsl(359 32% 80%)); }

/* Sand garden: a real oak tray with fine sand and smooth stones */
.zen {
  position: relative; padding: clamp(12px, 2.2vw, 20px); border-radius: 14px;
  background: linear-gradient(135deg, rgba(255, 236, 205, .22), rgba(0, 0, 0, .18)), url(/img/zen/oak-color.jpg) center / 340px;
  box-shadow: 0 2px 3px rgba(40, 25, 10, .25), 0 22px 40px -18px rgba(40, 25, 10, .55), inset 0 1px 0 rgba(255, 240, 215, .45), inset 0 -2px 3px rgba(30, 15, 5, .35);
}
.zen::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; box-shadow: inset 0 0 0 1px rgba(30, 15, 5, .25); }
.bed {
  position: relative; height: min(64vh, 600px); border-radius: 4px; overflow: hidden; touch-action: none; background: #E9E0CC;
  box-shadow: inset 0 0 0 1px rgba(60, 35, 15, .35);
}
.bed::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 3;
  box-shadow: inset 9px 10px 14px -6px rgba(60, 40, 20, .38), inset -2px -2px 6px -2px rgba(255, 245, 225, .35); } /* the tray wall's shadow on the sand */
.bed canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stones { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.stone {
  position: absolute; pointer-events: auto; touch-action: none; transform: translate(-50%, -50%);
  background:
    radial-gradient(ellipse at 32% 26%, rgba(255, 255, 255, .26), rgba(255, 255, 255, 0) 42%),
    radial-gradient(ellipse at 68% 78%, rgba(0, 0, 0, .55), rgba(0, 0, 0, 0) 62%),
    linear-gradient(rgba(18, 18, 18, .42), rgba(18, 18, 18, .42)),
    url(/img/zen/stone-color.jpg) center / 180px;
  box-shadow: 7px 9px 12px rgba(70, 50, 25, .38), 2px 3px 3px rgba(50, 35, 20, .4), inset -7px -9px 16px rgba(0, 0, 0, .5), inset 5px 6px 9px rgba(255, 255, 255, .1);
}
.zen[data-tool="move"] .stone { cursor: grab; }
.zen[data-tool="move"] .stone:active { cursor: grabbing; }
.zen-tools { margin-top: 18px; -webkit-user-select: none; user-select: none; }
.zen, .bed { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.zen-tools .btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: transparent; }
@media (max-width: 860px) { .bed { height: 58vh; } .zen-tools { gap: 6px; padding: 8px; } .zen-tools .btn { min-height: 44px; padding: 0 14px; font-size: 15px; } }

/* Color glow: rich light over a deep dark base. Only opacity changes, so it stays smooth on any phone. */
.stage.glow { background: #08090C; border-color: rgba(255, 255, 255, .06); }
.glow-layer { position: absolute; inset: -8%; opacity: 0; transition-property: opacity; transition-timing-function: ease-in-out; will-change: opacity; }
.stage.drifting .glow-layer { animation: glowDrift 40s ease-in-out infinite alternate; }
@keyframes glowDrift { from { transform: translate3d(-2%, -1%, 0) scale(1.02); } to { transform: translate3d(2%, 1.5%, 0) scale(1.06); } }
/* Touch the glow: the light follows your finger (moved with transform only, so it stays smooth: Gemini) */
@property --gx { syntax: '<percentage>'; inherits: true; initial-value: 38%; }
@property --gy { syntax: '<percentage>'; inherits: true; initial-value: 42%; }
@property --gs { syntax: '<number>'; inherits: true; initial-value: 1; }
.stage.glow { transition: --gx .7s var(--ease), --gy .7s var(--ease), --gs .7s var(--ease); }
.stage.glow.is-dragging { transition: --gx .18s linear, --gy .18s linear, --gs .18s linear; }
.glow-move { position: absolute; inset: 0; pointer-events: none; }
.swirl-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.stage.glow.is-swirl { background: #000; }
.swirl-looks { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.swirl-looks .btn[aria-checked="true"] { background: var(--ink); color: var(--bg); }
.swirl-looks .look-dot { width: 18px; height: 18px; border-radius: 50%; flex: none; }
.glow-dim { position: absolute; inset: 0; background: #000; opacity: .2; pointer-events: none; transition: opacity .3s linear; }
.stage.glow:fullscreen { border-radius: 0; height: 100vh; }
.glow-swatch { border: 2px solid rgba(255, 255, 255, .85); box-shadow: 0 0 0 1px var(--line), 0 4px 14px -2px var(--glow); }
.glow-swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--accent), 0 0 18px 2px var(--glow); }
.glow-sliders { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; width: 100%; }

/* Colors */
.wash { position: absolute; inset: 0; transition: background-color 4s var(--ease); }
.wash.drift { transition: background-color 9s var(--ease); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.swatch {
  width: 48px; height: 48px; border-radius: 50%; border: 3px solid var(--surface-solid); box-shadow: 0 0 0 1px var(--line), var(--shadow-sm);
  cursor: pointer; transition: transform .35s var(--ease), box-shadow .35s var(--ease);
}
.swatch:hover { transform: scale(1.08); }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--accent), var(--shadow-sm); transform: scale(1.06); }
.panel { display: grid; gap: 14px; justify-items: center; padding: 18px; border-radius: 26px; background: var(--surface); border: 1px solid var(--line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }

/* Pop bubbles: a soft silicone push-pop tray in rainbow rows. The domes are lit once in bubbles.js;
   the tray color in each row matches the flat silicone around them, so they blend in. */
.sheet {
  --cols: 6;
  position: relative; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 4px; padding: clamp(16px, 3vw, 28px);
  border-radius: clamp(28px, 5vw, 48px); touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  width: 100%; max-width: 880px; margin: 0 auto; box-sizing: border-box;
  /* a thicker, rounded silicone rim and a soft contact shadow under the whole tray (pop-it research) */
  box-shadow: 0 2px 3px rgba(0, 0, 0, .22), 0 7px 10px -4px rgba(0, 0, 0, .4), 0 26px 44px -22px rgba(0, 0, 0, .55),
    inset 0 3px 4px rgba(255, 255, 255, .35), inset 0 -6px 10px rgba(0, 0, 0, .24), inset 0 0 0 2px rgba(0, 0, 0, .08),
    inset 0 0 0 7px rgba(255, 255, 255, .07), inset 0 0 0 8px rgba(0, 0, 0, .06);
  transform-style: preserve-3d;
}
.sheet::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(120% 70% at 25% 0%, rgba(255, 255, 255, .16), rgba(255, 255, 255, 0) 55%); } /* soft matte sheen */
.dome {
  aspect-ratio: 1; width: 100%; border: 0; padding: 0; margin: 0; border-radius: 50%; cursor: pointer; touch-action: none;
  background: center / 100% 100% no-repeat transparent; -webkit-tap-highlight-color: transparent; position: relative; z-index: 1;
}
.dome.pressing { transform: scale(.985); }
/* After a pop: a short, damped settle (silicone, not a spring), about 240 ms */
.dome.wobble { animation: domeSettle .24s cubic-bezier(.3, .7, .4, 1); }
@keyframes domeSettle { 0% { transform: scale(.95); } 45% { transform: scale(1.025); } 75% { transform: scale(.995); } 100% { transform: scale(1); } }
.dome:focus-visible { outline: 3px solid #fff; outline-offset: -4px; }
.sheet.flip-out { transition: transform .34s cubic-bezier(.5, 0, .9, .5); transform: perspective(1200px) rotateY(90deg); }
.sheet.flip-in { animation: flipIn .36s cubic-bezier(.1, .5, .5, 1); }
@keyframes flipIn { from { transform: perspective(1200px) rotateY(-90deg); } to { transform: perspective(1200px) rotateY(0); } }
.pop-tools { margin-top: 18px; }

/* Silly sounds board */
.board { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* Glossy candy buttons: a bright shine across the top, a soft inner glow, and a solid edge that presses down. */
.silly {
  position: relative; display: grid; justify-items: center; align-content: center; gap: 6px; aspect-ratio: 1; min-height: 120px; border-radius: 30px; cursor: pointer;
  border: 0; color: var(--ink); overflow: hidden; isolation: isolate; -webkit-tap-highlight-color: transparent;
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 60%),
    radial-gradient(90% 60% at 50% 115%, rgba(0, 0, 0, .1), rgba(0, 0, 0, 0) 70%),
    var(--tile);
  box-shadow: 0 8px 0 -1px color-mix(in srgb, var(--tile) 70%, #000 12%), 0 18px 28px -14px rgba(43, 38, 49, .4), inset 0 2px 0 rgba(255, 255, 255, .6), inset 0 -10px 18px rgba(43, 38, 49, .08);
  touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  transition: transform .14s var(--ease), box-shadow .14s var(--ease);
}
.silly::before { content: ""; position: absolute; left: 10%; right: 10%; top: 5%; height: 34%; border-radius: 24px 24px 50% 50% / 24px 24px 30px 30px; z-index: -1;
  background: linear-gradient(rgba(255, 255, 255, .55), rgba(255, 255, 255, 0)); }
.silly:active, .silly.hit:active { transform: translateY(6px) scale(.98); box-shadow: 0 2px 0 -1px color-mix(in srgb, var(--tile) 70%, #000 12%), 0 8px 14px -10px rgba(43, 38, 49, .4), inset 0 2px 0 rgba(255, 255, 255, .5), inset 0 -4px 10px rgba(43, 38, 49, .1); }
.silly-emoji { filter: drop-shadow(0 4px 6px rgba(43, 38, 49, .22)); }
.silly-emoji { font-size: clamp(40px, 7vw, 64px); line-height: 1; }
.silly-name { font-size: clamp(16px, 2.2vw, 20px); font-weight: 800; }
.silly.hit .silly-emoji { animation: bounce .45s var(--ease); }
@keyframes bounce { 0% { transform: scale(1); } 35% { transform: scale(1.25) rotate(-6deg); } 70% { transform: scale(.95) rotate(3deg); } 100% { transform: scale(1); } }
@media (max-width: 860px) { .board { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; } .silly { min-height: 0; border-radius: 24px; } }
.art-silly { --tile: var(--sand); }

/* Sounds */
.sound-grid { display: grid; gap: 18px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sound {
  position: relative; display: grid; gap: 4px; justify-items: center; align-content: center; text-align: center; min-height: 220px; padding: 22px;
  border-radius: 30px; cursor: pointer; border: 2px solid transparent; background: var(--tile, var(--sky)); box-shadow: var(--shadow); overflow: hidden; isolation: isolate;
  transition: transform .45s var(--ease), box-shadow .45s var(--ease), border-color .45s var(--ease);
}
.sound:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.sound svg { width: 64px; height: 64px; margin-bottom: 6px; }
.sound strong { font-size: 22px; }
.sound span { color: var(--muted); font-size: 15px; }
.sound .state { margin-top: 6px; font-size: 14px; font-weight: 700; color: var(--ink); opacity: .75; }
.sound[aria-pressed="true"] { border-color: var(--accent); }
.sound::before { content: ""; position: absolute; inset: 50% auto auto 50%; width: 180px; height: 180px; margin: -110px 0 0 -90px; border-radius: 50%; background: var(--surface-solid); opacity: 0; z-index: -1; transition: opacity .6s var(--ease); }
.sound[aria-pressed="true"]::before { opacity: .45; animation: breathe 7s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(.85); } 50% { transform: scale(1.15); } }
.s-rain { --tile: var(--sky); }
.s-ocean { --tile: var(--sage); }
.s-brown { --tile: var(--sand); }
.player { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.now { font-weight: 700; min-height: 1.5em; text-align: center; }

/* Footer */
.foot { max-width: 1080px; margin: 0 auto; padding: 26px 24px 34px; color: var(--muted); font-size: 14px; display: grid; gap: 8px; text-align: center; justify-items: center; }
.foot a { color: var(--accent); font-weight: 650; text-underline-offset: 3px; }
:root[data-theme="light"] .foot a, :root:not([data-theme]) .foot a { color: var(--lavender-deep); }
.foot-links { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

@media (max-width: 860px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 8px 14px 34px; gap: 12px; }
  .tile { min-height: 180px; padding: 16px; }
  .tile strong { font-size: 19px; }
  .tile svg { width: 58%; }
  .sound-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .sound { min-height: 150px; }
  .hero { padding: 30px 20px 18px; }
  .top { padding: 8px 12px; }
  .activity { padding: 10px 14px 26px; }
  .stage { height: 62vh; border-radius: 24px; }
}
.ctl .label, .btn { white-space: nowrap; }
@media (max-width: 480px) {
  .ctl .k { display: none; } /* phones show the icon + "on/off" to fit; screen readers get the full label */
  .ctl { padding: 0 10px; font-size: 14px; gap: 6px; }
  .dock { flex-wrap: nowrap; gap: 6px; padding: 6px; }
  .dock .btn { min-height: 44px; padding: 0 14px; font-size: 15px; }
  .brand span { display: none; }
  .tile span { font-size: 14px; }
}

/* Still mode and reduced-motion: no animation, no transitions */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
:root[data-motion="still"] *, :root[data-motion="still"] *::before, :root[data-motion="still"] *::after { transition: none !important; animation: none !important; }

/* ==========================================================================
   Quiet Gallery layout. Phone below 600px; tablet (and tablets held upright up to 1366px);
   the rail layout for tablets held sideways and for computers from 1024px.
   ========================================================================== */
.ambient { display: none; }
main { animation: none; } /* nothing moves until touched */
body { font-size: 16px; }

/* ---------- Header: one solid bar, wordmark left, Sound / Motion / Settings right ---------- */
.top {
  max-width: none; margin: 0; min-height: 60px; padding: 8px max(var(--gutter), calc((100% - 1240px) / 2 + var(--gutter)));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.top::before { display: none; }
.brand { font-size: 20px; font-weight: 700; letter-spacing: -.02em; padding-left: 0; }
.brand-mark { width: 32px; height: 32px; }
.mark-bg { fill: var(--accent); }
:root[data-theme="dark"] .mark-bg { fill: #414DA4; }
.controls { gap: 8px; padding-right: 0; align-items: center; }
.ctl { min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; padding: 0 14px; }
@media (hover: hover) { .ctl:hover { background: var(--surface-2); } }
.ctl[aria-pressed="true"] { background: var(--glow); border-color: var(--accent); }
.ctl-icon { width: 48px; }
.ctl .v { color: var(--muted); font-weight: 500; }
.ctl[aria-pressed="true"] .v { color: var(--ink); }

/* Settings (Buzz and light/dark) open from the gear */
.settings { position: relative; }
.settings > summary { list-style: none; cursor: pointer; }
.settings > summary::-webkit-details-marker { display: none; }
.settings[open] > summary { background: var(--surface-2); border-color: var(--accent); }
.settings-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; min-width: 230px; display: grid; gap: 8px; padding: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
}
.settings-panel .ctl { width: 100%; justify-content: flex-start; }
.settings-panel .ctl .k { display: inline !important; }
.theme-name::before { content: "Light colors"; }
:root[data-theme="light"] .theme-name::before { content: "Dark colors"; }

/* ---------- Home ---------- */
.home { max-width: 1240px; margin: 0 auto; padding: 16px var(--gutter) 28px; display: grid; gap: 14px; }
.home-title { font-size: 24px; line-height: 1.15; font-weight: 700; letter-spacing: -.02em; }
.gallery { display: grid; gap: 12px; }
.ptiles { display: none; }

.card {
  display: grid; grid-template-rows: auto auto; text-decoration: none; color: var(--ink); overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  transition: transform .16s var(--ease), border-color .2s var(--ease);
}
.card .pic { border-radius: 0; aspect-ratio: 4 / 3; background: #0B0F18; }
.card strong { display: flex; align-items: center; min-height: 48px; padding: 0 14px; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.card:active, .card.touched { transform: scale(.98); border-color: var(--accent); }
@media (hover: hover) { .card:hover { border-color: var(--accent); } }
.card:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 12px; }
/* While a tile says its name (home.js): a soft steady glow, no flashing, so it's clear which one is talking. */
.card.saying { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent), 0 0 26px color-mix(in srgb, var(--accent) 55%, transparent); }

.feature { border-radius: 20px; }
.card.feature .pic { aspect-ratio: 2 / 1; }
.feature strong { min-height: 56px; padding: 0 18px; font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.feature:focus-visible { border-radius: 20px; }

.rail { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rail li { display: grid; }

/* Glow and water pictures keep their touch payoff */
.card .pic-glow { background: radial-gradient(circle at 50% 50%, #8E2BFF 0%, #4B10A8 55%, #12061F 100%); }
.card.touched .glow-core, .card:active .glow-core { transform: scale(1.18); filter: brightness(1.2) saturate(1.15); }
.card.touched .ring { animation: tileRing .9s cubic-bezier(.2, .7, .3, 1) forwards; }
.card.touched .pic-press, .card:active .pic-press { opacity: 1; }

.install { max-width: none; margin: 0; background: var(--surface); border-radius: 16px; backdrop-filter: none; -webkit-backdrop-filter: none; }
.about { max-width: 720px; padding: 10px 0 0; text-align: left; margin: 0; }

/* ---------- Activity pages ---------- */
.shell { max-width: 1240px; margin: 0 auto; }
.side { display: none; }
.activity { max-width: none; padding: 12px var(--gutter) 28px; gap: 12px; }
.activity h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.activity .lead { font-size: 15px; margin-top: 2px; }
.back {
  min-height: 48px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
  backdrop-filter: none; -webkit-backdrop-filter: none; font-weight: 600; padding: 0 16px 0 10px;
}
.stage { border-radius: 20px; box-shadow: none; border: 1px solid var(--line); background: var(--surface); }
.stage.glow { border-color: var(--line); }
/* One solid tool dock under the play area, never on top of it */
.dock, .player {
  position: static; transform: none; left: auto; bottom: auto; max-width: none; margin: 0;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: center; padding: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none;
}
.btn { border-radius: 12px; min-height: 48px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
@media (hover: hover) { .btn:hover { box-shadow: none; border-color: var(--accent); } }
.zen-tools .btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.panel { border-radius: 16px; background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
.zen-tools, .pop-tools { margin-top: 0; }
.sound { border-radius: 20px; border: 1px solid var(--line); }
.sound[aria-pressed="true"] { border: 2px solid var(--accent); }
.silly { border-radius: 20px; }
.note { font-size: 14px; }
.foot { max-width: 1240px; border-top: 1px solid var(--line); margin-top: 8px; }
.foot a { color: var(--accent); }

/* Bigger targets for fingers and whole hands */
@media (pointer: coarse) { /* touch is the main input (not touch laptops used with a trackpad) */
  .btn, .ctl, .back { min-height: 52px; }
  .ctl-icon { width: 52px; }
}

/* ---------- Lock for testing (temporary) ---------- */
.lock-toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 100;
  padding: 12px 18px; border-radius: 14px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); font-weight: 600; max-width: calc(100% - 32px); text-align: center; }
:root.is-locked .foot-links, :root.is-locked .install { display: none; }

/* ---------- Water and Sand Lab (test page) ---------- */
.activity.lab { max-width: 1240px; margin: 0 auto; }
.lab-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.lab-tabs [role="tab"] { min-height: 48px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; cursor: pointer; }
.lab-tabs [role="tab"] b { color: var(--accent); margin-right: 4px; }
.lab-tabs [aria-selected="true"] { border: 2px solid var(--accent); background: var(--surface-2); }
.lab-kind { display: flex; gap: 8px; }
.lab-kind .btn[aria-pressed="true"], .dock .btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.lab-stage { touch-action: none; -webkit-user-select: none; user-select: none; background: #0B0F18; }
.lab-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.lab-stage .lab-fx { pointer-events: none; }
.lab-stones { position: absolute; inset: 0; pointer-events: none; }
.lab-stage.tray { background: linear-gradient(135deg, rgba(255, 236, 205, .22), rgba(0, 0, 0, .18)), url(/img/zen/oak-color.jpg) center / 340px; }
.lab-stage.tray > canvas, .lab-stage.tray > .lab-stones { inset: 14px; width: calc(100% - 28px); height: calc(100% - 28px); }
.lab-stage.tray::after { content: ""; position: absolute; inset: 14px; pointer-events: none; z-index: 3;
  box-shadow: inset 0 0 0 1px rgba(60, 35, 15, .35), inset 9px 10px 14px -6px rgba(60, 40, 20, .38), inset -2px -2px 6px -2px rgba(255, 245, 225, .35); }
.lab-stage.dish { background: radial-gradient(circle at 30% 20%, #f4f2ec, #d9dcd4); }
.lab-stage.dish > canvas { inset: 12px; width: calc(100% - 24px); height: calc(100% - 24px); border-radius: 14px; }
.lab-stage.dish::after { content: ""; position: absolute; inset: 12px; border-radius: 14px; pointer-events: none; z-index: 3;
  box-shadow: inset 0 0 0 1px rgba(40, 60, 60, .25), inset 0 6px 16px rgba(20, 40, 45, .35), inset 0 0 26px 4px rgba(20, 40, 45, .18); }
.lab-rim { border-radius: 50% 48% 52% 49% / 49% 52% 48% 51%; }
.sand-stage[data-tool="move"] .lab-stones .stone { pointer-events: auto; cursor: grab; touch-action: none; }
.sand-stage[data-tool="move"] .lab-stones .stone:active { cursor: grabbing; }
.lab-stones .stone { pointer-events: none;
  /* muted charcoal, one broad soft highlight, darkest shadow right at contact fading down-right (ChatGPT) */
  background: radial-gradient(ellipse at 34% 28%, rgba(255, 255, 255, .16), rgba(255, 255, 255, 0) 55%),
    radial-gradient(ellipse at 66% 78%, rgba(0, 0, 0, .45), rgba(0, 0, 0, 0) 62%),
    linear-gradient(rgba(40, 38, 36, .5), rgba(40, 38, 36, .5)), url(/img/zen/stone-color.jpg) center / 180px;
  box-shadow: 1px 2px 1.5px rgba(50, 35, 20, .55), 5px 7px 9px rgba(70, 50, 25, .28), 12px 15px 20px rgba(70, 50, 25, .12),
    inset -6px -8px 14px rgba(0, 0, 0, .45), inset 4px 5px 8px rgba(255, 255, 255, .08); }
.lab-stage.tray > canvas, .lab-stage.tray > .lab-stones { inset: 16px; width: calc(100% - 32px); height: calc(100% - 32px); }
.lab-stage.tray::after { inset: 16px; }
.lab-stage.tray::before { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; z-index: 2;
  box-shadow: inset 0 1px 0 rgba(255, 240, 215, .35), inset 0 -2px 3px rgba(30, 15, 5, .3), inset 0 0 0 15px rgba(0, 0, 0, .04), inset 0 0 0 16px rgba(255, 235, 200, .18); } /* matte oak with a small inner bevel */
.lab-rim { position: absolute; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .18), rgba(0, 0, 0, .35) 75%), url(/img/zen/stone-color.jpg) center / 140px;
  box-shadow: 0 6px 14px rgba(40, 25, 10, .45), inset 0 2px 3px rgba(255, 255, 255, .25); }
.lab-pond { position: absolute; border-radius: 50%; overflow: hidden; box-shadow: inset 0 4px 12px rgba(0, 0, 0, .55); }
.lab-pond canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.lab-panel { justify-items: stretch; text-align: left; }
.lab-panel h2 { font-size: 20px; }
.lab-slots { display: grid; gap: 10px; }
.lab-slot { display: grid; grid-template-columns: 130px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.lab-slot label, .lab-slot .lab-touch { font-weight: 600; }
#labSounds .lab-slot { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); padding: 6px 0; border-bottom: 1px solid var(--line); }
.lab-slot select { min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); padding: 0 10px; font: inherit; min-width: 0; }
@media (max-width: 599px) { .lab-slot { grid-template-columns: minmax(0, 1fr) auto; } .lab-slot label { grid-column: 1 / -1; } }

/* ---------- Phones ---------- */
@media (max-width: 599px) {
  .top { min-height: 56px; padding-top: 6px; padding-bottom: 6px; }
  .brand span { display: inline; }
  .controls { gap: 6px; }
  .ctl { padding: 0 10px; gap: 6px; font-size: 15px; }
  .ctl .k { display: inline; } /* "Sound: off" and "Motion: slow" in words, not just icons (ChatGPT) */
  .settings-panel .ctl { padding: 0 14px; }
  .stage { height: 60vh; }
}
@media (max-width: 440px) { .brand span { display: none; } } /* the logo stays; the words make room for the labels */
@media (max-width: 340px) { .ctl .k { display: none; } }

/* ---------- Tablets (and tablets held upright, even big ones) ---------- */
@media (min-width: 600px) {
  :root { --gutter: 24px; }
  .top { min-height: 72px; }
  .home { padding-top: 20px; gap: 20px; }
  .home-title { font-size: 30px; }
  .gallery { gap: 16px; }
  .card.feature .pic { aspect-ratio: 3 / 1; }
  .feature strong { font-size: 28px; }
  .rail { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .card .pic { aspect-ratio: 3 / 2; }
  .card strong { min-height: 52px; font-size: 18px; padding: 0 16px; }
  .activity { padding-top: 16px; }
  .activity h1 { font-size: 28px; }
  .stage { height: min(62vh, 640px); }
}

/* ---------- Tablets held sideways, and computers: the activity rail ---------- */
@media (min-width: 1024px) and (orientation: landscape), (min-width: 1024px) and (hover: hover) and (pointer: fine) {
  .home { padding-top: 24px; }
  .home-title { font-size: 34px; }
  .gallery { grid-template-columns: 280px minmax(0, 1fr); gap: 24px; align-items: start; }
  .feature { grid-column: 2; grid-row: 1; }
  .card.feature .pic { aspect-ratio: 16 / 9; }
  .rail { grid-column: 1; grid-row: 1; grid-template-columns: 1fr; gap: 12px; }
  .rail .card { grid-template-columns: 96px minmax(0, 1fr); grid-template-rows: none; align-items: center; gap: 14px; min-height: 88px; padding: 12px; border-radius: 12px; }
  .rail .card .pic { width: 96px; height: 64px; aspect-ratio: auto; border-radius: 12px; }
  .rail .card strong { min-height: 0; padding: 0; font-size: 18px; }

  /* Activity pages: the same rail stays beside the activity */
  .shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 24px; padding: 20px var(--gutter) 0; align-items: start; }
  .side { display: grid; gap: 12px; position: sticky; top: 92px; }
  .side ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
  .side .card { grid-template-columns: 96px minmax(0, 1fr); grid-template-rows: none; align-items: center; gap: 14px; min-height: 88px; padding: 12px; }
  .side .card .pic { width: 96px; height: 64px; aspect-ratio: auto; border-radius: 12px; }
  .side .card strong { min-height: 0; padding: 0; font-size: 18px; }
  .side .card[aria-current="page"] { border: 2px solid var(--accent); background: var(--surface-2); }
  .side-home { display: inline-flex; align-items: center; gap: 6px; min-height: 52px; padding: 0 16px 0 10px; border-radius: 12px; border: 1px solid var(--line);
    background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 600; width: max-content; }
  .side-home svg { width: 18px; height: 18px; }
  .shell .activity { padding: 0 0 28px; margin: 0; min-width: 0; }
  .shell .back { display: none; }
  .activity h1 { font-size: 30px; }
  /* Short landscape screens: the play area shrinks so its tools stay in view without scrolling (ChatGPT) */
  .stage { height: clamp(300px, calc(100vh - 300px), 680px); }
  .bed { height: clamp(280px, calc(100vh - 340px), 600px); }
  .foot { padding-left: var(--gutter); padding-right: var(--gutter); }
}

/* ==========================================================================
   One screen, no scrolling (Simone's first test). Layout: ChatGPT; build notes: Gemini.
   The page is exactly the screen: header, a short name row, the play area (it takes all the space that is left),
   and one tool row. The footer and the about text live in the Settings gear.
   ========================================================================== */
html, body { height: 100%; height: 100vh; height: 100dvh; overflow: hidden; }
html { scroll-behavior: auto; }
body { min-height: 0; display: flex; flex-direction: column; overscroll-behavior: none; }
.top { flex: none; }
.foot, .about, .gallery { display: none; }
.home, .shell { flex: 1 1 auto; min-height: 0; width: 100%; }

/* Settings gear: Buzz, light/dark, the app, and the small print */
.settings-panel { width: min(300px, calc(100vw - 24px)); max-height: calc(100dvh - 90px); overflow: auto; }
.settings-about { display: grid; gap: 6px; padding: 8px 4px 2px; border-top: 1px solid var(--line); font-size: 13px; line-height: 1.45; color: var(--muted); }
.settings-about .foot-links { display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: flex-start; }
.settings-about a { color: var(--accent); font-weight: 600; }
.settings-panel .install { display: grid; gap: 8px; margin: 0; padding: 10px; border-radius: 12px; grid-template-columns: none; }
.settings-panel .install p { font-size: 13px; color: var(--muted); }

/* ---------- Home: six big pictures, Bubbles first ---------- */
.home { max-width: 1240px; margin: 0 auto; display: flex; padding: 12px var(--gutter) max(12px, env(safe-area-inset-bottom)); gap: 0; }
.grid6 { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; display: grid; gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); }
@media (orientation: landscape) { .grid6 { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); } }
.grid6 li { display: grid; min-height: 0; }
.grid6 .card { grid-template-rows: minmax(0, 1fr) auto; min-height: 0; border-radius: 16px; }
.grid6 .card .pic { aspect-ratio: auto; height: 100%; min-height: 0; }
.grid6 .card strong { justify-content: center; min-height: 44px; font-size: clamp(16px, 2.4vmin, 22px); font-weight: 700; }
.grid6 .card.feature { border: 2px solid var(--accent); grid-column: auto; grid-row: auto; } /* the old wide-layout .feature placement squeezed Bubbles on laptops */
.card .glow-core { inset: auto; left: 50%; top: 50%; height: 74%; width: auto; aspect-ratio: 1; translate: -50% -50%; }

/* ---------- Activity pages ---------- */
.shell { max-width: 1240px; margin: 0 auto; display: flex; }
main.activity { flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 10px;
  padding: 10px var(--gutter) max(10px, env(safe-area-inset-bottom)); }
.act-head { flex: none; display: flex; align-items: center; gap: 10px; }
.act-head .back { width: 48px; padding: 0; justify-content: center; }
.act-head h1 { font-size: 22px; line-height: 1.1; }
main.activity > .stage, main.activity > .pop-stage, main.activity > .board, main.activity > .sound-grid { flex: 1 1 auto; min-height: 0; height: auto; }
main.activity > .dock.tools { flex: none; gap: 8px; padding: 8px; }
.dock.tools .slider { min-width: 150px; flex: 1 1 150px; max-width: 320px; }

/* Colors: swatches, sliders and buttons share one tool area */
.colors-tools { justify-content: center; }
.colors-tools .swatches { gap: 8px; }
.colors-tools .swatch { width: 40px; height: 40px; }
.colors-tools .glow-sliders { display: flex; flex: 1 1 280px; gap: 12px; width: auto; flex-wrap: nowrap; }
.colors-tools .glow-sliders .slider { min-width: 0; flex: 1 1 120px; padding: 0 4px; }
.tool-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.look-btn { width: 48px; padding: 0; }
.look-btn .look-dot { width: 26px; height: 26px; }

/* Bubbles: the tray is sized in bubbles.js to the space that is left */
.pop-stage { position: relative; display: flex; align-items: center; justify-content: center; }
.pop-stage .sheet { display: block; position: relative; padding: 0; margin: 0; width: auto; max-width: none; border-radius: 0; box-shadow: none; background: none; flex: none; }
.pop-stage .sheet::after { display: none; }
.tray-shape { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; display: block;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25)) drop-shadow(0 12px 14px rgba(0, 0, 0, .35)); }
.pop-stage .dome { position: absolute; width: var(--d); height: var(--d); aspect-ratio: auto; }
.shapes { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.shape-btn { width: 52px; height: 52px; padding: 5px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface-2); cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: transform .15s var(--ease), border-color .2s var(--ease); }
.shape-btn svg { width: 100%; height: 100%; display: block; }
.shape-btn[aria-checked="true"] { border-color: var(--accent); background: var(--glow); }
.shape-btn:active { transform: scale(.94); }

/* Silly Sounds: every button on screen at once */
main.activity > .board { display: grid; gap: 10px; padding-bottom: 8px; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
@media (orientation: landscape) { main.activity > .board { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (orientation: portrait) and (min-width: 600px) { main.activity > .board { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
main.activity > .board .silly { aspect-ratio: auto; min-height: 0; border-radius: 18px; gap: 2px; }
.silly-emoji { font-size: clamp(26px, 6vmin, 60px); }
.silly-name { font-size: clamp(14px, 2.2vmin, 20px); }

/* Quiet Sounds */
main.activity > .sound-grid { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); grid-auto-rows: minmax(0, 1fr); }
@media (orientation: landscape) { main.activity > .sound-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
main.activity > .sound-grid .sound { min-height: 0; padding: 10px; }
.sound svg { width: clamp(40px, 9vmin, 72px); height: clamp(40px, 9vmin, 72px); }

/* Sand tools and the Drop button stay on one row */
.zen-tools .btn, .pop-tools .btn { padding: 0 16px; }

/* Tablets sideways and computers: the activity rail fits the screen too */
@media (min-width: 1024px) and (orientation: landscape), (min-width: 1024px) and (hover: hover) and (pointer: fine) {
  .shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; padding: 14px var(--gutter) 0; align-items: stretch; }
  .side { position: static; top: auto; display: flex; flex-direction: column; min-height: 0; padding-bottom: 14px; }
  .side ul { flex: 1; min-height: 0; display: grid; grid-template-rows: repeat(6, minmax(0, 1fr)); gap: 10px; }
  .side li { display: grid; min-height: 0; }
  .side .card { min-height: 0; padding: 6px 10px; grid-template-columns: 84px minmax(0, 1fr); gap: 12px; }
  .side .card .pic { width: 84px; height: 100%; max-height: 60px; min-height: 0; }
  .shell main.activity { padding: 0 0 14px; }
  .shell .act-head { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); } /* the rail shows where you are */
}

/* Short screens (phones sideways, small laptops): tighter header */
@media (max-height: 560px) {
  .top { min-height: 48px; padding-top: 4px; padding-bottom: 4px; }
  .ctl, .btn, .back { min-height: 44px; }
  .ctl-icon, .act-head .back { width: 44px; }
  main.activity { gap: 8px; padding-top: 8px; }
  .shape-btn { width: 44px; height: 44px; }
}
@media (max-height: 480px) and (orientation: landscape) { main.activity > .act-head { display: none; } }

/* The prototype lab page (local only) can still scroll */
html:has(.activity.lab), html:has(.activity.lab) body { height: auto; overflow: auto; display: block; }
@media (max-width: 420px) { .shapes { gap: 5px; flex-wrap: nowrap; } .shape-btn { width: 46px; height: 46px; padding: 4px; } }
.pop-stage .sheet { transform-style: flat; } /* the mirrored outline must not join a 3D scene: it hid the tray after a flip */
.silly-emoji { font-size: clamp(30px, min(10vw, 7vh), 66px); }

/* Inside the Dress Up school (a frame opened with ?in=school): only the activity, nothing around it. */
:root[data-embed] header.top, :root[data-embed] .side, :root[data-embed] .act-head, :root[data-embed] .skip { display: none !important; }
:root[data-embed] .shell { display: flex !important; grid-template-columns: none; padding: 0; max-width: none; gap: 0; }
:root[data-embed] main.activity { padding-top: 8px; }

/* Version label (Jacob): tiny, faint, in the very bottom corner, never taking taps. */
.app-version {
  position: fixed; right: max(6px, env(safe-area-inset-right)); bottom: max(2px, env(safe-area-inset-bottom));
  font: 600 10px/1 var(--font); letter-spacing: 0.04em; color: var(--muted); opacity: 0.55;
  pointer-events: none; user-select: none; z-index: 1;
}
/* Toy tiles (2026-11-30): one matching set of glossy toys on deep navy. The tile box can be wider than the square
   picture on some screens, so the picture sits whole in the middle and its edges fade into the same navy. */
.pic.pic-toy, .card .pic.pic-toy { background: radial-gradient(120% 100% at 50% 42%, #1d1a72 0%, #18155f 65%, #131151 100%); }
.pic-toy img {
  object-fit: contain; transition: transform 140ms ease;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 9%, #000 91%, transparent 100%), linear-gradient(to bottom, transparent 0, #000 9%, #000 91%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent 0, #000 9%, #000 91%, transparent 100%), linear-gradient(to bottom, transparent 0, #000 9%, #000 91%, transparent 100%);
  mask-composite: intersect;
}
.card:active .pic-toy img, .card.touched .pic-toy img { transform: scale(.95); }
:root[data-motion="still"] .pic-toy img { transition: none; }
/* Privacy page (for parents and the app stores): the one page that may scroll, since it is reading, not play. */
main.activity.privacy { overflow: auto; }
.privacy-text { max-width: 720px; line-height: 1.6; padding-bottom: 24px; }
.privacy-text h2 { font-size: 19px; margin: 18px 0 4px; }
main.activity.privacy { grid-column: 1 / -1; width: 100%; } /* no side list on this page: use the full width */

/* ---- Welcome: Chip Buddy runs in (home page, first visit of the day; theme.js sets data-intro) ----
   Jacob, 2026-11-30: the launch animation stars the new logo. ChatGPT's beats (1,200 ms): runs in from the left with
   two little hops (0-300), back-and-forth wiggle like Simone running back and forth (300-600), squash and settle
   (600-750), the StimRoom name appears under him (750-1000), everything fades to the home screen (1000-1200).
   Fizzy bubbles rise behind him. No flash, no sound. The first tap ends it at once and only skips (Gemini). */
:root[data-intro]::before {
  content: "StimRoom"; position: fixed; inset: 0; z-index: 1000; pointer-events: auto;
  display: grid; place-items: center; padding-top: clamp(170px, 44vmin, 300px);
  background: radial-gradient(circle at 50% 42%, #18223a 0%, #0f1626 50%, #0a0f1a 100%);
  font: 700 clamp(34px, 9vw, 56px)/1 var(--font); letter-spacing: -0.01em; color: transparent;
  animation: sr-intro-name 250ms ease-out 750ms forwards, sr-intro-out 200ms ease-in 1000ms forwards;
}
:root[data-intro]::after { /* Chip Buddy (the dark of his picture melts into the backdrop: blend lighten + soft round mask) */
  content: ""; position: fixed; left: 50%; top: 42%; z-index: 1002; pointer-events: none;
  width: clamp(130px, 36vmin, 210px); aspect-ratio: 1;
  background: url("/icons/icon-512.png") center / contain no-repeat; mix-blend-mode: lighten;
  -webkit-mask-image: radial-gradient(circle closest-side, #000 84%, transparent 100%); mask-image: radial-gradient(circle closest-side, #000 84%, transparent 100%);
  transform: translate(calc(-50% - 70vw), -50%);
  animation: sr-chip-run 1000ms linear forwards, sr-intro-out 200ms ease-in 1000ms forwards;
}
:root[data-intro] body::before { /* fizzy bubbles rising behind him */
  content: ""; position: fixed; left: calc(50% - 120px); top: calc(42% - 40px); width: 110px; height: 120px; z-index: 1001; pointer-events: none;
  background:
    radial-gradient(circle at 20% 80%, rgba(140, 220, 255, 0.85) 0 5px, transparent 6px),
    radial-gradient(circle at 55% 60%, rgba(140, 220, 255, 0.7) 0 7px, transparent 8px),
    radial-gradient(circle at 35% 35%, rgba(170, 230, 255, 0.8) 0 4px, transparent 5px),
    radial-gradient(circle at 75% 20%, rgba(140, 220, 255, 0.6) 0 6px, transparent 7px),
    radial-gradient(circle at 15% 15%, rgba(170, 230, 255, 0.7) 0 3px, transparent 4px);
  opacity: 0; animation: sr-chip-fizz 750ms ease-out 150ms forwards;
}
@keyframes sr-chip-run {
  0%   { transform: translate(calc(-50% - 70vw), -50%); animation-timing-function: ease-out; }
  12%  { transform: translate(calc(-50% - 42vw), calc(-50% - 8px)); }
  18%  { transform: translate(calc(-50% - 28vw), -50%); }
  25%  { transform: translate(calc(-50% - 12vw), calc(-50% - 8px)); }
  30%  { transform: translate(-50%, -50%); animation-timing-function: ease-in-out; }
  45%  { transform: translate(calc(-50% + 16px), -50%) rotate(5deg); animation-timing-function: ease-in-out; }
  60%  { transform: translate(calc(-50% - 16px), -50%) rotate(-5deg); }
  68%  { transform: translate(-50%, -50%) scale(1.07, 0.92); }
  75%  { transform: translate(-50%, -50%) scale(0.97, 1.04); }
  82%, 100% { transform: translate(-50%, -50%) scale(1); }
}
@keyframes sr-chip-fizz {
  0%   { opacity: 0; transform: translate(-30px, 20px); }
  25%  { opacity: 1; }
  100% { opacity: 0; transform: translate(0, -70px); }
}
@keyframes sr-intro-name { from { color: transparent; } to { color: #eef3ff; } }
@keyframes sr-intro-out { to { opacity: 0; } }
/* Logo: Chip Buddy, dedicated to Simone (Jacob's pick, 2026-11-30), in place of the old two-circle mark. */
img.brand-mark { display: block; border-radius: 11px; object-fit: cover; flex: none; }
/* a little bigger (Jacob): 42px stays under the 48px settings button, so the header height never changes */
.brand img.brand-mark { width: 42px; height: 42px; }
