/* Lilita One (SIL Open Font License) - bundled locally */
@font-face { font-family: "Lilita"; font-display: swap; src: url("fonts/lilita.woff2") format("woff2"); }

/* ================= TUMBLE — toy arcade ================= */
/* Themes: 0 Candy Lane, 1 Moss Hollow, 2 Night Arcade */
:root {
  --bg1: #ff7eb0; --bg2: #ffb36b; --dot: rgba(255, 255, 255, .2);
  --ink: #2d1638; --ink-soft: #7d5e86; --card: #fffaf6; --card-edge: #f1d9e2;
  --rim: #ff4d8d; --rim-hi: #ff86b2; --rim-dark: #c4205d;
  --felt: #2fb3b8; --felt-dark: #1a7c84;
  --wall: #ffe1ec; --wall-edge: #e3a7bd;
  --accent: #ff4d8d; --accent-dark: #c4205d; --gold: #ffc21a; --gold-dark: #e08d00;
  --bad: #e5484d;
}
body[data-theme="1"] {
  --bg1: #8be07a; --bg2: #28b59b; --dot: rgba(255, 255, 255, .18);
  --ink: #17351f; --ink-soft: #4f6f57; --card-edge: #cfe5cf;
  --rim: #2f9e57; --rim-hi: #5fcb7f; --rim-dark: #1c6c39;
  --felt: #44834a; --felt-dark: #2a5a2f; --wall: #efe6cf; --wall-edge: #b6a57c;
  --accent: #23a35a; --accent-dark: #17733f;
}
body[data-theme="2"] {
  --bg1: #34208a; --bg2: #0b0826; --dot: rgba(190, 160, 255, .22);
  --ink: #2a1846; --ink-soft: #6f5c97; --card-edge: #d8ccf3;
  --rim: #7b4dff; --rim-hi: #a98aff; --rim-dark: #4321b5;
  --felt: #2a1d66; --felt-dark: #150e3c; --wall: #6d5ae0; --wall-edge: #3b2b9c;
  --accent: #ff3fc4; --accent-dark: #b51f8a;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: "Lilita", "Arial Rounded MT Bold", system-ui, sans-serif; color: var(--ink); letter-spacing: .01em;
  background: linear-gradient(165deg, var(--bg1), var(--bg2)); background-attachment: fixed;
  user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none;
}
button { font-family: inherit; color: inherit; }
.ico { display: inline-flex; width: 26px; height: 26px; }
.ico svg, [data-ico] > svg { width: 100%; height: 100%; display: block; }

/* drifting polka dots */
#bg { position: fixed; inset: -60px; pointer-events: none;
  background-image: radial-gradient(circle, var(--dot) 0 7px, transparent 8px), radial-gradient(circle, var(--dot) 0 4px, transparent 5px);
  background-size: 64px 64px, 64px 64px; background-position: 0 0, 32px 32px; animation: drift 24s linear infinite; }
@keyframes drift { to { transform: translate(64px, 64px); } }
body[data-theme="2"] #bg { background-size: 90px 90px, 47px 47px; animation-duration: 60s; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: none; margin: 0 auto; max-width: 560px;
  padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
.screen.on { display: grid; animation: screenIn .4s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes screenIn { from { opacity: 0; transform: scale(.96); } }

/* ---------- chunky round buttons ---------- */
.orb {
  position: relative; width: 66px; height: 66px; border-radius: 50%; border: none; cursor: pointer; display: grid; place-items: center;
  background: radial-gradient(circle at 34% 26%, #fff 0 9%, transparent 10%), linear-gradient(180deg, #fff, #ffeef4);
  box-shadow: 0 6px 0 var(--card-edge), 0 10px 18px rgba(0, 0, 0, .18), inset 0 -5px 0 rgba(0, 0, 0, .05);
  transition: transform .1s;
}
.orb:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--card-edge), 0 4px 8px rgba(0, 0, 0, .18); }
.orb .ico { width: 30px; height: 30px; color: var(--ink); }
.orb small { position: absolute; top: calc(100% + 9px); left: 50%; transform: translateX(-50%); white-space: nowrap;
  font-size: 13px; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .25); letter-spacing: .05em; text-transform: uppercase; }
