:root {
  --bg: #f3f0e8;
  --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;
  --bone: #efe5cf;
  --bone-line: #6f5d40;
  --bone-shade: #c2b190;
  --bone-ridge: #e2d4b4;
  --cart: #cfe1e5;
  --cart-line: #6c8b93;
  --hole: #3d3531;
  --hole-deep: #1a1412;
  --tooth: #fbf8f0;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15191c;
    --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);
    --bone: #d8ccb2;
    --bone-line: #4a3e2c;
    --bone-shade: #9d8f74;
    --bone-ridge: #c9bb9c;
    --cart: #8fa9b0;
    --cart-line: #3f5a61;
    --hole: #241e1b;
    --hole-deep: #0b0807;
    --tooth: #ebe6da;
    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; }

.board {
  position: fixed;
  inset: 0;
  outline: none;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background: radial-gradient(ellipse at 50% 40%, color-mix(in srgb, var(--bg) 70%, var(--panel)) 0%, var(--bg) 70%);
}
.board.is-aiming { cursor: crosshair; }
.board.is-dragging { cursor: grabbing; }
.board:focus-visible { box-shadow: inset 0 0 0 3px var(--accent); }

.prancha-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.prancha-svg path, .prancha-svg line {
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
  stroke-width: 1;
}
.f-osso { fill: var(--bone); stroke: var(--bone-line); }
.f-sombra { fill: var(--bone-shade); stroke: var(--bone-line); }
.f-crista { fill: var(--bone-ridge); stroke: var(--bone-line); }
.f-cart { fill: var(--cart); stroke: var(--cart-line); }
.f-furo { fill: var(--hole); stroke: var(--hole); }
.f-furo2 { fill: var(--hole-deep); stroke: var(--hole-deep); }
.f-dente { fill: var(--tooth); stroke: var(--bone-line); stroke-opacity: 0.7; }
.f-alvo {
  fill: color-mix(in srgb, var(--target) 55%, transparent);
  stroke: var(--target);
  stroke-width: 2.5;
  animation: acende 0.6s ease-out;
}
.f-alvo-acidente { fill: color-mix(in srgb, var(--target) 40%, transparent); stroke-dasharray: 4 3; }
@keyframes acende { from { fill-opacity: 0; stroke-opacity: 0; } }
.f-linha { stroke: var(--ink); stroke-width: 2; stroke-dasharray: 3 4; stroke-linecap: round; }

.prancha-overlay { position: absolute; inset: 0; pointer-events: none; }
.prancha-overlay > * { position: absolute; left: 0; top: 0; pointer-events: auto; }

.prancha-ctrl {
  position: absolute;
  z-index: 1;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  gap: 2px;
  padding: 3px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.prancha-ctrl button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--ink);
  font: 600 1.15rem/1 system-ui, sans-serif;
  cursor: pointer;
}
.prancha-ctrl button:hover { background: var(--soft); }
.prancha-ctrl button:focus-visible { outline: 3px solid var(--target); outline-offset: 1px; }
body[data-screen="home"] .prancha-ctrl { display: none; }

/* ---- 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;
  margin: -36px 0 0 -13px;
  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; }
.board.is-aiming .pin-guess { cursor: grab; }
.pin-small svg { width: 18px; height: 25px; margin: -25px 0 0 -9px; }
.nota { margin-top: 6px !important; font-size: 0.88rem; color: var(--muted); }
.lado-errado { margin-top: 4px !important; font-size: 0.88rem; color: var(--accent); }

.esqueleto-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.partes { grid-template-columns: repeat(2, 1fr); }
.partes label:first-child { grid-column: 1 / -1; }
.seg input[type="checkbox"]:checked + span {
  background: var(--panel);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.pin-numero span {
  display: grid; place-items: center; width: 22px; height: 22px; margin: -11px 0 0 -11px;
  border-radius: 50%; background: var(--target); color: #fff; font-size: 0.7rem; font-weight: 800;
}
