:root {
  --tinta: #141a26;
  --amarelo: #ffd23f;
  --rosa: #ef3e5c;
  --ceu: #bfe3f5;
  --horizonte: #eaf6fb;
  --papel: #ffffff;
  --cinza: #6b7280;
  --sombra: 0 10px 30px rgba(20, 26, 38, 0.22);
  --borda: 4px solid var(--tinta);
  --raio: 22px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: linear-gradient(180deg, var(--ceu), var(--horizonte)); font-family: Nunito, system-ui, sans-serif; color: var(--tinta); -webkit-tap-highlight-color: transparent; }
#mapa { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }
#etiquetas { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
button { font-family: inherit; cursor: pointer; }

/* ---------- topo e busca */
#topo { position: fixed; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: min(560px, calc(100vw - 20px)); z-index: 5; }
.marca { text-align: center; font-weight: 900; font-size: 22px; letter-spacing: .3px; margin-bottom: 6px; color: white; -webkit-text-stroke: 5px var(--tinta); paint-order: stroke fill; }
.marca b { color: var(--amarelo); }
#busca { display: flex; gap: 8px; background: var(--papel); border: var(--borda); border-radius: 999px; padding: 6px 6px 6px 18px; box-shadow: var(--sombra); }
#busca input { flex: 1; border: 0; outline: 0; font: 800 17px Nunito, sans-serif; min-width: 0; background: transparent; color: var(--tinta); }
#busca button { border: 3px solid var(--tinta); background: var(--amarelo); color: var(--tinta); font-weight: 900; border-radius: 999px; padding: 6px 16px; font-size: 15px; }
#resultados { margin-top: 8px; background: var(--papel); border: var(--borda); border-radius: var(--raio); box-shadow: var(--sombra); overflow: hidden; max-height: 50vh; overflow-y: auto; }
#resultados button { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 10px; border: 0; border-bottom: 2px solid #eee; background: white; padding: 11px 16px; font-size: 16px; font-weight: 800; text-align: left; color: var(--tinta); }
#resultados button:last-child { border-bottom: 0; }
#resultados small { color: var(--cinza); font-weight: 800; }
#resultados .vazio { padding: 14px 16px; color: var(--cinza); font-weight: 800; }

/* ---------- controles */
#controles { position: fixed; right: 12px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 4; }
#controles button { width: 46px; height: 46px; border-radius: 50%; border: var(--borda); background: white; font-size: 24px; font-weight: 900; color: var(--tinta); box-shadow: var(--sombra); }

