:root {
  --ink: #17345a;
  --navy: #14224d;
  --teal: #1bb5b8;
  --lav: #bd85d5;
  --pink: #f46acc;
  --gold: #ffcf46;
  --snow: #f7fbff;
  --tile: min(11.2vw, 20vh);
  --display: "Lilita One", "Fredoka", system-ui, sans-serif;
  --body: "Fredoka", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--body);
  color: var(--ink);
  overflow: hidden;
  background: #1a2556;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; cursor: pointer; }

/* ---------- Sky ---------- */
.sky {
  position: fixed; inset: 0; overflow: hidden;
  background: linear-gradient(180deg, #141f4f 0%, #27397e 34%, #4f63b4 62%, #8f8fd6 82%, #c7b6ea 100%);
}
.aurora {
  position: absolute; border-radius: 50%; filter: blur(60px); opacity: .45; mix-blend-mode: screen;
  animation: drift 18s ease-in-out infinite alternate;
}
.a1 { width: 60vw; height: 30vh; left: -10vw; top: 6vh; background: radial-gradient(closest-side, #3ff2d2, transparent); }
.a2 { width: 55vw; height: 28vh; right: -8vw; top: 12vh; background: radial-gradient(closest-side, #c38bff, transparent); animation-duration: 23s; }
.a3 { width: 45vw; height: 24vh; left: 30vw; top: 0; background: radial-gradient(closest-side, #ff8fd8, transparent); opacity: .3; animation-duration: 27s; }
@keyframes drift {
  from { transform: translate(0, 0) rotate(-4deg) scale(1); }
  to { transform: translate(6vw, 3vh) rotate(5deg) scale(1.15); }
}
.stars i {
  position: absolute; width: 3px; height: 3px; background: #fff; border-radius: 50%;
  box-shadow: 0 0 6px 1px rgba(255,255,255,.8);
  animation: twinkle var(--d, 3s) ease-in-out infinite; animation-delay: var(--delay, 0s);
}
@keyframes twinkle { 0%,100% { opacity: .2; transform: scale(.7); } 50% { opacity: 1; transform: scale(1.2); } }
.moon {
  position: absolute; right: 7vw; top: 12vh; width: 9vh; height: 9vh; border-radius: 50%;
  box-shadow: inset -2.2vh 1.2vh 0 0 #fff4c7; transform: rotate(-20deg);
  filter: drop-shadow(0 0 18px rgba(255, 240, 180, .7));
}
#snow, #fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#fx { z-index: 60; }

/* ---------- Lights + lantern ---------- */
.lights { position: fixed; top: 0; left: 0; width: 100%; height: 90px; z-index: 5; overflow: visible; pointer-events: none; }
.bulb { animation: glow 1.6s ease-in-out infinite; animation-delay: var(--delay); transform-box: fill-box; transform-origin: 50% 0; }
@keyframes glow {
  0%, 100% { opacity: 1; filter: drop-shadow(0 0 6px var(--c)) drop-shadow(0 0 14px var(--c)); }
  50% { opacity: .45; filter: none; }
}
.lantern {
  position: fixed; left: 2.2vw; top: 54px; height: 16vh; z-index: 6; transform-origin: 44% 0;
  filter: drop-shadow(0 0 22px rgba(255, 220, 120, .55));
}
.swing { animation: swing 4s ease-in-out infinite; }
@keyframes swing { 0%,100% { transform: rotate(5deg); } 50% { transform: rotate(-5deg); } }

/* ---------- Header ---------- */
.top { position: relative; z-index: 10; text-align: center; padding-top: max(56px, 7vh); }
.title {
  margin: 0; font-family: var(--display); font-weight: 400; letter-spacing: .02em;
  font-size: clamp(2.2rem, 7.4vh, 5.6rem); line-height: 1; color: #fff;
}
.title span {
  display: inline-block; animation: bob 2.4s ease-in-out infinite; animation-delay: calc(var(--i) * .08s);
  text-shadow: 0 4px 0 rgba(20, 30, 80, .45), 0 0 26px rgba(255,255,255,.35);
}
.title .sp { width: .35em; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-.12em) rotate(-3deg); } }
.subtitle {
  margin: .5vh 0 0; color: #e8f1ff; font-weight: 600; font-size: clamp(1rem, 2.6vh, 1.6rem);
  text-shadow: 0 2px 6px rgba(10, 20, 60, .5);
}
.subtitle b { color: var(--gold); font-family: var(--display); font-weight: 400; font-size: 1.25em; }
.progress { width: min(560px, 80vw); margin: 1.4vh auto 0; }
.track {
  position: relative; height: 14px; border-radius: 99px; background: rgba(255,255,255,.22);
  box-shadow: inset 0 2px 4px rgba(0,0,0,.25);
}
.fill {
  height: 100%; width: 0; border-radius: 99px;
  background: repeating-linear-gradient(-45deg, #8ff3e6 0 10px, #c9fff6 10px 20px);
  box-shadow: 0 0 12px #8ff3e6; transition: width 1.2s cubic-bezier(.3,1.4,.5,1);
  background-size: 28px 28px; animation: stripes 1s linear infinite;
}
@keyframes stripes { to { background-position: 28px 0; } }
.rider {
  position: absolute; top: 50%; left: 0; height: 40px; transform: translate(-50%, -62%);
  transition: left 1.2s cubic-bezier(.3,1.4,.5,1); animation: hop 1.2s ease-in-out infinite;
}
@keyframes hop { 0%,100% { margin-top: 0; } 50% { margin-top: -5px; } }
.progress-label { margin-top: 8px; color: #dbe7ff; font-weight: 600; font-size: clamp(.8rem, 1.8vh, 1.05rem); }

/* ---------- Board ---------- */
.board {
  position: relative; z-index: 12;
  display: flex; flex-wrap: wrap; gap: calc(var(--tile) * .14); justify-content: center; /* a short last row stays centred */
  max-width: calc(var(--cols, 7) * var(--tile) * 1.14 - var(--tile) * .14 + 4vw); margin: 3vh auto 0; padding: 0 2vw;
}
.note {
  --rot: 0deg;
  position: relative; width: var(--tile); aspect-ratio: 1; border: 0; border-radius: 6px 6px 18px 6px;
  background: var(--bg); color: var(--fg);
  box-shadow: 0 10px 18px rgba(10, 20, 70, .35), inset 0 -10px 18px rgba(0,0,0,.06);
  transform: rotate(var(--rot)); transition: transform .25s cubic-bezier(.3,1.6,.5,1), box-shadow .25s;
  animation: dropIn .8s cubic-bezier(.3,1.5,.5,1) both; animation-delay: var(--delay);
  display: grid; place-items: center; padding: 0; overflow: visible;
}
.note::after { /* folded corner */
  content: ""; position: absolute; right: 0; bottom: 0; width: 22%; height: 22%;
  background: linear-gradient(135deg, var(--bg) 50%, rgba(0,0,0,.14) 50%, rgba(255,255,255,.5));
  border-radius: 0 0 18px 0;
}
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-60vh) rotate(calc(var(--rot) * -6)); }
  to { opacity: 1; transform: rotate(var(--rot)); }
}
.note:hover, .note:focus-visible {
  transform: rotate(calc(var(--rot) * -1)) scale(1.1) translateY(-6px);
  box-shadow: 0 18px 30px rgba(10, 20, 70, .45); z-index: 3; outline: none;
}
.note:hover .num { animation: jelly .6s; }
@keyframes jelly { 0%,100% { transform: scale(1); } 30% { transform: scale(1.25, .8); } 60% { transform: scale(.9, 1.15); } }
.note .tape {
  position: absolute; top: -10%; left: 50%; width: 46%; height: 18%; transform: translateX(-50%) rotate(-4deg);
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.75) 0 6px, rgba(255,255,255,.45) 6px 12px);
  box-shadow: 0 2px 4px rgba(0,0,0,.12); border-radius: 2px;
}
.note .num {
  font-family: var(--display); font-size: calc(var(--tile) * .5); line-height: 1; margin-top: -8%;
  text-shadow: 0 3px 0 rgba(255,255,255,.6);
}
.note .lbl {
  position: absolute; bottom: 11%; left: 0; right: 0; text-align: center;
  font-weight: 700; font-size: calc(var(--tile) * .085); text-transform: uppercase; letter-spacing: .06em; opacity: .75;
}
.note .doodle { position: absolute; width: 24%; height: 24%; top: 8%; left: 8%; opacity: .35; }
.note .doodle.r { left: auto; right: 8%; top: auto; bottom: 26%; width: 17%; height: 17%; transform: rotate(18deg); }

/* Next tile to open */
.note.next { animation: dropIn .8s cubic-bezier(.3,1.5,.5,1) both, pulse 1.6s ease-in-out 1s infinite; animation-delay: var(--delay), calc(var(--delay) + .8s); }
@keyframes pulse {
  0%,100% { box-shadow: 0 10px 18px rgba(10,20,70,.35), 0 0 0 0 rgba(255, 240, 150, .9); }
  50% { box-shadow: 0 10px 18px rgba(10,20,70,.35), 0 0 0 12px rgba(255, 240, 150, 0), 0 0 40px 10px rgba(255, 240, 150, .55); }
}
.note .openme {
  display: none; position: absolute; top: -34%; left: 50%; transform: translateX(-50%);
  background: #fff; color: var(--pink); font-family: var(--display); font-size: calc(var(--tile) * .12);
  padding: 4px 12px; border-radius: 99px; white-space: nowrap; box-shadow: 0 4px 10px rgba(0,0,0,.25);
  animation: bounceY .9s ease-in-out infinite;
}
.note .openme::after { content: ""; position: absolute; bottom: -7px; left: 50%; margin-left: -7px; border: 7px solid transparent; border-bottom: 0; border-top-color: #fff; }
.note.next .openme { display: block; }
@keyframes bounceY { 0%,100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -8px); } }

/* Opened tile */
.note .face {
  position: absolute; inset: 0; border-radius: inherit; display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 4%; padding: 10%; text-align: center;
  background: radial-gradient(circle at 30% 20%, #fff 0, #eef6ff 60%, #dbe8fb 100%);
}
.note .face .e { font-size: calc(var(--tile) * .34); line-height: 1; filter: drop-shadow(0 3px 2px rgba(0,0,0,.15)); }
.note .face .t { font-weight: 700; font-size: calc(var(--tile) * .095); line-height: 1.1; color: var(--ink); }
.note .face .dn { position: absolute; top: 6%; left: 8%; font-family: var(--display); font-size: calc(var(--tile) * .12); color: #9bb0d6; }
.note .stamp {
  display: none; position: absolute; right: -8%; top: 4%; transform: rotate(16deg);
  font-family: var(--display); color: #e5487f; border: 3px solid #e5487f; border-radius: 8px;
  padding: 1px 7px; font-size: calc(var(--tile) * .095); background: rgba(255,255,255,.85); letter-spacing: .05em;
}
.note.opened .face, .note.opened .stamp { display: flex; }
.note.opened .num, .note.opened .lbl, .note.opened .doodle { visibility: hidden; }
.note.just-opened .stamp { animation: stampIn .6s cubic-bezier(.2,1.8,.4,1) both .5s; }
.note.just-opened { animation: flipIn .8s cubic-bezier(.3,1.4,.5,1) both; }
@keyframes stampIn { from { opacity: 0; transform: rotate(16deg) scale(3); } to { opacity: 1; transform: rotate(16deg) scale(1); } }
@keyframes flipIn { from { transform: rotateY(90deg) rotate(var(--rot)); } to { transform: rotateY(0) rotate(var(--rot)); } }

/* ---------- Ground ---------- */
.ground { position: fixed; left: 0; right: 0; bottom: 0; height: 26vh; z-index: 8; pointer-events: none; }
.hills { position: absolute; inset: auto 0 0 0; width: 100%; height: 100%; }
.deco { position: absolute; filter: drop-shadow(0 6px 6px rgba(30, 50, 110, .25)); }
.tree { left: 4vw; bottom: 3vh; height: 23vh; }
.menorah { left: 15vw; bottom: 3vh; height: 11vh; }
.snowman { right: 35vw; bottom: 2.5vh; height: 18vh; animation: wobble 3s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes wobble { 0%,100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }

/* ---------- Pip ---------- */
.pip {
  position: fixed; right: 2vw; bottom: 1vh; z-index: 20; border: 0; background: none; padding: 0;
  width: 13vh; height: 16vh;
}
.pip img { width: 100%; height: 100%; object-fit: contain; animation: pipBob 2.2s ease-in-out infinite; transform-origin: 50% 100%; filter: drop-shadow(0 6px 8px rgba(20, 40, 100, .35)); }
.pip:hover img { animation: pipHop .5s ease-in-out infinite; }
@keyframes pipBob { 0%,100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg) translateY(-4px); } }
@keyframes pipHop { 0%,100% { transform: translateY(0) scale(1, 1); } 40% { transform: translateY(-14px) scale(.95, 1.05); } }
.bubble {
  position: absolute; right: 96%; bottom: 48%; width: max-content; max-width: min(320px, 46vw);
  background: #fff; color: var(--ink); border-radius: 18px; padding: 10px 14px;
  font-weight: 600; font-size: clamp(.85rem, 2vh, 1.15rem); line-height: 1.25; text-align: left;
  box-shadow: 0 8px 20px rgba(10, 20, 60, .3);
  transform-origin: 100% 100%; transition: transform .35s cubic-bezier(.3,1.6,.5,1), opacity .2s;
}
.bubble::after { content: ""; position: absolute; right: 8px; bottom: -10px; border: 12px solid transparent; border-left: 0; border-top-color: #fff; transform: skewX(-20deg); }
.bubble.hide { transform: scale(0); opacity: 0; }

/* ---------- Toolbar ---------- */
.toolbar { position: fixed; right: 12px; top: 10px; z-index: 30; display: flex; gap: 6px; opacity: .45; transition: opacity .2s; }
.toolbar:hover, .toolbar:focus-within { opacity: 1; }
.toolbar button {
  width: 38px; height: 38px; border-radius: 12px; border: 0; background: rgba(255,255,255,.18);
  color: #fff; font-size: 18px; backdrop-filter: blur(6px);
}
.toolbar button:hover { background: rgba(255,255,255,.35); }

/* ---------- Stage (reveal) ---------- */
.stage { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; }
.stage[hidden] { display: none; }
.stage-bg {
  position: absolute; inset: 0; overflow: hidden;
  background: radial-gradient(circle at 50% 50%, rgba(80, 70, 170, .82), rgba(12, 16, 50, .96) 70%);
  animation: fadeIn .35s ease both;
}
.rays {
  position: absolute; left: 50%; top: 50%; width: 220vmax; height: 220vmax; margin: -110vmax 0 0 -110vmax;
  background: repeating-conic-gradient(rgba(255,255,255,.07) 0 8deg, transparent 8deg 20deg);
  animation: spin 40s linear infinite; transition: opacity .6s;
}
.stage.revealed .rays { background: repeating-conic-gradient(rgba(255, 236, 160, .16) 0 8deg, transparent 8deg 20deg); animation-duration: 14s; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } }
.stage-close {
  position: absolute; top: 14px; right: 16px; z-index: 5; width: 46px; height: 46px; border-radius: 50%;
  border: 0; background: rgba(255,255,255,.15); color: #fff; font-size: 22px;
}
.stage-close:hover { background: rgba(255,255,255,.3); }
.stage-inner { position: relative; z-index: 2; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.stage.shake { animation: screenShake .4s; }
@keyframes screenShake {
  0%,100% { transform: translate(0,0); } 20% { transform: translate(-12px, 6px); } 40% { transform: translate(10px, -8px); }
  60% { transform: translate(-8px, -4px); } 80% { transform: translate(6px, 8px); }
}

.day-banner {
  font-family: var(--display); color: #fff; font-size: clamp(3rem, 15vh, 10rem); line-height: 1;
  text-shadow: 0 6px 0 #e5487f, 0 12px 0 rgba(0,0,0,.25);
  animation: slam .7s cubic-bezier(.2,1.8,.4,1) both;
}
.day-banner.small { font-size: clamp(1.6rem, 6vh, 3.4rem); text-shadow: 0 4px 0 #e5487f; animation: none; position: absolute; top: 4vh; }
@keyframes slam { from { transform: scale(4) rotate(-12deg); opacity: 0; } to { transform: scale(1) rotate(-3deg); opacity: 1; } }
.hint {
  margin-top: 2vh; color: #fff; font-weight: 700; font-size: clamp(1.2rem, 4vh, 2.4rem); text-align: center;
  padding: 0 4vw; text-shadow: 0 3px 8px rgba(0,0,0,.4); min-height: 1.3em;
}
.hint.pop { animation: popIn .5s cubic-bezier(.2,1.8,.4,1) both; }
@keyframes popIn { from { transform: scale(.3); opacity: 0; } }
.hint .key { display: inline-block; padding: 0 .4em; border-radius: .3em; background: rgba(255,255,255,.2); font-size: .7em; vertical-align: middle; }
.arena { position: relative; display: grid; place-items: center; margin-top: 3vh; }
.meter { display: flex; gap: 8px; margin-top: 3vh; }
.meter i {
  width: clamp(14px, 2.4vh, 26px); height: clamp(14px, 2.4vh, 26px); border-radius: 50%; background: rgba(255,255,255,.2);
  transition: background .2s, transform .3s cubic-bezier(.2,1.8,.4,1);
}
.meter i.on { background: var(--gold); transform: scale(1.3); box-shadow: 0 0 12px var(--gold); }

.stage-pip { position: absolute; left: 3vw; bottom: 3vh; width: 15vh; z-index: 3; animation: pipBob 1.4s ease-in-out infinite; transform-origin: 50% 100%; }
.stage-pip.cheer { animation: pipHop .45s ease-in-out infinite; }
.stage-bubble {
  position: absolute; left: calc(3vw + 15vh); bottom: 15vh; z-index: 3; background: #fff; color: var(--ink);
  border-radius: 18px 18px 18px 4px; padding: 10px 16px; font-weight: 700; font-size: clamp(1rem, 2.6vh, 1.5rem);
  max-width: 34vw; box-shadow: 0 8px 20px rgba(0,0,0,.3);
}
.stage-bubble.pop { animation: popIn .4s cubic-bezier(.2,1.8,.4,1) both; }

/* Gift challenge */
.gift {
  position: relative; width: min(46vh, 70vw); aspect-ratio: 1312 / 1199; border: 0; background: none; padding: 0;
  --s: 0; filter: drop-shadow(0 0 calc(var(--s) * 50px) rgba(255, 240, 160, calc(.3 + var(--s) * .7)));
  animation: giftIdle calc(1.6s - var(--s) * 1.4s) ease-in-out infinite;
}
.gift img { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.gift .lid { clip-path: inset(0 0 47% 0); }
.gift .box { clip-path: inset(53% 0 0 0); }
.gift .glow { position: absolute; inset: 10%; border-radius: 50%; background: radial-gradient(closest-side, rgba(255,250,200,.9), transparent); opacity: var(--s); mix-blend-mode: screen; pointer-events: none; }
@keyframes giftIdle {
  0%,100% { transform: rotate(calc(var(--s) * -6deg)) scale(1); }
  25% { transform: rotate(calc(var(--s) * 7deg)) scale(calc(1 + var(--s) * .05)); }
  75% { transform: rotate(calc(var(--s) * -7deg)) scale(calc(1 + var(--s) * .05)); }
}
.gift.open { animation: none; }
.gift.tap { animation: squash .25s ease-out; }
@keyframes squash { 0% { transform: scale(1); } 35% { transform: scale(1.15, .82); } 70% { transform: scale(.92, 1.1); } 100% { transform: scale(1); } }
.gift.open .lid { animation: lidFly 1s cubic-bezier(.2,.8,.3,1) forwards; }
.gift.open .box { animation: boxDrop 1s ease forwards; }
@keyframes lidFly { to { transform: translate(28vw, -80vh) rotate(160deg); } }
@keyframes boxDrop { 40% { transform: scale(1.1, .9); } to { transform: translateY(70vh) scale(.6); opacity: 0; } }
.count-pop {
  position: absolute; font-family: var(--display); color: var(--gold); font-size: clamp(3rem, 12vh, 8rem); pointer-events: none;
  text-shadow: 0 5px 0 #c2408a, 0 0 30px rgba(255,220,120,.8); animation: countPop .8s ease-out forwards; z-index: 4;
}
@keyframes countPop { 0% { transform: scale(.3) rotate(var(--r)); opacity: 0; } 25% { transform: scale(1.2) rotate(var(--r)); opacity: 1; } 100% { transform: translateY(-14vh) scale(.9) rotate(var(--r)); opacity: 0; } }

/* Ice challenge */
.ice {
  position: relative; width: min(52vh, 78vw); aspect-ratio: 6 / 5; border-radius: 28px; overflow: hidden; border: 0; padding: 0;
  background:
    linear-gradient(115deg, transparent 20%, rgba(255,255,255,.55) 22%, transparent 30%, transparent 58%, rgba(255,255,255,.35) 60%, transparent 64%),
    radial-gradient(circle at 30% 25%, rgba(255,255,255,.85), transparent 45%),
    linear-gradient(160deg, #d9f6ff, #8fd0f2 55%, #5fa8e0);
  box-shadow: inset 0 0 0 6px rgba(255,255,255,.55), inset 0 -20px 40px rgba(30, 80, 160, .35), 0 20px 50px rgba(0, 20, 80, .5), 0 0 60px rgba(140, 220, 255, .45);
}
.ice .frozen {
  position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); color: rgba(255,255,255,.75);
  font-size: min(28vh, 40vw); filter: blur(4px); text-shadow: 0 0 30px rgba(40, 90, 200, .6);
}
.ice .bubbles i { position: absolute; border-radius: 50%; border: 2px solid rgba(255,255,255,.6); }
.ice svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ice svg path { fill: none; stroke-linecap: round; stroke-linejoin: round; animation: draw .25s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.ice.hit { animation: iceHit .25s; }
@keyframes iceHit { 30% { transform: translate(-8px, 4px) rotate(-1.5deg); } 60% { transform: translate(6px, -3px) rotate(1deg); } }
.ice.gone { visibility: hidden; }
.snowball {
  position: fixed; left: 0; top: 0; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%; z-index: 50; pointer-events: none;
  background: radial-gradient(circle at 35% 30%, #fff, #e4eefc 55%, #b4c7e6);
  box-shadow: 0 6px 14px rgba(0,0,0,.3);
}

/* Frost challenge */
.window {
  position: relative; width: min(84vh, 82vw); aspect-ratio: 16 / 10; border-radius: 30px 30px 20px 20px;
  background: #fff; padding: 14px; box-shadow: 0 0 0 10px #c98a5e, 0 0 0 14px #8a5634, 0 30px 60px rgba(0,0,0,.45);
}
.window .scene {
  position: absolute; inset: 14px; border-radius: 18px 18px 10px 10px; overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #fff6dc, #ffd9a8 60%, #f7b3c8);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 4%;
}
.window .scene .e { font-size: min(22vh, 20vw); line-height: 1; }
.window .scene .t { font-family: var(--display); font-size: clamp(1.6rem, 7vh, 4.4rem); color: #c2408a; line-height: 1.05; }
.window canvas { position: absolute; inset: 14px; width: calc(100% - 28px); height: calc(100% - 28px); border-radius: 18px 18px 10px 10px; touch-action: none; cursor: grab; }
.window .sill { position: absolute; left: -24px; right: -24px; bottom: -26px; height: 30px; border-radius: 30px; background: #fff; box-shadow: 0 6px 0 #dbe7f7; }
.window.cleared canvas { transition: opacity .6s; opacity: 0; }

/* Countdown chant */
.chant-num {
  position: absolute; font-family: var(--display); font-size: min(55vh, 60vw); line-height: 1; color: #fff;
  text-shadow: 0 10px 0 var(--c), 0 20px 30px rgba(0,0,0,.35); animation: chant 1s cubic-bezier(.2,1.6,.4,1) forwards;
}
@keyframes chant { 0% { transform: scale(3) rotate(-10deg); opacity: 0; } 30% { transform: scale(1) rotate(3deg); opacity: 1; } 80% { transform: scale(1.05) rotate(-2deg); opacity: 1; } 100% { transform: scale(.4); opacity: 0; } }
.chant-box { position: relative; width: 100vw; height: 60vh; display: grid; place-items: center; }
.sled { position: fixed; left: 0; top: 50%; height: 26vh; z-index: 45; pointer-events: none; }

/* ---------- Reveal card ---------- */
.card {
  position: relative; width: min(820px, 90vw); max-height: 92vh; overflow: auto; border-radius: 32px; padding: 3.2vh 4vw 3vh;
  background: linear-gradient(180deg, #ffffff 0%, #f1f7ff 100%); text-align: center;
  box-shadow: 0 0 0 8px rgba(255,255,255,.35), 0 30px 80px rgba(0,0,0,.5);
  animation: cardIn .9s cubic-bezier(.2,1.5,.4,1) both;
}
@keyframes cardIn { 0% { transform: perspective(900px) rotateY(-100deg) scale(.4); opacity: 0; } 100% { transform: none; opacity: 1; } }
.card .ribbon {
  display: inline-block; margin-top: -.4vh; padding: 6px 26px; border-radius: 99px; background: linear-gradient(90deg, #f46acc, #bd85d5, #1bb5b8);
  color: #fff; font-family: var(--display); font-size: clamp(1rem, 3vh, 1.7rem); letter-spacing: .05em; box-shadow: 0 6px 14px rgba(190, 80, 180, .35);
}
.card .big {
  font-size: clamp(4rem, 19vh, 11rem); line-height: 1.1; margin: 2.6vh 0 0;
  animation: bigBounce 1.6s ease-in-out infinite .9s; display: inline-block; filter: drop-shadow(0 10px 10px rgba(0,0,0,.18));
}
@keyframes bigBounce { 0%,100% { transform: translateY(0) rotate(-4deg) scale(1); } 50% { transform: translateY(-14px) rotate(4deg) scale(1.06); } }
.card h2 {
  margin: .6vh 0 0; font-family: var(--display); font-weight: 400; font-size: clamp(2.2rem, 8.5vh, 5.2rem); line-height: 1.02; color: var(--ink);
}
.card h2 .w { display: inline-block; white-space: nowrap; margin: 0 .14em; }
.card h2 .l { display: inline-block; animation: letter .6s cubic-bezier(.2,1.8,.4,1) both; animation-delay: calc(.6s + var(--i) * .04s); color: var(--c); text-shadow: 0 4px 0 rgba(23, 52, 90, .15); }
@keyframes letter { from { transform: translateY(-60px) scale(.2); opacity: 0; } }
.card p.desc { margin: 1.4vh auto 0; max-width: 640px; font-size: clamp(1.1rem, 3.1vh, 1.8rem); font-weight: 500; line-height: 1.3; color: #33507a; animation: fadeUp .6s ease both 1.3s; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } }
.card .joke { margin: 2.2vh auto 0; max-width: 620px; animation: fadeUp .6s ease both 1.6s; }
.card .joke button, .card .done {
  border: 0; border-radius: 99px; font-weight: 700; font-size: clamp(1rem, 2.4vh, 1.35rem); padding: .6em 1.3em;
  transition: transform .2s cubic-bezier(.3,1.8,.5,1);
}
.card .joke button { background: #e9f3ff; color: #2b5fa8; box-shadow: inset 0 0 0 2px #c7dcf6; }
.card .joke button:hover, .card .done:hover { transform: scale(1.07) rotate(-1deg); }
.card .joke .q { font-size: clamp(1.1rem, 3vh, 1.7rem); font-weight: 700; color: var(--ink); margin: 1vh 0 .4vh; }
.card .joke .a { font-family: var(--display); font-size: clamp(1.3rem, 3.8vh, 2.2rem); color: #e5487f; animation: popIn .5s cubic-bezier(.2,1.8,.4,1) both; }
.card .done { display: block; margin: 2.4vh auto 0; background: linear-gradient(90deg, #1bb5b8, #4f8ff0); color: #fff; box-shadow: 0 8px 18px rgba(30, 120, 200, .35); animation: fadeUp .6s ease both 1.9s; }
.card .finale-msg { font-family: var(--display); font-size: clamp(1.8rem, 6vh, 3.6rem); margin-top: 1.4vh; background: linear-gradient(90deg, #f46acc, #bd85d5, #1bb5b8, #ffb02e); -webkit-background-clip: text; background-clip: text; color: transparent; animation: popIn .8s cubic-bezier(.2,1.8,.4,1) both 2s; }

.flash { position: fixed; inset: 0; z-index: 55; background: #fff; opacity: 0; pointer-events: none; }
.flash.go { animation: flash .7s ease-out; }
@keyframes flash { 0% { opacity: .95; } 100% { opacity: 0; } }

/* ---------- Settings ---------- */
.settings {
  width: min(1100px, 94vw); max-height: 90vh; padding: 0; border: 0; border-radius: 24px; color: var(--ink);
  box-shadow: 0 30px 80px rgba(0,0,0,.45); user-select: text;
}
.settings::backdrop { background: rgba(10, 16, 50, .6); backdrop-filter: blur(4px); }
.settings-inner { padding: 22px 26px; }
.settings-head { display: flex; align-items: center; justify-content: space-between; }
.settings h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 2rem; }
.settings .x { border: 0; background: #eef3fb; width: 40px; height: 40px; border-radius: 50%; font-size: 18px; }
.muted { color: #6a7fa3; margin: 6px 0 14px; }
.settings label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .85rem; color: #4b6390; }
.settings input, .settings textarea, .settings select {
  font: inherit; font-size: .95rem; color: var(--ink); border: 2px solid #dbe5f4; border-radius: 10px; padding: 7px 9px; background: #fff; width: 100%;
}
.settings textarea { resize: vertical; min-height: 58px; }
.settings input:focus, .settings textarea:focus, .settings select:focus { outline: none; border-color: var(--teal); }
.settings-foot { display: flex; gap: 10px; align-items: center; margin-top: 16px; position: sticky; bottom: -22px; background: #fff; padding: 12px 0 4px; flex-wrap: wrap; }
.settings-foot .spacer { flex: 1; }
.settings .primary { border: 0; border-radius: 99px; padding: 10px 26px; font-weight: 700; font-size: 1.05rem; color: #fff; background: linear-gradient(90deg, #1bb5b8, #4f8ff0); }
.settings .ghost { border: 2px solid #dbe5f4; background: #fff; border-radius: 99px; padding: 8px 16px; font-weight: 600; color: #4b6390; }

.missing {
  width: 100%; margin-top: 6vh; padding: 28px 40px; border-radius: 28px; background: rgba(255,255,255,.92); text-align: center;
  font-family: var(--display); font-size: clamp(1.6rem, 5vh, 3rem); color: var(--ink); box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.missing small { font-family: var(--body); font-size: .5em; color: #4b6390; }

/* Teacher Corner */
.settings h3 { margin: 18px 0 0; font-size: 1.05rem; }
.settings .small { font-size: .8rem; margin-top: 10px; }
.studio-link {
  display: block; margin-top: 12px; padding: 14px 18px; border-radius: 16px; text-decoration: none; color: #0f6f72; font-weight: 600;
  background: linear-gradient(90deg, #e2f8f6, #eee6ff); border: 2px solid #c9ece8;
}
.studio-link:hover { border-color: var(--teal); }
.opened-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 6px; }
.opened-row { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-radius: 10px; background: #f5f9ff; color: var(--ink); font-size: .9rem; min-height: 42px; }
.opened-row.is-open { background: #fff4ea; }
.opened-row b { white-space: nowrap; }
.opened-row span { flex: 1; min-width: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opened-row button { flex: none; border: 0; border-radius: 99px; padding: 5px 12px; font-weight: 700; font-size: .8rem; }
.opened-row .reset-one { background: #e5487f; color: #fff; }
.opened-row .reset-one:hover { background: #cc356b; }
.opened-row .mark-one { background: transparent; color: #8a9cbc; }
.opened-row .mark-one:hover { color: var(--ink); background: #e6eefa; }
.settings .ghost.danger { color: #c7376b; border-color: #f6c6d6; }
.settings .ghost:disabled { opacity: .45; cursor: default; }
.card .reset-day { display: block; margin: 1.2vh auto 0; border: 0; background: none; color: #8a9cbc; font-weight: 600; font-size: clamp(.85rem, 1.9vh, 1.05rem); text-decoration: underline; animation: fadeUp .6s ease both 1.9s; }
.card .reset-day:hover { color: #e5487f; }

/* ---------- Small screens ---------- */
@media (max-width: 760px), (max-aspect-ratio: 1/1) {
  body { overflow: auto; }
  .board { --tile: min(26vw, 150px) !important; --cols: 3 !important; padding-bottom: 30vh; row-gap: calc(var(--tile) * .3); margin-top: 5vh; }
  .ground { height: 18vh; }
  .menorah { display: none; }
  .lantern { height: 10vh; }
  .pip { width: 10vh; height: 12vh; }
  .stage-pip, .stage-bubble { display: none; }
  .moon { width: 6vh; height: 6vh; }
}

@media (prefers-reduced-motion: reduce) {
  /* calm the always-on decorations; the reveal games still animate */
  .aurora, .stars i, .title span, .swing, .snowman, .pip img, .rider, .fill, .rays, .bulb { animation: none !important; }
}
