/* Comic Creator — the web version of the assembly app's story machine.

   Hero Blue background, a Deep School Blue drum machine with gold trim, and
   Luckiest Guy in capitals for everything. No text shadows anywhere.

   Two layouts:
   - Wide (landscape, 700px+): a 16:9 stage sized in --u (1% of the stage
     width), exactly like the assembly app, so it scales to any window.
   - Compact (phones, portrait tablets, short landscape windows): a normal
     top-to-bottom page. The three options stack as rows, each with its own
     LOCK and CHOOSE! buttons beside the reel, and the page scrolls vertically
     if it has to — never sideways.
   The same media query is repeated in comic-creator.js (COMPACT). */

@font-face {
    font-family: 'Luckiest Guy';
    src: url('../fonts/LuckiestGuy.woff2') format('woff2');
    font-weight: 400;
    font-display: block;
}

:root {
    --blue: #1E69FF;        /* Hero Blue */
    --yellow: #FCEE41;
    --navy: #1E2A4A;
    --machine: #0014A5;     /* Deep School Blue */
    --pad: #2F46E0;
    --pink: #FF2FA6;
    --orange: #FF7A02;
    --green: #BEFF00;
    --u: min(1vw, 1.7778vh); /* 1% of a 16:9 box that fits the window */
    --emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
html, body { margin: 0; }

body.cc {
    font-family: 'Luckiest Guy', Impact, 'Arial Black', sans-serif;
    text-transform: uppercase;
    font-weight: 400;
    letter-spacing: 0.02em;
    background: var(--blue);
    color: #fff;
    height: 100vh; height: 100dvh;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
/* :where() keeps this at zero specificity, so each button's own size and colour wins. */
:where(body.cc) button {
    font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit;
    -webkit-user-select: none; user-select: none;
}
.cc-emoji { font-family: var(--emoji); letter-spacing: 0; }
.cc-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* A visible focus ring for keyboard users, on every control. */
body.cc :is(button, a):focus-visible { outline: calc(var(--u) * 0.45) solid #fff; outline-offset: calc(var(--u) * 0.3); }

/* ---------- Back to the main site ---------- */
/* Wide screens: in the stage, not the window. Its left edge is the machine's outer left edge (the round's
   2u side padding less the machine's -0.5u margin = 1.5u), and it is centred on the heading's letters, which sit in the top of the heading's box (ink centre about 2.85u). */
.cc-home {
    position: absolute; z-index: 5;
    top: calc(var(--u) * 2.85); left: calc(var(--u) * 1.5); transform: translateY(-50%);
    display: block; line-height: 0; text-decoration: none;
}
.cc-home-logo { display: block; height: calc(var(--u) * 4.6); width: auto; }
.cc-home-icon { display: none; }

/* ---------- Stage and screens ---------- */
#cc-stage { position: relative; z-index: 1; width: calc(var(--u) * 100); height: calc(var(--u) * 56.25); }
.cc-screen { position: absolute; inset: 0; animation: ccFade 0.3s both; }

/* ---------- Buttons ---------- */
.cc-btn {
    font-size: calc(var(--u) * 3); line-height: 1; min-height: max(48px, calc(var(--u) * 6.4));
    padding: calc(var(--u) * 0.7) calc(var(--u) * 3.4);
    background: var(--yellow); color: var(--navy);
    border: calc(var(--u) * 0.45) solid var(--navy); border-radius: calc(var(--u) * 1.5);
    box-shadow: 0 calc(var(--u) * 0.5) 0 var(--navy);
    cursor: pointer;
}
/* The download link is an <a> dressed as a button, in white so Make another story! stays the main yellow one. */
/* The sound button. On a wide screen it is a round pill fixed to the bottom-right corner, clear of everything
   else; on a phone it joins the top row (see the compact block). Hidden until Start is pressed. */
.cc-mute {
    position: fixed; z-index: 5; right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom));
    display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; padding: 0;
    color: #fff; border: 3px solid rgba(255, 255, 255, 0.6); border-radius: 50%; background: rgba(30, 42, 74, 0.35); cursor: pointer;
}
.cc-mute-x { display: none; }
.cc-mute[aria-pressed="true"] .cc-mute-waves { display: none; }
.cc-mute[aria-pressed="true"] .cc-mute-x { display: inline; }
@media (hover: hover) { .cc-mute:hover { background: var(--navy); border-color: #fff; } }

a.cc-btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; text-align: center; }
.cc-btn--alt { background: #fff; }
@media (hover: hover) { .cc-btn--alt:hover:not(:disabled) { background: #eaf1ff; } }
.cc-btn--big { font-size: calc(var(--u) * 5.2); min-height: calc(var(--u) * 10); padding: calc(var(--u) * 1) calc(var(--u) * 6); border-radius: calc(var(--u) * 2.4); }
.cc-btn:active:not(:disabled) { transform: translateY(calc(var(--u) * 0.3)); box-shadow: 0 calc(var(--u) * 0.2) 0 var(--navy); }
.cc-btn:disabled { opacity: 0.45; cursor: default; }
@media (hover: hover) { .cc-btn:hover:not(:disabled) { background: #fff6a3; } }

/* ---------- Intro ---------- */
#cc-intro { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: calc(var(--u) * 2.4); }
.cc-logo { display: block; width: calc(var(--u) * 52); height: auto; }
.cc-intro-title { margin: calc(var(--u) * -0.6) 0 calc(var(--u) * 1.2); font-weight: 400; font-size: calc(var(--u) * 6.2); line-height: 1; color: var(--yellow); }

/* ---------- A round ---------- */
#cc-round { display: flex; flex-direction: column; align-items: stretch; padding: calc(var(--u) * 0.8) calc(var(--u) * 2) calc(var(--u) * 1.2); }
.cc-top { display: contents; }
.cc-step-short, .cc-spin-sub, .cc-question { display: none; }
.cc-step { position: absolute; z-index: 2; top: calc(var(--u) * 3.15); right: calc(var(--u) * 1.5); transform: translateY(-50%); margin: 0; font-size: calc(var(--u) * 2); color: #fff; opacity: 0.85; }
.cc-heading { flex: none; margin: 0; height: calc(var(--u) * 6.4); text-align: center; font-weight: 400; font-size: calc(var(--u) * 5.2); line-height: 1.15; color: var(--yellow); }
#cc-play { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }

/* The drum machine: Deep School Blue body, bevelled, with a gold gradient rim. */
#cc-machine {
    --trim: calc(var(--u) * 0.9);
    position: relative; flex: none; margin: calc(var(--u) * 0.4) calc(var(--u) * -0.5) 0;
    border: var(--trim) solid transparent; border-radius: calc(var(--u) * 3.2);
    background:
        linear-gradient(var(--machine), var(--machine)) padding-box,
        linear-gradient(165deg, #FFF48A 0%, #FCEE41 18%, #FFCA5F 42%, #FCEE41 62%, #FFCA5F 82%, #E8A93A 100%) border-box;
    box-shadow:
        inset 0 0 0 calc(var(--u) * 0.14) rgba(30, 42, 74, 0.85),
        inset 0 calc(var(--u) * 0.55) 0 #4A63F5,
        inset 0 calc(var(--u) * -0.9) 0 var(--navy),
        0 calc(var(--u) * 1.1) calc(var(--u) * 2.4) rgba(8, 12, 60, 0.55);
    padding: calc(var(--u) * 1.8) calc(var(--u) * 2.2) calc(var(--u) * 2.2);
}
#cc-reels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: calc(var(--u) * 1.8); }
.cc-opt { min-width: 0; display: flex; flex-direction: column; gap: calc(var(--u) * 1.2); }

/* The sunken window round each reel, with one fixed-height reel showing one option. */
.cc-frame {
    padding: calc(var(--u) * 0.8); background: #050a52; border-radius: calc(var(--u) * 1.8);
    box-shadow:
        inset 0 calc(var(--u) * 0.6) calc(var(--u) * 1.1) rgba(0, 0, 0, 0.75),
        inset 0 0 0 calc(var(--u) * 0.2) #02052e,
        0 calc(var(--u) * 0.3) 0 rgba(120, 150, 255, 0.45);
}
.cc-reel {
    position: relative; overflow: hidden; height: calc(var(--u) * 17.5);
    background: #fff; color: var(--navy);
    border: calc(var(--u) * 0.45) solid var(--navy); border-radius: calc(var(--u) * 1.2);
    transition: box-shadow 0.2s;
}
/* Drum shading: darker towards the top and bottom, clear across the middle. */
.cc-reel::after {
    content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
    background: linear-gradient(to bottom,
        rgba(30, 42, 74, 0.42) 0%, rgba(30, 42, 74, 0.16) 9%, rgba(30, 42, 74, 0.05) 20%, rgba(30, 42, 74, 0) 32%,
        rgba(30, 42, 74, 0) 68%, rgba(30, 42, 74, 0.05) 80%, rgba(30, 42, 74, 0.16) 91%, rgba(30, 42, 74, 0.42) 100%);
}
.cc-strip { position: absolute; top: 0; left: 0; right: 0; will-change: transform; }
.cc-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
    gap: calc(var(--u) * 0.2); padding: 0 calc(var(--u) * 1); overflow: hidden;
    font-size: calc(var(--u) * 3); line-height: 1.05;
}
.cc-item-emoji { font-family: var(--emoji); letter-spacing: 0; line-height: 1.1; font-size: calc(var(--u) * 5.2); }
/* A locked reel is ringed in yellow, so it reads as "kept" at a glance. */
.cc-opt.locked .cc-reel { box-shadow: 0 0 0 calc(var(--u) * 0.5) var(--yellow); }

/* Two separate, clearly labelled buttons under every option, with a clear gap between them. */
.cc-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: calc(var(--u) * 1.4); }
.cc-lock, .cc-choose {
    min-height: max(48px, calc(var(--u) * 5.6)); padding: 0 calc(var(--u) * 0.6);
    font-size: calc(var(--u) * 2.1); line-height: 1; white-space: nowrap; overflow: hidden;
    border: calc(var(--u) * 0.4) solid var(--navy); border-radius: calc(var(--u) * 1.4);
    box-shadow: 0 calc(var(--u) * 0.4) 0 var(--navy); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 0.3em;
}
.cc-lock { background: var(--pad); color: #fff; border-color: #fff; box-shadow: 0 calc(var(--u) * 0.4) 0 #02052e; }
.cc-lock[aria-pressed="true"] { background: #fff; color: var(--navy); border-color: var(--navy); box-shadow: 0 calc(var(--u) * 0.4) 0 var(--navy); }
.cc-choose { background: var(--yellow); color: var(--navy); }
.cc-lock:active:not(:disabled), .cc-choose:active:not(:disabled) { transform: translateY(calc(var(--u) * 0.3)); box-shadow: none; }
.cc-lock:disabled, .cc-choose:disabled { opacity: 0.45; cursor: default; }
/* Once the last spin has landed there is nothing left to lock: CHOOSE! takes the whole width. */
.cc-lock[hidden] + .cc-choose { grid-column: 1 / -1; }
@media (hover: hover) { .cc-choose:hover:not(:disabled) { background: #fff6a3; } .cc-lock:hover:not(:disabled):not([aria-pressed="true"]) { background: #4660f5; } }

#cc-controls { flex: none; display: flex; align-items: center; justify-content: center; gap: calc(var(--u) * 3); margin-top: calc(var(--u) * 1.8); }
.cc-goes { margin: 0; font-size: calc(var(--u) * 3.4); line-height: 1; color: #fff; }
.cc-goes:empty { display: none; }

/* The story so far, in the band left under the controls. */
.cc-story {
    flex: 1 1 0; min-height: 0; overflow: hidden; margin: 0; padding: calc(var(--u) * 0.5) calc(var(--u) * 1);
    display: flex; align-items: center; justify-content: center; text-align: center;
    font-size: calc(var(--u) * 2.4); line-height: 1.12; color: var(--yellow);
}

/* ---------- The chosen option ---------- */
#cc-chosen { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--u) * 1.6); }
.cc-chosen-main { display: contents; }
#cc-burst { position: relative; flex: none; width: calc(var(--u) * 74); height: calc(var(--u) * 30); rotate: -3deg; }
#cc-burst svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
#cc-burst polygon { fill: var(--yellow); stroke: var(--navy); stroke-width: calc(var(--u) * 0.9); stroke-linejoin: round; vector-effect: non-scaling-stroke; }
#cc-burst polygon.cc-burst-shadow { fill: var(--navy); }
#cc-burst-text {
    position: absolute; left: 23.5%; top: 29%; width: 53%; height: 42%;
    display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
    color: var(--navy); line-height: 1.02; font-size: calc(var(--u) * 8); overflow: hidden;
}
#cc-burst-text .cc-emoji { font-size: 0.95em; line-height: 1.1; }
#cc-burst.pop-in svg { animation: ccBurstSlam 0.35s both; }
#cc-burst.pop-in #cc-burst-text { animation: ccTextSlam 0.3s 0.32s both; }
.cc-chosen-story { flex: none; margin: 0; max-width: calc(var(--u) * 92); text-align: center; font-size: calc(var(--u) * 2.8); line-height: 1.15; color: #fff; }
.cc-chosen-story .new { color: var(--yellow); }

/* Speed lines: a full-window layer behind the stage, so they reach the real screen edges. */
#cc-speedlines { position: fixed; inset: 0; z-index: 0; width: 100%; height: 100%; overflow: hidden; pointer-events: none; }
#cc-speedlines.show { animation: ccLinesIn 0.45s cubic-bezier(0.2, 0.8, 0.3, 1) both; }
#cc-confetti { position: fixed; inset: 0; z-index: 3; width: 100%; height: 100%; pointer-events: none; }

/* ---------- The finished story ---------- */
#cc-final { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--u) * 2.2); padding: calc(var(--u) * 3) calc(var(--u) * 4); }
.cc-final-title { flex: none; margin: 0; font-weight: 400; font-size: calc(var(--u) * 6.4); line-height: 1; color: #fff; }
.cc-final-sentence {
    flex: 1 1 0; min-height: 0; width: 100%; margin: 0; overflow: hidden;
    display: flex; align-items: center; justify-content: center; text-align: center;
    color: var(--yellow); line-height: 1.12; font-size: calc(var(--u) * 7.4);
}
.cc-final-pitch { flex: none; margin: 0; max-width: calc(var(--u) * 80); text-align: center; font-size: calc(var(--u) * 2.2); line-height: 1.2; color: #fff; text-wrap: balance; }
/* Three buttons in one row, in order of importance: Subscribe (the call to action: the standard yellow),
   the download (white), then Make another story (quiet: no fill, no shadow), all the same size. */
.cc-story-actions { flex: none; display: flex; flex-wrap: nowrap; align-items: center; justify-content: center; gap: calc(var(--u) * 1.6); }
#cc-story-actions .cc-btn { white-space: nowrap; padding-inline: calc(var(--u) * 2); }
/* Subscribe is the standard yellow button; its hover and focus go a darker gold. */
.cc-btn--subscribe:focus-visible { background: #FFCA5F; }
/* Desktop: the three buttons are exactly the same size and the same text size (phones set their own below). */
.cc-story-actions > .cc-btn { flex: none; width: calc(var(--u) * 28.5); min-height: calc(var(--u) * 7); font-size: calc(var(--u) * 1.55); padding-block: 0; }
.cc-btn--quiet { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.7); box-shadow: none; }
.cc-btn--quiet:active:not(:disabled) { box-shadow: none; }
@media (hover: hover) {
    .cc-btn--subscribe:hover:not(:disabled) { background: #FFCA5F; }
    .cc-btn--quiet:hover:not(:disabled) { background: rgba(255, 255, 255, 0.15); }
}

/* ---------- Motion ---------- */
@keyframes ccFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ccMachineIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes ccLinesIn { 0% { transform: scale(0.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
/* A hard slam: in fast, a little over, a little under, then settled. */
@keyframes ccBurstSlam {
    0% { transform: scale(0); animation-timing-function: ease-in; }
    43% { transform: scale(1.15); animation-timing-function: ease-out; }
    71% { transform: scale(0.95); animation-timing-function: ease-in-out; }
    100% { transform: scale(1); }
}
@keyframes ccTextSlam {
    0% { transform: scale(0); animation-timing-function: ease-in; }
    43% { transform: scale(1.08); animation-timing-function: ease-out; }
    71% { transform: scale(0.97); animation-timing-function: ease-in-out; }
    100% { transform: scale(1); }
}

/* Reduced motion: no slam, no shake, no press movement — things simply fade in. */
@media (prefers-reduced-motion: reduce) {
    #cc-burst.pop-in svg, #cc-burst.pop-in #cc-burst-text { animation: ccFade 0.3s both; }
    #cc-speedlines.show { animation: ccFade 0.3s both; }
    .cc-btn:active:not(:disabled), .cc-lock:active:not(:disabled), .cc-choose:active:not(:disabled) { transform: none; }
    .cc-reel { transition: none; }
}

/* ======================= Compact layout =======================
   Phones, portrait tablets and short landscape windows. Keep in step with
   COMPACT in comic-creator.js.

   The rule here: the machine (all three reels, with their buttons) is ALWAYS
   fully visible, and everything else gives way to it. Each screen is one
   column the height of the visible screen (100dvh): a single top row (back
   arrow, heading, counter), the content, and the main button at the bottom
   above the safe area. The machine takes whatever height is left, split three
   ways; each row is a wide reel with a strip of buttons under it (a 48x48
   padlock, then CHOOSE! across the rest). The dock is an ordinary part of the
   column, never laid over anything. */
@media (max-width: 700px), (max-aspect-ratio: 1/1), (max-height: 480px) {
    :root {
        --safe-top: env(safe-area-inset-top, 0px);
        --safe-bottom: env(safe-area-inset-bottom, 0px);
        --btn: 48px;        /* the least a tappable control may be, each way */
    }
    body.cc {
        display: block; height: 100vh; height: 100dvh;
        overflow-x: hidden; overflow-y: auto;
        overscroll-behavior-y: none;
    }
    #cc-stage {
        display: flex; flex-direction: column; width: 100%; max-width: 580px; height: auto; margin: 0 auto;
        min-height: 100%;
        padding: calc(var(--safe-top) + 2px) max(16px, env(safe-area-inset-right)) calc(var(--safe-bottom) + 10px) max(16px, env(safe-area-inset-left));
    }
    .cc-screen { position: relative; inset: auto; flex: 1 1 auto; min-height: 0; height: auto; padding: 0; }
    body.cc :is(button, a):focus-visible { outline-width: 3px; outline-offset: 3px; }

    /* The top row: ← on the left (a 44px tap area), the heading in the middle, 1/5 on the right. One line. */
    .cc-top { display: grid; flex: none; grid-template-columns: 44px minmax(0, 1fr) auto 44px; align-items: center; column-gap: 6px; min-height: 44px; }
    .cc-home { position: static; transform: none; display: flex; align-items: center; justify-content: center; width: 44px; min-height: 44px; }
    .cc-home-logo { display: none; }
    /* The icon file as it is, in a Beyond Yellow border with slightly rounded corners (done here, not in the file). */
    .cc-home-icon { display: block; box-sizing: border-box; width: 34px; height: 34px; border: 3px solid #fbed41; border-radius: 6px; }
    .cc-heading {
        position: static; grid-column: 2; height: auto; margin: 0; pointer-events: auto;
        font-size: clamp(18px, 6.4vw, 28px); line-height: 1.1; white-space: nowrap; overflow: hidden;
    }
    .cc-step { position: static; transform: none; grid-column: 3; margin: 0; min-width: 0; text-align: right; font-size: 15px; letter-spacing: 0.04em; opacity: 0.9; }
    /* The sound button, at the right end of the row: a plain icon with a 44px tap area, like the arrow. */
    .cc-mute { position: static; grid-column: 4; width: 44px; height: 44px; border: 0; border-radius: 0; background: none; color: rgba(255, 255, 255, 0.85); }
    .cc-step-long { display: none; }
    .cc-step-short { display: inline; }

    .cc-btn { font-size: 22px; min-height: 52px; padding: 6px 24px; border-width: 4px; border-radius: 16px; box-shadow: 0 4px 0 var(--navy); }
    .cc-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 var(--navy); }
    .cc-btn--big { font-size: 38px; min-height: 78px; padding: 10px 44px; border-radius: 22px; }

    #cc-intro { gap: 18px; }
    .cc-logo { width: min(78vw, 340px); }
    .cc-intro-title { font-size: clamp(34px, 11vw, 56px); margin: -4px 0 12px; }

    /* ----- A round ----- */
    #cc-round { display: flex; flex-direction: column; padding: 0; }
    #cc-play { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

    /* The story so far: at most two lines, under the top row. */
    .cc-story {
        order: -1; flex: none; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
        margin: 2px 0 4px; padding: 0; max-height: 2.4em; overflow: hidden; text-align: center; font-size: 13px; line-height: 1.15;
    }

    /* The machine takes all the height there is, split three ways, never less than a row needs. */
    #cc-machine { flex: 1 1 auto; display: flex; flex-direction: column; margin: 0; --trim: 5px; border-radius: 22px; padding: 6px 6px 9px; }
    #cc-reels { flex: 1 1 auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(3, minmax(96px, 1fr)); gap: 10px; }

    /* Each option: a wide reel, and under it a strip of buttons. */
    /* Tighter inside an option than between options, so each reel reads as belonging to the strip under it. */
    .cc-opt { display: flex; flex-direction: column; gap: 4px; min-height: 0; }
    .cc-frame { flex: 1 1 0; min-height: 52px; padding: 5px; border-radius: 14px; box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.75), inset 0 0 0 2px #02052e; }
    .cc-reel { height: 100%; border-width: 3px; border-radius: 10px; container-type: size; }
    .cc-opt.locked .cc-reel { box-shadow: 0 0 0 3px var(--yellow); }

    /* An option is sized from its reel: emoji beside the words in a short reel, above them in a tall one. */
    .cc-item { flex-direction: row; gap: 0.35em; padding: 0 8px; font-size: 20px; font-size: min(38cqh, 7.4cqw); line-height: 1.05; }
    .cc-item-emoji { font-size: 1.5em; }
    @container (min-height: 112px) {
        .cc-item { flex-direction: column; gap: 2px; font-size: min(17cqh, 8cqw); }
        .cc-item-emoji { font-size: 2em; }
    }

    .cc-actions { flex: none; grid-template-columns: var(--btn) minmax(0, 1fr); gap: 8px; height: var(--btn); }
    .cc-lock, .cc-choose { min-height: var(--btn); border-width: 3px; border-radius: 12px; box-shadow: 0 3px 0 var(--navy); }
    .cc-lock { width: var(--btn); padding: 0; font-size: 24px; box-shadow: 0 3px 0 #02052e; }
    .cc-lock .cc-lock-label { display: none; }          /* the padlock says it; aria-label and aria-pressed say it to a screen reader */
    .cc-lock[aria-pressed="true"] { box-shadow: 0 3px 0 var(--navy); transform: translateY(2px); }
    .cc-choose { font-size: 22px; padding: 0 6px; }
    .cc-lock:active:not(:disabled), .cc-choose:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
    .cc-lock[hidden] + .cc-choose { grid-column: 1 / -1; }

    /* The dock: Spin, with the goes count as its second line. Plain flow, so it can never cover the machine. */
    #cc-controls { flex: none; flex-direction: column; gap: 0; margin: 0; padding: 8px 0 0; }
    #cc-spin { align-self: center; min-width: 64%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 4px 24px; line-height: 1; }
    .cc-spin-sub { display: block; font-size: 13px; letter-spacing: 0.04em; opacity: 0.8; }
    .cc-spin-sub:empty { display: none; }
    .cc-goes { display: none; }
    /* On the last go the button is gone and the same spot reads "Time to choose!". */
    #cc-controls.is-done .cc-goes { display: flex; align-items: center; justify-content: center; min-height: 52px; margin: 0; font-size: 26px; line-height: 1; }

    /* ----- The question card -----
       Before a round's first spin the machine stays out of sight and the question takes its place: as big as
       fits, in balanced lines, centred in the space above the Spin button. The small heading steps out of the
       top row (still there for screen readers) until the reels appear. */
    #cc-stage[data-phase="idle"] #cc-machine { display: none; }
    #cc-stage[data-phase="idle"] .cc-question {
        display: flex; flex: 1 1 auto; min-height: 0; align-items: center; justify-content: center; margin: 0; padding: 0 2px; overflow: hidden;
        text-align: center; font-size: clamp(44px, 17vw, 110px); line-height: 1.02; color: var(--yellow);
    }
    .cc-question > span { display: block; max-width: 100%; text-wrap: balance; overflow-wrap: normal; hyphens: none; }
    #cc-stage[data-phase="idle"] .cc-heading { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    /* Pressing Spin: the machine arrives with a quick rise and fade, while the reels are already turning. */
    #cc-machine { animation: ccMachineIn 0.22s ease-out both; }

    /* ----- The chosen option ----- */
    #cc-chosen { flex: 1 1 auto; justify-content: flex-start; align-items: stretch; gap: 0; min-height: 0; padding-top: 8px; }
    /* Centred with spacers rather than justify-content: spacers shrink to nothing when the space runs out, where centring would push the burst up over the top row. */
    .cc-chosen-main { display: flex; flex: 1 1 auto; flex-direction: column; align-items: center; gap: 0; min-height: 0; }
    .cc-chosen-main::before, .cc-chosen-main::after { content: ''; flex: 1 1 0; min-height: 0; }
    #cc-burst { margin-bottom: 16px; width: min(90vw, 520px); height: min(60vw, 340px); max-height: 40dvh; }
    #cc-burst-text { left: 20%; top: 24%; width: 60%; height: 52%; font-size: clamp(26px, 10vw, 54px); }
    .cc-chosen-story { max-width: 100%; font-size: clamp(16px, 5vw, 24px); line-height: 1.2; }
    #cc-next { flex: none; align-self: center; margin-top: 8px; min-width: 64%; }

    /* ----- The finished story ----- */
    #cc-final { padding: 0; gap: 12px; }
    .cc-final-title { font-size: clamp(34px, 11vw, 56px); }
    .cc-final-sentence { font-size: clamp(30px, 10vw, 52px); }
    .cc-final-pitch { max-width: 100%; font-size: clamp(15px, 4.4vw, 19px); }
    /* The three buttons stack, Subscribe on top, each at least 48px tall, with tight gaps so the longest story still fits. */
    #cc-final .cc-story-actions { flex-direction: column; align-self: stretch; gap: 8px; }
    #cc-subscribe, #cc-sheet, #cc-again { flex: none; width: 100%; max-width: 420px; }
    #cc-subscribe, #cc-sheet, #cc-again { font-size: 24px; min-height: 56px; padding-inline: 8px; }
    #cc-again { border-width: 4px; box-shadow: none; }
}

/* Reduced motion, phone layout: the machine appears instantly when Spin is pressed. (After the compact block, so it wins.) */
@media (prefers-reduced-motion: reduce) {
    #cc-machine { animation: none; }
}
