:root {
  --bg: #F3EFE4;
  --surface: #FFFDF7;
  --surface-2: #ECE6D6;
  --text: #1B2A22;
  --muted: #5E6B62;
  --border: #DDD5C2;
  --primario: #1F8A4C;
  --primario-hover: #197340;
  --primario-ink: #FFFFFF;
  --amarelo: #F2C230;
  --azul: #2A5DB0;
  --erro: #D2443A;
  --gol: #1F8A4C;
  --barra-fundo: #E6DFCD;
  --mapa-fundo: #CFE3E4;
  --gol-suave: #BFE3C9;
  --erro-suave: #F4C9C3;
  --mapa-terra: #FBF6E6;
  --mapa-borda: #B9AE8C;
  --sombra: 0 1px 0 rgba(27, 42, 34, .06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1E19;
    --surface: #162B24;
    --surface-2: #1E372F;
    --text: #EEF3EE;
    --muted: #9DB0A5;
    --border: #28443B;
    --primario: #2FB464;
    --primario-hover: #3CC873;
    --primario-ink: #0B1A13;
    --amarelo: #FFD23F;
    --azul: #6A9BF4;
    --erro: #FF6B5E;
    --gol: #2FB464;
    --barra-fundo: #213C33;
    --mapa-fundo: #0B1814;
    --gol-suave: #2A6B47;
    --erro-suave: #6E3430;
    --mapa-terra: #1F3B32;
    --mapa-borda: #3C6456;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1E19;
  --surface: #162B24;
  --surface-2: #1E372F;
  --text: #EEF3EE;
  --muted: #9DB0A5;
  --border: #28443B;
  --primario: #2FB464;
  --primario-hover: #3CC873;
  --primario-ink: #0B1A13;
  --amarelo: #FFD23F;
  --azul: #6A9BF4;
  --erro: #FF6B5E;
  --gol: #2FB464;
  --barra-fundo: #213C33;
  --mapa-fundo: #0B1814;
  --gol-suave: #2A6B47;
  --erro-suave: #6E3430;
  --mapa-terra: #1F3B32;
  --mapa-borda: #3C6456;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { background: var(--surface); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Space Grotesk", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* Topo */
.topo {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 12px calc(16px + env(safe-area-inset-left));
  position: sticky; top: 0; z-index: 900;
  border-bottom: 2px solid var(--border);
  background: var(--surface);
  flex: none;
}
.logo {
  background: none; border: 0; padding: 0;
  font-size: 22px; font-weight: 700; letter-spacing: -.02em;
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.logo-bola { font-size: 20px; }
.topo-acoes { display: flex; gap: 8px; }
.icone {
  width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--surface);
  font-weight: 700; font-size: 17px;
  display: grid; place-items: center;
}
.icone:hover { border-color: var(--primario); }

.tela { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* Botões */
.btn {
  border: 0; border-radius: 999px;
  padding: 14px 24px; font-weight: 700; font-size: 16px;
  transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primario { background: var(--primario); color: var(--primario-ink); }
.btn-primario:hover:not(:disabled) { background: var(--primario-hover); }
.btn-primario:disabled { background: var(--surface-2); color: var(--muted); cursor: default; }
.btn-secundario { background: var(--amarelo); color: #1B2A22; }
.btn-secundario:hover { filter: brightness(1.05); }
.btn-link { background: none; color: var(--primario); text-decoration: underline; text-underline-offset: 3px; }
.btn-grande { font-size: 18px; padding: 18px 32px; width: 100%; max-width: 420px; }

/* Home */
.home {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 32px 16px; gap: 8px;
}
.home-bola { font-size: 64px; animation: quica 1.6s ease-in-out infinite; }
@keyframes quica { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
.home h1 { font-size: clamp(44px, 10vw, 72px); margin: 4px 0 0; letter-spacing: -.03em; line-height: 1; }
.home-sub { color: var(--muted); font-size: 18px; margin: 8px 0 16px; line-height: 1.4; }
.home-regras {
  list-style: none; padding: 0; margin: 0 0 28px;
  display: flex; flex-direction: column; gap: 10px; text-align: left;
}
.home-regras li { display: flex; align-items: center; gap: 12px; font-size: 16px; }
.home-regras span {
  width: 34px; height: 34px; flex: none; border-radius: 10px;
  background: var(--surface-2); display: grid; place-items: center; font-weight: 700;
}
.home-data { color: var(--muted); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; margin-top: 16px; }

/* Jogo */
.jogo { flex: 1; display: flex; flex-direction: column; min-height: 0; max-width: 900px; width: 100%; margin: 0 auto; padding: 12px 16px 16px; gap: 12px; }
.pergunta-card {
  background: var(--surface); border: 2px solid var(--border); border-radius: 18px;
  padding: 14px 18px; flex: none;
}
.pergunta-topo {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  color: var(--muted); font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em;
}
.bolinhas { display: flex; gap: 4px; font-size: 14px; }
.bolinhas i { width: 10px; height: 10px; border-radius: 50%; background: var(--barra-fundo); display: inline-block; align-self: center; }
.bolinhas i.atual { background: var(--amarelo); }
.pergunta { font-size: clamp(17px, 2.6vw, 21px); font-weight: 500; line-height: 1.35; margin: 8px 0 0; }

.mapa-wrap { position: relative; flex: 1; min-height: 280px; border-radius: 18px; overflow: hidden; border: 2px solid var(--border); }
#mapa { position: absolute; inset: 0; background: var(--mapa-fundo); cursor: crosshair; }
#mapa.leaflet-container { background: var(--mapa-fundo); cursor: crosshair; }
.leaflet-container { font-family: inherit; }

.pino { font-size: 30px; line-height: 1; transform: translate(-50%, -100%); position: absolute; filter: drop-shadow(0 2px 2px rgba(0,0,0,.25)); }
.pino-certo { font-size: 28px; transform: translate(-50%, -50%); position: absolute; }

.resposta {
  position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 500;
  background: var(--surface); border: 2px solid var(--border); border-radius: 16px;
  padding: 14px 16px; animation: sobe .25s ease-out;
}
@keyframes sobe { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.resposta-linha { display: flex; align-items: center; gap: 12px; }
.resposta-emoji { font-size: 34px; line-height: 1; }
.resposta-titulo { font-weight: 700; font-size: 18px; }
.resposta-dist { color: var(--muted); font-size: 14px; }
.resposta-pts { margin-left: auto; font-weight: 700; font-size: 24px; }
.resposta.gol .resposta-pts { color: var(--gol); }
.resposta.fora .resposta-pts { color: var(--erro); }
.resposta-local { margin-top: 10px; font-weight: 700; }
.resposta-info { color: var(--muted); font-size: 14px; line-height: 1.4; margin-top: 2px; }

.acao { flex: none; display: flex; justify-content: center; }

/* Resultado */
.resultado { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 24px 16px; gap: 16px; }
.card {
  width: 100%; max-width: 560px;
  background: var(--surface); border: 2px solid var(--border); border-radius: 24px;
  padding: 24px 20px; text-align: center;
}
.res-data { color: var(--muted); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.res-total { margin-top: 8px; display: flex; justify-content: center; align-items: baseline; gap: 10px; }
.res-total strong { font-size: 64px; letter-spacing: -.03em; line-height: 1; }
.res-total span { color: var(--muted); font-size: 22px; }
.res-frase { margin-top: 6px; font-weight: 500; }
.res-emojis { font-size: 34px; letter-spacing: 6px; margin: 14px 0 20px; }
.barras { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.barra {
  position: relative; height: 44px; border-radius: 10px; overflow: hidden; background: var(--barra-fundo);
  display: flex; align-items: center; padding: 0 14px; gap: 10px; font-weight: 700;
}
.barra-fill { position: absolute; inset: 0 auto 0 0; border-radius: 10px; transition: width .7s cubic-bezier(.2,.8,.2,1); width: 0; }
.barra.gol .barra-fill { background: var(--gol-suave); }
.barra.fora .barra-fill { background: var(--erro-suave); }
.barra > span { position: relative; z-index: 1; }
.barra .b-local { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.barra .b-pts { margin-left: auto; }
.res-botoes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
.res-botoes.solo { grid-template-columns: 1fr; }
.res-botoes .btn { padding: 14px 10px; white-space: nowrap; }
.res-proxima { color: var(--muted); text-align: center; font-size: 15px; }
.res-proxima b { color: var(--text); font-variant-numeric: tabular-nums; }

/* Ajuda */
dialog {
  border: 2px solid var(--border); border-radius: 20px; background: var(--surface); color: var(--text);
  max-width: 420px; width: calc(100% - 32px); padding: 24px;
}
dialog::backdrop { background: rgba(10, 20, 15, .55); }
dialog h2 { margin: 0 0 12px; }
dialog p { line-height: 1.5; margin: 0 0 10px; }
.ajuda-legenda { color: var(--muted); font-size: 14px; }
dialog .btn { width: 100%; margin-top: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 12px 20px; border-radius: 999px;
  font-weight: 500; z-index: 1000; animation: sobe .2s ease-out;
}

@media (max-width: 480px) {
  .res-total strong { font-size: 54px; }
  .res-emojis { font-size: 28px; letter-spacing: 3px; }
  .resposta-pts { font-size: 20px; }
}

.anuncio { width: 100%; max-width: 560px; min-height: 100px; }

/* Páginas de texto (sobre, arquivo, privacidade) */
.texto { max-width: 680px; margin: 0 auto; padding: 24px 16px 48px; line-height: 1.6; width: 100%; }
.texto h1 { letter-spacing: -.02em; line-height: 1.15; }
.texto h2 { font-size: 19px; margin-top: 32px; }
.texto a { color: var(--primario); }
.texto .jogar { display: inline-block; margin-top: 8px; text-decoration: none; color: var(--primario-ink); }
.rodada { background: var(--surface); border: 2px solid var(--border); border-radius: 18px; padding: 16px 18px; margin-top: 16px; }
.rodada h2 { margin: 0 0 8px; font-size: 17px; }
.rodada ol { margin: 0; padding-left: 20px; }
.rodada li { margin: 10px 0; }
.rodada .resp { font-weight: 700; }
.rodada .info { color: var(--muted); font-size: 14px; }
.rodape { display: flex; gap: 14px; justify-content: center; margin-top: 4px; }
.rodape a { color: var(--muted); font-size: 13px; }

/* Tempo por pergunta */
.tempo { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.tempo-trilho { flex: 1; height: 8px; border-radius: 999px; background: var(--barra-fundo); overflow: hidden; }
.tempo-barra { height: 100%; width: 100%; border-radius: 999px; background: var(--primario); }
.tempo-num { font-weight: 700; font-size: 14px; min-width: 28px; text-align: right; font-variant-numeric: tabular-nums; }
.tempo.acabando .tempo-barra { background: var(--erro); }
.tempo.acabando .tempo-num { color: var(--erro); }
