/* Fizzwick's Color Potions — lab scene, jars, cauldron, monsters. */

:root {
    --counter-h: clamp(148px, 21vh, 195px);
    --lab-wall-a: #E8DFF5;
    --lab-wall-b: #F6EFFB;
    --lab-wall-c: #FBEFDC;
    --wood: #C89B6C;
    --wood-dark: #9A6A38;
    --mud: #8B6F47;
}

#stage {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: var(--lab-wall-a);
}

.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 10;
}

/* ── Lab background ─────────────────────────────────────────────────────── */

#lab-bg { position: absolute; inset: 0; z-index: 1; }

#wall {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 18% 28%, rgba(255, 255, 255, 0.5) 0 7px, transparent 8px),
        radial-gradient(circle at 72% 14%, rgba(255, 255, 255, 0.42) 0 5px, transparent 6px),
        radial-gradient(circle at 46% 52%, rgba(255, 255, 255, 0.38) 0 6px, transparent 7px),
        radial-gradient(circle at 88% 44%, rgba(255, 255, 255, 0.4) 0 4px, transparent 5px),
        radial-gradient(circle at 8% 66%, rgba(255, 255, 255, 0.35) 0 5px, transparent 6px),
        linear-gradient(180deg, var(--lab-wall-a) 0%, var(--lab-wall-b) 55%, var(--lab-wall-c) 100%);
    background-size: 260px 220px, 300px 260px, 340px 300px, 280px 240px, 320px 280px, 100% 100%;
}

#pennant-line {
    position: absolute;
    top: -4px;
    left: -2%;
    width: 104%;
    height: clamp(52px, 8vh, 76px);
    opacity: 0.95;
}
#pennant-line svg { width: 100%; height: 100%; display: block; }

#wall-shelf {
    position: absolute;
    top: clamp(58px, 10vh, 96px);
    left: 50%;
    transform: translateX(-58%);
    width: clamp(240px, 30vw, 380px);
}
#wall-shelf svg { width: 100%; display: block; }

.glow-bottle { animation: bottle-glow 3.4s ease-in-out infinite; }
.glow-bottle.gb1 { animation-delay: 0.6s; }
.glow-bottle.gb2 { animation-delay: 1.2s; }
.glow-bottle.gb3 { animation-delay: 1.8s; }
.glow-bottle.gb4 { animation-delay: 2.4s; }
@keyframes bottle-glow { 0%, 100% { opacity: 0.75; } 50% { opacity: 1; } }

#wall-chart {
    position: absolute;
    right: clamp(8px, 4vw, 60px);
    top: clamp(96px, 17vh, 170px);
    width: clamp(110px, 13vw, 170px);
    transform: rotate(3deg);
    opacity: 0.95;
}
#wall-chart svg { width: 100%; display: block; }

/* decor gets out of the way per screen: the shelf hides behind the big title,
   the chart would sit under the GO button during the demo */
#stage.sc-title #wall-shelf { display: none; }
#stage.sc-howto #wall-chart { display: none; }

#counter {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--counter-h);
    background:
        repeating-linear-gradient(90deg,
            var(--wood) 0 118px, #BC8E5F 118px 122px,
            #D2A576 122px 240px, #B98A5C 240px 244px),
        var(--wood);
    box-shadow: 0 -6px 20px rgba(90, 60, 130, 0.22);
}

#counter-edge {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 18px;
    background: linear-gradient(180deg, #E9C494 0%, #D2A576 78%, rgba(122, 74, 38, 0.4) 100%);
    border-radius: 0 0 6px 6px;
}

/* ── Title screen ───────────────────────────────────────────────────────── */

#screen-title {
    justify-content: center;
    gap: clamp(4px, 1.2vh, 12px);
    padding-bottom: 2vh;
}

#game-title {
    font-size: clamp(2rem, 5.6vw, 3.4rem);
    line-height: 1.08;
    text-align: center;
    letter-spacing: 1px;
    text-shadow: 0 3px 0 rgba(255, 255, 255, 0.9), 0 7px 16px rgba(90, 60, 130, 0.25);
    margin-top: 1vh;
    max-width: 92vw;
}
#game-title span { display: inline-block; animation: letter-bounce 3s ease-in-out infinite; }
#game-title span:nth-child(6n+1) { color: #E63946; }
#game-title span:nth-child(6n+2) { color: #F77F00; }
#game-title span:nth-child(6n+3) { color: #E8A828; }
#game-title span:nth-child(6n+4) { color: #7CB518; }
#game-title span:nth-child(6n+5) { color: #00B4D8; }
#game-title span:nth-child(6n+6) { color: #B565D8; }
#game-title span:nth-child(odd) { animation-delay: 0.15s; }
#game-title span:nth-child(3n) { animation-delay: 0.3s; }
@keyframes letter-bounce {
    0%, 88%, 100% { transform: translateY(0); }
    94% { transform: translateY(-7px); }
}

