/* Enquete ao vivo — estilos (sem dependências externas, compatível com CSP estrita) */

:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --surface: #fcfcfb;
  --surface-2: #ffffff;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #6d6c67;
  --line: #e2e0da;
  --track: #ecebe6;
  --accent: #4a3aa7;
  --accent-ink: #ffffff;
  --accent-soft: #ebe8fb;
  --danger: #c0392b;
  --ok: #0f7a44;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 6px 24px rgba(0,0,0,.06);
  /* paleta categórica (ordem fixa) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #222220;
    --text: #ffffff; --text-2: #c3c2b7; --muted: #9d9c93; --line: #33322f; --track: #2a2a28;
    --accent: #9085e9; --accent-ink: #120f2b; --accent-soft: #2a2550;
    --danger: #e66767; --ok: #3ecf8e;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 24px rgba(0,0,0,.3);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #222220;
  --text: #ffffff; --text-2: #c3c2b7; --muted: #9d9c93; --line: #33322f; --track: #2a2a28;
  --accent: #9085e9; --accent-ink: #120f2b; --accent-soft: #2a2550;
  --danger: #e66767; --ok: #3ecf8e;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 24px rgba(0,0,0,.3);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
}

/* paleta "Vibrante" (inspirada nos quizzes de TV): vale para claro e escuro */
[data-palette="vibrante"] {
  --s1: #e21b3c; --s2: #1368ce; --s3: #d89e00; --s4: #26890c;
  --s5: #0aa3a3; --s6: #864cbf; --s7: #e5641f; --s8: #b8175a;
  --scale-col: #1368ce;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.45; -webkit-font-smoothing: antialiased; }
h1, h2 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; margin-top: 1.6em; }
a { color: var(--accent); }
code, kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 .35em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }

/* ---------- componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4em; font: inherit; font-weight: 600; font-size: .95rem; padding: .6em 1.1em; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); cursor: pointer; text-decoration: none; transition: transform .15s, background .15s, opacity .15s; }
.btn:hover { background: var(--track); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.btn-big { width: 100%; font-size: 1.1rem; padding: .9em 1em; margin-top: .75rem; }
.icon { font: inherit; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 8px; width: 2rem; height: 2rem; cursor: pointer; }
.icon:disabled { opacity: .3; cursor: default; }
.link { color: var(--accent); text-decoration: none; font-weight: 600; }
.alert { padding: .75rem 1rem; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.alert-ok { border-color: var(--ok); color: var(--ok); }
.alert-err { border-color: var(--danger); color: var(--danger); }

.form { display: grid; gap: .9rem; }
.form label { display: grid; gap: .35rem; font-weight: 600; font-size: .9rem; color: var(--text-2); }
input, select, textarea { font: inherit; font-size: 1rem; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: .65em .8em; width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 1px; border-color: var(--accent); }
textarea { resize: vertical; }
.inline { display: flex; gap: .6rem; align-items: center; }
.inline input { flex: 1; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.actions form { margin: 0; }

.brand { font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; color: var(--text); text-decoration: none; }
.brand span { color: var(--accent); margin-left: .3em; font-weight: 600; }

/* ---------- painel ---------- */
.page-admin .topbar { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.narrow { max-width: 760px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.login { max-width: 380px; margin: 3rem auto; }
.list, .qlist { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: .7rem; }
.list-item { display: flex; align-items: center; gap: 1rem; padding: .9rem 1.1rem; }
.list-item a.grow { text-decoration: none; color: var(--text); display: grid; }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.head-row h1 { margin: 0; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .08em; }
.qlist { counter-reset: q; }
.qlist > li { counter-increment: q; padding: .9rem 1.1rem; }
.q-head { display: flex; gap: .6rem; align-items: center; }
.q-head strong::before { content: counter(q) ". "; color: var(--muted); }
.q-head form { margin: 0; }
.qlist details { margin-top: .5rem; }
.qlist summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .9rem; }
.qlist details .form { margin-top: .8rem; }
.tag { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: .25em .6em; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }

/* ---------- participante (celular) ---------- */
.page-vote { min-height: 100vh; min-height: 100dvh; background: linear-gradient(180deg, var(--accent-soft), var(--bg) 40%); }
.vote-top { padding: 1rem 1rem .25rem; text-align: center; }
.vote-main { max-width: 520px; margin: 0 auto; padding: .75rem 16px 2rem; }
.join { display: grid; gap: .6rem; margin-top: 2rem; }
.join input { font-size: 2rem; text-align: center; letter-spacing: .15em; font-weight: 700; }
.q-title-m { font-size: 1.35rem; margin-bottom: 1rem; }
.anon { margin-top: 1rem; }
.fade-in { animation: fadeUp .35s ease-out both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.opts { display: grid; gap: .6rem; }
.opt { font: inherit; font-size: 1.05rem; text-align: left; padding: 1rem 1.1rem; border-radius: 12px; border: 2px solid var(--line); background: var(--surface-2); color: var(--text); cursor: pointer; transition: border-color .15s, background .15s, transform .1s; }
.opt:active { transform: scale(.98); }
.opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }

.scale-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; }
.scale-btn { font: inherit; font-size: 1.5rem; font-weight: 800; aspect-ratio: 1; border-radius: 12px; border: 2px solid var(--line); background: var(--surface-2); color: var(--text); cursor: pointer; transition: all .15s; }
.scale-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); transform: scale(1.06); }
.scale-labels { display: flex; justify-content: space-between; gap: 1rem; font-size: .8rem; color: var(--muted); margin-top: .5rem; }

