/* ---------- Mode 1: Naraka Vadha ---------- */
.vadha-bg, .vadha-bg svg, .colony, .colony svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.effigy { position: absolute; z-index: 2; left: 50%; bottom: 27%; height: 52%; aspect-ratio: 240 / 520; translate: -50% 0; transition: filter 2.5s; filter: drop-shadow(0 0 40px rgba(255,170,80,.25)); }
.effigy svg { width: 100%; height: 100%; }
.effigy.burning { filter: brightness(1.25) saturate(1.3) drop-shadow(0 0 40px rgba(255,120,40,.9)); animation: sway .25s ease-in-out infinite alternate; }
.effigy.charred { filter: brightness(.22) sepia(1) saturate(.4) drop-shadow(0 0 24px rgba(255,80,20,.7)); }
.reticle { display: none !important; }
.vadha-input { position: absolute; inset: 0; z-index: 10; touch-action: none; cursor: crosshair; }
.gully-input { position: absolute; inset: 0; z-index: 10; touch-action: none; }
.power { width: 140px; height: 8px; border-radius: 999px; background: var(--surface-overlay); overflow: hidden; margin-left: auto; margin-right: 150px; }
.power-fill { height: 100%; transform-origin: left; transform: scaleX(0); background: linear-gradient(90deg, var(--festive-gold), var(--festive-kumkum)); }
.hint { position: absolute; z-index: 15; bottom: var(--space-8); left: 50%; translate: -50% 0; max-width: 70%; text-align: center; padding: var(--space-2) var(--space-4); border-radius: 999px; background: var(--surface-overlay); backdrop-filter: blur(10px); font-size: 14px; color: var(--text-secondary); pointer-events: none; }
.only-cam, .tracking .only-touch { display: none; }
.tracking .only-cam { display: inline; }
.result { position: absolute; z-index: 22; inset: 0; display: grid; place-content: center; justify-items: center; gap: var(--space-4); text-align: center; background: radial-gradient(closest-side, rgba(9,9,15,.8), transparent); animation: rise .6s var(--ease-out); }
.result h2 { font-size: clamp(30px, 7cqh, 64px); font-weight: 900; letter-spacing: -.02em; color: var(--festive-gold); text-shadow: var(--glow-gold); }
.result-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; justify-content: center; }
.result[hidden] { display: none; }