#tagline {
    font-size: clamp(0.95rem, 2.4vw, 1.25rem);
    background: rgba(255, 255, 255, 0.72);
    border-radius: 30px;
    padding: 4px 20px;
    box-shadow: 0 3px 10px rgba(90, 60, 130, 0.12);
}

#title-art {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 0;
    height: clamp(130px, 22vh, 210px);
}

#title-fizz { width: clamp(120px, 20vh, 190px); height: 100%; }
#title-fizz svg { width: 100%; height: 100%; display: block; }

#title-pot { width: clamp(130px, 21vh, 200px); height: 86%; margin-left: -18px; }
#title-pot svg { width: 100%; height: 100%; display: block; }

.float-bub {
    position: absolute;
    border-radius: 50%;
    border: 3px solid rgba(181, 101, 216, 0.55);
    background: radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.9), rgba(214, 187, 240, 0.25));
    animation: bub-float 4.6s ease-in infinite;
    opacity: 0;
    pointer-events: none;
}
.fb1 { width: 22px; height: 22px; left: 38%; bottom: 55%; }
.fb2 { width: 15px; height: 15px; left: 47%; bottom: 62%; animation-delay: 1.5s; }
.fb3 { width: 28px; height: 28px; left: 55%; bottom: 50%; animation-delay: 3s; }
@keyframes bub-float {
    0% { transform: translateY(0) translateX(0); opacity: 0; }
    12% { opacity: 1; }
    100% { transform: translateY(-16vh) translateX(14px); opacity: 0; }
}

#btn-start { font-size: clamp(1.4rem, 4.4vw, 1.9rem); padding: 16px 54px; }

#level-row {
    display: flex;
    gap: clamp(14px, 3vw, 30px);
    align-items: flex-end;
    margin-top: clamp(2px, 1vh, 10px);
}

.level-bottle {
    position: relative;
    width: clamp(84px, 12vh, 112px);
    height: clamp(104px, 15vh, 138px);
    border: none;
    background: rgba(255, 255, 255, 0.65);
    border-radius: 22px;
    cursor: pointer;
    box-shadow: 0 5px 14px rgba(90, 60, 130, 0.18);
    transition: transform 0.18s, box-shadow 0.18s;
    padding: 6px 4px 2px;
}
.level-bottle:hover { transform: translateY(-3px); }
.level-bottle:active { transform: scale(0.94); }
.level-bottle.selected {
    box-shadow: 0 0 0 5px var(--gk-green), 0 8px 18px rgba(124, 181, 24, 0.35);
    background: #FFFFFF;
}
.level-bottle .lb-art { position: relative; display: block; width: 100%; height: 72%; }
.level-bottle .lb-art > svg.bottle-svg { width: 100%; height: 100%; display: block; }
.level-bottle .lb-icons {
    position: absolute;
    top: 52%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 1px;
    pointer-events: none;
}
.level-bottle .lb-icons .miniblob-svg { width: clamp(20px, 3vh, 26px); height: clamp(20px, 3vh, 26px); }
.level-bottle .lb-icons .lb-plus { color: #FFFFFF; font-weight: bold; font-size: 1rem; text-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.level-bottle .lb-icons .lb-spark { font-size: clamp(15px, 2.4vh, 20px); }
.level-bottle .lb-stars { display: block; font-size: clamp(0.8rem, 1.8vh, 1rem); letter-spacing: 1px; }
.level-bottle .lb-stars .off { filter: grayscale(1) opacity(0.3); }

.level-bottle .lb-cork {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 46px;
    z-index: 2;
    transition: transform 0.5s cubic-bezier(0.3, -0.4, 0.4, 1), opacity 0.5s;
}
.level-bottle .lb-cork svg { width: 100%; display: block; }
.level-bottle .lb-zzz {
    position: absolute;
    top: 16%;
    right: 8%;
    font-size: 0.85rem;
    font-weight: bold;
    color: #8A5CB8;
    animation: zzz-fade 2.4s ease-in-out infinite;
}
@keyframes zzz-fade { 0%, 100% { opacity: 0.35; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-4px); } }
.level-bottle.locked .lb-art { filter: grayscale(0.7) opacity(0.6); }
.level-bottle.uncork .lb-cork { transform: translate(30px, -70px) rotate(70deg); opacity: 0; }
.level-bottle.uncork { animation: uncork-bounce 0.7s cubic-bezier(0.2, 1.5, 0.4, 1); }
@keyframes uncork-bounce { 0% { transform: scale(1); } 40% { transform: scale(1.16); } 100% { transform: scale(1); } }