.orb.small { width: 50px; height: 50px; box-shadow: 0 5px 0 var(--card-edge), 0 8px 14px rgba(0, 0, 0, .16); }
.orb.small .ico { width: 24px; height: 24px; }
.orb.hint { background: radial-gradient(circle at 34% 26%, #fff 0 9%, transparent 10%), linear-gradient(180deg, #ffe066, var(--gold)); box-shadow: 0 6px 0 var(--gold-dark), 0 10px 18px rgba(0, 0, 0, .18); }
.orb.hint .ico { color: #5a3500; }
.orb:disabled { opacity: .5; cursor: default; transform: none; }
.badge { position: absolute; top: -4px; right: -4px; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px; border: 3px solid #fff;
  background: var(--accent); color: #fff; font-style: normal; font-size: 14px; display: grid; place-items: center; }
.pill-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 56px; padding: 0 26px; border: none; border-radius: 28px; cursor: pointer;
  background: linear-gradient(180deg, var(--rim-hi), var(--accent)); color: #fff; font-size: 22px; text-shadow: 0 2px 0 rgba(0, 0, 0, .2);
  box-shadow: 0 6px 0 var(--accent-dark), 0 10px 18px rgba(0, 0, 0, .18), inset 0 2px 0 rgba(255, 255, 255, .35);
}
.pill-btn .ico { width: 22px; height: 22px; }
.pill-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--accent-dark); }
.pill-btn.ghost { background: #fff; color: var(--ink); text-shadow: none; box-shadow: 0 6px 0 var(--card-edge); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 42px; padding: 0 16px 0 10px; border-radius: 21px; background: #fff; box-shadow: 0 4px 0 var(--card-edge); font-size: 20px; }
.chip .ico { width: 26px; height: 26px; }
.chip.bump { animation: bump .4s; }
@keyframes bump { 40% { transform: scale(1.22) rotate(-4deg); } }

/* ---------- HOME ---------- */
#home { grid-template-rows: auto minmax(0, 1fr) auto; }
.home-top { display: flex; justify-content: flex-end; }
.home-hero { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2vh; min-height: 0; }
.logo { margin: 0; display: flex; gap: .02em; font-size: clamp(60px, 18vw, 110px); font-weight: 400; line-height: 1; }
.logo span {
  display: inline-block; color: var(--c); -webkit-text-stroke: .14em #fff; paint-order: stroke fill;
  text-shadow: 0 .09em 0 rgba(60, 10, 50, .35); animation: drop .9s cubic-bezier(.2, 1.7, .4, 1) both, idle 3.2s ease-in-out infinite;
}
.logo span:nth-child(1) { --c: #ff4d6d; --r: -8deg; animation-delay: .05s, 1s; }
.logo span:nth-child(2) { --c: #3d8bff; --r: 5deg; animation-delay: .13s, 1.2s; }
.logo span:nth-child(3) { --c: #ffb020; --r: -4deg; animation-delay: .21s, 1.4s; }
.logo span:nth-child(4) { --c: #2bb673; --r: 7deg; animation-delay: .29s, 1.6s; }
.logo span:nth-child(5) { --c: #9b5de5; --r: -6deg; animation-delay: .37s, 1.8s; }
.logo span:nth-child(6) { --c: #ff7a3d; --r: 4deg; animation-delay: .45s, 2s; }
@keyframes drop { from { transform: translateY(-120px) rotate(-40deg); opacity: 0; } to { transform: rotate(var(--r)); } }
@keyframes idle { 0%, 100% { transform: rotate(var(--r)); } 50% { transform: translateY(-6px) rotate(calc(var(--r) * -1)); } }
.demo-wrap { perspective: 900px; }
#demoTilt { transform: rotateX(22deg) rotateZ(-5deg); transform-style: preserve-3d; }
.home-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-bottom: 4px; }
.play-orb {
  position: relative; width: 112px; height: 112px; border-radius: 50%; border: 6px solid #fff; cursor: pointer; display: grid; place-items: center;
  background: radial-gradient(circle at 34% 26%, rgba(255, 255, 255, .8) 0 10%, transparent 11%), linear-gradient(180deg, var(--rim-hi), var(--accent));
  box-shadow: 0 8px 0 var(--accent-dark), 0 14px 26px rgba(0, 0, 0, .25); animation: breathe 1.8s ease-in-out infinite;
}
.play-orb::after { content: ""; position: absolute; inset: -14px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .7); animation: halo 1.8s ease-out infinite; }
.play-orb .ico { width: 50px; height: 50px; color: #fff; margin-left: 6px; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .2)); }
.play-orb:active { transform: translateY(5px) scale(.97); box-shadow: 0 3px 0 var(--accent-dark); }
@keyframes breathe { 50% { transform: scale(1.05); } }
@keyframes halo { from { transform: scale(.85); opacity: 1; } to { transform: scale(1.25); opacity: 0; } }
.play-label { font-size: 22px; color: #fff; text-shadow: 0 3px 0 rgba(0, 0, 0, .22); letter-spacing: .04em; }
.home-row { display: flex; gap: 12px; align-items: center; width: 100%; max-width: 420px; margin-top: 4px; }
.ticket {
  position: relative; flex: 1; display: flex; align-items: center; gap: 12px; min-height: 66px; padding: 10px 16px 10px 14px; border: none; cursor: pointer; text-align: left;
  background: #fff; border-radius: 16px; box-shadow: 0 5px 0 var(--card-edge), 0 10px 16px rgba(0, 0, 0, .15);
  -webkit-mask: radial-gradient(circle at 0 50%, transparent 10px, #000 11px) left / 51% 100% no-repeat, radial-gradient(circle at 100% 50%, transparent 10px, #000 11px) right / 51% 100% no-repeat;
          mask: radial-gradient(circle at 0 50%, transparent 10px, #000 11px) left / 51% 100% no-repeat, radial-gradient(circle at 100% 50%, transparent 10px, #000 11px) right / 51% 100% no-repeat;
}
.ticket:active { transform: translateY(3px); }
.ticket-ico { width: 42px; height: 42px; flex: none; }
.ticket-text { flex: 1; display: flex; flex-direction: column; border-left: 3px dashed var(--card-edge); padding-left: 12px; }
.ticket-text b { font-size: 20px; font-weight: 400; }
.ticket-text small { font-family: system-ui, sans-serif; font-weight: 600; font-size: 13px; color: var(--ink-soft); }
.ticket.done { opacity: .8; }
.streak { display: inline-flex; align-items: center; gap: 2px; font-size: 22px; color: #f0782d; }
.streak .ico { width: 26px; height: 26px; }
body.wide #home { max-width: 1040px; grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); grid-template-rows: auto minmax(0, 1fr); column-gap: 40px; }
body.wide .home-top { grid-column: 1 / -1; }
body.wide .home-hero { grid-column: 1; grid-row: 2; }
body.wide .home-actions { grid-column: 2; grid-row: 2; align-self: center; }
body.wide .logo { font-size: clamp(48px, 13vh, 120px); }

/* ---------- GAME ---------- */
#game { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto; row-gap: 12px; }
#game > * { min-width: 0; }
.topbar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; }
.level-chip { justify-self: center; display: flex; flex-direction: column; align-items: center; line-height: 1; padding: 7px 22px 8px; border-radius: 20px; background: #fff; box-shadow: 0 5px 0 var(--card-edge); }
.level-chip small { font-size: 12px; color: var(--accent); letter-spacing: .12em; text-transform: uppercase; }
.level-chip b { font-size: 24px; font-weight: 400; }

/* star meter: fill = moves left; stars fall off as their target is passed */
.meter { display: flex; align-items: center; gap: 12px; padding: 8px 18px 8px 8px; border-radius: 36px; background: #fff; box-shadow: 0 5px 0 var(--card-edge), 0 10px 16px rgba(0, 0, 0, .12); }
.meter-count { flex: none; width: 64px; height: 64px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: .9;
  background: linear-gradient(180deg, var(--rim-hi), var(--accent)); color: #fff; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .15); text-shadow: 0 2px 0 rgba(0, 0, 0, .2); }
.meter-count b { font-size: 30px; font-weight: 400; }
.meter-count small { font-size: 9px; text-transform: uppercase; letter-spacing: .06em; text-align: center; }
.meter.low .meter-count { background: linear-gradient(180deg, #ff8a8a, var(--bad)); animation: bump .45s; }
.meter-track { position: relative; flex: 1; height: 20px; border-radius: 10px; background: #f1e6ee; box-shadow: inset 0 3px 0 rgba(0, 0, 0, .07); }
.meter-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 10px; width: 100%;
  background: linear-gradient(90deg, var(--gold), #ff9a3d 60%, var(--accent)); box-shadow: inset 0 3px 0 rgba(255, 255, 255, .45); transition: width .4s cubic-bezier(.3, 1.3, .5, 1); }
.meter-stars { position: absolute; inset: 0; }
.meter-stars .ms { position: absolute; top: 50%; width: 34px; height: 34px; transform: translate(-50%, -50%); transition: transform .3s; }
.meter-stars .ms svg { width: 100%; height: 100%; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .2)); }
.meter-stars .ms.lost { animation: starFall .7s forwards; }
@keyframes starFall { 30% { transform: translate(-50%, -90%) rotate(-20deg); } to { transform: translate(-50%, 120%) rotate(90deg) scale(.6); opacity: 0; } }

.stage { position: relative; display: grid; place-items: center; min-height: 0; perspective: 1000px; touch-action: none; cursor: grab; }
.tilt { transform-style: preserve-3d; transition: transform .45s cubic-bezier(.3, 1.6, .5, 1); }
.tilt.tipping { transition: transform .16s ease-out; }
.toolbar { display: flex; justify-content: center; gap: 22px; padding-bottom: 26px; }
body.wide #game { max-width: 1120px; grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  grid-template-rows: auto minmax(0, 1fr) auto auto minmax(0, 1fr); column-gap: 32px; row-gap: 26px; }
body.wide .topbar { grid-column: 1 / -1; }
body.wide .stage { grid-column: 1; grid-row: 2 / 6; }
body.wide .meter { grid-column: 2; grid-row: 3; }
body.wide .toolbar { grid-column: 2; grid-row: 4; }

/* ---------- TOY TRAY ---------- */
.board {
  --cs: 56px; --pad: calc(var(--cs) * .2);
  position: relative; padding: var(--pad); border-radius: calc(var(--cs) * .45);
  background: linear-gradient(180deg, var(--rim-hi), var(--rim));
  box-shadow: 0 calc(var(--cs) * .16) 0 var(--rim-dark), 0 calc(var(--cs) * .4) calc(var(--cs) * .6) rgba(0, 0, 0, .3), inset 0 3px 0 rgba(255, 255, 255, .5);
}
.board::before { content: ""; position: absolute; left: 8%; right: 8%; top: calc(var(--pad) * .28); height: calc(var(--pad) * .3); border-radius: 99px; background: rgba(255, 255, 255, .45); }
.felt {
  position: relative; display: grid; border-radius: calc(var(--cs) * .28); overflow: hidden;
  grid-template-columns: repeat(var(--w), var(--cs)); grid-template-rows: repeat(var(--h), var(--cs));
  background: radial-gradient(circle at 50% 35%, var(--felt), var(--felt-dark)); box-shadow: inset 0 6px 14px rgba(0, 0, 0, .4);
}
.felt::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .14;
  background-image: linear-gradient(rgba(255, 255, 255, .5) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .5) 1px, transparent 1px); background-size: var(--cs) var(--cs); }
.cell { position: relative; }
.cell.wall::before { content: ""; position: absolute; inset: 5%; border-radius: 24%; z-index: 1;
  background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, .9) 0 8%, transparent 9%), linear-gradient(180deg, #fff, var(--wall));
  box-shadow: 0 calc(var(--cs) * .09) 0 var(--wall-edge), 0 calc(var(--cs) * .12) calc(var(--cs) * .1) rgba(0, 0, 0, .25); }
.cell.moss::before { content: ""; position: absolute; inset: 7%; border-radius: 42%;
  background: radial-gradient(circle at 28% 30%, #b8f28a 0 9%, transparent 10%), radial-gradient(circle at 70% 58%, #9be36b 0 12%, transparent 13%),
    radial-gradient(circle at 42% 76%, #a6ea78 0 9%, transparent 10%), radial-gradient(circle, #6cc248, #3e8f2a);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .18), 0 0 0 2px rgba(255, 255, 255, .15); }
.cup { position: absolute; inset: 9%; border-radius: 50%; z-index: 1;
  background: radial-gradient(circle at 50% 62%, #0c0612 0 46%, #2a1a33 62%);
  box-shadow: 0 0 0 calc(var(--cs) * .075) var(--c), 0 0 0 calc(var(--cs) * .11) rgba(255, 255, 255, .55), inset 0 7px 9px rgba(0, 0, 0, .7); }
.cup .glyph { position: absolute; inset: 0 0 20% 0; display: grid; place-items: center; color: var(--c); }
.cup .glyph svg { width: 40%; height: 40%; }
.cup .pips { position: absolute; left: 50%; bottom: 16%; transform: translateX(-50%); display: flex; gap: calc(var(--cs) * .05); }
.cup .pips i { width: calc(var(--cs) * .12); height: calc(var(--cs) * .12); border-radius: 50%; background: rgba(255, 255, 255, .3); transition: background .2s, transform .2s; }
.cup .pips i.on { background: var(--c); transform: scale(1.3); box-shadow: 0 0 6px var(--c); }
.cup.gulp { animation: gulp .3s; }
@keyframes gulp { 40% { transform: scale(1.2); } }
.cup.popped { animation: cupPop .45s forwards; }
@keyframes cupPop { 30% { transform: scale(1.4); } to { transform: scale(0); opacity: 0; } }
.marbles { position: absolute; left: var(--pad); top: var(--pad); width: 0; height: 0; z-index: 3; }
.marble { position: absolute; left: 0; top: 0; width: var(--cs); height: var(--cs); padding: 8%; will-change: transform; }
.marble .ball { position: relative; width: 100%; height: 100%; border-radius: 50%;
  background: radial-gradient(circle at 32% 26%, rgba(255, 255, 255, .95) 0 8%, rgba(255, 255, 255, 0) 22%), radial-gradient(circle at 40% 36%, var(--hi), var(--c) 55%, var(--lo));
  box-shadow: inset -4px -6px 8px rgba(0, 0, 0, .25), 0 calc(var(--cs) * .08) 0 rgba(0, 0, 0, .28); transition: transform .12s; }
.marble .glyph { position: absolute; right: 11%; bottom: 9%; width: 30%; height: 30%; color: rgba(255, 255, 255, .9); }
.marble .eyes { position: absolute; left: 22%; top: 30%; width: 56%; height: 30%; display: flex; justify-content: space-between; }
.marble .eyes i { position: relative; width: 40%; height: 100%; border-radius: 50%; background: #fff; animation: blink 4.5s infinite; animation-delay: var(--blink, 0s); }
.marble .eyes i::after { content: ""; position: absolute; width: 52%; height: 56%; border-radius: 50%; background: #241329;
  left: calc(24% + var(--lx, 0) * 22%); top: calc(22% + var(--ly, 0) * 22%); transition: left .15s, top .15s; }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
.marble.squash .ball { transform: scale(1.14, .86); }

/* toast over the board */
.toast { position: absolute; left: 50%; top: 2%; z-index: 6; max-width: 92%; padding: 10px 18px; border-radius: 18px; background: #fff; text-align: center;
  font-size: 18px; line-height: 1.2; box-shadow: 0 5px 0 var(--card-edge), 0 10px 20px rgba(0, 0, 0, .2); pointer-events: none;
  transform: translate(-50%, -20px) scale(.9); opacity: 0; transition: transform .35s cubic-bezier(.2, 1.6, .4, 1), opacity .25s; }
.toast.on { transform: translate(-50%, 0) scale(1); opacity: 1; }
.toast b { color: var(--accent); font-weight: 400; }

/* swipe hint */
.swipe-hint { position: absolute; inset: 0; display: none; place-items: center; pointer-events: none; z-index: 5; }
.swipe-hint.on { display: grid; }
.swipe-hint .arrow { width: 96px; height: 96px; border-radius: 50%; background: rgba(255, 255, 255, .95); box-shadow: 0 6px 0 var(--card-edge), 0 10px 20px rgba(0, 0, 0, .25);
  display: grid; place-items: center; animation: nudge 1s ease-in-out infinite; }
.swipe-hint .arrow svg { width: 58px; height: 58px; color: var(--accent); transform: rotate(var(--rot, 0deg)); }
.swipe-hint .hand { position: absolute; width: 64px; height: 64px; animation: handSwipe 1.3s ease-in-out infinite; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .3)); }
.swipe-hint.no-hand .hand { display: none; }
@keyframes nudge { 50% { transform: translate(calc(var(--dx, 0) * 14px), calc(var(--dy, 0) * 14px)); } }
@keyframes handSwipe { 0% { transform: translate(calc(var(--dx, 0) * -60px + 30px), calc(var(--dy, 0) * -60px + 50px)); opacity: 0; }
  20%, 80% { opacity: 1; } 100% { transform: translate(calc(var(--dx, 0) * 70px + 30px), calc(var(--dy, 0) * 70px + 50px)); opacity: 0; } }

/* ---------- RESULT (sunburst card) ---------- */
.result { position: fixed; inset: 0; z-index: 25; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(20, 5, 30, .55); }
.result.on { display: flex; animation: fade .3s; }
@keyframes fade { from { opacity: 0; } }
.rays { position: absolute; left: 50%; top: 50%; width: 180vmax; height: 180vmax; margin: -90vmax 0 0 -90vmax; pointer-events: none;
  background: repeating-conic-gradient(rgba(255, 255, 255, .13) 0 9deg, transparent 9deg 18deg); animation: spin 30s linear infinite;
  -webkit-mask: radial-gradient(circle, #000 0 20%, transparent 55%); mask: radial-gradient(circle, #000 0 20%, transparent 55%); }
.result.fail .rays { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.card { position: relative; width: min(400px, 100%); padding: 46px 22px 22px; border-radius: 32px; background: var(--card); text-align: center;
  box-shadow: 0 8px 0 var(--card-edge), 0 30px 60px rgba(0, 0, 0, .35); animation: cardIn .55s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes cardIn { from { transform: scale(.6) translateY(40px); opacity: 0; } }
.ribbon { position: absolute; left: 50%; top: -22px; transform: translateX(-50%); white-space: nowrap; padding: 12px 34px; font-size: 26px; color: #fff;
  background: linear-gradient(180deg, var(--rim-hi), var(--accent)); border-radius: 10px; text-shadow: 0 2px 0 rgba(0, 0, 0, .25); box-shadow: 0 5px 0 var(--accent-dark); }
.ribbon::before, .ribbon::after { content: ""; position: absolute; top: 12px; width: 26px; height: 100%; background: var(--accent-dark); z-index: -1; }
.ribbon::before { left: -18px; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 40% 50%); }
.ribbon::after { right: -18px; clip-path: polygon(0 0, 100% 0, 60% 50%, 100% 100%, 0 100%); }
.result.fail .ribbon { background: linear-gradient(180deg, #8fb4ff, #4d7bff); box-shadow: 0 5px 0 #2c51c4; }
.result.fail .ribbon::before, .result.fail .ribbon::after { background: #2c51c4; }
.big-stars { display: flex; justify-content: center; align-items: flex-end; gap: 6px; margin: 4px 0 8px; }
.big-stars .s { width: 64px; height: 64px; transform: scale(0); }
.big-stars .s:nth-child(2) { width: 84px; height: 84px; }
.big-stars .s svg { width: 100%; height: 100%; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .18)); }
.big-stars .s.in { animation: slam .5s cubic-bezier(.2, 1.8, .4, 1) forwards; }
@keyframes slam { from { transform: scale(2.4) rotate(-30deg); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.face { display: none; width: 92px; height: 92px; margin: 2px auto 6px; border-radius: 50%;
  background: radial-gradient(circle at 32% 26%, rgba(255, 255, 255, .9) 0 8%, transparent 22%), radial-gradient(circle at 40% 36%, #9cc4ff, #3d8bff 55%, #1650b8);
  box-shadow: inset -5px -8px 10px rgba(0, 0, 0, .25); position: relative; animation: wobble 2s ease-in-out infinite; }
.face::before, .face::after { content: ""; position: absolute; top: 34px; width: 18px; height: 14px; border-radius: 50% 50% 40% 40%; background: #fff;
  box-shadow: inset 4px 4px 0 2px #241329; }
.face::before { left: 22px; } .face::after { right: 22px; }
.result.fail .face { display: block; }
.result.fail .big-stars, .result.fail .tokens { display: none; }
@keyframes wobble { 50% { transform: rotate(-8deg) translateY(-3px); } }
.result-text { margin: 4px 0 14px; font-family: system-ui, sans-serif; font-weight: 700; font-size: 17px; color: var(--ink-soft); }
.result-text b { color: var(--accent); }
.tokens { display: flex; justify-content: center; gap: 10px; margin-bottom: 18px; }
.tokens > div { flex: 1; max-width: 110px; padding: 8px 6px; border-radius: 16px; background: #fff; box-shadow: 0 4px 0 var(--card-edge); display: flex; flex-direction: column; }
.tokens b { font-size: 28px; font-weight: 400; }
.tokens small { font-family: system-ui, sans-serif; font-weight: 700; font-size: 12px; color: var(--ink-soft); }
.card-actions, .panel-actions { display: flex; gap: 14px; justify-content: center; align-items: center; }
.card-actions .pill-btn { flex: 1; }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 30; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(20, 5, 30, .5); }
.modal.on { display: flex; animation: fade .25s; }
.panel { width: min(440px, 100%); max-height: 100%; display: flex; flex-direction: column; gap: 14px; padding: 16px 18px 20px; overflow: auto;
  border-radius: 30px; background: var(--card); border-top: 10px solid var(--accent); box-shadow: 0 8px 0 var(--card-edge), 0 24px 50px rgba(0, 0, 0, .3); animation: cardIn .45s cubic-bezier(.2, 1.5, .4, 1); }
.panel-head { display: flex; align-items: center; gap: 10px; font-size: 26px; }
.panel-head b { flex: 1; font-weight: 400; }
.settings { display: flex; flex-direction: column; gap: 8px; }
.toggle { display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 0 14px; border-radius: 16px; background: #fff; box-shadow: 0 3px 0 var(--card-edge); font-size: 20px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; }
.toggle i { position: relative; width: 56px; height: 32px; border-radius: 16px; background: #d9c9d4; transition: background .2s; }
.toggle i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 0 rgba(0, 0, 0, .15); transition: transform .25s cubic-bezier(.3, 1.6, .5, 1); }
.toggle input:checked + i { background: #2bb673; }
.toggle input:checked + i::after { transform: translateX(24px); }
.toggle input:focus-visible + i { outline: 3px solid var(--accent); outline-offset: 2px; }
.how { font-family: system-ui, sans-serif; font-size: 15px; }
.how > b { font-family: "Lilita", system-ui; font-weight: 400; font-size: 20px; }
.how ol { margin: 6px 0; padding-left: 22px; line-height: 1.5; }
.how .keys { color: var(--ink-soft); }

/* level map: a winding path of marbles */
.map-panel { width: min(480px, 100%); height: min(720px, 100%); }
.map-scroll { position: relative; overflow: auto; padding: 4px 0 20px; }
.map-path { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.map-path path { fill: none; stroke: var(--card-edge); stroke-width: 10; stroke-linecap: round; stroke-dasharray: 2 18; }
.chapter-banner { position: relative; margin: 18px auto 10px; width: fit-content; padding: 8px 26px; border-radius: 12px; color: #fff; font-size: 20px;
  background: var(--cc); box-shadow: 0 5px 0 rgba(0, 0, 0, .2); text-shadow: 0 2px 0 rgba(0, 0, 0, .2); z-index: 1; }
.chapter-banner small { margin-left: 8px; font-size: 14px; opacity: .9; }
.map-node { position: relative; z-index: 1; display: block; width: 70px; height: 70px; margin: 6px auto; border-radius: 50%; border: 4px solid #fff; cursor: pointer;
  transform: translateX(var(--x)); color: #fff; font-size: 26px; text-shadow: 0 2px 0 rgba(0, 0, 0, .3);
  background: radial-gradient(circle at 32% 26%, rgba(255, 255, 255, .85) 0 8%, transparent 22%), radial-gradient(circle at 40% 36%, var(--hi), var(--cc) 60%, var(--lo));
  box-shadow: 0 5px 0 rgba(0, 0, 0, .2); }
.map-node .st { position: absolute; left: 50%; bottom: -14px; transform: translateX(-50%); display: flex; }
.map-node .st svg { width: 18px; height: 18px; }
.map-node.cur { animation: nodePulse 1.4s ease-in-out infinite; box-shadow: 0 0 0 6px rgba(255, 255, 255, .7), 0 5px 0 rgba(0, 0, 0, .2); }
@keyframes nodePulse { 50% { transform: translateX(var(--x)) scale(1.1); } }
.map-node:disabled { cursor: default; background: #d8cdd5; color: #9d8f99; text-shadow: none; }
.map-node:disabled .ico { width: 26px; height: 26px; color: #8d7f89; }
.end-panel { text-align: center; align-items: center; }
.end-panel p { font-family: system-ui, sans-serif; font-weight: 600; }
.end-art { width: 110px; height: 110px; }
.end-title { font-size: 28px; font-weight: 400; }

/* ---------- effects ---------- */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.confetti { position: absolute; width: 10px; height: 14px; border-radius: 3px; }
.ring { position: absolute; border-radius: 50%; border: 5px solid var(--c); transform: translate(-50%, -50%); animation: ring .55s ease-out forwards; }
@keyframes ring { from { width: 10px; height: 10px; opacity: 1; } to { width: 140px; height: 140px; opacity: 0; } }
.floater { position: absolute; transform: translate(-50%, -50%); font-size: 30px; color: #fff; -webkit-text-stroke: 6px var(--c, #ff4d8d); paint-order: stroke fill; animation: floatUp .9s ease-out forwards; }
@keyframes floatUp { 20% { transform: translate(-50%, -70%) scale(1.25); } to { transform: translate(-50%, -190%); opacity: 0; } }

@media (max-height: 600px) {
  #game { row-gap: 8px; }
  .meter-count { width: 52px; height: 52px; } .meter-count b { font-size: 24px; }
  .orb { width: 56px; height: 56px; } .orb .ico { width: 26px; height: 26px; }
  .toolbar { padding-bottom: 22px; }
  .play-orb { width: 92px; height: 92px; } .play-orb .ico { width: 40px; height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- polish pass ---------- */
.board.enter { animation: trayIn .55s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes trayIn { from { transform: translateY(-46px) scale(.9); opacity: 0; } }
.board.shake { animation: boardShake .38s; }
@keyframes boardShake { 20% { transform: translate(-6px, 3px) rotate(-.8deg); } 45% { transform: translate(5px, -2px) rotate(.6deg); } 70% { transform: translate(-3px, 1px); } }
.meter-count.tick { animation: countTick .35s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes countTick { 35% { transform: scale(1.18); } }
kbd { display: inline-grid; place-items: center; min-width: 32px; height: 30px; margin: 0 2px; padding: 0 7px; border-radius: 8px; vertical-align: middle;
  font-family: inherit; font-size: 20px; line-height: 1; color: var(--ink); background: linear-gradient(#fff, #f1e6ee); box-shadow: 0 3px 0 var(--card-edge), 0 0 0 2px var(--card-edge); }

/* ---------- Tumble 3D: the board is a WebGL canvas ---------- */
.board.board3d { padding: 0; background: none; box-shadow: none; border-radius: 0; }
.board.board3d::before { display: none; }
.board3d canvas { display: block; touch-action: none; }
#tilt, #demoTilt { transform: none !important; }
.stage .tilt, .stage #board { width: 100%; height: 100%; }
.stage { place-items: stretch; }
.no3d { margin: auto; max-width: 320px; padding: 18px; border-radius: 18px; background: #fff; text-align: center; font-family: system-ui, sans-serif; font-weight: 700; }
.logo { position: relative; }
.logo-3d { position: absolute; right: -.42em; top: -.32em; font-size: .38em; font-weight: 400; padding: .12em .32em; border-radius: .4em; color: #fff;
  background: linear-gradient(180deg, #8f6bff, #5b3df5); -webkit-text-stroke: 0; box-shadow: 0 .08em 0 #3a22b8, 0 .14em .3em rgba(0,0,0,.25);
  transform: rotate(12deg); animation: badgeIn .6s .6s cubic-bezier(.2, 1.8, .4, 1) both; }
@keyframes badgeIn { from { transform: rotate(12deg) scale(0); } }