/* ---------- Mode 2: Gully Patakha ---------- */
#mode-gully > canvas { z-index: 20; }
.diya ellipse:last-child, .candle .flame { animation: flicker 1.3s ease-in-out infinite alternate; animation-delay: var(--d, 0s); transform-origin: center bottom; transform-box: fill-box; }
.bulb { animation: twinkle 1.6s steps(2) infinite; animation-delay: var(--d); }
.candle { position: absolute; z-index: 3; aspect-ratio: 1/2; translate: -50% -100%; }
.candle svg { width: 100%; height: 100%; filter: drop-shadow(0 0 16px rgba(255,179,71,.55)); }
.road-items, .mudra-props { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.road-item { position: absolute; translate: -50% -100%; animation: drop .5s var(--ease-spring); transition: opacity .5s; }
.road-item svg { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 4px 3px rgba(0,0,0,.7)); }
.road-item::after { content: ''; position: absolute; left: 15%; right: 15%; bottom: -4%; height: 10%; border-radius: 50%; background: rgba(0,0,0,.45); filter: blur(3px); z-index: -1; }
.road-item.fusing svg { animation: jitter .12s infinite; }
.road-item.launched svg > :not(path:first-child) { opacity: 0; transition: opacity .15s; }
.road-item.spinning .disc-stripes { animation: stripes .25s linear infinite; }
.road-item.spinning { animation: wander 5s ease-in-out; }
.road-item.blown, .road-item.gone { opacity: 0; transition-duration: .1s; }
.road-item.eating { animation: eat 6s linear forwards; }
.pataka-box { position: absolute; z-index: 18; left: 50%; bottom: max(var(--space-3), env(safe-area-inset-bottom)); translate: -50% 0; width: 150px; height: 58px; border-radius: 8px 8px 12px 12px; background: repeating-linear-gradient(90deg, #b8321f 0 16px, #d24a2a 16px 32px); border: 3px solid var(--festive-gold); box-shadow: 0 0 30px rgba(255,154,60,.35), inset 0 -10px 20px rgba(0,0,0,.3); display: grid; place-items: center; transition: transform .3s var(--ease-spring); }
.pataka-box:hover { transform: translateY(-4px) rotate(-1deg); }
.box-lid { position: absolute; inset: -14px -8px auto; height: 18px; border-radius: 8px 8px 2px 2px; background: #8a2414; border: 3px solid var(--festive-gold); transition: transform .4s var(--ease-spring); transform-origin: left bottom; }
.pataka-box[aria-expanded="true"] .box-lid { transform: rotate(-28deg) translateY(-6px); }
.box-label { font-weight: 900; letter-spacing: .14em; font-size: 13px; color: var(--festive-gold); text-shadow: 0 2px 0 #5a1408; }
.shop { position: absolute; z-index: 19; left: 50%; bottom: calc(58px + var(--space-8)); translate: -50% 0; width: min(94%, 820px); display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--space-2); padding: var(--space-4); border-radius: var(--radius-l); background: linear-gradient(180deg, rgba(40,16,10,.92), rgba(18,10,14,.94)); border: 1px solid rgba(255,211,107,.3); box-shadow: 0 30px 80px -20px rgba(0,0,0,.8), 0 0 0 1px rgba(0,0,0,.4); backdrop-filter: blur(16px); transform-origin: 50% 100%; scale: .5; opacity: 0; pointer-events: none; transition: scale .45s var(--ease-spring), opacity .25s; }
.shop.open { scale: 1; opacity: 1; pointer-events: auto; }
.shop-item { display: grid; justify-items: center; gap: 2px; padding: var(--space-2) var(--space-1); border-radius: var(--radius-m); min-height: 44px; background: rgba(255,255,255,.03); border: 1px solid transparent; transition: background .2s, border-color .2s, transform .25s var(--ease-spring); opacity: 0; translate: 0 16px; }
.shop.open .shop-item { opacity: 1; translate: 0 0; transition: opacity .3s calc(var(--i) * 28ms), translate .45s var(--ease-spring) calc(var(--i) * 28ms), background .2s, border-color .2s, transform .25s var(--ease-spring); }
.shop-item:hover { background: rgba(255,211,107,.1); border-color: rgba(255,211,107,.35); transform: translateY(-3px); }
.shop-art { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; background: radial-gradient(circle, rgba(255,211,107,.14), transparent 70%); }
.shop-name { font-size: 13px; font-weight: 700; text-align: center; line-height: 1.1; }
.shop-local { font-size: 11px; color: var(--text-secondary); }
@media (max-aspect-ratio: 1/1) { .shop { grid-template-columns: repeat(3, 1fr); } }
.toast { position: absolute; z-index: 21; top: 13%; left: 50%; translate: -50% 0; max-width: 80%; text-align: center; padding: var(--space-2) var(--space-4); border-radius: 999px; background: var(--surface-overlay); backdrop-filter: blur(10px); font-size: 14px; opacity: 0; pointer-events: none; }
.toast.show { animation: toast 3.6s var(--ease-out); }
.hand-switch[hidden] { display: none; }

/* Gully First-Time Guidance Card */
.gully-onboarding { position: absolute; z-index: 25; inset: 0; display: grid; place-content: center; justify-items: center; background: radial-gradient(circle at center, rgba(16, 12, 22, 0.88), rgba(5, 5, 11, 0.94)); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); padding: var(--space-4); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.35s var(--ease-out), visibility 0.35s; }
.gully-onboarding.active { opacity: 1; visibility: visible; pointer-events: auto; }
.onboarding-card { max-width: 440px; width: 90%; padding: 24px 28px; border-radius: 20px; background: linear-gradient(180deg, rgba(35, 24, 45, 0.95), rgba(20, 14, 26, 0.96)); border: 1px solid rgba(255, 211, 107, 0.35); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 30px rgba(255, 154, 60, 0.2); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; animation: drop 0.4s var(--ease-spring); }
.onboarding-icon { font-size: 40px; filter: drop-shadow(0 0 12px rgba(255, 211, 107, 0.5)); }
.onboarding-title { font-size: 20px; font-weight: 800; color: #fff4dc; letter-spacing: -0.01em; line-height: 1.25; }
.onboarding-sub { font-size: 14px; color: rgba(255, 255, 255, 0.75); margin-top: -4px; }
.onboarding-steps { display: flex; flex-direction: column; gap: 8px; width: 100%; margin: 6px 0; }
.step-chip { padding: 10px 14px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 211, 107, 0.15); font-size: 13px; color: #ffffff; text-align: left; }
.step-chip b { color: var(--festive-gold); }
.onboarding-fallback { font-size: 11px; color: rgba(255, 255, 255, 0.5); margin: 0; }
.onboarding-btn { margin-top: 6px; padding: 10px 24px; font-size: 14px; font-weight: 700; border-radius: 999px; background: linear-gradient(135deg, var(--festive-gold), #ff9a3c); color: #1a1005; border: none; cursor: pointer; box-shadow: 0 4px 16px rgba(255, 154, 60, 0.4); transition: transform 0.2s, box-shadow 0.2s; }
.onboarding-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(255, 154, 60, 0.6); }
.gully-hint { bottom: calc(58px + var(--space-4)); }

/* ---------- Mode 3: Mudra Magic ---------- */
#mode-mudra { background: radial-gradient(100% 70% at 50% 100%, #1e1430, var(--surface-base)); }
.has-camera #mode-mudra { background: linear-gradient(rgba(9,9,15,.15), rgba(9,9,15,.55)); }
#mode-mudra > * { z-index: 6; }
#mode-mudra > canvas { z-index: 7; }
.legend { position: absolute; z-index: 30 !important; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); translate: -50% 0; display: flex; gap: 8px; align-items: stretch; justify-content: center; max-width: 98%; width: max-content; padding: 0; background: transparent; border: none; box-shadow: none; pointer-events: auto; }
.mudra-chip { position: relative; overflow: hidden; display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 12px; background: rgba(20, 18, 25, 0.88); border: 1px solid rgba(255, 255, 255, 0.1); color: var(--text-primary); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45); transition: all .2s cubic-bezier(0.16, 1, 0.3, 1); cursor: pointer; white-space: nowrap; }
.mudra-chip::before { content: ''; position: absolute; left: 0; bottom: 0; height: 3px; width: var(--progress, 0%); background: linear-gradient(90deg, #ff9a3c, #ffd36b); border-radius: 0 0 12px 12px; transition: width 0.05s linear; pointer-events: none; }
.mudra-chip:hover { background: rgba(32, 28, 38, 0.95); border-color: rgba(255, 211, 107, 0.35); transform: translateY(-2px); }
.mudra-chip.holding { border-color: rgba(255, 211, 107, 0.45); background: rgba(32, 26, 40, 0.94); box-shadow: 0 0 14px rgba(255, 170, 60, 0.25), 0 6px 20px rgba(0, 0, 0, 0.45); }
.mudra-chip.hit, .mudra-chip.active { background: rgba(36, 30, 44, 0.96); border-color: #ffd36b; box-shadow: 0 0 16px rgba(255, 211, 107, 0.45), 0 6px 20px rgba(0, 0, 0, 0.55); transform: scale(1.03) translateY(-2px); }
.mudra-emoji { font-size: 20px; line-height: 1; flex-shrink: 0; }
.mudra-info { display: flex; flex-direction: column; text-align: left; gap: 2px; }
.mudra-title { font-size: 13px; font-weight: 700; color: #ffffff; letter-spacing: -0.01em; line-height: 1.2; }
.mudra-sub { font-size: 10px; font-weight: 400; color: rgba(255, 255, 255, 0.65); line-height: 1.1; }
.wish { position: absolute; z-index: 15 !important; inset: 0; display: grid; place-content: center; justify-items: center; gap: var(--space-4); text-align: center; padding: var(--space-8); opacity: 0; visibility: hidden; pointer-events: none; background: radial-gradient(60% 60% at 50% 50%, rgba(40,14,6,.75), rgba(5,5,11,.55)); transition: opacity .8s, visibility .8s; }
.wish.show { opacity: 1; visibility: visible; }
.wish-mandala { position: absolute; left: 50%; top: 50%; width: min(80cqh, 90cqw); translate: -50% -50%; opacity: 0; filter: drop-shadow(0 0 30px rgba(255,154,60,.4)); }
.wish.show .wish-mandala { animation: mandala-in 1.4s var(--ease-out) forwards, spin 40s linear infinite; }
.wish-diyas { position: absolute; inset: 0; }
.wish-diya { position: absolute; width: 18px; height: 26px; translate: -50% -50%; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: radial-gradient(circle at 50% 70%, #fff4c0, #ffb347 45%, transparent 70%); opacity: 0; }
.wish-diya::after { content: ''; position: absolute; left: -6px; right: -6px; bottom: -8px; height: 10px; border-radius: 0 0 50% 50%; background: #b5542a; }
.wish.show .wish-diya { animation: diya-on .5s var(--ease-out) forwards, flicker 1.2s ease-in-out infinite alternate; animation-delay: calc(.4s + var(--i) * .12s), calc(.9s + var(--i) * .12s); }
.wish-by { position: relative; font-size: 13px; letter-spacing: .3em; text-transform: uppercase; color: var(--text-secondary); opacity: 0; }
.wish.show .wish-by { animation: rise .8s var(--ease-out) .3s forwards; }
.wish h2 { position: relative; font-size: clamp(48px, 13cqh, 150px); font-weight: 900; letter-spacing: -.035em; line-height: 1; white-space: nowrap; }
.wish h2 span { display: inline-block; opacity: 0; background: linear-gradient(180deg, #fff8e6, var(--festive-gold) 55%, var(--festive-marigold)); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 22px rgba(255,170,60,.7)); }
.wish.show h2 span { animation: letter 0.7s var(--ease-spring) forwards, glow 2.4s ease-in-out infinite alternate; animation-delay: calc(.7s + var(--i) * .06s), calc(1.6s + var(--i) * .06s); }
.wish blockquote { position: relative; max-width: 34ch; font-size: clamp(16px, 2.8cqh, 24px); font-style: italic; color: #fff4dc; opacity: 0; }
.wish.show blockquote { animation: rise 1s var(--ease-out) 2s forwards; }

.wish-socials { position: relative; z-index: 20; display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 6px; opacity: 0; pointer-events: auto; }
.wish.show .wish-socials { animation: rise 0.8s var(--ease-out) 2.4s forwards; }
.socials-label { font-size: 13px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--festive-gold); text-shadow: 0 0 12px rgba(255, 211, 107, 0.4); margin-right: 2px; }
.social-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px; background: rgba(28, 22, 36, 0.88); border: 1px solid rgba(255, 211, 107, 0.35); color: #ffffff; font-size: 13px; font-weight: 600; text-decoration: none; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5); transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1); pointer-events: auto; cursor: pointer; }
.social-pill:hover { transform: translateY(-2px) scale(1.04); border-color: #ffd36b; background: rgba(42, 32, 54, 0.95); box-shadow: 0 0 18px rgba(255, 211, 107, 0.45), 0 8px 24px rgba(0, 0, 0, 0.55); color: #ffd36b; }
.social-icon { width: 16px; height: 16px; flex-shrink: 0; display: inline-block; vertical-align: middle; }
.social-insta .social-icon { color: #ff7ad9; }
.social-insta:hover .social-icon { color: #ff9a3c; }
.social-yt .social-icon { color: #ff5a4d; }
.social-yt:hover .social-icon { color: #ff4336; }

@keyframes flicker { to { transform: scaleY(1.15) scaleX(.9); opacity: .85; } }
@keyframes twinkle { 50% { opacity: .35; } }
@keyframes sway { to { transform: rotate(.6deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes drop { from { transform: translateY(-50px); opacity: 0; } }
@keyframes jitter { 50% { transform: translateX(1px) rotate(1.5deg); } }
@keyframes stripes { to { stroke-dashoffset: -32; } }
@keyframes wander { 25% { transform: translateX(-18px); } 60% { transform: translateX(22px); } }
@keyframes eat { to { clip-path: inset(0 100% 0 0); } }
@keyframes toast { 0% { opacity: 0; translate: -50% 8px; } 10%, 85% { opacity: 1; translate: -50% 0; } 100% { opacity: 0; } }
@keyframes hit { 40% { transform: scale(1.12); border-color: var(--festive-gold); } }
@keyframes mandala-in { from { opacity: 0; scale: .6; } to { opacity: 1; scale: 1; } }
@keyframes spin { to { rotate: 360deg; } }
@keyframes diya-on { from { opacity: 0; scale: .3; } to { opacity: 1; scale: 1; } }
@keyframes letter { from { opacity: 0; transform: translateY(40px) scale(.6); filter: blur(8px); } to { opacity: 1; transform: none; } }
@keyframes glow { to { filter: drop-shadow(0 0 40px rgba(255,200,90,1)); } }

.hud-pill b { white-space: nowrap; }

.legend-sep { width: 1px; height: 26px; align-self: center; background: rgba(255, 255, 255, 0.16); margin: 0 2px; flex-shrink: 0; }
.pencil-chip { border-color: rgba(255, 211, 107, 0.3); }
.pencil-chip .pencil-icon { width: 18px; height: 18px; color: var(--festive-gold); transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1); display: block; }
.pencil-chip:hover .pencil-icon { transform: rotate(-15deg) scale(1.15); color: #ffd36b; }
.pencil-chip.active {
  border-color: #ffd36b !important;
  background: rgba(45, 30, 18, 0.95) !important;
  box-shadow: 0 0 18px rgba(255, 211, 107, 0.55), 0 6px 20px rgba(0, 0, 0, 0.55) !important;
  transform: scale(1.03) translateY(-2px);
}
.pencil-chip.active .pencil-icon { color: #ffffff; filter: drop-shadow(0 0 6px #ffd36b); }
.pencil-chip.active .mudra-title { color: #ffd36b; }

.draw-hud {
  position: absolute;
  z-index: 31 !important;
  left: 50%;
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 58px);
  translate: -50% 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(22, 18, 28, 0.92);
  border: 1px solid rgba(255, 211, 107, 0.45);
  color: var(--text-primary);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 14px rgba(255, 170, 60, 0.25);
  pointer-events: auto;
  animation: rise 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}
.draw-hud[hidden] { display: none !important; }
.draw-hud-text { font-size: 12px; color: #ffffff; font-weight: 500; letter-spacing: -0.01em; }
.draw-hud-text b { color: var(--festive-gold); font-weight: 700; }
.draw-clear-btn {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #ffd36b;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 211, 107, 0.35);
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.draw-clear-btn:hover {
  background: rgba(255, 211, 107, 0.25);
  color: #ffffff;
  border-color: #ffd36b;
  transform: scale(1.05);
}

@media (max-aspect-ratio: 1/1) {
  body:not([data-mode="home"]) .brand { top: auto; bottom: max(var(--space-2), env(safe-area-inset-bottom)); font-size: 10px; }
  [data-mode="gully"] .brand, [data-mode="mudra"] .brand { display: none; }
  .power { margin-right: 0; }
  .legend { flex-wrap: wrap; gap: 4px; padding: 4px; max-width: 100%; bottom: 8px; }
  .mudra-chip { padding: 6px 10px; gap: 6px; }
  .mudra-title { font-size: 11px; }
  .mudra-sub { font-size: 9px; }
  .mudra-emoji { font-size: 16px; }
  .draw-hud { bottom: calc(max(16px, env(safe-area-inset-bottom)) + 84px); padding: 5px 12px; font-size: 11px; max-width: 94%; }
  .draw-hud-text { font-size: 11px; }
  .legend-sep { height: 18px; margin: 0 1px; }
}
