:root {
  --bg: #1a0a05;
  --bg2: #2b120a;
  --marigold: #ff9f1c;
  --haldi: #ffd23f;
  --sindoor: #e63946;
  --nazar: #1e5bd6;
  --nazar-light: #6ec6ff;
  --cream: #fff4e0;
  --muted: #c9a98a;
  --wa: #25d366;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse at top, #4a1a0c 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--cream);
  font-family: "Baloo 2", system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow-x: hidden;
}
button, input { font: inherit; }
button, a, .item { touch-action: manipulation; } /* no double-tap zoom delay on phones */
[hidden] { display: none !important; }

.screen { display: none; min-height: 100dvh; }
.screen.active { display: block; }

/* ---------- intro ---------- */
#intro { padding: calc(24px + var(--safe-t)) 16px calc(90px + var(--safe-b)); position: relative; }
.marigold-top {
  position: absolute; inset: 0 0 auto 0; height: 38px; pointer-events: none;
  background:
    radial-gradient(circle at 12px 10px, var(--marigold) 9px, transparent 10px) 0 0 / 24px 22px repeat-x,
    radial-gradient(circle at 12px 10px, var(--haldi) 5px, transparent 6px) 12px 8px / 24px 22px repeat-x;
  opacity: .9;
}
.intro-inner { max-width: 440px; margin: 28px auto 0; text-align: center; }
.eye { font-size: 72px; line-height: 1; animation: bob 3s ease-in-out infinite; filter: drop-shadow(0 0 24px rgba(110,198,255,.55)); }
@keyframes bob { 50% { transform: translateY(-8px) rotate(8deg); } }
h1 { font-size: clamp(44px, 12vw, 64px); margin: 8px 0 0; line-height: 1; font-weight: 800; letter-spacing: -1px; }
h1 span { color: var(--marigold); }
.hindi { font-family: "Tiro Devanagari Hindi", serif; font-size: 22px; margin: 4px 0 8px; color: var(--haldi); }
.tag { color: var(--muted); margin: 0 0 20px; font-size: 17px; line-height: 1.35; }
.tag b { color: var(--cream); }

.invite {
  background: linear-gradient(135deg, #3b1608, #5a220d);
  border: 2px dashed var(--marigold); border-radius: 16px;
  padding: 14px 16px; margin-bottom: 18px; font-size: 18px; line-height: 1.35;
  animation: pulse 2s ease-in-out infinite;
}
.invite b { color: var(--haldi); }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255,159,28,.15); } }

.field { display: block; text-align: left; margin-bottom: 16px; }
.field span { display: block; font-size: 15px; color: var(--muted); margin-bottom: 4px; }
input {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 2px solid #5a2f1c; background: #120603; color: var(--cream); font-size: 17px; outline: none;
}
input:focus { border-color: var(--marigold); }

.items { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 20px; }
.item {
  background: var(--bg2); border: 2px solid #4a2414; border-radius: 14px; color: var(--cream);
  padding: 10px 4px 8px; cursor: pointer; font-size: 13px; line-height: 1.15; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 2px; transition: transform .15s, border-color .15s;
}
.item i { font-style: normal; font-size: 30px; }
.item em { font-style: normal; font-weight: 500; font-size: 11px; color: var(--muted); }
.item.active { border-color: var(--marigold); background: #3d1a0b; transform: translateY(-2px); }

.btn {
  display: block; width: 100%; border: 0; border-radius: 14px; padding: 14px 18px;
  font-size: 18px; font-weight: 800; cursor: pointer; text-decoration: none; text-align: center;
  transition: transform .1s, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--marigold), var(--sindoor)); color: #fff; box-shadow: 0 8px 24px rgba(230,57,70,.35); }