#title-bottom {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: clamp(2px, 1vh, 8px);
}

#potion-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.78);
    border-radius: 30px;
    padding: 6px 18px;
    box-shadow: 0 3px 10px rgba(90, 60, 130, 0.12);
    font-weight: bold;
    font-size: 1.05rem;
}
#potion-chip .sbottle-svg, #potion-chip .bottle-svg { width: 26px; height: 34px; }

#btn-howto {
    width: 58px;
    height: 58px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: var(--gk-purple);
    font-size: 1.7rem;
    font-weight: bold;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(90, 60, 130, 0.2);
    transition: transform 0.15s;
}
#btn-howto:hover { transform: scale(1.1); }
#btn-howto:active { transform: scale(0.92); }

/* ── Play screen ────────────────────────────────────────────────────────── */

#screen-play { z-index: 12; }

#scene {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: calc(var(--counter-h) - 26px);
    pointer-events: none;
}
#scene button { pointer-events: auto; }

/* progress bottle shelf */
#shelf-progress {
    position: absolute;
    top: clamp(60px, 9.5vh, 88px);
    left: 12px;
    z-index: 30;
    width: max-content;
}
#shelf-bottles { display: flex; gap: 6px; padding: 0 10px 2px; }
#shelf-bottles .sbottle { width: clamp(30px, 4.6vh, 42px); height: clamp(42px, 6.4vh, 58px); }
#shelf-bottles .sbottle svg { width: 100%; height: 100%; display: block; }
#shelf-plank {
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(180deg, #E9C494, var(--wood));
    box-shadow: 0 3px 6px rgba(90, 60, 130, 0.25);
}
.sb-liquid {
    transform-box: fill-box;
    transform-origin: 50% 100%;
    transform: scaleY(0);
    transition: transform 0.7s cubic-bezier(0.2, 1.2, 0.4, 1);
}
.sbottle.filled .sb-liquid { transform: scaleY(1); }
.sbottle.filled { animation: sb-pop 0.5s cubic-bezier(0.2, 1.5, 0.4, 1); }
@keyframes sb-pop { 0% { transform: scale(1); } 45% { transform: scale(1.3); } 100% { transform: scale(1); } }

/* customer */
#customer-zone {
    position: absolute;
    left: clamp(6px, 4vw, 70px);
    bottom: -6px;
    width: clamp(170px, 24vh, 240px);
}

#doormat {
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 116%;
}
#doormat svg { width: 100%; display: block; }

#customer-slot { position: relative; width: 100%; height: clamp(190px, 27vh, 270px); }

.customer { position: absolute; inset: 0; }
.customer .m-base, .customer .m-color { position: absolute; inset: 0; }
.customer .monster-svg { width: 100%; height: 100%; display: block; }
.customer .m-color {
    clip-path: circle(0% at 50% 58%);
    transition: clip-path 0.9s ease-in-out;
}
.customer.transformed .m-color { clip-path: circle(85% at 50% 58%); }
.customer .m-shadow {
    position: absolute;
    bottom: -4px;
    left: 12%;
    width: 76%;
    height: 16px;
    border-radius: 50%;
    background: rgba(90, 60, 130, 0.18);
}
.m-open { opacity: 0; }
.customer.drinking .m-open { opacity: 1; }
.customer.drinking .m-smile { opacity: 0; }
.m-eyes { transform-box: fill-box; transform-origin: center; animation: m-blink 4.2s infinite; }
@keyframes m-blink {
    0%, 91%, 97%, 100% { transform: scaleY(1); }
    94% { transform: scaleY(0.1); }
}

