:root {
  --bg: #0d1117;
  --bg-elev: #161b23;
  --text: #f1f3f6;
  --text-dim: #9aa5b1;
  --border: #262d3a;
  --accent: #8b5cf6;
  --c13: #8b5cf6; /* Lula, nº13 — roxo */
  --c22: #f59e0b; /* Flávio Bolsonaro, nº22 — âmbar */
  --live-badge: #8b5cf6; /* "AO VIVO" nunca vermelho */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --shadow-soft: 0 2px 10px rgba(0,0,0,0.35);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f6f8;
    --bg-elev: #ffffff;
    --text: #12161c;
    --text-dim: #5b6572;
    --border: #e1e4e9;
    --shadow-soft: 0 2px 10px rgba(0,0,0,0.08);
  }
}

:root[data-theme="light"] {
  --bg: #f5f6f8;
  --bg-elev: #ffffff;
  --text: #12161c;
  --text-dim: #5b6572;
  --border: #e1e4e9;
  --shadow-soft: 0 2px 10px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100dvh;
  padding-bottom: calc(64px + var(--safe-bottom));
}

a { color: var(--accent); text-decoration: none; }

.panel {
  box-shadow: var(--shadow-soft);
}

.sponsor-bar {
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  padding-top: calc(4px + var(--safe-top));
  min-height: 22px;
}

header.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  padding: 8px 14px 10px;
}

.wordmark-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.wordmark {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.3px;
}
.wordmark-sub {
  font-size: 10px;
  color: var(--text-dim);
  margin: 0 0 6px;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.countdown {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(139,92,246,0.15);
  color: var(--live-badge);
}

.countdown.live {
  background: rgba(139,92,246,0.18);
  color: var(--live-badge);
  animation: pulse 2s infinite;
}
.countdown.live::before {
  content: "●";
  margin-right: 5px;
  display: inline-block;
}

@media (prefers-reduced-motion: reduce) {
  .countdown.live { animation: none; }
}

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }

.watching {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 5px;
}
.watching .dot { width: 8px; height: 8px; border-radius: 50%; background: #2ecc71; }
.watching #watchingCount { font-size: 15px; }

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 10px;
  justify-content: center;
}
.legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 4px;
}

.regiao-row {
  margin-bottom: 10px;
}
.regiao-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 4px;
  text-align: center;
}
.regiao-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.uf-chip {
  min-width: 44px;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 10px;
  border: none;
  background: #4b5563;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.whatsapp-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  min-height: 44px;
  border-radius: 10px;
  border: none;
  background: #25d366;
  color: #0b0e13;
  font-weight: 700;
  cursor: pointer;
}

.feed-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.feed-item .feed-value { font-weight: 700; }

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

.candidate-card {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.candidate-card .avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid currentColor;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
  object-fit: cover;
}
.candidate-card.n13 .avatar { background: var(--c13); border-color: var(--c13); }
.candidate-card.n22 .avatar { background: var(--c22); border-color: var(--c22); }

.candidate-card .name { font-weight: 700; font-size: 12px; text-align: center; }
.candidate-card .meta { font-size: 10px; color: var(--text-dim); text-align: center; }
.candidate-card .pct { font-size: 30px; font-weight: 800; line-height: 1.05; }
.candidate-card.n13 .pct { color: var(--c13); }
.candidate-card.n22 .pct { color: var(--c22); }

.compare-bar {
  margin-top: 8px;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  gap: 2px;
  background: var(--border);
}
.compare-bar .seg1 { background: var(--c13); }
.compare-bar .seg2 { background: var(--c22); }