.btn.ghost { background: transparent; color: var(--muted); font-weight: 600; font-size: 16px; margin-top: 8px; }
.btn.wa { background: var(--wa); color: #06331a; }
.btn.ig { background: linear-gradient(45deg, #f58529, #dd2a7b 50%, #8134af); color: #fff; }
.btn.share { margin-top: 10px; }
.btn:disabled { opacity: .6; cursor: progress; }

.step-title {
  display: flex; align-items: center; gap: 8px; text-align: left;
  font-size: 18px; font-weight: 800; color: var(--cream); margin: 6px 0 6px;
}
.step-title i {
  font-style: normal; flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: inline-grid; place-items: center; font-size: 14px;
  background: var(--marigold); color: #3b1a00;
}
.field .step-title { margin-bottom: 6px; }
.step-sub { text-align: left; margin: -4px 0 10px 34px; font-size: 14px; color: var(--muted); }

.notice {
  margin-top: 18px; padding: 12px 14px; border-radius: 14px; text-align: left;
  background: rgba(255,244,224,.06); border: 1px solid #4a2414; font-size: 14px; line-height: 1.4; color: var(--muted);
}
.notice p { margin: 0 0 6px; }
.notice b { color: var(--cream); }
.notice a, .foot a { color: var(--haldi); font-weight: 700; }

.send-box {
  max-width: 440px; margin: 36px auto 0; padding: 18px 16px;
  background: var(--bg2); border-radius: 18px; border: 1px solid #4a2414;
}
.send-box h3 { margin: 0 0 10px; font-size: 19px; }
.send-row { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.send-row input { flex: 1 1 140px; font-size: 16px; } /* <16px makes iOS zoom in on focus */

.faq { max-width: 440px; margin: 28px auto 0; }
.faq h2 { font-size: 22px; margin: 0 0 10px; text-align: center; }
.faq details {
  background: var(--bg2); border: 1px solid #4a2414; border-radius: 14px; margin-bottom: 8px; overflow: hidden;
}
.faq summary {
  cursor: pointer; list-style: none; padding: 12px 40px 12px 14px; font-weight: 700; font-size: 16px; position: relative;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 14px; top: 8px; font-size: 22px; color: var(--marigold); }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin: 0; padding: 0 14px 14px; color: #ecd9c4; font-size: 15px; line-height: 1.5; }
.faq a { color: var(--haldi); }
@media (min-width: 768px) { .faq { max-width: 520px; } }
.foot { text-align: center; color: #8a6a55; font-size: 13px; line-height: 1.9; margin-top: 28px; }
.foot b { color: var(--muted); }

/* ---------- stage ---------- */
#stage { position: fixed; inset: 0; background: #000; }
#stage.active { display: block; }
#video { display: none; }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }

.hud {
  position: absolute; top: calc(12px + var(--safe-t)); left: 12px; right: 60px;
  display: flex; gap: 10px; align-items: flex-start; pointer-events: none;
}
.counter {
  background: rgba(0,0,0,.55); backdrop-filter: blur(6px); border-radius: 16px; padding: 4px 14px;
  font-size: 22px; font-weight: 800; border: 2px solid var(--marigold); flex: none;
}
.counter b { font-size: 36px; color: var(--haldi); }
.counter span { color: var(--muted); }
.aunty {
  display: flex; gap: 8px; align-items: center; min-width: 0;
  background: rgba(255,244,224,.95); color: #3b1a00; border-radius: 18px 18px 18px 4px;
  padding: 8px 12px; font-weight: 700; font-size: 16px; line-height: 1.2;
  box-shadow: 0 6px 20px rgba(0,0,0,.35); transition: transform .2s;
}
.aunty.pop { animation: pop .35s ease; }
@keyframes pop { 40% { transform: scale(1.06); } }
.aunty-face { font-size: 28px; }
.aunty p { margin: 0; }

.hint {
  position: absolute; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%);
  background: rgba(0,0,0,.6); padding: 8px 16px; border-radius: 99px; font-size: 16px;
  width: max-content; max-width: calc(100% - 32px); text-align: center; line-height: 1.3;
  pointer-events: none;
}
.quit, .mute {
  position: absolute; width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.55); color: #fff; font-size: 18px; cursor: pointer; z-index: 20;
}
.quit { position: absolute; top: calc(12px + var(--safe-t)); right: 12px; }
.mute { top: calc(64px + var(--safe-t)); right: 12px; }

/* ---------- result ---------- */
#result { padding: calc(20px + var(--safe-t)) 16px calc(90px + var(--safe-b)); }
.result-inner { max-width: 460px; margin: 0 auto; text-align: center; }
.result-inner h2 { font-size: 34px; margin: 0 0 12px; }
#cert { width: 100%; border-radius: 16px; box-shadow: 0 14px 40px rgba(0,0,0,.5); display: block; margin-bottom: 16px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row .btn { flex: 1 1 180px; }
.fine { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.dev { margin: 20px 0 4px; padding: 16px 14px; border-radius: 16px; background: var(--bg2); border: 1px dashed var(--haldi); }
.dev p { margin: 0 0 12px; font-size: 17px; line-height: 1.35; }
.dev p b { color: var(--haldi); }
.dev-links { display: flex; gap: 10px; flex-wrap: wrap; }
.dev-links .btn {
  flex: 1 1 160px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 16px; padding: 12px 14px; overflow-wrap: anywhere;
}
.dev-links svg { width: 20px; height: 20px; flex: none; }
.btn.li { background: #0a66c2; color: #fff; }
.btn.igl { background: linear-gradient(45deg, #f58529, #dd2a7b 50%, #8134af); color: #fff; }
.stat {
  display: inline-block; margin: 0 0 18px; padding: 6px 14px; border-radius: 99px;
  background: rgba(30,91,214,.18); border: 1px solid rgba(110,198,255,.35); font-size: 16px;
}
.stat b { color: var(--nazar-light); font-size: 18px; }

body.playing { overflow: hidden; overscroll-behavior: none; } /* no rubber-band scroll behind the game */


/* ---------- tutorial ---------- */
.tutorial {
  position: absolute; inset: 0; z-index: 6; display: flex; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b)); background: rgba(20,6,3,.72); backdrop-filter: blur(3px);
}
.tutorial .tut-card { margin: auto; } /* centred, but scrolls instead of clipping on short screens */
.tut-card {
  width: min(400px, 100%); background: var(--cream); color: #3b1a00; border-radius: 22px;
  padding: 20px 18px 14px; box-shadow: 0 20px 60px rgba(0,0,0,.5); animation: pop .35s ease;
}
.tut-card h3 { margin: 0 0 12px; font-size: 24px; text-align: center; }
.tut-steps { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 10px; }
.tut-steps li {
  display: flex; gap: 12px; align-items: center; background: #fbe6c4; border-radius: 14px; padding: 10px 12px;
}
.tut-steps b { display: block; font-size: 17px; line-height: 1.2; }
.tut-steps small { display: block; font-size: 14px; color: #7a4a2a; line-height: 1.3; }
.tut-ico { font-size: 34px; flex: none; width: 44px; text-align: center; display: inline-block; }
.tut-ico.wave { animation: wave 1.4s ease-in-out infinite; transform-origin: 70% 90%; }
.tut-ico.spin { animation: spin 2.4s linear infinite; }
.tut-ico.flicker { animation: flicker .9s ease-in-out infinite; }
@keyframes wave { 0%,100% { transform: rotate(0); } 25% { transform: rotate(18deg); } 75% { transform: rotate(-12deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes flicker { 50% { transform: scale(1.12) translateY(-2px); } }
.tut-status {
  margin: 0 0 10px; padding: 8px 10px; border-radius: 10px; font-size: 14px; font-weight: 600;
  background: #ffe1cc; color: #8a2a00;
}
.tut-privacy { margin: 10px 0 0; font-size: 12px; text-align: center; color: #8a5a3c; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(16px + var(--safe-t)); transform: translateX(-50%); z-index: 50;
  width: max-content; max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 14px;
  background: var(--cream); color: #3b1a00; font-weight: 700; font-size: 15px; text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.45); animation: pop .3s ease;
}

/* ---------- responsive ---------- */
/* very small phones (iPhone SE 1st gen, small Androids) */
@media (max-width: 359px) {
  .items { grid-template-columns: repeat(2, 1fr); }
  .item { flex-direction: row; justify-content: center; gap: 6px; padding: 10px 6px; font-size: 14px; }
  .item i { font-size: 24px; }
  .item em { display: none; }
  .counter { padding: 2px 10px; }
  .counter b { font-size: 28px; }
  .aunty { font-size: 14px; padding: 6px 10px; }
  .aunty-face { font-size: 22px; }
  .hint { font-size: 14px; }
}
/* tablets and up: roomier layout */
@media (min-width: 768px) {
  #intro { padding-top: calc(40px + var(--safe-t)); }
  .intro-inner, .send-box { max-width: 520px; }
  .eye { font-size: 88px; }
  .tag { font-size: 19px; }
  .item { padding: 14px 6px 12px; font-size: 15px; }
  .item i { font-size: 38px; }
  .item em { font-size: 12px; }
  .result-inner { max-width: 560px; }
  .aunty { font-size: 19px; padding: 10px 16px; }
  .aunty-face { font-size: 34px; }
  .hint { font-size: 18px; padding: 10px 20px; }
  .tut-card { width: min(460px, 100%); }
}
/* phones held sideways: short screens, keep game UI compact */
@media (max-height: 500px) and (orientation: landscape) {
  .hud { top: calc(8px + var(--safe-t)); left: calc(8px + env(safe-area-inset-left, 0px)); }
  .counter { padding: 0 10px; }
  .counter b { font-size: 26px; }
  .aunty { font-size: 14px; padding: 6px 10px; max-width: 60vw; }
  .aunty-face { font-size: 22px; }
  .hint { bottom: calc(10px + var(--safe-b)); font-size: 14px; padding: 6px 14px; }
  .tutorial .tut-card { width: min(720px, 100%); padding: 14px 16px 10px; }
  .tut-card h3 { font-size: 20px; margin-bottom: 8px; }
  .tut-steps { grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
  .tut-steps li { flex-direction: column; text-align: center; gap: 4px; padding: 8px; }
  .tut-ico { font-size: 26px; width: auto; }
  .tut-steps small { font-size: 12px; }
  .tut-privacy { margin-top: 6px; }
  .quit, .mute { right: calc(12px + env(safe-area-inset-right, 0px)); }
  .mute { top: calc(60px + var(--safe-t)); }
}
@media (prefers-reduced-motion: reduce) {
  .eye, .invite, .tut-ico, .aunty.pop, .tut-card, .toast { animation: none !important; }
}
