:root { --plum: #4a0b33; --plum2: #2e0620; --mag: #c2185b; --saffron: #ff8f1f; --gold: #ffc93d; --cream: #fff6e0; --ink: #3b1a10;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif; }
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { background: #3a0828 url(img/bg_wide.webp) center / cover no-repeat; font-family: var(--font); color: var(--cream); user-select: none; -webkit-user-select: none; touch-action: none; }
@media (max-aspect-ratio: 1/1) { body { background-image: url(img/bg_tall.webp); } }
button { font-family: var(--font); }
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
header { position: relative; z-index: 3; display: flex; align-items: center; gap: 8px; padding: 6px 10px; padding-top: max(6px, env(safe-area-inset-top));
  background: linear-gradient(#7a1450, var(--plum2)); box-shadow: 0 2px 10px rgba(0,0,0,.45); border-bottom: 3px solid #e3a12c; }
header h1 { margin: 0; font-size: 22px; font-weight: 900; color: var(--gold); text-shadow: 0 2px 0 #7a2a00; letter-spacing: .02em; }
.sp { flex: 1; }
.hbtn { height: 40px; min-width: 40px; border-radius: 12px; border: 2px solid rgba(255,214,120,.4); background: rgba(0,0,0,.25); color: #ffe7b0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 8px; }
.hbtn svg { width: 22px; height: 22px; }
.tabs { display: flex; background: rgba(0,0,0,.3); border-radius: 999px; padding: 3px; border: 2px solid rgba(255,214,120,.35); }
.tabs button { border: 0; background: none; color: #ffdca0; font-weight: 800; font-size: 14px; padding: 7px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.tabs button.on { background: linear-gradient(#ffd75e, #f2a71b); color: #4a1d00; }
main { position: relative; flex: 1; min-height: 0; }
.view { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 6px; padding: 8px 10px max(8px, env(safe-area-inset-bottom)); max-width: 1180px; margin: 0 auto; }

/* caller */
.caller { display: flex; align-items: center; gap: 10px; background: rgba(46,6,32,.82); border: 2px solid #e3a12c; border-radius: 18px; padding: 6px 10px; box-shadow: 0 6px 16px rgba(0,0,0,.35); }
.mithu { width: 64px; height: 68px; object-fit: contain; flex: none; transform-origin: 50% 90%; }
.mithu.talk { animation: talk .5s ease; }
@keyframes talk { 30% { transform: rotate(-6deg) scale(1.08); } 70% { transform: rotate(4deg); } }
.ball { flex: none; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 28px; color: #3b1a10;
  background: radial-gradient(circle at 35% 30%, #fff 0 18%, var(--bc, #ffc93d) 55%, color-mix(in srgb, var(--bc, #ffc93d) 70%, #000) 100%); box-shadow: 0 4px 0 rgba(0,0,0,.3), inset 0 -4px 8px rgba(0,0,0,.2); }
.ball span { background: #fff; border-radius: 50%; width: 62%; height: 62%; display: grid; place-items: center; box-shadow: inset 0 0 0 2px rgba(0,0,0,.12); }
.ball.pop { animation: pop .45s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { from { transform: scale(.3) rotate(-90deg); } }
.callTxt { flex: 1; min-width: 0; }
.say { font-size: 18px; font-weight: 800; color: var(--gold); line-height: 1.25; }
.meta { font-size: 13px; color: #ffd9b0; margin-top: 3px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.recent { display: inline-flex; gap: 4px; }
.recent b { min-width: 24px; height: 24px; padding: 0 3px; border-radius: 12px; background: rgba(255,255,255,.14); color: #fff; display: inline-grid; place-items: center; font-size: 12px; }
.callBtns { display: flex; flex-direction: column; gap: 6px; }
.pill { border: 2px solid rgba(255,214,120,.45); background: rgba(0,0,0,.3); color: #ffe7b0; font-weight: 800; font-size: 14px; border-radius: 999px; padding: 7px 12px; cursor: pointer; min-height: 38px; }
.pill.gold { background: linear-gradient(#ffd75e, #f2a71b); color: #4a1d00; border-color: #a8670b; }
.pill.on { background: #2e8b57; color: #fff; border-color: #a7f3c6; }
.pill.sel select { background: transparent; color: inherit; border: 0; font: inherit; }
.pill.sel select option { color: #000; }

/* rivals + claims */
.rivals { display: flex; gap: 6px; }
.rival { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; background: rgba(46,6,32,.75); border-radius: 14px; padding: 4px 8px 4px 4px; border: 2px solid rgba(255,255,255,.12); }
.rival img { width: 36px; height: 36px; flex: none; }
.rival .rn { font-size: 13px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rival .rs { font-size: 11px; color: #ffd9b0; white-space: nowrap; }
.rival.you { border-color: var(--gold); background: rgba(120,60,0,.6); }
.rival.flash { animation: flash .9s ease; }
@keyframes flash { 30% { background: #e3a12c; } }
.claims { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.claim { position: relative; border: 0; border-radius: 14px; padding: 6px 4px; cursor: pointer; color: #4a1d00; font-weight: 900; font-size: 14px; line-height: 1.15;
  background: linear-gradient(#ffe08a, #f5a623); box-shadow: 0 4px 0 #a8670b; min-height: 46px; }
.claim small { display: block; font-size: 11px; font-weight: 700; opacity: .8; }
.claim:active { transform: translateY(2px); box-shadow: 0 2px 0 #a8670b; }
.claim.done { background: linear-gradient(#8a6a80, #5c3f55); color: #f3e3ee; box-shadow: 0 4px 0 #2e1a28; cursor: default; }
.claim.mine { background: linear-gradient(#5be39a, #22a35d); color: #05351b; box-shadow: 0 4px 0 #0f6a39; }
.claim.locked { filter: grayscale(.7) brightness(.8); }
.claim.ready { animation: glow 1s ease-in-out infinite alternate; }
@keyframes glow { to { box-shadow: 0 4px 0 #a8670b, 0 0 0 4px #fff7, 0 0 18px #ffe08a; transform: translateY(-2px); } }
.claim.shake, .ticket.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.hint { font-size: 14px; color: #fff; text-align: center; background: rgba(0,0,0,.35); border-radius: 10px; padding: 4px 8px; }
.hint b { color: var(--gold); }

/* tickets */
.tickets { flex: 1; min-height: 0; overflow-y: auto; touch-action: pan-y; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 430px), 1fr)); gap: 10px; align-content: start; padding: 2px 2px 10px; }
.ticket { background: var(--cream); border-radius: 14px; border: 3px solid #e3a12c; box-shadow: 0 0 0 3px var(--plum), 0 8px 18px rgba(0,0,0,.4); padding: 6px; color: var(--ink); }
.ticket .tt { display: flex; justify-content: space-between; font-size: 12px; font-weight: 900; color: var(--mag); padding: 0 2px 4px; letter-spacing: .03em; }
.ticket .tt i { font-style: normal; color: #8a5a32; }
.grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 3px; }
.cell { position: relative; aspect-ratio: 1.05; border-radius: 7px; display: grid; place-items: center; font-weight: 900; font-size: clamp(14px, 3.6vw, 20px); }
.cell.blank { background: repeating-linear-gradient(45deg, #f7dfae 0 6px, #f2d39a 6px 12px); }
.cell.num { background: #fff; box-shadow: inset 0 0 0 2px #f0c989; cursor: pointer; }
.cell.num.due { box-shadow: inset 0 0 0 3px #22a35d; }
.cell.num.dab::after { content: ""; position: absolute; inset: 9%; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #ff5c8a, #d0105a 70%); opacity: .82; animation: dab .25s ease-out; }
.cell.num.dab { color: #fff; }
.cell.num.dab span { position: relative; z-index: 1; text-shadow: 0 1px 1px rgba(0,0,0,.4); }
.cell.num.win::after { background: radial-gradient(circle at 40% 35%, #ffe066, #f08c00 70%); }
@keyframes dab { from { transform: scale(1.8); opacity: 0; } }
.cell.nope { animation: shake .35s; background: #ffd6d6; }

/* host */
.hostTop { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.hostCaller { flex: 1 1 380px; display: flex; gap: 12px; align-items: center; background: rgba(46,6,32,.82); border: 2px solid #e3a12c; border-radius: 18px; padding: 10px; }
.ball.hball { width: 104px; height: 104px; font-size: 44px; }
.hostSay { flex: 1; min-width: 0; }
.hostSay .say { font-size: 20px; }
.hist { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.hist b { min-width: 28px; height: 28px; border-radius: 14px; background: rgba(255,255,255,.15); display: inline-grid; place-items: center; font-size: 13px; padding: 0 4px; }
.hist b:first-child { background: var(--gold); color: #4a1d00; }
.hostCtl { flex: 1 1 300px; display: flex; flex-direction: column; gap: 6px; justify-content: center; background: rgba(46,6,32,.82); border: 2px solid #e3a12c; border-radius: 18px; padding: 10px; }
.ctlRow { display: flex; gap: 6px; flex-wrap: wrap; }
.ctlRow .pill { flex: 1; }
.board { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(10, 1fr); grid-auto-rows: 1fr; gap: 4px; background: rgba(46,6,32,.82); border: 2px solid #e3a12c; border-radius: 18px; padding: 8px; }
.board b { display: grid; place-items: center; border-radius: 8px; background: rgba(255,255,255,.08); color: rgba(255,240,220,.55); font-size: clamp(12px, 2.4vh, 22px); font-weight: 800; min-height: 0; }
.board b.on { background: linear-gradient(#ffd75e, #f2a71b); color: #4a1d00; }
.board b.last { background: linear-gradient(#ff5c8a, #c2185b); color: #fff; animation: pop .45s cubic-bezier(.2,1.6,.4,1); }
.board.small { height: min(60vh, 420px); flex: none; margin: 8px 0; }

/* overlays */
.ov { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(30,4,20,.5); padding: 12px; }
.card { position: relative; width: min(440px, 100%); max-height: calc(100% - 4px); overflow: auto; touch-action: pan-y; background: linear-gradient(#fffaf0, #f8e6c4); color: var(--ink);
  border-radius: 22px; border: 4px solid #e3a12c; box-shadow: 0 0 0 4px var(--plum), 0 16px 44px rgba(0,0,0,.55); padding: 12px 18px 16px; text-align: center; animation: cardIn .35s cubic-bezier(.2,1.5,.4,1); }
.card.wide { width: min(900px, 100%); }
@keyframes cardIn { from { transform: scale(.7); opacity: 0; } }
.cardMithu { width: 84px; height: auto; display: block; margin: -2px auto 0; }
.card h2 { margin: 2px 0 4px; font-size: 26px; line-height: 1.2; color: var(--mag); }
.card h3 { margin: 4px 0; font-size: 22px; color: var(--mag); }
.intro { margin: 0 0 8px; font-size: 14px; line-height: 1.45; color: #6b3b1f; }
.row { margin: 8px 0; }
.row > span { display: block; font-size: 13px; font-weight: 800; color: #8a5a32; margin-bottom: 4px; }
.seg { display: flex; background: #f0dcb4; border-radius: 999px; padding: 3px; border: 2px solid #dfc08a; }
.seg button { flex: 1; border: 0; background: none; color: #6b3b1f; font-weight: 800; font-size: 15px; padding: 7px 4px; border-radius: 999px; cursor: pointer; min-height: 40px; }
.seg button.on { background: var(--mag); color: #fff; box-shadow: 0 2px 0 #6a0b31; }
.big { display: block; width: 100%; border: 0; border-radius: 16px; padding: 12px; margin-top: 10px; font-weight: 900; font-size: 22px; cursor: pointer; color: #4a1d00;
  background: linear-gradient(#ffd75e, #f2a71b); box-shadow: 0 5px 0 #a8670b, 0 8px 18px rgba(0,0,0,.2); }
.big small { font-size: 13px; opacity: .7; }
.big:active { transform: translateY(3px); box-shadow: 0 2px 0 #a8670b; }
.big.alt { background: linear-gradient(#d22c6c, #9c1048); color: #fff; box-shadow: 0 5px 0 #5a0628; font-size: 16px; padding: 10px; }
.hostCtl .big { margin-top: 0; }
.ctlHint { margin-top: 10px; font-size: 13px; color: #6b3b1f; }
.key { display: inline-block; min-width: 22px; padding: 1px 6px; border-radius: 6px; background: #fff; border: 2px solid #d9b77a; border-bottom-width: 4px; font-weight: 800; font-size: 12px; }
.stats { margin-top: 8px; font-size: 13px; color: #8a5a32; font-weight: 700; }
details { margin-top: 10px; text-align: left; font-size: 14px; line-height: 1.5; background: #fff3d9; border-radius: 12px; padding: 6px 12px; border: 1px solid #e7cf9f; }
summary { cursor: pointer; font-weight: 800; color: var(--mag); text-align: center; }
details ul { margin: 6px 0; padding-left: 18px; }
.hindi { margin: 4px 0; }
.results { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: 14px; }
.results td { padding: 6px 4px; border-bottom: 1px solid #ecd3a3; text-align: left; }
.results td:last-child { text-align: right; font-weight: 900; color: var(--mag); font-size: 16px; }
.results img { width: 30px; height: 30px; vertical-align: middle; }
.results tr.you td { background: #fff0c4; }
.results .cl { font-size: 11px; color: #8a5a32; }
.genRow { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; font-size: 14px; font-weight: 800; color: #6b3b1f; }
.genRow label { display: flex; align-items: center; gap: 6px; }
.genRow input { font: inherit; padding: 6px 8px; border-radius: 10px; border: 2px solid #dfc08a; width: 210px; }
.step { display: inline-flex; align-items: center; }
.step input { width: 58px; text-align: center; }
.step button { width: 38px; height: 38px; border-radius: 10px; border: 2px solid #dfc08a; background: #fff; font-weight: 900; font-size: 18px; cursor: pointer; }
.genBtns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 10px 0 4px; }
.genBtns .pill:not(.gold) { background: var(--plum); }
.genMsg { min-height: 18px; font-size: 13px; color: #2e8b57; font-weight: 700; }
.genList { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 8px; text-align: left; }
.genList .ticket { box-shadow: none; border-width: 2px; }
.genList .cell { font-size: 15px; cursor: default; }

.toast { position: fixed; left: 50%; top: 22%; transform: translate(-50%, -20px) scale(.9); z-index: 20; background: linear-gradient(#ffd75e, #f2a71b); color: #4a1d00; font-weight: 900; font-size: 20px;
  padding: 12px 20px; border-radius: 18px; border: 3px solid #fff; box-shadow: 0 10px 30px rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: .25s; text-align: center; max-width: 92vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.toast.bad { background: linear-gradient(#ffb3c6, #e05a7f); color: #3a0016; }
.toast.good { background: linear-gradient(#a7f3c6, #22a35d); color: #05351b; }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }
#printArea { display: none; }

@media (max-width: 760px) {
  .claims { grid-template-columns: repeat(3, 1fr); }
  .claim { min-height: 42px; font-size: 13px; }
}
@media (max-width: 520px) {
  header h1 { font-size: 18px; }
  header { gap: 6px; padding-left: 6px; padding-right: 6px; }
  .tabs button { padding: 7px 9px; font-size: 13px; }
  .hbtn { min-width: 36px; padding: 0 5px; }
  .mithu { width: 46px; height: 50px; }
  .ball { width: 54px; height: 54px; font-size: 22px; }
  .say { font-size: 15px; }
  .pill { font-size: 12px; padding: 5px 8px; min-height: 34px; }
  .rival .rs { font-size: 10px; }
  .rival img { width: 30px; height: 30px; }
  .hint { font-size: 12px; }
  .view { gap: 5px; padding: 6px 6px max(6px, env(safe-area-inset-bottom)); }
  .ball.hball { width: 78px; height: 78px; font-size: 32px; }
  .rivals { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
  .rival { padding: 2px 6px 2px 2px; }
  .hostSay .say { font-size: 16px; }
  .board { gap: 3px; padding: 5px; }
}
@media (max-width: 380px) { #bHome { display: none; } }

@media print {
  @page { margin: 10mm; }
  body { background: #fff !important; overflow: visible; height: auto; }
  #app, .ov, .toast, #fx { display: none !important; }
  html, body { height: auto; overflow: visible; }
  #printArea { display: block; color: #000; }
  #printArea h1 { font-size: 18px; margin: 0 0 8px; text-align: center; }
  #printArea .plist { display: grid; grid-template-columns: 1fr 1fr; gap: 8mm; }
  #printArea .ticket { break-inside: avoid; box-shadow: none; border: 2px solid #000; background: #fff; }
  #printArea .ticket .tt { color: #000; }
  #printArea .cell.num { box-shadow: inset 0 0 0 1px #000; }
  #printArea .cell.blank { background: #eee; }
}
