:root {
  --bg: #13111f;
  --panel: #1f1b33;
  --panel2: #2b2648;
  --line: #3a3460;
  --text: #ffffff;
  --muted: #a9a3c9;
  --accent: #7353ff;
  --accent2: #a48bff;
  --good: #1d8237;
  --bad: #e21b3c;
  --gold: #ffb703;
  --red: #e21b3c;
  --blue: #1368ce;
  --yellow: #b88300;
  --green: #26890c;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Nunito', system-ui, sans-serif;
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; }
.bigq, .dare-card, .opt, .qtext, .headline, .msg, .chip, .feed .f { overflow-wrap: anywhere; }
a { color: var(--accent2); }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.15; font-weight: 900; }
.muted { color: var(--muted); }
.center { text-align: center; }
.row { display: flex; gap: .6em; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* ---------- controls ---------- */
.btn, button.btn {
  border: 0; border-radius: 12px; padding: .7em 1.2em; cursor: pointer;
  background: var(--panel2); color: var(--text); font-weight: 900;
  transition: transform .08s, filter .15s; touch-action: manipulation;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; filter: none; }
.btn.primary { background: var(--accent); }
.btn.good { background: var(--good); }
.btn.danger { background: transparent; color: var(--muted); border: 2px solid var(--line); }
.btn.big { font-size: 1.25em; padding: .9em 1.4em; width: 100%; }
.btn.small { padding: .35em .7em; font-size: .85em; border-radius: 8px; }

input[type=text], input[type=number], input[type=password], input:not([type]), textarea, select {
  width: 100%; background: var(--panel2); border: 2px solid var(--line); border-radius: 12px;
  padding: .75em .9em; outline: none; font-weight: 700;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 4.5em; }
select { appearance: none; cursor: pointer; }
label { display: block; color: var(--muted); font-size: .85em; margin: 0 0 .35em; }

.card { background: var(--panel); border-radius: var(--radius); padding: 1.1em 1.2em; }

/* ---------- avatars & chips ---------- */
.av {
  display: inline-grid; place-items: center; width: 1.9em; height: 1.9em; border-radius: 50%;
  background: var(--c); color: #fff; font-weight: 900; flex: none; font-size: .95em;
}
.av { overflow: hidden; }
.av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av.emo { font-size: 1.1em; background: color-mix(in srgb, var(--c) 35%, var(--panel2)); }
.av.xl { width: 3.4em; height: 3.4em; font-size: 1.6em; box-shadow: 0 0 0 4px var(--c); }
.av.xl.emo { font-size: 3em; width: 1.9em; height: 1.9em; }
.chip { display: inline-flex; align-items: center; gap: .45em; background: var(--panel2); border-radius: 999px; padding: .25em .8em .25em .25em; }
.chip.off { opacity: .4; }
.chips { display: flex; flex-wrap: wrap; gap: .4em; }
.chips.tiny .chip { font-size: .75em; }

/* ---------- timers ---------- */
.clock {
  display: inline-grid; place-items: center; min-width: 2.4em; height: 2.4em; padding: 0 .4em; border-radius: 999px;
  background: var(--accent); font-weight: 900; font-size: 1.3em;
}
.tbar { height: 8px; background: var(--panel2); overflow: hidden; }
.tbar i { display: block; height: 100%; background: var(--accent2); width: 100%; transition: width .2s linear; }

/* ---------- toast ---------- */
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 99; display: grid; gap: 8px; width: min(92vw, 480px); }
.toast { background: #fff; color: #13111f; padding: .8em 1em; border-radius: 12px; box-shadow: 0 8px 30px #0008; animation: pop .2s ease-out; text-align: center; }
@keyframes pop { from { transform: translateY(10px) scale(.96); opacity: 0; } }

.offline-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 98; background: var(--bad); text-align: center; padding: .4em; font-size: .9em;
}

