:root {
  --bg: #f3f1ec;
  --panel: rgba(255, 255, 255, 0.94);
  --ink: #1d2a33;
  --muted: #5d6b74;
  --line: rgba(29, 42, 51, 0.12);
  --accent: #e2563b;
  --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;
  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: #ff7a5c;
    --accent-ink: #1a1210;
    --target: #6fb1ff;
    --soft: rgba(244, 241, 234, 0.07);
    --gold: #f2c14e;
    --silver: #c4cdd3;
    --bronze: #e0915a;
    --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));
}
.result {
  max-height: 62%;
  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; }
  .place { font-size: 1.35rem; }
}

/* ---- 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, .seg input:focus-visible + span, .brand:focus-visible {
  outline: 3px solid var(--target);
  outline-offset: 2px;
}

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

.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  background: var(--soft);
  border-radius: 12px;
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block;
  text-align: center;
  padding: 8px 4px;
  border-radius: 9px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.92rem;
}
.seg input:checked + span {
  background: var(--panel);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.dif-hint { margin: 0; min-height: 2.6em; font-size: 0.85rem; color: var(--muted); text-align: center; }

.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);
}
.place { margin: 0; font-size: 1.7rem; line-height: 1.15; letter-spacing: -0.01em; }
.country { margin: 2px 0 12px; color: var(--muted); }
.outcome { min-height: 2.6em; margin-bottom: 12px; }
.outcome p { margin: 0; }
.hint { color: var(--muted); }
.points { font-size: 1.25rem; }
.points strong { font-variant-numeric: tabular-nums; }
.dist { color: var(--muted); }

/* ---- 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; }

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

.pin { cursor: default; }
.pin-guess svg { display: block; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35)); }
.pin-guess path { fill: var(--accent); stroke: #fff; stroke-width: 1.5; }
.pin-guess circle { fill: #fff; }
.map.is-aiming .pin-guess { cursor: grab; }
.pin-small svg { width: 18px; height: 25px; }
.pin-target {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--target);
  border: 3px solid #fff;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--target) 35%, transparent), 0 2px 4px rgba(0, 0, 0, 0.3);
  display: grid;
  place-items: center;
}
.pin-target span { color: #fff; font-size: 0; }
.pin-target:has(span) { width: 22px; height: 22px; border-width: 2px; }
.pin-target:has(span) span { font-size: 0.7rem; font-weight: 800; }

.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; }
}
