/* Winter Wonder World · EduPlay Palace
   All sizes use container units of the 16:9 stage (cqw / cqh) so the artwork,
   signs, characters and touch targets stay aligned at any screen size. */

:root {
  --font: ui-rounded, "SF Pro Rounded", "Fredoka", "Nunito", "Baloo 2", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --wood-1: #c98a55; --wood-2: #a56a3f; --wood-3: #7d4c2a; --wood-hi: #e6b383;
  --cream: #fbf1df; --ink: #4b3a35; --snow: #ffffff;
  --pink: #e9a5b6; --lav: #c3b4e3; --blue: #8fb4e3; --sage: #aac9a4;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #aab4d6; overscroll-behavior: none; }
body { font-family: var(--font); color: var(--ink); touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button { font-family: inherit; color: inherit; cursor: pointer; }
img { -webkit-user-drag: none; user-select: none; }

#stage-wrap { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #c8d0ee, #8f9cc8); }
#stage {
  position: relative; overflow: hidden; container-type: size; background: #cfd8f0;
  width: min(100vw, calc(100dvh * 16 / 9)); aspect-ratio: 16 / 9;
  box-shadow: 0 0 40px rgba(40, 40, 80, .25);
}

.screen { position: absolute; inset: 0; }
.fade-in { animation: fadeIn .6s ease both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.veil { position: absolute; inset: 0; z-index: 90; background: radial-gradient(circle, #fff 0%, #eef2ff 70%); opacity: 0; pointer-events: none; transition: opacity .32s ease; }
.veil.on { opacity: 1; pointer-events: auto; }

/* ---------- shared wooden pieces ---------- */
.plank {
  position: relative; color: #fff7ea; font-weight: 700; text-align: center;
  background: linear-gradient(180deg, var(--wood-1), var(--wood-2) 60%, #94592f);
  border: .28cqw solid var(--wood-3); border-radius: 1.3cqw;
  box-shadow: inset 0 .22cqw 0 var(--wood-hi), 0 .5cqw 1cqw rgba(60, 35, 20, .35);
  text-shadow: 0 .14cqw 0 rgba(90, 52, 26, .8);
}
.plank::before { /* a little snow on top */
  content: ""; position: absolute; left: 6%; right: 6%; top: -.55cqw; height: .8cqw; border-radius: 1cqw .9cqw .6cqw .6cqw;
  background: linear-gradient(#fff, #e8eefc); box-shadow: 0 .1cqw .2cqw rgba(100, 120, 170, .3);
}
.pill { padding: .9cqw 2.2cqw; font-size: 1.9cqw; min-height: 5.8cqw; border-radius: 3cqw; cursor: pointer; }
.pill.small { font-size: 1.45cqw; min-height: 4.6cqw; padding: .6cqw 1.6cqw; }
.pill:disabled { opacity: .45; cursor: default; }
.pill:not(:disabled):active { transform: translateY(.15cqw); }

.icon-btn { display: grid; justify-items: center; background: none; border: 0; padding: 0; width: 6.2cqw; min-height: 6.2cqw; position: relative; }
.icon-btn img { width: 100%; height: auto; display: block; filter: drop-shadow(0 .3cqw .4cqw rgba(60, 35, 20, .35)); transition: transform .15s; }
.icon-btn:active img { transform: scale(.94); }
.icon-btn .cap { font-size: 1cqw; font-weight: 800; color: #fff; text-shadow: 0 .1cqw .3cqw rgba(60, 35, 20, .9); margin-top: -.1cqw; }
button:focus-visible { outline: .35cqw solid #fff; outline-offset: .2cqw; box-shadow: 0 0 0 .6cqw rgba(143, 180, 227, .9); }

.snow-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }
.layer { position: absolute; inset: 0; pointer-events: none; }

/* ---------- homepage ---------- */
.home-bg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.glow-spot { position: absolute; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(circle, rgba(255, 214, 140, .55), rgba(255, 214, 140, 0) 70%); mix-blend-mode: screen; animation: breathe 6s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: .15; } 50% { opacity: .75; } }
.light { position: absolute; width: .7cqw; aspect-ratio: 1; border-radius: 50%; background: #fff6c8; box-shadow: 0 0 .9cqw .4cqw rgba(255, 235, 160, .85); transform: translate(-50%, -50%); animation: twinkle 3s ease-in-out infinite; }
@keyframes twinkle { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

.hotspot { position: absolute; background: transparent; border: 0; padding: 0; z-index: 5; }
.hotspot::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 50% 60%, rgba(255, 233, 170, .75), rgba(255, 233, 170, 0) 72%); opacity: 0; transition: opacity .35s; }
.hotspot.glow::after, .hotspot:focus-visible::after { opacity: 1; }
.hotspot:focus-visible { outline: none; box-shadow: none; }

.sign { position: absolute; z-index: 8; transform: translate(-50%, -50%); background: none; border: 0; padding: 0; min-height: 8cqw; transition: transform .25s, filter .35s; }
.sign img { display: block; width: 100%; height: auto; filter: drop-shadow(0 .4cqw .5cqw rgba(60, 35, 20, .35)); }
.sign:active, .sign.glow { transform: translate(-50%, -50%) scale(1.05); filter: brightness(1.08) drop-shadow(0 0 1.2cqw rgba(255, 233, 170, .95)); }

.home-title { position: absolute; z-index: 9; left: 50%; top: .6%; width: 42%; transform: translateX(-50%); pointer-events: none; }
.ttl-img { display: block; width: 100%; height: auto; filter: drop-shadow(0 .5cqw .6cqw rgba(50, 40, 70, .3)); }
.ttl-ribbon {
  position: absolute; left: 20%; right: 19%; bottom: 2%; height: 36%; display: grid; place-items: center;
  background: linear-gradient(#fff2d8, #f6dfb8); border-radius: 1.4cqw; border: .15cqw solid #e8c890;
  font-weight: 800; font-size: 1.9cqw; color: #7a4a2a; box-shadow: 0 .2cqw .5cqw rgba(90, 60, 30, .25);
}

.level-panel { position: absolute; z-index: 10; left: 50%; bottom: 1.6%; transform: translateX(-50%); width: 38%; display: grid; justify-items: center; gap: .6cqw; padding: 1.3cqw 1.4cqw 1.1cqw; background: linear-gradient(#fff9ec, #f3e3c4); border: .3cqw solid #d9b886; border-radius: 2.6cqw; box-shadow: 0 .6cqw 1.2cqw rgba(60, 35, 20, .3); }
.lp-title { font-size: 1.9cqw; padding: .5cqw 2.4cqw; margin-top: -3cqw; border-radius: 1.8cqw; }
.lp-row { display: flex; gap: 1.6cqw; }
.lvl { width: 16cqw; background: none; border: 0; padding: 0; border-radius: 3cqw; transition: transform .2s, filter .25s; }
.lvl img { width: 100%; display: block; filter: drop-shadow(0 .3cqw .4cqw rgba(60, 35, 20, .3)); }
.lvl:not(.active) { filter: saturate(.55) brightness(1.04); opacity: .88; }
.lvl.active { transform: scale(1.06); filter: drop-shadow(0 0 .9cqw rgba(255, 232, 150, 1)); }
.lvl.active::after { content: ""; display: block; height: .5cqw; margin: .2cqw 22% 0; border-radius: 1cqw; background: #f4c64e; }

.teacher-btn { position: absolute; z-index: 10; right: 2.2%; bottom: 3%; display: flex; align-items: center; gap: .8cqw; padding: .6cqw 1.6cqw .6cqw .8cqw; font-size: 1.6cqw; min-height: 6.4cqw; }
.teacher-btn .gear { width: 4.4cqw; height: auto; }
.sound-toggle { position: absolute; z-index: 10; right: 1.8%; top: 2.5%; }

.char { position: absolute; transform: translateX(-50%); pointer-events: none; z-index: 12; line-height: 0; }
.char .pose { display: block; }
.char .pose[hidden] { display: none; }
.char.bob .pose:not([hidden]) { animation: bob .7s ease-in-out infinite alternate; transform-origin: 50% 100%; }
@keyframes bob { from { transform: rotate(-1.2deg); } to { transform: rotate(1.2deg); } }

/* ---------- backdrops (world + game) ---------- */
.backdrop { position: absolute; inset: 0; overflow: hidden; }
.backdrop-img { position: absolute; inset: 0; }
.backdrop-img.soft { filter: blur(.5cqw) saturate(.9); transform: scale(1.04); }
.backdrop-veil { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(250, 244, 255, .30), rgba(255, 243, 226, .18) 55%, rgba(240, 232, 255, .38)); }

.topbar { position: absolute; z-index: 20; left: 0; right: 0; top: 0; padding: 1.2cqw 1.8cqw; display: flex; align-items: flex-start; justify-content: space-between; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.bar-group { display: flex; gap: .8cqw; align-items: flex-start; }
.title-plank { font-size: 2.1cqw; padding: .7cqw 2.8cqw; margin-top: .4cqw; border-radius: 2cqw; }
.world-sign { width: 21cqw; margin-top: -.6cqw; pointer-events: none !important; }
.world-sign img { width: 100%; display: block; filter: drop-shadow(0 .4cqw .5cqw rgba(60, 35, 20, .35)); }
.level-chip { width: 11.5cqw; background: none; border: 0; padding: 0; min-height: 5cqw; }
.level-chip img { width: 100%; display: block; filter: drop-shadow(0 .3cqw .4cqw rgba(60, 35, 20, .3)); }

/* ---------- world menu ---------- */
.stations { position: absolute; inset: 0; }
.station { position: absolute; transform: translate(-50%, -50%); width: 14.6cqw; background: none; border: 0; padding: 0; display: grid; justify-items: center; transition: transform .2s; }
.station-art { height: 10cqw; width: auto; max-width: 11cqw; object-fit: contain; filter: drop-shadow(0 .5cqw .5cqw rgba(60, 35, 20, .4)); transition: transform .25s; }
.station:not(:disabled):hover .station-art, .station:not(:disabled):focus-visible .station-art { transform: translateY(-.5cqw) scale(1.06); }
.station:not(:disabled):active { transform: translate(-50%, -50%) scale(.96); }
.station-plate { margin-top: -.7cqw; width: 100%; font-size: 1.3cqw; line-height: 1.15; padding: .75cqw .7cqw; min-height: 4cqw; display: grid; place-items: center; border-radius: 1cqw; }
.station.planned .station-art { filter: grayscale(.8) opacity(.55) drop-shadow(0 .4cqw .4cqw rgba(60, 35, 20, .25)); }
.station.planned .station-plate { opacity: .6; }
.ribbon { position: absolute; top: 1cqw; right: -.4cqw; background: #f3e2c0; color: #7a4a2a; font-size: .95cqw; font-weight: 800; padding: .25cqw .8cqw; border-radius: .8cqw; transform: rotate(6deg); box-shadow: 0 .2cqw .4cqw rgba(60, 35, 20, .3); }

/* ---------- game screen ---------- */
.play-area { position: absolute; left: 3%; right: 3%; top: 12.5%; height: 63%; z-index: 10; touch-action: none; }
.play-area.round-in > * { animation: roundIn .45s ease both; }
@keyframes roundIn { from { opacity: 0; transform: translateY(1.2cqw); } to { opacity: 1; transform: none; } }
.bubble { position: absolute; z-index: 21; left: 14%; bottom: 2.5%; width: 52%; height: 17%; display: grid; place-items: center; }
.bubble-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; filter: drop-shadow(0 .3cqw .5cqw rgba(60, 35, 20, .3)); }
.bubble-text { position: relative; margin: 0; padding: 0 4cqw; font-size: 2.3cqw; font-weight: 800; line-height: 1.2; color: #5a3d36; text-align: center; }
.stars { position: absolute; z-index: 21; right: 3%; bottom: 3.5%; display: flex; gap: .5cqw; padding: .6cqw 1.2cqw; background: rgba(255, 247, 232, .85); border-radius: 2cqw; border: .2cqw solid #e3c89c; }
.star { width: 3.6cqw; height: auto; filter: grayscale(1) opacity(.45); transition: filter .4s, transform .4s; }
.star.on { filter: none; transform: scale(1.1); }
.game-screen .char { z-index: 22; }

.end-screen { position: absolute; inset: 0; display: grid; place-items: center; }
.end-board { width: 62%; padding: 2.2cqw 2cqw 2.2cqw; display: grid; gap: 1.4cqw; justify-items: center; z-index: 3; }
.end-board h2 { margin: 0; font-size: 5cqw; letter-spacing: .05cqw; }
.end-buttons { display: flex; gap: 1.2cqw; flex-wrap: wrap; justify-content: center; }
.end-kids { position: absolute; inset: 0; pointer-events: none; }
.end-kids .char { z-index: 4; }
.confetti { position: absolute; top: 0; border-radius: .2cqw; pointer-events: none; z-index: 60; }
.fx-sparkle { position: absolute; height: auto; pointer-events: none; z-index: 70; filter: drop-shadow(0 0 .4cqw rgba(255, 240, 170, .9)); }

/* ---------- settings ---------- */
.settings-overlay { position: absolute; inset: 0; z-index: 80; background: rgba(60, 50, 90, .45); display: grid; place-items: center; animation: fadeIn .25s both; }
.settings-panel { width: 52cqw; padding: 2.6cqw 3cqw 2.4cqw; display: grid; gap: 1.2cqw; text-align: left; }
.settings-panel h2 { margin: 0 0 .4cqw; text-align: center; font-size: 3cqw; }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 1cqw; background: rgba(255, 247, 232, .16); border-radius: 1.2cqw; padding: .7cqw 1.2cqw; }
.set-label { font-size: 1.7cqw; }
.set-levels { display: flex; gap: .8cqw; }
.set-levels .lvl { width: 11cqw; }
.switch { min-width: 7cqw; min-height: 4.2cqw; font-size: 1.6cqw; font-weight: 800; border-radius: 3cqw; border: .25cqw solid var(--wood-3); background: #d9c9b6; color: #6b5547; }
.switch.on { background: #bfe0b0; color: #2f5a2a; }
.set-actions { display: flex; flex-wrap: wrap; gap: .8cqw; justify-content: center; }
.settings-panel .close { justify-self: center; background: linear-gradient(#8fb4e3, #6f95cc); border-color: #4a6fa8; }

/* ---------- reusable game pieces ---------- */
.dd-item { touch-action: none; cursor: grab; }
.dd-item.selected { filter: drop-shadow(0 0 .9cqw rgba(255, 236, 140, 1)); transform: scale(1.1); }
.dd-item.dragging { cursor: grabbing; z-index: 50; }
.numeral { font-weight: 800; color: #fff; text-shadow: 0 .2cqw 0 rgba(60, 40, 90, .6); }
.choice { background: linear-gradient(#fffaf0, #f4e6cc); border: .3cqw solid #d9b886; border-radius: 1.6cqw; box-shadow: 0 .5cqw .9cqw rgba(60, 35, 20, .25); min-width: 9cqw; min-height: 9cqw; font-size: 5cqw; font-weight: 800; color: #6a4a8c; padding: 0; display: grid; place-items: center; transition: transform .15s; }
.choice:active { transform: scale(.95); }
.choice.right { background: linear-gradient(#e7f6dc, #c9e8b6); border-color: #8fbf7a; }
.choice.nudge { animation: nudge .35s; }
@keyframes nudge { 25% { transform: translateX(-.5cqw); } 75% { transform: translateX(.5cqw); } }
.hint { position: absolute; left: 50%; transform: translateX(-50%); font-weight: 800; font-size: 2cqw; color: #fff; text-shadow: 0 .2cqw .5cqw rgba(60, 35, 20, .8); pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

[hidden] { display: none !important; }