.customer.enter { animation: m-enter 0.75s cubic-bezier(0.3, 1, 0.5, 1); }
@keyframes m-enter {
    0% { transform: translateX(-130%) rotate(-4deg); }
    30% { transform: translateX(-85%) rotate(4deg) translateY(-12px); }
    60% { transform: translateX(-38%) rotate(-4deg) translateY(0); }
    82% { transform: translateX(-8%) rotate(3deg) translateY(-10px); }
    100% { transform: translateX(0) rotate(0); }
}
.customer.exit { animation: m-exit 0.85s cubic-bezier(0.5, 0, 0.8, 0.4) forwards; }
@keyframes m-exit {
    0% { transform: translateX(0); opacity: 1; }
    30% { transform: translateX(18vw) translateY(-14px) rotate(6deg); }
    60% { transform: translateX(38vw) translateY(0) rotate(-6deg); }
    100% { transform: translateX(64vw) translateY(-10px) rotate(6deg); opacity: 1; }
}
.customer.dance { animation: m-dance 1.2s ease-in-out; }
@keyframes m-dance {
    0% { transform: scale(1) rotate(0); }
    18% { transform: scale(1.08, 0.9) rotate(-7deg) translateY(-6px); }
    38% { transform: scale(0.94, 1.1) rotate(7deg) translateY(-22px); }
    56% { transform: scale(1.06, 0.92) rotate(-6deg) translateY(-4px); }
    76% { transform: scale(0.97, 1.05) rotate(5deg) translateY(-16px); }
    100% { transform: scale(1) rotate(0) translateY(0); }
}
.customer.giggle { animation: m-giggle 0.65s ease-in-out; }
@keyframes m-giggle {
    0%, 100% { transform: rotate(0); }
    20% { transform: rotate(-5deg) scale(1.03, 0.97); }
    45% { transform: rotate(5deg) scale(0.97, 1.03); }
    70% { transform: rotate(-4deg); }
}
.customer.drinking { animation: m-glug 0.8s ease-in-out; }
@keyframes m-glug {
    0%, 100% { transform: scaleY(1); }
    25% { transform: scaleY(0.95) rotate(-2deg); }
    50% { transform: scaleY(1.04) rotate(2deg); }
    75% { transform: scaleY(0.96); }
}

/* target speech bubble */
#target-bubble {
    position: absolute;
    bottom: calc(100% + clamp(2px, 1vh, 14px));
    left: 46%;
    width: clamp(150px, 22vh, 200px);
    background: #FFFFFF;
    border: 4px solid #E3D3EE;
    border-radius: 26px;
    padding: 10px 12px 8px;
    box-shadow: 0 8px 20px rgba(90, 60, 130, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    z-index: 25;
}
#target-bubble::after {
    content: '';
    position: absolute;
    bottom: -19px;
    left: 26px;
    width: 26px;
    height: 26px;
    background: #FFFFFF;
    border-right: 4px solid #E3D3EE;
    border-bottom: 4px solid #E3D3EE;
    transform: rotate(58deg) skew(24deg);
    border-radius: 0 0 8px 0;
}
#target-bubble.pop { animation: bubble-pop 0.55s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes bubble-pop {
    0% { transform: scale(0.2); opacity: 0; }
    70% { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(1); }
}
#bubble-bottle { width: clamp(64px, 10vh, 88px); height: clamp(78px, 12.5vh, 108px); }
#bubble-bottle svg { width: 100%; height: 100%; display: block; }
#bubble-hint {
    display: flex;
    align-items: center;
    gap: 3px;
    background: #F4EDFA;
    border-radius: 16px;
    padding: 3px 10px;
}
#bubble-hint .miniblob-svg { width: clamp(26px, 4vh, 34px); height: clamp(26px, 4vh, 34px); }
#bubble-hint .hint-plus { font-weight: bold; font-size: 1.2rem; color: var(--gk-purple); }

/* cauldron */
#cauldron-zone {
    position: absolute;
    left: 50%;
    bottom: -14px;
    transform: translateX(-50%);
    width: clamp(230px, 34vh, 310px);
}
#cauldron-wrap { width: 100%; position: relative; }
#cauldron-wrap svg.cauldron-svg { width: 100%; height: auto; display: block; }

.pot-spoon { transform-box: fill-box; transform-origin: 30% 92%; }
.cauldron-wrap-stir .pot-spoon,
#cauldron-wrap.stirring .pot-spoon { animation: spoon-stir 0.28s ease-in-out 3; }
@keyframes spoon-stir {
    0%, 100% { transform: rotate(0) translateX(0); }
    30% { transform: rotate(-16deg) translateX(-30px); }
    70% { transform: rotate(8deg) translateX(10px); }
}
.liquid-swirl { transform-box: fill-box; transform-origin: center; }
#cauldron-wrap.stirring .liquid-swirl { animation: swirl-spin 0.85s linear; }
@keyframes swirl-spin {
    from { transform: rotate(0turn) scaleX(1); }
    50% { transform: rotate(1turn) scaleX(0.5); }
    to { transform: rotate(2turn) scaleX(1); }
}
#cauldron-wrap.wobble { animation: pot-wobble 0.5s ease-in-out; }
@keyframes pot-wobble {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-2.5deg) scale(1.02, 0.98); }
    60% { transform: rotate(2.5deg) scale(0.98, 1.02); }
}

