/* ═══════════════════════ Ambiente do participante (smartphone) ═══════════════════════ */
body.play { min-height: 100dvh; overflow-x: hidden; }
.stage {
  min-height: 100dvh; display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 20px);
  max-width: 560px; margin: 0 auto;
}
body.has-topbar .stage { padding-top: calc(env(safe-area-inset-top) + 76px); }
.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 18px; }

.loader { width: 46px; height: 46px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .12); border-top-color: var(--pink); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Barra superior */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px; background: rgba(3, 23, 15, .72);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--border);
}
.topbar .me { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.topbar .me .who { min-width: 0; }
.topbar .me strong { display: block; font-family: var(--font-display); font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .me small { display: block; color: var(--muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-pill { display: flex; align-items: baseline; gap: 4px; padding: .4em .85em; border-radius: 999px; background: var(--grad); font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; box-shadow: 0 8px 22px -10px rgba(0, 179, 107, .9); }
.score-pill small { font-size: .7rem; opacity: .85; font-weight: 600; }
.topbar .sound-toggle { position: static; }

/* Marca */
.brand { display: flex; align-items: center; gap: 10px; justify-content: center; }
.brand-mark { width: 44px; height: 44px; }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; letter-spacing: -.02em; }

/* Formulários */
.join-card { width: 100%; padding: 26px 22px; display: flex; flex-direction: column; gap: 16px; text-align: left; }
.join-card h1 { font-size: 1.6rem; line-height: 1.15; }
.join-card .quiz-title { font-size: .95rem; color: var(--muted); }
.steps { display: flex; gap: 6px; }
.steps i { flex: 1; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .12); }
.steps i.on { background: var(--grad); }
.code-input { text-align: center; font-family: var(--font-display); font-size: 2rem; font-weight: 800; letter-spacing: .35em; padding-left: .35em; }
.err-msg { color: #fda4af; font-size: .9rem; min-height: 1.2em; margin: -6px 0 0; }

/* Seletor de avatar */
.av-preview { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 16px; background: var(--grad-soft); border: 1px solid var(--border); }
.av-preview .avatar { transition: transform .35s var(--ease-spring); }
.av-preview .avatar.bump { transform: scale(1.15) rotate(-6deg); }
.av-preview strong { font-family: var(--font-display); font-size: 1.15rem; display: block; }
.av-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.av-grid button {
  aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-size: 1.35rem;
  cursor: pointer; display: grid; place-items: center; transition: transform .15s, background .2s, border-color .2s; padding: 0;
}
.av-grid button[aria-pressed="true"] { background: rgba(0, 153, 93, .35); border-color: var(--primary-2); transform: scale(1.08); }
.color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-row button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; background: var(--c); cursor: pointer; transition: transform .15s; box-shadow: 0 0 0 1px rgba(255, 255, 255, .2); }
.color-row button[aria-pressed="true"] { border-color: #fff; transform: scale(1.12); }
.section-label { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* Lobby */
.lobby-avatar { position: relative; }
.lobby-avatar::before { content: ''; position: absolute; inset: -18px; border-radius: 50%; border: 2px dashed rgba(63, 196, 138, .45); animation: spin 14s linear infinite; }
.lobby-avatar .avatar { animation: floaty 3.2s ease-in-out infinite; }
@keyframes floaty { 50% { transform: translateY(-8px); } }
.lobby h2 { font-size: 1.7rem; }
.dots span { display: inline-block; width: 8px; height: 8px; margin: 0 3px; border-radius: 50%; background: var(--primary-2); animation: bounce 1.2s infinite; }
.dots span:nth-child(2) { animation-delay: .15s; } .dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-8px); opacity: 1; } }
.stat-chip { display: inline-flex; align-items: center; gap: 8px; padding: .55em 1em; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-weight: 600; }

/* Contagem */
.q-counter { font-family: var(--font-display); font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; font-size: .85rem; }
.q-text { font-family: var(--font-display); font-size: clamp(1.3rem, 5.5vw, 1.75rem); font-weight: 700; line-height: 1.22; text-align: center; }
.big-count { font-family: var(--font-display); font-size: 7rem; font-weight: 900; line-height: 1; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.big-count.tick { animation: countTick .9s var(--ease-out); }
@keyframes countTick { from { transform: scale(1.6); opacity: 0; } 30% { opacity: 1; } }
.double-badge { display: inline-flex; gap: 6px; align-items: center; padding: .4em .9em; border-radius: 999px; background: linear-gradient(90deg, #f59e0b, #ef4444); color: #fff; font-weight: 800; font-size: .85rem; letter-spacing: .04em; box-shadow: 0 8px 24px -8px rgba(245, 158, 11, .8); }

/* Pergunta */
.q-head { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.timebar { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.timebar i { display: block; height: 100%; width: 100%; background: var(--grad); border-radius: inherit; transform-origin: left; }
.timebar.urgent i { background: linear-gradient(90deg, #f43f5e, #f59e0b); }
.q-meta { display: flex; justify-content: space-between; align-items: center; }
.q-meta .secs { font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; }
.q-meta .secs.urgent { color: #fb7185; animation: pulse 1s infinite; }
.q-head .q-text { text-align: left; font-size: clamp(1.15rem, 5vw, 1.5rem); }

.answers { display: grid; gap: 10px; flex: 1; align-content: start; }
.answers.grid2 { grid-template-columns: 1fr 1fr; }
.ans {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 74px; padding: 14px 16px; text-align: left;
  border: 0; border-radius: 18px; cursor: pointer; color: var(--opt-ink, #fff); font-weight: 700; font-size: 1.04rem; line-height: 1.25;
  background: linear-gradient(160deg, color-mix(in srgb, var(--opt) 92%, white 8%), color-mix(in srgb, var(--opt) 78%, black 22%));
  box-shadow: 0 6px 0 color-mix(in srgb, var(--opt) 55%, black 45%), 0 16px 30px -14px var(--opt);
  transition: transform .12s var(--ease-out), box-shadow .12s, opacity .3s, filter .3s;
  animation: fadeUp .45s var(--ease-out) both;
}
.answers.grid2 .ans { flex-direction: column; align-items: flex-start; justify-content: space-between; min-height: 132px; }
.ans:active { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--opt) 55%, black 45%); }
.ans .tag { display: flex; align-items: center; gap: 6px; font-family: var(--font-display); font-size: 1.05rem; font-weight: 900; }
.ans .tag .shape { width: 22px; height: 22px; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25)); }
.ans .txt { flex: 1; overflow-wrap: anywhere; }
.answers.locked .ans { cursor: default; }
.answers.locked .ans:not(.chosen) { opacity: .28; filter: saturate(.4); }
.ans.chosen { outline: 3px solid #fff; outline-offset: 3px; animation: chosen .45s var(--ease-spring); }
.ans.is-correct { opacity: 1 !important; filter: none !important; outline: 3px solid #4ade80; outline-offset: 3px; }
.ans .mark { position: absolute; top: -10px; right: -10px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #fff; color: #111; box-shadow: 0 6px 16px rgba(0, 0, 0, .35); animation: popIn .4s var(--ease-spring); }
.ans .mark svg { width: 20px; height: 20px; }
@keyframes chosen { 50% { transform: scale(1.04); } }

.sent-box { margin-top: 16px; padding: 14px 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); display: flex; align-items: center; gap: 12px; animation: fadeUp .4s var(--ease-out); }
.sent-box .check { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--grad); flex: none; }
.sent-box .check svg { width: 22px; height: 22px; }
.sent-box strong { display: block; font-family: var(--font-display); }

.paused-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(1, 14, 10, .82); backdrop-filter: blur(6px); display: grid; place-items: center; text-align: center; animation: fadeUp .3s; }
.paused-overlay .icon { font-size: 3rem; }

/* Resultado */
.result { width: 100%; padding: 28px 22px; display: flex; flex-direction: column; align-items: center; gap: 12px; position: relative; overflow: hidden; }
.result .burst { width: 104px; height: 104px; border-radius: 50%; display: grid; place-items: center; animation: popIn .6s var(--ease-spring); }
.result .burst svg { width: 56px; height: 56px; }
.result.ok .burst { background: radial-gradient(circle at 30% 30%, #86efac, #16a34a); box-shadow: 0 0 0 12px rgba(34, 197, 94, .15), 0 0 60px rgba(34, 197, 94, .55); }
.result.bad .burst { background: radial-gradient(circle at 30% 30%, #fda4af, #e11d48); box-shadow: 0 0 0 12px rgba(244, 63, 94, .15), 0 0 60px rgba(244, 63, 94, .5); animation: popIn .5s var(--ease-spring), shake .5s .5s; }
.result.miss .burst { background: radial-gradient(circle at 30% 30%, #fde68a, #d97706); box-shadow: 0 0 0 12px rgba(245, 158, 11, .15); }
.result h2 { font-size: 2rem; }
.result .pts { font-family: var(--font-display); font-size: 2.6rem; font-weight: 900; }
.result .pts.plus { background: linear-gradient(90deg, #4ade80, #b1d34b); -webkit-background-clip: text; background-clip: text; color: transparent; }
.breakdown { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.breakdown span { padding: .35em .8em; border-radius: 999px; background: var(--surface-2); font-size: .85rem; font-weight: 600; }
.correct-ans { width: 100%; padding: 12px 14px; border-radius: 14px; background: rgba(34, 197, 94, .12); border: 1px solid rgba(34, 197, 94, .4); display: flex; gap: 10px; align-items: center; text-align: left; }
.correct-ans .shape { width: 22px; height: 22px; color: var(--opt); }

.rank-card { width: 100%; padding: 18px; display: flex; align-items: center; gap: 14px; border-radius: 18px; background: var(--grad-soft); border: 1px solid var(--border-strong); }
.rank-card .pos { font-family: var(--font-display); font-size: 2.6rem; font-weight: 900; line-height: 1; min-width: 70px; text-align: center; }
.rank-card .pos sup { font-size: 1rem; }
.rank-card .info { flex: 1; }
.rank-card .info strong { font-family: var(--font-display); font-size: 1.1rem; }

.mv { display: inline-flex; align-items: center; gap: 2px; font-weight: 800; font-size: .85rem; padding: .2em .55em; border-radius: 999px; }
.mv svg { width: 14px; height: 14px; }
.mv.up { color: #4ade80; background: rgba(34, 197, 94, .14); }
.mv.down { color: #fb7185; background: rgba(244, 63, 94, .14); }
.mv.same { color: var(--muted); background: var(--surface-2); }
.mv.new { color: #a7e9c8; background: rgba(0, 153, 93, .16); font-size: .72rem; text-transform: uppercase; }

.mini-board { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.mini-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); animation: fadeUp .4s var(--ease-out) both; }
.mini-row.me { background: rgba(0, 153, 93, .22); border-color: var(--primary-2); }
.mini-row .n { width: 30px; font-family: var(--font-display); font-weight: 800; text-align: center; }
.mini-row .nm { flex: 1; min-width: 0; }
.mini-row .nm strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .95rem; }
.mini-row .nm small { color: var(--muted); font-size: .76rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-row .sc { font-family: var(--font-display); font-weight: 800; }
.medal-1 { color: var(--gold); } .medal-2 { color: var(--silver); } .medal-3 { color: var(--bronze); }
.gap { color: var(--faint); text-align: center; letter-spacing: .3em; }

/* Final */
.final-hero { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.final-hero .trophy { font-size: 4.5rem; animation: popIn .7s var(--ease-spring), floaty 3s 1s ease-in-out infinite; }
.final-hero .place { font-family: var(--font-display); font-size: 4rem; font-weight: 900; line-height: 1; }
.stats3 { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats3 > div { padding: 12px 8px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); text-align: center; }
.stats3 b { display: block; font-family: var(--font-display); font-size: 1.35rem; }
.stats3 small { color: var(--muted); font-size: .75rem; }

.footer-note { color: var(--faint); font-size: .78rem; text-align: center; margin-top: 18px; }

@media (min-width: 520px) {
  .ans { font-size: 1.12rem; }
}

/* Re-renderização da mesma pergunta (ex.: após responder) não repete animações de entrada */
.stage.static .ans, .stage.static .fade-up, .stage.static .pop-in { animation: none; }
.stage.static .ans.chosen { animation: chosen .45s var(--ease-spring); }

.mini-row, .rank-card { text-align: left; }
.correct-ans .shape { color: #bbf7d0; }
