/* Nicko's Adventures - illustrated children's world.
   Visual language: warm cream + honey wood + sage + dusty rose + sky.
   Soft rounded forms, dimensional shading, gentle light. Original art. */
* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color: transparent; }
html, body { height:100%; overflow:hidden; }
body {
  font-family:'Baloo 2', ui-rounded, 'Comic Sans MS', system-ui, sans-serif;
  background:#2b1f33; color:#5a3d2b; overscroll-behavior:none;
}
#app { position:fixed; inset:0; overflow:hidden; }
#stage { position:absolute; inset:0; overflow:hidden; touch-action:manipulation; user-select:none; -webkit-user-select:none; cursor:pointer; }

#room-wrap { position:absolute; inset:0; transition:transform .38s ease, opacity .38s ease; }
#room-wrap.slide-out-left { transform:translateX(-60px); opacity:0; }
#room-wrap.slide-out-right { transform:translateX(60px); opacity:0; }
#room-wrap.slide-in-left { animation:slideInLeft .38s ease; }
#room-wrap.slide-in-right { animation:slideInRight .38s ease; }
@keyframes slideInLeft { from { transform:translateX(-60px); opacity:0; } to { transform:none; opacity:1; } }
@keyframes slideInRight { from { transform:translateX(60px); opacity:0; } to { transform:none; opacity:1; } }

#room-bg { position:absolute; inset:0; z-index:0; }
#room-bg svg { width:100%; height:100%; display:block; }
#objects { position:absolute; inset:0; z-index:10; }

.obj {
  position:absolute; transform:translate(-50%,-50%);
  min-width:64px; min-height:64px; cursor:pointer;
  transition:transform .15s ease; pointer-events:auto;
}
.obj svg { width:100%; height:100%; display:block; overflow:visible; }
.obj:active { transform:translate(-50%,-50%) scale(.93); }

/* discovery glow: warm golden halo */
.obj.glow::after {
  content:''; position:absolute; inset:-10px; border-radius:26px;
  border:4px solid rgba(255,205,80,.95);
  box-shadow:0 0 22px 6px rgba(255,205,80,.55), inset 0 0 14px rgba(255,205,80,.4);
  animation:glowPulse 1.4s ease-in-out infinite; pointer-events:none;
}
.obj.glow-soft::after {
  content:''; position:absolute; inset:-7px; border-radius:22px;
  border:3px solid rgba(255,205,80,.5);
  box-shadow:0 0 12px 2px rgba(255,205,80,.3);
  animation:glowPulse 2.2s ease-in-out infinite; pointer-events:none;
}
@keyframes glowPulse { 0%,100% { opacity:.35; transform:scale(.97); } 50% { opacity:1; transform:scale(1.04); } }

/* Doors render first in the DOM (see addDoors) so room objects win taps
   over a door's invisible padding; no z-index boost needed. */
.door .door-arrow { animation:bobArrow 1.6s ease-in-out infinite; }
@keyframes bobArrow { 0%,100% { transform:translateX(0); } 50% { transform:translateX(6px); } }
.door.door-left .door-arrow { animation-name:bobArrowL; }
@keyframes bobArrowL { 0%,100% { transform:translateX(0) scaleX(-1); } 50% { transform:translateX(-6px) scaleX(-1); } }

#dim { position:absolute; inset:0; z-index:15; background:rgba(20,16,48,.66);
  opacity:0; pointer-events:none; transition:opacity .8s ease; }
#dim.on { opacity:1; }
#fx { position:absolute; inset:0; z-index:30; pointer-events:none; overflow:hidden; }

/* ================= Nicko ================= */
#nicko-wrap {
  position:absolute; bottom:5%; left:50%; width:21%; max-width:210px; min-width:132px;
  transform:translateX(-50%); z-index:20; pointer-events:none;
  transition:left .3s linear;
  filter:drop-shadow(0 10px 10px rgba(60,40,20,.22));
}
#nicko-wrap.flip #nicko { transform:scaleX(-1); }
#nicko svg { width:100%; height:auto; display:block; overflow:visible; }
#nicko-wrap.walking #nicko { animation:walkBob .32s ease-in-out infinite; }
@keyframes walkBob { 0%,100% { transform:translateY(0); } 50% { transform:translateY(-7px); } }
#nicko-wrap.walking .leg { animation:legSwing .32s ease-in-out infinite; transform-origin:top center; transform-box:fill-box; }
#nicko-wrap.walking .leg.l2 { animation-delay:.16s; }
@keyframes legSwing { 0%,100% { transform:rotate(14deg); } 50% { transform:rotate(-14deg); } }

/* tail */
#nicko .nko-tail { transform-origin:15% 80%; transform-box:fill-box; animation:tailWag 2.8s ease-in-out infinite; }
@keyframes tailWag { 0%,100% { transform:rotate(-7deg); } 50% { transform:rotate(11deg); } }
#nicko .nko-tail.tail-fast { animation-duration:.7s; }
#nicko .nko-tail.tail-puff { animation:tailPuff .5s ease-in-out infinite; }
@keyframes tailPuff { 0%,100% { transform:scale(1.28) rotate(-10deg); } 50% { transform:scale(1.34) rotate(8deg); } }

