/* Live Quiz — "Notebook doodle" theme on light-blue dot-grid paper */
:root {
  --paper: #fbfaf6;
  --dot: #a9c9ec;
  --ink: #2b2a27;
  --ink-2: #5d5b55;
  --pen: #2456a6;
  --red: #d9483b;
  --ok: #1e8a5a;
  --bad: #d9483b;
  --hl: #ffe27a;
  --line: #d6d2c6;
  /* sticky notes: fill / text */
  --s0: #ffd66b; --s0t: #4a3300;
  --s1: #f7b6ce; --s1t: #5a1730;
  --s2: #a8e6cf; --s2t: #0d4434;
  --s3: #b0d2f5; --s3t: #0d3260;
  --sketch: 255px 15px 225px 15px / 15px 225px 15px 255px;
  --sketch2: 15px 225px 15px 255px / 255px 15px 225px 15px;
  font-family: 'Sarabun', 'Noto Sans Thai', system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body, .paper {
  background-color: var(--paper);
  background-image: radial-gradient(var(--dot) 1.3px, transparent 1.5px);
  background-size: 22px 22px;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, .hand, button, .logo, .pts, .pin, .count-badge { font-family: 'Mali', 'Sarabun', cursive; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  cursor: pointer; border: 2.5px solid var(--ink); border-radius: var(--sketch); padding: .55em 1.1em;
  font-weight: 700; background: var(--s3); color: var(--s3t); box-shadow: 2px 3px 0 var(--ink);
  transition: transform .06s, box-shadow .06s;
}
button:hover { transform: translate(-1px, -1px); box-shadow: 3px 4px 0 var(--ink); }
button:active { transform: translate(2px, 3px); box-shadow: 0 0 0 var(--ink); }
button:disabled { opacity: .45; cursor: default; transform: none; box-shadow: 2px 3px 0 var(--ink); }
button.ghost { background: #fff; color: var(--ink); }
button.light { background: #fff; color: var(--ink); }
button.danger { background: var(--s1); color: var(--s1t); }
button.big { font-size: 1.2rem; padding: .7em 1.5em; background: var(--s0); color: var(--s0t); }
input, select, textarea { border: 2px solid var(--ink); border-radius: var(--sketch2); padding: .6em .8em; background: #fff; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 4px var(--hl); }
.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.card { background: #fff; border: 2px solid var(--ink); border-radius: var(--sketch2); padding: 1.1rem; box-shadow: 3px 4px 0 rgba(43, 42, 39, .85); }
.tape { position: relative; }
.tape::before {
  content: ''; position: absolute; top: -13px; left: 50%; width: 96px; height: 24px; transform: translateX(-50%) rotate(-3deg);
  background: rgba(169, 201, 236, .65); border-left: 2px dashed rgba(255,255,255,.7); border-right: 2px dashed rgba(255,255,255,.7); z-index: 2;
}
.tape.y::before { background: rgba(255, 214, 107, .7); }
.banner { position: fixed; top: 0; left: 0; right: 0; z-index: 50; background: var(--hl); color: var(--ink); text-align: center; padding: .4rem; font-weight: 700; border-bottom: 2px dashed var(--ink); }
.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%) rotate(-1deg); background: #fff; color: var(--ink); border: 2.5px solid var(--ink); box-shadow: 3px 4px 0 var(--ink); padding: .7rem 1.1rem; border-radius: var(--sketch); z-index: 60; max-width: 92vw; text-align: center; font-weight: 700; }
.hl { background: linear-gradient(transparent 55%, var(--hl) 55%); padding: 0 .15em; }

/* sticky-note answer colours: ★ yellow, ♥ pink, ☁ mint, ✿ blue · true = mint, false = pink */
.c0 { background: var(--s0) !important; color: var(--s0t) !important; }
.c1, .tf1 { background: var(--s1) !important; color: var(--s1t) !important; }
.c2, .tf0 { background: var(--s2) !important; color: var(--s2t) !important; }
.c3 { background: var(--s3) !important; color: var(--s3t) !important; }
.shape { font-size: 1.25em; margin-right: .35em; }

/* ---------- player (phone) ---------- */
.player { min-height: 100%; display: flex; flex-direction: column; }
.player header { display: flex; justify-content: space-between; align-items: center; padding: .55rem .9rem; background: #fff; border-bottom: 2px dashed var(--ink); font-weight: 700; font-family: 'Mali', 'Sarabun', cursive; }
.player main { flex: 1; display: flex; flex-direction: column; padding: 1rem; gap: 1rem; }
.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 1rem; }
.join-box { background: #fff; border: 2.5px solid var(--ink); border-radius: var(--sketch2); padding: 1.4rem 1.2rem 1.2rem; width: min(380px, 100%); display: flex; flex-direction: column; gap: .8rem; box-shadow: 4px 5px 0 var(--ink); position: relative; }
.join-box::before { content: ''; position: absolute; top: -13px; left: 50%; width: 96px; height: 24px; transform: translateX(-50%) rotate(-3deg); background: rgba(169, 201, 236, .65); }
.join-box input { font-size: 1.3rem; text-align: center; font-weight: 700; }
.join-box .pin { letter-spacing: .25em; }
.logo { font-size: 2.2rem; font-weight: 700; transform: rotate(-2deg); }
.logo small { display: block; font-size: .95rem; font-weight: 500; color: var(--ink-2); transform: rotate(1deg); }
.qtext { font-size: 1.1rem; font-weight: 700; background: #fff; padding: .8rem; border: 2px solid var(--ink); border-radius: var(--sketch2); }
.answers { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; min-height: 55vh; padding: .2rem; }
.answers.tf, .answers.one-col { grid-template-columns: 1fr; }
.answers button { font-size: 1.1rem; display: flex; align-items: center; justify-content: center; padding: .8rem; text-align: center; border-radius: 4px 4px 4px 18px; box-shadow: 3px 4px 0 var(--ink); }
.answers button:nth-child(1) { transform: rotate(-1.5deg); }
.answers button:nth-child(2) { transform: rotate(1.2deg); }
.answers button:nth-child(3) { transform: rotate(1deg); }
.answers button:nth-child(4) { transform: rotate(-1deg); }
.answers button.picked { outline: 4px dashed var(--pen); outline-offset: 4px; }
.answers.done button:not(.picked) { opacity: .3; }
.big-emoji { font-size: 4.5rem; line-height: 1; }
.result-ok { background: var(--s2); color: var(--s2t); }
.result-bad { background: var(--s1); color: var(--s1t); }
.result-box { border: 2.5px solid var(--ink); box-shadow: 4px 5px 0 var(--ink); border-radius: 4px 4px 4px 24px; padding: 1.4rem; width: min(380px, 100%); transform: rotate(-1deg); }
.pts { font-size: 2.4rem; font-weight: 700; }
.timer-bar { height: 12px; background: #fff; border: 2px solid var(--ink); border-radius: 10px; overflow: hidden; }
.timer-bar > div { height: 100%; background: repeating-linear-gradient(-45deg, var(--pen) 0 6px, #4f7fcf 6px 12px); width: 100%; transition: width .25s linear; }
.chip { display: inline-block; background: #fff; border: 2px solid var(--ink); padding: .2rem .7rem; border-radius: var(--sketch); margin: .2rem; font-weight: 700; }
textarea.short { min-height: 9rem; font-size: 1.05rem; resize: vertical; }
.counter { text-align: right; font-size: .9rem; color: var(--ink-2); }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 4px dashed var(--pen); animation: spin 2.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.player header .sndbtn { background: #fff; color: var(--ink); padding: .15rem .55rem; font-size: 1rem; box-shadow: 1px 2px 0 var(--ink); }

/* ---------- host ---------- */
.host-shell { min-height: 100%; }
.topbar { display: flex; align-items: center; gap: 1rem; padding: .7rem 1.2rem; background: #fff; border-bottom: 2.5px dashed var(--ink); }
.topbar .brand { font-weight: 700; font-size: 1.3rem; font-family: 'Mali', cursive; }
.wrap { max-width: 1050px; margin: 0 auto; padding: 1.4rem 1.2rem; }
.quiz-list { display: grid; gap: 1.1rem; }
.quiz-item { display: flex; gap: 1rem; align-items: center; }
.quiz-item h3 { margin: 0 0 .2rem; }
.qcard { margin-bottom: 1.1rem; }
.qcard .head { display: flex; gap: .5rem; align-items: center; margin-bottom: .6rem; }
.qcard .num { background: var(--hl); border: 2px solid var(--ink); border-radius: 50%; width: 2.1rem; height: 2.1rem; display: grid; place-items: center; font-weight: 700; font-family: 'Mali', cursive; }
.opt-row { display: flex; gap: .5rem; align-items: center; margin: .35rem 0; }
.opt-row .sw { width: 34px; height: 34px; border: 2px solid var(--ink); border-radius: 4px 4px 4px 10px; display: grid; place-items: center; flex: none; }
.opt-row label { display: flex; align-items: center; gap: .25rem; white-space: nowrap; font-size: .9rem; }
.opt-row input[type=checkbox], .opt-row input[type=radio] { width: auto; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .6rem; margin-top: .6rem; }
.field label { display: block; font-size: .85rem; color: var(--ink-2); margin-bottom: .2rem; }
.tag { display: inline-block; font-size: .8rem; padding: .05rem .5rem; border-radius: var(--sketch); border: 1.5px solid var(--ink); background: var(--hl); font-weight: 700; }

/* stage (projector) */
.stage { position: fixed; inset: 0; display: flex; flex-direction: column; color: var(--ink);
  background-color: var(--paper); background-image: radial-gradient(var(--dot) 1.5px, transparent 1.7px); background-size: 26px 26px; }
.stage .bar { display: flex; align-items: center; gap: .8rem; padding: .6rem 1.2rem; background: #fff; border-bottom: 2.5px dashed var(--ink); }
.stage .bar .grow { font-weight: 700; font-family: 'Mali', cursive; font-size: 1.1rem; }
.stage .bar button { padding: .3em .7em; }
.stage .body { flex: 1; display: flex; flex-direction: column; padding: 1.4rem 2rem; gap: 1.2rem; min-height: 0; }
.stage .foot { display: flex; gap: .8rem; justify-content: flex-end; align-items: center; padding: .8rem 1.5rem; background: #fff; border-top: 2.5px dashed var(--ink); }
.stage .foot button { font-size: 1.1rem; }
.lobby { display: grid; grid-template-columns: 1fr auto; gap: 2.5rem; align-items: center; }
.pinbox { background: var(--s0); color: var(--s0t); border: 2.5px solid var(--ink); border-radius: 4px 4px 4px 28px; padding: 1.4rem 1.8rem; box-shadow: 5px 6px 0 var(--ink); transform: rotate(-1.2deg); position: relative; }
.pinbox::before { content: ''; position: absolute; top: -14px; left: 40%; width: 120px; height: 26px; transform: rotate(-4deg); background: rgba(169, 201, 236, .7); }
.pinbox .url { font-size: 1.4rem; }
.pinbox .pin { font-size: 5.5rem; font-weight: 700; letter-spacing: .08em; line-height: 1.05; color: var(--ink); }
.qr { background: #fff; padding: .9rem; border: 2.5px solid var(--ink); border-radius: var(--sketch2); box-shadow: 5px 6px 0 var(--ink); transform: rotate(1.5deg); }
.qr svg, .qr img { display: block; width: 220px; height: 220px; }
.names { display: flex; flex-wrap: wrap; gap: .6rem; align-content: flex-start; overflow: auto; flex: 1; padding: .3rem; }
.names .n { background: #fff; border: 2px solid var(--ink); padding: .35rem .9rem; border-radius: var(--sketch); font-weight: 700; font-size: 1.15rem; cursor: pointer; animation: pop .3s ease-out; font-family: 'Mali', cursive; }
.names .n:nth-child(4n+1) { background: var(--s0); } .names .n:nth-child(4n+2) { background: var(--s2); }
.names .n:nth-child(4n+3) { background: var(--s1); } .names .n:nth-child(4n) { background: var(--s3); }
.names .n:hover { text-decoration: line-through 3px var(--red); }
@keyframes pop { from { transform: scale(.4) rotate(-8deg); opacity: 0; } }
.count-badge { font-size: 1.7rem; font-weight: 700; }
.stage-q { background: #fff; border: 2.5px solid var(--ink); border-radius: var(--sketch2); box-shadow: 4px 5px 0 var(--ink); padding: 1rem 1.4rem; font-size: clamp(1.4rem, 3vw, 2.4rem); font-weight: 800; text-align: center; position: relative; }
.stage-q::before { content: ''; position: absolute; top: -13px; left: 50%; width: 110px; height: 24px; transform: translateX(-50%) rotate(-2deg); background: rgba(255, 214, 107, .75); }
.stage-mid { flex: 1; display: grid; grid-template-columns: 140px 1fr 140px; align-items: center; gap: 1rem; min-height: 0; }
.stage-mid img { max-width: 100%; max-height: 38vh; border: 2.5px solid var(--ink); border-radius: 6px; margin: 0 auto; display: block; background: #fff; box-shadow: 4px 5px 0 var(--ink); transform: rotate(-1deg); }
.ring { width: 120px; height: 120px; border-radius: 48% 52% 46% 54%; display: grid; place-items: center; font-size: 2.8rem; font-weight: 700; font-family: 'Mali', cursive;
  background: conic-gradient(var(--pen) var(--p, 100%), #fff 0); position: relative; border: 3px solid var(--ink); }
.ring::after { content: ''; position: absolute; inset: 11px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); }
.ring span { position: relative; z-index: 1; }
.answered { text-align: center; font-family: 'Mali', cursive; }
.answered b { display: block; font-size: 3rem; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.tiles .tile { border: 2.5px solid var(--ink); border-radius: 4px 4px 4px 22px; box-shadow: 4px 5px 0 var(--ink); padding: 1rem 1.2rem; font-size: clamp(1.1rem, 2.2vw, 1.8rem); font-weight: 700; display: flex; align-items: center; gap: .6rem; min-height: 4.2rem; transition: opacity .3s; }
.tiles .tile:nth-child(1) { transform: rotate(-.8deg); } .tiles .tile:nth-child(2) { transform: rotate(.7deg); }
.tiles .tile:nth-child(3) { transform: rotate(.6deg); } .tiles .tile:nth-child(4) { transform: rotate(-.6deg); }
.tiles .tile .cnt { margin-left: auto; background: #fff; border: 2px solid var(--ink); border-radius: 50%; padding: .1rem .6rem; }
.tiles.reveal .tile.wrong { opacity: .3; }
.tiles .tile .tick { font-size: 1.5em; color: var(--ok); margin-left: auto; font-family: 'Mali', cursive; }
.bars { display: flex; justify-content: center; align-items: flex-end; gap: 2.2rem; height: 32vh; border-bottom: 3px solid var(--ink); padding: 0 2rem; }
.bars .b { width: 110px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bars .b .fill { width: 100%; border: 2.5px solid var(--ink); border-bottom: 0; border-radius: 8px 14px 0 0; min-height: 8px; transition: height .6s cubic-bezier(.2, .8, .2, 1);
  background-image: repeating-linear-gradient(-45deg, rgba(255,255,255,.4) 0 5px, transparent 5px 11px); }
.bars .b .v { font-size: 1.8rem; font-weight: 700; font-family: 'Mali', cursive; }
.cloud { flex: 1; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; align-content: center; gap: .3rem 1.2rem; background: #fff; border: 2.5px dashed var(--ink); border-radius: var(--sketch2); padding: 1rem; overflow: hidden; }
.cloud span { font-weight: 700; line-height: 1.15; cursor: pointer; transition: font-size .4s; font-family: 'Mali', 'Sarabun', cursive; }
.cloud span:nth-child(3n) { transform: rotate(-3deg); } .cloud span:nth-child(5n) { transform: rotate(2deg); }
.cloud span:hover { text-decoration: line-through 3px var(--red); }
.shorts { flex: 1; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1.1rem; align-content: start; padding: .6rem; }
.shorts .s { border: 2px solid var(--ink); border-radius: 4px 4px 4px 20px; box-shadow: 3px 4px 0 var(--ink); padding: 1rem 1.1rem; position: relative; font-size: 1.3rem; line-height: 1.45; }
.shorts .s:nth-child(4n+1) { background: var(--s0); transform: rotate(-.8deg); } .shorts .s:nth-child(4n+2) { background: var(--s2); transform: rotate(.6deg); }
.shorts .s:nth-child(4n+3) { background: var(--s3); transform: rotate(.5deg); } .shorts .s:nth-child(4n) { background: var(--s1); transform: rotate(-.5deg); }
.shorts .s .who { font-size: 1rem; color: var(--ink-2); font-weight: 700; margin-bottom: .2rem; font-family: 'Mali', cursive; }
.shorts .s .x { position: absolute; top: .3rem; right: .4rem; background: #fff; padding: 0 .45rem; box-shadow: 1px 2px 0 var(--ink); }
.board { width: min(760px, 100%); margin: 0 auto; display: flex; flex-direction: column; gap: .8rem; }
.board .r { display: flex; align-items: center; gap: 1rem; background: #fff; border: 2.5px solid var(--ink); border-radius: var(--sketch2); box-shadow: 3px 4px 0 var(--ink); padding: .65rem 1.1rem; font-size: 1.5rem; font-weight: 700; animation: slide .4s ease-out both; font-family: 'Mali', 'Sarabun', cursive; }
.board .r:first-child { background: var(--s0); }
@keyframes slide { from { transform: translateX(-40px) rotate(-2deg); opacity: 0; } }
.board .r .rk { width: 2.3rem; height: 2.3rem; border-radius: 48% 52% 45% 55%; border: 2.5px solid var(--ink); background: var(--hl); display: grid; place-items: center; font-size: 1.1rem; }
.board .r .sc { margin-left: auto; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 1.4rem; flex: 1; }
.podium .p { width: 210px; text-align: center; }
.podium .p .nm { font-size: 1.6rem; font-weight: 700; margin-bottom: .3rem; word-break: break-word; font-family: 'Mali', 'Sarabun', cursive; }
.podium .p .blk { border: 3px solid var(--ink); border-bottom: 0; border-radius: 10px 16px 0 0; display: grid; place-items: center; font-size: 3.4rem; font-weight: 700; font-family: 'Mali', cursive; animation: rise .9s cubic-bezier(.2, .8, .2, 1) both; box-shadow: 4px 0 0 var(--ink); }
@keyframes rise { from { transform: scaleY(0); transform-origin: bottom; } }
.podium .p1 .blk { height: 260px; background: var(--s0); animation-delay: .9s; }
.podium .p2 .blk { height: 190px; background: var(--s3); animation-delay: .45s; }
.podium .p3 .blk { height: 140px; background: var(--s1); }
.podium .p1 .nm::before { content: '♛ '; color: #c9900c; }
.title-big { font-size: clamp(1.8rem, 3.8vw, 3.2rem); font-weight: 700; text-align: center; margin: 0; }
.title-big .hl { display: inline-block; transform: rotate(-1.5deg); }
.snd.off { opacity: .45; text-decoration: line-through; }
@media (max-width: 800px) { .lobby { grid-template-columns: 1fr; } .stage-mid { grid-template-columns: 1fr; } .tiles { grid-template-columns: 1fr; } }
