:root {
  --panel: rgba(28, 30, 86, .92);
  --wood1: #f3d2a8; --wood2: #d9a46f; --wood3: #9a5e32;
  --brown: #a33a12;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1d1560; color: #fff; font-family: 'Nunito', system-ui, sans-serif; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
.hidden { display: none !important; }
#app { position: fixed; inset: 0; overflow: hidden; }
.snowfx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.pi { display: inline-block; width: 1.4em; height: 1.4em; vertical-align: middle; font-style: normal; }
.pi svg { width: 100%; height: 100%; display: block; overflow: visible; }
/* white chunky text with a dark outline, as in the reference UI */
.out, .lbl, .pill b, .plvl b, .t-cnt b, .big-play, .green-btn, .map-plate, .ribbon, .rw b, .card-num, .card-cap, .stage-pill {
  font-weight: 900; color: #fff; paint-order: stroke fill; -webkit-text-stroke: 4px #3a1670; letter-spacing: .2px; white-space: nowrap; }

@keyframes bob { 50% { transform: translateY(-8px); } }
@keyframes pulse { 50% { transform: scale(1.08); } }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } }

/* ---------------- loader */
#loader { position: absolute; inset: 0; z-index: 100; transition: opacity .6s; overflow: hidden; }
#loader.done { opacity: 0; pointer-events: none; }
#loader.gone { display: none; }
.ld-sky { position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 30% at 70% 10%, rgba(80, 255, 200, .35), transparent 70%),
    radial-gradient(ellipse 70% 40% at 20% 25%, rgba(255, 120, 200, .35), transparent 70%),
    linear-gradient(#2a2178 0%, #6b4bc4 35%, #f6a3c9 52%, #cfe3ff 60%, #eef6ff 100%); }
.ld-sky::after { content: ""; position: absolute; left: -10%; right: -10%; bottom: 0; height: 48%;
  background: radial-gradient(ellipse 60% 50% at 50% 0%, #ffffff, #dbe9ff 60%, #b9cdf5 100%); border-radius: 50% 50% 0 0 / 30% 30% 0 0; }
.ld-center { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); text-align: center; width: 100%; }
.ld-castle { font-size: min(24vw, 120px); line-height: 1; margin-bottom: -18px; filter: drop-shadow(0 6px 10px rgba(60, 20, 120, .5)); animation: bob 4s ease-in-out infinite; }
.ld-castle::before { content: "🏰"; }
.ld-title { font-family: 'Lobster', cursive; font-size: min(26vw, 140px); line-height: 1;
  background: linear-gradient(#fff6b0 10%, #ffd23a 45%, #ff9d00 80%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 #a34d00) drop-shadow(0 8px 14px rgba(80, 20, 120, .5)); animation: bob 3s ease-in-out infinite; position: relative; z-index: 2; }
.ld-book { width: min(70vw, 380px); height: min(20vw, 110px); margin: -10px auto 0; position: relative;
  background: linear-gradient(90deg, #f3e3c4, #fff8ea 48%, #e7d3ad 50%, #fff8ea 52%, #f3e3c4);
  border-radius: 10px 10px 40px 40px / 10px 10px 30px 30px; border-bottom: 10px solid #2c46b8; box-shadow: 0 10px 0 #e7a522, 0 18px 30px rgba(0,0,0,.25); }
.ld-bar { position: absolute; left: 50%; bottom: calc(10% + var(--safe-bot)); transform: translateX(-50%); width: min(80vw, 520px); height: 34px;
  border-radius: 20px; background: linear-gradient(#5a5f9c, #3b3f78); border: 4px solid #ffcf4a; box-shadow: 0 0 0 3px #b0620a, 0 8px 20px rgba(0,0,0,.3); overflow: hidden; }
.ld-fill { height: 100%; width: 0; background: repeating-linear-gradient(-45deg, #ffa21e 0 14px, #ff8a00 14px 28px); transition: width .25s; }
.ld-pct { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 900; font-size: 18px; text-shadow: 0 2px 0 rgba(0,0,0,.4); }

/* ---------------- scene */
#scene { position: absolute; inset: 0; isolation: isolate; }
#snowMain { z-index: 1500; }
#bg { position: absolute; inset: 0; width: 100%; height: 100%; }
#world { position: absolute; inset: 0; }
.sky-obj { position: absolute; z-index: 3; pointer-events: none; filter: drop-shadow(0 0 8px rgba(255, 220, 160, .7)); }
.planet { font-size: 32px; left: 40%; top: 21%; animation: planet 9s ease-in-out infinite; }
.ufo { font-size: 22px; left: 20%; top: 18%; animation: ufo 14s ease-in-out infinite; }
@keyframes planet { 50% { transform: translate(10px, -8px) rotate(8deg); } }
@keyframes ufo { 0%,100% { transform: translate(0, 0) rotate(-6deg); } 25% { transform: translate(30px, 10px) rotate(6deg); } 50% { transform: translate(60px, -6px) rotate(-4deg); } 75% { transform: translate(24px, -14px) rotate(5deg); } }
.aurora { animation: aurora 16s ease-in-out infinite alternate; transform-box: view-box; }
@keyframes aurora { 0% { transform: translateX(-4%) skewX(-6deg); } 100% { transform: translateX(4%) skewX(6deg); } }
.moonglow { animation: moon 5s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes moon { 50% { transform: scale(1.18); opacity: .8; } }
.bgsmoke { opacity: 0; animation: bgsmoke 4s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes bgsmoke { 0% { transform: translate(0, 0) scale(.5); opacity: 0; } 20% { opacity: .8; } 100% { transform: translate(14px, -40px) scale(2); opacity: 0; } }
.sleigh { position: absolute; left: 100%; z-index: 5; font-size: 24px; white-space: nowrap; pointer-events: none; animation: sleigh 15s linear forwards; filter: drop-shadow(0 0 6px rgba(255, 240, 180, .8)); }
.sleigh span { display: inline-block; animation: bob 1s ease-in-out infinite; }
.sleigh span:nth-child(2) { animation-delay: .2s; } .sleigh span:nth-child(3) { animation-delay: .4s; }
@keyframes sleigh { 0% { transform: translate(0, 0); } 25% { transform: translate(-35vw, -18px); } 50% { transform: translate(-70vw, 6px); } 75% { transform: translate(-105vw, -14px); } 100% { transform: translate(-150vw, 0); } }

/* tree */
#tree { position: absolute; left: 50%; bottom: 36%; transform: translateX(-50%); transform-origin: 50% 100%; transition: height .8s cubic-bezier(.3,1.6,.5,1), width .8s cubic-bezier(.3,1.6,.5,1); }
#tree svg.tree-svg { width: 100%; height: 100%; display: block; overflow: visible; filter: drop-shadow(0 10px 12px rgba(20, 10, 70, .35)); }
#tree .sway { position: absolute; inset: 0; transform-origin: 50% 100%; animation: treeSway 7s ease-in-out infinite; }
#tree .sway.shake { animation: treeShake .7s ease-out, treeSway 7s ease-in-out .7s infinite; }
#tree .sway.perk { animation: treePerk .9s cubic-bezier(.3,1.6,.5,1), treeSway 7s ease-in-out .9s infinite; }
#tree.sketch .sway { filter: grayscale(1) sepia(1) saturate(3.2) hue-rotate(-12deg) brightness(.95); opacity: .78; }
@keyframes treeSway { 0%,100% { transform: rotate(-.8deg) scaleY(1); } 50% { transform: rotate(.8deg) scaleY(1.012); } }
@keyframes treeShake { 0% { transform: rotate(0); } 15% { transform: rotate(-4deg); } 35% { transform: rotate(3.5deg); } 55% { transform: rotate(-2deg); } 75% { transform: rotate(1deg); } 100% { transform: rotate(0); } }
@keyframes treePerk { 0% { transform: scale(1, 1); } 30% { transform: scale(1.06, .92); } 60% { transform: scale(.96, 1.08); } 100% { transform: scale(1, 1); } }
#tree .slot { position: absolute; width: max(12%, 16px); aspect-ratio: 1; transform: translate(-50%, -50%); display: grid; place-items: center; pointer-events: none; }
#tree .slot .toy { width: 100%; height: 100%; display: grid; place-items: center; transform-origin: 50% 0; animation-name: pop, toySwing; animation-iteration-count: 1, infinite; animation-timing-function: ease-out, ease-in-out; }
@keyframes toySwing { 0%,100% { transform: rotate(calc(var(--amp, 5deg) * -1)); } 50% { transform: rotate(var(--amp, 5deg)); } }
#tree .emo { font-size: var(--fs, 20px); line-height: 1; filter: drop-shadow(0 2px 2px rgba(0,0,0,.3)); }
#tree .twinkle { position: absolute; width: 9%; aspect-ratio: 1; transform: translate(-50%, -50%) scale(0); pointer-events: none; animation: twinkle 4s ease-in-out infinite;
  background: radial-gradient(circle, #fff 0 8%, transparent 30%), conic-gradient(from 0deg, transparent 0 20deg, rgba(255,255,255,.9) 22deg 23deg, transparent 25deg 110deg, rgba(255,255,255,.9) 112deg 113deg, transparent 115deg 200deg, rgba(255,255,255,.9) 202deg 203deg, transparent 205deg 290deg, rgba(255,255,255,.9) 292deg 293deg, transparent 295deg);
  border-radius: 50%; filter: drop-shadow(0 0 3px #fff); }
@keyframes twinkle { 0%,70%,100% { transform: translate(-50%, -50%) scale(0) rotate(0); opacity: 0; } 80% { transform: translate(-50%, -50%) scale(1) rotate(45deg); opacity: 1; } 90% { transform: translate(-50%, -50%) scale(.3) rotate(90deg); opacity: .6; } }
#tree .topper { position: absolute; left: 50%; top: -2%; transform: translate(-50%, -60%); font-size: var(--fs, 40px); line-height: 1; }
#tree .topper span { position: relative; display: block; filter: drop-shadow(0 0 12px rgba(255, 230, 120, .9)); animation: pulse 2.5s ease-in-out infinite; }
#tree .topper .rays { position: absolute; left: 50%; top: 50%; width: 260%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none;
  background: repeating-conic-gradient(rgba(255, 240, 160, .55) 0 8deg, transparent 8deg 30deg);
  -webkit-mask: radial-gradient(circle, #000 15%, transparent 68%); mask: radial-gradient(circle, #000 15%, transparent 68%); animation: spin 14s linear infinite; }
.ball { width: 100%; height: 100%; border-radius: 50%; position: relative;
  background: radial-gradient(circle at 32% 30%, #fff 0 8%, transparent 26%), radial-gradient(circle at 50% 50%, var(--c) 40%, color-mix(in srgb, var(--c), #000 45%) 100%);
  box-shadow: 0 2px 4px rgba(0,0,0,.35); }
.ball::before { content: ""; position: absolute; left: 36%; top: -12%; width: 28%; height: 18%; border-radius: 3px; background: linear-gradient(#ffe9a0, #c98a16); }
.light { position: absolute; width: 2.8%; min-width: 4px; aspect-ratio: 1; border-radius: 50%; transform: translate(-50%, -50%); background: var(--c); box-shadow: 0 0 6px 2px var(--c); animation: chase 2s ease-in-out infinite; }
@keyframes chase { 0%,100% { opacity: .35; transform: translate(-50%, -50%) scale(.8); } 50% { opacity: 1; transform: translate(-50%, -50%) scale(1.25); box-shadow: 0 0 10px 4px var(--c); } }

/* meadow objects */
.obj { position: absolute; transform: translate(-50%, -100%); line-height: 1; text-align: center; cursor: pointer; }
.obj .drop { position: relative; transform-origin: 50% 100%; }
.obj .drop.jump { animation: jump .45s cubic-bezier(.3,1.6,.5,1); }
.obj .drop.built { animation: built .9s cubic-bezier(.3,1.5,.5,1); }
.obj .cluster { display: flex; align-items: flex-end; justify-content: center; }
.obj .e { display: block; font-size: var(--fs); filter: drop-shadow(0 4px 3px rgba(30, 20, 90, .35)); transform-origin: 50% 100%; }
.obj .e.small { font-size: calc(var(--fs) * .6); margin: 0 -2px; }
.obj::after { content: ""; position: absolute; left: 8%; right: 8%; bottom: -5%; height: 14%; border-radius: 50%; background: rgba(60, 50, 150, .25); z-index: -1; }
.obj.sketch .cluster { filter: grayscale(1) sepia(1) saturate(3.4) hue-rotate(-12deg) brightness(.95); opacity: .8; }
.obj.sketch::before { content: ""; position: absolute; left: -12%; right: -12%; bottom: -14%; height: 34%; border-radius: 50%; border: 3px dashed rgba(255, 255, 255, .85); background: rgba(255, 255, 255, .18); animation: pulse 1.6s infinite; z-index: -1; }
.obj .badge-up { position: absolute; right: -6px; top: -10px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; font-weight: 900;
  background: radial-gradient(circle at 40% 30%, #c8ff8a, #4ccf2c 55%, #1f8a14); border: 2px solid #fff; box-shadow: 0 2px 4px rgba(0,0,0,.4); animation: bob 1.2s ease-in-out infinite; }
.obj .lock { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); font-size: 22px; filter: drop-shadow(0 2px 2px rgba(0,0,0,.4)); }
.drift { position: relative; width: var(--w); height: calc(var(--w) * .55); }
.drift svg { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 6px 6px rgba(40, 20, 110, .35)); }
.obj.covered .drift { animation: driftWobble 3s ease-in-out infinite; }
@keyframes driftWobble { 0%,100% { transform: scale(1, 1); } 50% { transform: scale(1.02, .98); } }
.obj.focus::before { content: ""; position: absolute; left: 50%; top: 50%; width: 150%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 200, .5), transparent 65%); animation: pulse 1.2s infinite; z-index: -1; }
@keyframes jump { 0% { transform: none; } 25% { transform: scale(1.15, .85); } 55% { transform: translateY(-30%) scale(.92, 1.1); } 85% { transform: scale(1.06, .94); } 100% { transform: none; } }
@keyframes built { 0% { transform: scale(.2) translateY(-60%); opacity: 0; } 60% { transform: scale(1.15, .9); opacity: 1; } 80% { transform: scale(.95, 1.06); } 100% { transform: none; } }
.a-wobble { animation: wobble 3.4s ease-in-out infinite; }
.a-sway { animation: dsway 4.5s ease-in-out infinite; }
.a-hop { animation: hop 2.8s ease-in-out infinite; }
.a-waddle { animation: waddle 1.3s ease-in-out infinite; }
.a-graze { animation: graze 5s ease-in-out infinite; }
.a-breathe { animation: breathe 3.5s ease-in-out infinite; }
.a-bounce { animation: dbounce 1.6s ease-in-out infinite; }
.a-rock { animation: rock 6s ease-in-out infinite; }
.a-jiggle { animation: jiggle 4s ease-in-out infinite; }
.a-glow { animation: glow 2.2s ease-in-out infinite; }
.a-shimmer { animation: shimmer 3s ease-in-out infinite; }
@keyframes wobble { 0%,100% { transform: rotate(-4deg) scale(1, 1); } 25% { transform: rotate(0) scale(1.04, .96); } 50% { transform: rotate(4deg) scale(1, 1); } 75% { transform: rotate(0) scale(.97, 1.04); } }
@keyframes dsway { 0%,100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes hop { 0%,55%,100% { transform: none; } 62% { transform: scale(1.12, .85); } 72% { transform: translateY(-38%) scale(.94, 1.1); } 80% { transform: translateY(-38%) scale(.96, 1.06) rotate(-6deg); } 90% { transform: scale(1.1, .88); } 96% { transform: scale(.98, 1.03); } }
@keyframes waddle { 0%,100% { transform: rotate(-7deg) translateX(-3%); } 50% { transform: rotate(7deg) translateX(3%); } }
@keyframes graze { 0%,40%,100% { transform: rotate(0); } 50%,75% { transform: rotate(6deg) translateY(2%); } 85% { transform: rotate(-2deg); } }
@keyframes breathe { 0%,100% { transform: scale(1, 1); } 50% { transform: scale(1.02, 1.04); } }
@keyframes dbounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7%); } }
@keyframes rock { 0%,100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes jiggle { 0%,80%,100% { transform: none; } 84% { transform: rotate(-6deg) scale(1.05); } 88% { transform: rotate(6deg); } 92% { transform: rotate(-4deg); } 96% { transform: rotate(2deg); } }
@keyframes glow { 0%,100% { filter: drop-shadow(0 4px 3px rgba(30,20,90,.35)) brightness(1); } 50% { filter: drop-shadow(0 0 12px rgba(255, 190, 90, .9)) brightness(1.25); } }
@keyframes shimmer { 0%,100% { filter: drop-shadow(0 0 4px rgba(160, 220, 255, .5)); } 50% { filter: drop-shadow(0 0 16px rgba(200, 240, 255, 1)); } }
.obj .smoke { position: absolute; width: 18%; aspect-ratio: 1; border-radius: 50%; background: rgba(240, 240, 255, .85); pointer-events: none; opacity: 0; animation: smoke 3.3s ease-out infinite; }
@keyframes smoke { 0% { transform: translate(-50%, 0) scale(.4); opacity: 0; } 15% { opacity: .9; } 100% { transform: translate(10%, -260%) scale(1.6); opacity: 0; } }

/* object popup: cost bar + green button, like the reference */
#objPop { position: absolute; z-index: 30; transform: translate(-50%, 0); width: 190px; padding: 8px; border-radius: 22px; text-align: center;
  background: linear-gradient(#fff3e6, #ffd9b8); border: 3px solid #e6a77a; box-shadow: 0 8px 20px rgba(40, 10, 80, .45); animation: pop .25s; }
#objPop .op-name { color: var(--brown); font-weight: 900; font-size: 15px; }
#objPop .op-stage { color: #b0703a; font-weight: 800; font-size: 12px; margin-bottom: 6px; }
#objPop .op-need { position: relative; height: 22px; border-radius: 12px; background: #e7c9f0; overflow: hidden; border: 2px solid #c38ad8; margin-bottom: 6px; }
#objPop .op-need i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#ffb6f0, #e25fd0); }
#objPop .op-need b { position: relative; font-size: 13px; -webkit-text-stroke: 3px #7a1a6a; paint-order: stroke fill; font-weight: 900; line-height: 18px; }
#objPop .op-btn { width: 100%; }
#objPop .op-arrow { position: absolute; left: -40px; top: 50%; font-size: 34px; transform: translateY(-50%); animation: arrowX 1s ease-in-out infinite; filter: drop-shadow(0 2px 2px rgba(0,0,0,.4)); }
@keyframes arrowX { 50% { transform: translate(8px, -50%); } }

/* ---------------- HUD */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
#hud button, #hud .pill { pointer-events: auto; }
body.visiting #hud { display: none; }
.hud-top { position: absolute; top: calc(6px + var(--safe-top)); left: 6px; right: 6px; display: flex; gap: 8px; align-items: center; }
.plvl { display: flex; align-items: center; flex: 1; min-width: 0; }
.pstar { position: relative; z-index: 2; width: 56px; height: 54px; flex: none; display: grid; place-items: center;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cdefs%3E%3CradialGradient id='g' cx='.4' cy='.35' r='.7'%3E%3Cstop offset='0' stop-color='%23ffc4f4'/%3E%3Cstop offset='.55' stop-color='%23f040c0'/%3E%3Cstop offset='1' stop-color='%23a0168a'/%3E%3C/radialGradient%3E%3C/defs%3E%3Cpath d='M20 2l5.4 11 12.1 1.7-8.8 8.5 2.1 12-10.8-5.7-10.8 5.7 2.1-12-8.8-8.5 12.1-1.7z' fill='url(%23g)' stroke='%237a0a6a' stroke-width='1.6' stroke-linejoin='round'/%3E%3Ccircle cx='20' cy='21' r='8' fill='%233a8cff' stroke='%23123a9a' stroke-width='1.4'/%3E%3C/svg%3E") center/contain no-repeat;
  filter: drop-shadow(0 3px 3px rgba(0,0,0,.4)); animation: pulse 3s ease-in-out infinite; }
.pstar b { font-size: 15px; margin-top: 4px; -webkit-text-stroke: 3px #0d2a80; }
.plbar { flex: 1; min-width: 0; margin-left: -14px; height: 22px; border-radius: 0 12px 12px 0; position: relative; overflow: hidden;
  background: linear-gradient(#b4743e, #8a4f22); border: 2px solid #5e3212; box-shadow: inset 0 2px 3px rgba(0,0,0,.35); }
.plfill { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(#bff0ff, #4fb6ff 60%, #2a7ae0); transition: width .6s; }
.pltxt { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 900; text-shadow: 0 1px 2px #000; padding-left: 10px; }
.pill { position: relative; display: flex; align-items: center; height: 30px; border-radius: 16px; padding: 0 10px 0 30px;
  background: linear-gradient(#2c2a6e, #3e3c8e 50%, #2a285f); border: 2px solid #0f0d3a; box-shadow: inset 0 3px 4px rgba(0,0,0,.45); }
.pill .pi { position: absolute; left: -6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; filter: drop-shadow(0 2px 2px rgba(0,0,0,.45)); }
.pill b { flex: 1; text-align: center; font-size: 15px; -webkit-text-stroke: 3px #14123f; }
.pill.wood { background: linear-gradient(#ffe4c0, #eab988 55%, #d79a62); border: 2px solid #a8683a; box-shadow: inset 0 2px 2px rgba(255,255,255,.7), 0 3px 6px rgba(0,0,0,.3); }
.pill.wood b { -webkit-text-stroke: 3px #8a4a1c; }
.plus { position: absolute; left: 12px; bottom: -9px; width: 22px; height: 22px; border-radius: 50%; font-weight: 900; font-size: 17px; line-height: 1; display: grid; place-items: center;
  background: radial-gradient(circle at 40% 30%, #c8ff8a, #4ccf2c 55%, #1f8a14); border: 2px solid #fff; box-shadow: 0 2px 3px rgba(0,0,0,.4); z-index: 2; }
.round-btn { width: 46px; height: 46px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 22px;
  background: radial-gradient(circle at 40% 30%, #bfeaff, #3c9bff 55%, #1452c4); border: 3px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,.35); }
.hud-cur { position: absolute; top: calc(60px + var(--safe-top)); left: 12px; right: 8px; display: flex; gap: 14px; }
.hud-cur .pill { flex: 1; min-width: 0; padding-right: 6px; }
.side { position: absolute; top: calc(116px + var(--safe-top)); display: flex; flex-direction: column; gap: 14px; align-items: center; pointer-events: none; }
.side-left { left: 6px; } .side-right { right: 6px; }
.tbtn { position: relative; width: 64px; display: flex; flex-direction: column; align-items: center; }
.tbtn .tile { width: 58px; height: 58px; border-radius: 16px; display: grid; place-items: center; position: relative; overflow: hidden;
  background: linear-gradient(var(--c1), var(--c2)); border: 2px solid var(--c3);
  box-shadow: 0 4px 0 var(--c3), 0 7px 12px rgba(20, 0, 60, .45), inset 0 -6px 10px rgba(0,0,0,.18); }
.tbtn .tile::before { content: ""; position: absolute; left: 6%; right: 6%; top: 3%; height: 42%; border-radius: 12px 12px 40% 40%; background: linear-gradient(rgba(255,255,255,.7), rgba(255,255,255,.08)); }
.tbtn .ic { position: relative; font-size: 32px; line-height: 1; filter: drop-shadow(0 3px 2px rgba(0,0,0,.35)); }
.tbtn .lbl { margin-top: -9px; position: relative; font-size: 12px; }
.tbtn:active .tile { transform: translateY(3px); }
.badge { position: absolute; top: -8px; right: -6px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 900; font-size: 16px; color: #fff; z-index: 2;
  background: radial-gradient(circle at 40% 30%, #ffe680, #ff9d00 60%, #d46a00); border: 2px solid #fff; box-shadow: 0 2px 4px rgba(0,0,0,.4); animation: pulse 1.2s infinite; }
.t-red { --c1: #ffb26b; --c2: #f0452e; --c3: #9a1d12; }
.t-sky { --c1: #b8e8ff; --c2: #4a9cf0; --c3: #1d4f9a; }
.t-pink { --c1: #ffb0e0; --c2: #e83f9c; --c3: #8a1556; }
.bottom { position: absolute; left: 8px; right: 8px; bottom: calc(10px + var(--safe-bot)); display: flex; align-items: flex-end; justify-content: space-between; pointer-events: none; }
.guide { width: 76px; height: 76px; flex: none; }
.guide .ring, .say-face { width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 35%, #ffffff, #cfe6ff 70%); border: 5px solid #ffb21e; box-shadow: 0 0 0 3px #b0620a, 0 6px 14px rgba(0,0,0,.4); }
.guide .face { font-size: 46px; animation: bob 3s ease-in-out infinite; }
.big-play { min-width: 170px; height: 72px; padding: 0 18px; border-radius: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(#b7ff6a, #4fd12a 50%, #23a01c); border: 3px solid #eaffc8; box-shadow: 0 0 0 3px #1b6d10, 0 6px 0 3px #1b6d10, 0 12px 22px rgba(0,0,0,.4); animation: pulse 2s infinite; }
.big-play .bp-top { font-size: 13px; -webkit-text-stroke: 3px #1b6d10; }
.big-play .bp-cost { font-size: 26px; -webkit-text-stroke: 5px #1b6d10; line-height: 1; }
.pulse1 { animation: pop .3s; }
.say { position: absolute; z-index: 75; max-width: min(78vw, 330px); padding: 12px 16px; border-radius: 20px; background: #fff; color: var(--brown); font-weight: 900; font-size: 16px; line-height: 1.3; text-align: center;
  box-shadow: 0 6px 16px rgba(30, 10, 90, .4); animation: pop .3s; pointer-events: none; transform-origin: 30px 100%; }
.say::after { content: ""; position: absolute; left: 30px; bottom: -10px; border: 10px solid transparent; border-top-color: #fff; border-bottom: 0; }
.say.top::after { left: 26px; bottom: auto; top: -10px; border: 10px solid transparent; border-bottom-color: #fff; border-top: 0; }
#visitBar { position: absolute; top: calc(8px + var(--safe-top)); left: 8px; right: 8px; z-index: 25; background: var(--panel); border-radius: 18px; padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; font-weight: 900; border: 2px solid rgba(255,255,255,.5); }
#visitBar button { background: linear-gradient(#b5ff6a, #2fb43c); padding: 8px 14px; border-radius: 12px; border: 2px solid #fff; }

/* ---------------- buttons */
.green-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 26px; border-radius: 22px; font-size: 22px;
  background: linear-gradient(#b7ff6a, #4fd12a 50%, #23a01c); border: 3px solid #eaffc8; box-shadow: 0 0 0 3px #1b6d10, 0 5px 0 3px #1b6d10, 0 10px 18px rgba(0,0,0,.35); -webkit-text-stroke: 5px #1b6d10; }
.green-btn .pi { width: 32px; height: 32px; }
.green-btn.off { filter: grayscale(.8) brightness(.9); }
.green-btn:active, .big-play:active { transform: translateY(3px); }
.x { width: 40px; height: 40px; border-radius: 50%; background: radial-gradient(circle at 40% 30%, #ffa3b5, #ff3d64 55%, #c0103a); border: 3px solid #fff; font-weight: 900; font-size: 18px; box-shadow: 0 3px 6px rgba(0,0,0,.35); }
.x.small { width: 34px; height: 34px; font-size: 15px; flex: none; }

/* ---------------- adventure map */
#map { position: absolute; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; padding: calc(10px + var(--safe-top)) 12px calc(18px + var(--safe-bot));
  background: repeating-linear-gradient(90deg, #3a3290 0 58px, #342c84 58px 62px), #3a3290; animation: fadeIn .25s; }
#map::before { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 30%, rgba(140, 220, 255, .25), transparent 60%); pointer-events: none; }
.map-top { width: 100%; display: flex; justify-content: space-between; align-items: center; padding-left: 14px; position: relative; }
.map-top .pill { min-width: 110px; }
.map-plate { position: relative; margin-top: 8px; padding: 10px 26px 14px; border-radius: 18px 18px 0 0; font-size: 22px;
  background: linear-gradient(#e3b88c, #c88d5a); border: 3px solid #8a5228; border-bottom: 0; -webkit-text-stroke: 5px #6a3814; }
.parchment { position: relative; flex: 1; width: 100%; max-width: 460px; min-height: 0; border-radius: 22px; padding: 10px;
  background: radial-gradient(ellipse at 50% 40%, #fff3dc, #f0d4a8 70%, #e2b880); border: 6px solid #c97f9a; box-shadow: 0 0 0 3px #7a3a58, 0 10px 24px rgba(0,0,0,.4), inset 0 0 30px rgba(160, 100, 40, .35); }
#mapSvg { width: 100%; height: 100%; display: block; }
#mapSvg .node { cursor: pointer; }
#mapSvg .cur { animation: pulse 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
#mapSvg .portal { animation: portal 6s linear infinite; transform-box: fill-box; transform-origin: center; }
@keyframes portal { to { transform: rotate(360deg); } }
#map .green-btn { margin-top: -26px; position: relative; z-index: 2; }

/* ---------------- tile match */
#tiles { position: absolute; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; padding: calc(8px + var(--safe-top)) 8px calc(10px + var(--safe-bot));
  background: radial-gradient(ellipse at 50% 40%, #3e66c8, #24409a 60%, #172a6e); animation: fadeIn .25s; overflow: hidden; }
#tiles::before { content: ""; position: absolute; inset: 0; opacity: .14; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='84' height='96' viewBox='0 0 84 96'%3E%3Cpath d='M42 2l38 22v48L42 94 4 72V24z' fill='none' stroke='%23fff' stroke-width='3'/%3E%3C/svg%3E"); }
.t-top { position: relative; width: 100%; max-width: 480px; display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 16px;
  background: linear-gradient(#ffe4c0, #e5b07e); border: 2px solid #a8683a; box-shadow: 0 4px 0 #a8683a, 0 6px 12px rgba(0,0,0,.35); }
.t-prog { flex: 1; display: flex; align-items: center; min-width: 0; }
.cp { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 13px; color: #9a6a3a; background: #e8c39a; border: 2px solid #c4935e; }
.cp.done { background: radial-gradient(circle at 40% 30%, #c8ff8a, #4ccf2c 55%, #1f8a14); color: #fff; border-color: #fff; }
.cp.gift { background: none; border: 0; font-size: 22px; }
.t-line { flex: 1; height: 8px; border-radius: 4px; background: #d9a875; overflow: hidden; }
.t-line span { display: block; height: 100%; width: 0; background: linear-gradient(#c8ff8a, #3fbf1c); transition: width .3s; }
.t-cnt { display: flex; align-items: center; gap: 2px; padding: 2px 6px; border-radius: 10px; background: rgba(150, 90, 40, .25); }
.t-cnt .pi { width: 24px; height: 24px; }
.t-cnt b { font-size: 15px; -webkit-text-stroke: 3px #8a4a1c; min-width: 22px; text-align: center; }
#tboard { position: relative; flex: 1; width: 100%; max-width: 480px; margin: 8px 0; }
.tl { position: absolute; border-radius: 12%; display: grid; place-items: center; cursor: pointer;
  background: linear-gradient(#fffaf0, #f6e8cf); box-shadow: 0 5px 0 #d8a26a, 0 7px 8px rgba(0,0,0,.35), inset 0 -2px 0 rgba(0,0,0,.06); transition: transform .25s, filter .2s, left .3s, top .3s; }
.tl span { font-size: calc(var(--ts) * .62); line-height: 1; filter: drop-shadow(0 2px 1px rgba(0,0,0,.25)); }
.tl.blocked { filter: brightness(.68) saturate(.7); background: linear-gradient(#f0d6b2, #dfbb8c); cursor: default; }
.tl.hintme { animation: pulse .6s 3; }
.tl.fly { z-index: 3000 !important; transition: left .28s ease-in, top .28s ease-in, width .28s, height .28s; }
.t-boost { display: flex; gap: 14px; margin-bottom: 8px; }
.boost { position: relative; width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; font-size: 26px;
  background: radial-gradient(circle at 40% 30%, #bfeaff, #3c9bff 55%, #1452c4); border: 3px solid #fff; box-shadow: 0 0 0 2px #0e3a8c, 0 4px 8px rgba(0,0,0,.35); }
.boost span { filter: drop-shadow(0 2px 2px rgba(0,0,0,.4)); }
.boost em { position: absolute; right: -6px; bottom: -4px; min-width: 22px; height: 22px; border-radius: 11px; padding: 0 4px; font-style: normal; font-weight: 900; font-size: 13px; display: grid; place-items: center;
  background: #fff; color: #1452c4; border: 2px solid #1452c4; }
.boost.locked span { filter: grayscale(1) brightness(.6); }
.boost.locked em { background: #ffd34a; color: #8a4a00; border-color: #8a4a00; }
.tray { display: flex; gap: 4px; padding: 6px; border-radius: 16px; background: linear-gradient(#d39a62, #b47640); border: 3px solid #7a4a22; box-shadow: inset 0 4px 8px rgba(0,0,0,.35), 0 4px 10px rgba(0,0,0,.35); }
.tray .slot { border-radius: 10px; background: rgba(90, 50, 20, .3); box-shadow: inset 0 2px 4px rgba(0,0,0,.3); position: relative; }
.tray .tl { cursor: default; }
.tl.gone { transform: scale(0) rotate(20deg); opacity: 0; transition: transform .25s, opacity .25s; }

/* ---------------- overlays: ribbon, rewards, result cards */
#overlay { position: absolute; inset: 0; z-index: 70; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px 10px;
  background: radial-gradient(ellipse at 50% 45%, rgba(60, 40, 140, .55), rgba(10, 6, 40, .82)); animation: fadeIn .25s; }
.ribbon { position: relative; padding: 12px 34px; font-size: 22px; text-align: center; border-radius: 6px;
  background: linear-gradient(#ff6fb8, #e2287e); -webkit-text-stroke: 5px #8a0a48; box-shadow: 0 6px 0 #9a1050, 0 10px 18px rgba(0,0,0,.35); animation: pop .4s; }
.ribbon::before, .ribbon::after { content: ""; position: absolute; top: 12px; width: 26px; height: 100%; background: #b81a62; z-index: -1; }
.ribbon::before { left: -18px; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 35% 50%); }
.ribbon::after { right: -18px; clip-path: polygon(0 0, 100% 0, 65% 50%, 100% 100%, 0 100%); }
.ribbon.dark { background: linear-gradient(#a8306e, #7a1a4e); -webkit-text-stroke: 5px #4a0a2a; }
.stage-pill { margin-top: 10px; padding: 4px 20px; border-radius: 14px; background: #fff3e6; color: var(--brown); -webkit-text-stroke: 0; font-size: 16px; box-shadow: 0 3px 6px rgba(0,0,0,.3); }
.rewards { display: flex; flex-wrap: wrap; gap: 10px 16px; justify-content: center; margin: 26px 0 16px; max-width: 420px; }
.rw { display: flex; flex-direction: column; align-items: center; width: 74px; animation: pop .4s both; }
.rw .ri { width: 56px; height: 56px; display: grid; place-items: center; font-size: 40px; filter: drop-shadow(0 4px 4px rgba(0,0,0,.35)); }
.rw .ri svg { width: 100%; height: 100%; }
.rw .ri.circle { border-radius: 50%; background: radial-gradient(circle at 40% 30%, #bfeaff, #3c9bff 55%, #1452c4); border: 3px solid #fff; font-size: 28px; }
.rw b { font-size: 18px; margin-top: -6px; }
.rw small { font-weight: 900; font-size: 11px; -webkit-text-stroke: 3px #3a1670; paint-order: stroke fill; margin-bottom: 2px; }
.prestige { width: 100%; max-width: 520px; padding: 10px; text-align: center; background: linear-gradient(90deg, transparent, rgba(150, 60, 255, .85) 20%, rgba(150, 60, 255, .85) 80%, transparent); animation: fadeIn .4s .3s both; }
.prestige .t { font-weight: 900; font-size: 16px; }
.prestige .v { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 34px; font-weight: 900; }
.prestige .v .pi { width: 52px; height: 44px; }
.prestige .plus7 { color: #9dff5a; font-size: 24px; }
.tap-cont { position: absolute; bottom: calc(26px + var(--safe-bot)); font-weight: 800; opacity: .9; animation: blink 2s infinite; }
.cards { display: flex; gap: 16px; margin-top: 40px; }
.card2 { width: 138px; border-radius: 22px; padding: 10px 8px 0; text-align: center; position: relative; background: linear-gradient(#ead7c4, #c9a888); border: 4px solid #a8805e; box-shadow: 0 8px 0 #8a6040; }
.card2.win { background: repeating-linear-gradient(45deg, #ffd65a 0 14px, #ffcb3a 14px 28px); border-color: #ffa500; box-shadow: 0 8px 0 #c47a00, 0 0 34px 8px rgba(255, 220, 80, .7); animation: pulse 1.6s infinite; }
.card2.lose { opacity: .55; filter: saturate(.5); }
.card-cap { display: block; font-size: 13px; margin: -42px 0 16px; white-space: normal; line-height: 1.1; -webkit-text-stroke: 3px #3a1670; }
.card2 .pi { width: 84px; height: 84px; }
.card-num { display: block; font-size: 28px; margin: 4px 0 8px; -webkit-text-stroke: 5px #6a4a2a; }
.card2 .foot { margin: 0 -8px; padding: 6px; border-radius: 0 0 18px 18px; background: rgba(120, 70, 30, .35); display: flex; align-items: center; justify-content: center; gap: 4px; }
.card2 .foot .pi { width: 26px; height: 26px; }
.card2 .foot b { font-size: 18px; -webkit-text-stroke: 3px #3a1670; paint-order: stroke fill; font-weight: 900; }
.up-arrow { font-size: 42px; margin-top: 10px; animation: bob 1s infinite; filter: drop-shadow(0 3px 2px rgba(0,0,0,.4)); }
.ov-btns { display: flex; flex-direction: column; gap: 14px; margin-top: 24px; align-items: center; }
.ov-guide { position: absolute; left: 12px; top: calc(14px + var(--safe-top)); width: 70px; height: 70px; }
.ov-guide .say-face { font-size: 42px; }

/* ---------------- sheet */
#sheet { position: absolute; inset: 0; z-index: 80; }
.sheet-bg { position: absolute; inset: 0; background: rgba(10, 5, 40, .55); }
.sheet-box { position: absolute; left: 0; right: 0; bottom: 0; max-height: 82%; display: flex; flex-direction: column;
  background: linear-gradient(#5c3fd1, #3a2a9a); border-radius: 26px 26px 0 0; border: 3px solid #fff; border-bottom: 0; padding: 0 12px calc(12px + var(--safe-bot)); animation: up .25s ease-out; }
@keyframes up { from { transform: translateY(100%); } }
.sheet-head { display: flex; align-items: center; justify-content: center; position: relative; padding: 14px 40px 10px; }
.sheet-head h2 { margin: 0; font-family: 'Lobster', cursive; font-weight: 400; font-size: 28px; color: #ffe46b; text-shadow: 0 3px 0 #a34d00; }
.sheet-head .x { position: absolute; right: 2px; top: 10px; width: 36px; height: 36px; }
#sheetBody { overflow-y: auto; padding-bottom: 6px; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { flex: 1; padding: 8px 4px; border-radius: 12px; background: rgba(255,255,255,.15); font-weight: 900; font-size: 13px; }
.tabs button.on { background: linear-gradient(#ffd25c, #ff9d1e); color: #5a2a00; }
.row { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.12); border-radius: 14px; padding: 10px; margin-bottom: 8px; }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 900; }
.row .sub { font-size: 12px; opacity: .85; }
.row .pi { width: 20px; height: 20px; }
.bar { height: 14px; margin-top: 4px; border-radius: 8px; background: rgba(20, 20, 60, .65); border: 2px solid rgba(255,255,255,.85); position: relative; overflow: hidden; }
.bar-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(#a6ff6b, #2fbf3a); }
.bar span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10px; font-weight: 900; text-shadow: 0 1px 2px #000; }
.btn { padding: 8px 14px; border-radius: 12px; font-weight: 900; background: linear-gradient(#b5ff6a, #2fb43c); border: 2px solid #fff; white-space: nowrap; text-shadow: 0 1px 1px rgba(0,0,0,.4); }
.btn.gray { background: #7a78a0; }
.btn.blue { background: linear-gradient(#7fe0ff, #2f8ff0); }
.btn.big { display: block; width: 100%; padding: 14px; font-size: 18px; margin-top: 10px; }
.btn:active { transform: translateY(2px) scale(.97); }
.ava { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(#ff8ad8, #8a3cff) center/cover; flex: none; display: grid; place-items: center; border: 2px solid #fff; }
.rank { width: 28px; text-align: center; font-weight: 900; font-size: 18px; }
.days { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.day { background: rgba(255,255,255,.14); border-radius: 14px; padding: 8px 4px; text-align: center; font-weight: 900; border: 2px solid transparent; }
.day .big { height: 34px; display: grid; place-items: center; font-size: 26px; }
.day .big .pi { width: 32px; height: 32px; }
.day.got { opacity: .5; }
.day.now { border-color: #ffe46b; background: rgba(255, 228, 107, .25); animation: pulse 1.2s infinite; }
.center { text-align: center; }

#toast { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%) scale(.8); z-index: 95; background: var(--panel); border: 2px solid rgba(255,255,255,.6); padding: 12px 18px; border-radius: 18px; font-weight: 900; text-align: center; opacity: 0; pointer-events: none; transition: .25s; max-width: 86%; }
#toast.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.floaty { position: absolute; pointer-events: none; font-weight: 900; font-size: 22px; z-index: 90; text-shadow: 0 2px 0 rgba(0,0,0,.4); transition: transform 1.2s ease-out, opacity 1.2s; }
.flyico { position: absolute; z-index: 91; width: 34px; height: 34px; pointer-events: none; transition: left .7s cubic-bezier(.5,0,.8,.6), top .7s cubic-bezier(.3,.6,.6,1), transform .7s; }
.flyico svg { width: 100%; height: 100%; }
