/* Create a Penguin, the "paint studio". Tokens follow docs/PUBLIC-SITE.md §3. No art is drawn here: every
   character, puffle, sticky note, icon and confetti piece is an <img>/inline SVG of authentic CP art (see build-art.sh).
   CSS only supplies surfaces, light (gradients, glows) and motion. */

@layer tokens, base, layout, components, steps, modes, views, motion;

@layer tokens {
  :root {
    --ocean-900: #06213F; --ocean-800: #00529B; --ocean-700: #0B5DB8; --ocean-600: #0058B0;
    --sea-500: #0186B1; --sea-400: #13A6D9; --sky-300: #3CC3F0; --sky-200: #57B3F1;
    --ice-50: #EAF6FF; --snow: #F8F8F8;
    --gold-500: #FFCC00; --gold-400: #F8E050; --gold-600: #F8C038; --orange-500: #FA9301;
    --ink: #0A1A2F; --success: #2E9E3F; --danger: #CC0000;
    --penguin: #cc0000;              /* set live by JS from player_colors.json */
    --penguin-soft: color-mix(in oklab, var(--penguin) 16%, #F4FAFF);

    --r-pill: 999px; --r-card: 28px; --r-tile: 18px; --r-input: 14px;
    --outline: 3px solid var(--ink);
    --lift-1: 0 2px 0 rgba(6,33,63,.25);
    --lift-2: 0 6px 0 rgba(6,33,63,.22), 0 12px 24px rgba(6,33,63,.18);
    --lift-3: 0 2px 0 rgba(255,255,255,.5) inset, 0 30px 60px -20px rgba(2,20,48,.55), 0 10px 24px rgba(2,20,48,.22);

    --t-fast: 140ms; --t-base: 300ms; --t-slow: 600ms;
    --ease-out: cubic-bezier(.2,.8,.2,1);
    --ease-spring: linear(0, .009, .035 2.1%, .141 4.4%, .723 12.9%, .938 16.7%, 1.017 19.4%, 1.051 22.4%, 1.051 25.9%, 1.016 33%, .998 40.4%, 1);
    --ease-bob: cubic-bezier(.45,0,.55,1);

    --f-display: 'Site Display', 'Arial Rounded MT Bold', system-ui, sans-serif;
    --f-ui: 'Fredoka', 'Nunito Sans', system-ui, sans-serif;
    --f-body: 'Nunito Sans', system-ui, sans-serif;
    --f-comic: 'Bangers', 'Site Display', system-ui, sans-serif;

    --gutter: max(16px, env(safe-area-inset-left));
    --topbar-h: 100px;
  }
}

@layer base {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; color-scheme: light; }
  body {
    margin: 0; min-height: 100svh; font: 400 17px/1.55 var(--f-body); color: var(--ocean-900);
    background: var(--ocean-800); overflow-x: hidden;
    display: flex; flex-direction: column;
  }
  img { max-width: 100%; }
  button, input, select { font: inherit; color: inherit; }
  button { cursor: pointer; }
  a { color: var(--ocean-700); }
  :focus-visible { outline: 3px solid var(--sky-300); outline-offset: 3px; }
  .sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
}

