:root{
  --ink:#1b0f45; --deep:#22105e; --purple:#4b22b8; --violet:#7a3df0; --gold:#ffc83d; --gold2:#ff9f1c;
  --white:#fff; --cream:#fff6e0; --green:#22c55e; --red:#ef4444;
  --a:#ff5d8f; --b:#2fb4ff; --c:#ffb020; --d:#34d17a;
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%;overflow:hidden;background:#1b0f45;color:var(--white);font-family:var(--font);touch-action:manipulation;user-select:none;-webkit-user-select:none}
#bg{position:fixed;inset:0;background:#2a1170 url(img/stage.webp) center 30%/cover no-repeat}
#bg::after{content:"";position:absolute;inset:0;background:linear-gradient(180deg,rgba(27,15,69,.55),rgba(27,15,69,.35) 40%,rgba(27,15,69,.8))}
#app{position:fixed;inset:0;display:flex;flex-direction:column}
.hidden{display:none!important}
button{font-family:inherit;cursor:pointer;border:0;color:inherit;touch-action:manipulation}
kbd{display:inline-flex;align-items:center;justify-content:center;min-width:1.7em;height:1.7em;padding:0 .35em;border-radius:6px;background:var(--white);color:var(--ink);font:800 .8em var(--font);box-shadow:0 2px 0 rgba(0,0,0,.35);margin:0 1px}

/* top bar */
#top{display:flex;align-items:center;gap:8px;padding:8px 10px;padding-top:max(8px,env(safe-area-inset-top));z-index:5}
.ib{width:44px;height:44px;border-radius:14px;background:rgba(255,255,255,.14);border:2px solid rgba(255,255,255,.25);display:flex;align-items:center;justify-content:center;flex:none}
.ib svg{width:24px;height:24px}
.ib:active{transform:scale(.92)}
#where{flex:1;min-width:0;display:flex;flex-direction:column;line-height:1.05}
#where b{font-size:20px;font-weight:900;letter-spacing:.3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-shadow:0 2px 0 rgba(0,0,0,.35)}
#where span{font-size:13px;color:var(--gold);font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#scoreBox{display:flex;flex-direction:column;align-items:center;justify-content:center;background:linear-gradient(#ffd75e,#ffad1f);color:var(--ink);border-radius:14px;padding:3px 12px;min-width:84px;border:3px solid #fff3c4;box-shadow:0 3px 0 rgba(0,0,0,.35)}
#scoreBox small{font-size:10px;font-weight:900;letter-spacing:1px;opacity:.75}
#scoreBox b{font-size:19px;font-weight:900;line-height:1}
#scoreBox.bump{animation:bump .35s}
@keyframes bump{40%{transform:scale(1.18)}}

#main{flex:1;min-height:0;position:relative;overflow:hidden}
.view{position:absolute;inset:0;overflow-y:auto;padding:6px 14px 16px;display:flex;flex-direction:column;align-items:center}
.vh{margin:4px 0 12px;font-size:24px;font-weight:900;text-shadow:0 3px 0 rgba(0,0,0,.4)}
.note{font-size:13px;opacity:.85;text-align:center;margin:10px 0 0;max-width:640px}
.small{font-size:14px;opacity:.9}

/* categories */
#cats{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;width:100%;max-width:880px}
.cat{background:linear-gradient(180deg,#fff,#efe7ff);color:var(--ink);border-radius:20px;padding:12px 8px 10px;display:flex;flex-direction:column;align-items:center;gap:4px;border:4px solid var(--gold);box-shadow:0 6px 0 rgba(0,0,0,.35);transition:transform .12s}
.cat:hover{transform:translateY(-3px)}
.cat:active{transform:scale(.96)}
.cat img{width:72px;height:72px}
.cat b{font-size:17px;font-weight:900}
.cat small{font-size:12px;font-weight:700;opacity:.75}
.cat .sbar{display:flex;align-items:center;gap:4px;font-weight:900;font-size:14px}
.st{display:inline-block;width:16px;height:16px;background:var(--gold);clip-path:polygon(50% 0,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%)}
.st.off{background:rgba(27,15,69,.2)}

/* levels */
#levels{display:flex;flex-direction:column;gap:12px;width:100%;max-width:640px}
.tier{background:rgba(27,15,69,.55);border:2px solid rgba(255,255,255,.18);border-radius:20px;padding:10px 12px}
.tier h3{margin:0 0 8px;font-size:16px;display:flex;align-items:center;gap:8px}
.tier h3 i{display:inline-block;padding:2px 10px;border-radius:99px;font-style:normal;font-size:12px;font-weight:900;color:var(--ink)}
.tier .lv{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.lvb{background:linear-gradient(#8a55ff,#5a26d6);border:3px solid #c9b2ff;border-radius:16px;padding:10px 4px 8px;display:flex;flex-direction:column;align-items:center;gap:4px;box-shadow:0 5px 0 rgba(0,0,0,.35)}
.lvb b{font-size:24px;font-weight:900;text-shadow:0 2px 0 rgba(0,0,0,.35)}
.lvb .ss{display:flex;gap:2px}
.lvb.lock{filter:grayscale(.9) brightness(.7)}
.lvb.next{animation:glow 1.4s infinite}
.lvb.nope{animation:shake .4s}
@keyframes glow{50%{box-shadow:0 5px 0 rgba(0,0,0,.35),0 0 0 6px rgba(255,200,61,.55)}}

/* play */
#playView{gap:8px;padding-top:2px}
#players{display:flex;gap:6px;width:100%;max-width:760px;justify-content:center;flex-wrap:wrap}
.pl{display:flex;align-items:center;gap:6px;background:rgba(27,15,69,.7);border:2px solid rgba(255,255,255,.2);border-radius:99px;padding:3px 10px 3px 4px;font-weight:800;font-size:14px;transition:transform .2s}
.pl i{width:20px;height:20px;border-radius:50%;border:2px solid #fff}
.pl.on{border-color:var(--gold);transform:scale(1.08);background:rgba(75,34,184,.9)}
#hud{display:flex;gap:6px;width:100%;max-width:760px;align-items:center}
.chip{background:rgba(27,15,69,.75);border:2px solid rgba(255,255,255,.22);border-radius:99px;padding:4px 12px;font-weight:900;font-size:14px;white-space:nowrap}
.chip.ghost{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;color:var(--gold)}
.streak{display:flex;align-items:center;gap:6px}
.flame{width:16px;height:20px;background:linear-gradient(#ffe066,#ff6b1a);clip-path:path("M8 0C9 6 16 8 16 14A8 6 0 0 1 0 14C0 10 3 9 4 5C5 8 6 9 7 9C7 6 6 3 8 0Z");filter:grayscale(1) brightness(.8);transition:filter .3s}
.streak.hot .flame{filter:none;animation:flick .5s infinite alternate}
.streak.hot{border-color:#ff9f1c;background:rgba(120,30,10,.75)}
@keyframes flick{to{transform:scaleY(1.15) translateY(-1px)}}
.pips{display:flex;gap:3px}
.pips i{width:8px;height:8px;border-radius:50%;background:rgba(255,255,255,.25)}
.pips i.f{background:var(--gold)}
#streak.pop{animation:bump .45s}

#hostRow{display:flex;align-items:center;gap:10px;width:100%;max-width:760px}
#hostImg{width:62px;height:124px;object-fit:contain;object-position:bottom;flex:none;filter:drop-shadow(0 4px 0 rgba(0,0,0,.3));transform-origin:50% 100%}
#hostImg.hop{animation:hop .5s}
@keyframes hop{30%{transform:translateY(-12px) scale(1.04)}60%{transform:translateY(0)}}
#bubble{flex:1;min-width:0;background:var(--white);color:var(--ink);border-radius:18px;padding:9px 14px;font-weight:800;font-size:15px;position:relative;box-shadow:0 4px 0 rgba(0,0,0,.3)}
#bubble::before{content:"";position:absolute;left:-9px;top:50%;margin-top:-9px;border:9px solid transparent;border-right-color:#fff;border-left:0}
#bubble.pop{animation:bump .3s}
#timer{width:70px;height:70px;position:relative;flex:none}
#timer svg{width:100%;height:100%;transform:rotate(-90deg)}
#timer circle{fill:rgba(27,15,69,.85);stroke-width:9}
#timer .trk{stroke:rgba(255,255,255,.18)}
#timer .arc{fill:none;stroke:var(--gold);stroke-linecap:round;stroke-dasharray:276.46;stroke-dashoffset:0}
#timer.low .arc{stroke:var(--red)}
#timer.low{animation:pulse .5s infinite alternate}
@keyframes pulse{to{transform:scale(1.08)}}
#timer b{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:24px;font-weight:900}

#qCard{width:100%;max-width:760px;background:linear-gradient(180deg,#fff,#f1eaff);color:var(--ink);border-radius:22px;padding:16px 18px;border:4px solid var(--gold);box-shadow:0 6px 0 rgba(0,0,0,.35),0 0 30px rgba(255,200,61,.25);min-height:96px;display:flex;flex-direction:column;justify-content:center}
#qCard.in{animation:cardIn .35s}
@keyframes cardIn{from{transform:translateY(14px) scale(.96);opacity:0}}
#qWho{font-weight:900;font-size:13px;margin-bottom:4px}
#qText{margin:0;font-size:20px;font-weight:800;line-height:1.3;text-align:center}
#answers{display:grid;grid-template-columns:1fr 1fr;gap:10px;width:100%;max-width:760px}
.ans{display:flex;align-items:center;gap:10px;text-align:left;padding:12px 12px;border-radius:18px;font-weight:800;font-size:17px;color:#fff;min-height:58px;border:3px solid rgba(255,255,255,.55);box-shadow:0 5px 0 rgba(0,0,0,.35);transition:transform .1s,opacity .25s,filter .25s;text-shadow:0 1px 0 rgba(0,0,0,.35)}
.ans kbd{flex:none;font-size:15px}
.ans span{flex:1;min-width:0}
.ans[data-i="0"]{background:linear-gradient(#ff7aa5,#e83f75)}
.ans[data-i="1"]{background:linear-gradient(#4fc3ff,#1688dd)}
.ans[data-i="2"]{background:linear-gradient(#ffc54d,#f08c00)}
.ans[data-i="3"]{background:linear-gradient(#4fe08f,#17a457)}
.ans:hover{transform:translateY(-2px)}
.ans:active{transform:scale(.97)}
.ans.gone{opacity:.12;pointer-events:none;filter:grayscale(1)}
.ans.pick{animation:lock .5s infinite alternate;border-color:#fff}
@keyframes lock{to{filter:brightness(1.25)}}
.ans.ok{background:linear-gradient(#5df59b,#16a34a)!important;border-color:#eafff1;animation:okPop .45s;filter:none;opacity:1}
.ans.bad{background:linear-gradient(#ff8a8a,#d32020)!important;animation:shake .45s}
.ans.dim{opacity:.35}
@keyframes okPop{40%{transform:scale(1.06)}}
@keyframes shake{20%,60%{transform:translateX(-7px)}40%,80%{transform:translateX(7px)}}
#lifelines{display:flex;gap:10px;justify-content:center}
.life{width:86px;height:56px;border-radius:16px;background:linear-gradient(#3a1d8f,#25105f);border:3px solid var(--gold);display:flex;flex-direction:column;align-items:center;justify-content:center;box-shadow:0 4px 0 rgba(0,0,0,.35);line-height:1.05}
.life b{font-size:18px;font-weight:900;color:var(--gold)}
.life svg{width:22px;height:22px;color:var(--gold)}
.life small{font-size:11px;font-weight:800;opacity:.9}
.life:active{transform:scale(.94)}
.life.used{opacity:.3;filter:grayscale(1);pointer-events:none}
.pts{position:fixed;z-index:30;font-weight:900;font-size:30px;color:var(--gold);text-shadow:0 3px 0 rgba(0,0,0,.45);pointer-events:none;animation:rise 1.1s forwards}
@keyframes rise{to{transform:translateY(-70px);opacity:0}}

/* overlays */
.overlay{position:fixed;inset:0;z-index:20;display:flex;align-items:center;justify-content:center;background:rgba(18,8,48,.55);padding:14px;overflow-y:auto}
.panel{background:linear-gradient(180deg,#3d1b9c,#26106a);border:4px solid var(--gold);border-radius:28px;padding:18px 20px 18px;max-width:520px;width:100%;text-align:center;box-shadow:0 10px 0 rgba(0,0,0,.35),0 0 60px rgba(255,200,61,.25);position:relative;margin:auto;animation:cardIn .35s}
.panel.wide{max-width:600px}
.panel h1{margin:2px 0 4px;font-size:52px;line-height:1;font-weight:900;color:var(--gold);text-shadow:0 4px 0 #b55d00,0 8px 0 rgba(0,0,0,.3);letter-spacing:1px}
.panel h1 span{display:block;font-size:22px;color:#fff;text-shadow:0 2px 0 rgba(0,0,0,.4);letter-spacing:.5px;margin-top:6px}
.panel h2{margin:4px 0 8px;font-size:28px;font-weight:900;color:var(--gold);text-shadow:0 3px 0 rgba(0,0,0,.4)}
.startPanel{padding-top:12px}
.hostBig{width:90px;height:180px;object-fit:contain;object-position:bottom;display:block;margin:-6px auto 0;filter:drop-shadow(0 5px 0 rgba(0,0,0,.3))}
.startPanel .hostBig{animation:sway 2.4s ease-in-out infinite}
@keyframes sway{50%{transform:rotate(-3deg) translateY(-3px)}}
.intro{font-size:15px;line-height:1.4;margin:8px auto 12px;max-width:440px}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;border-radius:18px;font-weight:900;font-size:17px;padding:10px 18px;background:linear-gradient(#fff,#e9e0ff);color:var(--ink);box-shadow:0 5px 0 rgba(0,0,0,.35);border:3px solid #fff}
.btn:active{transform:translateY(3px);box-shadow:0 2px 0 rgba(0,0,0,.35)}
.btn.big{font-size:26px;padding:12px 44px;background:linear-gradient(#ffe066,#ffa41b);border-color:#fff4c7;min-width:220px}
.btn.big:hover{filter:brightness(1.06)}
.btn.ghost{background:rgba(255,255,255,.12);color:#fff;border-color:rgba(255,255,255,.35);font-size:16px}
.modes{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:14px 0 8px}
.btn.mode{flex-direction:column;gap:2px;font-size:14px;padding:8px 6px;line-height:1.1;border-radius:16px}
.btn.mode img{width:36px;height:36px}
.cal{display:flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:8px;background:#fff;border:3px solid #ef4444;border-top-width:8px;font-weight:900;font-size:15px;color:var(--ink)}
.ppl{display:flex;align-items:center;justify-content:center;width:42px;height:34px;border-radius:17px;background:linear-gradient(#ff7aa5,#7a3df0);color:#fff;font-weight:900;font-size:15px}
.ctl{display:flex;flex-wrap:wrap;gap:10px 16px;justify-content:center;font-size:13px;margin-top:8px;opacity:.95}
.touchOnly{display:none}
@media (hover:none){.touchOnly{display:inline}.keyOnly{display:none}}
.row{display:flex;gap:10px;justify-content:center;margin-top:10px;flex-wrap:wrap}
#stars{display:flex;justify-content:center;gap:8px;margin:4px 0 8px}
#stars i{width:58px;height:58px;background:rgba(255,255,255,.2);clip-path:polygon(50% 0,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%)}
#stars i:nth-child(2){transform:translateY(-10px) scale(1.15)}
#stars i.on{background:linear-gradient(#fff3a6,#ffc83d 40%,#ff9f1c);animation:starIn .5s backwards}
#stars i.on:nth-child(2){animation-delay:.25s}
#stars i.on:nth-child(3){animation-delay:.5s}
@keyframes starIn{from{transform:scale(0) rotate(-90deg)}}
#stars i:nth-child(2).on{animation-name:starIn2}
@keyframes starIn2{from{transform:translateY(-10px) scale(0) rotate(-90deg)}}
#resStats{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:6px 0}
#resStats div{background:rgba(255,255,255,.1);border-radius:14px;padding:8px}
#resStats small{display:block;font-size:12px;opacity:.8;font-weight:700}
#resStats b{font-size:22px;font-weight:900;color:var(--gold)}
.podium{display:flex;flex-direction:column;gap:6px;margin:8px 0}
.podium div{display:flex;align-items:center;gap:10px;background:rgba(255,255,255,.1);border-radius:14px;padding:8px 12px;font-weight:900;font-size:18px}
.podium div:first-child{background:linear-gradient(90deg,rgba(255,200,61,.45),rgba(255,200,61,.1));font-size:21px}
.podium em{font-style:normal;width:28px;color:var(--gold)}
.podium i{width:20px;height:20px;border-radius:50%;border:2px solid #fff;flex:none}
.podium span{flex:1;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.lbl{font-weight:900;font-size:14px;margin:12px 0 6px;color:var(--gold);text-align:left}
.seg{display:flex;gap:6px}
.seg.wrap{flex-wrap:wrap}
.seg button{flex:1;padding:9px 8px;border-radius:12px;background:rgba(255,255,255,.12);border:2px solid rgba(255,255,255,.25);font-weight:900;font-size:15px;white-space:nowrap}
.seg.wrap button{flex:1 1 auto}
.seg button.on{background:var(--gold);color:var(--ink);border-color:#fff}
#nNames{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-top:10px}
#nNames label{min-width:0;display:flex;align-items:center;gap:6px;background:rgba(255,255,255,.1);border-radius:12px;padding:4px 8px}
#nNames i{width:18px;height:18px;border-radius:50%;border:2px solid #fff;flex:none}
#nNames input{flex:1;min-width:0;background:transparent;border:0;color:#fff;font:800 16px var(--font);padding:6px 2px;outline:none;user-select:text;-webkit-user-select:text}
.pdot{width:64px;height:64px;border-radius:50%;margin:4px auto 6px;border:5px solid #fff;box-shadow:0 0 0 6px rgba(255,255,255,.15)}
#fx{position:fixed;inset:0;width:100%;height:100%;pointer-events:none;z-index:40}

/* wide screens: host stands next to the quiz */
@media (min-width:1000px) and (min-height:600px){
  #hostRow{max-width:760px}
  #hostImg{position:fixed;left:max(10px,calc(50% - 640px));bottom:0;width:250px;height:500px;z-index:1}
  #playView{padding-left:250px;padding-right:20px;justify-content:center;padding-bottom:40px}
  #qText{font-size:24px}
  #qCard{min-height:120px}
  .ans{font-size:19px;min-height:64px}
}
@media (min-width:1000px) and (min-height:600px) and (max-width:1290px){
  #playView{padding-left:240px}
  #hostImg{width:220px;height:440px}
}
/* phones */
@media (max-width:640px){
  #cats{grid-template-columns:repeat(2,1fr);gap:10px}
  .cat img{width:58px;height:58px}
  #answers{grid-template-columns:1fr;gap:8px}
  .ans{min-height:52px;font-size:16px;padding:10px 12px}
  #qText{font-size:18px}
  #qCard{padding:12px 14px;min-height:84px}
  #hostImg{width:60px;height:120px}
  #timer{width:62px;height:62px}
  #bubble{font-size:14px;padding:8px 11px}
  .panel h1{font-size:44px}
  .panel h1 span{font-size:19px}
  .btn.big{font-size:23px;padding:11px 30px}
  .life{width:80px;height:52px}
  #where b{font-size:18px}
  #scoreBox{min-width:70px;padding:3px 8px}
  .podium small{display:none}
  .podium div{font-size:17px}
}
@media (max-height:700px){
  .hostBig{width:70px;height:140px}
  .intro{margin:6px auto 8px}
}
