:root {
  --deep: #0b3d2e; --emerald: #0b5d3f; --jade: #15805a; --gold: #d4a81e; --ink: #1d2a24; --light: #ecf5ee;
  --c0: #e21b3c; --c1: #1368ce; --c2: #d89e00; --c3: #26890c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "IBM Plex Sans Thai", "Sarabun", system-ui, sans-serif; color: #fff;
  background: radial-gradient(circle at 20% 10%, #13704c 0, var(--deep) 55%, #062519 100%); background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, .big, .pin, .num, button { font-family: "Kanit", "IBM Plex Sans Thai", sans-serif; }
.screen { display: none; min-height: 100vh; padding: 24px; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.screen.on { display: flex; }
button {
  border: 0; border-radius: 10px; padding: 14px 28px; font-size: 22px; font-weight: 600; cursor: pointer;
  background: var(--gold); color: var(--deep); box-shadow: 0 4px 0 #8f7010; transition: transform .05s;
}
button:active { transform: translateY(3px); box-shadow: 0 1px 0 #8f7010; }
button.ghost { background: rgba(255,255,255,.15); color: #fff; box-shadow: none; }
input {
  font: 600 24px "Kanit", sans-serif; text-align: center; padding: 14px; border-radius: 10px; border: 0;
  width: min(340px, 90vw); margin: 8px 0; color: var(--ink);
}
.logo { font-size: 18px; letter-spacing: .5px; opacity: .85; margin-bottom: 12px; }
.logo b { color: var(--gold); }
.card { background: #fff; color: var(--ink); border-radius: 14px; padding: 24px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.err { color: #ffd2d2; min-height: 1.5em; margin-top: 8px; font-weight: 600; }
#net { position: fixed; top: 10px; right: 12px; width: 12px; height: 12px; border-radius: 50%; background: #3ddc84; }
#net.bad { background: #e21b3c; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.shape svg { width: 1em; height: 1em; fill: #fff; display: block; }
.c0 { background: var(--c0); } .c1 { background: var(--c1); } .c2 { background: var(--c2); } .c3 { background: var(--c3); }

/* host */
.host .pinbox { display: flex; gap: 40px; align-items: center; flex-wrap: wrap; justify-content: center; }
.host .pin { font-size: 120px; font-weight: 700; letter-spacing: 8px; color: var(--deep); line-height: 1; }
.host .url { font-size: 26px; color: var(--emerald); font-weight: 600; }
.host #qr svg, .host #qr img { width: 230px; height: 230px; display: block; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 1400px; margin: 24px 0; }
.chip { background: rgba(255,255,255,.14); border-radius: 30px; padding: 8px 18px; font: 600 22px "Kanit", sans-serif; cursor: pointer; animation: pop .3s; }
.chip:hover { background: var(--c0); }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.qhead { width: 100%; max-width: 1500px; display: flex; justify-content: space-between; align-items: center; font-size: 22px; }
.qtext { background: #fff; color: var(--ink); border-radius: 12px; padding: 28px 36px; font: 600 46px/1.35 "Kanit", sans-serif; width: 100%; max-width: 1500px; margin: 18px 0; }
.mid { display: flex; align-items: center; gap: 40px; margin: 10px 0 24px; }
.clock { width: 140px; height: 140px; border-radius: 50%; background: #5b2a86; display: grid; place-items: center; font: 700 64px "Kanit", sans-serif; }
.ans-count { font: 600 26px "Kanit", sans-serif; }
.ans-count .num { font-size: 64px; display: block; }
.grid4 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; max-width: 1500px; }
.tile { display: flex; align-items: center; gap: 18px; padding: 22px 26px; border-radius: 10px; font: 600 32px/1.3 "Kanit", sans-serif; text-align: left; min-height: 110px; transition: opacity .3s; }
.tile .shape { font-size: 44px; flex: none; }
.tile.dim { opacity: .3; }
.tile.ok { outline: 6px solid #fff; }
.bars { display: flex; gap: 30px; align-items: flex-end; height: 200px; margin: 0 0 14px; }
.bar { width: 110px; border-radius: 6px 6px 0 0; display: flex; flex-direction: column; justify-content: flex-start; align-items: center; color: #fff; font: 700 30px "Kanit", sans-serif; padding-top: 6px; min-height: 76px; transition: height .6s; }
.bar .shape { font-size: 26px; margin-top: 4px; }
#s-reveal .tile { min-height: 70px; padding: 14px 22px; font-size: 26px; }
#s-reveal .qtext { padding: 18px 30px; margin: 10px 0; }
.explain { background: #fff; color: var(--ink); border-left: 10px solid var(--gold); border-radius: 10px; padding: 18px 26px; font-size: 28px; line-height: 1.45; max-width: 1500px; width: 100%; text-align: left; margin-top: 18px; }
.explain b { color: var(--emerald); font-family: "Kanit", sans-serif; }
.board { width: min(900px, 95vw); }
.row { display: flex; justify-content: space-between; align-items: center; background: #fff; color: var(--ink); border-radius: 10px; padding: 16px 26px; margin: 10px 0; font: 600 34px "Kanit", sans-serif; animation: slide .4s backwards; }
.row:nth-child(2) { animation-delay: .1s } .row:nth-child(3) { animation-delay: .2s } .row:nth-child(4) { animation-delay: .3s } .row:nth-child(5) { animation-delay: .4s }
.row small { color: var(--jade); font-size: 22px; margin-left: 12px; }
@keyframes slide { from { transform: translateX(-60px); opacity: 0; } }
.podium { display: flex; align-items: flex-end; gap: 18px; margin: 30px 0; }
.step { width: 230px; border-radius: 10px 10px 0 0; background: var(--emerald); display: flex; flex-direction: column; justify-content: flex-start; padding-top: 18px; font: 700 30px "Kanit", sans-serif; animation: rise 1s backwards; }
.step .place { font-size: 70px; color: var(--gold); }
.step small { font-size: 22px; opacity: .85; }
@keyframes rise { from { transform: translateY(200px); opacity: 0; } }
.foot { position: fixed; bottom: 4px; left: 0; right: 0; text-align: center; font-size: 16px; opacity: .6; }
.btnrow { display: flex; gap: 14px; margin-top: 26px; }

/* player */
.player .screen { padding: 16px; }
.player .pgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; flex: 1; max-height: 78vh; }
.player .pgrid button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: #fff; font-size: 19px; line-height: 1.3; padding: 12px; box-shadow: 0 5px 0 rgba(0,0,0,.25); }
.player .pgrid .shape { font-size: 46px; }
.player .tbar { height: 8px; background: var(--gold); border-radius: 4px; width: 100%; margin: 8px 0 14px; }
.player .top { width: 100%; display: flex; justify-content: space-between; font: 600 18px "Kanit", sans-serif; }
.player .verdict { font: 700 44px "Kanit", sans-serif; margin: 8px 0; }
.player .pts { font: 700 34px "Kanit", sans-serif; color: var(--gold); }
.player .ok { background: var(--c3); } .player .bad { background: var(--c0); }
.player #result.ok, .player #result.bad { background-image: none; }
.player .muted { opacity: .85; font-size: 18px; margin-top: 10px; }
.player .nick { font: 700 34px "Kanit", sans-serif; color: var(--gold); }
.spinner { width: 54px; height: 54px; border: 6px solid rgba(255,255,255,.25); border-top-color: var(--gold); border-radius: 50%; animation: spin 1s linear infinite; margin: 20px; }
@keyframes spin { to { transform: rotate(360deg); } }