.pot-bubbles .pb { animation: pb-rise 2.6s ease-in infinite; }
.pot-bubbles .pb2 { animation-delay: 0.7s; }
.pot-bubbles .pb3 { animation-delay: 1.3s; }
.pot-bubbles .pb4 { animation-delay: 1.9s; }
.pot-bubbles .pb5 { animation-delay: 0.4s; }
@keyframes pb-rise {
    0% { transform: translateY(4px) scale(0.5); opacity: 0; }
    25% { opacity: 0.6; }
    100% { transform: translateY(-46px) scale(1.15); opacity: 0; }
}
#cauldron-wrap.brew .pot-bubbles .pb { animation-duration: 1.2s; }

.mud-eyes { opacity: 0; transition: opacity 0.3s; }
#cauldron-wrap.mud .mud-eyes { opacity: 1; }
.mud-pupil { transform-box: fill-box; transform-origin: center; animation: googly 1.1s ease-in-out infinite; }
@keyframes googly {
    0%, 100% { transform: translate(0, 0); }
    30% { transform: translate(3px, -2px); }
    65% { transform: translate(-3px, 2px); }
}

.pot-liquid { transition: fill 0.25s; }
#cauldron-wrap.draining .liquid-g { animation: liquid-drain 0.45s ease-in; }
@keyframes liquid-drain {
    0% { transform: scaleY(1); }
    50% { transform: scaleY(0.4) translateY(4px); }
    100% { transform: scaleY(1); }
}
.liquid-g { transform-box: fill-box; transform-origin: center; }

/* stir + drain buttons */
#btn-stir {
    position: absolute;
    right: clamp(-124px, -11vw, -104px);
    bottom: 46px;
    width: clamp(104px, 15vh, 120px);
    height: clamp(104px, 15vh, 120px);
    border: 6px solid #8A5A28;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #F2D8AE, #D9AE7C 70%, #C89B6C);
    cursor: pointer;
    box-shadow: 0 8px 0 #8A5A28, 0 12px 22px rgba(90, 60, 130, 0.3);
    transition: transform 0.15s, filter 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}
#btn-stir:active { transform: translateY(4px); box-shadow: 0 4px 0 #8A5A28, 0 8px 14px rgba(90, 60, 130, 0.3); }
#stir-icon { width: 74%; height: 74%; display: block; }
#stir-icon svg { width: 100%; height: 100%; display: block; }
#stir-zzz {
    position: absolute;
    top: -16px;
    right: -8px;
    font-weight: bold;
    color: #7B62A8;
    font-size: 1.3rem;
    text-shadow: 0 1px 0 #FFFFFF;
    opacity: 0;
    pointer-events: none;
}
#btn-stir.asleep { filter: grayscale(0.75) opacity(0.75); }
#btn-stir.asleep #stir-zzz { opacity: 1; animation: zzz-fade 2.4s ease-in-out infinite; }
/* pulse via box-shadow only — transform pulses would make taps miss (and
   trip Playwright's stability check) */
#btn-stir.armed { animation: stir-pulse 1.1s ease-in-out infinite; }
@keyframes stir-pulse {
    0%, 100% { box-shadow: 0 8px 0 #8A5A28, 0 12px 22px rgba(90, 60, 130, 0.3), 0 0 0 0 rgba(124, 181, 24, 0.55); }
    50% { box-shadow: 0 8px 0 #8A5A28, 0 12px 22px rgba(90, 60, 130, 0.3), 0 0 0 16px rgba(124, 181, 24, 0.05); }
}
#btn-stir.wob, #btn-drain.wob, .level-bottle.wob { animation: btn-wob 0.45s ease-in-out; }
@keyframes btn-wob {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-7deg); }
    65% { transform: rotate(7deg); }
}

#btn-drain {
    position: absolute;
    left: clamp(-78px, -7vw, -66px);
    bottom: 26px;
    width: 66px;
    height: 66px;
    border: 4px solid #0090B0;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #E8F8FD, #BDE9F5);
    cursor: pointer;
    box-shadow: 0 5px 0 #0090B0, 0 8px 14px rgba(0, 144, 176, 0.3);
    transition: transform 0.15s;
    padding: 8px;
}
#btn-drain:active { transform: translateY(3px); box-shadow: 0 2px 0 #0090B0; }
#btn-drain svg { width: 100%; height: 100%; display: block; }

