:root {
  --c0: #e21b3c; --c1: #1368ce; --c2: #d89e00; --c3: #26890c;
  --purple: #46178f; --purple-d: #2b0f5c; --purple-l: #864cbf;
  --ok: #26890c; --bad: #e21b3c;
  --bg: #f4f2f8; --card: #ffffff; --ink: #1d1530; --mute: #6b6480; --line: #e4dff0; --accent: #46178f;
  --shadow: 0 1px 2px rgba(30, 10, 60, .06), 0 4px 16px rgba(30, 10, 60, .06);
  font-family: 'IBM Plex Sans Thai', system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #14101d; --card: #1e1829; --ink: #efeaf8; --mute: #a79fbb; --line: #322a42; --accent: #b48cf0; --shadow: 0 1px 2px rgba(0,0,0,.3); }
}
:root[data-theme="dark"] { --bg: #14101d; --card: #1e1829; --ink: #efeaf8; --mute: #a79fbb; --line: #322a42; --accent: #b48cf0; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
#app { min-height: 100%; }
body { background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, .disp { font-family: 'Kanit', 'IBM Plex Sans Thai', sans-serif; }
.hidden { display: none !important; }
.mute { color: var(--mute); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* ---------- ปุ่ม / ฟอร์ม ---------- */
.btn { border: 1px solid var(--line); background: var(--card); padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: 14px; line-height: 1.2; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.pri { background: var(--purple); border-color: var(--purple); color: #fff; }
.btn.pri:hover { background: #5a22b0; }
.btn.go { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.warn { background: var(--c2); border-color: var(--c2); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 9px; font-size: 13px; border-radius: 8px; }
.btn.on { background: var(--purple); color: #fff; border-color: var(--purple); }
.btn:disabled { opacity: .45; cursor: default; }
.inp { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 10px 12px; font-size: 15px; }
.inp:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea.inp { resize: vertical; min-height: 80px; }
label.f { display: block; font-size: 13px; color: var(--mute); margin: 12px 0 4px; font-weight: 600; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
#toast div { background: #1d1530; color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; box-shadow: 0 6px 24px rgba(0,0,0,.25); animation: pop .2s ease-out; max-width: 90vw; }
#toast div.err { background: var(--bad); }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }

/* ---------- หน้าแรก ---------- */
.home { min-height: 100vh; background: radial-gradient(1200px 600px at 20% -10%, #864cbf 0, transparent 60%), linear-gradient(160deg, #46178f, #2b0f5c); color: #fff; padding: 40px 16px; }
.home .wrap { max-width: 980px; margin: 0 auto; }
.home h1 { font-size: clamp(34px, 6vw, 56px); margin: 0; letter-spacing: -.5px; }
.home .lead { opacity: .85; font-size: 18px; margin: 8px 0 28px; }
.home .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.home .card { color: var(--ink); padding: 22px; }
.home .card h2 { margin: 0 0 6px; font-size: 22px; }
.feat { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 28px; }
.feat div { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); border-radius: 14px; padding: 14px; font-size: 14px; }
.feat b { display: block; font-family: Kanit; font-size: 17px; margin-bottom: 4px; }
.myrooms a { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.myrooms a:hover b { color: var(--accent); }
.ver { opacity: .55; font-size: 12px; margin-top: 24px; }
@media (max-width: 760px) { .home .grid, .feat { grid-template-columns: 1fr; } }

/* ---------- ผู้จัด (host) ---------- */
.host { display: flex; flex-direction: column; min-height: 100%; }
.hbar { background: linear-gradient(90deg, #2b0f5c, #46178f); color: #fff; padding: 10px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
.hbar h1 { margin: 0; font-size: 20px; font-weight: 600; }
.hbar .btn { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.2); color: #fff; }
.hbar .btn:hover { background: rgba(255,255,255,.22); }
.codechip { background: #fff; color: var(--purple); font-family: Kanit; font-weight: 700; padding: 3px 10px; border-radius: 8px; letter-spacing: 2px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #9a93ab; vertical-align: middle; }
.dot.on { background: #3ddc84; box-shadow: 0 0 0 3px rgba(61, 220, 132, .25); }
.viewbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--card); }
.viewbar .lbl { font-weight: 700; font-size: 13px; color: var(--mute); margin-right: 4px; }
.hmain { display: grid; grid-template-columns: 330px 1fr 300px; gap: 14px; padding: 14px 16px; align-items: start; }
@media (max-width: 1200px) { .hmain { grid-template-columns: 300px 1fr; } .hmain .pcol { grid-column: 1 / -1; } }
@media (max-width: 800px) { .hmain { grid-template-columns: 1fr; } }
.panel { padding: 14px; }
.panel h3 { margin: 0 0 10px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.agenda { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow: auto; margin: 0 -4px; padding: 0 4px; }
.ag { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--card); }
.ag:hover { border-color: var(--accent); }
.ag.sel { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.ag .ic { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; font-size: 14px; color: #fff; }
.ag .t { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ag .s { font-size: 12px; color: var(--mute); }
.ag .tools { display: flex; gap: 2px; opacity: .55; }
.ag:hover .tools { opacity: 1; }
.ag .tools button { border: 0; background: none; padding: 3px 5px; border-radius: 6px; font-size: 13px; }
.ag .tools button:hover { background: var(--bg); }
.livebadge { background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 5px; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .55; } }
.ic.poll { background: var(--c1); } .ic.quiz { background: var(--c0); } .ic.comments { background: var(--c3); }
.addrow { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.lp-q { font-family: Kanit; font-size: 22px; font-weight: 600; margin: 4px 0 12px; line-height: 1.3; }
.hbars { display: flex; flex-direction: column; gap: 8px; }
.hb { display: grid; grid-template-columns: 1fr 70px; gap: 8px; align-items: center; font-size: 14px; }
.hb .tr { background: var(--bg); border-radius: 8px; overflow: hidden; position: relative; min-height: 34px; display: flex; align-items: center; }
.hb .fill { position: absolute; inset: 0 auto 0 0; border-radius: 8px; transition: width .5s; opacity: .9; }
.hb .lab { position: relative; padding: 6px 10px; font-weight: 600; }
.hb .num { text-align: right; font-weight: 700; }
.hb.correct .tr { outline: 2px solid var(--ok); }
.ctl { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--line); }
.phase { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--bg); }
.phase.open { background: var(--ok); color: #fff; } .phase.reveal { background: var(--purple); color: #fff; }
.clist { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; }
.cm { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.cm.hid { opacity: .45; } .cm.pin { border-color: var(--c2); background: color-mix(in srgb, var(--c2) 8%, var(--card)); }
.cm .n { font-size: 12px; font-weight: 700; color: var(--accent); }
.cm .x { white-space: pre-wrap; word-break: break-word; }
.plist { max-height: 62vh; overflow: auto; display: flex; flex-direction: column; }
.pl { display: grid; grid-template-columns: 28px 1fr auto auto; gap: 6px; align-items: center; padding: 6px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.pl .rk { color: var(--mute); font-weight: 700; text-align: center; }
.pl .sc { font-weight: 700; font-variant-numeric: tabular-nums; }
.pl .mn { border: 0; background: none; padding: 2px 6px; border-radius: 6px; opacity: .5; }
.pl .mn:hover { opacity: 1; background: var(--bg); }
.wlist { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; font-size: 14px; }
.wlist div { display: flex; justify-content: space-between; gap: 8px; padding: 6px 8px; background: var(--bg); border-radius: 8px; }
.preview { width: 100%; aspect-ratio: 16/9; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #000; position: relative; }
.preview iframe { width: 1600px; height: 900px; border: 0; transform-origin: 0 0; position: absolute; left: 0; top: 0; pointer-events: none; }
.empty { color: var(--mute); text-align: center; padding: 30px 10px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(15, 5, 30, .55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal .box { background: var(--card); border-radius: 16px; width: min(640px, 100%); max-height: 92vh; overflow: auto; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.modal h2 { margin: 0 0 4px; font-size: 22px; }
.qopts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.qopt { display: grid; grid-template-columns: 36px 1fr 30px; align-items: center; border-radius: 10px; overflow: hidden; border: 2px solid transparent; }
.qopt .sh { height: 100%; display: grid; place-items: center; color: #fff; }
.qopt input[type=text] { border: 0; padding: 10px; background: var(--bg); height: 100%; outline: none; min-width: 0; }
.qopt input[type=radio] { width: 20px; height: 20px; margin: auto; accent-color: var(--ok); }
.qopt.ok { border-color: var(--ok); }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 560px) { .qopts { grid-template-columns: 1fr; } }

/* ---------- จอโปรเจกเตอร์ ---------- */
.scr { position: fixed; inset: 0; overflow: hidden; color: #fff; background: radial-gradient(1400px 700px at 15% -10%, #864cbf 0, transparent 60%), linear-gradient(160deg, #46178f, #2b0f5c 70%); font-size: 1.6vw; display: flex; flex-direction: column; }
.scr .stage { flex: 1; display: flex; flex-direction: column; padding: 2.5vw 3vw 2vw; min-height: 0; position: relative; }
.scr .corner { position: absolute; right: 1.6vw; top: 1.4vw; display: flex; gap: .8vw; align-items: center; background: #fff; color: #2b0f5c; border-radius: 1vw; padding: .5vw .8vw .5vw 1vw; z-index: 4; box-shadow: 0 .5vw 2vw rgba(0,0,0,.25); }
.scr .corner .u { font-size: .95vw; line-height: 1.35; } .scr .corner b { font-family: Kanit; font-size: 1.7vw; letter-spacing: .15vw; }
.scr .corner .qr { width: 6.5vw; height: 6.5vw; }
.qr svg { width: 100%; height: 100%; display: block; }
.scr .foot { display: flex; justify-content: space-between; align-items: center; padding: .8vw 3vw; background: rgba(0,0,0,.22); font-size: 1.05vw; }
.scr .foot b { font-family: Kanit; }
.scr .title-sm { font-family: Kanit; font-size: 1.3vw; opacity: .75; }
.scr .big-q { font-family: Kanit; font-weight: 600; font-size: 3.2vw; line-height: 1.25; margin: .6vw 0 1.8vw; max-width: 80%; }
.scr .big-q.c { text-align: center; max-width: none; margin-left: auto; margin-right: auto; }
.qbox { background: #fff; color: #1d1530; border-radius: 1vw; padding: 1.4vw 2vw; text-align: center; font-family: Kanit; font-weight: 600; font-size: 2.8vw; line-height: 1.25; box-shadow: 0 .5vw 2vw rgba(0,0,0,.2); }
.lobby { flex: 1; display: grid; grid-template-columns: 1fr auto; gap: 3vw; align-items: center; }
.lobby h1 { font-size: 4.4vw; margin: 0 0 .5vw; line-height: 1.15; }
.lobby .how { font-size: 1.8vw; opacity: .9; }
.lobby .url { display: inline-block; background: rgba(255,255,255,.14); padding: .5vw 1.2vw; border-radius: .8vw; font-weight: 700; font-size: 2vw; margin-top: 1vw; }
.lobby .pin { font-family: Kanit; font-size: 6vw; font-weight: 800; letter-spacing: .6vw; line-height: 1; margin-top: 1.5vw; }
.lobby .qrbig { background: #fff; padding: 1.2vw; border-radius: 1.4vw; width: 30vw; height: 30vw; box-shadow: 0 1vw 4vw rgba(0,0,0,.35); }
.lobby .cnt { font-family: Kanit; font-size: 2.2vw; margin-top: 2vw; display: flex; align-items: center; gap: 1vw; }
.lobby .cnt b { background: #fff; color: #46178f; padding: .1vw 1.2vw; border-radius: .8vw; font-size: 2.8vw; }
.chips { display: flex; flex-wrap: wrap; gap: .6vw; margin-top: 1.4vw; max-height: 14vw; overflow: hidden; }
.chips span { background: rgba(255,255,255,.14); padding: .35vw .9vw; border-radius: 99px; font-weight: 600; animation: pop .35s ease-out; }
.sbars { display: flex; flex-direction: column; gap: 1vw; flex: 1; justify-content: center; }
.sb { display: grid; grid-template-columns: 1fr 7vw; gap: 1vw; align-items: center; }
.sb .tr { position: relative; background: rgba(255,255,255,.1); border-radius: .8vw; min-height: 4vw; display: flex; align-items: center; overflow: hidden; }
.sb .fill { position: absolute; inset: 0 auto 0 0; border-radius: .8vw; transition: width .7s cubic-bezier(.2,.8,.2,1); }
.sb .lab { position: relative; padding: .6vw 1.4vw; font-size: 1.9vw; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.35); }
.sb .num { font-family: Kanit; font-size: 2.4vw; font-weight: 700; text-align: right; }
.sb .num small { display: block; font-size: 1.1vw; opacity: .75; font-weight: 500; }
.stat { font-family: Kanit; font-size: 1.6vw; opacity: .9; }
.cwall { columns: 3; column-gap: 1.2vw; flex: 1; overflow: hidden; }
.cc { break-inside: avoid; background: #fff; color: #1d1530; border-radius: 1vw; padding: 1vw 1.3vw; margin-bottom: 1.2vw; box-shadow: 0 .4vw 1.4vw rgba(0,0,0,.18); }
.cc.new { animation: drop .5s cubic-bezier(.2,.9,.3,1.2); }
.cc.pin { background: #fff4d1; outline: .25vw solid var(--c2); }
.cc .x { font-size: 1.6vw; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }
.cc .n { font-size: 1.05vw; font-weight: 700; color: #864cbf; margin-top: .5vw; }
@keyframes drop { from { transform: translateY(-2vw) scale(.92); opacity: 0; } }

/* Kahoot-style quiz */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 1vw; margin-top: auto; }
.tile { display: flex; align-items: center; gap: 1.2vw; padding: 1.4vw 1.6vw; border-radius: .8vw; color: #fff; font-size: 2.1vw; font-weight: 600; min-height: 8vw; box-shadow: 0 .35vw 0 rgba(0,0,0,.25); transition: opacity .4s, transform .4s; }
.tile .shp { width: 3.2vw; height: 3.2vw; flex: none; }
.tile.dim { opacity: .28; }
.tile.ok { transform: scale(1.02); }
.tile .ck { margin-left: auto; font-size: 3vw; }
.bg0 { background: var(--c0); } .bg1 { background: var(--c1); } .bg2 { background: var(--c2); } .bg3 { background: var(--c3); }
.qmid { flex: 1; display: grid; grid-template-columns: 12vw 1fr 12vw; align-items: center; gap: 2vw; margin: 1.5vw 0; min-height: 0; }
.timer { width: 10vw; height: 10vw; border-radius: 50%; background: #fff; color: #46178f; display: grid; place-items: center; font-family: Kanit; font-weight: 800; font-size: 4.2vw; position: relative; }
.timer svg { position: absolute; inset: -.5vw; width: 11vw; height: 11vw; transform: rotate(-90deg); }
.timer.low { color: var(--c0); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.07); } }
.anscount { text-align: center; font-family: Kanit; } .anscount b { display: block; font-size: 4.2vw; line-height: 1; } .anscount span { font-size: 1.4vw; opacity: .85; }
.rbars { display: flex; justify-content: center; align-items: flex-end; gap: 2vw; height: 13vw; }
.rbar { width: 8vw; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.rbar .b { width: 100%; border-radius: .5vw .5vw 0 0; transition: height .8s cubic-bezier(.2,.8,.2,1); min-height: .6vw; }
.rbar .v { font-family: Kanit; font-size: 2.2vw; font-weight: 700; margin-bottom: .3vw; display: flex; align-items: center; gap: .4vw; }
.rbar .v svg { width: 1.8vw; height: 1.8vw; }
.rbar.dim { opacity: .35; }
.getready { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.getready .num { font-family: Kanit; font-size: 1.8vw; background: rgba(255,255,255,.15); padding: .4vw 1.4vw; border-radius: 99px; }
.getready .q { font-family: Kanit; font-size: 4vw; font-weight: 600; margin: 2vw 0; max-width: 85%; line-height: 1.25; }
.loadbar { width: 40vw; height: .8vw; background: rgba(255,255,255,.15); border-radius: 99px; overflow: hidden; }
.loadbar i { display: block; height: 100%; width: 40%; background: #fff; border-radius: 99px; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }
.fastest { display: flex; gap: 1vw; justify-content: center; margin-top: 1vw; font-size: 1.4vw; }
.fastest span { background: rgba(255,255,255,.14); padding: .3vw 1vw; border-radius: 99px; }

.lboard { flex: 1; display: flex; flex-direction: column; gap: .45vw; max-width: 64vw; width: 100%; margin: 0 auto; justify-content: center; }
.lrow { display: grid; grid-template-columns: 5vw 1fr auto; gap: 1vw; align-items: center; background: #fff; color: #1d1530; border-radius: .8vw; padding: .35vw 1.4vw; font-size: 1.75vw; font-weight: 700; animation: slidein .5s both; }
.lrow:nth-child(1) { background: #ffd54a; } .lrow:nth-child(2) { background: #e9edf2; } .lrow:nth-child(3) { background: #f2c49b; }
.lrow .r { font-family: Kanit; text-align: center; } .lrow .s { font-family: Kanit; font-variant-numeric: tabular-nums; }
@keyframes slidein { from { transform: translateX(-4vw); opacity: 0; } }
.podium { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 1.5vw; padding-top: 2vw; }
.pod { width: 20vw; display: flex; flex-direction: column; align-items: center; animation: rise 1s cubic-bezier(.2,.9,.3,1.1) both; }
.pod .nm { font-family: Kanit; font-size: 2.4vw; font-weight: 700; text-align: center; margin-bottom: .8vw; line-height: 1.15; }
.pod .blk { width: 100%; border-radius: 1vw 1vw 0 0; display: flex; flex-direction: column; align-items: center; padding-top: 1.2vw; font-family: Kanit; box-shadow: inset 0 -1vw 2vw rgba(0,0,0,.15); }
.pod .blk .m { font-size: 5vw; line-height: 1; } .pod .blk .p { font-size: 1.8vw; font-weight: 700; color: #1d1530; margin-top: .5vw; }
.pod.p1 .blk { height: 26vw; background: #ffd54a; } .pod.p2 .blk { height: 19vw; background: #e9edf2; } .pod.p3 .blk { height: 14vw; background: #f2c49b; }
.pod.p1 { animation-delay: 1.6s; } .pod.p2 { animation-delay: .9s; } .pod.p3 { animation-delay: .2s; }
@keyframes rise { from { transform: translateY(30vw); opacity: 0; } }
.drawbox { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.drawbox .prize { font-family: Kanit; font-size: 2.4vw; background: rgba(255,255,255,.15); padding: .4vw 1.6vw; border-radius: 99px; margin-bottom: 2vw; }
.reel { background: #fff; color: #46178f; border-radius: 1.6vw; padding: 2.5vw 4vw; min-width: 55vw; font-family: Kanit; font-weight: 800; font-size: 6vw; line-height: 1.15; box-shadow: 0 1vw 5vw rgba(0,0,0,.35), inset 0 0 0 .5vw #ffd54a; }
.reel.spin { animation: shake .12s infinite; }
@keyframes shake { 50% { transform: translateY(.2vw); } }
.reel.win { animation: winpop .6s cubic-bezier(.2,.9,.3,1.4); }
@keyframes winpop { from { transform: scale(.7); } }
.wingrid { display: flex; flex-wrap: wrap; gap: 1.2vw; justify-content: center; max-width: 85vw; }
.wingrid .reel { min-width: 0; font-size: 3.4vw; padding: 1.5vw 2.5vw; }
.recent { margin-top: 2vw; font-size: 1.3vw; opacity: .85; max-width: 80vw; }
.sndbtn { position: absolute; left: 1vw; bottom: 4vw; background: rgba(255,255,255,.12); border: 0; color: #fff; border-radius: 99px; padding: .4vw .9vw; font-size: 1vw; z-index: 5; opacity: .5; }
.sndbtn:hover { opacity: 1; }
canvas.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 9; }
.offline { position: fixed; top: 0; left: 0; right: 0; background: var(--bad); color: #fff; text-align: center; font-weight: 700; padding: 4px; z-index: 60; font-size: 14px; }

/* ---------- มือถือผู้เข้าร่วม ---------- */
.ply { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: linear-gradient(170deg, #46178f, #2b0f5c); color: #fff; }
.ply .top { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: rgba(0,0,0,.2); font-weight: 600; gap: 10px; }
.ply .top .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ply .top .sc { background: #fff; color: #46178f; padding: 2px 10px; border-radius: 8px; font-family: Kanit; font-weight: 700; white-space: nowrap; }
.ply .body { flex: 1; display: flex; flex-direction: column; padding: 16px; gap: 14px; }
.ply .center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; }
.ply h2 { margin: 0; font-size: 26px; line-height: 1.25; }
.ply .q { font-family: Kanit; font-size: 21px; font-weight: 600; line-height: 1.35; }
.ply .card { color: var(--ink); background: #fff; border: 0; padding: 20px; }
.ply .inp { background: #fff; color: #1d1530; border-color: #ddd; font-size: 18px; padding: 14px; }
.ply .btn.big { width: 100%; padding: 15px; font-size: 18px; border-radius: 12px; }
.ply .btn.wht { background: #fff; color: #46178f; border: 0; }
.popt { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: rgba(255,255,255,.12); border: 2px solid rgba(255,255,255,.18); color: #fff; padding: 14px 16px; border-radius: 12px; font-size: 17px; font-weight: 600; }
.popt .bx { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; flex: none; display: grid; place-items: center; font-size: 14px; }
.popt.multi .bx { border-radius: 6px; }
.popt.sel { background: #fff; color: #46178f; border-color: #fff; }
.popt.sel .bx { background: #46178f; border-color: #46178f; color: #fff; }
.pans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; flex: 1; min-height: 52vh; }
.pans button { border: 0; border-radius: 12px; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 10px; font-weight: 600; font-size: 15px; box-shadow: 0 5px 0 rgba(0,0,0,.25); transition: transform .08s; }
.pans button:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.pans button svg { width: 52px; height: 52px; }
.pans.n2 { grid-template-columns: 1fr; }
.res { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; border-radius: 16px; padding: 24px; }
.res.ok { background: var(--ok); } .res.bad { background: var(--bad); } .res.none { background: rgba(255,255,255,.1); }
.res .ico { font-size: 64px; line-height: 1; }
.res .pts { background: rgba(0,0,0,.25); padding: 8px 18px; border-radius: 10px; font-family: Kanit; font-size: 24px; font-weight: 700; }
.ptimer { font-family: Kanit; font-size: 20px; font-weight: 700; background: #fff; color: #46178f; border-radius: 99px; width: 52px; height: 52px; display: grid; place-items: center; flex: none; }
.spinner { width: 54px; height: 54px; border: 6px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: rot 0.9s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.mine { display: flex; flex-direction: column; gap: 6px; }
.mine div { background: rgba(255,255,255,.12); border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.rankbig { font-family: Kanit; font-size: 64px; font-weight: 800; line-height: 1; }

/* ---------- โลโก้ Glow Group ---------- */
.homelogo { height: 120px; display: block; margin-bottom: 18px; }
.hlogo { height: 34px; width: auto; }
.fbrand { display: flex; align-items: center; gap: .6vw; }
.fbrand img { height: 2.4vw; }
.lobbylogo { height: 11vw; display: block; margin-bottom: 1vw; }
.blanklogo { height: 16vw; margin-bottom: 2vw; }

/* ---------- จับฉลาก: ตั้งค่าในแผงผู้จัด ---------- */
.dset { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.dset label { font-size: 12px; font-weight: 600; color: var(--mute); display: flex; flex-direction: column; gap: 4px; }
.dset .inp { padding: 8px 10px; font-size: 14px; }
@media (max-width: 900px) { .dset { grid-template-columns: 1fr; } }

/* ---------- จับฉลาก: วงล้อบนจอ ---------- */
.wheelwrap { flex: 1; display: grid; grid-template-columns: 1fr auto 1fr; gap: 2vw; align-items: center; min-height: 0; }
.wside { align-self: stretch; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.wlbl { font-family: Kanit; font-size: 1.5vw; opacity: .75; margin-bottom: .5vw; }
.wprize { font-family: Kanit; font-weight: 700; font-size: 2.6vw; line-height: 1.2; color: #ffd54a; }
.wstat { font-size: 1.5vw; margin-top: 1.2vw; opacity: .9; } .wstat small { font-size: 1.1vw; opacity: .8; }
.wwin { display: flex; flex-direction: column; gap: .5vw; overflow: hidden; max-height: 34vw; }
.wwin div { background: rgba(255,255,255,.12); border-left: .3vw solid #ffd54a; border-radius: .5vw; padding: .45vw .9vw; animation: slidein .5s both; }
.wwin div b { display: block; font-size: 1.5vw; } .wwin div span { font-size: 1vw; opacity: .8; }
.wwin div.abs { opacity: .45; text-decoration: line-through; border-left-color: #999; }
.mute2 { opacity: .6; font-size: 1.3vw; }
.wheel { position: relative; height: min(40vw, calc(100vh - 9vw)); aspect-ratio: 1; }
.wsvg { width: 100%; height: 100%; display: block; overflow: visible; filter: drop-shadow(0 1vw 3vw rgba(0,0,0,.45)); }
.wempty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font-family: Kanit; font-size: 2vw; border: .3vw dashed rgba(255,255,255,.3); border-radius: 50%; }
.wempty small { font-size: 1.2vw; opacity: .75; }
.seg { stroke: rgba(255,255,255,.35); stroke-width: .35; transition: fill .08s; }
.seg.faded { fill: #2b2140 !important; opacity: .55; }
.seg.hl { fill: #ffd54a !important; opacity: 1; filter: url(#glow); }
.lab { fill: #fff; font-family: 'IBM Plex Sans Thai', sans-serif; font-weight: 600; pointer-events: none; }
.lab.faded { fill: rgba(255,255,255,.3); text-decoration: line-through; }
.lab.hl { fill: #2b0f5c; font-weight: 800; }
.bulb { fill: #7a5a1c; transition: fill .05s; }
.bulb.on { fill: #fff3b0; filter: url(#glow); }
.bulbs.idle .bulb { animation: twinkle 1.6s infinite; }
.bulbs.idle .bulb:nth-child(2n) { animation-delay: .8s; }
.bulbs.party .bulb { animation: twinkle .35s infinite; }
.bulbs.party .bulb:nth-child(2n) { animation-delay: .17s; }
@keyframes twinkle { 0%, 49% { fill: #fff3b0; } 50%, 100% { fill: #7a5a1c; } }
.hubname { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 22%; text-align: center; font-family: Kanit; font-weight: 700; font-size: 1.15vw; line-height: 1.15; color: #ffd54a; pointer-events: none; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ป๊อปอัปผู้โชคดี */
.winpop { position: fixed; inset: 0; z-index: 8; display: grid; place-items: center; background: rgba(15, 3, 35, .62); animation: fadein .3s; }
@keyframes fadein { from { opacity: 0; } }
.wpray { position: absolute; width: 120vmax; height: 120vmax; background: repeating-conic-gradient(from 0deg, rgba(255,213,74,.16) 0 10deg, transparent 10deg 20deg); animation: rays 14s linear infinite; mask: radial-gradient(circle, #000 0, transparent 60%); -webkit-mask: radial-gradient(circle, #000 0, transparent 60%); }
@keyframes rays { to { transform: rotate(360deg); } }
.wpcard { position: relative; text-align: center; padding: 3vw 6vw; border-radius: 2vw; background: linear-gradient(160deg, #fffaf0, #ffe9a8); color: #2b0f5c; box-shadow: 0 0 0 .5vw #d4a640, 0 0 6vw rgba(255,213,74,.6), 0 2vw 6vw rgba(0,0,0,.4); animation: popin .8s cubic-bezier(.2, 1.4, .4, 1) both; max-width: 80vw; }
@keyframes popin { 0% { transform: scale(.2) rotate(-8deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.wptop { font-family: Kanit; font-size: 2.4vw; font-weight: 600; color: #8a5a00; }
.wpname { font-family: Kanit; font-weight: 800; font-size: 6.5vw; line-height: 1.15; margin: 1vw 0; word-break: break-word; animation: glowtxt 1.2s ease-in-out infinite alternate; }
@keyframes glowtxt { to { text-shadow: 0 0 2vw rgba(212,166,64,.9); } }
.wpprize { display: inline-block; font-family: Kanit; font-size: 2.2vw; font-weight: 600; background: #46178f; color: #ffd54a; padding: .5vw 2vw; border-radius: 99px; }

.hublogo { transition: opacity .2s; }
.wheel.named .hublogo { opacity: 0; }

/* พื้นหลังหน้าวงล้อ: สปอตไลต์ทองหลังวงล้อ + ลำแสงหมุน + ขอบจอไล่มืด */
.scr.drawmode { background:
  radial-gradient(circle at 50% 45%, rgba(255, 213, 74, .10) 0, rgba(255, 213, 74, .38) 27%, rgba(180, 120, 255, .30) 33%, rgba(70, 23, 143, 0) 50%),
  radial-gradient(1200px 600px at 12% -10%, #9a5fe0 0, transparent 55%),
  radial-gradient(1000px 500px at 95% 110%, #6a2fc0 0, transparent 55%),
  linear-gradient(160deg, #4a1896, #240a52 70%); }
.scr.drawmode::before { content: ''; position: absolute; left: 50%; top: 45%; width: 150vmax; height: 150vmax; margin: -75vmax 0 0 -75vmax; pointer-events: none;
  background: repeating-conic-gradient(from 0deg, rgba(255, 220, 140, .09) 0 6deg, transparent 6deg 15deg);
  -webkit-mask: radial-gradient(circle, #000 8%, transparent 45%); mask: radial-gradient(circle, #000 8%, transparent 45%);
  }
.scr.drawmode::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(8, 0, 25, .55) 100%); }
.scr.drawmode .stage, .scr.drawmode .foot { position: relative; z-index: 1; }

/* โพเดียมหลายอันดับ */
.pod.p4 .blk { background: linear-gradient(#b9a3e0, #8e74c4); }
.pod .blk .rk { display: inline-grid; place-items: center; width: 4vw; height: 4vw; border-radius: 50%; background: #fff; color: #46178f; font-size: 2.4vw; font-weight: 800; }
.podsel { display: flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--mute); margin-left: 6px; }
.podsel select { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 4px 6px; font-size: 13px; }
.podrest { display: flex; flex-wrap: wrap; justify-content: center; gap: .8vw; margin-top: 1vw; animation: slidein .6s both; }
.podrest div { background: rgba(255,255,255,.14); border-radius: .7vw; padding: .5vw 1.2vw; font-size: 1.5vw; font-weight: 600; display: flex; align-items: center; gap: .8vw; }
.podrest .rk { background: #fff; color: #46178f; border-radius: 50%; width: 2.2vw; height: 2.2vw; display: grid; place-items: center; font-family: Kanit; font-size: 1.2vw; }
.podrest b { font-family: Kanit; color: #ffd54a; }

/* รายชื่อผู้โชคดีทั้งหมด */
.wall { flex: 1; display: grid; gap: 1vw; align-content: start; overflow: hidden; max-width: 90vw; width: 100%; margin: 0 auto; }
.wall.lg { grid-template-columns: repeat(2, 1fr); } .wall.md { grid-template-columns: repeat(3, 1fr); }
.wall.sm { grid-template-columns: repeat(4, 1fr); gap: .7vw; } .wall.xs { grid-template-columns: repeat(5, 1fr); gap: .5vw; }
.wcard { display: flex; align-items: center; gap: 1vw; background: linear-gradient(160deg, #fffaf0, #ffe9a8); color: #2b0f5c; border-radius: 1vw; padding: 1vw 1.3vw; box-shadow: 0 0 0 .2vw #d4a640, 0 .5vw 1.5vw rgba(0,0,0,.3); animation: popin .5s cubic-bezier(.2, 1.4, .4, 1) both; min-width: 0; }
.wcard .no { flex: none; width: 3.2vw; height: 3.2vw; border-radius: 50%; background: #46178f; color: #ffd54a; display: grid; place-items: center; font-family: Kanit; font-weight: 800; font-size: 1.6vw; }
.wcard div { min-width: 0; } .wcard b { display: block; font-family: Kanit; font-size: 2.3vw; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wcard span { font-size: 1.3vw; color: #6b4a00; } .wcard em { display: block; font-size: 1.1vw; color: #b00; font-style: normal; }
.wcard.abs { opacity: .5; } .wcard.abs b { text-decoration: line-through; }
.wall.md .wcard b { font-size: 1.9vw; } .wall.sm .wcard { padding: .6vw .9vw; } .wall.sm .wcard b { font-size: 1.5vw; } .wall.sm .wcard .no { width: 2.4vw; height: 2.4vw; font-size: 1.2vw; } .wall.sm .wcard span { font-size: 1vw; }
.wall.xs .wcard { padding: .45vw .7vw; } .wall.xs .wcard b { font-size: 1.2vw; } .wall.xs .wcard .no { width: 2vw; height: 2vw; font-size: 1vw; } .wall.xs .wcard span { font-size: .85vw; }
