/* Whack-a-Ghost. Layout reference is the screen height: top 67% decorative, bottom 33% interactive. */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #12062b; color: #fff; font-family: "Chalkboard SE","Comic Sans MS","Marker Felt","Arial Rounded MT Bold","Trebuchet MS",Arial,sans-serif; font-weight: 900;
  overscroll-behavior: none; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; cursor: default;
}
img, svg { -webkit-user-drag: none; user-drag: none; }
#app { position: fixed; top: 0; right: 0; bottom: 0; left: 0; overflow: hidden; }
#scene { position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
#ambient, #title, .hud, #big, #celebrate, #fx, #diag { pointer-events: none; }

/* ---------- scene animation ---------- */
#stars circle { animation: twinkle 3s ease-in-out infinite; }
@keyframes twinkle { 0%,100% { opacity: .25; } 50% { opacity: 1; } }
.cloud { animation: drift 70s linear infinite; }
.c2 { animation-duration: 95s; animation-delay: -40s; } .c3 { animation-duration: 120s; animation-delay: -70s; }
@keyframes drift { from { transform: translateX(-700px); } to { transform: translateX(900px); } }
.win { animation: windowGlow 3.4s ease-in-out infinite; }
.w2 { animation-delay: -1.1s; } .w3 { animation-delay: -2.2s; } .w4 { animation-delay: -.6s; }
@keyframes windowGlow { 0%,100% { opacity: 1; } 45% { opacity: .72; } 60% { opacity: .95; } }
.flick { animation: flicker 1.7s steps(1, end) infinite; }
.f2 { animation-duration: 2.3s; animation-delay: -.7s; } .f3 { animation-duration: 1.4s; animation-delay: -1.1s; }
@keyframes flicker { 0% { opacity: .85; } 20% { opacity: .55; } 35% { opacity: .95; } 60% { opacity: .65; } 80% { opacity: .9; } }

#ambient { position: absolute; top: 0; right: 0; bottom: 0; left: 0; overflow: hidden; }
.fog { position: absolute; left: -50%; width: 200%; border-radius: 50%; background: radial-gradient(ellipse at center, rgba(210,190,255,.28), rgba(210,190,255,0) 68%); animation: fogMove 60s linear infinite; }
.fog1 { top: 50%; height: 22%; } .fog2 { top: 56%; height: 16%; animation-duration: 85s; animation-direction: reverse; opacity: .8; } .fog3 { top: 44%; height: 20%; animation-duration: 110s; opacity: .55; }
@keyframes fogMove { from { transform: translateX(-12%); } to { transform: translateX(12%); } }
.bat { position: absolute; width: 7vw; height: 3.5vw; left: -10vw; animation: batFly 22s linear infinite; }
.bat .wing { transform-box: fill-box; animation: flap .28s ease-in-out infinite alternate; }
.bat .wl { transform-origin: 100% 50%; } .bat .wr { transform-origin: 0% 50%; }
@keyframes flap { from { transform: scaleY(1); } to { transform: scaleY(.35); } }
@keyframes batFly { 0% { transform: translate(0,0); } 25% { transform: translate(35vw,-4vh); } 50% { transform: translate(70vw,3vh); } 75% { transform: translate(105vw,-3vh); } 100% { transform: translate(125vw,2vh); } }
.b1 { top: 12%; } .b2 { top: 30%; animation-duration: 28s; animation-delay: -8s; width: 5vw; height: 2.5vw; }
.b3 { top: 20%; animation-duration: 19s; animation-delay: -14s; } .b4 { top: 38%; animation-duration: 34s; animation-delay: -20s; width: 4vw; height: 2vw; } .b5 { top: 8%; animation-duration: 25s; animation-delay: -3s; width: 4.5vw; height: 2.25vw; }
.dghost { position: absolute; width: 7vh; height: 9.1vh; opacity: .88; left: -12vw; filter: drop-shadow(0 0 1.2vh rgba(200,180,255,.7)); animation: ghostFloat 40s linear infinite; }
.dg1 { top: 24%; } .dg2 { top: 40%; animation-duration: 52s; animation-delay: -18s; width: 9vh; height: 11.7vh; } .dg3 { top: 15%; animation-duration: 46s; animation-delay: -30s; animation-direction: reverse; } .dg4 { top: 47%; animation-duration: 60s; animation-delay: -45s; width: 6vh; height: 7.8vh; }
@keyframes ghostFloat { 0% { transform: translate(0,0) rotate(-4deg); } 25% { transform: translate(28vw,-3vh) rotate(4deg); } 50% { transform: translate(60vw,2vh) rotate(-4deg); } 75% { transform: translate(92vw,-3vh) rotate(4deg); } 100% { transform: translate(120vw,0) rotate(-4deg); } }
.dcandy { position: absolute; width: 5vw; height: 2.5vw; animation: candyBob 5s ease-in-out infinite; opacity: .95; }
.dc1 { left: 6%; top: 12%; } .dc2 { left: 30%; top: 5%; animation-delay: -1s; transform: rotate(20deg); } .dc3 { left: 68%; top: 41%; animation-delay: -2s; } .dc4 { left: 90%; top: 46%; animation-delay: -3s; } .dc5 { left: 47%; top: 45%; animation-delay: -4s; }
@keyframes candyBob { 0%,100% { transform: translateY(0) rotate(-12deg); } 50% { transform: translateY(-1.8vh) rotate(12deg); } }

