/* Scene art and its animations. Rule: the base look is the FINAL state; animations only travel to it, so with the
   Reduced motion option (html.rm) every ending still shows. */
.scene { width: 100%; height: 100%; display: block; }
.scene .off { display: none; }
.scene .star { fill: #fff; opacity: .8; animation: tw 3s ease-in-out infinite alternate; animation-delay: var(--d, 0s); }
@keyframes tw { from { opacity: .25; } to { opacity: 1; } }
.scene .flick { transform-box: fill-box; transform-origin: 50% 100%; animation: flick .9s ease-in-out infinite alternate; animation-delay: var(--d, 0s); }
@keyframes flick { 0% { transform: scale(1, 1) skewX(0); } 50% { transform: scale(.94, 1.1) skewX(3deg); } 100% { transform: scale(1.05, .93) skewX(-3deg); } }
.rm .scene, .rm .scene * { animation: none !important; transition: none !important; }

/* ---- Burn the Witch ---- */
.scene-witch .hat-fall, .scene-witch .smoke, .scene-witch .cackle, .scene-witch .flyer, .scene-witch .burst { opacity: 0; pointer-events: none; }
.scene-witch .hatw { animation: hatsway 3.2s ease-in-out infinite alternate; }
@keyframes hatsway { from { transform: rotate(-2deg); } to { transform: rotate(2deg); } }
.scene-witch .pup { animation: look 5s ease-in-out infinite; }
@keyframes look { 0%, 40% { transform: translateX(0); } 50%, 90% { transform: translateX(1.6px); } }
.scene-witch .sweat { animation: sweatdrop 1.4s ease-in infinite; }
@keyframes sweatdrop { from { transform: translateY(0); opacity: 1; } to { transform: translateY(12px); opacity: 0; } }
.scene-witch[data-step="5"] .witch { animation: shiver .18s linear infinite alternate; }
@keyframes shiver { from { transform: translateX(-.8px); } to { transform: translateX(.8px); } }
/* lose: a puff of smoke, she is gone, only the hat floats down; she cackles from off-screen */
.scene-witch.lose .witch-body { opacity: 0; animation: vanish .5s; }
@keyframes vanish { 0%, 55% { opacity: 1; } 100% { opacity: 0; } }
.scene-witch.lose .smoke { opacity: .35; animation: puff 3.2s ease-out; transform-box: fill-box; transform-origin: 50% 70%; }
@keyframes puff { 0% { transform: scale(.2); opacity: 1; } 22% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.18) translateY(-12px); opacity: .35; } }
.scene-witch.lose .hat-fall { opacity: 1; }
.scene-witch.lose .hatf { animation: hatfall 2.6s .5s cubic-bezier(.3, .6, .4, 1) backwards; }
@keyframes hatfall { 0% { opacity: 0; transform: translate(0, -170px) rotate(30deg); } 12% { opacity: 1; } 30% { transform: translate(-26px, -110px) rotate(-18deg); } 55% { transform: translate(22px, -60px) rotate(14deg); } 80% { transform: translate(-8px, -16px) rotate(-6deg); } 100% { transform: translate(0, 0) rotate(0); } }
.scene-witch.lose .cackle { opacity: 1; animation: cackle 3.4s 1.6s backwards; transform-box: fill-box; transform-origin: 100% 50%; }
@keyframes cackle { 0% { opacity: 0; transform: translateX(60px); } 12% { opacity: 1; transform: translateX(0) rotate(-3deg); } 24% { transform: rotate(3deg); } 36% { transform: rotate(-3deg); } 48% { transform: rotate(2deg); } 100% { opacity: 1; transform: none; } }
/* win: ropes fall away, the flames go out, she flies off on her broom */
.scene-witch.win .witch-body { opacity: 0; animation: vanish .5s .3s backwards; }
.scene-witch.win .ropes { opacity: 0; }
.scene-witch.win .flick { opacity: 0; animation: flameout .9s; }
@keyframes flameout { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(.2, .1); } }
.scene-witch.win .flyer { opacity: 1; transform: translate(104px, -84px); animation: fly 2.8s .4s cubic-bezier(.3, .1, .3, 1) backwards; }
@keyframes fly { 0% { opacity: 0; transform: translate(0, 0); } 8% { opacity: 1; } 35% { transform: translate(-50px, -70px) rotate(-14deg); } 60% { transform: translate(40px, -150px) rotate(8deg); } 100% { transform: translate(104px, -84px); } }
.scene-witch.win .burst { opacity: .9; animation: burst 1.6s ease-out; transform-box: fill-box; transform-origin: center; }
@keyframes burst { from { opacity: 1; transform: scale(.2); } to { opacity: .9; transform: scale(1); } }