.diferenca-line {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

@media (max-width: 380px) {
  .candidate-card .avatar { width: 38px; height: 38px; font-size: 13px; }
  .candidate-card { padding: 6px; gap: 2px; }
  .candidate-card .name { font-size: 11px; }
  .candidate-card .pct { font-size: 24px; }
  .scoreboard { gap: 6px; }
  .countdown { font-size: 11px; padding: 3px 8px; }
  .watching { font-size: 11px; }
  header.app-header { padding: 6px 10px 8px; }
  .wordmark { font-size: 16px; }
}

.apuracao-info {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}
.apuracao-sub {
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
}

main {
  padding: 14px;
  max-width: 1200px;
  margin: 0 auto;
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}

.panel h2 { margin: 0 0 10px; font-size: 16px; }

.map-placeholder, .chat-placeholder {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 14px;
  text-align: center;
  padding: 20px;
}

nav.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  z-index: 30;
}

nav.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 56px;
  min-width: 44px;
  color: var(--text-dim);
  font-size: 11px;
}
nav.bottom-nav a.active { color: var(--accent); }
nav.bottom-nav .icon { font-size: 20px; }

@media (min-width: 1024px) {
  nav.bottom-nav { display: none; }
  body { padding-bottom: 0; }
  .desktop-columns {
    display: grid;
    grid-template-columns: 1.4fr 0.9fr;
    gap: 16px;
    align-items: start;
  }
}

footer.app-footer {
  padding: 24px 16px calc(24px + var(--safe-bottom));
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
}
footer.app-footer a { margin: 0 6px; }

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  min-height: 44px;
  min-width: 44px;
  cursor: pointer;
}

.legal-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 60px;
  line-height: 1.6;
  font-size: 14px;
}
.legal-page h1 { font-size: 22px; }
.legal-page h2 { font-size: 16px; margin-top: 24px; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--bg-elev);
  border-radius: 14px;
  padding: 20px;
  max-width: 420px;
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
}

.chat-msg { font-size: 13px; padding: 4px 8px; border-radius: 8px; background: var(--bg); }
.chat-msg .nick { font-weight: 700; margin-right: 4px; }
.chat-msg.highlight { background: rgba(59,130,246,0.15); }

.pix-qr { width: 200px; max-width: 100%; margin-top: 8px; }
@media (min-width: 1024px) {
  .pix-qr { width: 260px; }
}

#superchatButtons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 1024px) {
  #superchatButtons { grid-template-columns: repeat(3, 1fr); }
}

.superchat-card {
  border: none;
  border-radius: 14px;
  padding: 12px;
  color: #fff;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 110px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.superchat-card-price { font-size: 22px; font-weight: 800; }
.superchat-card-label { font-size: 12px; font-weight: 700; opacity: 0.95; }
.superchat-card-ganha { font-size: 11px; opacity: 0.9; line-height: 1.3; flex: 1; }
.superchat-card-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.superchat-badge {
  font-size: 9px;
  font-weight: 800;
  background: rgba(255,255,255,0.25);
  padding: 2px 6px;
  border-radius: 999px;
  letter-spacing: 0.3px;
}

.superchat-card-animated {
  background-size: 200% 200%;
  animation: megaGradient 4s ease infinite;
}
@media (prefers-reduced-motion: reduce) {
  .superchat-card-animated { animation: none; }
}
@keyframes megaGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.superchat-fab {
  display: none;
  position: fixed;
  right: 14px;
  bottom: calc(72px + var(--safe-bottom));
  z-index: 40;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  min-height: 44px;
}
@media (max-width: 1023px) {
  .superchat-fab { display: block; }
}

.patente-lenda {
  display: inline-block;
  animation: lendaGlow 1.5s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .patente-lenda { animation: none; }
}
@keyframes lendaGlow {
  0%, 100% { filter: drop-shadow(0 0 1px gold); }
  50% { filter: drop-shadow(0 0 6px gold); }
}

.chat-msg.payment-highlight {
  color: #fff;
  font-weight: 600;
  animation: paymentSlideIn 0.4s ease-out;
}
@media (prefers-reduced-motion: reduce) {
  .chat-msg.payment-highlight { animation: none; }
}
@keyframes paymentSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