/* ears */
#nicko .nko-ear { transform-box:fill-box; transition:transform .25s ease; }
#nicko .nko-ear-l { transform-origin:80% 90%; }
#nicko .nko-ear-r { transform-origin:20% 90%; }
#nicko .ears-up .nko-ear-l, #nicko .ears-up .nko-ear-r { transform:rotate(0); }
#nicko .ears-perk .nko-ear-l { transform:rotate(-14deg); }
#nicko .ears-perk .nko-ear-r { transform:rotate(10deg); }
#nicko .ears-flat .nko-ear-l { transform:rotate(-52deg); }
#nicko .ears-flat .nko-ear-r { transform:rotate(52deg); }
#nicko .ears-flop .nko-ear-l { transform:rotate(-30deg) translateY(4px); }
#nicko .ears-flop .nko-ear-r { transform:rotate(30deg) translateY(4px); }
#nicko .ears-side .nko-ear-l { transform:rotate(-38deg); }
#nicko .ears-side .nko-ear-r { transform:rotate(38deg); }

/* head tilts */
#nicko .nko-head { transform-box:fill-box; transform-origin:50% 70%; transition:transform .25s ease; }
#nicko .nko-head.tilt-1 { transform:rotate(9deg); }
#nicko .nko-head.tilt--1 { transform:rotate(-9deg); }
#nicko .nko-head.tilt-back { transform:rotate(-7deg) translateY(-5px); }

/* body animations */
#nicko-wrap.happy-jump #nicko { animation:happyJump .55s ease; }
@keyframes happyJump { 0% { transform:translateY(0) scale(1); } 35% { transform:translateY(-36px) scale(1.06,1.1); } 70% { transform:translateY(0) scale(1.08,.9); } 100% { transform:none; } }
#nicko-wrap.startled #nicko { animation:startled .5s ease; }
@keyframes startled { 0% { transform:translateY(0) scale(1); } 25% { transform:translateY(-28px) scale(1.1); } 60% { transform:translateY(0) scale(1); } 100% { transform:none; } }
#nicko-wrap.pounce #nicko { animation:pounce .6s ease; }
@keyframes pounce { 0% { transform:translateX(0) translateY(0) scale(1); } 40% { transform:translateX(46px) translateY(-30px) scale(1.12,.9); } 75% { transform:translateX(80px) translateY(4px) scale(1.15,.82); } 100% { transform:none; } }
#nicko-wrap.flip.pounce #nicko { animation-name:pounceL; }
@keyframes pounceL { 0% { transform:scaleX(-1); } 40% { transform:scaleX(-1) translateX(46px) translateY(-30px); } 75% { transform:scaleX(-1) translateX(80px) translateY(4px); } 100% { transform:scaleX(-1); } }
#nicko-wrap.dance #nicko { animation:dance .5s ease-in-out 3; }
@keyframes dance { 0%,100% { transform:rotate(0); } 25% { transform:rotate(-9deg) translateY(-6px); } 75% { transform:rotate(9deg) translateY(-6px); } }
#nicko-wrap.shakeoff #nicko { animation:shakeoff .5s ease; }
@keyframes shakeoff { 0%,100% { transform:rotate(0); } 20% { transform:rotate(-14deg); } 40% { transform:rotate(12deg); } 60% { transform:rotate(-10deg); } 80% { transform:rotate(8deg); } }
#nicko-wrap.slip #nicko { animation:slip .7s ease; }
@keyframes slip { 0% { transform:translateX(0) rotate(0); } 40% { transform:translateX(60px) rotate(18deg); } 70% { transform:translateX(90px) rotate(-8deg); } 100% { transform:none; } }
#nicko-wrap.flip.slip #nicko { animation-name:slipL; }
@keyframes slipL { 0% { transform:scaleX(-1); } 40% { transform:scaleX(-1) translateX(60px) rotate(18deg); } 70% { transform:scaleX(-1) translateX(90px) rotate(-8deg); } 100% { transform:scaleX(-1); } }
#nicko-wrap.wiggle #nicko { animation:wiggle .45s ease 2; }
@keyframes wiggle { 0%,100% { transform:rotate(0); } 25% { transform:rotate(-7deg) translateY(-4px); } 75% { transform:rotate(7deg) translateY(-4px); } }
#nicko-wrap.crouch #nicko { animation:crouchHold .8s ease; }
@keyframes crouchHold { 0% { transform:scale(1); } 35%,75% { transform:scale(1.18,.72) translateY(10px); } 100% { transform:scale(1); } }
#nicko-wrap.stretch #nicko { animation:stretchOut 1.1s ease; }
@keyframes stretchOut { 0%,100% { transform:scale(1); } 40% { transform:scale(1.28,.78) translateY(8px); } }
#nicko-wrap.curl #nicko { animation:curlUp 1s ease forwards; }
@keyframes curlUp { to { transform:scale(.86) rotate(-4deg) translateY(10px); } }
#nicko .nko-dirt { display:none; }
#nicko .nightcap-g { display:none; }
#nicko-wrap.nightcap .nightcap-g { display:block; }

