:root {
  --bg: #1d0738;
  --bg-2: rgba(28, 6, 52, 0.72);
  --card: rgba(46, 12, 82, 0.58);
  --card-2: rgba(92, 28, 120, 0.62);
  --edge: rgba(247, 201, 72, 0.22);
  --text: #fff6e5;
  --muted: #d9c6f0;
  --gold: #f7c948;
  --gold-deep: #d99a1e;
  --magenta: #b0207a;
  --orange: #ff7a1a;
  --red: #ff3d3d;
  --green: #3ddc84;
  --radius: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  /* The festive night sky: deep violet into magenta, with warm glows. */
  background:
    radial-gradient(ellipse at 85% 75%, rgba(255, 140, 60, 0.28) 0%, transparent 45%),
    radial-gradient(ellipse at 10% 0%, rgba(150, 70, 255, 0.35) 0%, transparent 55%),
    linear-gradient(125deg, #1d0738 0%, #3a0c63 45%, #6e1563 85%, #8a1c55 100%) fixed;
  min-height: 100%;
  color: var(--text);
  font-family: "Baloo 2", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
h1, h2, h3 { margin: 0 0 12px; line-height: 1.15; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.wrap { max-width: 560px; margin: 0 auto; padding: 16px; }
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  border: 1px solid var(--edge);
  box-shadow: 0 10px 30px rgba(10, 0, 25, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
/* Title type: an elegant gold serif, like a festive greeting card. */
.brand { font-family: "Cinzel", Georgia, serif; font-size: 27px; font-weight: 700; letter-spacing: 0.5px; }
.brand span, .gold-text {
  background: linear-gradient(180deg, #fff1b8 0%, var(--gold) 45%, var(--gold-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

button, .btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 16px 18px;
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  color: #1b0f2e;
  background: var(--gold);
  cursor: pointer;
  width: 100%;
  touch-action: manipulation;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.secondary { background: var(--card-2); color: var(--text); }
button.danger { background: var(--red); color: #fff; }
button.small { padding: 8px 12px; font-size: 14px; width: auto; }

input, select {
  font-family: inherit;
  width: 100%;
  font-size: 20px;
  padding: 14px;
  border-radius: 12px;
  border: 2px solid var(--card-2);
  background: var(--bg-2);
  color: var(--text);
  margin-bottom: 12px;
}
input:focus, select:focus { outline: none; border-color: var(--gold); }
label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--muted); }

.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 14px; }
.avatars button { font-size: 28px; padding: 10px 0; background: var(--bg-2); border: 2px solid transparent; }
.avatars button.sel { border-color: var(--gold); background: var(--card-2); }

.list { list-style: none; padding: 0; margin: 0; }
.list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .score { font-weight: 800; color: var(--gold); }
.off { opacity: 0.4; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 > * { min-width: 0; } /* long content wraps instead of widening the page */
.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 10px; align-items: center; }

.toast {
  position: fixed; left: 50%; top: 14px; transform: translateX(-50%);
  background: #3d1260; color: var(--text); padding: 10px 16px; border-radius: 999px;
  border: 1px solid rgba(255, 201, 74, 0.5);
  font-weight: 700; z-index: 50; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
  max-width: calc(100% - 32px); text-align: center;
}

.flash {
  position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 24px;
  font-size: 44px; font-weight: 900; animation: flash 1.6s ease-out forwards; pointer-events: none;
}
.flash.boom { background: radial-gradient(circle, #fff3b0 0%, #ff7a1a 35%, #ff1f1f 70%, #3a0000 100%); color: #fff; }
.flash.safe { background: rgba(61, 220, 132, 0.85); color: #10301d; }
@keyframes flash {
  0% { opacity: 1; transform: scale(1.15); }
  15% { transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

/* Phataka Pass */
.bomb-zone { text-align: center; }
.bomb {
  font-size: 96px; display: inline-block; animation: shake 0.35s infinite;
  filter: drop-shadow(0 0 18px rgba(255, 122, 26, 0.9));
}
.bomb.fizzle { animation: shake 0.08s infinite; filter: drop-shadow(0 0 30px #fff); }
@keyframes shake {
  0%, 100% { transform: rotate(-6deg) scale(1); }
  50% { transform: rotate(6deg) scale(1.08); }
}
.question { font-size: 22px; font-weight: 800; margin: 10px 0 14px; }
.options { display: grid; gap: 10px; }
.options button { background: var(--card-2); color: var(--text); font-size: 20px; }
.targets { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.targets button { background: var(--orange); color: #1b0f2e; font-size: 18px; }
.locked { color: var(--red); font-weight: 800; font-size: 22px; }
.safe-zone { text-align: center; font-size: 22px; }
.safe-zone .big { font-size: 72px; }
.holders { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }
.chip { background: var(--card-2); border-radius: 999px; padding: 6px 12px; font-weight: 700; }
.chip.hot { background: var(--orange); color: #1b0f2e; }

/* Ladoo Relay */
.team-badge { display: inline-block; padding: 6px 12px; border-radius: 999px; font-weight: 800; color: #1b0f2e; }
#thali-screen { position: fixed; inset: 0; background: var(--bg); z-index: 40; display: flex; flex-direction: column; touch-action: none; }
#thali-screen .hud { display: flex; justify-content: space-between; padding: 12px 16px; font-weight: 800; font-size: 20px; }
#thali-screen canvas { flex: 1; width: 100%; min-height: 0; }
#thali-screen .runner { text-align: center; font-size: 22px; font-weight: 800; padding: 4px 16px; }
#thali-screen .controls { padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); }
.countdown { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 140px; font-weight: 900; color: var(--gold); pointer-events: none; }
.progress { height: 10px; background: var(--bg-2); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.progress > div { height: 100%; background: var(--gold); }

/* Host (TV) layout */
.host { display: grid; grid-template-columns: 340px 1fr; gap: 18px; padding: 18px; min-height: 100vh; }
.host .side .card { margin-bottom: 14px; }
.qr img { width: 100%; background: #fff; border-radius: 12px; padding: 8px; }
.code { font-size: 54px; font-weight: 900; letter-spacing: 8px; color: var(--gold); text-align: center; }
.join-url { text-align: center; color: var(--muted); word-break: break-all; font-size: 14px; }
.stage-title { font-size: 40px; font-weight: 900; }
.tv-bombs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin: 14px 0; }
.tv-bomb { background: var(--card-2); border-radius: var(--radius); padding: 18px; text-align: center; font-size: 26px; font-weight: 800; }
.tv-bomb .bomb { font-size: 64px; }
.feed li { font-size: 20px; }
.team-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 12px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.team-row:last-child { border-bottom: 0; }
.big-num { font-size: 26px; font-weight: 900; }

@media (max-width: 900px) {
  .host { grid-template-columns: 1fr; padding: 12px; }
  .code { font-size: 40px; }
  .stage-title { font-size: 30px; }
}

/* Party link words, shown big wherever someone has to read them out. */
.party-words { font-size: 30px; font-weight: 800; color: var(--gold); line-height: 1.1; word-break: break-word; margin: 2px 0 4px; }
.lock-row { margin-top: 14px; color: var(--text); font-weight: 600; cursor: pointer; }
.lock-row input { width: 22px; height: 22px; margin: 0; accent-color: var(--gold); }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 14px; background: var(--card); border-radius: var(--radius); }
.topbar .face { font-size: 34px; }
.topbar .who { flex: 1; min-width: 0; }
.topbar .who b { display: block; font-size: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .who small { color: var(--muted); }
.topbar .pts { font-size: 28px; font-weight: 800; color: var(--gold); }
.hero { text-align: center; padding: 22px 18px; }
.hero .big { font-size: 64px; line-height: 1; }
.choice { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--text); }
.choice .ic { font-size: 36px; }
.choice b { display: block; font-size: 20px; }

/* Question difficulty badges */
.chip.level-easy { background: #1f7a4d; color: #eafff3; }
.chip.level-medium { background: #a77b00; color: #fff6dc; }
.chip.level-hard { background: #a3243b; color: #ffe6ea; }

/* ---------- Festive backdrop (built by js/festive.js) ---------- */
.festive { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
body > *:not(.festive):not(.toast):not(.flash) { position: relative; z-index: 1; }
.festive .fireworks { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.85; }
.festive .mandala {
  position: absolute; width: min(120vh, 95vw); height: min(120vh, 95vw); right: -18vw; top: 50%;
  transform: translateY(-50%); opacity: 0.32; animation: spin 240s linear infinite;
}
.mandala .m-line { fill: none; stroke: var(--gold); stroke-width: 0.35; opacity: 0.55; }
.mandala .m-dash { stroke-dasharray: 1.2 2.2; }
.mandala .m-petal { fill: none; stroke: #ff9fcf; stroke-width: 0.4; opacity: 0.6; }
.mandala .m-dot { fill: var(--gold); opacity: 0.7; }
@keyframes spin { from { transform: translateY(-50%) rotate(0deg); } to { transform: translateY(-50%) rotate(360deg); } }

/* A diya: clay bowl with a gold rim, a flickering flame and a warm glow. */
.diya { position: absolute; width: calc(52px * var(--s, 1)); height: calc(46px * var(--s, 1)); }
.diya .bowl {
  position: absolute; bottom: 0; left: 0; right: 0; height: 45%;
  background: radial-gradient(ellipse at 50% 0%, #ffb24a 0%, #c9561a 55%, #6d2208 100%);
  border-radius: 6% 6% 50% 50% / 10% 10% 90% 90%;
  box-shadow: inset 0 3px 0 #ffd27a, 0 0 18px rgba(255, 150, 40, 0.55);
}
.diya .flame {
  position: absolute; left: 50%; bottom: 40%; width: 26%; height: 60%; margin-left: -13%;
  background: radial-gradient(ellipse at 50% 75%, #ffffff 0%, #fff3b0 22%, #ffc93a 48%, #ff7a1a 72%, rgba(255, 90, 0, 0) 76%);
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  transform-origin: 50% 100%;
  filter: drop-shadow(0 0 8px rgba(255, 190, 60, 0.95)) drop-shadow(0 0 22px rgba(255, 120, 20, 0.6));
  animation: flicker 1.2s ease-in-out infinite alternate;
}
@keyframes flicker {
  0% { transform: scale(1, 1) rotate(-2deg); opacity: 0.95; }
  25% { transform: scale(0.94, 1.08) rotate(2deg); }
  50% { transform: scale(1.04, 0.94) rotate(-1deg); opacity: 1; }
  75% { transform: scale(0.97, 1.05) rotate(3deg); }
  100% { transform: scale(1.02, 0.98) rotate(-3deg); opacity: 0.9; }
}
.diya.hang { top: var(--len); left: var(--x); --s: 0.8; animation: sway 6s ease-in-out infinite alternate; transform-origin: 50% calc(-1 * var(--len)); }
.diya.hang-r { left: auto; right: var(--x); animation-duration: 7s; }
.diya.hang::before {
  content: ""; position: absolute; left: 50%; bottom: 40%; width: 1px; height: calc(var(--len) + 40%);
  background: linear-gradient(var(--gold), rgba(247, 201, 72, 0.4)); transform: translateX(-50%);
}
.diya.hang .bowl::before { content: ""; position: absolute; left: 10%; right: 10%; top: -3px; height: 3px; border-radius: 3px; background: var(--gold); }
@keyframes sway { from { transform: rotate(-3deg); } to { transform: rotate(3deg); } }

@media (prefers-reduced-motion: reduce) {
  .festive .mandala, .diya, .diya .flame { animation: none; }
}

/* The phataka fuse: drains to the answer deadline, glows red near the end. */
.fuse { position: relative; height: 18px; margin-top: 12px; border-radius: 999px; background: rgba(0, 0, 0, 0.35); overflow: hidden; border: 1px solid var(--edge); }
.fuse-fill { height: 100%; width: 100%; border-radius: 999px; background: linear-gradient(90deg, #ffd23f, #ff8a3d); box-shadow: 0 0 14px rgba(255, 180, 60, 0.7); }
.fuse-fill.hot { background: linear-gradient(90deg, #ff3d3d, #ff8a3d); animation: fuse-pulse 0.35s ease-in-out infinite alternate; }
.fuse-secs { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-weight: 800; font-size: 13px; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); }
@keyframes fuse-pulse { from { filter: brightness(1); } to { filter: brightness(1.5); } }

/* Points card */
.points-list { margin: 0; padding-left: 18px; color: var(--muted); }
.points-list li { margin: 3px 0; }

/* Tambola (phone) */
.tambola-now { text-align: center; padding: 14px; }
.now-num { font-size: 76px; font-weight: 800; color: var(--gold); line-height: 1; margin: 4px 0; text-shadow: 0 0 24px rgba(255, 201, 74, 0.45); }
.recent { display: flex; gap: 6px; justify-content: center; margin-top: 8px; }
.recent span { background: var(--bg-2); border-radius: 999px; padding: 2px 10px; font-weight: 700; color: var(--muted); }
.ticket { display: grid; grid-template-columns: repeat(9, 1fr); gap: 3px; background: #f3dfb0; padding: 4px; border-radius: 10px; }
.ticket .cell { padding: 0; height: 40px; border-radius: 6px; background: #fff8e8; color: #3a1a00; font-size: 17px; font-weight: 800; }
.ticket .cell.blank { background: transparent; opacity: 1; }
.ticket .cell.marked { background: radial-gradient(circle, #ff7a1a 55%, #b0207a 100%); color: #fff; }
.automark { gap: 6px; color: var(--muted); font-weight: 600; margin: 0; }
.automark input { width: 20px; height: 20px; margin: 0; accent-color: var(--gold); }
.claims { display: grid; gap: 8px; }
.claims button { font-size: 17px; padding: 12px; }

/* Diwali Decode (phone and host) */
.decode-banner { border: 2px solid; }
.decode-clue { font-size: 22px; font-weight: 800; margin-top: 6px; }
.clue-form { display: grid; grid-template-columns: 1fr 70px; gap: 8px; }
.clue-form input, .clue-form select { margin: 0; text-transform: uppercase; }
.decode-board { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.decode-board .word { padding: 10px 1px; min-height: 52px; font-size: clamp(8px, calc((100vw - 64px) / 5 / (var(--len, 6) * 0.72)), 12px); font-weight: 800; letter-spacing: -0.3px; border-radius: 8px; background: #fff3dc; color: #2b1340; word-break: normal; overflow-wrap: normal; white-space: nowrap; overflow: hidden; line-height: 1.1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.decode-board .word:disabled { opacity: 1; cursor: default; }
.decode-board .word small { font-size: 12px; }
.decode-board .word.pick { outline: 3px solid var(--gold); transform: scale(1.05); }
.decode-board .word.rev { color: #fff; }
.decode-board .word.rev.k-neutral { background: #8a7a5c; }
.k-red { --k: #e63946; }
.k-blue { --k: #3a86ff; }
.k-neutral { --k: #c9b48a; }
.k-bomb { --k: #111; }
.decode-board .word.rev { background: var(--k); }
.decode-board .word.hint { box-shadow: inset 0 -6px 0 var(--k); border: 2px solid var(--k); background: color-mix(in srgb, var(--k) 30%, #fff3dc); }
.decode-board .word.hint.k-bomb { background: #2a2a2a; color: #fff; }
/* Keep the score clear of the two hanging diyas in the top-right corner. */
.topbar .pts { margin-right: 76px; }

/* Tambola: several tickets */
.ticket-wrap + .ticket-wrap { margin-top: 10px; }
.ticket-label { font-size: 12px; margin-bottom: 4px; }
/* Decode team picking */
.pick-team { border: 2px solid transparent; }
.pick-team.mine { box-shadow: 0 0 18px rgba(255, 255, 255, 0.18); }

/* Host: game tiles and the "Next up" screen */
.game-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.game-tile { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 4px; padding: 14px 12px; min-width: 0; background: var(--card); color: var(--text); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 16px; }
.game-tile:active { transform: scale(0.98); }
.game-tile .t-icon { font-size: 30px; line-height: 1; }
.game-tile .t-name { font-size: 17px; font-weight: 800; }
.game-tile .t-blurb { font-size: 13px; font-weight: 500; color: var(--muted); line-height: 1.3; }
.game-tile .t-min { font-size: 12px; color: var(--gold); font-weight: 700; }
.game-tile .t-min.short { color: #ff9f9f; }
.rules { margin: 4px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; line-height: 1.35; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.seg button { width: auto; flex: 1 1 auto; padding: 9px 10px; font-size: 14px; }
.seg button.on { background: var(--gold); color: #1b0f2e; }
/* Phone: tonight's games */
.games-list li { align-items: flex-start; }
.games-list .g-icon { font-size: 22px; }
.games-list .g-name { font-weight: 800; }
.games-list .g-blurb { color: var(--muted); font-size: 13px; }

/* Host judging */
.judge-answer { background: rgba(125, 255, 176, 0.12); border: 1px solid rgba(125, 255, 176, 0.4); color: #7dffb0; border-radius: 12px; padding: 10px 12px; font-weight: 800; font-size: 18px; }
button.yes { background: #2fbf71; color: #fff; }
button.no { background: #e5484d; color: #fff; }
.jg-phone-task { font-size: 24px; font-weight: 800; text-align: center; line-height: 1.25; }
.jg-phone-letter { font-size: 64px; font-weight: 900; color: var(--gold); text-align: center; line-height: 1; }
.jg-phone-secs { font-size: 40px; font-weight: 900; text-align: center; color: var(--gold); font-variant-numeric: tabular-nums; }
.jg-phone-secs.hot { color: #ff5a5a; }
.mine-turn { box-shadow: 0 0 0 2px var(--gold), 0 0 24px rgba(255, 201, 74, 0.35); }
button.lvl-easy { background: #2fbf71; color: #fff; }
button.lvl-medium { background: var(--gold); color: #1b0f2e; }
button.lvl-hard { background: #e5484d; color: #fff; }
.claims button.tie { background: #ff8a3d; color: #1b0f2e; animation: fuse-pulse 0.3s ease-in-out infinite alternate; }

/* Phone: a short shake when the phataka bursts on you */
@keyframes ph-shake { 10%, 90% { transform: translateX(-3px); } 30%, 70% { transform: translateX(6px); } 50% { transform: translateX(-6px); } }
body.shake #app { animation: ph-shake 0.45s both; }
@media (prefers-reduced-motion: reduce) { body.shake #app { animation: none; } }

/* Landing page */
.landing .lead { font-size: 24px; line-height: 1.2; margin: 6px 0 4px; }
.landing .cta { margin-top: 14px; }
.btn { display: block; text-align: center; text-decoration: none; padding: 14px 16px; border-radius: 14px; font-weight: 800; font-size: 18px; background: var(--gold); color: #1b0f2e; }
.btn.secondary { background: var(--card-2); color: var(--text); }
.landing .steps, .landing .tips { padding-left: 20px; margin: 6px 0 0; display: flex; flex-direction: column; gap: 8px; line-height: 1.4; }
.landing .faq dt { font-weight: 800; margin-top: 10px; }
.landing .faq dd { margin: 2px 0 0; color: var(--muted); line-height: 1.4; }
.landing .foot { text-align: center; margin: 18px 0 30px; }
.landing a { color: var(--gold); }
.landing a.btn { color: #1b0f2e; }
.landing a.btn.secondary { color: var(--text); }
.btn.whatsapp { background: #25d366; color: #06301a; }

/* Privacy & terms page and small footer links */
.legal h2 { margin: 0 0 8px; }
.legal p { line-height: 1.5; }
.legal .home { color: inherit; text-decoration: none; }
.legal .choice { margin: 12px 0 8px; }
.small { font-size: 13px; }
.foot { text-align: center; }
.foot a { color: var(--gold); }

/* Feedback stars */
.feedback .stars { display: flex; gap: 6px; margin: 6px 0 10px; }
.feedback .star { width: auto; flex: 1; font-size: 30px; line-height: 1; padding: 8px 0; background: transparent; color: var(--gold); border: 1px solid rgba(255, 201, 74, 0.35); }
.feedback textarea { width: 100%; margin: 0 0 10px; }
/* One-tap thumbs after a game */
.thumbs { padding: 12px 14px; }
.thumbs-q { margin: 0 0 8px; font-weight: 700; }
.thumbs-row { display: flex; gap: 10px; }
.thumbs-row button { flex: 1; }
.thumb { font-size: 26px; padding: 8px 0; background: transparent; border: 1px solid rgba(255, 255, 255, 0.25); }
.thumbs input { width: 100%; margin: 0 0 8px; }
