:root {
  --bg: #23050f;
  --bg-2: #41031c;
  --brand: #8a0d30;
  --brand-2: #570219;
  --surface: rgba(255, 255, 255, 0.07);
  --surface-2: rgba(255, 255, 255, 0.12);
  --line: rgba(255, 255, 255, 0.14);
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.72);
  --ok: #1f9d55;
  --bad: #d64040;
  --gold: #f2c14e;
  --silver: #cfd6df;
  --bronze: #d08a56;
  --opt-0: #0e7c86;
  --opt-1: #b86e0e;
  --opt-2: #6c4bd8;
  --opt-3: #2563eb;
  --radius: 16px;
  --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(1200px 700px at 80% -10%, var(--bg-2), transparent 60%), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  line-height: 1.4;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* ───────────── componentes */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: 12px; border: 0;
  background: #fff; color: var(--brand-2); font-weight: 700; font-size: 16px;
  cursor: pointer; text-decoration: none;
  transition: transform .12s ease, filter .12s ease, background .12s ease;
}
.btn:hover { filter: brightness(.95); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.danger { background: transparent; color: #ffb3b3; border: 1px solid rgba(255, 120, 120, .4); }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn.big { min-height: 60px; font-size: 20px; padding: 0 34px; }

.field { display: grid; gap: 6px; }
.field label { font-size: 14px; color: var(--muted); font-weight: 500; }
.input {
  width: 100%; min-height: 52px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(0, 0, 0, .25);
  font-size: 18px; outline: none;
}
.input:focus { border-color: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .15); }
textarea.input { padding: 12px 16px; min-height: 120px; resize: vertical; font-size: 15px; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #fff 50%), linear-gradient(135deg, #fff 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
select.input option { background: #2b0713; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.muted { color: var(--muted); }
.error { color: #ffb3b3; font-size: 15px; min-height: 1.4em; }
.center { text-align: center; }
.logo { height: 36px; width: auto; display: block; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #fff; color: var(--brand-2); padding: 12px 18px; border-radius: 12px;
  font-weight: 600; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); z-index: 50;
  animation: rise .25s ease;
}

.letter {
  display: inline-grid; place-items: center; flex: none;
  width: 1.9em; height: 1.9em; border-radius: 10px;
  background: rgba(0, 0, 0, .22); font-weight: 800;
}
.opt-0 { background: var(--opt-0); }
.opt-1 { background: var(--opt-1); }
.opt-2 { background: var(--opt-2); }
.opt-3 { background: var(--opt-3); }

.timer-bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.timer-bar > i { display: block; height: 100%; background: #fff; transform-origin: left; }

@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes pop { 0% { transform: scale(.7); opacity: 0; } 70% { transform: scale(1.05); opacity: 1; } 100% { transform: scale(1); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.pop { animation: pop .4s cubic-bezier(.2, .9, .3, 1.2) both; }
.fade-up { animation: fadeUp .45s ease both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ───────────── celular do jogador */

.phone { min-height: 100dvh; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; padding: 16px; }
.phone header { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.phone header .who { text-align: right; font-size: 14px; line-height: 1.2; }
.phone header .who b { display: block; font-size: 16px; }
.phone main { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 16px 0; }
.phone h1 { font-size: 26px; line-height: 1.2; margin: 0; }
.phone .pin-input { text-align: center; font-size: 32px; letter-spacing: .25em; font-weight: 700; min-height: 68px; }
.phone .q-meta { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.phone .q-text { font-size: 22px; font-weight: 700; line-height: 1.3; margin: 0; }
.phone .q-img { border-radius: 12px; max-height: 28vh; object-fit: contain; align-self: center; }
.answers { display: grid; gap: 12px; }
.answers.two { grid-template-columns: 1fr 1fr; }
.answer-btn {
  display: flex; align-items: center; gap: 12px; text-align: left;
  min-height: 72px; padding: 14px 16px; border-radius: 14px; border: 0;
  color: #fff; font-size: 18px; font-weight: 600; cursor: pointer;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .25);
  transition: transform .1s ease, opacity .2s ease, filter .2s ease;
}
.answers.two .answer-btn { flex-direction: column; justify-content: center; text-align: center; min-height: 140px; font-size: 22px; }
.answer-btn:active { transform: scale(.97); }
.answer-btn:disabled { cursor: default; }
.answer-btn.dim { opacity: .3; filter: grayscale(.5); }
.answer-btn.chosen { outline: 3px solid #fff; outline-offset: 2px; }
.answer-btn.right { outline: 3px solid #7cf2a6; outline-offset: 2px; }

.status-big { text-align: center; display: grid; gap: 10px; justify-items: center; }
.status-big .emoji { font-size: 64px; line-height: 1; }
.status-big h2 { font-size: 30px; margin: 0; }
.status-big .pts { font-size: 40px; font-weight: 800; }
.result-ok { background: linear-gradient(180deg, rgba(31, 157, 85, .35), transparent); border-color: rgba(31, 157, 85, .6); }
.result-bad { background: linear-gradient(180deg, rgba(214, 64, 64, .3), transparent); border-color: rgba(214, 64, 64, .55); }
.rank-pill { display: inline-flex; gap: 8px; align-items: baseline; padding: 10px 18px; border-radius: 99px; background: var(--surface-2); font-weight: 600; }
.rank-pill b { font-size: 22px; }
.waiting-dots::after { content: '…'; animation: pulse 1.2s infinite; }

/* ───────────── telão */

.stage { min-height: 100dvh; display: flex; flex-direction: column; padding: 24px 40px; gap: 20px; }
.stage-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.stage-top .controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.stage-body { flex: 1; display: flex; flex-direction: column; gap: 24px; min-height: 0; }

.lobby { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 32px; align-items: start; }
.join-box { display: grid; gap: 16px; justify-items: center; text-align: center; padding: 28px; }
.join-box .url { font-size: 18px; word-break: break-all; }
.join-box .pin-label { font-size: 16px; color: var(--muted); margin-bottom: -10px; }
.join-box .pin { font-size: 72px; font-weight: 800; letter-spacing: .08em; line-height: 1; }
.qr { background: #fff; padding: 12px; border-radius: 12px; width: 212px; height: 212px; }
.qr img, .qr canvas { width: 188px !important; height: 188px !important; }
.players-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.players-head h2 { margin: 0; font-size: 28px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 99px;
  background: var(--surface-2); font-weight: 600; font-size: 18px; border: 0; cursor: pointer;
  animation: pop .35s ease both;
}
.chip small { color: var(--muted); font-weight: 400; font-size: 13px; }
.chip:hover { background: rgba(214, 64, 64, .35); }
.chip:hover::after { content: '✕'; font-size: 13px; }

.q-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; font-size: 18px; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; background: var(--gold); color: #3b2500; font-weight: 700; font-size: 15px; }
.badge.soft { background: var(--surface-2); color: var(--text); }
.q-title { font-size: clamp(28px, 3.4vw, 52px); line-height: 1.2; margin: 0; font-weight: 700; text-align: center; text-wrap: balance; }
.q-middle { flex: 1; display: grid; grid-template-columns: 140px 1fr 140px; align-items: center; gap: 24px; min-height: 0; }
.q-middle .q-image { justify-self: center; max-height: 38vh; border-radius: 16px; object-fit: contain; }
.q-middle .spacer { min-height: 120px; }
.countdown {
  width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center;
  font-size: 46px; font-weight: 800; background: var(--brand); box-shadow: 0 0 0 6px rgba(255, 255, 255, .12);
}
.countdown.low { background: var(--bad); animation: pulse .8s infinite; }
.answered { text-align: center; }
.answered b { display: block; font-size: 46px; line-height: 1; }
.answered span { color: var(--muted); }
.stage-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stage-answer {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 16px; min-height: 88px; padding: 16px 22px;
  border-radius: 16px; font-size: clamp(20px, 2vw, 30px); font-weight: 600;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .25); transition: opacity .3s ease, filter .3s ease;
}
.stage-answer .count { margin-left: auto; font-weight: 800; font-size: 1.1em; }
.stage-answer.dim { opacity: .28; filter: grayscale(.6); }
.stage-answer.right::before { content: '✓'; position: absolute; right: 18px; top: 8px; font-size: 18px; opacity: .9; }
.stage-answer .fill { position: absolute; inset: 0 auto 0 0; background: rgba(255, 255, 255, .14); transition: width .8s ease; }
.preview-wrap { flex: 1; display: grid; place-items: center; gap: 24px; align-content: center; }
.preview-wrap .timer-bar { width: min(600px, 80%); }

.board { display: grid; gap: 12px; max-width: 900px; width: 100%; margin: 0 auto; }
.board h2 { text-align: center; font-size: 38px; margin: 0 0 8px; }
.row {
  display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 16px;
  padding: 14px 22px; border-radius: 14px; background: var(--surface-2); font-size: 24px; font-weight: 600;
  animation: fadeUp .4s ease both;
}
.row .pos { font-weight: 800; color: var(--muted); }
.row .score { font-weight: 800; }
.row .streak { font-size: 14px; color: var(--gold); margin-left: 10px; font-weight: 600; }
.row:nth-child(2) { background: rgba(242, 193, 78, .22); }

.podium { flex: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 260px)); justify-content: center; align-items: end; gap: 18px; }
.step { display: grid; gap: 12px; justify-items: center; text-align: center; animation: fadeUp .6s ease both; }
.step .name { font-size: 26px; font-weight: 700; line-height: 1.2; }
.step .pts { color: var(--muted); font-size: 18px; }
.step .block { width: 100%; border-radius: 16px 16px 0 0; display: grid; place-items: center; font-size: 56px; font-weight: 800; color: rgba(0, 0, 0, .55); }
.step.p1 .block { height: 300px; background: linear-gradient(180deg, #ffd978, var(--gold)); }
.step.p2 .block { height: 220px; background: linear-gradient(180deg, #eef2f6, var(--silver)); }
.step.p3 .block { height: 160px; background: linear-gradient(180deg, #ecb084, var(--bronze)); }
.step.p1 { animation-delay: 2.4s; }
.step.p2 { animation-delay: 1.2s; }
.step.p3 { animation-delay: 0s; }
.final-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(420px, 100%); display: grid; gap: 16px; }

@media (max-width: 900px) {
  .stage { padding: 16px; }
  .lobby { grid-template-columns: 1fr; }
  .q-middle { grid-template-columns: 1fr; justify-items: center; }
  .q-middle .spacer { display: none; }
  .stage-answers { grid-template-columns: 1fr; }
  .podium { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .step .name { font-size: 16px; }
  .step.p1 .block { height: 200px; } .step.p2 .block { height: 150px; } .step.p3 .block { height: 110px; }
}

/* ───────────── admin */

.admin { max-width: 1040px; margin: 0 auto; padding: 20px 16px 80px; display: grid; gap: 20px; }
.admin-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.admin h1 { font-size: 26px; margin: 0; }
.admin h2 { font-size: 20px; margin: 0 0 12px; }
.list { display: grid; gap: 10px; }
.list-item { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
.list-item .info b { display: block; font-size: 17px; }
.list-item .info span { color: var(--muted); font-size: 14px; }
.list-item .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.q-card { display: grid; gap: 14px; }
.q-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.q-card-head .num { font-weight: 800; font-size: 18px; }
.q-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.opt-edit { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }
.opt-edit .letter { color: #fff; }
.opt-edit input[type='radio'] { width: 22px; height: 22px; accent-color: var(--ok); }
.correct-hint { font-size: 13px; color: var(--muted); }
.img-preview { display: flex; align-items: center; gap: 12px; }
.img-preview img { height: 64px; border-radius: 8px; }
.sticky-save {
  position: sticky; bottom: 0; z-index: 5; display: flex; gap: 12px; align-items: center; justify-content: flex-end;
  padding: 12px 0; background: linear-gradient(180deg, transparent, var(--bg) 35%);
}
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: #fff; }
table.simple { width: 100%; border-collapse: collapse; font-size: 14px; }
table.simple th, table.simple td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }

@media (max-width: 700px) {
  .q-row { grid-template-columns: 1fr; }
}