/* ---- The Cauldron ---- */
.scene-cauldron .potion, .scene-cauldron .boom, .scene-cauldron .goop, .scene-cauldron .blorp { opacity: 0; pointer-events: none; }
.scene-cauldron .liquid { fill: #4fd47a; transition: fill .6s; }
.scene-cauldron[data-step="1"] .liquid { fill: #5cc88a; } .scene-cauldron[data-step="2"] .liquid { fill: #6ab4b0; }
.scene-cauldron[data-step="3"] .liquid { fill: #8a8ad8; } .scene-cauldron[data-step="4"] .liquid { fill: #a066e6; }
.scene-cauldron[data-step="5"] .liquid, .scene-cauldron[data-step="6"] .liquid { fill: #b94ae8; }
.scene-cauldron .bub { animation: bubble 1.6s ease-in infinite; animation-delay: var(--d); transform-box: fill-box; transform-origin: center; }
@keyframes bubble { 0% { transform: translateY(2px) scale(.5); opacity: 0; } 30% { opacity: .9; } 100% { transform: translateY(-16px) scale(1.15); opacity: 0; } }
.scene-cauldron .foam circle { fill: #f3e7ff; stroke: #cdb0f0; stroke-width: 1.5; }
.scene-cauldron .foam.big circle { fill: #e6c8ff; }
.scene-cauldron .drip { fill: #b94ae8; }
.scene-cauldron[data-step="4"] .pot { animation: rumble .28s linear infinite alternate; }
.scene-cauldron[data-step="5"] .pot { animation: rumble .16s linear infinite alternate; }
@keyframes rumble { from { transform: translate(-1px, 0); } to { transform: translate(1px, -1.5px); } }
.scene-cauldron .item.on { animation: plop .55s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes plop { from { transform: translateY(-120px); opacity: 0; } to { transform: none; opacity: 1; } }
.scene-cauldron .foam.on circle { animation: foamy 1s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
@keyframes foamy { from { transform: scale(.92); } to { transform: scale(1.1); } }
/* win: a perfect, glowing potion */
.scene-cauldron.win .liquid { fill: #ffcf4a; }
.scene-cauldron.win .foam, .scene-cauldron.win .bub { opacity: 0; }
.scene-cauldron.win .item { opacity: .35; }
.scene-cauldron.win .potion { opacity: 1; animation: rise 1.4s cubic-bezier(.2, .8, .3, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(70px) scale(.6); } to { opacity: 1; transform: none; } }
.scene-cauldron.win .rays { transform-box: fill-box; transform-origin: center; animation: spin 14s linear infinite; }
.scene-cauldron.win .halo { animation: pulse 2s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { from { opacity: .7; transform: scale(.94); } to { opacity: 1; transform: scale(1.08); } }
/* lose: it boils over in a goopy purple explosion */
.scene-cauldron.lose .fire, .scene-cauldron.lose .bub { opacity: 0; }
.scene-cauldron.lose .pot { animation: none; transform: rotate(-6deg); transform-box: fill-box; transform-origin: 50% 100%; }
.scene-cauldron.lose .flash { opacity: 0; animation: flash 1s ease-out; transform-box: fill-box; transform-origin: center; }
@keyframes flash { 0% { opacity: 1; transform: scale(.1); } 40% { opacity: 1; } 100% { opacity: 0; transform: scale(1.1); } }
.scene-cauldron.lose .boom { opacity: 1; }
.scene-cauldron.lose .chunks circle { opacity: 0; animation: chunk 1.3s ease-out; }
@keyframes chunk { 0% { opacity: 1; transform: translate(0, 0); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)); } }
.scene-cauldron.lose .goop { opacity: 1; animation: splat .7s .25s cubic-bezier(.2, 1.3, .4, 1) backwards; }
@keyframes splat { from { opacity: 0; transform: translateY(-30px) scale(.9); } to { opacity: 1; transform: none; } }
.scene-cauldron.lose .drips rect { transform-box: fill-box; transform-origin: top; animation: dripgrow 3.5s ease-out; }
@keyframes dripgrow { from { transform: scaleY(.1); } to { transform: scaleY(1); } }
.scene-cauldron.lose .blorp { opacity: 1; animation: pop .5s 1s cubic-bezier(.3, 1.6, .5, 1) backwards; transform-box: fill-box; transform-origin: center; }
@keyframes pop { from { opacity: 0; transform: scale(.3); } to { opacity: 1; transform: scale(1); } }

/* ---- The Last Candle ---- */
.scene-candle .dark { opacity: calc(var(--step, 0) * .1); transition: opacity .6s; }
.scene-candle .dead, .scene-candle .sparkles { opacity: 0; pointer-events: none; }
.scene-candle .wisp { opacity: 0; }
.scene-candle .on .wisp { animation: wisp 2.8s ease-out; }
@keyframes wisp { 0% { opacity: .9; transform: translateY(6px) scaleY(.4); } 100% { opacity: 0; transform: translateY(-10px) scaleY(1.1); } }
.scene-candle .ember { animation: ember 1.4s ease-in-out infinite alternate; }
@keyframes ember { from { opacity: .2; } to { opacity: 1; } }
.scene-candle .glow { animation: glowpulse 2.4s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
@keyframes glowpulse { from { transform: scale(.93); } to { transform: scale(1.05); } }
.scene-candle.lose .dead { opacity: 1; animation: fadein 1.4s; }
.scene-candle.lose .blackout { opacity: .94; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.scene-candle.lose .eyes { animation: eyesin 3.2s; }
@keyframes eyesin { 0%, 55% { opacity: 0; } 100% { opacity: 1; } }
.scene-candle .blink { transform-box: fill-box; transform-origin: center; animation: blinkeyes 4.5s infinite; }
@keyframes blinkeyes { 0%, 92%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.08); } }
.scene-candle.win .dark { opacity: 0; }
.scene-candle.win .cdl .flick { animation: flick .9s ease-in-out infinite alternate, relight .8s backwards; animation-delay: var(--d, 0s), calc(var(--i) * .2s); }
@keyframes relight { from { transform: scale(0); opacity: 0; } 60% { transform: scale(1.5, 1.7); opacity: 1; } to { transform: scale(1); } }
.scene-candle.win .sparkles { opacity: 1; animation: twink 1.6s ease-in-out infinite alternate; }
@keyframes twink { from { opacity: .35; } to { opacity: 1; } }
.scene-candle.win .bookglow { opacity: 1; }
