:root{
  --ink:#fff4dc; --ink-2:#e9cf9c; --gold:#e8b84a; --gold-l:#ffd98a; --gold-d:#a8761f;
  --saffron:#f59e0b; --saffron-d:#e2600c; --plum:#2a0d1f; --night:#12060c;
  --tile:64px; --tileh:70px; --edge:6px;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%;overflow:hidden;background:var(--night)}
body{font-family:system-ui,-apple-system,"Segoe UI",Roboto,"Noto Sans Tamil",sans-serif;color:var(--ink);touch-action:manipulation;-webkit-user-select:none;user-select:none}
#app{position:relative;max-width:520px;height:100vh;height:100dvh;margin:0 auto;overflow:hidden;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 240'%3E%3Cpath fill='%23e8b84a' fill-opacity='.07' d='M96 0h8l2 10h-12zM70 14h60l4 22H66zM60 40h80l6 30H54zM48 74h104l8 36H40zM36 114h128l10 44H26zM22 162h156l12 78H10z'/%3E%3C/svg%3E") no-repeat 50% 104%/78% auto,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='110' height='110' viewBox='0 0 110 110'%3E%3Cg fill='none' stroke='%23e8b84a' stroke-opacity='.06' stroke-width='1.4'%3E%3Cpath d='M55 16c11 11 28 28 39 39-11 11-28 28-39 39C44 83 27 66 16 55 27 44 44 27 55 16z'/%3E%3Ccircle cx='55' cy='55' r='10'/%3E%3Cpath d='M0 0c9 9 9 18 0 27M110 0c-9 9-9 18 0 27M0 110c9-9 9-18 0-27M110 110c-9-9-9-18 0-27'/%3E%3C/g%3E%3Cg fill='%23e8b84a' fill-opacity='.08'%3E%3Ccircle cx='55' cy='35' r='2'/%3E%3Ccircle cx='55' cy='75' r='2'/%3E%3Ccircle cx='35' cy='55' r='2'/%3E%3Ccircle cx='75' cy='55' r='2'/%3E%3C/g%3E%3C/svg%3E") 0 0/110px 110px,
    radial-gradient(90% 45% at 50% 0%, rgba(255,160,60,.22), transparent 70%),
    radial-gradient(70% 40% at 50% 100%, rgba(232,140,40,.16), transparent 70%),
    linear-gradient(180deg,#3a1029 0%,#25091a 45%,#14060d 100%);}
#app::after{content:"";position:absolute;inset:0;pointer-events:none;background:radial-gradient(120% 80% at 50% 45%,transparent 55%,rgba(0,0,0,.45));z-index:0}
button{font:inherit;color:inherit;border:0;background:none;padding:0;cursor:pointer}
svg{display:block}
.screen{position:absolute;inset:0;display:none;flex-direction:column;z-index:1}
.screen.active{display:flex}
.screen.leaving{display:flex;z-index:50}

/* ---------- floating petals / diya sparkles ---------- */
.petals{position:absolute;inset:0;pointer-events:none;overflow:hidden;z-index:2}
.play-petals{z-index:0}
.petals i{position:absolute;top:-30px;display:block;width:12px;height:16px;border-radius:60% 60% 60% 60%/80% 80% 30% 30%;
  background:linear-gradient(160deg,#ffc24a,#f07a12);opacity:.0;animation:petalFall linear infinite}
.petals i.s{width:6px;height:6px;border-radius:50%;background:#ffd98a;box-shadow:0 0 8px 3px rgba(255,190,80,.6);animation-name:sparkUp}
@keyframes petalFall{0%{transform:translate(0,0) rotate(0);opacity:0}10%{opacity:.75}90%{opacity:.6}100%{transform:translate(var(--dx,40px),110vh) rotate(540deg);opacity:0}}
@keyframes sparkUp{0%{transform:translate(0,105vh) scale(.6);opacity:0}20%{opacity:.9}100%{transform:translate(var(--dx,20px),40vh) scale(1.1);opacity:0}}

/* ---------- HOME / GATE ---------- */
#home{background:#0d0509;overflow:hidden}
.stage{position:absolute;left:50%;top:50%;width:720px;height:1280px;transform-origin:50% 50%;background:url(gate-bg.webp) 0 0/100% 100% no-repeat;transition:transform 1s ease-in, opacity .7s ease-in}
.doorway{position:absolute;left:30.14%;top:44.53%;width:40%;height:34.69%;perspective:1400px}
.door-glow{position:absolute;inset:0;background:radial-gradient(60% 55% at 50% 55%,#ffe2a0 0%,#ffae3d 35%,#7a2a08 75%,#1a0805 100%);opacity:0;transition:opacity .9s}
.door{position:absolute;top:0;width:50%;height:100%;transform-style:preserve-3d;transition:transform 1.25s cubic-bezier(.55,.05,.35,1)}
.door.left{left:0;transform-origin:0 50%}
.door.right{right:0;transform-origin:100% 50%}
.door .leaf{position:absolute;inset:0;background:url(door-leaf.webp) 50% 50%/100% 100% no-repeat;box-shadow:inset 0 0 18px rgba(0,0,0,.55)}
.door.right .leaf{transform:scaleX(-1)}
.door.left::after,.door.right::after{content:"";position:absolute;top:0;bottom:0;width:6px;background:linear-gradient(90deg,rgba(0,0,0,.6),transparent)}
.door.left::after{right:0;transform:scaleX(-1)}
.door.right::after{left:0}
.gate-bell{position:absolute;left:50%;top:-1%;width:15%;margin-left:-7.5%;transform-origin:50% 0;filter:drop-shadow(0 4px 6px rgba(0,0,0,.6))}
#home.opening .door.left{transform:rotateY(-108deg)}
#home.opening .door.right{transform:rotateY(108deg)}
#home.opening .door-glow{opacity:1}
#home.opening .gate-bell{animation:bellSwing 1.6s ease-in-out}
#home.opening .home-top,#home.opening .home-bottom,#home.opening .mute{opacity:0;transition:opacity .35s}
#home.entering .stage{opacity:0}
#home .mute{position:absolute;top:calc(env(safe-area-inset-top) + 12px);right:12px;z-index:5}
.home-top{position:absolute;top:calc(env(safe-area-inset-top) + 14px);left:12px;z-index:5}
.home-top .blessings{padding:6px 14px 6px 8px;border-radius:30px;background:rgba(20,6,12,.55);border:1.5px solid rgba(232,184,74,.55);box-shadow:0 4px 12px rgba(0,0,0,.4)}
.home-bottom{position:absolute;left:0;right:0;bottom:calc(env(safe-area-inset-bottom) + 14px);display:flex;flex-direction:column;align-items:center;gap:14px;z-index:5}
.playpill{display:flex;align-items:center;justify-content:center;gap:10px;min-width:210px;height:76px;padding:0 34px 0 26px;border-radius:40px;
  background:linear-gradient(180deg,#ffd36b 0%,#fbab26 38%,#ef7d0e 62%,#d85d08 100%);
  border:3px solid #fff1c9;box-shadow:0 7px 0 #8f3a05,0 12px 26px rgba(0,0,0,.6),0 0 30px rgba(255,170,50,.45),inset 0 2px 0 rgba(255,255,255,.7);
  color:#fff;font:900 38px system-ui,sans-serif;text-shadow:0 2px 0 #9a3d04;position:relative;overflow:hidden;animation:pillPulse 2.2s ease-in-out infinite}
.playpill::before{content:"";position:absolute;left:8%;right:8%;top:5px;height:42%;border-radius:30px;background:linear-gradient(180deg,rgba(255,255,255,.75),rgba(255,255,255,0))}
.playpill svg{width:40px;height:40px;fill:#fff;filter:drop-shadow(0 2px 0 #9a3d04);position:relative}
.playpill span{position:relative}
.playpill:active{transform:translateY(4px);box-shadow:0 3px 0 #8f3a05,0 6px 14px rgba(0,0,0,.6)}
@keyframes pillPulse{50%{transform:scale(1.04)}}
.shelf-wrap{display:flex;flex-direction:column;align-items:center;gap:10px}
.shelf{display:flex;align-items:flex-end;gap:3px;padding:7px 12px 5px;border-radius:14px;min-height:52px;
  background:linear-gradient(180deg,rgba(40,14,8,.85),rgba(24,8,4,.9));border:1.5px solid rgba(232,184,74,.5);border-bottom:5px solid #8a5a22;box-shadow:0 6px 16px rgba(0,0,0,.5)}
.shelf .slot{width:26px;height:32px;display:flex;align-items:flex-end;justify-content:center}
.shelf .slot img{width:26px;height:26px;object-fit:contain}
.shelf .slot.empty{opacity:.25;filter:grayscale(1) brightness(1.5)}
.shelf .temples{display:flex;align-items:center;gap:2px;margin-right:8px;padding-right:8px;border-right:2px solid rgba(232,184,74,.4);font:800 20px system-ui,sans-serif;color:var(--gold-l)}
.shelf .temples img{width:40px;height:40px}
.shelf .slot.new img{animation:landIn .8s cubic-bezier(.2,1.4,.4,1)}
@keyframes landIn{0%{transform:translateY(-120px) scale(2.2);opacity:0}60%{opacity:1}100%{transform:none}}
.blessings{display:flex;align-items:center;gap:6px;font:800 22px system-ui,sans-serif;color:var(--gold-l)}
.blessings img{width:32px;height:32px}

/* ---------- PLAY ---------- */
.topbar{display:flex;align-items:center;gap:8px;padding:calc(env(safe-area-inset-top) + 8px) 10px 6px;position:relative;z-index:3}
.iconbtn{width:50px;height:50px;border-radius:16px;background:linear-gradient(180deg,rgba(255,255,255,.12),rgba(255,255,255,.03));border:1.5px solid rgba(232,184,74,.6);box-shadow:0 4px 10px rgba(0,0,0,.45),inset 0 1px 0 rgba(255,255,255,.15);display:flex;align-items:center;justify-content:center}
.iconbtn svg{width:28px;height:28px;fill:var(--gold-l)}
.iconbtn:active{transform:scale(.95)}
.levelbadge{flex:1;display:flex;align-items:center;justify-content:center;gap:6px;font:800 30px system-ui,sans-serif;color:var(--ink);text-shadow:0 2px 6px rgba(0,0,0,.6)}
.levelbadge img{width:42px;height:42px;filter:drop-shadow(0 0 8px rgba(255,180,60,.5))}
.progress{height:8px;margin:0 16px 2px;border-radius:6px;background:rgba(0,0,0,.45);border:1px solid rgba(232,184,74,.25);overflow:hidden;position:relative;z-index:3}
#progressBar{height:100%;width:0;border-radius:6px;background:linear-gradient(90deg,#ffd36b,#f08a12);box-shadow:0 0 10px rgba(255,170,40,.7);transition:width .3s}
.board{position:relative;flex:1;min-height:0;margin:2px 3px;z-index:3}
.tile{position:absolute;width:var(--tile);height:var(--tileh);border-radius:11px;
  background:linear-gradient(180deg,#fffef9 0%,#fdf4e1 48%,#f1dfbb 100%);
  border:1.5px solid #d6ad5e;
  box-shadow:0 var(--edge) 0 #b8863a,0 calc(var(--edge) + 1.5px) 0 #6b4214,0 calc(var(--edge) + 5px) 10px rgba(0,0,0,.6),inset 0 -2px 3px rgba(160,110,40,.25);
  transition:filter .18s, transform .12s;cursor:pointer}
.tile::after{content:"";position:absolute;left:4%;right:4%;top:3%;height:38%;border-radius:9px 9px 40% 40%/9px 9px 18px 18px;background:linear-gradient(180deg,rgba(255,255,255,.85),rgba(255,255,255,0));pointer-events:none}
.tile img{position:absolute;left:9%;top:8%;width:82%;height:82%;object-fit:contain;pointer-events:none}
.tile.blocked{filter:brightness(.5) saturate(.6);cursor:default}
.tile.blocked::after{opacity:.35}
.tile.free:active{transform:translateY(2px)}
.tile.hint{animation:hintPulse .7s ease-in-out 4;z-index:9999 !important}
@keyframes hintPulse{50%{box-shadow:0 var(--edge) 0 #b8863a,0 0 0 4px #fff3c4,0 0 26px 12px rgba(255,190,50,.9)}}
.tile.wiggle{animation:wiggle .3s}
@keyframes wiggle{20%{transform:translateX(-3px)}50%{transform:translateX(3px)}80%{transform:translateX(-1px)}}
.tile.spin{animation:spin .45s ease-in-out}
@keyframes spin{50%{transform:scale(.6) rotate(180deg);filter:brightness(1.2)}}
.tile.fly{position:fixed;z-index:10000;pointer-events:none;transform-origin:0 0}

.pooja{display:flex;justify-content:center;gap:10px;padding:4px 0 2px;position:relative;z-index:3}
.pooja .pi{width:46px;height:46px;border-radius:50%;border:2px dashed rgba(232,184,74,.6);background:rgba(0,0,0,.3);display:flex;align-items:center;justify-content:center;transition:all .25s}
.pooja .pi img{width:34px;height:34px;opacity:.5;filter:grayscale(.5)}
.pooja .pi.on{border-style:solid;border-color:#ffd27a;background:rgba(255,190,60,.22);box-shadow:0 0 14px rgba(255,190,60,.7)}
.pooja .pi.on img{opacity:1;filter:none}
.pooja.burst .pi{animation:poojaBurst .9s ease-out}
@keyframes poojaBurst{40%{transform:scale(1.35);box-shadow:0 0 30px 10px #ffcf4d}}

.traywrap{padding:4px 10px 6px;position:relative;z-index:3}
.tray{display:grid;grid-template-columns:repeat(4,58px);gap:10px;padding:8px 14px;border-radius:22px;width:fit-content;margin:0 auto;
  background:linear-gradient(180deg,#6a3818 0%,#4a230e 55%,#341707 100%);border:2.5px solid #d9a64a;
  box-shadow:0 6px 0 #241005,0 10px 24px rgba(0,0,0,.6),inset 0 2px 0 rgba(255,220,150,.35),inset 0 -3px 6px rgba(0,0,0,.4)}
.tray .ts{aspect-ratio:1/1.06;border-radius:12px;background:linear-gradient(180deg,#1e0b04,#2e1408);box-shadow:inset 0 3px 6px rgba(0,0,0,.7),0 1px 0 rgba(255,220,150,.2);position:relative}
.tray .ts.danger{background:linear-gradient(180deg,#4a0d08,#3a0a06);box-shadow:inset 0 0 10px rgba(255,60,40,.6)}
.tray .tt{position:absolute;inset:0;border-radius:11px;background:linear-gradient(180deg,#fffef9,#f1dfbb);border:1.5px solid #d6ad5e;box-shadow:0 4px 0 #b8863a,0 5px 0 #6b4214}
.tray .tt::after{content:"";position:absolute;left:5%;right:5%;top:3%;height:38%;border-radius:9px;background:linear-gradient(180deg,rgba(255,255,255,.8),rgba(255,255,255,0))}
.tray .tt img{position:absolute;left:9%;top:9%;width:82%;height:82%;object-fit:contain}
.tray .tt.pop{animation:pop .28s ease-in forwards}
@keyframes pop{40%{transform:scale(1.25);box-shadow:0 0 0 3px #fff3c4,0 0 24px 10px rgba(255,190,50,.9)}100%{transform:scale(0);opacity:0}}
.tray.warn{animation:trayWarn .6s 2}
@keyframes trayWarn{50%{border-color:#ff5a3a;box-shadow:0 6px 0 #241005,0 0 22px #ff5a3a}}
.controls{display:flex;justify-content:space-evenly;padding:6px 10px calc(env(safe-area-inset-bottom) + 12px);position:relative;z-index:3}
.ctrl{width:70px;height:70px;border-radius:50%;display:flex;align-items:center;justify-content:center;position:relative;overflow:hidden;
  background:radial-gradient(circle at 50% 30%,#ffe7a6 0%,#f0bf55 40%,#c58a26 75%,#9a6416 100%);border:2.5px solid #fff0c2;
  box-shadow:0 6px 0 #5e3a0b,0 10px 20px rgba(0,0,0,.6),inset 0 -4px 6px rgba(110,60,0,.35)}
.ctrl::before{content:"";position:absolute;left:18%;right:18%;top:6%;height:36%;border-radius:50%;background:linear-gradient(180deg,rgba(255,255,255,.75),rgba(255,255,255,0))}
.ctrl svg{width:38px;height:38px;fill:#4a1408;position:relative}
.ctrl:active{transform:translateY(3px);box-shadow:0 3px 0 #5e3a0b,0 5px 10px rgba(0,0,0,.6)}
.ctrl.small{width:62px;height:62px}.ctrl.small svg{width:32px;height:32px}
.ctrl.big{width:84px;height:84px}.ctrl.big svg{width:46px;height:46px}
.ctrl.glow,.ctrl.attn{animation:ctrlGlow 1.2s ease-in-out infinite}
@keyframes ctrlGlow{50%{box-shadow:0 6px 0 #5e3a0b,0 0 0 6px rgba(255,220,120,.4),0 0 28px 10px #ffbf3d}}
.ctrl.no{background:radial-gradient(circle at 50% 30%,#ffd0c4,#e0705c 60%,#a83a2a)}
.ctrl.yes{background:radial-gradient(circle at 50% 30%,#d8f5c4,#5fb83c 60%,#2f7a18)}

/* ---------- OVERLAYS ---------- */
.overlay{position:absolute;inset:0;z-index:20000;display:flex;align-items:center;justify-content:center;background:rgba(10,2,6,.62);-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);animation:fadeIn .25s}
.overlay[hidden]{display:none}
.overlay.sheet{align-items:flex-start;padding-top:22%;background:rgba(10,2,6,.45)}
@keyframes fadeIn{from{opacity:0}}
.card{width:min(92%,420px);padding:22px 16px 26px;border-radius:28px;text-align:center;
  background:radial-gradient(100% 60% at 50% 0%,rgba(255,170,60,.22),transparent 70%),linear-gradient(180deg,#4a1530,#2a0b1b);border:2.5px solid #e2b04e;
  box-shadow:0 24px 60px rgba(0,0,0,.7),inset 0 1px 0 rgba(255,230,170,.3);animation:cardIn .35s cubic-bezier(.2,1.3,.4,1)}
@keyframes cardIn{from{transform:scale(.7);opacity:0}}
.cardbtns{display:flex;align-items:center;justify-content:space-evenly;margin-top:18px}
.win-stars{font-size:34px;color:#ffd27a;letter-spacing:10px;text-shadow:0 0 14px #ffb300}
.win-gopuram{width:110px;height:110px;margin:6px auto 10px;display:block;filter:drop-shadow(0 0 22px rgba(255,200,80,.8));animation:glowPulse 1.6s infinite}
@keyframes glowPulse{50%{transform:scale(1.06)}}
.wincard .shelf{justify-content:center;margin:0 auto 10px;width:fit-content}
.wincard .blessings{justify-content:center}
.playpill.next{min-width:150px;height:70px;font-size:32px;padding:0 26px 0 20px;animation:none}
.playpill.next svg{width:34px;height:34px}
.yt{display:flex;align-items:center;justify-content:center;width:52px;height:52px;border-radius:16px;background:rgba(255,255,255,.08);border:1.5px solid rgba(232,184,74,.5)}
.yt svg{width:34px;height:24px}
.lose-tray-icon svg{width:64px;height:64px;margin:0 auto;fill:none;stroke:#ff8a75;stroke-width:2;animation:wiggle .5s 2}
.skip-icon{display:flex;align-items:center;justify-content:center;gap:10px;font:800 40px system-ui,sans-serif;color:var(--ink)}
.skip-icon svg{width:64px;height:64px;fill:var(--gold)}

/* ---------- FX ---------- */
#fx{position:fixed;inset:0;pointer-events:none;z-index:30000;overflow:hidden}
#fx .p{position:absolute;will-change:transform}
#fx .petal{width:16px;height:22px;border-radius:60% 60% 60% 60%/80% 80% 30% 30%}
#fx .lamprow{position:absolute;left:0;right:0;top:34%;display:flex;justify-content:center;gap:4px}
#fx .lamp{position:relative;width:50px;height:76px}
#fx .lamp img{width:50px;height:66px;object-fit:contain;position:absolute;bottom:0;filter:brightness(.6)}
#fx .lamp.lit img{filter:none}
#fx .lamp .flame{position:absolute;left:50%;top:-8px;width:16px;height:24px;margin-left:-8px;border-radius:50% 50% 50% 50%/60% 60% 40% 40%;
  background:radial-gradient(circle at 50% 70%,#fff7c0,#ffcc33 40%,#ff7a00 75%,transparent 76%);opacity:0;transform:scale(.2);transition:all .3s;box-shadow:0 0 22px 8px rgba(255,180,40,.55)}
#fx .lamp.lit .flame{opacity:1;transform:scale(1);animation:flicker .25s infinite alternate}
@keyframes flicker{to{transform:scale(1.08,.94) translateX(1px)}}
#fx .bellwrap{position:absolute;left:50%;top:14%;width:160px;margin-left:-80px;transform-origin:50% 0;animation:bellSwing 1.8s ease-in-out}
#fx .bellwrap img{width:160px;height:160px;filter:drop-shadow(0 0 20px rgba(255,200,80,.8))}
@keyframes bellSwing{0%{transform:rotate(0)}15%{transform:rotate(28deg)}35%{transform:rotate(-24deg)}55%{transform:rotate(16deg)}75%{transform:rotate(-8deg)}100%{transform:rotate(0)}}
#fx .ring{position:absolute;border:4px solid rgba(255,215,110,.85);border-radius:50%}
#fx svg.kolam{position:absolute;left:50%;top:22%;width:280px;height:280px;margin-left:-140px}
#fx .feather{position:absolute;width:150px;height:150px}
#fx .spark{width:12px;height:12px;border-radius:50%}
#fx .plus{position:absolute;display:flex;align-items:center;gap:4px;font:bold 30px system-ui,sans-serif;color:#ffd27a;text-shadow:0 2px 0 #3a0912}
#fx .plus img{width:44px;height:44px}
@media (max-height:700px){.ctrl{width:62px;height:62px}.ctrl svg{width:34px;height:34px}.iconbtn{width:46px;height:46px}.levelbadge{font-size:26px}.levelbadge img{width:38px;height:38px}}
