/* =========================================================
   One More Slice – cosy bakery look
   Thick cocoa outlines + hard sticker shadows
   ========================================================= */
:root {
  color-scheme: light;
  --ink: #4b2e2b;
  --ink-soft: #8a6a62;
  --line: 3px solid var(--ink);
  --pop: 0 5px 0 var(--ink);
  --pop-sm: 0 3px 0 var(--ink);
  --wall-top: #9fdcae;
  --wall-bot: #e4f6dc;
  --card: #ffffff;
  --cream: #fff8ec;
  --green: #45c06e;
  --green-dark: #2e9a52;
  --yellow: #ffd23f;
  --good: #36c97a;
  --wood: #d99a5b;
  --wood-dark: #b3743a;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--wall-bot); color: var(--ink);
  font-family: var(--font); font-weight: 700;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none; touch-action: manipulation;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
svg { display: block; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
.defs { position: absolute; }

/* ---------- Backdrop ---------- */
.room {
  position: fixed; inset: 0; z-index: 0; overflow: hidden;
  background:
    radial-gradient(circle at 12px 12px, rgba(255, 255, 255, .5) 3.5px, transparent 4px) 0 0 / 44px 44px,
    radial-gradient(circle at 34px 34px, rgba(255, 255, 255, .35) 3.5px, transparent 4px) 0 0 / 44px 44px,
    linear-gradient(180deg, var(--wall-top), var(--wall-bot) 70%);
}
.floor {
  position: absolute; left: 0; right: 0; bottom: 0; height: 17%;
  border-top: 4px solid var(--ink);
  background: repeating-linear-gradient(90deg, #f3b98a 0 58px, #e9a873 58px 62px);
}
.bunting { position: absolute; top: calc(var(--safe-t) - 4px); left: -4%; right: -4%; height: 46px; display: flex; justify-content: space-between; }
.bunting i {
  width: 30px; height: 36px; background: var(--c); border: 3px solid var(--ink); border-top-width: 4px;
  clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: 50% 0;
  animation: sway 3.2s ease-in-out infinite; animation-delay: calc(var(--i) * -0.37s);
  margin-top: calc(var(--y) * 1px);
}
@keyframes sway { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(7deg); } }

/* ---------- Screens ---------- */
#app { position: fixed; inset: 0; z-index: 1; }
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 12px) 14px calc(var(--safe-b) + 12px);
  max-width: 560px; margin: 0 auto;
  opacity: 0; pointer-events: none; transform: translateY(24px) scale(.97);
  transition: opacity .25s, transform .35s cubic-bezier(.2, 1.3, .4, 1);
}
.screen.active { opacity: 1; pointer-events: auto; transform: none; }

