:root {
  --bg: #0b0f14;
  --card: #141a22;
  --line: #222b36;
  --text: #e8eef5;
  --muted: #8b98a8;
  --primary: #22c55e;
  --primary-ink: #04120a;
  --secondary: #1f2937;
  --danger: #ef4444;
  --gold: #fbbf24;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
[hidden] { display: none !important; }

#app { max-width: 520px; margin: 0 auto; }
.view {
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}

h1, h2 { margin: 0; }
h2 { font-size: 1.1rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.error { color: #fca5a5; margin: 0; }
.warning { margin: -4px 0 0; padding: 10px 12px; border-radius: 12px; background: rgba(251, 191, 36, .12); color: #fde68a; font-size: .9rem; text-align: center; }
.row { display: flex; gap: 8px; align-items: center; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

.brand { text-align: center; padding: 8px 0; }
.logo { font-size: 56px; }
.logo-sm { font-size: 28px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; color: var(--muted); }
input, select {
  font: inherit; color: var(--text); background: #0e141b; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; font-size: 1.05rem;
}
input:focus { outline: 2px solid var(--primary); border-color: transparent; }
label.row input { padding: 8px 10px; font-size: .95rem; }

.btn {
  font: inherit; font-weight: 600; border: 0; border-radius: 12px; padding: 12px 18px;
  background: var(--secondary); color: var(--text); cursor: pointer; text-align: center;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.ig { background: linear-gradient(45deg, #f58529, #dd2a7b 50%, #8134af); color: #fff; }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.btn.wide { width: 100%; margin-top: 12px; }
.big-btn { padding: 18px 10px; font-size: 1.05rem; flex: 1; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.stats { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 8px; text-align: center; }
.stats.three { grid-template-columns: repeat(3, 1fr); width: 100%; }
.stats > div { display: flex; flex-direction: column; justify-content: flex-end; }
.big { font-size: 2rem; font-weight: 800; color: var(--primary); }
.mid { font-size: 1.3rem; font-weight: 700; }
.huge { font-size: 5rem; font-weight: 900; color: var(--primary); line-height: 1; }

.actions { display: flex; gap: 10px; }

.ranking-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.day-nav { display: flex; align-items: center; gap: 6px; font-size: .9rem; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 8px; }
.tab {
  font: inherit; font-size: .85rem; border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 6px 12px; white-space: nowrap; cursor: pointer;
}
.tab.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.ranking { list-style: none; margin: 0; padding: 0; }
.ranking li { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.ranking li:last-child { border-bottom: 0; }
.ranking .pos { width: 28px; text-align: center; font-weight: 800; color: var(--muted); }
.ranking .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking .who small { color: var(--muted); margin-left: 4px; }
.ranking .val { font-weight: 800; font-variant-numeric: tabular-nums; }
.ranking li.me { background: rgba(34, 197, 94, .08); border-radius: 10px; }
.ranking .empty { color: var(--muted); justify-content: center; }

/* vídeo enviado */
.stage { position: relative; background: #000; overflow: hidden; }
.small-stage { width: 100%; aspect-ratio: 3 / 4; max-height: 55dvh; border-radius: var(--radius); }
.stage video, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }

/* câmera ao vivo: ocupa a tela toda, fixa (não rola nem pula) */
.live { position: fixed; inset: 0; z-index: 5; background: #000; overflow: hidden; touch-action: none; }
.live > video, .live > canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.live .mirror { transform: scaleX(-1); }

.hud {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 10px max(12px, env(safe-area-inset-bottom));
  pointer-events: none;
}
.hud button, .hud select { pointer-events: auto; }
.hud-top { display: flex; gap: 8px; align-items: center; }
.pill {
  background: rgba(0, 0, 0, .6); color: var(--text); border: 0; padding: 8px 14px; border-radius: 999px;
  font: inherit; font-size: .95rem; font-variant-numeric: tabular-nums;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.pill.grow { flex: 1; text-align: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.btn-round { width: 42px; height: 42px; padding: 0; display: grid; place-items: center; cursor: pointer; flex: none; }

.hud-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.hud-stats div {
  background: rgba(0, 0, 0, .6); border-radius: 14px; padding: 8px 4px; text-align: center;
  display: flex; flex-direction: column; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.hud-stats strong { font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hud-stats span { color: #cbd5e1; font-size: .75rem; }

.hud-center { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-shadow: 0 2px 16px rgba(0, 0, 0, .9); }
.count { font-size: min(30vw, 22vh, 10rem); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.count.bump { animation: bump .15s ease-out; }
@keyframes bump { from { transform: scale(1.12); color: var(--primary); } to { transform: scale(1); } }
.count-label { font-size: 1.1rem; font-weight: 700; opacity: .85; }
.countdown { font-size: min(36vw, 26vh, 12rem); font-weight: 900; color: var(--gold); line-height: 1; }

.hud-bottom { display: flex; flex-direction: column; gap: 8px; }
.hud-controls { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.hud-controls select { max-width: 100%; font-size: .85rem; padding: 8px 12px; }
.seg { display: flex; align-items: center; gap: 2px; background: rgba(0, 0, 0, .6); border-radius: 999px; padding: 3px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.seg span { font-size: .75rem; color: #cbd5e1; padding: 0 6px 0 10px; }
.seg button { font: inherit; font-size: .85rem; border: 0; background: transparent; color: var(--text); padding: 6px 10px; border-radius: 999px; cursor: pointer; }
.seg button.active { background: var(--primary); color: var(--primary-ink); font-weight: 700; }
.hint { margin: 0; text-align: center; font-size: .82rem; color: #e2e8f0; background: rgba(0, 0, 0, .55); padding: 6px 10px; border-radius: 10px; }
.diag { align-self: center; font: 600 .72rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; color: #e2e8f0; background: rgba(0, 0, 0, .55); padding: 4px 10px; border-radius: 8px; }
.test-btn { font-size: .85rem; cursor: pointer; }
.test-btn[aria-pressed="true"] { background: #b91c1c; color: #fff; }
.rec-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #ef4444; margin-right: 6px; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.debug-link { display: block; text-align: center; color: var(--muted); font-size: .85rem; text-decoration: underline; cursor: pointer; margin-top: -6px; }
.huge-btn { padding: 16px; font-size: 1.2rem; border-radius: 16px; }

/* celular deitado: tudo mais compacto para caber */
@media (orientation: landscape) and (max-height: 560px) {
  .hud { gap: 4px; }
  .hud-stats { grid-template-columns: repeat(3, minmax(0, 140px)); justify-content: center; }
  .hud-stats strong { font-size: 1.2rem; }
  .hint, #live-guest { display: none !important; }
  .hud-bottom { flex-direction: row; align-items: center; justify-content: center; }
  .huge-btn { padding: 10px 28px; font-size: 1rem; }
}

.progress { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--primary); transition: width .2s; }

/* admin */
.audit { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: start; }
.audit video { width: 120px; border-radius: 10px; background: #000; }
.audit .noclip { width: 120px; aspect-ratio: 3/4; border-radius: 10px; background: #000; display: grid; place-items: center; color: var(--muted); font-size: .8rem; text-align: center; }
.audit .meta { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; min-width: 0; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #111827; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; z-index: 10; max-width: 90vw; }

/* na câmera, o aviso aparece em cima para não tampar os botões */
body.no-scroll .toast { top: calc(130px + env(safe-area-inset-top)); bottom: auto; text-align: center; }

/* estatísticas "nerds" ao vivo */
.nerd { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.nerd span {
  background: rgba(0, 0, 0, .6); border-radius: 999px; padding: 4px 10px; font-size: .8rem; color: #cbd5e1;
  font-variant-numeric: tabular-nums; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.nerd b { color: var(--text); font-size: .95rem; }
.spark { width: 100%; height: 44px; border-radius: 10px; background: rgba(0, 0, 0, .45); }
.diag { font-size: .65rem; opacity: .8; }

/* mão aberta para começar */
.palm {
  pointer-events: none; text-align: center; background: rgba(0, 0, 0, .65); border-radius: 20px;
  padding: 14px 20px; font-size: 1.1rem; max-width: 90%; text-shadow: none;
}
.palm-icon { font-size: 3rem; line-height: 1.1; animation: wave 1.6s ease-in-out infinite; transform-origin: 70% 90%; }
@keyframes wave { 0%, 60%, 100% { transform: rotate(0); } 20% { transform: rotate(14deg); } 40% { transform: rotate(-8deg); } }
.palm-bar { height: 6px; background: rgba(255, 255, 255, .2); border-radius: 999px; margin-top: 10px; overflow: hidden; }
.palm-bar div { height: 100%; width: 0; background: var(--primary); transition: width .1s linear; }

/* resultado */
.nerd-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; width: 100%; }
.nerd-grid div { background: #0e141b; border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; }
.nerd-grid strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.nerd-grid span { font-size: .75rem; color: var(--muted); }
.chart-wrap { width: 100%; }
.chart-wrap canvas { width: 100%; height: auto; background: #0e141b; border: 1px solid var(--line); border-radius: 12px; margin-top: 6px; }
.left { text-align: left; }

@media (orientation: landscape) and (max-height: 560px) {
  .spark, .diag { display: none; }
  .palm { padding: 8px 14px; font-size: .95rem; }
  .palm-icon { font-size: 2rem; }
}
