:root {
  color-scheme: dark;
  --bg: #12151b;
  --card: rgba(22, 26, 33, 0.94);
  --card-solid: #161a21;
  --ink: #edf0f4;
  --muted: #9aa3af;
  --faint: #6b7380;
  --line: #2a303b;
  --hover: #222833;
  --accent: #e9c46a;
  --accent-ink: #1a1a1a;
  --radius: 10px;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 14px; }
#mapa { position: fixed; inset: 0; }
button { font: inherit; color: inherit; }

.card {
  position: absolute; z-index: 2;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(6px); box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

/* Placar */
.placar { top: 16px; left: 16px; width: 340px; padding: 16px 18px 14px; max-height: calc(100dvh - 32px); overflow-y: auto; }
.eyebrow { margin: 0 0 6px; font: 500 10.5px/1.4 var(--mono); letter-spacing: 0.06em; color: var(--accent); text-transform: uppercase; }
h1 { margin: 0 0 10px; font-size: 19px; line-height: 1.25; font-weight: 700; text-wrap: balance; }
.niveis { display: flex; gap: 2px; padding: 3px; background: #0d1015; border-radius: 8px; margin-bottom: 14px; }
.niveis button { flex: 1; border: 0; background: transparent; padding: 6px 4px; border-radius: 6px; color: var(--muted); cursor: pointer; font-size: 12.5px; font-weight: 500; }
.niveis button[aria-selected="true"] { background: var(--hover); color: var(--ink); }
.niveis button:hover:not(:disabled) { color: var(--ink); }
.niveis button:disabled { opacity: 0.35; cursor: not-allowed; }
.area { margin: 0 0 6px; font: 500 10.5px/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

.duelo { display: grid; grid-template-columns: 1fr 1fr; align-items: end; gap: 8px; }
.duelo .lado { min-width: 0; }
.duelo .lado.b { text-align: right; }
.duelo .pct { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.05; }
.duelo .nome { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra-duelo { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin: 8px 0 6px; background: #2b313c; }
.barra-duelo span { display: block; height: 100%; }
.vitorias { display: grid; grid-template-columns: 1fr 1fr; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.vitorias span:last-child { text-align: right; }
.vitorias b { color: var(--ink); font-weight: 600; }

.outros { margin: 12px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line); list-style: none; display: grid; gap: 5px; }
.outros li { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; font-size: 12.5px; }
.outros .pt { width: 8px; height: 8px; border-radius: 50%; }
.outros .v { font-variant-numeric: tabular-nums; color: var(--muted); }
.extra { margin-top: 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.ajuda { margin: 12px 0 8px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.acoes { display: flex; gap: 16px; flex-wrap: wrap; }
.link { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-size: 12.5px; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }

/* Busca */
.busca { position: absolute; z-index: 3; top: 16px; left: 50%; transform: translateX(-50%); width: min(420px, calc(100vw - 760px)); min-width: 240px; }
.busca input { width: 100%; padding: 10px 14px; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); font: inherit; outline: none; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35); }
.busca input:focus { border-color: var(--accent); }
.busca-res { list-style: none; margin: 6px 0 0; padding: 4px; background: var(--card-solid); border: 1px solid var(--line); border-radius: var(--radius); max-height: 50dvh; overflow-y: auto; }
.busca-res li { padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.busca-res li:hover, .busca-res li.ativo { background: var(--hover); }
.busca-res small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 1px; }

/* Filtros */
.filtros { top: 16px; right: 16px; width: 280px; padding: 14px 16px; max-height: calc(100dvh - 32px); overflow-y: auto; }
.grupo + .grupo { margin-top: 14px; }
.grupo h2 { margin: 0 0 7px; font: 500 10.5px/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; }
.opcoes { display: flex; flex-wrap: wrap; gap: 5px; }
.opcoes button { border: 1px solid var(--line); background: transparent; color: var(--ink); padding: 5px 9px; border-radius: 6px; cursor: pointer; font-size: 12.5px; }
.opcoes button:hover { background: var(--hover); }
.opcoes button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.opcoes button:disabled { opacity: 0.35; cursor: not-allowed; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.botao-filtros { display: none; }

/* Legenda */
.legenda { right: 16px; bottom: 28px; width: 280px; padding: 12px 14px; font-size: 12px; }
.legenda h3 { margin: 0 0 8px; font: 500 10.5px/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.legenda .itens { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.legenda .item { display: inline-flex; align-items: center; gap: 6px; }
.legenda .pt { width: 10px; height: 10px; border-radius: 50%; }
.legenda .grad { height: 9px; border-radius: 5px; margin: 2px 0 4px; }
.legenda .escala { display: flex; justify-content: space-between; color: var(--muted); font-variant-numeric: tabular-nums; }
.legenda .nota { margin: 8px 0 0; color: var(--faint); font-size: 11.5px; line-height: 1.4; }

/* Popup */
.maplibregl-popup-content { background: var(--card-solid); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); font-family: var(--sans); min-width: 240px; }
.maplibregl-popup-tip { border-top-color: var(--card-solid) !important; border-bottom-color: var(--card-solid) !important; }
.maplibregl-popup-close-button { color: var(--muted); font-size: 18px; padding: 2px 8px; }
.pop h4 { margin: 0 22px 2px 0; font-size: 14px; line-height: 1.3; }
.pop .sub { margin: 0 0 10px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.pop table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.pop td { padding: 3px 0; }
.pop td.n { text-align: right; padding-left: 10px; color: var(--muted); }
.pop td.p { text-align: right; padding-left: 10px; font-weight: 600; width: 52px; }
.pop .bar { height: 3px; border-radius: 2px; margin-top: 2px; }
.pop .rod { margin: 10px 0 0; padding-top: 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.5; }
.pop .rod b { color: var(--ink); }

dialog { max-width: 560px; width: calc(100vw - 32px); background: var(--card-solid); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; padding: 22px 24px; line-height: 1.55; }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { margin: 0 0 12px; font-size: 18px; }
dialog p { margin: 0 0 10px; color: #cdd3db; font-size: 13.5px; }
dialog .fonte { color: var(--muted); font-size: 12px; }
.botao { margin-top: 6px; border: 0; background: var(--accent); color: var(--accent-ink); padding: 8px 16px; border-radius: 8px; font-weight: 600; cursor: pointer; }

.maplibregl-ctrl-attrib { font-size: 10.5px; }
.maplibregl-ctrl-group { background: var(--card-solid); }
.maplibregl-ctrl-group button + button { border-top-color: var(--line); }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(0.9); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 1100px) {
  .busca { left: 372px; transform: none; width: auto; right: 312px; min-width: 0; }
}

@media (max-width: 760px) {
  .placar { top: auto; bottom: 0; left: 0; right: 0; width: auto; border-radius: 14px 14px 0 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); max-height: 46dvh; }
  .placar h1 { font-size: 16px; margin-bottom: 8px; }
  .placar .ajuda { display: none; }
  .duelo .pct { font-size: 22px; }
  .outros { display: none; }
  .busca { top: 12px; left: 16px; right: 16px; width: auto; min-width: 0; transform: none; }
  .botao-filtros { display: block; top: 62px; right: 16px; padding: 8px 14px; cursor: pointer; font-weight: 600; font-size: 13px; }
  .filtros { top: 104px; right: 16px; left: 16px; width: auto; max-height: calc(100dvh - 104px - 46dvh - 8px); display: none; }
  .filtros.aberto { display: block; }
  .legenda { top: 62px; left: 16px; right: auto; bottom: auto; width: calc(100vw - 32px - 100px); padding: 8px 10px; font-size: 11px; }
  .legenda .nota { display: none; }
  .maplibregl-ctrl-bottom-right, .maplibregl-ctrl-top-right { display: none; }
}