/* ---------- Buttons ---------- */
.btn, .tool, .icon-btn {
  --gleam: radial-gradient(ellipse 13px 6px at 20% 22%, rgba(255, 255, 255, .95), rgba(255, 255, 255, 0) 100%);
  --sheen: linear-gradient(180deg, rgba(255, 255, 255, .28), rgba(255, 255, 255, 0) 50%);
  background: var(--gleam), var(--sheen), var(--base, var(--card));
  border: var(--line);
  box-shadow: var(--pop), inset 0 3px 0 rgba(255, 255, 255, .7), inset 0 -4px 0 rgba(75, 46, 43, .08);
  transition: transform .12s, box-shadow .12s;
}
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border-radius: 22px; padding: 12px 18px; min-height: 58px; width: 100%;
}
.btn:active, .tool:active, .icon-btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--ink), inset 0 3px 0 rgba(255, 255, 255, .7); }
.btn-primary { --base: var(--green); color: #fff; }
.btn-primary .btn-big { -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; }
.btn-light { --base: #fff; }
.btn-big { font-size: 21px; font-weight: 900; display: block; }
.btn-small { font-size: 13px; font-weight: 800; opacity: .95; display: block; }
.btn-ico { width: 24px; height: 24px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-row .btn { min-height: 50px; padding: 8px; }
.btn-row .btn-big { font-size: 17px; }
.icon-btn { width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center; box-shadow: var(--pop-sm), inset 0 2px 0 rgba(255, 255, 255, .7); flex-shrink: 0; }
.icon-btn svg { width: 24px; height: 24px; }
.link-btn { font-size: 14px; font-weight: 800; color: var(--ink-soft); text-decoration: underline; padding: 6px; }

/* ---------- Home ---------- */
.home-top { display: flex; gap: 8px; align-items: center; }
.home-top .icon-btn { margin-left: auto; }
.pill {
  display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px 0 9px; border-radius: 20px;
  background: #fff; border: var(--line); box-shadow: var(--pop-sm); font-size: 17px; font-weight: 900; font-variant-numeric: tabular-nums;
}
.pill svg { width: 22px; height: 22px; fill: var(--yellow); stroke: var(--ink); stroke-width: 2px; stroke-linejoin: round; paint-order: stroke; overflow: visible; }
.pill span { font-size: 19px; }
.pill.bump { animation: popIn .45s cubic-bezier(.2, 1.8, .4, 1); }
.home-hero { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; }
.hero-scene { position: relative; width: min(62vw, 250px, 30vh); aspect-ratio: 1.5; }
.hero-scene .mon { position: absolute; left: 0; bottom: 0; width: 62%; }
.hero-cake { position: absolute; right: 2%; bottom: 8%; font-size: min(17vw, 70px, 8.5vh); line-height: 1; animation: heroCake 2.4s ease-in-out infinite; filter: drop-shadow(0 4px 0 rgba(75, 46, 43, .35)); }
@keyframes heroCake { 0%, 100% { transform: translate(0, 0) rotate(8deg); } 50% { transform: translate(-22%, -8%) rotate(-10deg); } }
.title { font-size: clamp(38px, 12.5vw, 62px); font-weight: 900; line-height: .98; color: #fff; -webkit-text-stroke: 9px var(--ink); paint-order: stroke fill; letter-spacing: .5px; }
.title span { display: inline-block; animation: letter 2.6s ease-in-out infinite; animation-delay: calc(var(--i) * .09s); }
.title span.sp { width: .28em; }
.title .w2 { color: var(--yellow); }
.title .w3 { color: #a6ec8f; }
@keyframes letter { 0%, 70%, 100% { transform: translateY(0) rotate(0); } 80% { transform: translateY(-9px) rotate(-5deg); } 90% { transform: translateY(2px) rotate(3deg); } }
.subtitle { font-size: 15px; font-weight: 800; line-height: 1.35; margin-top: 6px; color: var(--ink); }
.home-play { display: flex; flex-direction: column; gap: 12px; padding: 10px 6px 14px; }
.btn-play { min-height: 74px; flex-direction: column; gap: 0; animation: playPulse 2.2s ease-in-out infinite; }
.btn-play .btn-big { font-size: 27px; }
.btn-play .btn-small { -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; font-size: 14px; }
@keyframes playPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.035); } }
.btn-play:active { animation: none; }

.app-footer { text-align: center; font-size: 12px; font-weight: 800; color: #fff; line-height: 1.35; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.app-footer a, .app-footer button { color: #fff; font-weight: 900; text-decoration: underline; text-underline-offset: 2px; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.app-footer-legal { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 2px; }
.app-footer-legal button { padding: 2px 4px; }
.app-footer .heart { display: inline-block; margin: 0 2px; -webkit-text-stroke: 0; animation: heartbeat 1.4s ease-in-out infinite; }
@keyframes heartbeat { 0%, 60%, 100% { transform: scale(1); } 15% { transform: scale(1.3); } 30% { transform: scale(1.1); } 45% { transform: scale(1.25); } }
.settings-legal { margin: 6px 0 0; font-size: 12.5px; color: var(--ink-soft); font-weight: 700; }
.settings-legal a, .settings-legal button { color: var(--ink-soft); text-decoration: underline; font-weight: 800; }
.kofi-link { display: inline-block; margin-top: 6px; }

/* ---------- Top bar ---------- */
.topbar { display: flex; align-items: center; gap: 10px; min-height: 50px; }
.game-title { flex: 1; text-align: center; line-height: 1.1; }
.game-title h2 { font-size: 24px; font-weight: 900; color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; }
.game-title small { font-size: 12.5px; font-weight: 800; color: var(--ink); }
.spacer { width: 46px; }
.moves { min-width: 58px; height: 46px; border-radius: 16px; background: #fff; border: var(--line); box-shadow: var(--pop-sm); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.moves small { font-size: 9.5px; font-weight: 900; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .5px; }
.moves b { font-size: 20px; font-weight: 900; font-variant-numeric: tabular-nums; }
.moves.bump b { animation: popIn .3s cubic-bezier(.2, 1.8, .4, 1); display: inline-block; }

/* ---------- Level select ---------- */
.level-grid {
  flex: 1; min-height: 0; overflow-y: auto; touch-action: pan-y; margin-top: 10px; padding: 4px 4px 20px;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; align-content: start;
}
.lvl {
  aspect-ratio: 1; border-radius: 18px; background: #fff; border: var(--line); box-shadow: var(--pop-sm);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 20px; font-weight: 900;
}
.lvl:active { transform: translateY(3px); box-shadow: none; }
.lvl .st { display: flex; gap: 1px; }
.lvl .st svg { width: 11px; height: 11px; fill: #e6dcd4; }
.lvl .st svg.on { fill: var(--yellow); stroke: var(--ink); stroke-width: 2.5px; paint-order: stroke; overflow: visible; }
.lvl.next { background: var(--yellow); animation: playPulse 1.6s ease-in-out infinite; }
.lvl.locked { background: rgba(255, 255, 255, .45); color: var(--ink-soft); box-shadow: none; border-style: dashed; }
.lvl.endless { background: none; border-style: dashed; box-shadow: none; color: var(--ink-soft); font-size: 26px; }
.lvl.locked svg { width: 20px; height: 20px; opacity: .6; }

/* ---------- Game ---------- */
.tip {
  margin: 8px 4px 0; padding: 9px 14px; border-radius: 18px; background: #fff; border: var(--line); box-shadow: var(--pop-sm);
  font-size: 14.5px; font-weight: 800; line-height: 1.3; text-align: center; animation: popIn .5s cubic-bezier(.2, 1.6, .4, 1) both;
}
.board-wrap { flex: 1; min-height: 0; position: relative; display: grid; place-items: center; }
/* --pl/--pt/--pr/--pb: room around the table, wide only on sides where a monster sits */
.stage { --pl: 1.15; --pt: 1.15; --pr: 1.15; --pb: 1.15; position: relative; width: calc(var(--u) * (var(--w) + var(--pl) + var(--pr))); height: calc(var(--u) * (var(--h) + var(--pt) + var(--pb))); touch-action: none; }
.table {
  position: absolute; left: calc(var(--u) * var(--pl)); top: calc(var(--u) * var(--pt)); z-index: 2;
  width: calc(var(--u) * var(--w)); height: calc(var(--u) * var(--h));
}
.cloth {
  position: absolute; z-index: 0; pointer-events: none; overflow: visible;
  left: calc(var(--u) * -.4); top: calc(var(--u) * -.4); width: calc(var(--u) * (var(--w) + .8)); height: calc(var(--u) * (var(--h) + .8));
  filter: drop-shadow(0 calc(var(--u) * .3) calc(var(--u) * .2) rgba(75, 46, 43, .25));
}

/* mouth-wide gap in the table rim */
.gate {
  position: absolute; z-index: 1; background: var(--c); border: 3px solid var(--ink); border-radius: calc(var(--u) * .08);
  background-image: repeating-linear-gradient(var(--ga), rgba(255, 255, 255, .55) 0 4px, transparent 4px 10px);
}
.gate.t, .gate.b { left: calc(var(--u) * var(--at) + 4px); width: calc(var(--u) * var(--len) - 8px); height: calc(var(--u) * .2); --ga: 90deg; }
.gate.l, .gate.r { top: calc(var(--u) * var(--at) + 4px); height: calc(var(--u) * var(--len) - 8px); width: calc(var(--u) * .2); --ga: 0deg; }
.gate.t { top: calc(var(--u) * -.2); } .gate.b { bottom: calc(var(--u) * -.2); }
.gate.l { left: calc(var(--u) * -.2); } .gate.r { right: calc(var(--u) * -.2); }
.gate.want { animation: gateGlow .5s ease-in-out infinite alternate; }
@keyframes gateGlow { to { box-shadow: 0 0 0 4px #fff, 0 0 14px 6px var(--c); } }

/* ---------- Monsters ---------- */
.eater { position: absolute; width: calc(var(--u) * 1.12); height: calc(var(--u) * 1.12); pointer-events: none; }
.eater.t { z-index: 1; left: calc(var(--u) * (var(--pl) + var(--mid)) - var(--u) * .56); top: calc(var(--u) * (var(--pt) - 1.27)); }
.eater.b { z-index: 3; left: calc(var(--u) * (var(--pl) + var(--mid)) - var(--u) * .56); top: calc(var(--u) * (var(--pt) + var(--h) + .2)); }
.eater.l { z-index: 3; top: calc(var(--u) * (var(--pt) + var(--mid)) - var(--u) * .62); left: calc(var(--u) * (var(--pl) - 1.17)); }
.eater.r { z-index: 3; top: calc(var(--u) * (var(--pt) + var(--mid)) - var(--u) * .62); left: calc(var(--u) * (var(--pl) + var(--w) + .08)); }
.eater.l .mon { transform: rotate(10deg); } .eater.r .mon { transform: rotate(-10deg); }
.mon { width: 100%; height: 100%; overflow: visible; }
.mon * { vector-effect: none; }
.mon .ink { stroke: var(--ink); stroke-width: 4.5; stroke-linejoin: round; stroke-linecap: round; }
.mon-body { transform-origin: 50% 95%; animation: bob 2.6s ease-in-out infinite; animation-delay: var(--d, 0s); transform-box: fill-box; }
@keyframes bob { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.04, .95); } }
.mon .m-open, .mon .eyes-happy, .mon .drool, .mon .zzz { display: none; }
.mon .pupil { transition: transform .12s; }
.mon .lid { transform-box: fill-box; transform-origin: 50% 0; animation: blink 4.2s infinite; animation-delay: var(--d, 0s); transform: scaleY(0); }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(0); } 96%, 98% { transform: scaleY(1); } }

.want .mon-body { animation: wiggle .45s ease-in-out infinite; }
@keyframes wiggle { 0%, 100% { transform: rotate(-5deg) scale(1.06); } 50% { transform: rotate(5deg) scale(1.1, 1.03); } }
.want .m-open, .eat .m-open { display: block; }
.want .m-closed, .eat .m-closed { display: none; }
.want .drool { display: block; animation: drool 1s ease-in infinite; transform-box: fill-box; transform-origin: 50% 0; }
@keyframes drool { 0% { transform: scaleY(.2); opacity: 0; } 30% { opacity: 1; } 100% { transform: scaleY(1.6) translateY(6px); opacity: 0; } }

.eat .mon-body { animation: gulp .52s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes gulp { 0% { transform: scale(1.25, .8); } 30% { transform: scale(.88, 1.2); } 55% { transform: scale(1.18, .86); } 80% { transform: scale(.96, 1.06); } 100% { transform: none; } }
.eat .m-open { transform-box: fill-box; transform-origin: 50% 20%; animation: chomp .17s ease-in-out 3; }
@keyframes chomp { 50% { transform: scaleY(.12); } }

.full .eyes-open, .party .eyes-open { display: none; }
.full .eyes-happy, .party .eyes-happy { display: block; }
.full .mon-body { animation: bob 3.6s ease-in-out infinite; }
.full .zzz { display: block; animation: zzz 2.4s ease-in-out infinite; transform-box: fill-box; }
@keyframes zzz { 0% { transform: translate(0, 6px) scale(.5); opacity: 0; } 40% { opacity: 1; } 100% { transform: translate(8px, -14px) scale(1.1); opacity: 0; } }
.party .mon-body { animation: party .5s ease-in-out infinite; animation-delay: var(--d, 0s); }
.party .zzz { display: none; }

/* a full monster waves and leaves; it comes back for the party at the end */
.eater .mon { transition: opacity .3s; }
.eater.leaving .mon { animation: leave 1.2s cubic-bezier(.45, 0, .6, 1) forwards; }
@keyframes leave {
  0% { transform: none; }
  20% { transform: translateY(-14%) rotate(-12deg) scale(1.06); }
  35% { transform: translateY(0) rotate(10deg); }
  50% { transform: translateY(-8%) rotate(-8deg); }
  62% { transform: translateY(0) rotate(0) scale(1.05, .92); opacity: 1; }
  100% { transform: translateY(-70%) scale(.1) rotate(30deg); opacity: 0; }
}
.eater.left { visibility: hidden; }
.eater.back .mon { animation: backIn .55s var(--back, 0s) cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes backIn { 0% { transform: translateY(-60%) scale(0); opacity: 0; } 100% { transform: none; opacity: 1; } }
.gate { transition: opacity .6s .6s, transform .6s .6s; }
.gate.left { opacity: 0; transform: scale(.4); }
@keyframes party { 0%, 100% { transform: translateY(0) rotate(-8deg); } 50% { transform: translateY(-16%) rotate(8deg) scale(.95, 1.08); } }

/* ---------- Cakes ---------- */
.cake {
  position: absolute; left: 0; top: 0; pointer-events: none; z-index: 2;
  width: calc(var(--u) * var(--cw)); height: calc(var(--u) * var(--ch));
  transform: translate(calc(var(--u) * var(--x) + var(--lx, 0px)), calc(var(--u) * var(--y) + var(--ly, 0px)));
  transition: transform .11s cubic-bezier(.3, 1.3, .6, 1);
}
.cake svg { width: 100%; height: 100%; overflow: visible; transition: transform .15s cubic-bezier(.2, 1.8, .4, 1), filter .15s; transform-origin: 50% 50%; }
.cake svg * { pointer-events: none; }
.stage { cursor: grab; }
.stage:active { cursor: grabbing; }
.cake .ink { stroke: var(--ink); stroke-width: 5; stroke-linejoin: round; }
.cake .pipe { fill: none; stroke-width: 9; stroke-linecap: round; stroke-dasharray: 0 17; }
.cake .inner { stroke: var(--ink); stroke-width: 4; }
.cake .emo { font-size: 46px; text-anchor: middle; dominant-baseline: central; }
.cake .num { font-size: 44px; font-weight: 900; text-anchor: middle; dominant-baseline: central; fill: var(--ink); font-family: var(--font); }
.cake.drag { z-index: 5; transition: none; } /* follows the finger exactly */
.cake.drag svg { transform: scale(1.07) translateY(-3%); filter: drop-shadow(0 calc(var(--u) * .14) 0 rgba(75, 46, 43, .28)); }
.cake.pop svg { animation: cakePop .45s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes cakePop { 0% { transform: scale(.7); } 60% { transform: scale(1.14); } 100% { transform: none; } }
.cake.enter svg { animation: cakeIn .5s cubic-bezier(.2, 1.6, .4, 1) both; animation-delay: var(--delay, 0s); }
@keyframes cakeIn { 0% { transform: translateY(-120%) scale(.5) rotate(-12deg); opacity: 0; } 70% { transform: translateY(4%) scale(1.06, .92); opacity: 1; } 100% { transform: none; } }
.cake.nope svg { animation: nope .35s; }
@keyframes nope { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-7%) rotate(-3deg); } 50% { transform: translateX(7%) rotate(3deg); } 80% { transform: translateX(-4%); } }
.cake.hinted svg { animation: hintWiggle .6s ease-in-out infinite; }
@keyframes hintWiggle { 0%, 100% { transform: rotate(-3deg) scale(1.04); } 50% { transform: rotate(3deg) scale(1.08); } }
.cake .dome { transform-box: fill-box; transform-origin: 50% 100%; }
.cake.dome-off .dome { animation: domeOff .55s cubic-bezier(.4, 0, .8, .6) forwards; }
@keyframes domeOff { 30% { transform: translateY(-12%) rotate(-6deg); opacity: 1; } 100% { transform: translateY(-120%) rotate(18deg) scale(1.15); opacity: 0; } }
.cake.ghost { z-index: 6; }
.hint-ghost { position: absolute; left: 0; top: 0; z-index: 1; pointer-events: none; width: calc(var(--u) * var(--cw)); height: calc(var(--u) * var(--ch)); transform: translate(calc(var(--u) * var(--x)), calc(var(--u) * var(--y))); animation: ghost 1s ease-in-out infinite alternate; }
.hint-ghost svg { width: 100%; height: 100%; overflow: visible; }
.hint-ghost path { fill: rgba(255, 210, 63, .35); stroke: var(--ink); stroke-width: 5; stroke-dasharray: 14 12; stroke-linecap: round; }
@keyframes ghost { from { opacity: .45; } to { opacity: 1; } }

.teapot { position: absolute; left: 0; top: 0; width: var(--u); height: var(--u); transform: translate(calc(var(--u) * var(--x)), calc(var(--u) * var(--y))); display: grid; place-items: center; z-index: 1; }
.teapot::before { content: ""; position: absolute; inset: 9%; border-radius: 50%; background: #fff; border: 2.5px dashed var(--ink-soft); }
.teapot span { position: relative; font-size: calc(var(--u) * .6); line-height: 1; filter: drop-shadow(0 3px 0 rgba(75, 46, 43, .3)); }
.teapot i { position: absolute; left: 50%; top: 4%; width: 4px; height: 22%; border-radius: 4px; background: rgba(255, 255, 255, .9); animation: steam 2s ease-in-out infinite; }
@keyframes steam { 0% { transform: translate(-50%, 40%) scaleY(.4); opacity: 0; } 50% { opacity: .9; } 100% { transform: translate(40%, -70%) scaleY(1.2); opacity: 0; } }

.combo {
  position: absolute; left: 50%; top: 4%; transform: translate(-50%, 0) scale(0); z-index: 8; pointer-events: none; white-space: nowrap;
  font-size: 30px; font-weight: 900; color: var(--yellow); -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill;
}
.combo.show { animation: comboPop 1.1s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes comboPop { 0% { transform: translate(-50%, 20px) scale(0) rotate(-12deg); } 25% { transform: translate(-50%, 0) scale(1.25) rotate(4deg); } 40%, 75% { transform: translate(-50%, 0) scale(1) rotate(-2deg); opacity: 1; } 100% { transform: translate(-50%, -30px) scale(.8); opacity: 0; } }

.baking { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font-size: 17px; font-weight: 900; }
.baking span { font-size: 64px; animation: baking 1s ease-in-out infinite; }
@keyframes baking { 0%, 100% { transform: translateY(0) scale(1, 1) rotate(-6deg); } 50% { transform: translateY(-18px) scale(.94, 1.08) rotate(6deg); } }

.tools { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; padding: 6px 4px 2px; }
.tool { border-radius: 20px; min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 13px; font-weight: 900; }
.tool svg { width: 26px; height: 26px; }
.tool-hint { --base: var(--yellow); }
.tool:disabled { opacity: .5; }
.tool[hidden] { display: none; }
.tool b { font-weight: 900; }

/* ---------- Knife ---------- */
.tool-knife { --base: #dff3ff; }
.tool-knife.on { --base: #ffb3c1; animation: wiggle .5s ease-in-out infinite; }
.tool-knife.hinted { animation: hintWiggle .6s ease-in-out infinite; }
.stage.knife { cursor: crosshair; }
.cake .cutlines { fill: none; stroke: var(--ink); stroke-width: 4; stroke-dasharray: 10 9; stroke-linecap: round; opacity: 0; transition: opacity .2s; }
.stage.knife .cake .cutlines { opacity: .55; }
.slash {
  position: absolute; z-index: 9; height: 7px; margin-top: -3.5px; transform-origin: 0 50%; pointer-events: none; border-radius: 4px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), #fff 30%, #fff);
  box-shadow: 0 0 0 2px rgba(75, 46, 43, .55), 0 0 14px 4px rgba(255, 255, 255, .9);
}
.slash.fade { transition: opacity .35s, height .35s; opacity: 0; height: 2px; }
.cake.split svg { animation: split .55s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes split { 0% { transform: translate(calc(var(--kx) * -.5), calc(var(--ky) * -.5)); } 35% { transform: translate(var(--kx), var(--ky)) rotate(var(--kr)); } 100% { transform: none; } }
.hint-cut { position: absolute; left: 0; top: 0; z-index: 7; pointer-events: none; border-radius: 4px; animation: ghost .6s ease-in-out infinite alternate;
  background: repeating-linear-gradient(var(--hd), #fff 0 9px, var(--ink) 9px 16px); box-shadow: 0 0 0 2px var(--ink); }
.hint-cut.v { --hd: 180deg; width: 5px; height: calc(var(--u) * var(--len)); transform: translate(calc(var(--u) * var(--x) - 2.5px), calc(var(--u) * var(--y))); }
.hint-cut.h { --hd: 90deg; height: 5px; width: calc(var(--u) * var(--len)); transform: translate(calc(var(--u) * var(--x)), calc(var(--u) * var(--y) - 2.5px)); }
.stage.nope-knife { animation: nope .35s; }

/* ---------- Effects ---------- */
.fx { position: fixed; inset: 0; z-index: 40; pointer-events: none; overflow: hidden; }
.crumb { position: absolute; left: 0; top: 0; width: 9px; height: 9px; border-radius: 3px; border: 2px solid var(--ink); }
.yum { position: absolute; left: 0; top: 0; font-size: 24px; font-weight: 900; color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; white-space: nowrap; }
.sprinkle { position: absolute; left: 0; top: 0; width: 8px; height: 20px; border-radius: 6px; border: 2px solid var(--ink); }
.heartfx { position: absolute; left: 0; top: 0; font-size: 22px; }

/* ---------- Modals ---------- */
.modal {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px;
  background: rgba(75, 46, 43, .38); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
  opacity: 0; pointer-events: none; transition: opacity .3s;
}
.modal.show { opacity: 1; pointer-events: auto; }
.card {
  position: relative; width: 100%; max-width: 380px; background: var(--cream); border-radius: 28px; padding: 22px 18px 18px;
  display: flex; flex-direction: column; gap: 11px; align-items: stretch; text-align: center;
  border: 4px solid var(--ink); box-shadow: 0 8px 0 var(--ink);
  transform: scale(.6) translateY(60px) rotate(-4deg); transition: transform .55s cubic-bezier(.2, 1.5, .4, 1);
}
.modal.show .card { transform: none; }
.card h2 { font-size: 27px; font-weight: 900; }
.modal-text { font-size: 15px; font-weight: 700; line-height: 1.4; color: var(--ink-soft); }
.win-card { padding-top: 6px; }
.win-mon { width: 120px; height: 120px; margin: -78px auto -4px; }
.modal.show .win-mon { animation: winDrop .9s cubic-bezier(.2, 1.5, .4, 1) both; }
@keyframes winDrop { 0% { transform: translateY(-120px) scale(.4) rotate(-30deg); opacity: 0; } 60% { transform: translateY(8px) scale(1.1, .92); opacity: 1; } 100% { transform: none; } }
.win-card h2 { color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; font-size: 30px; }
.modal.show .win-card h2 { animation: popIn .5s .25s cubic-bezier(.2, 1.8, .4, 1) both; }
@keyframes popIn { 0% { transform: scale(0); opacity: 0; } 100% { transform: none; opacity: 1; } }
.win-stars { display: flex; justify-content: center; align-items: flex-end; gap: 4px; }
.win-stars .star { width: 54px; height: 54px; fill: #e9dfd6; stroke: var(--ink); stroke-width: 2px; stroke-linejoin: round; paint-order: stroke; overflow: visible; }
.win-stars .star.big { width: 74px; height: 74px; margin-bottom: 8px; }
.win-stars .star.on { fill: var(--yellow); animation: starPop .7s cubic-bezier(.2, 1.9, .4, 1); }
@keyframes starPop { 0% { transform: scale(0) rotate(-180deg); } 60% { transform: scale(1.45) rotate(15deg); } 100% { transform: none; } }
.win-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.win-stats div { background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; padding: 6px 4px; display: flex; flex-direction: column; }
.win-stats small { font-size: 11px; color: var(--ink-soft); font-weight: 800; }
.win-stats b { font-size: 21px; font-weight: 900; font-variant-numeric: tabular-nums; }
.kofi-note { display: flex; align-items: center; gap: 10px; text-align: left; text-decoration: none; color: var(--ink); background: #fff3d6; border: 2.5px solid var(--ink); border-radius: 16px; padding: 8px 12px; font-size: 12.5px; font-weight: 700; line-height: 1.35; }
.kofi-note b { font-weight: 900; font-size: 13.5px; }
.kofi-cup { font-size: 28px; }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px; border-bottom: 2px dashed rgba(75, 46, 43, .15); text-align: left; font-weight: 900; font-size: 17px; }
.toggle input { display: none; }
.toggle i { width: 56px; height: 34px; border-radius: 18px; background: #e3d8d0; border: 3px solid var(--ink); position: relative; flex-shrink: 0; transition: background .2s; }
.toggle i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 2.5px solid var(--ink); box-sizing: border-box; transition: transform .3s cubic-bezier(.2, 1.6, .4, 1); }
.toggle input:checked + i { background: var(--good); }
.toggle input:checked + i::after { transform: translateX(22px); }
.lang-pick { display: flex; border: 3px solid var(--ink); border-radius: 18px; overflow: hidden; flex-shrink: 0; background: #fff; }
.lang-pick button { padding: 6px 12px; min-height: 34px; font-size: 14px; font-weight: 900; color: var(--ink-soft); }
.lang-pick button + button { border-left: 3px solid var(--ink); }
.lang-pick button.on { background: var(--good); color: #fff; }

.install-steps { text-align: left; font-size: 16px; font-weight: 800; line-height: 1.5; margin: 0; padding-left: 26px; }
.share-ico { display: inline-block; width: 20px; height: 20px; vertical-align: -4px; }

.legal-card { max-height: calc(100dvh - 40px - var(--safe-t) - var(--safe-b)); }
.legal {
  flex: 1; min-height: 0; overflow-y: auto; text-align: left; font-size: 14px; line-height: 1.5; font-weight: 600;
  background: #fff; border: 2.5px solid var(--ink); border-radius: 16px; padding: 4px 14px 10px;
  touch-action: pan-y; -webkit-user-select: text; user-select: text;
}
.legal h3 { margin: 12px 0 4px; font-size: 15px; font-weight: 900; }
.legal p { margin: 6px 0; }
.legal ul { margin: 6px 0; padding-left: 20px; }
.legal a { color: #2e8a4c; }
.legal strong { font-weight: 900; }
.legal-meta { color: var(--ink-soft); font-size: 12.5px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 96px); z-index: 30;
  transform: translate(-50%, 40px) scale(.8); opacity: 0; max-width: calc(100% - 32px); width: max-content;
  background: var(--card); color: var(--ink); padding: 10px 16px; border-radius: 18px; border: var(--line); box-shadow: var(--pop-sm);
  font-weight: 800; font-size: 15px; text-align: center; line-height: 1.3;
  transition: transform .4s cubic-bezier(.2, 1.6, .4, 1), opacity .25s; pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-height: 640px) {
  .subtitle { display: none; }
  .tool { min-height: 50px; }
}
@media (prefers-reduced-motion: reduce) {
  .bunting i, .title span, .btn-play, .mon-body { animation: none !important; }
}
