/* Shravan's Trick or Treat Heist
   Tokens from the My Shravan design system: ink #1c2b44, muted #4b5565, sapphire #1e3bb8, blue #2e52e6, line #d9def2. */
:root {
  --ink: #1c2b44; --muted: #4b5565; --sapphire: #1e3bb8; --blue: #2e52e6; --line: #d9def2; --soft: #eef0f8; --peri: #eeedff;
  --card: #fff; --r-btn: 15.75px; --r-card: 21px; --r-hero: 24.5px;
  --sh-card: 0 1px 2px rgba(23,37,84,.05), 0 8px 24px rgba(23,37,84,.08);
  --sh-soft: 0 4px 14px rgba(23,37,84,.10);
  --sh-primary: 0 8px 20px rgba(30,59,184,.26);
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
  --font: "Nunito Sans", "Noto Sans", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #7C88DD; color: var(--ink); font-family: var(--font);
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; touch-action: manipulation; overscroll-behavior: none; }
body { position: fixed; inset: 0; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; -webkit-user-select: text; user-select: text; }

/* ---------- world ---------- */
.world { position: fixed; inset: 0; overflow: hidden; touch-action: none; background: #7C88DD; }
.world[hidden] { display: none !important; }
#stage { position: absolute; left: 50%; top: 50%; width: 540px; height: 960px; transform: translate(-50%, -50%) scale(var(--s, .7)); transform-origin: 50% 50%; }
.scene { position: absolute; left: 0; top: 0; overflow: visible; }
.spr { position: absolute; left: 0; top: 0; transform-origin: 50% 100%; will-change: transform; pointer-events: none; }
.scene .star { animation: twinkle 3s ease-in-out infinite; }
.scene .star.s1 { animation-delay: -1s; } .scene .star.s2 { animation-delay: -2s; }
@keyframes twinkle { 50% { opacity: .35; } }
.scene .bat { animation: batfly 9s ease-in-out infinite; transform-box: fill-box; }
.scene .bat.b2 { animation-duration: 12s; animation-delay: -4s; }
@keyframes batfly { 0%,100% { translate: 0 0; } 25% { translate: 40px -14px; } 50% { translate: 80px 6px; } 75% { translate: 30px 16px; } }
#planks { opacity: 0; transition: opacity .5s; }
#planks.on { opacity: 1; }

/* ---------- bowl ---------- */
#bowl { width: 120px; height: 92px; z-index: 440; }
#bowl svg { width: 100%; height: 100%; overflow: visible; display: block; }
#bowl .bowl-golden { display: none; }
#bowl.has-golden .bowl-golden { display: inline; animation: goldbob 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes goldbob { 50% { transform: translateY(-3px) scale(1.06); } }
#bowl .rummage { position: absolute; left: 22%; top: -16px; width: 56%; height: 9px; border-radius: 9px; background: #fff; box-shadow: var(--sh-soft); opacity: 0; transition: opacity .2s; overflow: hidden; }
#bowl .rummage i { display: block; height: 100%; width: calc(var(--rum, 0) * 100%); background: linear-gradient(90deg, #FFD54A, #F5B21B); border-radius: 9px; }
#bowl.rummaging .rummage { opacity: 1; }
#bowl.rummaging .bowl-pile { animation: rummage .18s linear infinite; transform-box: fill-box; transform-origin: center bottom; }
@keyframes rummage { 50% { transform: rotate(2deg) translateY(-1px); } }

/* ---------- Shravan (stand-in vector) ---------- */
#shravan { width: 100px; height: 160px; }
.s-hop, .s-flip, .s-art { position: absolute; inset: 0; }
.s-flip { transition: transform .12s; }
.s-dz { position: absolute; inset: 0; }
.s-dz svg { width: 100%; height: 100%; overflow: visible; display: block; animation: dzpop .22s cubic-bezier(.34,1.56,.64,1); transform-origin: 50% 90%; }
@keyframes dzpop { from { transform: scale(.4); opacity: 0; } }
.sv { width: 100px; height: 160px; display: block; overflow: visible; }
.sv g { transform-box: view-box; }
.sv-all { transform-origin: 50px 156px; }
.sv-armL { transform-origin: 32.5px 66px; transition: transform .12s; }
.sv-armR { transform-origin: 67.5px 66px; transition: transform .12s; }
.sv-legL { transform-origin: 43px 104px; }
.sv-legR { transform-origin: 57px 104px; }
.sv-head { transform-origin: 50px 60px; transition: transform .15s; }
.sv-pupils { transition: transform .15s; }
.sv-eyes { transform-origin: 50px 39px; transition: transform .15s; }
.sv .m, .sv-eyes-happy, .sv-finger, .sv-held { display: none; }
.sv-bulge { transform-origin: 50px 104px; transform: scale(var(--bulge, .4)); opacity: 0; transition: opacity .2s, transform .2s; }
#shravan.bulgy .sv-bulge { opacity: 1; }

.p-idle .m-smile, .p-walk .m-sly, .p-freeze .m-flat, .p-shush .m-flat, .p-grab .m-grin, .p-caught .m-o, .p-sheepish .m-smile, .p-cheer .m-grin, .p-offer .m-smile, .p-sly .m-sly { display: inline; }
.p-idle .sv-all { animation: breathe 2.4s ease-in-out infinite; }
.p-idle .sv-armL { transform: rotate(6deg); } .p-idle .sv-armR { transform: rotate(-6deg); }
@keyframes breathe { 50% { transform: scaleY(1.015) translateY(-.5px); } }

.p-walk .sv-all { animation: tiptoe .4s ease-in-out infinite; }
.p-walk .sv-legL { animation: legA .4s ease-in-out infinite; }
.p-walk .sv-legR { animation: legB .4s ease-in-out infinite; }
.p-walk .sv-armL { transform: rotate(48deg); animation: armA .4s ease-in-out infinite; }
.p-walk .sv-armR { transform: rotate(-48deg); animation: armB .4s ease-in-out infinite; }
.p-walk .sv-pupils { transform: translate(2.2px, -1px); }
.p-walk .sv-head { transform: rotate(-4deg); }
@keyframes tiptoe { 0%,100% { transform: translateY(-3px); } 50% { transform: translateY(-6px) rotate(1.5deg); } }
@keyframes legA { 0%,100% { transform: rotate(-16deg); } 50% { transform: rotate(14deg); } }
@keyframes legB { 0%,100% { transform: rotate(14deg); } 50% { transform: rotate(-16deg); } }
@keyframes armA { 0%,100% { transform: rotate(40deg); } 50% { transform: rotate(56deg); } }
@keyframes armB { 0%,100% { transform: rotate(-56deg); } 50% { transform: rotate(-40deg); } }

.p-freeze .sv-armL { transform: rotate(82deg); } .p-freeze .sv-armR { transform: rotate(-82deg); }
.p-freeze .sv-pupils { animation: dart 1.4s steps(1) infinite; }
.p-freeze .sv-all { animation: shiver .3s linear infinite; }
@keyframes dart { 0% { transform: translate(-2.5px, 0); } 33% { transform: translate(2.5px, 0); } 66% { transform: translate(0, -1px); } }
@keyframes shiver { 25% { transform: translateX(-.5px); } 75% { transform: translateX(.5px); } }
#shravan[data-dz="sheet"] .sv-armL, #shravan[data-dz="sheet"] .sv-armR { transform: rotate(0deg); }
#shravan[data-dz="scarecrow"] .sv-armL { transform: rotate(90deg); } #shravan[data-dz="scarecrow"] .sv-armR { transform: rotate(-90deg); }
#shravan[data-dz="sheet"] .sv-head, #shravan[data-dz="sheet"] .sv-all > path, #shravan[data-dz="sheet"] .sv-bulge { opacity: 0; }
#shravan[data-dz="pumpkin"] .sv-head { opacity: 0; }

.p-shush .sv-armR { transform: rotate(138deg) scale(.72); }
.p-shush .sv-finger { display: inline; }
.p-shush .sv-head { transform: rotate(-5deg); }
.p-shush .sv-brows { transform: translateY(-1.5px); }

.p-grab .sv-armR { transform: rotate(-82deg); }
.p-grab .sv-armL { transform: rotate(22deg); }
.p-grab .sv-all { animation: grabby .42s ease-in-out infinite; }
@keyframes grabby { 50% { transform: rotate(4deg) translateX(1px); } }

.p-caught .sv-armL { transform: rotate(150deg); } .p-caught .sv-armR { transform: rotate(-150deg); }
.p-caught .sv-eyes { transform: scale(1.3); }
.p-caught .sv-all { animation: jolt .5s ease-out; }
@keyframes jolt { 30% { transform: translateY(-14px); } }

.p-sheepish .sv-armR { transform: rotate(-162deg) scale(.72); }
.p-sheepish .sv-eyes { display: none; } .p-sheepish .sv-eyes-happy { display: inline; }
.p-sheepish .sv-head { transform: rotate(6deg); }

.p-cheer .sv-armL { transform: rotate(158deg); } .p-cheer .sv-armR { transform: rotate(-158deg); }
.p-cheer .sv-eyes { display: none; } .p-cheer .sv-eyes-happy { display: inline; }
.p-cheer .sv-all { animation: bounce .45s ease-in-out infinite; }
@keyframes bounce { 50% { transform: translateY(-7px); } }

.p-offer .sv-armR { transform: rotate(-74deg); }
.p-offer .sv-held { display: inline; }
.p-offer .sv-eyes { display: none; } .p-offer .sv-eyes-happy { display: inline; }
.p-offer .sv-head { transform: rotate(4deg); }

.p-sly .sv-pupils { transform: translate(2.6px, 0); }
.p-sly .sv-brows path:last-child { transform: translateY(-2.5px); }
.p-sly .sv-armL { transform: rotate(10deg); } .p-sly .sv-armR { transform: rotate(-12deg); }

/* 3D render sprites (when assets/shravan/manifest.json exists) */
.s-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: 50% 100%; -webkit-user-drag: none; }
.has-sprites .s-art.p-walk { animation: tiptoeImg .4s ease-in-out infinite; }
.has-sprites .s-art.p-freeze { animation: shiver .3s linear infinite; }
.has-sprites .s-art.p-cheer { animation: bounce .45s ease-in-out infinite; }
.has-sprites .s-art.p-idle { animation: breathe 2.4s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes tiptoeImg { 0%,100% { transform: translateY(-2px) rotate(-2deg); } 50% { transform: translateY(-7px) rotate(2deg); } }
#shravan.has-sprites.in-dz[data-dz="sheet"] .s-art { clip-path: inset(93% -40% -10% -40%); }
.has-sprites .s-img { inset: auto; object-fit: fill; }
.s-dz svg { transform-box: view-box; }

#sshadow { width: 84px; height: 14px; background: radial-gradient(closest-side, rgba(52,60,130,.28), rgba(52,60,130,0)); }

.pocket { display: flex; align-items: center; gap: 4px; padding: 4px 10px 4px 8px; background: #fff; border-radius: 999px; box-shadow: var(--sh-soft); font-weight: 900; font-size: 17px; color: var(--ink); transition: opacity .15s; white-space: nowrap; }
.pocket svg { width: 24px; height: 14px; } .pocket svg:last-child:not(:first-child) { width: 20px; height: 20px; }

/* ---------- ghost ---------- */
#ghost { width: 140px; height: 150px; }
.gh { width: 140px; height: 150px; display: block; overflow: visible; }
.gh g { transform-box: view-box; }
.g-bob, .g-turn { position: absolute; inset: 0; }
.g-bob { animation: float 2.6s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-7px); } }
.g-turn { transform-origin: 50% 50%; }
.gh-front, .gh-peek, .gh-backmark, .gh-bodyback, .ge, .gm, .gacc { display: none; }
#ghost.front .gh-front { display: inline; }
#ghost:not(.front) .gh-bodyback, #ghost:not(.front) .gh-backmark { display: inline; }
.gh-armL { transform-origin: 24px 80px; transition: transform .2s; }
.gh-armR { transform-origin: 116px 80px; transition: transform .2s; }
#ghost.acc-nightcap .gacc-nightcap, #ghost.acc-bowler .gacc-bowler, #ghost.acc-monocle .gacc-monocle, #ghost.acc-tiara .gacc-tiara,
#ghost.acc-boa .gacc-boa, #ghost.acc-bowtie .gacc-bowtie, #ghost.acc-party .gacc-party { display: inline; }
#ghost.acc-sweat.ph-watch .gacc-sweat, #ghost.acc-sweat.ph-tell .gacc-sweat, #ghost.acc-sweat.ph-startled .gacc-sweat { display: inline; }
/* faces by phase */
#ghost .ge-open, #ghost .gm-smile { display: inline; }
#ghost.ph-watch .ge-open, #ghost.ph-watch .gm-smile, #ghost.ph-boo .ge-open, #ghost.ph-boo .gm-smile, #ghost.ph-happy .ge-open, #ghost.ph-happy .gm-smile,
#ghost.ph-startled .ge-open, #ghost.ph-startled .gm-smile, #ghost.ph-turnIn .gm-smile { display: none; }
#ghost.ph-watch .ge-squint, #ghost.ph-watch .gm-flat { display: inline; }
#ghost.ph-watch .ge-squint .ge-pupils { animation: scan 2.2s ease-in-out infinite; }
@keyframes scan { 0%,100% { transform: translateX(-3px); } 50% { transform: translateX(3px); } }
#ghost.ph-turnIn .gm-o { display: inline; }
#ghost.ph-boo .ge-wide, #ghost.ph-boo .gm-boo { display: inline; }
#ghost.ph-boo .g-bob { animation: boo .5s ease-out; }
@keyframes boo { 30% { transform: scale(1.12) translateY(-6px); } }
#ghost.ph-happy .ge-closed, #ghost.ph-happy .gm-happy { display: inline; }
#ghost.ph-happy .gh-blush { transform: scale(1.3); transform-origin: center; transform-box: fill-box; }
#ghost.ph-happy .g-bob { animation: float 1.2s ease-in-out infinite; }
#ghost.ph-startled .ge-wide, #ghost.ph-startled .gm-wobble { display: inline; }
#ghost.ph-startled .g-bob { animation: shake .12s linear infinite; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
/* tells */
#ghost.ph-tell .gh-peek { display: inline; animation: peek .3s ease-out; transform-origin: 110px 62px; }
@keyframes peek { from { transform: translateX(-10px); opacity: 0; } }
#ghost.ph-tell .g-bob { animation: wiggle .22s ease-in-out infinite; }
@keyframes wiggle { 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
#ghost.t-snoozy.ph-tell .gh-armL { transform: rotate(140deg); } #ghost.t-snoozy.ph-tell .gh-armR { transform: rotate(-140deg); }
#ghost.t-snoozy.ph-tell .g-bob { animation: stretch .9s ease-in-out infinite; }
@keyframes stretch { 50% { transform: scaleY(1.08) translateY(-4px); } }
#ghost.t-diva.ph-tell .gh-armR { transform: rotate(-120deg); } #ghost.t-diva.ph-tell .gh-armL { transform: rotate(40deg); }
#ghost.t-diva.ph-tell .g-bob { animation: twirl .9s ease-in-out infinite; }
@keyframes twirl { 50% { transform: rotate(-6deg) translateY(-5px); } }
#ghost.quick.ph-tell .g-bob { animation: wiggle .12s linear infinite; }
#ghost.t-jumpy.ph-tell .g-bob { animation: shake .1s linear infinite; }
#ghost.ph-watch .gh-armL { transform: rotate(30deg); } #ghost.ph-watch .gh-armR { transform: rotate(-30deg); }
#ghost.t-diva.ph-watch .gh-armR { transform: rotate(-150deg); } #ghost.t-diva.ph-watch .gh-armL { transform: rotate(20deg); }
#ghost.ph-away .gh-armL { animation: hum 1.6s ease-in-out infinite; }
@keyframes hum { 50% { transform: rotate(-14deg); } }
#ghost.doze .g-bob { animation: float 4s ease-in-out infinite; }
#ghost.doze .g-turn svg { transform: rotate(-8deg); transform-origin: 50% 90%; }

.bubble { position: absolute; left: 0; top: 0; padding: 7px 13px; background: #fff; border-radius: 16px; box-shadow: var(--sh-soft); font-weight: 800; font-size: 17px; color: var(--ink);
  white-space: nowrap; opacity: 0; transition: opacity .15s; pointer-events: none; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -7px; margin-left: -7px; border: 7px solid transparent; border-top-color: #fff; border-bottom: 0; }
.bubble.show { opacity: 1; animation: bubpop .25s cubic-bezier(.34,1.56,.64,1); }
.bubble.big { font-size: 26px; font-weight: 900; padding: 8px 16px; }
.bubble.small { font-size: 16px; }
.bubble.zz { color: #6E62B8; }
@keyframes bubpop { from { scale: .5; } }

/* ---------- queue ---------- */
.q { width: 80px; height: 112px; transition: transform .45s cubic-bezier(.3,.7,.4,1), opacity .4s; }
.q svg { width: 80px; height: 112px; overflow: visible; display: block; }
.q-in { position: absolute; inset: 0; animation: qbob 2.4s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes qbob { 50% { transform: translateY(-2px) rotate(1deg); } }
.q-enter { opacity: 0; }
.q .q-bucket-fill, .q .q-m-yay { display: none; }
.q-served .q-bucket-fill, .q-served-gold .q-bucket-fill, .q-served .q-m-yay, .q-served-gold .q-m-yay { display: inline; }
.q-served .q-m-smile, .q-served-gold .q-m-smile { display: none; }
.q-served .q-in, .q-served-gold .q-in { animation: qhop .45s ease-out 2; }
@keyframes qhop { 40% { transform: translateY(-16px) scaleY(1.05); } }
.q-leave .q-in { animation: none; transform: translateY(26px) scale(.9); opacity: 0; transition: transform .6s, opacity .6s; }
.q-cheer .q-in { animation: qhop .5s ease-out var(--d, 0s) 3; }
.q-wings { animation: flap .28s ease-in-out infinite alternate; transform-origin: 40px 78px; transform-box: view-box; }
@keyframes flap { to { transform: scaleY(.7); } }
.q-say { position: absolute; left: 50%; top: -14px; transform: translate(-50%, -100%); background: #fff; color: var(--ink); font-weight: 900; font-size: 15px; padding: 4px 10px; border-radius: 12px;
  box-shadow: var(--sh-soft); white-space: nowrap; opacity: 0; }
.q-served .q-say, .q-served-gold .q-say { opacity: 1; animation: bubpop .25s cubic-bezier(.34,1.56,.64,1); }
.q-served-gold .q-say { background: #FFF3C4; }

/* ---------- fx ---------- */
#fx { position: absolute; inset: 0; pointer-events: none; z-index: 3000; }
#rollp { width: 50px; height: 50px; opacity: 0; transition: opacity .2s; }
#rollp svg { width: 100%; height: 100%; overflow: visible; }
#rollp .rp-spin { transform-box: view-box; transform-origin: 25px 26px; transform: rotate(var(--spin, 0deg)); }
#rollp.warn svg { animation: wobble .18s ease-in-out infinite; }
@keyframes wobble { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
.ftext { position: absolute; transform: translate(-50%, -50%); font-weight: 900; font-size: 26px; color: #fff; text-shadow: 0 2px 0 rgba(84,66,168,.45), 0 0 12px rgba(84,66,168,.35);
  animation: rise 1.3s ease-out forwards; white-space: nowrap; }
.ftext.gold { color: #FFE27A; }
.ftext.small { font-size: 20px; }
.ftext.creak { font-style: italic; font-size: 18px; color: #FFE3C4; }
.ftext.statue { font-size: 19px; color: var(--sapphire); background: #fff; padding: 3px 11px; border-radius: 12px; text-shadow: none; box-shadow: var(--sh-soft); animation: rise 1s ease-out forwards; }
@keyframes rise { 0% { opacity: 0; translate: 0 8px; scale: .7; } 15% { opacity: 1; scale: 1.08; } 100% { opacity: 0; translate: 0 -46px; scale: 1; } }
.fcandy { position: absolute; left: 0; top: 0; width: 30px; height: 16px; }
.fcandy.gold { width: 30px; height: 30px; }
.fcandy svg, .fconf svg, .fheart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.fheart { position: absolute; width: 26px; height: 24px; opacity: 0; animation: heart 2.2s ease-out forwards; }
@keyframes heart { 0% { opacity: 0; transform: translateY(0) scale(.4); } 20% { opacity: 1; transform: translateY(-20px) scale(1.1); } 100% { opacity: 0; transform: translateY(-140px) scale(.9); } }
.fconf { position: absolute; width: 30px; height: 16px; animation: fall 2s cubic-bezier(.3,.6,.6,1) forwards; }
@keyframes fall { to { transform: translate(var(--dx), 1000px) rotate(var(--r)); } }

/* ---------- HUD ---------- */
.hud { position: fixed; left: 0; right: 0; top: 0; padding: calc(var(--st) + 10px) 12px 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 8px; z-index: 40;
  pointer-events: none; opacity: 0; transform: translateY(-10px); transition: opacity .3s, transform .3s; }
body.playing.g-heist #hud, body.playing.g-tower #hud-tower, body.playing.g-peek #hud-peek { opacity: 1; transform: none; }
body.playing.g-heist #hud > *, body.playing.g-tower #hud-tower > *, body.playing.g-peek #hud-peek > * { pointer-events: auto; }
.hud .left { justify-self: start; display: flex; align-items: center; gap: 6px; }
.home-btn svg { fill: var(--ink); }
.pill { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.94); border-radius: 999px; box-shadow: var(--sh-soft); padding: 7px 14px; font-weight: 800; font-size: 15px; color: var(--ink); }
.pill.score { justify-self: start; font-size: 20px; font-weight: 900; padding: 6px 14px 6px 10px; }
.pill.score svg { width: 28px; height: 16px; }
.mid { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pill.round { font-size: 14px; white-space: nowrap; }
.pill.round span { color: var(--sapphire); font-size: 11px; letter-spacing: .6px; text-transform: uppercase; font-weight: 800; margin-right: 2px; }
.need { font-size: 13px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(46,40,110,.45); }
.right { justify-self: end; display: flex; align-items: center; gap: 8px; }
.lives { display: flex; gap: 2px; background: rgba(255,255,255,.94); border-radius: 999px; padding: 5px 8px; box-shadow: var(--sh-soft); }
.lives i { width: 22px; height: 22px; display: block; transition: opacity .3s, filter .3s, transform .3s; }
.lives i svg { width: 100%; height: 100%; }
.lives i.lost { opacity: .35; filter: grayscale(1); transform: scale(.8); }
.icon-btn { width: 40px; height: 40px; border-radius: 999px; border: 0; background: rgba(255,255,255,.94); box-shadow: var(--sh-soft); display: grid; place-items: center; padding: 0; }
.icon-btn svg { width: 22px; height: 22px; fill: var(--ink); }
.snd .off-i { display: none; } .snd.off .on-i { display: none; } .snd.off .off-i { display: inline; }

#hint { position: fixed; left: 50%; top: calc(var(--st) + 92px); transform: translate(-50%, -8px); background: #fff; color: var(--ink); border-radius: 16px; box-shadow: var(--sh-card);
  padding: 10px 16px; font-size: 16px; font-weight: 600; text-align: center; width: max-content; max-width: min(92vw, 380px); z-index: 45; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; }
#hint.show { opacity: 1; transform: translate(-50%, 0); }
#hint b { color: var(--sapphire); font-weight: 800; }
#toast { position: fixed; left: 50%; top: calc(var(--st) + 150px); transform: translate(-50%, -8px) scale(.96); background: #FFF6E4; color: var(--ink); border-radius: 16px; box-shadow: var(--sh-card);
  padding: 10px 16px; font-size: 16px; font-weight: 600; text-align: center; width: max-content; max-width: min(92vw, 380px); z-index: 46; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
#toast b { font-weight: 900; } #toast small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }

#roundcard { position: fixed; left: 50%; top: 56%; transform: translate(-50%, -50%) scale(.9); background: #fff; border-radius: var(--r-hero); box-shadow: var(--sh-card); padding: 18px 26px 16px;
  text-align: center; width: min(86vw, 340px); z-index: 44; opacity: 0; transition: opacity .25s, transform .3s cubic-bezier(.34,1.56,.64,1); pointer-events: none; }
#roundcard.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.rc-r { font-size: 12px; font-weight: 800; letter-spacing: .7px; text-transform: uppercase; color: var(--sapphire); }
.rc-g { font-size: 30px; font-weight: 900; margin: 2px 0 2px; }
.rc-l { font-size: 15px; color: var(--muted); }
.rc-t { font-size: 14px; color: var(--ink); margin-top: 10px; padding-top: 10px; border-top: 1.5px solid var(--soft); font-weight: 600; }

#hh { position: fixed; left: 0; right: 0; top: calc(var(--st) + 3vh); text-align: center; font-weight: 900; font-size: clamp(38px, 11vw, 68px); line-height: 1.05; color: #fff; z-index: 55;
  text-shadow: 0 3px 0 rgba(84,66,168,.35), 0 0 30px rgba(255,214,170,.6); opacity: 0; transform: scale(.6); pointer-events: none; transition: opacity .4s, transform .6s cubic-bezier(.34,1.56,.64,1); }
body.show-hh #hh { opacity: 1; transform: scale(1); }
#rotate { display: none; }
body.landscape-phone #rotate { display: block; position: fixed; left: 50%; bottom: 8px; transform: translateX(-50%); background: #fff; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; z-index: 200; box-shadow: var(--sh-soft); }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: none; flex-direction: column; align-items: center; z-index: 50; pointer-events: none; padding: calc(var(--st) + 12px) 12px calc(var(--sb) + 12px); }
.screen.show { display: flex; }
.screen-card { pointer-events: auto; width: min(440px, 100%); background: #fff; border-radius: var(--r-hero); box-shadow: 0 10px 40px rgba(23,37,84,.18); padding: 18px 20px 14px; text-align: center; animation: cardup .45s cubic-bezier(.34,1.3,.64,1); }
@keyframes cardup { from { transform: translateY(40px); opacity: 0; } }
#title { justify-content: space-between; }
.logo { text-align: center; color: #fff; margin-top: 1vh; animation: logo .7s cubic-bezier(.34,1.56,.64,1); }
@keyframes logo { from { transform: scale(.6); opacity: 0; } }
.logo-small { font-weight: 800; font-size: clamp(16px, 4.4vw, 22px); letter-spacing: 1.2px; text-transform: uppercase; color: #FFF6E4; text-shadow: 0 2px 0 rgba(84,66,168,.3); }
.logo h1 { margin: 0; font-weight: 900; font-size: clamp(36px, 10.5vw, 60px); line-height: 1.02; text-shadow: 0 3px 0 rgba(84,66,168,.35), 0 0 30px rgba(255,214,170,.5); }
.lead { font-size: 15.5px; line-height: 1.45; color: var(--muted); margin: 2px 0 10px; }
.how { font-size: 16px; font-weight: 600; margin: 0 0 12px; color: var(--ink); }
.how b { color: var(--sapphire); font-weight: 800; }
.chal { background: #FFF6E4; border-radius: 14px; padding: 9px 12px; font-size: 15px; margin: 0 0 10px; }
.btn { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 52px; border-radius: var(--r-btn); border: 0; font-size: 17px; font-weight: 800; padding: 10px 16px; transition: transform .12s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, var(--blue), var(--sapphire)); color: #fff; box-shadow: var(--sh-primary); }
.btn.secondary { background: #fff; color: var(--sapphire); border: 1.5px solid var(--line); }
.row { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.row .icon-btn { box-shadow: none; background: var(--peri); }
.row .icon-btn svg { fill: var(--sapphire); }
.switch[hidden] { display: none !important; }
.switch { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; color: var(--ink); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 46px; height: 28px; border-radius: 999px; background: #cdd3e3; position: relative; transition: background .2s; flex: none; }
.switch .track i { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + .track { background: var(--sapphire); }
.switch input:checked + .track i { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--blue); outline-offset: 2px; }
.sig { margin: 12px 0 0; font-size: 12.5px; color: var(--muted); font-weight: 600; }

#end { justify-content: flex-end; }
#end .screen-card { max-height: calc(100% - 22vh); overflow: auto; -webkit-overflow-scrolling: touch; }
.caption { font-size: 15.5px; line-height: 1.4; color: var(--ink); font-weight: 600; margin: 0 0 6px; }
.sig .dot { margin: 0 4px; }
.bigscore { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.bigscore b { font-size: 46px; font-weight: 900; line-height: 1; color: var(--sapphire); }
.bigscore span { font-size: 17px; font-weight: 800; color: var(--ink); }
.best { margin: 2px 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.newbest { background: #FFF3C4; color: #8A5E00; font-weight: 800; padding: 3px 10px; border-radius: 999px; }
.stats { margin: 0 0 8px; font-size: 14.5px; color: var(--muted); font-weight: 600; background: var(--peri); border-radius: 12px; padding: 7px 10px; }
.stats b { color: var(--ink); font-weight: 900; }
.fav { font-size: 14px; color: var(--muted); margin: 0 0 10px; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btns .btn { font-size: 16px; padding: 10px 8px; }
.rate { margin-top: 12px; padding-top: 10px; border-top: 1.5px solid var(--soft); }
.rate-q { margin: 0 0 6px; font-size: 15px; font-weight: 700; }
.stars { display: flex; justify-content: center; gap: 6px; }
.stars button { width: 42px; height: 42px; border: 0; background: none; padding: 4px; filter: grayscale(1) opacity(.45); transition: filter .15s, transform .15s; }
.stars button.on { filter: none; transform: scale(1.08); }
.stars button svg { width: 100%; height: 100%; }
.rate-thanks { display: none; margin: 6px 0 0; font-size: 14px; font-weight: 600; }
.rate.rated .rate-thanks { display: block; }
.links { margin: 10px 0 0; font-size: 15px; }
a { color: var(--sapphire); font-weight: 700; }

/* ---------- sheets ---------- */
.sheet { position: fixed; inset: 0; z-index: 100; display: none; align-items: flex-end; justify-content: center; background: rgba(28,43,68,.38); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.sheet.show { display: flex; }
.sheet-card { position: relative; width: min(480px, 100%); max-height: 94%; overflow: auto; background: #fff; border-radius: var(--r-card) var(--r-card) 0 0; padding: 20px 20px calc(var(--sb) + 18px);
  animation: sheetup .3s cubic-bezier(.2,.8,.2,1); -webkit-user-select: text; user-select: text; }
@keyframes sheetup { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 560px) { .sheet { align-items: center; } .sheet-card { border-radius: var(--r-card); } }
.sheet h2 { margin: 0 34px 4px 0; font-size: 22px; font-weight: 900; }
.sheet .sub { margin: 0 0 12px; font-size: 15px; line-height: 1.45; color: var(--muted); }
.x { position: absolute; right: 12px; top: 12px; width: 40px; height: 40px; border-radius: 999px; border: 0; background: var(--soft); font-size: 24px; line-height: 1; color: var(--ink); }
.preview { width: 100%; aspect-ratio: 1; max-width: 300px; margin: 0 auto 12px; border-radius: 16px; overflow: hidden; background: var(--peri); }
.preview img { width: 100%; height: 100%; display: block; }
.preview.loading { background: linear-gradient(90deg, var(--peri), #fff, var(--peri)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.field { display: block; margin-bottom: 10px; text-align: left; }
.field span { display: block; font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.field input, .field textarea { width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 12px; font-size: 16px; color: var(--ink); background: #fff; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--blue); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; margin: 4px 0 12px; text-align: left; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--sapphire); flex: none; }
.err { color: #b9443a; font-size: 14px; font-weight: 700; margin: 0 0 8px; }
.fine { font-size: 12.5px; color: var(--muted); margin: 10px 0 0; line-height: 1.4; }
.done p { font-size: 16px; margin: 6px 0 14px; }
#s-native { margin-bottom: 10px; }
.share-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.share-grid button { border: 0; background: var(--peri); border-radius: 14px; padding: 10px 2px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--ink); }
.share-grid svg { width: 26px; height: 26px; }
#f-stars { margin-bottom: 10px; }

@media (prefers-reduced-motion: reduce) {
  .q-in, .g-bob, .scene .star, .scene .bat { animation: none !important; }
}

@media (max-width: 380px) {
  .hud { padding-left: 8px; padding-right: 8px; gap: 6px; }
  .pill.round span { display: none; }
  .pill.round { font-size: 13px; padding: 6px 11px; }
  .pill.score { font-size: 18px; padding: 5px 11px 5px 8px; }
  .lives { padding: 4px 6px; } .lives i { width: 18px; height: 18px; }
  .icon-btn { width: 36px; height: 36px; }
  .lead { font-size: 14.5px; }
}
@media (max-height: 700px) { .lead { display: none; } }

/* ---------- how to play (coachmarks, design-system style: frosted brand blue, white bubble) ---------- */
.linkbtn { background: none; border: 0; color: var(--sapphire); font-weight: 800; font-size: 15px; padding: 10px 6px 2px; text-decoration: underline; text-underline-offset: 3px; }
#tour { position: fixed; inset: 0; z-index: 120; display: none; }
#tour.show { display: block; }
.tour-mask { position: absolute; inset: 0; background: rgba(34, 82, 214, .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.tour-ring { position: absolute; left: 0; top: 0; border-radius: 50%; border: 3px solid rgba(255,255,255,.95); box-shadow: 0 0 0 6px rgba(255,255,255,.25), 0 0 30px rgba(255,255,255,.6);
  transition: transform .35s cubic-bezier(.2,.8,.2,1), width .35s, height .35s, opacity .2s; animation: ringpulse 1.6s ease-in-out infinite; pointer-events: none; }
@keyframes ringpulse { 50% { box-shadow: 0 0 0 12px rgba(255,255,255,.12), 0 0 40px rgba(255,255,255,.7); } }
.tour-bubble { position: absolute; left: 0; top: 0; background: #fff; border-radius: var(--r-card); box-shadow: 0 14px 40px rgba(23,37,84,.25); padding: 16px 16px 12px;
  transition: transform .35s cubic-bezier(.2,.8,.2,1); }
.tour-text { margin: 0 0 12px; font-size: 17px; line-height: 1.4; font-weight: 600; color: var(--ink); text-wrap: pretty; }
.tour-text b { color: var(--sapphire); font-weight: 800; }
.tour-foot { display: flex; align-items: center; gap: 10px; }
.tour-dots { display: flex; gap: 5px; flex: 1; }
.tour-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); transition: background .2s, width .2s; }
.tour-dots i.on { background: var(--sapphire); width: 18px; border-radius: 4px; }
.tour-skip { background: none; border: 0; color: var(--muted); font-weight: 700; font-size: 15px; padding: 8px; }
.tour-next { width: auto; min-height: 44px; padding: 8px 18px; font-size: 16px; }
.tour-arrow { position: absolute; width: 18px; height: 18px; background: #fff; transform: translateX(-50%) rotate(45deg); border-radius: 3px; }
.tour-arrow.up { top: -8px; } .tour-arrow.down { bottom: -8px; } .tour-arrow.none { display: none; }
.tour-finger { position: absolute; left: 50%; top: 40%; width: 64px; height: 80px; transform: translate(-50%, -50%); display: none; }
#tour.finger .tour-finger { display: block; }
.tour-finger svg { width: 100%; height: 100%; position: relative; animation: press 2.4s ease-in-out infinite; }
.tour-finger .ripple { position: absolute; left: 14px; top: -6px; width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; opacity: 0; animation: ripple 2.4s ease-out infinite; }
@keyframes press { 0%, 100% { transform: translateY(0) scale(1); } 15%, 60% { transform: translateY(6px) scale(.94); } 75% { transform: translateY(-4px) scale(1); } }
@keyframes ripple { 0%, 10% { opacity: 0; transform: scale(.4); } 20% { opacity: 1; } 60% { opacity: .9; transform: scale(1.6); } 70%, 100% { opacity: 0; transform: scale(2); } }

/* ---------- the win moment ---------- */
#win { position: fixed; inset: 0; z-index: 130; display: none; overflow: hidden; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 42%, rgba(255,246,228,.95), rgba(238,237,255,.92) 45%, rgba(124,136,221,.92) 100%); }
#win.show { display: flex; animation: winin .35s ease-out; }
@keyframes winin { from { opacity: 0; } }
.win-rays { position: absolute; left: 50%; top: 42%; width: 220vmax; height: 220vmax; transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from 0deg, rgba(255,255,255,.55) 0 9deg, rgba(255,214,170,.18) 9deg 18deg); animation: spin 24s linear infinite; pointer-events: none;
  -webkit-mask-image: radial-gradient(circle, #000 0 30%, transparent 62%); mask-image: radial-gradient(circle, #000 0 30%, transparent 62%); }
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
.win-body { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0 16px; text-align: center; max-width: 460px; }
#win.show .win-body { animation: winshake .5s ease-out 1.25s; }
@keyframes winshake { 10%, 50% { transform: translate(-6px, 3px) rotate(-1deg); } 30%, 70% { transform: translate(6px, -3px) rotate(1deg); } }
.win-line { margin: 0; font-weight: 900; font-size: clamp(30px, 8.6vw, 46px); line-height: 1.05; color: var(--ink); text-wrap: balance; }
.win-line .w { display: inline-block; white-space: nowrap; }
.win-line .w span { display: inline-block; opacity: 0; }
#win.show .win-line .w span { animation: letterin .5s cubic-bezier(.34,1.8,.64,1) forwards, wave 1.6s ease-in-out infinite; animation-delay: calc(var(--k) * 35ms), calc(1.2s + var(--k) * 60ms); }
.win-line .w:nth-child(even) span { color: var(--sapphire); }
@keyframes letterin { from { opacity: 0; transform: translateY(30px) rotate(-20deg) scale(.4); } to { opacity: 1; transform: none; } }
@keyframes wave { 50% { transform: translateY(-5px) rotate(3deg); } }
.win-stamp { margin-top: 4px; font-weight: 900; font-size: clamp(38px, 12vw, 64px); letter-spacing: 3px; color: #fff; background: linear-gradient(180deg, var(--blue), var(--sapphire));
  padding: 2px 22px 4px; border-radius: 18px; box-shadow: 0 10px 0 rgba(30,59,184,.25), 0 16px 34px rgba(30,59,184,.35); transform: rotate(-7deg); opacity: 0; }
#win.show .win-stamp { animation: stamp .45s cubic-bezier(.2,1.6,.4,1) 1.15s forwards, stampwob 2.2s ease-in-out 1.8s infinite; }
@keyframes stamp { from { opacity: 0; transform: rotate(-30deg) scale(3.2); } to { opacity: 1; transform: rotate(-7deg) scale(1); } }
@keyframes stampwob { 0%, 100% { transform: rotate(-7deg) scale(1); } 50% { transform: rotate(-3deg) scale(1.05); } }
.win-hero { position: relative; width: 120px; height: 176px; margin: 4px 0 -2px; }
.win-shravan { position: absolute; inset: 0; }
.win-shravan .sv, .win-shravan img { width: 120px; height: 192px; }
#win.show .win-hero { animation: dance .5s ease-in-out infinite alternate; transform-origin: 50% 100%; }
@keyframes dance { from { transform: rotate(-6deg) translateY(0); } to { transform: rotate(6deg) translateY(-8px); } }
.win-shades { position: absolute; left: 50%; top: 38px; width: 62px; transform: translate(-50%, -260px) rotate(-20deg); opacity: 0; }
#win.show .win-shades { animation: shades .7s cubic-bezier(.3,1.5,.5,1) 2s forwards; }
@keyframes shades { 0% { opacity: 1; transform: translate(-50%, -260px) rotate(-20deg); } 100% { opacity: 1; transform: translate(-50%, 0) rotate(0); } }
.win-iykyk { font-weight: 900; font-size: 26px; color: var(--ink); background: #fff; padding: 6px 18px; border-radius: 999px; box-shadow: var(--sh-card); opacity: 0; }
.win-iykyk span { display: inline-block; }
#win.show .win-iykyk { animation: pop .5s cubic-bezier(.34,1.8,.64,1) 2.6s forwards, wiggle2 .9s ease-in-out 3.1s infinite; }
#win.show .win-iykyk span { animation: spin2 1.2s ease-in-out 3.1s infinite; }
@keyframes pop { from { opacity: 0; transform: scale(.3) rotate(12deg); } to { opacity: 1; transform: scale(1) rotate(-3deg); } }
@keyframes wiggle2 { 50% { transform: scale(1.06) rotate(3deg); } }
@keyframes spin2 { 50% { transform: rotate(25deg) scale(1.25); } }
.win-sub { margin: 6px 0 4px; font-size: 16px; font-weight: 700; color: var(--ink); opacity: 0; }
#win.show .win-sub { animation: fadeup .4s ease-out 3s forwards; }
.win-go { width: auto; padding: 10px 26px; opacity: 0; }
#win.show .win-go { animation: fadeup .4s ease-out 3.3s forwards; }
@keyframes fadeup { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.win-ghost { position: absolute; right: -10px; bottom: 6%; width: 120px; height: 128px; animation: dizzy 1.4s ease-in-out infinite; }
.win-ghost svg { width: 100%; height: 100%; overflow: visible; }
.win-ghost .gh-front, .win-ghost .ge-wide, .win-ghost .gm-wobble, .win-ghost.acc-nightcap .gacc-nightcap, .win-ghost.acc-bowler .gacc-bowler, .win-ghost.acc-monocle .gacc-monocle,
.win-ghost.acc-tiara .gacc-tiara, .win-ghost.acc-boa .gacc-boa, .win-ghost.acc-bowtie .gacc-bowtie, .win-ghost.acc-party .gacc-party { display: inline; }
@keyframes dizzy { 0%, 100% { transform: rotate(-10deg) translateX(0); } 50% { transform: rotate(10deg) translateX(-8px); } }
.win-rain { position: absolute; inset: 0; pointer-events: none; }
.win-rain i { position: absolute; top: -40px; width: 30px; height: 18px; animation: wfall linear forwards; }
.win-rain i svg { width: 100%; height: 100%; display: block; overflow: visible; }
.win-rain i b { font-size: 26px; font-style: normal; }
@keyframes wfall { to { transform: translateY(115vh) rotate(var(--r)); } }
@media (prefers-reduced-motion: reduce) { .win-rays, #win.show .win-hero, .win-ghost { animation: none !important; } }

/* ---------- shell: tabs and more games ---------- */
#title .top { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.tabs { pointer-events: auto; display: flex; gap: 4px; padding: 4px; background: rgba(255,255,255,.28); border-radius: 999px; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; border: 0; background: transparent; color: #fff; font-weight: 800; font-size: 14.5px; padding: 9px 14px; border-radius: 999px; white-space: nowrap; transition: background .2s, color .2s; }
.tabs button.on { background: #fff; color: var(--sapphire); box-shadow: var(--sh-soft); }
.tabs button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.t-best { font-size: 13.5px; font-weight: 700; color: var(--muted); margin-left: auto; margin-right: 10px; }
.row .switch[hidden] + .t-best { margin-left: 0; }
.more { margin-top: 12px; padding-top: 10px; border-top: 1.5px solid var(--soft); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.more > span { font-size: 13.5px; font-weight: 700; color: var(--muted); }
#e-more-games { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chip { border: 1.5px solid var(--line); background: #fff; color: var(--sapphire); font-weight: 800; font-size: 14.5px; padding: 8px 14px; border-radius: 999px; }
/* cast in the heist queue */
.q-cast img { width: 100%; height: 100%; display: block; -webkit-user-drag: none; }
.q-cast .q-say { top: 6px; }
/* 3D Shravan in the win moment */
#win.three-d .win-hero { width: 205px; height: 260px; }
#win .win-shravan img.win-img { position: absolute; left: 0; top: 0; width: 205px; height: 260px; }
#win.three-d .win-shades { left: 108px; top: 57px; width: 40px; --rot: 12deg; }
#win.three-d.show .win-shades { animation-name: shades3d; }
@keyframes shades3d { 0% { opacity: 1; transform: translate(-50%, -280px) rotate(-20deg); } 100% { opacity: 1; transform: translate(-50%, 0) rotate(12deg); } }
@media (max-height: 700px) { #win.three-d .win-hero { transform: scale(.8); margin: -24px 0 -30px; } }

/* ---------- shared for the new games ---------- */
.stage2 { position: absolute; left: 50%; top: 50%; width: 540px; height: 960px; transform: translate(-50%, -50%) scale(var(--s, .7)); transform-origin: 50% 50%; }
.shr { width: 100px; height: 160px; }
.shr-art { position: absolute; inset: 0; }
.shr-art.p-cheer { animation: bounce .45s ease-in-out infinite; }
.shr-art.p-stand { animation: breathe 2.6s ease-in-out infinite; transform-origin: 50% 100%; }
.shr-art.p-startled { animation: shiver .25s linear infinite; }
.shr.wob .shr-art { animation: wobble2 .5s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes wobble2 { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg) translateY(-2px); } }
.mem { transition: transform .3s; }
.mem-in { position: absolute; inset: 0; animation: qbob 2.4s ease-in-out infinite; transform-origin: 50% 100%; }
.mem-in img { width: 100%; height: 100%; display: block; -webkit-user-drag: none; }
.mem.hop .mem-in { animation: qhop .45s ease-out 2; }
.mem .q-say { top: 4px; }
.mem.saying .q-say { opacity: 1; animation: bubpop .25s cubic-bezier(.34,1.56,.64,1); }

/* ---------- Pumpkin Tower ---------- */
.tw-sky, .cam { position: absolute; left: 0; top: 0; width: 540px; height: 960px; will-change: transform; }
.tw-tower, .tw-fx { position: absolute; inset: 0; }
.tw-fx { z-index: 30; pointer-events: none; }
.tw-tower { z-index: 20; }
#tw-shravan { z-index: 10; }
.pk-el { position: absolute; left: 0; top: 0; transform-origin: 50% 100%; }
.pk-el svg { width: 100%; height: 100%; display: block; overflow: visible; filter: drop-shadow(0 3px 2px rgba(52,60,130,.22)); }
.pk-el.landed { animation: squish .28s ease-out; }
@keyframes squish { 30% { scale: 1.12 .82; } 70% { scale: .96 1.05; } }
.pk-el.golden svg { filter: drop-shadow(0 0 10px rgba(255,213,74,.8)); }
.tw-swing { position: absolute; inset: 0; z-index: 25; pointer-events: none; }
.tw-swing .pk-el { animation: swingbob 1s ease-in-out infinite; }
@keyframes swingbob { 50% { rotate: 4deg; } }
.pk-el.miss { animation: pkmiss 1.1s ease-in forwards; }
@keyframes pkmiss { 30% { translate: calc(var(--mx) * .3) -30px; rotate: 60deg; } 100% { translate: var(--mx) 700px; rotate: 300deg; opacity: .3; } }
.pk-el.topple { animation: topple 1.2s cubic-bezier(.4,0,.8,.4) forwards; }
@keyframes topple { 100% { translate: var(--tx) var(--ty); rotate: var(--tr); } }
.tw-ghost { width: 140px; height: 150px; z-index: 24; transition: transform .6s cubic-bezier(.34,1.3,.64,1); }
.tw-ghost .gh { width: 140px; height: 150px; overflow: visible; }
.tw-ghost .gh-front, .tw-ghost .ge-open, .tw-ghost .gacc-party { display: inline; }
.tw-ghost .gm-o { display: inline; }
.tw-ghost.on .g-bob { animation: blow .5s ease-in-out infinite; }
@keyframes blow { 50% { transform: scale(1.08, .94) translateX(-6px); } }
#tw-gbub { z-index: 40; }
.tw-audience { position: absolute; inset: 0; z-index: 35; pointer-events: none; }

/* ---------- Peekaboo ---------- */
.pw { position: absolute; padding: 0; border: 7px solid #A79DE0; border-radius: 22px; overflow: hidden; background: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.25), 0 6px 16px rgba(40,30,110,.25); transition: transform .12s, border-color .2s; touch-action: manipulation; }
.pw:active { transform: scale(.97); }
.pw-glass { position: absolute; inset: 0; background: radial-gradient(circle at 50% 60%, #9D92DA, #7568C0); transition: background .2s; }
.pw.pop .pw-glass { background: radial-gradient(circle at 50% 60%, #FFF4CF, #FFD08A 60%, #F6A867); }
.pw.decoy .pw-glass { background: radial-gradient(circle at 50% 60%, #F4F1FF, #C9C1F2); }
.pw.wrong .pw-glass { background: radial-gradient(circle at 50% 60%, #FBD3D6, #E99AA4); }
.pw-who { position: absolute; inset: 0; transform: translateY(185%); transition: transform .16s cubic-bezier(.3,1.4,.5,1); }
.pw-who img { position: absolute; -webkit-user-drag: none; pointer-events: none; }
.pw.pop:not(.decoy) .pw-who, .pw.stay .pw-who { transform: translateY(0); }
.pw-ghost { position: absolute; left: 50%; bottom: -10px; width: 140px; height: 150px; transform: translate(-50%, 185%); transition: transform .16s cubic-bezier(.3,1.4,.5,1); }
.pw-ghost .gh { width: 140px; height: 150px; overflow: visible; }
.pw-ghost .gh-front, .pw-ghost .ge-open, .pw-ghost .gm-happy, .pw-ghost .gacc-party { display: inline; }
.pw.decoy .pw-ghost { transform: translate(-50%, 0); }
.pw-cur { position: absolute; top: 0; bottom: 18px; width: 30%; background: linear-gradient(90deg, #FFC9A8, #F7A882); transition: width .18s; }
.pw-cur.l { left: 0; border-radius: 0 0 40px 0; } .pw-cur.r { right: 0; border-radius: 0 0 0 40px; }
.pw.pop .pw-cur, .pw.stay .pw-cur { width: 9%; }
.pw-sill { position: absolute; left: -4px; right: -4px; bottom: 0; height: 16px; background: #C7B3E8; }
.pw-say { position: absolute; left: 50%; top: 8px; transform: translateX(-50%) scale(.6); background: #fff; color: var(--ink); font-weight: 900; font-size: 15px; padding: 3px 10px; border-radius: 12px; opacity: 0; transition: opacity .12s, transform .15s; white-space: nowrap; pointer-events: none; }
.pw.pop .pw-say { opacity: 1; transform: translateX(-50%) scale(1); }
.pw.stay .pw-say { opacity: 0; }
#world-peek.your-turn .pw { border-color: #FFFFFF; animation: ready 1.4s ease-in-out infinite; }
@keyframes ready { 50% { box-shadow: inset 0 0 0 3px rgba(255,255,255,.25), 0 0 0 6px rgba(255,255,255,.35), 0 6px 16px rgba(40,30,110,.25); } }
.pk-fx { position: absolute; inset: 0; pointer-events: none; z-index: 30; }
#pk-shravan { z-index: 20; }
@media (max-width: 380px) {
  .tabs button { font-size: 13px; padding: 8px 10px; }
  .need { font-size: 12px; }
}

/* ---------- laptops and tablets held sideways: the game sits in a framed portrait window ---------- */
body.framed { background: linear-gradient(160deg, #7C88DD 0%, #A99BE3 40%, #E7B9CF 75%, #FBD3B2 100%); }
body.framed .world { background: transparent; }
body.framed::before { content: ""; position: fixed; inset: 0; pointer-events: none;
  background-image: radial-gradient(circle, rgba(255,255,255,.75) 1.2px, transparent 1.6px), radial-gradient(circle, rgba(255,255,255,.45) 1px, transparent 1.4px);
  background-size: 160px 160px, 230px 230px; background-position: 20px 30px, 90px 110px; }
body.framed #stage, body.framed .stage2 { overflow: hidden; border-radius: 34px; box-shadow: 0 30px 80px rgba(40,30,110,.35), 0 0 0 1px rgba(255,255,255,.35); }
body.framed .hud, body.framed .screen, body.framed #hh { left: var(--fx); right: auto; width: var(--fw); }
body.framed .screen { top: var(--fy); bottom: auto; height: var(--fh); padding-left: 14px; padding-right: 14px; }
body.framed .hud { top: var(--fy); }
body.framed #hint { top: calc(var(--fy) + 82px); max-width: calc(var(--fw) - 32px); }
body.framed #toast { top: calc(var(--fy) + 140px); max-width: calc(var(--fw) - 32px); }
body.framed #hh { top: calc(var(--fy) + 3vh); font-size: calc(var(--fw) * .115); }
body.framed .logo h1 { font-size: min(60px, calc(var(--fw) * .105)); }
body.framed .logo-small { font-size: min(22px, calc(var(--fw) * .042)); }
body.framed .tabs button { font-size: min(14.5px, calc(var(--fw) * .029)); padding: 8px 12px; }
body.framed #end .screen-card { max-height: calc(var(--fh) - 18vh); }
body.compact .lead { display: none; }
body.compact #title .screen-card { padding-top: 14px; }

/* sprites keep their own size (some hosts add img { max-width: 100% }, which squashed them) */
.s-img, .win-img, .pw-who img, .q-cast img, .mem-in img { max-width: none !important; }
.sig a.site { font-weight: 800; }

#ghost.peek-left .gh-peekwrap { transform: scaleX(-1); transform-origin: 70px 75px; }
#ghost.peek-top .gh-peekwrap { transform: translate(-44px, -40px); }
#ghost.fake.ph-tell .g-bob { animation: wiggle .3s ease-in-out infinite; }

.q.walking { transition: transform .9s ease-in-out; }
.q.walking .q-in { animation: walkbob .28s ease-in-out infinite; }
@keyframes walkbob { 50% { transform: translateY(-5px) rotate(2deg); } }
/* peekaboo twists and lights out */
.pk-twist { position: absolute; left: 50%; top: 470px; transform: translate(-50%, -50%) scale(.5); z-index: 40; background: #fff; border-radius: 26px; padding: 14px 24px 16px; text-align: center;
  box-shadow: 0 16px 40px rgba(40,30,110,.35); opacity: 0; pointer-events: none; width: 380px; }
.pk-twist b { display: block; font-size: 16px; letter-spacing: 1px; text-transform: uppercase; color: #E46A7B; font-weight: 900; }
.pk-twist span { display: block; font-size: 40px; font-weight: 900; color: var(--ink); line-height: 1.1; }
.pk-twist small { display: block; font-size: 18px; color: var(--muted); font-weight: 600; margin-top: 4px; }
.pk-twist small b { display: inline; color: var(--sapphire); font-size: inherit; letter-spacing: 0; text-transform: none; }
.pk-twist.show { animation: twist 2s cubic-bezier(.34,1.56,.64,1) forwards; }
@keyframes twist { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.4) rotate(-8deg); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.05) rotate(2deg); } 22%, 85% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(.9); } }
#world-peek.dark .pw.pop:not(.wrong) .pw-glass { background: radial-gradient(circle at 50% 60%, #9D92DA, #7568C0); }
#world-peek.dark .pw-cur { width: 9%; }
.pw-who img { position: absolute; }

.win-hh { margin: 0; font-weight: 900; font-size: 15px; letter-spacing: 1.4px; text-transform: uppercase; color: #E46A7B; opacity: 0; }
#win.show .win-hh { animation: fadeup .4s ease-out .1s forwards; }

/* win moment timing: the per-round version runs about twice as fast and carries on by itself */
#win { --sp: 1; }
#win.quick { --sp: .45; }
#win.show .win-body { animation-delay: calc(1.25s * var(--sp)); }
#win.show .win-line .w span { animation-delay: calc(var(--k) * 24ms * var(--sp)), calc(1.2s * var(--sp) + var(--k) * 60ms); }
#win.show .win-stamp { animation-delay: calc(1.15s * var(--sp)), calc(1.8s * var(--sp)); }
#win.show .win-shades, #win.three-d.show .win-shades { animation-delay: calc(2s * var(--sp)); }
#win.show .win-iykyk { animation-delay: calc(2.6s * var(--sp)), calc(3.1s * var(--sp)); }
#win.show .win-iykyk span { animation-delay: calc(3.1s * var(--sp)); }
#win.show .win-sub { animation-delay: calc(3s * var(--sp)); }
#win.show .win-go, #win.show .win-alt { animation-delay: calc(3.3s * var(--sp)); }
.win-alt { opacity: 0; padding-top: 4px; }
#win.show .win-alt { animation: fadeup .4s ease-out forwards; animation-delay: calc(3.3s * var(--sp)); }
.win-stamp { white-space: nowrap; }
/* game over: encouraging, softer, no sunglasses */
#win.cheer { background: radial-gradient(circle at 50% 42%, rgba(255,246,228,.95), rgba(238,237,255,.92) 45%, rgba(178,170,232,.94) 100%); }
#win.cheer .win-stamp { background: linear-gradient(180deg, #F38BA6, #E46A7B); box-shadow: 0 10px 0 rgba(228,106,123,.25), 0 16px 34px rgba(228,106,123,.35); }
#win.cheer .win-shades { display: none; }
#win.cheer.show .win-hero { animation: sway 1.4s ease-in-out infinite alternate; }
@keyframes sway { from { transform: rotate(-3deg); } to { transform: rotate(3deg) translateY(-4px); } }
#win.quick .win-go { min-height: 44px; }

/* the champion's crown drops onto Shravan's head */
.win-crown { position: absolute; left: 50%; top: 0; width: 46px; transform: translate(-50%, -280px); opacity: 0; display: none; }
#win.crowned .win-crown { display: block; }
#win.three-d .win-crown { left: 106px; top: 13px; width: 52px; }
#win.crowned.show .win-crown { animation: crown .8s cubic-bezier(.3,1.6,.5,1) forwards; animation-delay: calc(2s * var(--sp)); }
@keyframes crown { 0% { opacity: 1; transform: translate(-50%, -280px) rotate(-25deg); } 100% { opacity: 1; transform: translate(-50%, 0) rotate(-8deg); } }
#win.crowned .win-shades { display: none; }

.t-links { display: flex; justify-content: center; align-items: center; gap: 2px; flex-wrap: wrap; }
.t-links .dot { color: var(--muted); }

/* lives: hearts, and losing one is impossible to miss */
.lives i { width: 22px; height: 20px; }
.lives i.lost { opacity: 1; filter: none; transform: none; }
.lives i.just { animation: lifeLost .7s cubic-bezier(.3,1.5,.5,1); }
@keyframes lifeLost { 0% { transform: scale(1.6) rotate(-12deg); } 30% { transform: scale(.7) rotate(10deg); } 55% { transform: scale(1.15) rotate(-6deg); } 100% { transform: none; } }
.lives:has(.just) { animation: livesShake .45s ease-in-out; }
@keyframes livesShake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
/* HUD never pushes the sound button off small phones */
.hud { grid-template-columns: auto minmax(0, 1fr) auto; }
.hud .mid { min-width: 0; }
.pill.round { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.need { text-align: center; }

/* ---------- end card: a proper little trophy moment ---------- */
#end .screen-card.end-card { padding: 0 18px 14px; overflow-x: hidden; }
.end-hero { position: relative; height: 150px; margin: 0 -18px 6px; border-radius: var(--r-hero) var(--r-hero) 0 0; overflow: hidden;
  background: linear-gradient(160deg, #8E92E2 0%, #B9A6E8 45%, #F6C5C9 80%, #FBD3B2 100%); }
.end-burst { position: absolute; left: 50%; top: 58%; width: 520px; height: 520px; transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from 0deg, rgba(255,255,255,.28) 0 10deg, rgba(255,255,255,0) 10deg 20deg); animation: spin 30s linear infinite;
  -webkit-mask-image: radial-gradient(circle, #000 0 25%, transparent 60%); mask-image: radial-gradient(circle, #000 0 25%, transparent 60%); }
.end-hero::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(circle, rgba(255,255,255,.9) 1.4px, transparent 1.8px); background-size: 46px 46px; background-position: 10px 14px; opacity: .55; }
.end-shr { position: absolute; left: 2%; bottom: -36px; height: 188px; width: auto; max-width: none !important; z-index: 1; filter: drop-shadow(0 6px 10px rgba(40,30,110,.25)); animation: bounce .9s ease-in-out infinite; }
.end-badge { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 118px; height: 118px; border-radius: 50%; z-index: 2;
  background: radial-gradient(circle at 35% 30%, #fff, #F4F2FF 70%); box-shadow: 0 0 0 6px rgba(255,255,255,.55), 0 0 0 12px rgba(255,255,255,.22), 0 14px 30px rgba(40,30,110,.3);
  display: flex; flex-direction: column; align-items: center; justify-content: center; animation: badgein .6s cubic-bezier(.34,1.56,.64,1); }
@keyframes badgein { from { transform: translate(-50%, -50%) scale(.3) rotate(-20deg); } }
.end-badge b { font-size: 46px; font-weight: 900; line-height: 1; color: var(--sapphire); font-variant-numeric: tabular-nums; }
.end-badge span { font-size: 13px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; margin-top: 2px; }
.end-best { position: absolute; right: 12px; top: 12px; z-index: 2; background: rgba(255,255,255,.9); color: var(--ink); font-size: 13px; font-weight: 800; padding: 5px 11px; border-radius: 999px; box-shadow: var(--sh-soft); }
.end-best.is-new { background: linear-gradient(180deg, #FFE27A, #FFC93C); color: #6B4A00; animation: wiggle2 .9s ease-in-out infinite; }
.end-card .caption { font-size: 16px; margin: 4px 4px 8px; text-wrap: balance; }
#end .stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; background: none; padding: 0; margin: 0 0 10px; }
#end .stats span { background: var(--peri); color: var(--muted); border-radius: 999px; padding: 5px 11px; font-size: 13.5px; font-weight: 600; }
#end .stats b { color: var(--ink); }
#e-share svg { width: 18px; height: 18px; margin-right: 6px; flex: none; }
/* rating: a soft card with big pumpkins that bounce */
.end-card .rate { margin-top: 12px; padding: 12px 10px 10px; border-top: 0; border-radius: 18px;
  background: linear-gradient(135deg, #FFF3E8 0%, #FFFFFF 45%, #EEEDFF 100%); box-shadow: inset 0 0 0 1.5px #F2E6F5; }
.end-card .rate-q { font-size: 16px; font-weight: 800; margin-bottom: 4px; }
.end-card .stars { gap: 4px; }
.end-card .stars button, #f-stars button { width: 50px; height: 50px; filter: grayscale(1) opacity(.4); transition: filter .15s, transform .18s cubic-bezier(.34,1.56,.64,1); }
.stars button.hover { filter: grayscale(.2) opacity(.85); transform: translateY(-3px) scale(1.06); }
.stars button.on { filter: none; transform: scale(1.1); }
.stars button.bounce { animation: pumpkinpop .5s cubic-bezier(.34,1.8,.64,1) var(--d, 0s); }
@keyframes pumpkinpop { 0% { transform: scale(.6) rotate(-14deg); } 60% { transform: scale(1.3) rotate(8deg); } 100% { transform: scale(1.1); } }
.rate-label { margin: 2px 0 0; font-size: 14px; font-weight: 800; color: var(--sapphire); min-height: 19px; }
.end-card .rate.rated .rate-label { display: none; }
.end-card .rate-thanks { display: none; align-items: center; justify-content: center; gap: 8px; margin-top: 4px; font-size: 15px; font-weight: 700; }
.end-card .rate.rated .rate-thanks { display: flex; }
/* try another game: little coloured cards */
.end-card .more { border-top: 0; padding-top: 4px; }
.game-chip { display: inline-flex; align-items: center; gap: 7px; border: 0; border-radius: 14px; padding: 8px 14px 8px 10px; font-weight: 800; font-size: 14.5px; color: var(--ink);
  box-shadow: 0 4px 12px rgba(23,37,84,.1); transition: transform .12s; }
.game-chip:active { transform: scale(.96); }
.game-chip svg { width: 24px; height: 22px; }
.game-chip.g-heist { background: linear-gradient(135deg, #FFE3EE, #FFF3F7); }
.game-chip.g-tower { background: linear-gradient(135deg, #FFE7D1, #FFF5EA); }
.game-chip.g-peek { background: linear-gradient(135deg, #E6E4FF, #F4F3FF); }
/* sheets get the family peeking over the top */
.sheet-card { padding-top: 0; }
.sheet-hero { position: relative; height: 104px; margin: 0 -20px 10px; border-radius: var(--r-card) var(--r-card) 0 0; overflow: hidden;
  background: linear-gradient(160deg, #8E92E2 0%, #B9A6E8 50%, #FBD3B2 100%); }
.sheet-hero::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(circle, rgba(255,255,255,.9) 1.3px, transparent 1.7px); background-size: 40px 40px; opacity: .5; }
.sheet-hero img { position: absolute; bottom: -8px; width: auto; max-width: none !important; filter: drop-shadow(0 4px 8px rgba(40,30,110,.25)); z-index: 1; }
.sheet-hero .sh-shr { left: 10px; height: 150px; bottom: -42px; }
.sheet-hero .sh-c1 { right: 96px; height: 112px; bottom: -36px; }
.sheet-hero .sh-c2 { right: 18px; height: 78px; bottom: -6px; }
.sheet-hero .sh-c3 { right: 150px; height: 116px; bottom: -40px; }
.sheet-hero.fb .sh-c1 { left: 16px; right: auto; }
.sheet-card .x { z-index: 3; background: rgba(255,255,255,.9); }
.sheet-card h2 { margin-top: 2px; }
.field input::placeholder, .field textarea::placeholder { color: #A3A9BD; }
.done { text-align: center; }
.done-big { font-size: 44px; margin: 6px 0 0 !important; animation: pumpkinpop .6s cubic-bezier(.34,1.8,.64,1); }
#f-stars { justify-content: center; }
#sheet-share .sheet-card { padding-top: 20px; }
#f-stars button.hover, .end-card .stars button.hover { filter: grayscale(.2) opacity(.85); transform: translateY(-3px) scale(1.06); }
#f-stars button.on, .end-card .stars button.on { filter: none; transform: scale(1.1); }