.word-input { font-size: 1.2rem; padding: .9em; }
.qa-input { font-size: 1.05rem; }
.form-err { color: var(--danger); min-height: 1.2em; margin: .5rem 0 0; font-size: .9rem; }
.form-ok { color: var(--ok); margin: 0; font-weight: 600; }

.thanks { text-align: center; padding: 1rem 0; }
.thanks p { margin: .3rem 0; }
.check { width: 72px; height: 72px; margin: 0 auto .8rem; border-radius: 50%; background: var(--ok); color: #fff; font-size: 2.4rem; display: grid; place-items: center; animation: popIn .45s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes popIn { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.waiting h1 { margin-top: 1rem; }
.pulse { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); margin: .5rem auto; animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--accent-soft); } 70% { box-shadow: 0 0 0 22px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.spinner { width: 34px; height: 34px; margin: 1rem auto; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.qa-h { font-size: 1rem; margin-top: 1.4rem; }
.qa-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.qa-item { display: flex; align-items: center; gap: .6rem; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.qa-item.answered { opacity: .55; }
.qa-text { flex: 1; margin: 0; overflow-wrap: anywhere; }
.like { font: inherit; font-weight: 700; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: .35em .7em; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.like[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.like:disabled { cursor: default; }
.badge { font-size: .7rem; font-weight: 700; color: var(--ok); }

/* ---------- apresentador (projetor) ---------- */
.page-present { overflow: hidden; height: 100vh; background: var(--surface); font-size: clamp(14px, 1.2vw, 26px); }
.stage { height: 100vh; display: grid; grid-template-rows: auto 1fr; padding: 1.2em 3em 5em; }
.p-top { display: flex; justify-content: space-between; align-items: center; gap: 2em; color: var(--text-2); font-size: .95em; min-height: 3.2em; }
.p-join { display: flex; align-items: center; gap: .8em; }
.p-join strong { color: var(--text); }
.qr-mini img { display: block; width: 3.2em; height: 3.2em; image-rendering: pixelated; border-radius: 4px; }
.p-count { font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }
body[data-screen="lobby"] .p-join, body[data-screen="ended"] .p-join { visibility: hidden; }

.screen { display: flex; flex-direction: column; min-height: 0; }
.screen.enter { animation: fadeUp .5s ease-out both; }

#lobby, #ended { justify-content: center; align-items: center; text-align: center; }
.lobby-title { font-size: 2.6em; max-width: 26ch; margin-bottom: .8em; }
.lobby-grid { display: flex; align-items: center; gap: 4em; }
.qr-big { background: #fff; padding: 1em; border-radius: 18px; box-shadow: var(--shadow); }
.qr-big img { display: block; width: min(42vh, 30vw); height: auto; image-rendering: pixelated; }
.lobby-info { text-align: left; font-size: 1.4em; }
.lobby-info p { margin: .2em 0; }
.lobby-code { font-size: 3.4em; font-weight: 800; letter-spacing: .08em; color: var(--accent); margin-top: .2em !important; font-variant-numeric: tabular-nums; }

.q-title { font-size: 2.4em; margin: .6em 0 .9em; max-width: 40ch; letter-spacing: -.01em; }
.viz { flex: 1; min-height: 0; position: relative; }
.hidden-results { flex: 1; display: grid; place-content: center; text-align: center; font-size: 1.6em; }
.hidden-results p { margin: .2em 0; }
.empty { font-size: 1.3em; text-align: center; margin-top: 3em; }

/* barras (múltipla escolha) */
.bars { --row: min(11vh, calc(62vh / var(--n))); position: relative; height: calc(var(--n) * var(--row)); }
.bar-row { position: absolute; left: 0; right: 0; top: 0; height: var(--row); display: grid; grid-template-columns: minmax(8em, 30%) 1fr 7.5em; align-items: center; gap: 1.2em; transform: translateY(calc(var(--i) * var(--row))); transition: transform .8s cubic-bezier(.2,.8,.2,1); }
.bar-label { font-size: 1.35em; font-weight: 600; text-align: right; display: flex; align-items: center; justify-content: flex-end; gap: .5em; min-width: 0; }
.bar-row.lead .bar-label { font-weight: 800; }
.bar-track { height: 62%; background: var(--track); border-radius: 0 6px 6px 0; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--c); border-radius: 0 6px 6px 0; transition: width .9s cubic-bezier(.2,.8,.2,1); position: relative; }
.bar-row.lead .bar-fill::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent); transform: translateX(-100%); animation: shine 2.4s ease-in-out infinite; }
@keyframes shine { 60%, 100% { transform: translateX(100%); } }
.bar-val { display: grid; line-height: 1.1; font-variant-numeric: tabular-nums; }
.bar-pct { font-size: 1.7em; font-weight: 800; }
.bar-cnt { color: var(--muted); font-size: .9em; }

/* escala */
.scale-viz { height: 100%; display: grid; grid-template-columns: minmax(16em, 1fr) 2fr; gap: 4em; align-items: end; }
.avg-box { align-self: center; }
.avg-num { font-size: 7em; font-weight: 800; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.avg-cap { color: var(--muted); font-size: 1.2em; margin-bottom: 1.5em; }
.avg-track { position: relative; height: 10px; border-radius: 999px; background: linear-gradient(90deg, var(--track), var(--accent)); }
.avg-marker { position: absolute; top: 50%; left: 0; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; background: var(--surface); border: 5px solid var(--accent); box-shadow: var(--shadow); transition: left 1s cubic-bezier(.2,.8,.2,1); }
.avg-ends { display: flex; justify-content: space-between; gap: 1em; color: var(--muted); font-size: .95em; margin-top: .8em; }
.cols { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1.4em; height: min(48vh, 100%); }
.col { display: grid; grid-template-rows: 1fr auto; text-align: center; min-height: 0; }
.col-val { font-size: 1.6em; font-weight: 800; font-variant-numeric: tabular-nums; padding-bottom: .2em; }
.col-wrap { display: flex; flex-direction: column; justify-content: flex-end; min-height: 0; border-bottom: 2px solid var(--line); }
.col-bar { flex: none; width: 100%; height: 0; background: var(--scale-col, var(--s1)); border-radius: 6px 6px 0 0; transition: height .9s cubic-bezier(.2,.8,.2,1); }
.col-lab { font-size: 1.4em; font-weight: 700; color: var(--text-2); padding-top: .3em; }

/* nuvem de palavras */
.cloud { height: 100%; display: flex; flex-wrap: wrap; justify-content: center; align-content: center; align-items: center; gap: .15em .55em; overflow: hidden; padding: 0 2em; }
.word { font-size: 1.1rem; line-height: 1.05; letter-spacing: -.01em; transition: font-size .9s cubic-bezier(.2,.8,.2,1), font-weight .3s; white-space: nowrap; }
.word.pop { animation: popIn .6s cubic-bezier(.2,1.5,.4,1) both; }

/* perguntas do público */
.qa-board { list-style: none; margin: 0; padding: 0 0 1em; display: grid; gap: .7em; max-height: 100%; overflow-y: auto; }
.qa-card { display: grid; grid-template-columns: 4.2em 1fr auto; align-items: center; gap: 1em; padding: .8em 1.1em; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); transition: transform .6s cubic-bezier(.2,.8,.2,1), opacity .4s; }
.qa-card.pop { animation: fadeUp .5s ease-out both; }
.qa-card.answered { opacity: .45; }
.qa-likes { display: grid; justify-items: center; font-weight: 800; font-size: 1.3em; font-variant-numeric: tabular-nums; color: var(--accent); }
.qa-thumb { font-size: .8em; }
.qa-txt { margin: 0; font-size: 1.35em; overflow-wrap: anywhere; }
.qa-tools { display: flex; gap: .4em; opacity: 0; transition: opacity .2s; }
.qa-card:hover .qa-tools { opacity: 1; }
.qa-tools button { font: inherit; font-size: .8em; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); border-radius: 8px; padding: .3em .7em; cursor: pointer; }

/* controles */
.controls { position: fixed; left: 50%; bottom: 1em; transform: translateX(-50%); display: flex; align-items: center; gap: .3em; padding: .4em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); font-size: 15px; transition: opacity .4s, transform .4s; z-index: 10; }
.controls button { font: inherit; font-weight: 600; background: transparent; border: 0; color: var(--text); padding: .55em .9em; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.controls button:hover { background: var(--track); }
.controls button:disabled { opacity: .35; cursor: default; }
.controls .danger { color: var(--danger); }
.controls .pos { min-width: 4.5em; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.controls .sep { width: 1px; height: 1.4em; background: var(--line); margin: 0 .2em; }
body.idle .controls { opacity: 0; transform: translate(-50%, 1em); }
body.idle .controls:hover { opacity: 1; transform: translateX(-50%); }
body.idle { cursor: none; }
.voting-closed .q-title::after { content: "  🔒"; font-size: .6em; vertical-align: middle; }

.toast { position: fixed; top: 1em; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: .6em 1.1em; border-radius: 10px; font-weight: 600; z-index: 20; }

@media (max-width: 900px) {
  .stage { padding: 1em 1em 5em; }
  .lobby-grid { flex-direction: column; gap: 1.5em; }
  .lobby-info { text-align: center; }
  .scale-viz { grid-template-columns: 1fr; gap: 2em; }
  .bar-row { grid-template-columns: minmax(6em, 35%) 1fr 5em; gap: .6em; }
  .controls { font-size: 13px; max-width: calc(100vw - 16px); overflow-x: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.form label input, .form label select, .form label textarea { font-weight: 400; }
.form h2 { margin-top: 0; }

/* formas, resposta correta e cronômetro (v2) */
.bar-text { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bar-shape { flex: none; width: 1.6em; height: 1.6em; border-radius: .3em; background: var(--c); color: #fff; display: grid; place-items: center; }
.bar-shape .shape { width: 60%; height: 60%; }
.bar-row { transition: transform .8s cubic-bezier(.2,.8,.2,1), opacity .5s; }
.bar-row.wrong { opacity: .3; }
.bar-row.correct .bar-text::after { content: "  ✓"; color: #26890c; font-weight: 900; }
.bar-row.correct .bar-fill { box-shadow: 0 0 0 3px #26890c inset; }
.p-right { display: flex; align-items: center; gap: 1.2em; }
.p-timer { --p: 100%; width: 3.6em; height: 3.6em; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--accent) var(--p), var(--track) 0); position: relative; font-weight: 800; font-size: 1.1em; font-variant-numeric: tabular-nums; }
.p-timer::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--surface); }
.p-timer span { position: relative; }
.p-timer.urgent { background: conic-gradient(#e21b3c var(--p), var(--track) 0); color: #e21b3c; animation: tickPulse 1s ease-in-out infinite; }
@keyframes tickPulse { 50% { transform: scale(1.08); } }

/* celular: opções coloridas com formas, cronômetro e acerto (v2) */
.opt { display: flex; align-items: center; gap: .8rem; background: var(--c); border-color: var(--c); color: #fff; font-weight: 700; padding: .9rem 1rem; box-shadow: 0 3px 0 rgba(0,0,0,.18); }
.opt-shape { flex: none; width: 34px; height: 34px; border-radius: 8px; background: rgba(255,255,255,.2); display: grid; place-items: center; }
.opt-shape .shape { width: 20px; height: 20px; }
.opt-label { flex: 1; overflow-wrap: anywhere; }
.opts:has(.opt[aria-pressed="true"]) .opt:not([aria-pressed="true"]) { opacity: .4; }
.opt[aria-pressed="true"] { background: var(--c); border-color: var(--text); box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--c); transform: scale(1.02); }
.opt-static { cursor: default; margin-top: .4rem; }
.m-timer { position: relative; height: 26px; border-radius: 999px; background: var(--track); overflow: hidden; margin-bottom: 1rem; }
.m-timer-fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); transition: width .25s linear; }
.m-timer-n { position: relative; display: block; text-align: center; font-weight: 800; font-size: .85rem; line-height: 26px; color: var(--text); font-variant-numeric: tabular-nums; }
.m-timer.urgent .m-timer-fill { background: #e21b3c; }
.timeout { text-align: center; font-weight: 800; font-size: 1.1rem; color: #e21b3c; margin: 0 0 .5rem; }
.check-no { background: #e21b3c; }
.big-ok { font-size: 1.3rem; font-weight: 800; color: var(--ok); }
.big-no { font-size: 1.3rem; font-weight: 800; color: #e21b3c; }