/* Fizzwick */
#fizzwick-zone {
    position: absolute;
    right: clamp(4px, 3.4vw, 60px);
    bottom: -4px;
    width: clamp(150px, 24vh, 225px);
    pointer-events: none;
}
#fizzwick-rig { width: 100%; }
#fizzwick-rig svg.fizz-svg, #title-fizz svg.fizz-svg { width: 100%; height: auto; display: block; }

.fizz-arm-l, .fizz-arm-r, .fizz-spoon { transform-box: fill-box; }
.fizz-arm-l { transform-origin: 90% 40%; }
.fizz-arm-r { transform-origin: 10% 40%; }
#fizzwick-rig.point .fizz-arm-l { animation: fizz-point 2s ease-in-out; }
@keyframes fizz-point {
    0%, 100% { transform: rotate(0); }
    20%, 80% { transform: rotate(58deg); }
}
#fizzwick-rig.happy .fizz-root { animation: fizz-happy 1s ease-in-out; }
@keyframes fizz-happy {
    0%, 100% { transform: rotate(0) translateY(0); }
    20% { transform: rotate(-4deg) translateY(-10px); }
    50% { transform: rotate(4deg) translateY(-4px); }
    75% { transform: rotate(-3deg) translateY(-8px); }
}
#fizzwick-rig.stir-cheer .fizz-arm-r { animation: fizz-stir 0.9s ease-in-out; }
@keyframes fizz-stir {
    0%, 100% { transform: rotate(0); }
    30% { transform: rotate(-18deg); }
    65% { transform: rotate(10deg); }
}
.fizz-root { transform-box: fill-box; transform-origin: center bottom; }
.fizz-eyes { transform-box: fill-box; transform-origin: center; animation: m-blink 5s infinite; }

/* jar row */
#jar-row {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 6px;
    height: calc(var(--counter-h) - 16px);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(16px, 3.4vw, 38px);
    z-index: 20;
}

.jar {
    width: clamp(98px, 15vh, 124px);
    height: clamp(98px, 15vh, 124px);
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    position: relative;
    transition: transform 0.15s;
}
.jar svg.jar-svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 6px 8px rgba(90, 60, 130, 0.28)); }
.jar:hover { transform: translateY(-4px); }
.jar:active { transform: scale(0.93); }
.jar .jar-blob { transform-box: fill-box; transform-origin: center bottom; }
.jar:nth-child(1) .jar-blob { animation: blob-idle 3.2s ease-in-out infinite; }
.jar:nth-child(2) .jar-blob { animation: blob-idle 3.6s ease-in-out 0.5s infinite; }
.jar:nth-child(3) .jar-blob { animation: blob-idle 3.4s ease-in-out 1s infinite; }
.jar:nth-child(4) .jar-blob { animation: blob-idle 3.8s ease-in-out 1.5s infinite; }
@keyframes blob-idle {
    0%, 100% { transform: scale(1, 1); }
    50% { transform: scale(1.03, 0.96); }
}
.jar.squish .jar-wob { animation: jar-squish 0.3s ease-out; transform-box: fill-box; transform-origin: center bottom; }
@keyframes jar-squish {
    0% { transform: scale(1, 1); }
    40% { transform: scale(1.18, 0.78); }
    100% { transform: scale(1, 1); }
}
.jar.hint { animation: jar-hop 0.7s ease-in-out 4; }
.jar.hint svg.jar-svg { filter: drop-shadow(0 0 14px rgba(252, 191, 73, 0.95)) drop-shadow(0 6px 8px rgba(90, 60, 130, 0.28)); }
@keyframes jar-hop {
    0%, 100% { transform: translateY(0); }
    40% { transform: translateY(-16px) scale(1.04); }
    70% { transform: translateY(0) scale(0.98, 1.02); }
}
.jar.pop-in { animation: jar-pop-in 0.6s cubic-bezier(0.2, 1.5, 0.4, 1); }
@keyframes jar-pop-in {
    0% { transform: scale(0); }
    70% { transform: scale(1.15); }
    100% { transform: scale(1); }
}
.jar.ghost { visibility: hidden; }

/* ── FX layer ───────────────────────────────────────────────────────────── */

#fx-layer {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 500;
}

.fly-blob {
    position: absolute;
    width: 54px;
    height: 54px;
    margin: -27px 0 0 -27px;
}
.fly-blob svg { width: 100%; height: 100%; display: block; }