/* emote bubble (secondary to the face system) */
#emote {
  position:absolute; left:50%; bottom:100%; transform:translateX(-50%);
  font-size:clamp(30px, 6vw, 48px); line-height:1;
  background:#fffdf7; border-radius:50%; width:1.7em; height:1.7em;
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 6px 16px rgba(60,40,20,.28); border:3px solid #ffd166;
  animation:emotePop .3s ease; z-index:21; pointer-events:none;
}
#emote.hidden { display:none; }
@keyframes emotePop { from { transform:translateX(-50%) scale(.3); } to { transform:translateX(-50%) scale(1); } }

/* ================= HUD ================= */
#hud { position:absolute; top:0; left:0; right:0; z-index:40; display:flex;
  justify-content:space-between; align-items:flex-start; padding:calc(10px + env(safe-area-inset-top)) 12px 0; pointer-events:none; }
#points-pill {
  pointer-events:auto; background:rgba(255,253,247,.96); border:3px solid #ffd166;
  border-radius:999px; padding:8px 18px; font-size:24px; font-weight:800; color:#8a5a1e;
  box-shadow:0 4px 14px rgba(60,40,20,.22), inset 0 2px 0 #fff; display:flex; align-items:center; gap:6px;
}
#points-pill.bump { animation:pillBump .4s ease; }
#points-pill.goldbump { animation:goldBump .8s ease; border-color:#ffdf8a; }
@keyframes pillBump { 0% { transform:scale(1); } 40% { transform:scale(1.18); } 100% { transform:scale(1); } }
@keyframes goldBump { 0% { transform:scale(1); } 30% { transform:scale(1.28) rotate(-3deg); } 60% { transform:scale(1.28) rotate(3deg); } 100% { transform:scale(1); } }
#hud-buttons { display:flex; gap:10px; pointer-events:auto; }
#hud-buttons button {
  width:56px; height:56px; border-radius:20px; font-size:26px; border:3px solid #fff;
  background:rgba(255,253,247,.96); box-shadow:0 4px 14px rgba(60,40,20,.22), inset 0 2px 0 #fff;
  cursor:pointer; display:flex; align-items:center; justify-content:center; position:relative; color:#8a5a1e;
}
#hud-buttons button:active { transform:scale(.92); }
#coll-count { position:absolute; bottom:-8px; right:-8px; background:#ffd166; color:#8a5a1e;
  font-size:12px; font-weight:800; border-radius:999px; padding:1px 7px; border:2px solid #fff; }

/* needs: soft badges, icon-first */
#needs-bar { display:flex; gap:6px; align-items:center; }
.need { display:flex; flex-direction:column; align-items:center; gap:3px;
  background:rgba(255,253,247,.92); border-radius:16px; padding:5px 8px; min-width:44px;
  border:2.5px solid rgba(190,150,105,.5); box-shadow:0 3px 8px rgba(60,40,20,.14);
  transition:border-color .4s ease, transform .3s ease; }