/* ---------- Kahoot-style answers ---------- */
.shape svg { width: 1.4em; height: 1.4em; fill: #fff; flex: none; }
.ans-0 { background: var(--red); }
.ans-1 { background: var(--blue); }
.ans-2 { background: var(--yellow); }
.ans-3 { background: var(--green); }

/* =========================================================
   HOST (TV) SCREEN
   ========================================================= */
.host { min-height: 100vh; font-size: clamp(15px, 1.35vw, 30px); display: flex; flex-direction: column; }
.host .bar { display: flex; align-items: center; gap: 1em; padding: .7em 1.2em; background: var(--panel); }
.host .gname { font-weight: 900; font-size: 1.15em; }
.host .codechip { background: var(--panel2); border-radius: 999px; padding: .3em .9em; color: var(--muted); }
.host .codechip b { color: var(--text); letter-spacing: .1em; }
.host .stage { flex: 1; padding: 1.4em 2em; display: flex; flex-direction: column; min-height: 0; }
.host .controls { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 40%); display: flex; gap: .8em; justify-content: flex-end; padding: .8em 1.2em; }
.host .controls .btn { font-size: 1em; }

.headline { font-size: 2.6em; font-weight: 900; text-align: center; margin: .3em 0; line-height: 1.15; }
.subline { font-size: 1.3em; text-align: center; color: var(--muted); }
.bigq { font-size: 2.1em; font-weight: 900; text-align: center; background: #fff; color: #13111f; border-radius: var(--radius); padding: .6em 1em; line-height: 1.2; }
.bigq .blank { color: var(--accent); }
.center-stage { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 1em; }
.count-pill { display: inline-flex; flex-direction: column; align-items: center; background: var(--panel); border-radius: var(--radius); padding: .5em 1.2em; }
.count-pill b { font-size: 2.4em; line-height: 1; }

/* lobby */
.lobby { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 1.2em; padding: 1.2em; flex: 1; }
.joinbox { text-align: center; display: flex; flex-direction: column; align-items: center; gap: .3em; }
.joinbox .url { font-size: 1.6em; font-weight: 900; }
.joinbox .code { font-size: 5em; font-weight: 900; letter-spacing: .12em; line-height: 1; color: var(--gold); }
#qr { background: #fff; border-radius: 12px; padding: 8px; line-height: 0; margin-top: .4em; }
#qr svg { width: 9em; height: 9em; }
.pgrid { display: flex; flex-wrap: wrap; gap: .5em; }
.pgrid .chip button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 0 0 .3em; font-size: 1em; }
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(13em, 1fr)); gap: .8em; }
.gcard { background: var(--panel); border-radius: var(--radius); padding: 1em; display: flex; flex-direction: column; gap: .5em; }
.gcard h3 { font-size: 1.1em; margin: 0; }
.gcard p { margin: 0; color: var(--muted); font-size: .85em; flex: 1; }
.gcard .opts { display: flex; gap: .4em; align-items: center; }
.gcard select { padding: .4em .6em; font-size: .85em; border-radius: 8px; }
.gcard .quizopts { display: grid; gap: .4em; }
.gcard .check { display: flex; gap: .4em; align-items: center; color: var(--muted); font-size: .8em; margin: 0; }
.lobby-side { display: flex; flex-direction: column; gap: 1.2em; }
.board { display: grid; gap: .35em; }
.board .brow { display: flex; align-items: center; gap: .6em; background: var(--panel2); border-radius: 12px; padding: .35em .7em .35em .35em; }
.board .brow .pos { width: 1.6em; text-align: center; color: var(--muted); }
.board .brow .pts { margin-left: auto; font-weight: 900; }
.board .brow .plus { color: var(--good); margin-left: .6em; font-size: .85em; }
.board .brow.first { background: linear-gradient(90deg, #ffb70333, var(--panel2)); }

/* quiz host */
.quiz-q { display: flex; flex-direction: column; gap: 1em; flex: 1; min-height: 0; }
.quiz-mid { flex: 1; display: flex; align-items: center; justify-content: center; gap: 2em; min-height: 0; }
.quiz-mid img { max-height: 32vh; max-width: 50vw; border-radius: 12px; object-fit: contain; }
.atiles { display: grid; grid-template-columns: 1fr 1fr; gap: .7em; }
.atile { display: flex; align-items: center; gap: .7em; padding: .9em 1em; border-radius: 12px; font-size: 1.4em; font-weight: 900; position: relative; }
.atile.dim { opacity: .3; }
.atile .tick { margin-left: auto; font-size: 1.2em; }
.atile .cnt { margin-left: auto; background: #0004; border-radius: 999px; padding: 0 .6em; }
.reveal-wrap { display: grid; grid-template-columns: 1.5fr 1fr; gap: 1.5em; flex: 1; align-items: start; }

/* draw host */
.draw-wrap { display: grid; grid-template-columns: auto minmax(14em, 1fr); gap: 1.4em; flex: 1; min-height: 0; align-items: start; }
.board-canvas { background: #fff; border-radius: 12px; width: min(62vw, calc((100vh - 13em) * 4 / 3)); aspect-ratio: 4 / 3; display: block; }
.hint { font-size: 2.2em; font-weight: 900; letter-spacing: .25em; font-family: ui-monospace, monospace; text-align: center; white-space: pre-wrap; }
.slots { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: .2em; }
.slots b { display: inline-block; min-width: .9em; border-bottom: .12em solid currentColor; text-align: center; line-height: 1.2; text-transform: uppercase; }
.slots .gap { width: .6em; }
.hint { letter-spacing: 0; font-family: inherit; }
/* comfortable tap targets for small buttons on touch screens (admin pages) */
@media (pointer: coarse) { .btn.small { min-height: 40px; min-width: 40px; } }
.feed { display: grid; gap: .3em; font-size: .95em; }
.feed .f { background: var(--panel); border-radius: 10px; padding: .3em .6em; display: flex; gap: .4em; align-items: center; }
.feed .f.ok { background: #1d823733; }
.feed .f.close { background: #ffb70333; }

/* option cards (liar / likely / faceoff) */
.opts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15em, 1fr)); gap: .8em; }
.opt { background: var(--panel); border-radius: var(--radius); padding: 1em 1.1em; font-size: 1.3em; font-weight: 900; display: flex; flex-direction: column; gap: .5em; }
.opt .who { font-size: .65em; color: var(--muted); font-weight: 700; }
.opt.truth { background: var(--good); }
.opt.truth .who { color: #fff; }
.tallybar { height: 10px; border-radius: 999px; background: var(--accent2); }
.versus { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1.2em; align-items: stretch; flex: 1; }
.versus .vs { align-self: center; font-size: 2em; font-weight: 900; color: var(--muted); }
.versus .opt { font-size: 1.8em; justify-content: center; text-align: center; }
.versus .opt.win { outline: 4px solid var(--gold); }
.sweep { background: var(--gold); color: #13111f; border-radius: 999px; padding: .1em .8em; font-size: .6em; align-self: center; }

/* =========================================================
   PLAYER (PHONE)
   ========================================================= */
.phone { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; }
.phone .top { display: flex; align-items: center; gap: .6em; padding: .7em 16px; background: var(--panel); }
.phone .top .pts { margin-left: auto; color: var(--gold); font-weight: 900; }
.phone main { flex: 1; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.phone .msg { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: .5em; }
.phone .msg .emoji { font-size: 4em; line-height: 1; }
.phone .msg h2 { font-size: 1.6em; }
.phone .qtext { font-size: 1.2em; font-weight: 900; text-align: center; }
.phone .list { display: grid; gap: 10px; }
.phone .list .btn { text-align: left; display: flex; align-items: center; gap: .6em; padding: .9em 1em; font-size: 1.05em; }
.phone .list .btn.sel { background: var(--accent); }
.pad-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; flex: 1; min-height: 50vh; }
.pad-grid button { border: 0; border-radius: 14px; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4em; font-weight: 900; font-size: 1.05em; padding: .6em; cursor: pointer; }
.pad-grid button .shape svg { width: 2.6em; height: 2.6em; }
.pad-grid.two { grid-template-columns: 1fr; }
.result { border-radius: var(--radius); padding: 1.6em 1em; text-align: center; }
.result.good { background: var(--good); }
.result.bad { background: var(--bad); }
.result h2 { font-size: 2em; margin: 0; }
.secret-card { background: var(--panel); border-radius: var(--radius); padding: 2.2em 1em; text-align: center; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; cursor: pointer; }
.secret-card .secret { display: none; font-size: 2em; font-weight: 900; }
.secret-card.show .secret { display: block; }
.secret-card.show .cover { display: none; }
.secret-card .cover { color: var(--muted); }
.drawpad { background: #fff; border-radius: 12px; width: 100%; aspect-ratio: 4 / 3; touch-action: none; display: block; }
.palette { display: flex; flex-wrap: wrap; gap: 8px; }
.palette button[data-c] { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; background: var(--c); cursor: pointer; }
.palette button[data-c].sel { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.palette .size { width: auto; border-radius: 10px; background: var(--panel2); color: #fff; padding: 0 .6em; height: 34px; }
.palette .size.sel { background: var(--accent); }

/* landing */
.landing { max-width: 440px; margin: 0 auto; padding: 8vh 16px 40px; display: flex; flex-direction: column; gap: 14px; }
.landing h1 { font-size: 2.6em; text-align: center; }
.landing .code-in { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-size: 1.6em; font-weight: 900; }

@media (max-width: 900px) {
  .lobby { grid-template-columns: 1fr; }
  .reveal-wrap, .draw-wrap { grid-template-columns: 1fr; }
  .board-canvas { width: 100%; }
  .versus { grid-template-columns: 1fr; }
}

/* ---------- join: pick yourself ---------- */
.who-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.who-grid button { background: var(--panel); border: 2px solid transparent; border-radius: 14px; padding: 12px 6px; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; font-weight: 900; }
.who-grid button .av { font-size: 1.5em; }
.who-grid button:hover { border-color: var(--accent); }
.who-grid button:disabled { opacity: .35; cursor: default; border-color: transparent; }
.who-grid button small { color: var(--muted); font-weight: 700; font-size: .7em; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.emoji-grid button { font-size: 1.5em; background: var(--panel2); border: 2px solid transparent; border-radius: 10px; padding: 4px 0; cursor: pointer; }
.emoji-grid button.sel { border-color: var(--accent); background: var(--accent); }

/* ---------- Spin the Dare ---------- */
.wheel-wrap { position: relative; width: min(62vh, 44vw); aspect-ratio: 1; margin: 0 auto; }
.wheel-wrap::after { content: ''; position: absolute; top: -.4em; left: 50%; transform: translateX(-50%); border: 1.1em solid transparent; border-top: 1.8em solid #fff; border-bottom: 0; filter: drop-shadow(0 3px 4px #0008); }
.wheel { width: 100%; height: 100%; border-radius: 50%; position: relative; box-shadow: 0 0 0 8px var(--panel2), 0 20px 60px #0008; transition: transform 5.4s cubic-bezier(.12, .7, .1, 1); }
.wheel .seg { position: absolute; left: 50%; top: 50%; width: 0; height: 50%; transform-origin: 0 0; }
.wheel .seg > span { position: absolute; left: 0; top: 52%; transform: translate(-50%, 0) rotate(0deg); display: flex; flex-direction: column; align-items: center; gap: .2em; font-weight: 900; font-size: .9em; text-shadow: 0 1px 3px #0009; white-space: nowrap; }
.dare-card { background: #fff; color: #13111f; border-radius: 22px; padding: 1em 1.4em; font-size: 2.2em; font-weight: 900; text-align: center; line-height: 1.2; max-width: 28em; box-shadow: 0 20px 60px #0008; }
.dare-card .tag { display: inline-block; font-size: .45em; padding: .2em .8em; border-radius: 999px; background: #e0559b; color: #fff; margin-bottom: .5em; letter-spacing: .05em; }
.dare-card .tag.solo { background: var(--accent); }
.phone .dare-card { font-size: 1.3em; }
.judge { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.judge button { font-size: 2.6em; padding: .4em 0; }
.wheel .seg .av { font-size: 1.7em; }

/* ---------- Paranoia coin ---------- */
.coin { font-size: 5em; line-height: 1; }
.coin.spinning { animation: flip .5s linear infinite; }
@keyframes flip { from { transform: rotateY(0); } to { transform: rotateY(360deg); } }

/* ---------- Fastest Finger ---------- */
.reaction { border-radius: var(--radius); background: var(--bad); transition: background .05s; }
.reaction.go { background: var(--good); }
.reaction .when-go, .reaction.go .when-wait { display: none; }
.reaction.go .when-go { display: block; }
.tapzone { flex: 1; min-height: 60vh; border: 0; border-radius: 24px; background: var(--bad); color: #fff; font-size: 2em; font-weight: 900; touch-action: manipulation; user-select: none; -webkit-user-select: none; cursor: pointer; }
.tapzone.go { background: var(--good); }
.tapzone .when-go, .tapzone.go .when-wait { display: none; }
.tapzone.go .when-go { display: inline; }
.tapzone.frenzy { background: var(--accent); }
.tapzone:active { filter: brightness(1.2); }
.bigbtns { display: grid; gap: 12px; flex: 1; }
.bigbtns button { font-size: 2em; border-radius: 22px; }
.bigq .muted, .dare-card .muted { color: #6b6685; }