.splash-ring {
    position: absolute;
    width: 22px;
    height: 12px;
    margin: -6px 0 0 -11px;
    border: 4px solid rgba(255, 255, 255, 0.85);
    border-radius: 50%;
    animation: splash-out 0.5s ease-out forwards;
}
@keyframes splash-out {
    from { transform: scale(0.5); opacity: 1; }
    to { transform: scale(3.4); opacity: 0; }
}
.splash-drop {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50% 50% 50% 0;
    animation: drop-up 0.55s ease-out forwards;
}
@keyframes drop-up {
    0% { transform: translate(0, 0) scale(1) rotate(-45deg); opacity: 1; }
    100% { transform: translate(var(--dx, 20px), -46px) scale(0.4) rotate(-45deg); opacity: 0; }
}

.serve-bottle {
    position: absolute;
    width: 74px;
    height: 102px;
    margin: -51px 0 0 -37px;
}
.serve-bottle svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 4px 8px rgba(90, 60, 130, 0.3)); }
.serve-bottle.fizzing { animation: bottle-fizz 0.7s ease-in-out; }
@keyframes bottle-fizz {
    0%, 100% { transform: rotate(0); }
    20% { transform: rotate(-9deg) scale(1.05); }
    45% { transform: rotate(9deg) scale(0.97); }
    70% { transform: rotate(-7deg); }
}
.serve-bottle.fade { transition: opacity 0.4s; opacity: 0; }

.smoke-puff {
    position: absolute;
    width: 130px;
    height: 100px;
    margin: -80px 0 0 -65px;
    animation: puff-up 1.3s ease-out forwards;
}
.smoke-puff svg { width: 100%; height: 100%; display: block; }
@keyframes puff-up {
    0% { transform: scale(0.2) translateY(10px); opacity: 0; }
    25% { transform: scale(1) translateY(-6px); opacity: 1; }
    100% { transform: scale(1.5) translateY(-52px); opacity: 0; }
}

.spark-bit {
    position: absolute;
    font-size: 20px;
    animation: spark-fly 0.9s ease-out forwards;
    will-change: transform;
}
@keyframes spark-fly {
    0% { transform: translate(0, 0) scale(0.4) rotate(0); opacity: 1; }
    100% { transform: translate(var(--dx, 0), var(--dy, -60px)) scale(1.2) rotate(120deg); opacity: 0; }
}

.conga-monster {
    position: absolute;
    bottom: calc(var(--counter-h) - 40px);
    left: -140px;
    width: clamp(88px, 13vh, 120px);
    animation: conga-run 2s linear forwards;
}
.conga-monster svg { width: 100%; display: block; }
.conga-monster .cg-inner { animation: conga-bounce 0.4s ease-in-out infinite; }
@keyframes conga-run { from { transform: translateX(0); } to { transform: translateX(120vw); } }
@keyframes conga-bounce {
    0%, 100% { transform: translateY(0) rotate(-4deg); }
    50% { transform: translateY(-18px) rotate(4deg); }
}

.crate-holder {
    position: absolute;
    width: 140px;
    height: 122px;
    margin-left: -70px;
    animation: crate-drop 0.55s cubic-bezier(0.3, 0, 0.5, 1.3);
}
.crate-holder svg { width: 100%; height: 100%; display: block; }
@keyframes crate-drop {
    from { transform: translateY(-70vh); }
    to { transform: translateY(0); }
}
.crate-holder.open .crate-lid {
    transform-box: fill-box;
    animation: lid-fly 0.7s ease-in forwards;
}
@keyframes lid-fly {
    0% { transform: translate(0, 0) rotate(0); opacity: 1; }
    100% { transform: translate(90px, -160px) rotate(80deg); opacity: 0; }
}
.crate-holder.gone { transition: opacity 0.4s, transform 0.4s; opacity: 0; transform: translateY(30px); }

/* ── How-to overlay ─────────────────────────────────────────────────────── */

#howto-layer {
    position: fixed;
    inset: 0;
    z-index: 600;
    pointer-events: none;
}

#ghost-hand {
    position: absolute;
    width: 86px;
    height: 102px;
    margin: -20px 0 0 -30px;
    filter: drop-shadow(0 6px 10px rgba(90, 60, 130, 0.4));
    transition: left 0.7s cubic-bezier(0.4, 0, 0.3, 1), top 0.7s cubic-bezier(0.4, 0, 0.3, 1);
    opacity: 0;
    z-index: 2;
}
#ghost-hand svg { width: 100%; height: 100%; display: block; }
#ghost-hand.show { opacity: 0.95; }
#ghost-hand.press { animation: hand-press 0.4s ease-out; }
@keyframes hand-press {
    0%, 100% { transform: scale(1); }
    45% { transform: scale(0.82) translateY(8px); }
}