/* ---------- title + HUD (decorative area) ---------- */
#title { position: absolute; top: 1.5vh; left: 0; right: 0; text-align: center; animation: bob 4s ease-in-out infinite; }
#title h1 { margin: 0; font-size: 10vh; line-height: 1.05; letter-spacing: .04em; color: #ffa11f; -webkit-text-stroke: .8vh #3b0f6b; paint-order: stroke fill; text-shadow: 0 .8vh 0 #7a2bc2, 0 0 4vh rgba(255,150,30,.85); }
#title p { margin: .6vh 0 0; font-size: 3.2vh; letter-spacing: .28em; color: #8dff6b; -webkit-text-stroke: .35vh #1c0a3c; paint-order: stroke fill; text-shadow: 0 0 2vh rgba(120,255,90,.9); }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(1vh); } }
.hud { position: absolute; opacity: 0; transition: opacity .3s; }
body[data-state="PLAYING"] .hud, body[data-state="VICTORY"] #score { opacity: 1; }
#score { left: 3vw; top: 18vh; min-width: 19vw; padding: 1.2vh 2vw 1.6vh; text-align: center; border: .7vh solid #ffd34d; border-radius: 3vh; background: rgba(40,12,80,.72); box-shadow: 0 0 3vh rgba(255,211,77,.6); }
#score .lbl { display: block; font-size: 3.4vh; letter-spacing: .25em; color: #ffd34d; }
#scoreNum { display: block; font-size: 14vh; line-height: 1; color: #fff; text-shadow: 0 0 2vh #ff8a1f; }
#scoreNum.bump { animation: bump .25s ease-out; }
@keyframes bump { 0% { transform: scale(1.35); color: #5dff9e; } 100% { transform: scale(1); } }
#timer { left: 83.33%; top: 24.07%; transform: translate(-50%,-50%); font-size: 17vh; line-height: 1; color: #4a1a7a; -webkit-text-stroke: .5vh #fff; paint-order: stroke fill; text-shadow: 0 0 2vh rgba(255,255,255,.6); }
#timer.low { color: #d62d6b; animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: translate(-50%,-50%) scale(1.15); } }
#big { position: absolute; left: 0; right: 0; top: 21vh; text-align: center; }
#bigMain { font-size: 24vh; line-height: 1; color: #ffd34d; -webkit-text-stroke: 1vh #4a1a7a; paint-order: stroke fill; text-shadow: 0 1.2vh 0 #b4402a, 0 0 5vh rgba(255,170,40,.9); }
#bigMain.pop { animation: bigPop .75s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes bigPop { 0% { transform: scale(.2) rotate(-8deg); opacity: 0; } 55% { transform: scale(1.18) rotate(3deg); opacity: 1; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
body[data-state="VICTORY"] #bigMain { font-size: 22vh; color: #5dff9e; animation: bigPop .8s cubic-bezier(.2,1.4,.4,1) both, rainbow 1.6s linear infinite; }
@keyframes rainbow { 0% { filter: hue-rotate(0); } 100% { filter: hue-rotate(360deg); } }
#bigSub { font-size: 8.5vh; margin-top: 1.5vh; color: #ff9a2e; -webkit-text-stroke: .6vh #3b0f6b; paint-order: stroke fill; text-shadow: 0 0 3vh rgba(255,140,30,.9); animation: bob 1.4s ease-in-out infinite; }
#bigScore { font-size: 5vh; margin-top: 1vh; color: #fff; text-shadow: 0 0 2vh #b86bff, 0 .4vh 0 #4a1a7a; }
#bigSub:empty, #bigScore:empty { display: none; }

/* ---------- INTERACTIVE ZONE: bottom 33% ---------- */
#zone { position: absolute; left: 0; right: 0; bottom: 0; height: 33%; touch-action: none; overflow: hidden; }
#slots { position: absolute; left: 50%; bottom: 0; width: 88vw; height: 100%; transform: translateX(-50%); display: flex; touch-action: none; }
body[data-state="ATTRACT"] #slots { visibility: hidden; }
body[data-state="COUNTDOWN"] #slots, body[data-state="VICTORY"] #slots { pointer-events: none; }
.slot { position: relative; flex: 1 1 0; margin: 0 .25vw; height: 100%; overflow: hidden; touch-action: none; cursor: pointer; }
.gw { position: absolute; left: 50%; bottom: 7vh; width: 18.5vh; height: 24vh; transform: translate(-50%, 140%); will-change: transform; }
.ghost { width: 100%; height: 100%; display: block; overflow: visible; filter: drop-shadow(0 0 1.2vh rgba(210,190,255,.9)); transform-origin: 50% 90%; }
.slot.up .ghost { animation: wiggle .7s ease-in-out infinite alternate; }
@keyframes wiggle { from { transform: rotate(-4deg) translateY(0); } to { transform: rotate(4deg) translateY(-.8vh); } }
.slot.hit .gw { transition: opacity .2s; opacity: 0; }
.slot.hit .ghost { transform: scale(1.18); transition: transform .2s; }
.ghost .f { display: none; }
.slot[data-face="0"] .f0, .slot[data-face="1"] .f1, .slot[data-face="2"] .f2 { display: inline; }
.mound { position: absolute; left: 3%; right: 3%; bottom: 1.5vh; height: 9vh; border-radius: 50% 50% 14% 14% / 100% 100% 30% 30%;
  background: radial-gradient(ellipse at 50% 0%, #6a3a2c 0%, #3b1f2a 70%); border-top: .7vh solid #fff; box-shadow: inset 0 1vh 2vh rgba(0,0,0,.45); }
.mound::after { content: ""; position: absolute; left: 50%; top: -3.4vh; width: 55%; height: 3vh; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(ellipse, rgba(10,0,30,.95), rgba(10,0,30,0) 70%); }

#start { position: absolute; left: 50%; bottom: 6vh; width: 62vw; height: 21vh; transform: translateX(-50%); border: 1vh solid #fff3b0; border-radius: 6vh;
  font: inherit; font-size: 9.2vh; letter-spacing: .03em; color: #fff; -webkit-text-stroke: .7vh #8a2a00; paint-order: stroke fill; cursor: pointer; touch-action: none;
  background: linear-gradient(#ffc83d, #ff8a1f 55%, #e8560f); box-shadow: 0 1.4vh 0 #9c3300, 0 0 6vh 1vh rgba(255,170,40,.85); text-shadow: 0 .6vh 0 rgba(140,40,0,.6);
  animation: startPulse 1.1s ease-in-out infinite; padding: 0; }
@keyframes startPulse { 0%,100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.04); box-shadow: 0 1.4vh 0 #9c3300, 0 0 9vh 2.2vh rgba(255,200,60,.95); } }
#start:active { filter: brightness(1.15); }
body:not([data-state="ATTRACT"]) #start, body:not([data-state="ATTRACT"]) #pointer { display: none; }
#pointer { position: absolute; left: 2vw; bottom: 8vh; width: 12vw; height: 20vh; display: flex; align-items: center; pointer-events: none; animation: pointerBob 1s ease-in-out infinite; }
#pointer svg { width: 11vh; height: 14.3vh; filter: drop-shadow(0 0 1.2vh rgba(210,190,255,.9)); }
#pointer span { font-size: 7vh; color: #ffd34d; margin-left: .5vw; text-shadow: 0 0 2vh #ff8a1f; }
@keyframes pointerBob { 0%,100% { transform: translateX(0); } 50% { transform: translateX(1.6vw); } }

#fx { position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%; }
#celebrate { position: absolute; top: 0; right: 0; bottom: 0; left: 0; overflow: hidden; }
.cg { position: absolute; bottom: -22vh; width: 12vh; height: 15.6vh; animation: riseUp 3.6s ease-out forwards; filter: drop-shadow(0 0 1.5vh rgba(255,255,255,.8)); }
@keyframes riseUp { 0% { transform: translateY(0) rotate(-8deg); opacity: 1; } 50% { transform: translateY(-60vh) rotate(8deg); } 100% { transform: translateY(-105vh) rotate(-8deg); opacity: .9; } }
#diag { position: absolute; left: 1vw; top: 1vh; margin: 0; padding: 1vh 1.2vw; font: 700 2vh/1.4 monospace; background: rgba(0,0,0,.7); color: #7dff9e; border-radius: 1vh; z-index: 20; }
#diag[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) { .dghost, .bat, .cloud, .fog { animation-duration: 240s; } }
.slot[data-i="0"] .mound { border-top-color: #ffb02e; box-shadow: 0 0 3vh #ffb02e, inset 0 1vh 2vh rgba(0,0,0,.45); }
.slot[data-i="1"] .mound { border-top-color: #b86bff; box-shadow: 0 0 3vh #b86bff, inset 0 1vh 2vh rgba(0,0,0,.45); }
.slot[data-i="2"] .mound { border-top-color: #5dff9e; box-shadow: 0 0 3vh #5dff9e, inset 0 1vh 2vh rgba(0,0,0,.45); }
.slot[data-i="3"] .mound { border-top-color: #ffd34d; box-shadow: 0 0 3vh #ffd34d, inset 0 1vh 2vh rgba(0,0,0,.45); }
.slot[data-i="4"] .mound { border-top-color: #ff6bd6; box-shadow: 0 0 3vh #ff6bd6, inset 0 1vh 2vh rgba(0,0,0,.45); }

/* Booth-operator full-screen control: unlabeled purple box, top-right, out of children's reach. Hidden once full screen. */
#fs { position: absolute; top: 1vh; right: 1vw; width: 4.5vh; height: 4.5vh; padding: 0; margin: 0; background: #8a3fe0; border: .3vh solid #c9a0ff; border-radius: .8vh; opacity: .75; cursor: pointer; touch-action: none; z-index: 6; }
body.is-fs #fs, body.no-fs #fs { display: none; }
