/* Bolão Presidencial — estilos compartilhados (público + admin). Mobile first. */

:root {
  color-scheme: light;
  --bg: #f3f4f9;
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --ink: #151830;
  --muted: #646985;
  --faint: #9a9eb6;
  --line: #e5e7f0;
  --accent: #4c44d4;
  --accent-ink: #ffffff;
  --accent-soft: #eeedfd;
  --ok: #0e7a52;
  --ok-soft: #e2f4eb;
  --bad: #c23a32;
  --bad-soft: #fcebea;
  --gold: #e6b53f;
  --silver: #aeb7c5;
  --bronze: #cd8a55;
  --hero-a: #13163a;
  --hero-b: #2d2678;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgb(21 24 48 / .04), 0 10px 30px rgb(21 24 48 / .07);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0d0f1e;
    --surface: #161930;
    --surface-2: #1d2039;
    --ink: #eef0fa;
    --muted: #a3a7c2;
    --faint: #6f7493;
    --line: #2a2e4d;
    --accent: #8f87ff;
    --accent-ink: #0d0f1e;
    --accent-soft: #26245a;
    --ok: #4cd3a0;
    --ok-soft: #10372a;
    --bad: #ff8a80;
    --bad-soft: #3b1b1d;
    --hero-a: #0a0c1c;
    --hero-b: #231e5e;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 30px rgb(0 0 0 / .25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.wrap { width: 100%; max-width: 652px; margin: 0 auto; padding: 0 22px; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  color: #fff;
  padding: 26px 0 76px;
  background:
    radial-gradient(90% 120% at 100% 0%, var(--hero-b) 0%, transparent 70%),
    var(--hero-a);
}
.hero::after { /* faixa sutil, lembra a cédula */
  content: "";
  position: absolute;
  right: -40px;
  bottom: -60px;
  width: 220px;
  height: 220px;
  border-radius: 40px;
  border: 1.5px solid rgb(255 255 255 / .07);
  transform: rotate(18deg);
  pointer-events: none;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.logo {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: rgb(255 255 255 / .1);
}
.logo svg { width: 22px; height: 22px; }
.badge {
  display: inline-flex; align-items: center;
  font-size: 13px; font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  background: rgb(255 255 255 / .1);
  color: #d9d8ff;
}
.hero h1 {
  margin: 0;
  font-size: clamp(28px, 7.6vw, 42px);
  line-height: 1.08;
  letter-spacing: -.025em;
  font-weight: 800;
}
.hero h1 .league-name { display: block; margin-top: 4px; font-size: .62em; letter-spacing: -.01em; color: #b9b4ff; }
.hero .lead { margin: 10px 0 0; color: #c8cae6; max-width: 44ch; }
.league-list { display: grid; gap: 12px; margin-top: 16px; }
.zone-title { display: flex; align-items: center; gap: 10px; margin: 8px 0 12px; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.card-title .league-label { color: var(--accent); }
.hero .meta {
  display: flex; align-items: center; gap: 8px;
  margin: 16px 0 0;
  font-size: 14px; color: #b3b6da;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #5ee0a8; box-shadow: 0 0 0 4px rgb(94 224 168 / .15); }
.dot.closed { background: #ff8a80; box-shadow: 0 0 0 4px rgb(255 138 128 / .15); }

main.wrap { position: relative; margin-top: -50px; padding-bottom: 32px; }

/* ---------- Tabs ---------- */
.tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.tab {
  appearance: none; border: 0; background: transparent;
  color: var(--muted);
  font-weight: 650; font-size: 15px;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card, .card + .stack, .stack + .card { margin-top: 16px; }
.card-title { margin: 0 0 4px; font-size: 18px; letter-spacing: -.01em; }
.card-sub { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.stack > * + * { margin-top: 16px; }

/* ---------- Campos ---------- */
.field { display: block; }
.field > span { display: block; font-size: 14px; font-weight: 650; margin-bottom: 6px; }
.input {
  width: 100%;
  font: inherit; font-size: 16px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--faint); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

/* ---------- Lista de percentuais ---------- */
.list-head {
  display: flex; justify-content: space-between;
  margin: 22px 0 2px;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--faint);
}
.pct-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  cursor: text;
}
.pct-row:last-child { border-bottom: 0; }
.num {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font: 700 15px var(--mono);
  color: var(--muted);
  transition: background .15s, color .15s, border-color .15s;
}
.pct-row.has-value .num { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.who { min-width: 0; }
.who b { display: block; font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; }
.who small { display: block; color: var(--muted); font-size: 13px; }
.pct-input { position: relative; width: 100px; }
.pct-input input {
  width: 100%;
  padding: 10px 30px 10px 10px;
  text-align: right;
  font: 650 16px var(--font);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: 11px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.pct-input input::placeholder { color: var(--faint); }
.pct-input input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.pct-input input.invalid { border-color: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
.pct-input i {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  font-style: normal; font-weight: 650;
  color: var(--faint);
  pointer-events: none;
}

/* ---------- Barra da soma (fixa no rodapé do card) ---------- */
.sumbar {
  position: sticky; bottom: 0; z-index: 2;
  margin: 18px -20px -20px;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
}
.progress { height: 6px; margin-bottom: 12px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress > span {
  display: block; height: 100%; width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width .2s ease, background-color .2s;
}
.sumbar.ok .progress > span { background: var(--ok); }
.sumbar.over .progress > span { background: var(--bad); }
.sum-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sums { display: flex; flex-direction: column; line-height: 1.3; font-variant-numeric: tabular-nums; }
.sums strong { font-size: 17px; }
.sums span { font-size: 14px; font-weight: 600; color: var(--muted); }
.sumbar.ok .sums span { color: var(--ok); }
.sumbar.over .sums span { color: var(--bad); }

/* ---------- Botões e mensagens ---------- */
.btn {
  appearance: none; border: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 18px;
  border-radius: 12px;
  font-weight: 700; font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .15s, background .15s, transform .05s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.success { background: var(--ok); color: #fff; }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-row > .btn { flex: 1 1 auto; }
.msg { margin: 10px 0 0; font-size: 14px; font-weight: 600; min-height: 0; }
.msg:empty { display: none; }
.msg.err { color: var(--bad); }
.msg.ok { color: var(--ok); }
.msg.info { color: var(--muted); }

.rules { margin-top: 18px; font-size: 14px; color: var(--muted); }
.rules summary { cursor: pointer; font-weight: 650; color: var(--ink); }
.rules p { margin: 8px 0 0; }
.formula {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  font: 600 14px var(--mono);
  color: var(--ink);
}

/* ---------- Estados (enviado, encerrado, aguardando) ---------- */
.state { text-align: center; padding: 34px 20px; }
.state .icon {
  width: 58px; height: 58px;
  margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: 18px;
  background: var(--accent-soft); color: var(--accent);
}
.state .icon svg { width: 28px; height: 28px; }
.state.success .icon { background: var(--ok-soft); color: var(--ok); }
.state h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.01em; }
.state p { margin: 0 auto; color: var(--muted); max-width: 40ch; }
.state .hint { margin-top: 12px; }
.state .btn-row { margin-top: 20px; justify-content: center; }
.state .btn-row > .btn { flex: 0 1 auto; }

.mini {
  list-style: none;
  margin: 20px 0 0; padding: 0;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.mini li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 14px; font-size: 15px; }
.mini li + li { border-top: 1px solid var(--line); }
.mini li span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; }
.mini li.zero span { color: var(--faint); }

/* ---------- Pódio ---------- */
.podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 10px;
  padding-top: 6px;
}
.pod {
  display: flex; flex-direction: column; align-items: center;
  min-width: 0;
  padding: 0;
  border: 0; background: none;
  text-align: center;
  cursor: pointer;
}
.medal {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  margin-bottom: 8px;
  border-radius: 50%;
  font-weight: 800; color: #23190a;
  background: var(--surface-2);
  box-shadow: 0 6px 16px rgb(0 0 0 / .12);
}
.medal.g1 { background: var(--gold); }
.medal.g2 { background: var(--silver); }
.medal.g3 { background: var(--bronze); }
.pod.first .medal { width: 56px; height: 56px; font-size: 20px; }
.pname {
  max-width: 100%;
  padding: 0 4px;
  font-weight: 700; font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pscore { margin-bottom: 8px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.step {
  width: 100%;
  display: grid; place-items: center;
  border-radius: 14px 14px 6px 6px;
  background: var(--surface-2);
  font-weight: 800; font-size: 26px; color: var(--faint);
}
.pod.first .step { height: 112px; box-shadow: inset 0 4px 0 var(--gold); color: var(--ink); }
.pod.second .step { height: 84px; }
.pod.third .step { height: 62px; }

/* ---------- Lista do ranking ---------- */
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-item + .rank-item { border-top: 1px solid var(--line); }
.rank-row {
  width: 100%;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto 18px;
  align-items: center;
  gap: 10px;
  padding: 12px 2px;
  border: 0; background: none;
  text-align: left;
  cursor: pointer;
}
.pos {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--surface-2);
  font-weight: 800; font-size: 14px; color: var(--muted);
}
.pos.g1 { background: var(--gold); color: #23190a; }
.pos.g2 { background: var(--silver); color: #23190a; }
.pos.g3 { background: var(--bronze); color: #23190a; }
.rname { font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }
.rname small { margin-left: 6px; font-size: 12px; font-weight: 700; color: var(--accent); }
.rscore { font-weight: 800; font-variant-numeric: tabular-nums; }
.chev { width: 18px; height: 18px; color: var(--faint); transition: transform .2s; }
.rank-row[aria-expanded="true"] .chev { transform: rotate(180deg); }
.rank-item.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 40% { background: var(--accent-soft); } 100% { background: transparent; } }

.detail { padding: 2px 2px 16px; }
.detail table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.detail th {
  padding: 6px;
  text-align: right;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--faint);
}
.detail td { padding: 7px 6px; text-align: right; border-top: 1px solid var(--line); }
.detail th:first-child, .detail td:first-child { padding-left: 0; text-align: left; }
.detail th:last-child, .detail td:last-child { padding-right: 0; }
.detail td.err { font-weight: 700; color: var(--bad); }
.detail td.err.zero { color: var(--ok); }
.detail-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 14px; color: var(--muted);
}
.detail-foot b { font-size: 20px; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- Barras do resultado oficial ---------- */
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.bar-top { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.bar-top b { font-variant-numeric: tabular-nums; }
.bar { height: 8px; margin-top: 5px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

/* ---------- Admin ---------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { padding: 14px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); }
.stat small {
  display: block;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted);
}
.stat b { display: block; margin-top: 2px; font-size: 20px; letter-spacing: -.01em; }
.stat b.ok { color: var(--ok); }
.stat b.bad { color: var(--bad); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.toolbar .card-title { margin: 0; }
.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12px; font-weight: 700;
  background: var(--surface-2); color: var(--muted);
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.entry-meta { display: block; font-size: 13px; color: var(--muted); font-weight: 500; }
.detail .mini { margin-top: 0; }
.empty { margin: 0; padding: 18px 0 4px; text-align: center; color: var(--muted); font-size: 14px; list-style: none; }
.hint { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.mt { margin-top: 14px; }
code { padding: 1px 6px; border-radius: 6px; background: var(--surface-2); font: 600 .9em var(--mono); }

.foot { padding: 8px 16px 36px; text-align: center; font-size: 13px; color: var(--faint); }

@media (max-width: 480px) {
  .stat { padding: 12px 7px; }
  .stat small { font-size: 10px; letter-spacing: 0; text-transform: none; }
  .stat b { font-size: 15px; }
}

@media (min-width: 420px) {
  .tabs.leagues { grid-template-columns: repeat(4, 1fr); } /* as 4 ligas do admin numa linha; no celular estreito, 2×2 */
}

@media (min-width: 560px) {
  .card { padding: 26px; }
  .sumbar { margin: 22px -26px -26px; padding-left: 26px; padding-right: 26px; }
  .pct-input { width: 112px; }
  .podium { gap: 16px; }
  .pname { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