/* ------------------------------------------------------------------ page backdrop */
@layer layout {
  .backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden;
    background:
      radial-gradient(120% 70% at 50% -10%, rgba(87,179,241,.55), transparent 60%),
      radial-gradient(80% 60% at 100% 100%, rgba(1,134,177,.55), transparent 65%),
      linear-gradient(180deg, #0a57a8 0%, #0B5DB8 40%, #0a4f9e 100%);
  }
  /* 2015-17 agegate backdrop: soft blue penguin silhouettes, blended into the ocean */
  .backdrop-art { position: absolute; inset: -4%; background: url(/site/create/art/ui/agegate-bg.webp) center / cover no-repeat;
    mix-blend-mode: soft-light; opacity: .55; filter: blur(2px) saturate(1.1); }
  /* light snow: plain white particles (not characters) */
  .backdrop-snow { position: absolute; inset: -200px 0 0; opacity: .5;
    background-image:
      radial-gradient(2px 2px at 20px 30px, #fff 60%, transparent 61%),
      radial-gradient(1.5px 1.5px at 120px 80px, #fff 60%, transparent 61%),
      radial-gradient(2.5px 2.5px at 200px 150px, rgba(255,255,255,.9) 60%, transparent 61%),
      radial-gradient(1.5px 1.5px at 60px 190px, #fff 60%, transparent 61%),
      radial-gradient(2px 2px at 170px 20px, rgba(255,255,255,.8) 60%, transparent 61%);
    background-size: 240px 240px; animation: snowfall 26s linear infinite; }

  /* ------------------------------------------------------------------ header */
  .topbar { position: relative; z-index: 5; height: var(--topbar-h);
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 24px;
    padding: 0 max(28px, env(safe-area-inset-right)) 0 max(28px, env(safe-area-inset-left)); }
  .brand { justify-self: start; display: block; line-height: 0; }
  .brand img { width: 150px; height: auto; filter: drop-shadow(0 4px 10px rgba(0,20,60,.35)); }
  .exit { justify-self: end; display: inline-flex; align-items: center; gap: 12px; text-decoration: none;
    font: 600 16px var(--f-ui); color: #fff; opacity: .92; }
  .exit img { width: 46px; height: 46px; border-radius: 50%; background: #fff; box-shadow: var(--lift-1); transition: transform var(--t-fast) var(--ease-out); }
  .exit:hover img { transform: rotate(90deg); }

  /* ------------------------------------------------------------------ main studio grid */
  .studio { position: relative; flex: 1; width: min(1320px, 100% - 56px); margin: 0 auto; padding: 8px 0 26px;
    display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, .88fr); gap: 28px; align-items: stretch; }

  /* ------------------------------------------------------------------ footer */
  .footer { position: relative; margin-top: auto; color: rgba(255,255,255,.86); background: var(--ocean-900); }
  .footer-band { height: 30px; background: url(/site/create/art/ui/pattern-bg.png) 0 -28px / auto 85px repeat-x;
    box-shadow: inset 0 -1px 0 rgba(255,255,255,.08); }
  .footer-inner { width: min(1320px, 100% - 56px); margin: 0 auto; padding: 12px 0 max(14px, env(safe-area-inset-bottom));
    display: flex; gap: 24px; align-items: center; justify-content: space-between; }
  .disclaimer { margin: 0; font-size: 12.5px; line-height: 1.45; max-width: 88ch; }
  .disclaimer b { color: #fff; }
  .disclaimer a { color: #fff; }
  .footer-links { display: flex; gap: 18px; font: 600 13px var(--f-ui); white-space: nowrap; }
  .footer-links a { color: #fff; text-decoration: none; opacity: .85; }
}

@layer components {
  /* ------------------------------------------------------------------ stepper (2008 dot-and-star) */
  .stepper { text-align: center; color: #fff; }
  .stepper-title { margin: 0 0 6px; font: 400 15px/1 var(--f-display); letter-spacing: .08em; text-transform: uppercase; opacity: .9; }
  .stepper ol { list-style: none; margin: 0; padding: 0; display: flex; align-items: flex-start; }
  .stepper li { position: relative; width: 104px; display: grid; justify-items: center; gap: 6px; }
  .stepper li + li::before { content: ""; position: absolute; top: 15px; right: calc(50% + 14px); width: calc(100% - 28px); height: 4px; border-radius: 4px;
    background: rgba(255,255,255,.22); }
  .stepper li.done + li::before, .stepper li.done + li.current::before { background: #fff; }
  .node { position: relative; width: 34px; height: 34px; display: grid; place-items: center; }
  .node::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 3px solid rgba(255,255,255,.55); background: transparent; transition: all var(--t-base) var(--ease-out); }
  .done .node::before { background: #fff; border-color: #fff; box-shadow: 0 2px 0 rgba(0,0,0,.18); }
  .node .star { position: absolute; inset: -4px; width: 42px; height: 42px; max-width: none; object-fit: contain; opacity: 0; transform: scale(.4) rotate(-40deg); transition: all var(--t-slow) var(--ease-spring);
    filter: drop-shadow(0 0 10px rgba(255,214,0,.75)) drop-shadow(0 3px 0 rgba(0,0,0,.2)); }
  .current .node::before { opacity: 0; }
  .current .node .star { opacity: 1; transform: none; }
  .lbl { font: 600 13px/1 var(--f-ui); opacity: .72; white-space: nowrap; }
  .done .lbl { opacity: .95; }
  .current .lbl { opacity: 1; color: var(--gold-500); }
  .stepper-now { display: none; margin: 0; }

  /* ------------------------------------------------------------------ the stage (paint studio preview) */
  .stage { position: relative; isolation: isolate; overflow: hidden; border-radius: 36px; min-height: 560px; container-type: size;
    background:
      radial-gradient(60% 55% at 50% 44%, #fff 0%, transparent 70%),
      linear-gradient(180deg, color-mix(in oklab, var(--penguin) 20%, #F3FAFF) 0%, color-mix(in oklab, var(--penguin) 10%, #FFFFFF) 55%, color-mix(in oklab, var(--penguin) 22%, #E3F1FC) 100%);
    box-shadow: var(--lift-3), inset 0 0 0 6px rgba(255,255,255,.55);
    transition: background var(--t-base) var(--ease-out); }
  .stage::after { /* soft floor */ content: ""; position: absolute; left: 8%; right: 8%; bottom: 0; height: 26%; z-index: -1;
    background: radial-gradient(50% 60% at 50% 100%, color-mix(in oklab, var(--penguin) 18%, rgba(11,93,184,.14)), transparent 70%); }
  /* the 2013 create module's sunburst rays (MainBackgroundGraphic), tinted with your colour */
  .stage-rays { position: absolute; left: 50%; top: 46%; width: 170%; aspect-ratio: 1; translate: -50% -50%; z-index: -1;
    background: color-mix(in oklab, var(--penguin) 16%, transparent);
    -webkit-mask: url(/site/create/art/vec/rays.svg) center / contain no-repeat; mask: url(/site/create/art/vec/rays.svg) center / contain no-repeat;
    animation: spin 90s linear infinite; transition: background var(--t-base); }
  .stage-bloom { position: absolute; left: 50%; top: 47%; width: 62%; aspect-ratio: 1; translate: -50% -50%; z-index: -1; border-radius: 50%;
    background: radial-gradient(closest-side, color-mix(in oklab, var(--penguin) 34%, transparent), transparent); opacity: .8; transition: background var(--t-base); }

  /* the doll */
  .doll-wrap { position: absolute; left: 50%; top: 47%; width: min(40%, 300px); aspect-ratio: 194 / 262; translate: -50% -50%; z-index: 2; }
  .doll, .toboggan { position: absolute; inset: 0; z-index: 1; transition: opacity 200ms linear, transform var(--t-slow) var(--ease-spring); }
  .doll svg, .toboggan svg { display: block; width: 100%; height: 100%; overflow: visible; }
  .doll { filter: drop-shadow(0 18px 18px rgba(6,33,63,.18)); }
  .doll-standing, .toboggan { opacity: 0; }
  .pd-body { fill: var(--doll, var(--penguin)); transition: fill 240ms var(--ease-out); }

  /* name bubble (create_module speech bubble, 3x raster) */
  .bubble { position: absolute; left: 50%; bottom: 100%; translate: -44% -6px; width: 118%; aspect-ratio: 794 / 222;
    display: grid; place-items: center; padding-bottom: 7%; opacity: 0; transform: scale(.6) translateY(20px); transform-origin: 44% 100%;
    background: url(/site/create/art/ui/bubble@3x.png) center / 100% 100% no-repeat; filter: drop-shadow(0 6px 10px rgba(6,33,63,.16));
    transition: all var(--t-slow) var(--ease-spring); }
  .bubble span { font: 700 clamp(18px, 2.1vw, 30px)/1 var(--f-ui); color: var(--ocean-900); letter-spacing: .01em; white-space: nowrap; }

  /* the colour ring (2015-17 ring of colour buttons, with the authentic colour-ball icons) */
  .ring { position: absolute; left: 50%; top: 47%; width: 0; height: 0; z-index: 3; --r: min(265px, 36cqmin); }
  .swatch { --a: calc(var(--i) * 22.5deg - 90deg); position: absolute; left: 0; top: 0; width: 70px; height: 70px; margin: -35px 0 0 -35px; padding: 0; border: 0; border-radius: 50%; background: none;
    transform: rotate(var(--a)) translate(var(--r)) rotate(calc(-1 * var(--a))); transition: transform var(--t-base) var(--ease-spring); }
  .swatch img { width: 100%; height: 100%; display: block; transition: transform var(--t-fast) var(--ease-out), filter var(--t-fast); filter: drop-shadow(0 3px 2px rgba(6,33,63,.18)); }
  .swatch:hover img { transform: scale(1.1) translateY(-3px); }
  .swatch::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 4px solid var(--gold-500); box-shadow: 0 0 0 3px var(--ink), 0 0 18px rgba(255,204,0,.7); opacity: 0; transform: scale(.8); transition: all var(--t-base) var(--ease-spring); }
  .swatch[aria-checked="true"]::after { opacity: 1; transform: scale(1); }
  .swatch[aria-checked="true"] img { transform: scale(1.12); }
  .swatch .check { position: absolute; right: -6px; top: -6px; width: 28px; height: 28px; border-radius: 50%; opacity: 0; transform: scale(.3);
    background: #fff url(/site/create/art/ui/icon-checkmark.png) 50% 3px / 22px auto no-repeat; box-shadow: 0 0 0 3px var(--ink); transition: all var(--t-base) var(--ease-spring); }
  .swatch[aria-checked="true"] .check { opacity: 1; transform: scale(1); }

  /* paint splash: drops from the 2008 paint buckets, tinted with the picked colour */
  .splash { position: absolute; left: 50%; top: 50%; width: 0; height: 0; z-index: 3; pointer-events: none; }
  .drop { position: absolute; left: 0; top: 0; width: clamp(48px, 11cqmin, 84px); aspect-ratio: 30 / 19; translate: -50% -50%; opacity: 0; filter: drop-shadow(0 4px 4px rgba(6,33,63,.18)); }
  .drop i, .drop img { position: absolute; inset: 0; width: 100%; height: 100%; }
  .drop i { background: var(--splash, var(--penguin)); -webkit-mask: url(/site/create/art/vec/drops-fill.svg) center / 100% 100% no-repeat; mask: url(/site/create/art/vec/drops-fill.svg) center / 100% 100% no-repeat; }
  .splashing .doll-waving, .splashing .doll-standing { animation: doll-squash 560ms var(--ease-spring); }
  .splash-ring { position: absolute; left: 0; top: 0; width: 88cqmin; height: 88cqmin; translate: -50% -50%; border-radius: 50%; border: 5px solid var(--splash, var(--penguin)); opacity: 0; }
  .splashing .splash-ring { animation: ring-out 800ms var(--ease-out) both; }
  .splashing .stage-bloom { animation: bloom 900ms var(--ease-out); }

  /* colour caption under the ring */
  .stage-caption { position: absolute; left: 0; right: 0; bottom: 22px; z-index: 3; display: flex; justify-content: center; align-items: center; gap: 12px; }
  .caption-name { margin: 0; display: inline-flex; align-items: center; gap: 10px; padding: 7px 20px 7px 8px; border-radius: var(--r-pill);
    background: #fff; box-shadow: var(--lift-2); font: 400 26px/1 var(--f-display); color: var(--ocean-900); }
  .caption-name img { width: 38px; height: 38px; }
  .btn-soft { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 22px; border-radius: var(--r-pill);
    border: 2px solid rgba(11,93,184,.25); background: rgba(255,255,255,.75); color: var(--ocean-700); font: 600 16px var(--f-ui);
    backdrop-filter: blur(6px); box-shadow: var(--lift-1); transition: transform var(--t-fast) var(--ease-out), background var(--t-fast); }
  .btn-soft:hover { background: #fff; transform: translateY(-1px); }
  .btn-soft:active { transform: translateY(2px) scale(.97); }

  /* collapsed colour chip (steps 2-4) */
  .colour-chip { position: absolute; left: 20px; top: 20px; z-index: 6; display: inline-flex; align-items: center; gap: 10px; padding: 6px 8px 6px 6px; border-radius: var(--r-pill);
    background: rgba(255,255,255,.88); backdrop-filter: blur(8px); box-shadow: var(--lift-1); opacity: 0; transform: translateY(-10px); pointer-events: none; transition: all var(--t-base) var(--ease-out); }
  .colour-chip img { width: 40px; height: 40px; }
  .colour-chip span { display: grid; line-height: 1.05; }
  .colour-chip small { font: 600 11px var(--f-ui); text-transform: uppercase; letter-spacing: .08em; color: #5a7896; }
  .colour-chip b { font: 400 18px var(--f-display); }
  .chip-change { border: 0; background: var(--ice-50); color: var(--ocean-700); border-radius: var(--r-pill); padding: 8px 14px; font: 600 14px var(--f-ui); }

  /* sticky notes (2008 create.swf, lettering baked into the art) */
  /* decoration: never a click target (hidden on steps 1, 3 and 4 they sat invisibly over the Red, Green and Pink balls),
     and out of the accessibility tree until step 2 shows them */
  .sticky { position: absolute; z-index: 5; height: auto; filter: drop-shadow(0 8px 10px rgba(6,33,63,.18)); opacity: 0; visibility: hidden;
    pointer-events: none; transition: opacity var(--t-slow), transform var(--t-slow) var(--ease-spring), visibility 0s linear var(--t-slow); }
  .sticky-real { left: 5%; top: 17%; width: 23%; transform: rotate(-4deg) translateY(-30px); }
  .sticky-checked { right: 5%; top: 42%; width: 23%; transform: rotate(5deg) translateY(-30px); }
  .buckets { position: absolute; right: 5%; bottom: 7%; width: 19%; z-index: 2; opacity: 0; transition: opacity var(--t-base); filter: drop-shadow(0 6px 8px rgba(6,33,63,.15)); }

  /* rule friends (the 2008 rules vignettes), they join you as you pledge */
  .friends { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
  .friend { position: absolute; margin: 0; width: 20%; opacity: 0; transition: opacity var(--t-base), transform var(--t-slow) var(--ease-spring), filter var(--t-slow); }
  .friend img { display: block; width: 100%; height: auto; }
  .friend.f-respect { left: 5%; bottom: 13%; }
  .friend.f-chat { right: 6%; bottom: 14%; width: 18%; }
  .friend.f-safe { left: 8%; top: 12%; width: 17%; }
  .friend.f-safe .nosign { position: absolute; left: 1%; top: -2%; width: 88%; }
  .friend.f-fair { right: 5%; top: 11%; width: 21%; }
  .friend::after { content: ""; position: absolute; right: 6%; top: 4%; width: 34px; height: 34px; border-radius: 50%;
    background: #fff url(/site/create/art/ui/icon-checkmark.png) 50% 4px / 26px auto no-repeat; box-shadow: 0 0 0 3px var(--ink), var(--lift-1); transform: scale(0); transition: transform var(--t-slow) var(--ease-spring) 120ms; }
  .friend:not(.on) { filter: brightness(0) invert(1) drop-shadow(0 0 0 transparent); }

  /* ------------------------------------------------------------------ the panel (ice card) */
  .panel { position: relative; display: flex; flex-direction: column; padding: 30px 38px 24px; border-radius: var(--r-card);
    background: linear-gradient(180deg, rgba(255,255,255,.97), rgba(234,246,255,.96)); box-shadow: var(--lift-3); min-width: 0; }
  .step { display: none; flex: 1; min-height: 0; }
  .step.active { display: block; animation: step-in var(--t-slow) var(--ease-spring) both; }
  .eyebrow { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font: 600 14px/1.2 var(--f-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--ocean-700); }
  .eyebrow img { width: 30px; height: auto; }
  .h1 { margin: 0 0 10px; font: 400 clamp(34px, 3.2vw, 48px)/1.02 var(--f-display); color: var(--ocean-900); letter-spacing: .005em; }
  .lede { margin: 0 0 22px; font-size: 18px; color: #26486b; }

  /* step 1 panel */
  .picked { display: flex; align-items: center; gap: 18px; padding: 16px 20px; border-radius: 22px; margin-bottom: 18px;
    background: linear-gradient(135deg, color-mix(in oklab, var(--penguin) 14%, #fff), #fff 70%); border: 2px solid color-mix(in oklab, var(--penguin) 30%, #d7e8f7); transition: all var(--t-base); }
  .picked-ball { width: 96px; height: 96px; margin: -8px 0; filter: drop-shadow(0 6px 8px rgba(6,33,63,.2)); }
  .picked-name { margin: 0; font: 400 40px/1 var(--f-display); }
  .picked-meta { margin: 4px 0 0; font: 600 15px var(--f-ui); color: #5a7896; }
  .snaprow { display: none; }
  .minigrid { display: none; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: 0 0 18px; }
  .minigrid .swatch, .snaprow .swatch { position: relative; transform: none; margin: 0; width: auto; height: auto; aspect-ratio: 1; }
  /* small grid balls: the check badge scales with the ball, so it sits on its shoulder instead of covering its face */
  .minigrid .swatch .check, .snaprow .swatch .check { width: max(16px, 40%); height: max(16px, 40%); right: -14%; top: -14%; background-size: 76% auto; background-position: 50% 30%; box-shadow: 0 0 0 2px var(--ink); }
  .history { display: flex; align-items: center; gap: 10px; margin: 0 0 18px; padding: 0 4px; font: 600 14px var(--f-ui); color: #5a7896; }
  .history-balls { display: flex; }
  .history-balls img { width: 40px; height: 40px; margin-right: -8px; filter: drop-shadow(0 2px 2px rgba(6,33,63,.2)); }
  .history kbd { display: inline-grid; place-items: center; min-width: 30px; height: 28px; padding: 0 6px; border-radius: 8px; background: #fff; border: 2px solid #cfe2f3; border-bottom-width: 4px; font: 700 13px var(--f-ui); color: var(--ocean-700); }
  .history .keys { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
  .tip { display: flex; align-items: center; gap: 16px; }
  .tip .tip-art { width: 104px; flex: none; margin: -6px 0; }
  .tip { margin: 0; padding: 14px 16px; border-radius: 16px; background: rgba(11,93,184,.06); font-size: 15px; color: #33557a; }
  .tip b { color: var(--ocean-900); }

  /* fields */
  .field { position: relative; margin-bottom: 12px; }
  .field label, .label-row label { display: block; margin: 0 0 6px; font: 600 16px var(--f-ui); color: var(--ocean-900); }
  .label-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
  .label-row label { margin: 0; }
  .control { position: relative; display: flex; align-items: center; }
  .control input, .control select { width: 100%; height: 56px; padding: 0 64px 0 18px; border-radius: var(--r-input); border: 2px solid #bcd6ee; background: #fff;
    font: 700 20px var(--f-ui); color: var(--ocean-900); letter-spacing: .01em; box-shadow: inset 0 2px 0 rgba(6,33,63,.05); transition: border-color var(--t-fast), box-shadow var(--t-fast); }
  .control input::placeholder { color: #9bb3c9; font-weight: 500; }
  .control input:focus, .control select:focus { outline: none; border-color: var(--sky-300); box-shadow: 0 0 0 4px rgba(60,195,240,.28); }
  .count { position: absolute; right: 52px; font: 600 13px var(--f-ui); color: #7d98b3; }
  .state-ico { position: absolute; right: 14px; width: 28px; height: 28px; border-radius: 50%; display: none; }
  .field[data-state="ok"] input { border-color: var(--success); }
  .field[data-state="ok"] .state-ico { display: block; background: #e7f6e9 url(/site/create/art/ui/checkmark-green.png) center / 16px auto no-repeat; box-shadow: 0 0 0 2px var(--success) inset; }
  .field[data-state="bad"] input, .field[data-state="taken"] input { border-color: #e46b6b; background: #fff8f8; }
  .field[data-state="bad"] .state-ico, .field[data-state="taken"] .state-ico { display: block; background: #fdeaea url(/site/create/art/ui/errormark.png) center / 13px auto no-repeat; box-shadow: 0 0 0 2px #e46b6b inset; }
  .status { margin: 6px 0 0; min-height: 0; font: 600 15px/1.35 var(--f-ui); }
  .st { display: none; align-items: center; gap: 8px; }
  .st img { flex: none; }
  .st-ok { color: var(--success); }
  .st-taken, .st-bad { color: #b3261e; }
  .field[data-state="ok"] .st-ok, .field[data-state="taken"] .st-taken, .field[data-state="bad"] .st-bad { display: inline-flex; }
  .field[data-state="idle"] .status { display: none; }
  .hint { margin: 6px 0 0; font-size: 14px; line-height: 1.45; color: #56728f; }
  @media (min-width: 1024px) and (not ((orientation: landscape) and (max-height: 499px))) { .hint-more { display: none; } }
  .chips { display: none; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
  .field[data-state="taken"] .chips { display: flex; }
  .chip { min-height: 40px; padding: 0 16px; border-radius: var(--r-pill); border: 2px solid var(--ocean-700); background: #fff; color: var(--ocean-700); font: 600 15px var(--f-ui); box-shadow: 0 3px 0 rgba(11,93,184,.25); }
  .chip:hover { background: var(--ocean-700); color: #fff; }

  .toggle { display: inline-flex; align-items: center; gap: 10px; border: 0; background: none; padding: 4px 0; font: 700 12.5px var(--f-ui); letter-spacing: .08em; text-transform: uppercase; color: #4d6f91; }
  .toggle img { width: 50px; height: auto; }
  .toggle .t-off, .toggle[aria-pressed="false"] .t-on { display: none; }
  .toggle[aria-pressed="false"] .t-off { display: inline; }

  .meter { display: grid; grid-template-columns: repeat(3, 1fr) auto; gap: 6px; align-items: center; margin-top: 10px; }
  .meter i { height: 7px; border-radius: 6px; background: #dbe7f2; transition: background var(--t-base); }
  .meter-word { font: 700 13px var(--f-ui); color: var(--success); margin-left: 6px; min-width: 50px; text-align: right; }
  [data-strength="1"] .meter i:nth-child(1) { background: #e0564f; }
  [data-strength="1"] .meter-word { color: #b3261e; }
  [data-strength="2"] .meter i:nth-child(-n+2) { background: var(--orange-500); }
  [data-strength="2"] .meter-word { color: #b86a00; }
  [data-strength="3"] .meter i { background: var(--success); }
  #f-pass .status { display: none; }
  #f-pass[data-state="bad"] .status { display: block; }
  #f-pass[data-state="bad"] #pass-hint { display: none; }
  #f-pass .hint { margin-top: 6px; }
  .sticky-pass { left: 6%; bottom: 8%; width: 26%; transform: rotate(4deg) translateY(-30px); }
  body[data-step="2"] .sticky-pass { transform: rotate(4deg); }

  .step[data-step="2"] .h1 { font-size: clamp(32px, 2.9vw, 42px); margin-bottom: 12px; }
  .field[data-state="taken"] #name-hint { display: none; }

  /* step 3 */
  .dob { display: grid; grid-template-columns: 1.3fr 1fr; gap: 14px; }
  .control.select::after { content: ""; position: absolute; right: 18px; width: 12px; height: 12px; border-right: 3px solid var(--ocean-700); border-bottom: 3px solid var(--ocean-700); transform: translateY(-3px) rotate(45deg); pointer-events: none; }
  .control select { appearance: none; padding-right: 48px; cursor: pointer; }
  .callout { display: flex; gap: 14px; align-items: center; margin: 22px 0 16px; padding: 16px 18px; border-radius: 18px; background: linear-gradient(135deg, #e6f7ff, #f5fbff); border: 2px solid #b5def5; }
  .callout img { width: 48px; height: auto; flex: none; }
  .callout p { margin: 0; font-size: 16px; line-height: 1.45; color: #1f4468; }
  .callout b { color: var(--ocean-900); }
  .fineprint { display: flex; gap: 12px; align-items: center; margin: 0; font-size: 14.5px; color: #56728f; }
  .fineprint img { width: 34px; height: auto; flex: none; }

  /* step 4: pledge cards */
  .pledge-count { display: inline-block; margin-left: 6px; padding: 2px 12px; border-radius: var(--r-pill); background: var(--ice-50); font: 600 14px/1.6 var(--f-ui); color: var(--ocean-700); white-space: nowrap; }
  .pledges { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; perspective: 900px; }
  .pledge { position: relative; display: grid; container-type: inline-size; min-height: 126px; padding: 0; border: 0; background: none; border-radius: 20px; text-align: left; transform-style: preserve-3d; transition: transform var(--t-slow) var(--ease-spring); }
  .pledge[aria-pressed="true"] { transform: rotateY(180deg); }
  .face { position: relative; grid-area: 1 / 1; min-width: 0; display: grid; align-content: start; grid-template-columns: auto 1fr; column-gap: 12px; row-gap: 2px; padding: 16px 16px 14px; border-radius: 20px; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
  .face.front { background: #fff; border: 2px solid #cfe2f3; box-shadow: 0 4px 0 #cfe2f3; }
  .pledge:hover .face.front { border-color: var(--sky-300); box-shadow: 0 4px 0 var(--sky-300); }
  .face.front img { grid-row: span 2; width: 44px; height: auto; align-self: center; }
  .face b { font: 400 20px/1.1 var(--f-display); color: var(--ocean-900); align-self: end; }
  .face small { font-size: 13.5px; line-height: 1.35; color: #4a6785; }
  .face.front em { grid-column: 1 / -1; margin-top: auto; padding-top: 10px; font: 700 12px var(--f-ui); font-style: normal; letter-spacing: .1em; text-transform: uppercase; color: var(--ocean-700); display: flex; align-items: center; gap: 6px; }
  .face.front em::before { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2px dashed var(--ocean-700); }
  .face.back { transform: rotateY(180deg); grid-template-columns: auto 1fr; align-content: center; color: #fff;
    background: linear-gradient(160deg, #1a7fe0, var(--ocean-700) 55%, #0a4b98); border: 3px solid var(--gold-500); box-shadow: 0 4px 0 #b88a00, 0 10px 20px rgba(11,93,184,.25); }
  .face.back b { color: #fff; }
  .face.back small { color: #d8ecff; font-weight: 700; }
  .tick { grid-row: span 2; width: 46px; height: 46px; border-radius: 50%; align-self: center; background: #fff url(/site/create/art/ui/icon-checkmark.png) 50% 5px / 36px auto no-repeat; box-shadow: 0 0 0 3px var(--ink); }
  .verify { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; }
  .verify .agree { flex: 1 1 200px; }
  /* narrow cards: icon above the words */
  @container (max-width: 215px) {
    .face { grid-template-columns: 1fr; padding: 14px 12px 12px; }
    .face.front img { grid-row: auto; width: 38px; margin-bottom: 4px; }
    .face.back { justify-items: start; }
    .tick { grid-row: auto; width: 40px; height: 40px; background-size: 30px auto; margin-bottom: 6px; }
  }
  .agree { margin: 0; font-size: 13.5px; line-height: 1.45; color: #4a6785; }
  .agree a { font-weight: 700; }


  /* action bar */
  .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 18px; padding-top: 16px; border-top: 2px solid rgba(11,93,184,.08); }
  .btn-back { flex: none; width: 56px; height: 56px; padding: 0; border: 0; border-radius: 50%; background: var(--ocean-700); box-shadow: 0 4px 0 var(--ocean-900); transition: transform var(--t-fast); display: grid; place-items: center; }
  .btn-back img { width: 56px; height: 56px; }
  .btn-back:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ocean-900); }
  .btn-back[hidden] { display: grid; visibility: hidden; }
  .why { flex: 1 1 0; margin: 0; font: 600 14px/1.3 var(--f-ui); color: #5a7896; text-align: right; }
  body[data-step="4"] .why { order: -1; flex: 1 0 100%; }
  .why:empty { display: none; }
  .actions .cta { margin-left: auto; }
  .cta { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 60px; padding: 0 30px 0 34px; border-radius: var(--r-pill);
    border: var(--outline); background: linear-gradient(180deg, #FFE97A 0%, var(--gold-400) 30%, var(--gold-600) 100%); color: var(--ocean-900);
    font: 400 24px/1 var(--f-display); letter-spacing: .03em; text-transform: uppercase; text-decoration: none; white-space: nowrap;
    box-shadow: inset 0 2px 0 rgba(255,255,255,.85), inset 0 -4px 0 rgba(214,142,0,.35), 0 6px 0 var(--ink), 0 14px 24px rgba(6,33,63,.25);
    transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out), filter var(--t-fast); }
  .cta::before { content: ""; position: absolute; left: 14px; right: 14px; top: 5px; height: 38%; border-radius: var(--r-pill); background: linear-gradient(rgba(255,255,255,.75), rgba(255,255,255,0)); pointer-events: none; }
  .cta svg { width: 24px; height: 24px; }
  .cta:hover { filter: brightness(1.04); }
  .cta:active { transform: translateY(4px) scale(.98); box-shadow: inset 0 2px 0 rgba(255,255,255,.85), inset 0 -4px 0 rgba(214,142,0,.35), 0 2px 0 var(--ink), 0 6px 12px rgba(6,33,63,.2); }
  .cta.is-off, .cta:disabled { cursor: not-allowed; filter: grayscale(.85) brightness(1.05); opacity: .6; box-shadow: inset 0 2px 0 rgba(255,255,255,.6), 0 4px 0 #6b7b8c; }

  .submitting { display: none; position: absolute; inset: 0; z-index: 20; border-radius: var(--r-card); place-content: center; justify-items: center; gap: 8px;
    background: rgba(234,246,255,.9); backdrop-filter: blur(8px); font: 400 28px var(--f-display); color: var(--ocean-900); }
  .submitting img { width: 150px; }
  .submitting p { margin: 0; }
  body.is-submitting .submitting { display: grid; }

  /* ------------------------------------------------------------------ finish: Waddle On! */
  .finish { position: relative; flex: 1; width: min(1320px, 100% - 56px); margin: 0 auto; padding: 4px 0 28px;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 44px; align-items: center; isolation: isolate; }
  .party { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
  .finish-card, .finish-copy { position: relative; z-index: 2; }
  .party img { position: absolute; top: 0; left: var(--x); width: var(--w); height: auto; }
  .party .confetti { animation: confetti-fall var(--dur) linear var(--delay) infinite; }
  .party .balloon { position: absolute; left: var(--x); width: var(--w); top: auto; bottom: 0; animation: balloon-rise var(--dur) var(--ease-bob) var(--delay) infinite; }
  .party .balloon img { position: static; display: block; width: 100%; }
  .party .balloon .str { position: absolute; left: 50%; top: 96%; width: 30%; translate: -50% 0; opacity: .7; }
  .zoom { position: absolute; z-index: 1; left: 0; right: 0; bottom: 0; height: 170px; pointer-events: none; overflow: visible; }
  .zoom .toboggan { position: absolute; inset: auto; left: 0; bottom: 0; width: 190px; aspect-ratio: 152 / 114; opacity: 1; animation: toboggan-zoom 5s linear var(--zoom-delay, -.55s) infinite; filter: drop-shadow(0 16px 14px rgba(0,0,0,.25)); }

  .finish-card { display: grid; justify-items: center; gap: 18px; }
  .pcard { position: relative; margin: 0; width: min(100%, 380px); padding: 12px; border-radius: 30px; background: linear-gradient(170deg, #2b8cf0, var(--ocean-700) 45%, #07407f);
    border: var(--outline); box-shadow: 0 10px 0 var(--ink), 0 40px 70px -18px rgba(2,16,40,.65); transform: rotate(-3deg); animation: card-pop 900ms var(--ease-spring) both; }
  .pcard-top { display: flex; justify-content: center; padding: 6px 0 12px; font: 700 30px/1 var(--f-ui); color: #fff; letter-spacing: .01em; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
  .pcard-stage { position: relative; overflow: hidden; aspect-ratio: 1 / 1; border-radius: 20px; background: radial-gradient(70% 70% at 50% 42%, #ffffff, #d8f0ff 58%, #9fd6f7); box-shadow: inset 0 0 0 3px rgba(255,255,255,.6); }
  .pcard-rays { position: absolute; left: 50%; top: 45%; width: 190%; aspect-ratio: 1; translate: -50% -50%; background: rgba(255,255,255,.9); -webkit-mask: url(/site/create/art/vec/rays.svg) center / contain no-repeat; mask: url(/site/create/art/vec/rays.svg) center / contain no-repeat; animation: spin 60s linear infinite; }
  .avatar { position: absolute; inset: -9% -12% -9%; }
  .avatar img { position: absolute; inset: 0; width: 100%; height: 100%; }
  .avatar .l-colour { z-index: 15010; } .avatar .l-head { z-index: 60070; }
  .pcard-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 8px 4px; color: #fff; font: 600 15px var(--f-ui); }
  .pm-colour { display: inline-flex; align-items: center; gap: 8px; }
  .pm-colour img { width: 34px; height: 34px; }
  .pm-colour b { font: 400 20px var(--f-display); }
  .pm-date b { font-weight: 700; }
  .pcard-foot { margin: 6px 0 0; text-align: center; font: 600 10.5px var(--f-ui); letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.6); }

  .finish-copy { position: relative; display: grid; gap: 16px; justify-items: start; color: #fff; }
  .waddle { margin: 0; font: 400 clamp(52px, 5.8vw, 92px)/.92 var(--f-comic); letter-spacing: .02em; color: var(--gold-500);
    -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink), 0 18px 30px rgba(0,0,0,.3); transform: rotate(-2deg); transform-origin: left bottom; }
  .waddle span { color: #fff; }
  .finish-lede { margin: 0; font-size: 20px; color: #e3f2ff; max-width: 40ch; text-shadow: 0 1px 2px rgba(0,24,70,.55), 0 0 18px rgba(0,40,110,.5); }
  .pm-date { white-space: nowrap; }
  .gift { display: flex; align-items: center; gap: 14px; padding: 10px 20px 10px 10px; border-radius: 22px; background: rgba(255,255,255,.12); border: 2px solid rgba(255,255,255,.22); backdrop-filter: blur(8px); }
  .gift img { width: 60px; height: 60px; background: #fff; border-radius: 16px; padding: 4px; box-shadow: var(--lift-1); }
  .gift p { margin: 0; display: grid; }
  .gift b { font: 400 21px var(--f-display); letter-spacing: .01em; }
  .gift span { font-size: 15px; color: #cfe6ff; }


  .remember { display: flex; align-items: center; gap: 12px; font: 600 16px var(--f-ui); color: #e3f2ff; cursor: pointer; }
  .remember .toggle { padding: 0; }
  .cta-play { min-height: 76px; padding: 0 44px 0 52px; font-size: 34px; }
  .cta-play svg { width: 30px; height: 30px; }

  /* ------------------------------------------------------------------ under-13 stop page */
  .stop { flex: 1; width: min(1180px, 100% - 56px); margin: 0 auto; padding: 8px 0 32px; align-items: center; }
  .stop-card { display: grid; grid-template-columns: 1fr 1.05fr; border-radius: 36px; overflow: hidden; background: linear-gradient(180deg, #fff, var(--ice-50)); box-shadow: var(--lift-3); min-height: 560px; }
  .stop-stage { position: relative; isolation: isolate; overflow: hidden;
    background: radial-gradient(60% 55% at 50% 45%, #fff, transparent 70%), linear-gradient(180deg, color-mix(in oklab, var(--penguin) 18%, #F3FAFF), color-mix(in oklab, var(--penguin) 26%, #E3F1FC)); }
  .stop-stage .stage-rays { top: 44%; }
  .stop-stage .doll { inset: auto; left: 50%; top: 45%; width: 52%; aspect-ratio: 194 / 262; translate: -50% -50%; animation: wave-bye 2.4s var(--ease-bob) infinite; transform-origin: 50% 100%; }
  .stop-puffle { position: absolute; width: 17%; height: auto; filter: drop-shadow(0 8px 6px rgba(6,33,63,.18)); animation: puffle-hop 1.6s var(--ease-bob) infinite; }
  .stop-puffle.p1 { left: 7%; bottom: 8%; animation-delay: -.2s; }
  .stop-puffle.p2 { left: 25%; bottom: 3%; width: 15%; animation-delay: -.9s; }
  .stop-puffle.p3 { right: 23%; bottom: 3%; width: 15%; animation-delay: -.5s; }
  .stop-puffle.p4 { right: 6%; bottom: 8%; animation-delay: -1.3s; }
  .stop-copy { padding: 56px 56px 48px; display: grid; align-content: center; justify-items: start; gap: 4px; }
  .stop-copy .waddle { font-size: clamp(48px, 4.8vw, 74px); margin: 16px 0 18px; }
  .stop-copy .lede { font-size: 19px; }
  .stop-safe { display: flex; align-items: center; gap: 10px; margin: 0 0 26px; padding: 12px 16px; border-radius: 14px; background: #eaf7ec; color: #1d5e2a; font: 600 15px var(--f-ui); }
  .stop-actions { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
  .btn-link { font: 600 17px var(--f-ui); color: var(--ocean-700); text-underline-offset: 4px; }
}

/* ------------------------------------------------------------------ per-step stage choreography */
@layer steps {
  body:not([data-step="1"]) .ring, body:not([data-step="1"]) .stage-caption { opacity: 0; pointer-events: none; }
  body:not([data-step="1"]) .ring .swatch { transform: rotate(var(--a)) translate(0) rotate(calc(-1 * var(--a))) scale(.2); }
  body:not([data-step="1"]) .colour-chip { opacity: 1; transform: none; pointer-events: auto; }
  .ring, .stage-caption { transition: opacity var(--t-base); }

  /* 1: waving inside the ring */
  body[data-step="1"] .doll-wrap { width: min(36%, 262px); top: 46%; }
  body[data-step="1"] .buckets { opacity: 0; }

  /* 2: standing, holding up the name; the two 2008 sticky notes pinned to the stage */
  body[data-step="2"] .doll-waving { opacity: 0; }
  body[data-step="2"] .doll-standing { opacity: 1; }
  body[data-step="2"] .doll-wrap { top: 55%; width: min(38%, 290px); }
  body[data-step="2"] .bubble { opacity: 1; transform: none; }
  body[data-step="2"] .sticky { opacity: 1; visibility: visible; transition-delay: 0s; }
  body[data-step="2"] .sticky-real { transform: rotate(-6deg); }
  body[data-step="2"] .sticky-checked { transform: rotate(5deg); }
  body[data-step="2"] .buckets { opacity: 1; }
  body[data-step="2"] .stage-bloom { top: 55%; }

  /* 3: hatch day, the "...Almost done!" toboggan penguin, in your colour */
  body[data-step="3"] .doll { opacity: 0; }
  body[data-step="3"] .toboggan { opacity: 1; animation: sled 3.2s var(--ease-bob) infinite; }
  body[data-step="3"] .doll-wrap { width: min(62%, 460px); aspect-ratio: 152 / 114; top: 50%; }

  .hatch-balloons { position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0; transition: opacity var(--t-base); }
  .hatch-balloons .hb { position: absolute; width: 11%; animation: hb-float 5s var(--ease-bob) infinite; }
  .hatch-balloons .hb img { display: block; width: 100%; }
  .hatch-balloons .hb .str { position: absolute; left: 50%; top: 95%; width: 34%; translate: -50% 0; opacity: .75; }
  .hb.b1 { left: 12%; top: 16%; } .hb.b2 { left: 22%; top: 30%; width: 9%; animation-delay: -1.7s; } .hb.b3 { right: 13%; top: 14%; width: 12%; animation-delay: -3.1s; } .hb.b4 { right: 24%; top: 32%; width: 8.5%; animation-delay: -.8s; }
  body[data-step="3"] .hatch-balloons { opacity: 1; }
  .toboggan-shadow { position: absolute; left: 50%; bottom: 24%; width: 44%; height: 5%; translate: -50% 0; border-radius: 50%; background: radial-gradient(closest-side, rgba(6,33,63,.22), transparent); opacity: 0; z-index: 1; }
  body[data-step="3"] .toboggan-shadow { opacity: 1; animation: shadow-breathe 3.2s var(--ease-bob) infinite; }

  /* 4: the pledge, rule friends gather round */
  body[data-step="4"] .doll-wrap { width: min(34%, 250px); top: 52%; }
  body[data-step="4"] .friend { opacity: 1; }
  body[data-step="4"] .friend:not(.on) { opacity: .5; }
  body[data-step="4"] .friend.on::after { transform: scale(1); }
  body[data-step="4"] .friend.on { animation: friend-in var(--t-slow) var(--ease-spring) both; }
}

/* ------------------------------------------------------------------ layout modes (§3.5) */
@layer modes {
  /* tablet: two columns from 760 px (below that the panel is too narrow for the pledge cards and the widget) */
  @media (min-width: 760px) and (max-width: 1023px) and (not ((orientation: landscape) and (max-height: 499px))) {
    .studio { grid-template-columns: 45fr 55fr; width: calc(100% - 32px); gap: 18px; }
    .stage { position: sticky; top: 12px; align-self: start; height: min(720px, calc(100svh - 24px)); min-height: 480px; }
    .ring { display: none; }
    .minigrid { display: grid; }
    .stepper li { width: 76px; }
    .exit-text { display: none; }
  }

  /* desktop fits one screen: everything visible without scrolling at 1440x900 */
  @media (min-width: 1024px) and (min-height: 700px) {
    .studio { height: calc(100svh - var(--topbar-h) - 96px); min-height: 640px; }
    .panel { overflow: hidden; }
  }

  /* phone portrait */
  @media (max-width: 759px) and (min-height: 500px), (max-width: 759px) and (orientation: portrait) {
    :root { --topbar-h: 60px; }
    /* focus and error scrolls stop clear of the sticky top bar and the sticky action bar */
    html { scroll-padding: calc(var(--topbar-h) + 8px) 0 calc(96px + env(safe-area-inset-bottom)); }
    body { font-size: 16px; }
    .topbar { position: sticky; top: 0; grid-template-columns: auto 1fr auto; gap: 10px; padding: 0 12px; height: var(--topbar-h);
      background: rgba(8,70,145,.82); backdrop-filter: blur(12px) saturate(1.2); box-shadow: 0 1px 0 rgba(255,255,255,.1), 0 8px 20px rgba(2,20,48,.18); }
    .brand img { width: 84px; }
    .stepper-title { display: none; }
    .stepper { display: grid; justify-items: center; gap: 4px; }
    .stepper li { width: 34px; }
    .stepper li + li::before { top: 11px; right: calc(50% + 9px); width: calc(100% - 18px); height: 3px; }
    .node { width: 24px; height: 24px; }
    .node::before { width: 12px; height: 12px; border-width: 2.5px; }
    .node .star { width: 32px; height: 32px; inset: -4px; }
    .lbl { display: none; }
    .stepper-now { display: block; font: 600 11.5px/1 var(--f-ui); letter-spacing: .06em; text-transform: uppercase; color: rgba(255,255,255,.8); }
    .stepper-now b { color: var(--gold-500); margin-left: 6px; }
    .exit-text { display: none; }
    .exit img { width: 38px; height: 38px; }

    .studio { display: block; width: 100%; padding: 12px 12px 0; }
    /* until create.js has drawn the first step (a taller panel and the colour row) the studio holds a screen's height, so
       the footer never flashes into view and then jumps away (layout shift); afterwards the content is taller anyway */
    body:not([data-ready]) .studio { min-height: calc(100svh - var(--topbar-h)); }
    /* ...and the colour row keeps the room its swatches (58px, drawn by create.js) will take, so the form never jumps down */
    body:not([data-ready]) .snaprow { min-height: 88px; }
    .stage { height: 40svh; min-height: 300px; border-radius: 28px; }
    .stage-caption { bottom: 12px; }
    .caption-name { font-size: 20px; padding: 5px 16px 5px 6px; }
    .caption-name img { width: 30px; height: 30px; }
    .btn-soft { min-height: 44px; padding: 0 16px; font-size: 15px; }
    .ring { display: none; }
    /* the stage is wider than tall on bigger phones: the doll follows the smaller side, so the name bubble never meets the colour chip */
    body[data-step="1"] .doll-wrap { width: min(40%, 44cqh); top: 43%; }
    body[data-step="2"] .doll-wrap { width: min(34%, 37cqh); top: 60%; }
    body[data-step="2"] .bubble span { font-size: 19px; }
    .sticky-real { width: min(27%, 34cqh); left: 3%; top: 21%; }
    .sticky-checked { width: min(27%, 34cqh); right: 3%; top: 49%; }
    .buckets { display: none; }
    body[data-step="3"] .doll-wrap { width: min(68%, 92cqh); }
    body[data-step="4"] .doll-wrap { width: min(30%, 33cqh); top: 55%; }
    .friend { width: 22%; }
    .friend.f-respect { left: 3%; bottom: 7%; } .friend.f-chat { right: 4%; bottom: 8%; width: 19%; }
    .friend.f-safe { left: 6%; top: 18%; width: 18%; } .friend.f-fair { right: 3%; top: 16%; width: 23%; }
    .colour-chip { left: 12px; top: 12px; }
    .colour-chip img { width: 32px; height: 32px; }

    .snaprow { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 20px 18px 10px; margin: 0 -12px; scrollbar-width: none; }
    .snaprow::-webkit-scrollbar { display: none; }
    .snaprow .swatch { flex: 0 0 58px; scroll-snap-align: center; }
    body:not([data-step="1"]) .snaprow { display: none; }

    .panel { margin-top: 12px; padding: 24px 20px 0; border-radius: 26px 26px 0 0; box-shadow: 0 -2px 0 rgba(255,255,255,.5) inset, 0 -10px 30px rgba(2,20,48,.2); }
    .h1 { font-size: 34px; }
    .lede { font-size: 16.5px; margin-bottom: 16px; }
    .picked { padding: 12px 14px; }
    .picked-ball { width: 72px; height: 72px; }
    .picked-name { font-size: 32px; }
    .control input, .control select { height: 54px; font-size: 19px; }
    .sticky-pass { right: -8px; top: -28px; width: 96px; }
    .pledges { gap: 10px; }
    .pledge { min-height: 150px; }
    .face { grid-template-columns: 1fr; padding: 14px 12px 12px; }
    .face.front img { grid-row: auto; width: 38px; margin-bottom: 4px; }
    .face b { font-size: 18px; }
    .face small { font-size: 12.5px; }
    .face.back { justify-items: start; }
    .tick { grid-row: auto; width: 40px; height: 40px; background-size: 30px auto; margin-bottom: 6px; }
    .verify { justify-content: center; }
    .agree { text-align: center; }
    .actions { position: sticky; bottom: 0; z-index: 8; margin: 22px -20px 0; padding: 12px 16px max(14px, env(safe-area-inset-bottom));
      background: rgba(255,255,255,.92); backdrop-filter: blur(14px); border-top: 1px solid rgba(11,93,184,.12); box-shadow: 0 -8px 20px rgba(2,20,48,.08); }
    .btn-back, .btn-back img { width: 52px; height: 52px; }
    .btn-back[hidden] { display: none; }
    .why { display: none; }
    body.shot-full .actions { position: relative; }
    .actions { flex-wrap: nowrap; }
    .cta { flex: 1; min-height: 56px; font-size: 21px; padding: 0 18px 0 22px; }
    /* the action bar's button shrinks with the screen instead of pushing the page sideways */
    .actions .cta { min-width: 0; font-size: clamp(17px, 5.4vw, 21px); padding: 0 16px 0 20px; gap: 8px; white-space: nowrap; }
    .sticky-pass { display: none; }
    @media (max-width: 379px) { .actions .cta svg { display: none; } .actions .cta { padding: 0 12px; } }
    .footer-inner { flex-direction: column; align-items: flex-start; gap: 10px; width: calc(100% - 32px); }
    .footer-links { flex-wrap: wrap; gap: 14px; }

    .finish { grid-template-columns: 1fr; gap: 16px; width: 100%; padding: 18px 16px 30px; justify-items: center; text-align: center; }
    .finish-copy { display: contents; }
    /* the big PLAY NOW sits right under the greeting, above the fold; the card, the gift and the toggle follow */
    .finish .waddle { order: 1; } .finish-lede { order: 2; } .cta-play { order: 3; } .finish-card { order: 4; margin: 6px 0 4px; } .gift { order: 5; }
      .waddle { font-size: 52px; transform: rotate(-2deg); transform-origin: center; }
    .finish-lede { font-size: 17px; }
    .pcard { width: 290px; }
    .pcard-top { font-size: 24px; }
    .finish-copy > * { position: relative; z-index: 2; }
      .gift { text-align: left; width: 100%; max-width: 520px; }
    .remember { order: 6; }
          .cta-play { width: 100%; max-width: 460px; min-height: 64px; font-size: 28px; }
    .zoom { display: none; }
    
    .stop { width: 100%; padding: 12px 12px 24px; }
    .stop-card { grid-template-columns: 1fr; min-height: 0; border-radius: 28px; }
    .stop-stage { height: 300px; }
    .stop-copy { padding: 26px 22px 28px; }
    .stop-copy .waddle { font-size: 46px; margin-bottom: 12px; }
    .stop-copy .lede { font-size: 17px; }
    .stop-actions { width: 100%; }
    .stop-actions .cta { width: 100%; }
  }

  /* phone landscape: two columns, preview left, action bar inline */
  @media (orientation: landscape) and (max-height: 499px) {
    :root { --topbar-h: 52px; }
    .topbar { padding: 0 max(16px, env(safe-area-inset-left)); }
    .brand img { width: 92px; }
    .stepper-title { display: none; }
    .stepper li { width: 62px; gap: 2px; }
    .stepper li + li::before { top: 11px; right: calc(50% + 10px); width: calc(100% - 20px); height: 3px; }
    .node { width: 24px; height: 24px; }
    .node::before { width: 12px; height: 12px; border-width: 2.5px; }
    .node .star { width: 30px; height: 30px; }
    .lbl { font-size: 10.5px; }
    .exit-text { display: none; }
    .exit img { width: 36px; height: 36px; }
    .studio { grid-template-columns: 40fr 60fr; gap: 12px; width: calc(100% - max(24px, env(safe-area-inset-left) + env(safe-area-inset-right) + 16px)); padding: 4px 0 12px; }
    .stage { position: sticky; top: 8px; height: calc(100svh - var(--topbar-h) - 20px); min-height: 0; border-radius: 22px; }
    .ring { display: none; }
    .stage-caption { bottom: 8px; }
    .caption-name { font-size: 18px; padding: 4px 14px 4px 5px; }
    .caption-name img { width: 26px; height: 26px; }
    .stage-caption .btn-soft { display: none; }
    .sticky, .buckets { display: none; }
    body[data-step="1"] .doll-wrap { width: 40%; top: 44%; }
    body[data-step="2"] .doll-wrap { width: 30%; top: 63%; }
    body[data-step="2"] .bubble span { font-size: 16px; }
    .panel { padding: 18px 20px 16px; border-radius: 22px; }
    .h1 { font-size: 30px; }
    .lede { font-size: 15.5px; margin-bottom: 12px; }
    .picked { display: none; }
    .minigrid { display: grid; gap: 6px; }
    .tip { display: none; }
    .actions { margin-top: 12px; padding-top: 12px; }
    .cta { min-height: 52px; font-size: 20px; }
    .btn-back, .btn-back img { width: 50px; height: 50px; }
    .footer-inner { padding-top: 8px; }
    .disclaimer { font-size: 11.5px; }
    .footer-links { display: none; }
    .finish { grid-template-columns: .62fr 1.38fr; gap: 16px; padding: 6px 0 14px; width: calc(100% - 32px); align-items: start; }
    .pcard { width: 206px; padding: 8px; border-radius: 22px; }
    .pcard-top { font-size: 18px; padding: 2px 0 8px; }
    .pcard-meta { font-size: 11px; padding: 8px 4px 0; } .pm-colour b { font-size: 15px; } .pm-colour img { width: 24px; height: 24px; }
    .pcard-foot { font-size: 8px; }
    .finish-card .btn-soft { min-height: 38px; font-size: 13px; }
    .waddle { font-size: 40px; }
    .finish-lede, .gift { display: none; }
        .remember { font-size: 13.5px; }
    .remember .toggle img { width: 42px; }
    .cta-play { min-height: 50px; font-size: 22px; padding: 0 26px 0 30px; }
    .finish-copy { gap: 8px; }
    .zoom .toboggan { width: 120px; }
    body[data-step="1"] .lede, .history { display: none; }
    .stop-card { min-height: 0; }
    .stop-copy { padding: 22px 26px; }
    .stop-copy .waddle { font-size: 38px; }
    /* the copy column is taller than the screen: the waving penguin and its puffles stay in the first screen */
    .stop-card { grid-template-columns: .8fr 1.2fr; }
    .stop-stage { align-self: start; height: max(250px, calc(100svh - 96px)); }
  }
}

/* ------------------------------------------------------------------ which screen is showing (wins over layout modes) */
@layer views {
  .finish, .stop { display: none; }
  body[data-view="finish"] .studio, body[data-view="stop"] .studio { display: none; }
  body[data-view="finish"] .finish { display: grid; }
  body[data-view="stop"] .stop { display: grid; }
  body[data-view="stop"] .stop-stage .doll { opacity: 1; }   /* the stop comes from step 3, whose rule hides the studio dolls */
  body[data-view="stop"] .stepper { visibility: hidden; }
}

/* ------------------------------------------------------------------ motion */
@layer motion {
  @keyframes spin { to { rotate: 360deg; } }
  @keyframes snowfall { to { transform: translateY(240px); } }
  @keyframes step-in { from { opacity: 0; transform: translateX(26px); } to { opacity: 1; transform: none; } }
  @keyframes drop-fly {
    0% { opacity: 0; transform: rotate(var(--rot)) translateX(calc(var(--k) * .25cqmin)) scale(.5); }
    12% { opacity: 1; }
    70% { opacity: 1; }
    100% { opacity: 0; transform: rotate(var(--rot)) translateX(calc(var(--k) * 1cqmin)) scale(var(--s, 1)); }
  }
  @keyframes ring-out { 0% { opacity: .9; transform: scale(.35); } 100% { opacity: 0; transform: scale(1); } }
  @keyframes bloom { 0% { opacity: .4; scale: .6; } 40% { opacity: 1; scale: 1.15; } 100% { opacity: .8; scale: 1; } }
  @keyframes doll-squash { 0% { transform: none; } 30% { transform: scale(1.06, .92) translateY(4%); } 60% { transform: scale(.97, 1.04) translateY(-3%); } 100% { transform: none; } }
  @keyframes sled { 0%, 100% { transform: translate(-3%, 0) rotate(-2deg); } 50% { transform: translate(3%, -4%) rotate(2deg); } }
  @keyframes hb-float { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-14px) rotate(3deg); } }
  @keyframes shadow-breathe { 0%, 100% { transform: scaleX(1); opacity: 1; } 50% { transform: scaleX(.86); opacity: .7; } }
  @keyframes friend-in { from { transform: scale(.6) translateY(20px); } to { transform: none; } }
  @keyframes wave-bye { 0%, 100% { rotate: -2deg; } 50% { rotate: 2deg; } }
  @keyframes puffle-hop { 0%, 100% { transform: translateY(0) scale(1, 1); } 20% { transform: translateY(0) scale(1.08, .9); } 50% { transform: translateY(-22%) scale(.96, 1.05); } 80% { transform: translateY(0) scale(1.05, .95); } }
  @keyframes confetti-fall {
    0% { transform: translate3d(0, -12vh, 0) rotate(var(--r0)); }
    100% { transform: translate3d(var(--sway), 112vh, 0) rotate(var(--r1)); }
  }
  @keyframes balloon-rise {
    0% { transform: translate3d(0, 30vh, 0) rotate(-4deg); }
    50% { transform: translate3d(var(--sway), -40vh, 0) rotate(4deg); }
    100% { transform: translate3d(0, -115vh, 0) rotate(-4deg); }
  }
  @keyframes toboggan-zoom {
    0% { transform: translateX(-240px) rotate(-6deg); }
    8% { transform: translateX(3vw) translateY(-6px) rotate(-3deg); }
    100% { transform: translateX(115vw) translateY(-40px) rotate(-10deg); }
  }
  @keyframes card-pop { from { transform: rotate(-3deg) scale(.7) translateY(40px); opacity: 0; } to { transform: rotate(-3deg); opacity: 1; } }

  /* reduced motion: still frames, instant state changes, no splash/confetti/flips/toboggan (§3.4, §6.6) */
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    .party, .zoom, .splash, .backdrop-snow { display: none !important; }
  }
}

/* ------------------------------------------------------------------ live-site additions */
@layer components {
  [hidden] { display: none !important; }
  .skip { position: fixed; left: 12px; top: -60px; z-index: 100; padding: 10px 16px; border-radius: 12px; background: var(--gold-500); color: var(--ocean-900); font: 600 16px var(--f-ui); }
  .skip:focus { top: 12px; }
  /* Cloudflare Turnstile: the real widget (an iframe from challenges.cloudflare.com) renders into #turnstile */
  .ts-slot { min-width: 0; min-height: 65px; display: grid; align-items: center; }
  .ts-slot[data-state="off"] { display: none; }
  .ts-slot[data-state="waiting"] #ts-widget { display: none; }
  .ts-slot:not([data-state="waiting"]) .ts-wait { display: none; }
  .ts-wait { margin: 0; max-width: 300px; padding: 12px 14px; border-radius: 14px; border: 2px dashed #bcd6ee; font: 600 13.5px/1.35 var(--f-ui); color: #4d6f91; }
  .form-error { margin: 14px 0 0; padding: 12px 14px; border-radius: 14px; background: #fff1f0; border: 2px solid #f2b8b5; color: #8c1d18; font: 600 15px/1.4 var(--f-ui); }
  .remember { display: flex; align-items: center; gap: 12px; font: 600 16px var(--f-ui); color: #e3f2ff; }
  .remember .toggle { padding: 0; }
  .remember .toggle img { width: 50px; }
}
