:root {
  --bg: #f3f1ec;
  --panel: rgba(255, 255, 255, 0.94);
  --ink: #1d2a33;
  --muted: #5d6b74;
  --line: rgba(29, 42, 51, 0.12);
  --accent: #17804f;
  --accent-ink: #ffffff;
  --target: #1d6fd6;
  --soft: rgba(29, 42, 51, 0.06);
  --gold: #b8860b;
  --silver: #6f7b85;
  --bronze: #a0522d;
  --shadow: 0 10px 30px rgba(20, 30, 40, 0.18);
  --radius: 18px;
  --ok: #2e9e5b;
  --bad: #c2453a;
  --mark: #e2563b;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11181d;
    --panel: rgba(24, 33, 40, 0.94);
    --ink: #f4f1ea;
    --muted: #9fadb6;
    --line: rgba(244, 241, 234, 0.14);
    --accent: #3ecf8e;
    --accent-ink: #0c1f16;
    --target: #6fb1ff;
    --soft: rgba(244, 241, 234, 0.07);
    --gold: #f2c14e;
    --silver: #c4cdd3;
    --bronze: #e0915a;
    --ok: #4cc77d;
    --bad: #f07a6e;
    --mark: #ff7a5c;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

[hidden] { display: none !important; }

.map {
  position: fixed;
  inset: 0;
  outline: none;
}
.map.is-aiming .maplibregl-canvas-container { cursor: crosshair; }
.map:focus-visible { box-shadow: inset 0 0 0 3px var(--accent); }

/* ---- Painéis ---------------------------------------------------------- */

.panel {
  position: fixed;
  z-index: 2;
  background: var(--panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.home {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow: auto;
  display: grid;
  gap: 14px;
}

.title {
  margin: 0;
  font-size: 2.1rem;
  letter-spacing: -0.02em;
}
.lede { margin: 0; color: var(--muted); }

.card, .result {
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
}
/* No celular o cartão para em 56% da altura e rola: acima dele o mapa
   precisa caber o Brasil inteiro, que é onde a revelação acontece. */
.card, .result {
  max-height: 56%;
  overflow: auto;
}

/* Coluna lateral: no desktop e no celular deitado. Deitado, o cartão embaixo
   cobriria 70% da tela e esconderia justamente o alvo revelado. A mesma
   consulta está em app.js (SIDE_LAYOUT). */
@media (min-width: 1000px), (orientation: landscape) and (max-height: 520px) {
  .card, .result {
    right: auto;
    bottom: auto;
    top: 84px;
    width: min(360px, 55vw);
    max-height: calc(100% - 100px);
    overflow: auto;
  }
}
@media (orientation: landscape) and (max-height: 520px) {
  .card, .result { top: 64px; max-height: calc(100% - 76px); padding: 14px; }
  .prompt { font-size: 1.1rem; }
}

/* ---- Botões ----------------------------------------------------------- */

.btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  min-height: 48px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--soft);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn small { font-weight: 400; opacity: 0.8; font-size: 0.82rem; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
}
.btn-ghost { background: transparent; }
.btn:focus-visible, .brand:focus-visible, .select:focus-visible, .card-body button:focus-visible {
  outline: 3px solid var(--target);
  outline-offset: 2px;
}

.free { display: grid; gap: 8px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0;
  text-align: center;
}
.stats dt { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stats dd { margin: 2px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }

.credit { margin: 0; font-size: 0.78rem; color: var(--muted); }
.credit a { color: inherit; }

/* ---- Barra superior --------------------------------------------------- */

.hud {
  position: fixed;
  z-index: 3;
  top: calc(12px + env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
}
@media (min-width: 1000px), (orientation: landscape) and (max-height: 520px) { .hud { right: auto; min-width: min(360px, 55vw); } }

.brand {
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  padding: 0;
  cursor: pointer;
  white-space: nowrap;
}
.edition { color: var(--muted); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dots {
  display: flex;
  gap: 4px;
  margin: 0 0 0 auto;
  padding: 0;
  list-style: none;
}
.dots li {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--soft);
  border: 1px solid var(--line);
  font-size: 10px;
  line-height: 14px;
  text-align: center;
  overflow: hidden;
}
.dots li.done { background: none; border-color: transparent; }
.dots li.now { border: 2px solid var(--accent); }
.total { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 4ch; text-align: right; }

/* ---- Cartão da rodada ------------------------------------------------- */

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.prompt { margin: 0; font-size: 1.3rem; line-height: 1.2; letter-spacing: -0.01em; }
.prompt .em { color: var(--accent); }
.sub { margin: 4px 0 10px; font-size: 0.85rem; color: var(--muted); }
.sub:empty { display: none; }
.card-body { display: grid; gap: 10px; margin: 10px 0 12px; }
.card-body p { margin: 0; }
.hint { color: var(--muted); font-size: 0.85rem; text-align: center; }
.points { font-size: 1.25rem; }
.points strong { font-variant-numeric: tabular-nums; }

/* ---- Resultado -------------------------------------------------------- */

.score { margin: 0; font-size: 1rem; color: var(--muted); }
.score strong { font-size: 2.4rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.medal { margin: 0 0 10px; font-weight: 700; }
.medal[data-medal="ouro"] { color: var(--gold); }
.medal[data-medal="prata"] { color: var(--silver); }
.medal[data-medal="bronze"] { color: var(--bronze); }

.rounds { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 4px; }
.rounds button {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: var(--soft);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.rounds small { display: block; color: var(--muted); font-size: 0.8rem; }
.r-n {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--target);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.r-name { min-width: 0; }
.r-name strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-pts { text-align: right; font-variant-numeric: tabular-nums; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .btn-ghost { grid-column: 1 / -1; }
.countdown { margin: 12px 0 0; text-align: center; font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; }


@media (max-width: 400px) { .edition { display: none; } .brand { font-size: 0.92rem; } }

/* ---- Controles das rodadas -------------------------------------------- */

.select {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--soft);
  color: var(--ink);
  font: inherit;
}
.select option { background: var(--bg); color: var(--ink); }

.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--soft);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chip.ok { border-color: var(--ok); color: var(--ok); font-weight: 600; }
.chip.bad { border-color: color-mix(in srgb, var(--bad) 50%, transparent); }

/* Raio-X */
.clues { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.clues li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  column-gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--soft);
}
.clues strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.clues small { grid-column: 1 / -1; color: var(--muted); font-size: 0.78rem; }
.clues li.locked { display: block; padding: 6px 10px; background: none; border: 1px dashed var(--line); color: var(--muted); font-size: 0.82rem; }

/* Chute */
.chute { display: grid; gap: 6px; }
.big { display: block; text-align: center; font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.chute-row { display: grid; grid-template-columns: 40px 1fr 40px; gap: 8px; align-items: center; }
.chute input[type="range"] { width: 100%; accent-color: var(--accent); height: 32px; }
.nudge {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
  color: var(--ink);
  font: inherit;
  font-size: 1.2rem;
  cursor: pointer;
}
.range-ends { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Mais ou Menos */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-height: 84px;
  padding: 10px 8px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--soft);
  color: var(--ink);
  font: inherit;
  text-align: center;
  cursor: pointer;
}
.choice:hover { border-color: var(--accent); }
.choice small { color: var(--muted); font-size: 0.78rem; }
.tag {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--target);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  display: grid;
  place-items: center;
}
.pairs { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.pairs li {
  display: grid;
  grid-template-columns: 18px 1fr 1fr;
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 10px;
  background: var(--soft);
  font-size: 0.82rem;
}
.pairs .mark { font-weight: 800; }
.pairs li.ok .mark { color: var(--ok); }
.pairs li.bad .mark { color: var(--bad); }
.pairs .side { min-width: 0; color: var(--muted); }
.pairs .side b { color: var(--ink); font-weight: 600; }
.pairs .side em { display: block; font-style: normal; font-variant-numeric: tabular-nums; }
.pairs .side.chosen { color: var(--ink); }
.pairs .side.chosen b { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }

/* Ordene */
.sortable, .final-order { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.sortable li, .final-order li {
  display: grid;
  grid-template-columns: 16px 24px 1fr 36px 36px;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 10px;
  background: var(--soft);
  border: 1px solid var(--line);
  touch-action: none;
  user-select: none;
  cursor: grab;
}
.sortable li.dragging { border-color: var(--accent); box-shadow: var(--shadow); cursor: grabbing; }
.grip { color: var(--muted); letter-spacing: -2px; }
.pos {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.75rem;
  font-weight: 800;
  display: grid;
  place-items: center;
}
.mv {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.75rem;
}
.mv:disabled { opacity: 0.3; cursor: default; }
.final-order li { grid-template-columns: 24px 1fr auto auto; cursor: default; touch-action: auto; }
.final-order strong { font-variant-numeric: tabular-nums; }
.final-order small { color: var(--muted); font-size: 0.78rem; min-width: 3.6em; text-align: right; }
.final-order li.ok small { color: var(--ok); font-weight: 700; }
.final-order li.bad { border-color: color-mix(in srgb, var(--bad) 40%, transparent); }

/* Onde Fica?: a ficha do município na revelação */
.ficha { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: 0.85rem; }
.ficha li { display: grid; grid-template-columns: 1fr auto 3.2em; gap: 8px; padding: 4px 2px; border-bottom: 1px solid var(--line); }
.ficha strong { font-variant-numeric: tabular-nums; }
.ficha small { color: var(--muted); text-align: right; }

/* ---- Revelação -------------------------------------------------------- */

.reveal-head { font-size: 1rem; }
.rank { color: var(--muted); font-size: 0.85rem; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.tab {
  display: grid;
  gap: 1px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  text-align: left;
  cursor: pointer;
}
.tab strong { font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.tab small { color: var(--muted); }
.tab[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.ind { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); display: grid; gap: 6px; }
.ind-name { font-weight: 700; }
.ind-def, .ind-src { font-size: 0.8rem; color: var(--muted); }
.legend { padding-bottom: 16px; }
.lg-bar { display: grid; grid-template-columns: repeat(5, 1fr); height: 12px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.lg-ticks { position: relative; height: 14px; font-size: 0.68rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.lg-ticks span { position: absolute; top: 2px; transform: translateX(-50%); white-space: nowrap; }

/* ---- Marcadores ------------------------------------------------------- */

.pin {
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border-radius: 999px;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
}
.pin-alvo { width: 18px; min-width: 18px; height: 18px; padding: 0; background: var(--target); box-shadow: 0 0 0 4px color-mix(in srgb, var(--target) 35%, transparent), 0 2px 4px rgba(0, 0, 0, 0.3); }
.pin-a, .pin-b { background: var(--target); }
.pin-num { background: #1d2a33; }
.pin-certo { width: 14px; min-width: 14px; height: 14px; padding: 0; background: var(--ok); }
.pin-errado { background: var(--bad); }
.pin-regiao { background: #c9a227; }
.pin-palpite { width: 20px; min-width: 20px; height: 20px; padding: 0; background: var(--mark); cursor: grab; }
.pin-ponto { width: 10px; min-width: 10px; height: 10px; padding: 0; border-width: 1.5px; background: #5d6b74; }

.maplibregl-ctrl-attrib { font-size: 10px; }
body[data-screen="card"] .maplibregl-ctrl-bottom-right,
body[data-screen="result"] .maplibregl-ctrl-bottom-right { bottom: auto; top: 70px; }
@media (min-width: 1000px), (orientation: landscape) and (max-height: 520px) {
  body[data-screen] .maplibregl-ctrl-bottom-right { top: auto; bottom: 0; }
}