.need-icon { font-size:19px; line-height:1; filter:saturate(1.1); }
.need-fill { width:36px; height:7px; border-radius:4px; background:#EDE0CB; overflow:hidden; box-shadow:inset 0 1px 3px rgba(60,40,20,.18); }
.need-fill span { display:block; height:100%; border-radius:4px; background:linear-gradient(180deg,#a8e08a,#7cc46a); transition:width .6s ease; }
.need.mid .need-fill span { background:linear-gradient(180deg,#ffd166,#f0a93c); }
.need.low { border-color:#ff8a70; animation:needWobble .6s ease; }
.need.low .need-fill span { background:linear-gradient(180deg,#ff9a7e,#f0664a); }
@keyframes needWobble { 0%,100% { transform:rotate(0); } 25% { transform:rotate(-6deg); } 75% { transform:rotate(6deg); } }

/* ================= toasts ================= */
#toast-wrap { position:absolute; left:0; right:0; top:calc(84px + env(safe-area-inset-top)); bottom:auto;
  z-index:50; display:flex; flex-direction:column; align-items:center; gap:8px; pointer-events:none; }
.toast {
  background:rgba(58,40,30,.94); color:#fff8ec; font-weight:700; font-size:19px;
  padding:10px 24px; border-radius:999px; border:3px solid #ffd166;
  box-shadow:0 8px 20px rgba(0,0,0,.32); animation:toastIn .3s ease; max-width:88vw; text-align:center;
  pointer-events:auto; cursor:pointer; display:flex; align-items:center; gap:10px;
}
.toast.out { animation:toastOut .3s ease forwards; }
@keyframes toastIn { from { transform:translateY(24px); opacity:0; } to { transform:none; opacity:1; } }
@keyframes toastOut { to { transform:translateY(16px); opacity:0; } }
/* hint bubble extras: speaker button + bouncing marker over the target */
.hint-speak { background:#ffd166; border:none; border-radius:50%; width:44px; height:44px;
  font-size:22px; cursor:pointer; flex:0 0 auto; box-shadow:0 2px 6px rgba(0,0,0,.3); }
.hint-speak:active { transform:scale(.92); }
.hint-marker { position:absolute; top:-34px; left:50%; transform:translateX(-50%);
  font-size:30px; pointer-events:none; z-index:40;
  animation:hintBounce .7s ease-in-out infinite; filter:drop-shadow(0 2px 4px rgba(0,0,0,.3)); }
@keyframes hintBounce { 0%,100% { transform:translateX(-50%) translateY(0); } 50% { transform:translateX(-50%) translateY(-12px); } }

/* ================= FX particles ================= */
.fxp { position:absolute; transform:translate(-50%,-50%); pointer-events:none; z-index:31; }
.fx-sparkle { color:#ffd166; text-shadow:0 0 8px #ffedb0; animation:fxSparkle 1.15s ease forwards; animation-delay:var(--d,0s); }
@keyframes fxSparkle {
  0% { transform:translate(-50%,-50%) scale(.3) rotate(0); opacity:1; }
  100% { transform:translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(var(--s,1)) rotate(40deg); opacity:0; }
}
.fx-bubble { width:var(--s,20px); height:var(--s,20px); border-radius:50%;
  background:radial-gradient(circle at 32% 30%, rgba(255,255,255,.95), rgba(190,225,255,.35) 55%, rgba(160,200,255,.5));
  border:1.5px solid rgba(255,255,255,.7); box-shadow:inset -2px -3px 6px rgba(140,190,255,.35);
  animation:fxBubble 1.7s ease-in forwards; animation-delay:var(--d,0s); }
@keyframes fxBubble {
  0% { transform:translate(-50%,-50%) scale(.5); opacity:0; }
  15% { opacity:.95; }
  100% { transform:translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.1); opacity:0; }
}
.fx-heart { animation:fxFloat 1.3s ease forwards; animation-delay:var(--d,0s); }
@keyframes fxFloat {
  0% { transform:translate(-50%,-50%) scale(.5); opacity:1; }
  100% { transform:translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.15); opacity:0; }
}
.fx-puff { width:var(--s,20px); height:var(--s,20px); border-radius:50%; background:var(--tint);
  filter:blur(3px); animation:fxPuff 1s ease forwards; animation-delay:var(--d,0s); }
@keyframes fxPuff {
  0% { transform:translate(-50%,-50%) scale(.5); opacity:.9; }
  100% { transform:translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.7); opacity:0; }
}
.fx-drop { animation:fxDrop .85s ease forwards; animation-delay:var(--d,0s); }
@keyframes fxDrop {
  0% { transform:translate(-50%,-50%) scale(1); opacity:1; }
  100% { transform:translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.7); opacity:0; }
}
.fx-zz { color:#9db4d8; font-weight:800; font-style:italic; text-shadow:0 2px 4px rgba(40,50,90,.3);
  animation:fxZ 2.1s ease forwards; }
@keyframes fxZ {
  0% { transform:translate(-50%,-50%) scale(.6); opacity:0; }
  20% { opacity:.95; }
  100% { transform:translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.3); opacity:0; }
}
.fx-pip { animation:fxFloat 1.15s ease forwards; filter:drop-shadow(0 2px 3px rgba(120,80,20,.35)); }
.fx-leaf { animation:fxLeaf 2.5s ease-in-out forwards; }
@keyframes fxLeaf {
  0% { transform:translate(-50%,-50%) rotate(0); opacity:1; }
  100% { transform:translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(160deg); opacity:0; }
}
/* golden glow that gathers before the print appears */
.fx-glow { width:130px; height:130px; border-radius:50%; transform:translate(-50%,-50%);
  background:radial-gradient(circle, rgba(255,215,120,.95), rgba(255,190,80,.45) 55%, transparent 72%);
  animation:fxGlow 2.2s ease forwards; }
@keyframes fxGlow {
  0% { transform:translate(-50%,-50%) scale(.3); opacity:0; }
  25% { opacity:1; }
  70% { transform:translate(-50%,-50%) scale(1.15); opacity:1; }
  100% { transform:translate(-50%,-50%) scale(1.3); opacity:0; }
}
/* the print itself */
.fx-goldprint { font-size:74px; transform:translate(-50%,-50%);
  filter:drop-shadow(0 0 18px #ffd166) drop-shadow(0 6px 8px rgba(120,70,10,.4));
  animation:goldPop .55s cubic-bezier(.2,1.6,.4,1) forwards; }
@keyframes goldPop { 0% { transform:translate(-50%,-50%) scale(0) rotate(-18deg); } 100% { transform:translate(-50%,-50%) scale(1) rotate(0); } }
.fx-goldprint.rise { animation:goldRise 1.6s ease-in forwards; }
@keyframes goldRise {
  0% { transform:translate(-50%,-50%) scale(1); opacity:1; }
  100% { transform:translate(-50%,-260%) scale(1.25); opacity:0; }
}
/* sticker achievement pop */
.fx-sticker {
  position:absolute; left:50%; top:30%; transform:translate(-50%,-50%) scale(0) rotate(-6deg);
  background:#fffdf7; border:5px solid #ffd166; border-radius:26px; padding:18px 30px;
  text-align:center; box-shadow:0 16px 44px rgba(60,40,20,.4);
  animation:stickerIn 2.6s ease forwards; max-width:84vw; z-index:56;
}
@keyframes stickerIn {
  0% { transform:translate(-50%,-50%) scale(0) rotate(-14deg); }
  14% { transform:translate(-50%,-50%) scale(1.12) rotate(3deg); }
  22% { transform:translate(-50%,-50%) scale(1) rotate(0); }
  80% { transform:translate(-50%,-50%) scale(1); opacity:1; }
  100% { transform:translate(-50%,-62%) scale(.92); opacity:0; }
}
.fx-sticker .st-ic { font-size:58px; }
.fx-sticker .st-nm { font-size:23px; font-weight:800; color:#8a5a1e; }

/* legacy hooks kept for compatibility */
.float-text {
  position:absolute; font-size:30px; font-weight:800; color:#fff8dc;
  text-shadow:0 2px 0 #b57e1b, 0 4px 10px rgba(0,0,0,.35);
  animation:floatUp 1.1s ease forwards; pointer-events:none;
}
@keyframes floatUp { from { transform:translate(-50%,0); opacity:1; } to { transform:translate(-50%,-70px); opacity:0; } }
.sparkle { position:absolute; font-size:26px; animation:sparkleFly 1s ease forwards; pointer-events:none; }
@keyframes sparkleFly { 0% { transform:translate(-50%,-50%) scale(.4); opacity:1; } 100% { transform:translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.2); opacity:0; } }
.splash-drop { position:absolute; width:10px; height:14px; border-radius:50%; background:#7ecbf2;
  animation:dropFly .8s ease forwards; pointer-events:none; }
@keyframes dropFly { 0% { transform:translate(-50%,-50%); opacity:1; } 100% { transform:translate(calc(-50% + var(--dx)), var(--dy)); opacity:0; } }

/* ================= modal ================= */
#modal-wrap { position:absolute; inset:0; z-index:60; display:flex; align-items:center; justify-content:center;
  background:rgba(43,28,40,.55); backdrop-filter:blur(2px); padding:18px; }
#modal-wrap.hidden { display:none; }
.modal-card {
  background:#fffdf7; border:4px solid #ffd166; border-radius:30px; padding:24px;
  max-width:520px; width:100%; max-height:82vh; overflow:auto; text-align:center;
  box-shadow:0 22px 60px rgba(30,15,5,.45), inset 0 2px 0 #fff; animation:modalIn .32s ease;
}
@keyframes modalIn { from { transform:scale(.85) translateY(20px); opacity:0; } to { transform:none; opacity:1; } }
.modal-card h2 { color:#8a5a1e; font-size:30px; margin-bottom:6px; }
.modal-card p.sub { color:#b3814d; font-weight:600; margin-bottom:14px; font-size:17px; }
/* golden paw celebration card */
.modal-card.gold-card { border-color:#ffdf8a; background:linear-gradient(180deg,#fffbe8,#fff3cf);
  box-shadow:0 0 44px 10px rgba(255,205,80,.55), 0 22px 60px rgba(30,15,5,.45); }
.modal-card.gold-card .big-paw { font-size:84px; animation:goldBump .8s ease;
  filter:drop-shadow(0 0 16px #ffd166); }
/* sticker-book grids */
.collect-grid { display:grid; grid-template-columns:repeat(4, 1fr); gap:10px; margin:12px 0; }
.collect-slot { background:#f6ecd6; border-radius:20px; padding:10px 4px; border:3px solid #e9d3a3;
  box-shadow:inset 0 2px 5px rgba(120,80,20,.1); }
.collect-slot .ci { font-size:34px; filter:grayscale(1); opacity:.32; }
.collect-slot.found { background:#fff6d8; border-color:#ffd166; box-shadow:0 0 14px rgba(255,205,80,.5); transform:rotate(-2deg); }
.collect-slot.found:nth-child(even) { transform:rotate(2deg); }
.collect-slot.found .ci { filter:none; opacity:1; }
.collect-slot .cn { font-size:11px; font-weight:700; color:#8a5a1e; margin-top:4px; line-height:1.2; }
.collect-slot .ch { font-size:10px; color:#b3814d; font-weight:600; line-height:1.25; margin-top:2px; }
.achieve-row { display:flex; align-items:center; gap:12px; background:#fff; border:3px solid #f0dcae;
  border-radius:20px; padding:10px 14px; margin:8px 0; text-align:left; box-shadow:0 2px 6px rgba(120,80,20,.08); }
.achieve-row.locked { opacity:.55; filter:grayscale(.8); }
.achieve-row .ai { font-size:38px; }
.achieve-row .an { font-weight:800; color:#8a5a1e; font-size:18px; }
.achieve-row .ad { font-weight:600; color:#b3814d; font-size:14px; }
.modal-close {
  margin-top:14px; background:linear-gradient(180deg,#ffa76b,#f08a4b); color:#fff; border:none; border-radius:999px;
  font-family:inherit; font-size:20px; font-weight:800; padding:12px 44px; cursor:pointer;
  box-shadow:0 5px 0 #cf6a35, 0 8px 16px rgba(200,110,50,.35);
}
.modal-close:active { transform:translateY(3px); box-shadow:0 1px 0 #cf6a35; }

.hot-badge {
  position:absolute; font-size:30px; font-weight:800; color:#fff; background:#ff5a3c;
  border:4px solid #fff; border-radius:16px; padding:4px 16px;
  animation:hotShake .4s ease 3; pointer-events:none; z-index:31;
  box-shadow:0 6px 16px rgba(0,0,0,.3);
}
@keyframes hotShake { 0%,100% { transform:translate(-50%,-50%) rotate(-4deg); } 50% { transform:translate(-50%,-50%) rotate(4deg); } }
.heat-wave { position:absolute; width:70px; height:90px; pointer-events:none; z-index:31;
  background:radial-gradient(ellipse at center, rgba(255,120,60,.55), transparent 70%);
  border-radius:50%; animation:heatRise 1s ease infinite; filter:blur(4px); }
@keyframes heatRise { 0% { transform:translateY(10px) scaleX(1); opacity:.8; } 100% { transform:translateY(-26px) scaleX(1.5); opacity:0; } }

#selftest-results { position:absolute; inset:auto 0 0 0; z-index:100; background:#111; color:#0f0;
  font-family:monospace; font-size:12px; padding:10px; max-height:40vh; overflow:auto; white-space:pre-wrap; }
#selftest-results.hidden { display:none; }
#selftest-results .fail { color:#f66; }

@media (min-width:900px) {
  #nicko-wrap { width:14%; }
  .obj { min-width:80px; min-height:80px; }
}

/* Short landscape screens (phones turned sideways): the fixed 64px minimum
   would overlap the tightly spaced bottom-row toys, so targets shrink
   slightly while staying generous for small fingers. */
@media (orientation:landscape) and (max-height:520px) {
  .obj { min-width:52px; min-height:52px; }
}

/* ---------- object animation helpers ---------- */
.obj.bounce { animation:objBounce .6s ease; }
@keyframes objBounce {
  0%,100% { transform:translate(-50%,-50%); }
  30% { transform:translate(-50%,-64%); }
  55% { transform:translate(-50%,-44%); }
  75% { transform:translate(-50%,-54%); }
}
.obj.wobble svg { animation:objWobbleInner .6s ease; transform-origin:50% 90%; }
@keyframes objWobbleInner {
  0%,100% { transform:rotate(0); }
  25% { transform:rotate(-9deg); }
  50% { transform:rotate(7deg); }
  75% { transform:rotate(-4deg); }
}
.obj.tumble { animation:objTumble .55s ease forwards; }
@keyframes objTumble {
  to { transform:translate(-50%,-6%) rotate(64deg); opacity:0; }
}
.obj.swish .curtain-l { animation:swishL .7s ease; transform-origin:top center; }
.obj.swish .curtain-r { animation:swishR .7s ease; transform-origin:top center; }
@keyframes swishL { 0%,100% { transform:rotate(0); } 40% { transform:rotate(16deg); } }
@keyframes swishR { 0%,100% { transform:rotate(0); } 40% { transform:rotate(-16deg); } }
.obj .wings { animation:wingFlap .36s ease-in-out infinite; transform-origin:50% 50%; transform-box:fill-box; }
@keyframes wingFlap { 0%,100% { transform:scaleX(1); } 50% { transform:scaleX(.55); } }
.obj.bloom .flower { animation:bloomGrow 1s ease; transform-origin:50% 100%; transform-box:fill-box; }
@keyframes bloomGrow { 0% { transform:scale(.7); } 60% { transform:scale(1.25); } 100% { transform:scale(1); } }
/* Watered flowers stay visibly grown: a lasting consequence. */
.obj.grown .flower { transform:scale(1.18); transform-origin:50% 100%; transform-box:fill-box; }
.obj.tv-on .tv-screen { animation:tvStatic 1.1s steps(2) infinite; }
@keyframes tvStatic { 0% { fill:#FF6B5E; } 25% { fill:#6BA8E8; } 50% { fill:#8FD16F; } 75% { fill:#C49BE8; } }
.obj .lamp-glow { transition:opacity .4s ease; }

/* ambient life: applied inside room SVGs */
.amb-sway { animation:ambSway 3.4s ease-in-out infinite; transform-origin:50% 100%; transform-box:fill-box; }
@keyframes ambSway { 0%,100% { transform:rotate(-3deg); } 50% { transform:rotate(3deg); } }
.amb-drift { animation:ambDrift 26s linear infinite; }
@keyframes ambDrift { from { transform:translateX(-12%); } to { transform:translateX(112%); } }
.amb-bob { animation:ambBob 2.8s ease-in-out infinite; }
@keyframes ambBob { 0%,100% { transform:translateY(0); } 50% { transform:translateY(-7px); } }
.amb-twinkle { animation:ambTwinkle 2.4s ease-in-out infinite; }
@keyframes ambTwinkle { 0%,100% { opacity:.35; } 50% { opacity:1; } }
.amb-flicker { animation:ambFlicker 4s ease-in-out infinite; }
@keyframes ambFlicker { 0%,100% { opacity:.85; } 50% { opacity:1; } 70% { opacity:.92; } }

/* ---------- thought bubble ---------- */
#thought {
  position:absolute; bottom:112%; left:50%; transform:translateX(-50%) scale(.4);
  min-width:44px; min-height:44px; display:flex; align-items:center; justify-content:center;
  background:#fffdf7; border:3px solid #a06a42; border-radius:20px; font-size:26px; padding:4px 10px;
  opacity:0; transition:opacity .25s ease, transform .25s ease; z-index:5; pointer-events:none;
  box-shadow:0 4px 10px rgba(60,40,20,.2);
}
#thought::after {
  content:''; position:absolute; bottom:-12px; left:50%; transform:translateX(-50%);
  border:7px solid transparent; border-top-color:#a06a42;
}
#thought.on { opacity:1; transform:translateX(-50%) scale(1); }

/* ---------- toy chest (toybox) ---------- */
#tray { position:absolute; left:10px; bottom:10px; z-index:40; display:flex; flex-direction:column; align-items:flex-start; gap:6px; }
.tray-handle { width:58px; height:58px; border-radius:20px 20px 24px 24px; font-size:30px;
  display:flex; align-items:center; justify-content:center; cursor:pointer; color:#fff;
  background:linear-gradient(180deg,#c98d4e,#a56a32); border:3px solid #7c4f22;
  box-shadow:0 4px 0 #7c4f22, 0 8px 16px rgba(60,40,20,.3), inset 0 2px 0 rgba(255,255,255,.35); }
.tray-handle:active { transform:translateY(2px); box-shadow:0 2px 0 #7c4f22; }
.tray-items { display:flex; gap:8px; background:rgba(255,253,247,.97); border-radius:18px; padding:10px;
  border:3px solid #c98d4e; box-shadow:0 6px 18px rgba(60,40,20,.25); max-width:72vw; overflow-x:auto; }
.tray-items.hidden { display:none; }
.tray-item { display:flex; flex-direction:column; align-items:center; gap:2px; background:#fff6e6;
  border:2.5px solid #e9d3a3; border-radius:14px; padding:8px 10px; cursor:pointer; min-width:64px;
  box-shadow:0 2px 5px rgba(120,80,20,.12); }
.tray-item:active { transform:scale(.92); }
.tray-item.worn { border-color:#7cc46a; background:#eafbDD; box-shadow:0 0 10px rgba(124,196,106,.5); }
.tray-icon { font-size:26px; line-height:1; }
.tray-name { font-size:11px; font-weight:700; color:#7c5a35; white-space:nowrap; }
.tray-empty { font-size:13px; font-weight:700; color:#a5875f; padding:8px 12px; }

/* ---------- drag & drop ---------- */
.obj { touch-action:none; }
.obj.draggable { cursor:grab; z-index:2; }
.obj.draggable::after { content:''; position:absolute; left:50%; bottom:-3px; transform:translateX(-50%);
  width:36px; height:9px; border-radius:50%; background:rgba(120,80,40,.25); filter:blur(1px); }
.obj.draggable:not(.dragging) { animation:dragHint 2.6s ease-in-out infinite; }
@keyframes dragHint { 0%,100% { filter:drop-shadow(0 3px 3px rgba(60,40,20,.18)); } 50% { filter:drop-shadow(0 7px 7px rgba(60,40,20,.3)); } }
.obj.dragging { opacity:.95; filter:drop-shadow(0 18px 14px rgba(40,25,10,.38)); z-index:60 !important; pointer-events:none; }
.obj.dragging svg { transform:scale(1.12) rotate(-3deg); }
.obj.drag-ghost { opacity:.25; filter:none; }
.obj.drop-target { outline:3px dashed rgba(255,182,46,.8); outline-offset:5px; border-radius:14px; }
.obj.drop-hot { outline:4px solid #ffb62e; outline-offset:5px; border-radius:14px;
  box-shadow:0 0 18px 4px rgba(255,182,46,.55); animation:pillBump .35s ease; }
.carry-dot { position:absolute; z-index:61; font-size:30px; pointer-events:none;
  filter:drop-shadow(0 4px 6px rgba(0,0,0,.25)); }

/* ---------- misc hooks ---------- */
.obj.climb { animation:climbIn .6s ease; }
@keyframes climbIn { 0% { transform:none; opacity:1; } 100% { transform:translateY(-30px) scale(.7); opacity:0; } }
.obj.water-on .water-stream { opacity:1; }
.obj.water-on { animation:pillBump .4s ease; }
.fridge-open { filter:brightness(1.06); }
#stage { user-select:none; -webkit-user-select:none; }

/* ---------- mobile ---------- */
@media (max-width:600px) {
  #hud { flex-wrap:wrap; row-gap:6px; }
  #needs-bar { order:3; flex-basis:100%; justify-content:center; gap:4px; }
  /* hint bubbles sit below the wrapped needs bar, never over it */
  #toast-wrap { top:calc(138px + env(safe-area-inset-top)); }
  .need { min-width:36px; padding:4px 6px; }
  .need-fill { width:28px; }
  .tray-handle { width:52px; height:52px; font-size:26px; }
  #thought { font-size:22px; min-width:38px; min-height:38px; }
  #nicko-wrap { min-width:140px; }
  #points-pill { font-size:20px; padding:7px 14px; }
  #hud-buttons { gap:8px; }
  #hud-buttons button { width:46px; height:46px; font-size:22px; border-radius:17px; }
}

/* ================= Hero Hideout: code screen + parent gate ================= */
.code-slots { display:flex; justify-content:center; gap:12px; margin:14px 0; }
.code-slot { width:64px; height:64px; border-radius:18px; border:3px dashed #C9A86A;
  background:#FFFDF7; display:flex; align-items:center; justify-content:center; font-size:36px; }
.code-slot.filled { border-style:solid; border-color:#FFD166; background:#FFF8E6; }
.code-slots.wiggle { animation:codeWiggle .55s ease; }
@keyframes codeWiggle { 0%,100% { transform:translateX(0); } 20% { transform:translateX(-10px); }
  40% { transform:translateX(9px); } 60% { transform:translateX(-6px); } 80% { transform:translateX(4px); } }
.code-grid { display:grid; grid-template-columns:repeat(4, 1fr); gap:10px; margin:6px 0 12px; }
.code-btn { aspect-ratio:1; border-radius:20px; border:3px solid #FFD166; background:#FFFDF7;
  font-size:38px; cursor:pointer; box-shadow:0 4px 10px rgba(60,40,20,.18); }
.code-btn:active { transform:scale(.93); }
.code-undo { background:#F3E6D2; }
.grownups-link { display:block; margin:4px auto 0; background:none; border:none; color:#8A7A66;
  font-size:14px; text-decoration:underline; cursor:pointer; padding:10px; }
.gate-grid { display:grid; grid-template-columns:repeat(3, 1fr); gap:12px; margin:14px 0; }
.gate-btn { aspect-ratio:1.4; border-radius:18px; border:3px solid #C9A86A; background:#FFFDF7;
  font-size:34px; font-weight:800; color:#5A3D2B; cursor:pointer; }
.gate-btn:active { transform:scale(.94); }

/* ================= Hero Hideout: badges ================= */
.badge-medal { width:100%; aspect-ratio:1; border-radius:50%;
  background:radial-gradient(circle at 35% 30%, #E8DCC4, #B8A888);
  border:4px solid #C9A227; display:flex; align-items:center; justify-content:center;
  filter:grayscale(1); opacity:.45; transition:all .35s ease; position:relative;
  box-shadow:0 0 0 3px rgba(201,162,39,.35), 0 4px 10px rgba(60,40,20,.25); }
.badge-medal .badge-icon { font-size:44px; }
.obj.lit .badge-medal, .badge-medal.lit { filter:none; opacity:1; border-color:#FFD166;
  background:radial-gradient(circle at 35% 30%, #FFF3D0, #F7C873);
  box-shadow:0 0 0 3px rgba(255,209,102,.9), 0 0 22px rgba(255,209,102,.85); }
.badge-medal.mystery { filter:none; opacity:1; border-color:#FFD166;
  background:radial-gradient(circle at 35% 30%, #FFF8E6, #E8C98F);
  animation:mysteryPulse 1.6s ease-in-out infinite; }
.badge-medal.mystery .badge-icon { font-size:52px; color:#B57E1B; font-weight:900; }
@keyframes mysteryPulse { 0%,100% { box-shadow:0 0 10px rgba(255,209,102,.5); }
  50% { box-shadow:0 0 26px rgba(255,209,102,.95); } }
.obj.revealed .badge-medal { animation:none; }
/* ---- Hero Hideout: magical polish ---- */
.fl { opacity:.18; transition:opacity .45s ease; }
.fl.on { opacity:1; animation:flTwinkle 2.6s ease-in-out infinite; }
@keyframes flTwinkle { 0%,100% { opacity:1; } 50% { opacity:.55; } }
.mote { animation:moteDrift 7s ease-in-out infinite; }
@keyframes moteDrift { 0%,100% { transform:translateY(0); opacity:.35; }
  50% { transform:translateY(-26px); opacity:1; } }
.hideout-aura { animation:auraPulse 5s ease-in-out infinite; }
@keyframes auraPulse { 0%,100% { opacity:.28; } 50% { opacity:.45; } }
.hero-star { flex-direction:column; }
.hero-ribbon { width:44px; height:26px; margin-bottom:2px;
  background:linear-gradient(180deg, #E84A5C, #C23344);
  clip-path:polygon(0 0, 100% 0, 100% 70%, 50% 100%, 0 70%); }
.hero-label { font-size:11px; font-weight:800; color:#8A5A1B; margin-top:2px; }
/* unlocked hatch: padlock disappears */
.obj.unlocked .hatch-lock { display:none; }