/* ---------- painel (folha de baixo) */
#painel { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(64px + env(safe-area-inset-bottom)); width: min(520px, calc(100vw - 20px)); max-height: 62vh; overflow-y: auto; background: var(--papel); border: var(--borda); border-radius: var(--raio); box-shadow: var(--sombra); padding: 18px 18px 16px; z-index: 6; }
#painel .fechar { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--tinta); background: white; font-size: 22px; font-weight: 900; line-height: 1; }
#painel h2 { margin: 0 44px 2px 0; font-size: 26px; font-weight: 900; line-height: 1.1; word-break: break-word; }
#painel .sub { color: var(--cinza); font-weight: 800; margin-bottom: 12px; }
.selo { display: inline-flex; align-items: center; gap: 6px; font-weight: 900; font-size: 14px; letter-spacing: 1px; padding: 4px 12px; border: 3px solid var(--tinta); border-radius: 12px; background: var(--amarelo); margin: 0 6px 8px 0; }
.selo.cinza { background: #e5e7eb; }
.selo.uf { background: var(--rosa); color: white; }
.numeros { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0 12px; }
.numeros div { border: 3px solid var(--tinta); border-radius: 14px; text-align: center; padding: 8px 4px 6px; }
.numeros b { display: block; font-size: 21px; font-weight: 900; }
.numeros span { font-size: 12px; color: var(--cinza); font-weight: 800; }
.linha { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 2px solid #f0f0f0; font-weight: 800; }
.linha span:first-child { color: var(--cinza); }
.barra { height: 14px; border: 3px solid var(--tinta); border-radius: 999px; overflow: hidden; margin: 6px 0 12px; }
.barra i { display: block; height: 100%; background: var(--amarelo); }
.botoes { display: flex; gap: 10px; margin-top: 14px; }
.botoes button { flex: 1; border: 3px solid var(--tinta); background: var(--amarelo); border-radius: 999px; padding: 10px; font-weight: 900; font-size: 15px; color: var(--tinta); }
.botoes button.sec { background: white; }
ol.ranking { margin: 8px 0 0; padding: 0; list-style: none; counter-reset: r; }
ol.ranking li { counter-increment: r; display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 2px solid #f0f0f0; font-weight: 800; }
ol.ranking li::before { content: counter(r); display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--tinta); background: var(--amarelo); font-weight: 900; font-size: 14px; flex-shrink: 0; }
ol.ranking li span { flex: 1; }
ol.ranking li small { color: var(--cinza); }
ol.ranking li button { border: 3px solid var(--tinta); background: white; border-radius: 999px; padding: 4px 10px; font-weight: 900; font-size: 13px; color: var(--tinta); }
.grande { font-size: 46px; font-weight: 900; line-height: 1; }
.nota { font-size: 13px; color: var(--cinza); font-weight: 700; margin-top: 10px; }

/* ---------- abas e rodapé */
#abas { position: fixed; bottom: calc(26px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; gap: 6px; background: white; border: var(--borda); border-radius: 999px; padding: 5px; box-shadow: var(--sombra); z-index: 5; }
#abas button { border: 0; background: transparent; border-radius: 999px; padding: 7px 13px; font-weight: 900; font-size: 14px; color: var(--tinta); white-space: nowrap; }
#abas button.ativa { background: var(--amarelo); }
#rodape { position: fixed; bottom: max(4px, env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; font-size: 11px; font-weight: 800; color: var(--tinta); opacity: .75; z-index: 4; }
#rodape a { color: var(--tinta); }
#aviso-demo { position: fixed; top: 0; left: 0; right: 0; z-index: 7; text-align: center; background: var(--rosa); color: white; font-weight: 900; font-size: 13px; padding: 4px 8px; letter-spacing: .5px; }
#aviso-demo:not([hidden]) ~ #topo { top: max(28px, calc(env(safe-area-inset-top) + 20px)); }

/* ---------- etiquetas sobre o mapa */
.etq-casa { position: absolute; transform: translate(-50%, -100%); background: white; border: 3px solid var(--tinta); border-radius: 999px; padding: 3px 11px 2px; font-weight: 900; font-size: 13px; white-space: nowrap; box-shadow: 0 4px 10px rgba(0,0,0,.18); pointer-events: auto; cursor: pointer; }
.etq-casa small { display: block; font-size: 10px; color: var(--cinza); font-weight: 800; margin-top: -2px; text-align: center; }
.etq-casa.fundador { background: var(--amarelo); }
.etq-casa.voce { outline: 4px solid var(--rosa); }
.etq-cidade { position: absolute; transform: translate(-50%, -130%); font-weight: 900; font-size: 13px; white-space: nowrap; color: white; -webkit-text-stroke: 4px var(--tinta); paint-order: stroke fill; pointer-events: auto; cursor: pointer; }
.etq-cidade small { color: var(--amarelo); }

/* ---------- carregando */
#carregando { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; z-index: 9; background: linear-gradient(180deg, var(--ceu), var(--horizonte)); font-weight: 900; font-size: 18px; transition: opacity .4s; }
#carregando .bola { width: 46px; height: 46px; margin: 0 auto 12px; border-radius: 50%; border: 6px solid var(--tinta); border-top-color: var(--amarelo); animation: gira 0.9s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
@media (max-width: 420px) {
  #abas button { padding: 7px 9px; font-size: 13px; }
  .numeros b { font-size: 18px; }
}