#btn-go {
    position: absolute;
    right: clamp(16px, 6vw, 90px);
    top: clamp(90px, 16vh, 170px);
    pointer-events: auto;
    font-size: clamp(1.6rem, 5vw, 2.2rem);
    padding: 20px 58px;
    animation: go-pulse 1.2s ease-in-out infinite;
    z-index: 3;
}
@keyframes go-pulse {
    0%, 100% { box-shadow: 0 6px 20px rgba(124, 181, 24, 0.4), 0 0 0 0 rgba(124, 181, 24, 0.5); }
    50% { box-shadow: 0 6px 20px rgba(124, 181, 24, 0.4), 0 0 0 20px rgba(124, 181, 24, 0.05); }
}

/* ── Grown-ups modal ────────────────────────────────────────────────────── */

#info-overlay { position: fixed; inset: 0; z-index: 920; }
#info-scrim {
    position: absolute;
    inset: 0;
    background: rgba(74, 59, 92, 0.45);
    animation: gk-fade-in 0.25s ease-out;
}
#info-card {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(92vw, 520px);
    max-height: 86vh;
    overflow-y: auto;
    animation: gk-pop-in 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
    padding: 24px 28px;
}
#info-card h3 { color: var(--gk-purple); margin-bottom: 8px; font-size: 1.3rem; }
#info-card p { margin: 8px 0; font-size: 0.98rem; line-height: 1.45; }
#info-card .info-small { font-size: 0.85rem; opacity: 0.75; }
#info-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 64px;
    height: 64px;
    border: none;
    border-radius: 50%;
    background: #F4EDFA;
    color: var(--gk-purple);
    font-size: 1.6rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.15s;
}
#info-close:hover { transform: scale(1.08); }
.info-recipes {
    display: block;
    background: #F8F3FC;
    border-radius: 14px;
    padding: 10px 14px !important;
    text-align: center;
    font-weight: bold;
    color: var(--gk-purple);
    line-height: 2 !important;
}
.rd {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    vertical-align: middle;
    margin: 0 3px;
    box-shadow: inset 0 -3px 4px rgba(0, 0, 0, 0.12);
}
.r-red { background: #E63946; } .r-yellow { background: #FCBF49; }
.r-blue { background: #00B4D8; } .r-orange { background: #F77F00; }
.r-green { background: #7CB518; } .r-purple { background: #B565D8; }
.r-pink { background: #FF7BAC; } .r-sky { background: #9BDCF5; }
.r-white { background: #FFFDF6; border: 2px solid #E0D2B4; width: 16px; height: 16px; }
.rlabel { font-size: 0.85rem; opacity: 0.8; margin-right: 6px; }

/* ── portrait: Fizzwick tucks up top-right ──────────────────────────────── */

@media (orientation: portrait) {
    #fizzwick-zone {
        bottom: auto;
        top: clamp(150px, 20vh, 240px);
        right: 8px;
        width: clamp(110px, 17vh, 150px);
    }
    #wall-chart { right: auto; left: clamp(6px, 2vw, 24px); top: clamp(240px, 30vh, 330px); width: 96px; }
    #wall-shelf { transform: translateX(-42%); }
    #customer-zone { left: clamp(4px, 3vw, 40px); }
    #cauldron-zone { left: 50%; }
    /* On a narrow phone the pot + its two flanking buttons can't all fit side
       by side, so the stir/drain buttons used to hang past the right edge and
       get clipped (kids couldn't fully tap them). Tuck them onto the pot's
       right rim — stacked, drain above stir — so they stay fully on-screen. */
    #btn-stir  { right: clamp(-16px, -2vw, -4px); }
    #btn-drain { left: auto; right: clamp(-16px, -2vw, -4px); bottom: 172px; }
    /* the decor shelf would touch the 6-bottle progress shelf at 768px */
    #wall-shelf { display: none; }
    #btn-go { top: auto; bottom: calc(var(--counter-h) + 24vh); }
}

@media (max-width: 850px) and (orientation: landscape) {
    #cauldron-zone { width: clamp(210px, 30vh, 260px); }
}

/* ── reduced motion ─────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    #game-title span, .float-bub, .glow-bottle, .pot-bubbles .pb,
    .jar .jar-blob, #btn-stir.armed, #btn-go, .m-eyes, .fizz-eyes,
    #stir-zzz, .lb-zzz, .mud-pupil { animation: none !important; }
    .customer .m-color { transition: none; }
    #ghost-hand { transition: none; }
}
