:root {
  --verde: #e6f4e6;
  --verde-forte: #2e7d32;
  --verde-borda: #b7ddb7;
  --rosa: #fdeaef;
  --rosa-forte: #c2185b;
  --rosa-borda: #f3c3d0;
  --linha: #dcdcdc;
  --texto: #1a1a1a;
  --fraco: #6b6b6b;
  --fundo: #f5f5f4;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fundo);
  color: var(--texto);
  font-size: 15px;
  padding-bottom: 90px;
}

header {
  background: #fff;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--linha);
  position: sticky; top: 0; z-index: 20;
}
h1 { margin: 0 0 8px; font-size: 17px; letter-spacing: -0.2px; }

.geral { display: flex; gap: 8px; align-items: stretch; }
.geral .lado {
  flex: 1; border-radius: 8px; padding: 7px 10px; text-align: center;
  border: 1px solid;
}
.geral .v { background: var(--verde); border-color: var(--verde-borda); }
.geral .r { background: var(--rosa); border-color: var(--rosa-borda); }
.geral .nome { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--fraco); }
.geral .pts { font-size: 24px; font-weight: 700; line-height: 1.1; }
.geral .v .pts { color: var(--verde-forte); }
.geral .r .pts { color: var(--rosa-forte); }
.geral .saldo { font-size: 11px; color: var(--fraco); }

.status { font-size: 11px; color: var(--fraco); margin-top: 6px; min-height: 14px; }
.status.erro { color: #c62828; font-weight: 600; }
.status.ok { color: var(--verde-forte); }

.abas {
  display: flex; gap: 4px; padding: 8px 10px; overflow-x: auto;
  background: #fff; border-bottom: 1px solid var(--linha);
  position: sticky; top: 0; z-index: 10;
}
.abas button {
  flex: 0 0 auto; border: 1px solid var(--linha); background: #fff;
  padding: 8px 14px; border-radius: 999px; font-size: 14px; cursor: pointer;
  color: var(--fraco); font-family: inherit;
}
.abas button.ativa { background: var(--texto); color: #fff; border-color: var(--texto); }

main { padding: 12px 10px; max-width: 900px; margin: 0 auto; }

h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.6px;
  margin: 20px 0 8px; color: var(--fraco);
}
h2:first-child { margin-top: 4px; }

.rodada { font-size: 12px; font-weight: 700; color: var(--fraco); margin: 14px 0 6px; }

.jogo {
  background: #fff; border: 1px solid var(--linha); border-radius: 10px;
  padding: 8px 10px; margin-bottom: 6px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px;
}
.jogo.feito { border-color: #c8c8c8; }
.jogo .lado { font-size: 14px; line-height: 1.25; }
.jogo .lado.v { text-align: right; }
.jogo .lado.r { text-align: left; }
.jogo .lado small { display: block; font-size: 10px; color: var(--fraco); text-transform: uppercase; letter-spacing: 0.4px; }
.jogo .venceu { font-weight: 700; }
.jogo .perdeu { color: var(--fraco); }
.jogo .placar { display: flex; align-items: center; gap: 4px; }
.jogo input {
  width: 46px; height: 44px; text-align: center; font-size: 19px; font-weight: 700;
  border: 1px solid var(--linha); border-radius: 8px; background: var(--fundo);
  font-family: inherit; color: var(--texto);
}
.jogo input:focus { outline: 2px solid #1976d2; outline-offset: -1px; background: #fff; }
.jogo input.v { border-color: var(--verde-borda); }
.jogo input.r { border-color: var(--rosa-borda); }
.jogo .x { color: #bbb; font-size: 13px; }
.jogo .quadra { font-size: 10px; color: var(--fraco); }

table { width: 100%; border-collapse: collapse; background: #fff; font-size: 13px; }
table th, table td { border: 1px solid var(--linha); padding: 6px 7px; text-align: center; }
table th { background: #f0f0ef; font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--fraco); font-weight: 600; }
table td.nome, table th.nome { text-align: left; }
tr.tv td.nome { background: var(--verde); }
tr.tr td.nome { background: var(--rosa); }
td.pos { font-weight: 700; width: 34px; }
tr.classificado td { background: #fffbe6; }
tr.classificado td.nome { background: #fff3c4; }
.empate { color: #b26a00; font-size: 11px; margin: 4px 0 0; }

.aviso {
  background: #fff8e1; border: 1px solid #ffe082; border-radius: 8px;
  padding: 8px 10px; font-size: 12px; margin: 8px 0;
}

.escolha { display: flex; gap: 6px; align-items: center; margin: 6px 0; font-size: 13px; flex-wrap: wrap; }
.escolha select { padding: 7px; border-radius: 8px; border: 1px solid var(--linha); font-family: inherit; font-size: 13px; max-width: 100%; }

footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff; border-top: 1px solid var(--linha);
  padding: 10px; display: flex; gap: 8px; justify-content: center;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
}
.btn {
  border: 1px solid var(--linha); background: #fff; color: var(--texto);
  padding: 9px 14px; border-radius: 8px; font-size: 13px; cursor: pointer; font-family: inherit;
}
.btn.perigo { color: #c62828; border-color: #ffcdd2; }

@media (max-width: 420px) {
  .jogo { grid-template-columns: 1fr auto 1fr; gap: 4px; padding: 7px 8px; }
  .jogo .lado { font-size: 13px; }
  .jogo input { width: 42px; height: 42px; font-size: 18px; }
  table { font-size: 12px; }
  table th, table td { padding: 5px 4px; }
}

@media print {
  header, .abas, footer, .jogo input { display: none !important; }
  body { background: #fff; padding: 0; }
  .impresso { display: block !important; }
}

tr.indefinido td { background: #fff3e0; }
tr.indefinido td.nome { background: #ffe0b2; }
tr.indefinido td.pos { color: #b26a00; }

.escolha.formato { background: #fff; border: 1px solid var(--linha); border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; }
.escolha.formato select { flex: 1; min-width: 180px; }
.jogo.fora-regra { border-color: #e57373; background: #fff5f5; }
.jogo.fora-regra input { border-color: #e57373; background: #ffebee; }

/* ============ PAINEL PÚBLICO (somente leitura) ============ */

body.painel {
  padding-bottom: 24px;
  background: linear-gradient(180deg, #fafaf9 0%, #f2f2f0 100%);
  background-attachment: fixed;
}

body.painel header {
  background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  border-bottom: none;
  padding: 16px 14px 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,.18);
}
body.painel h1 {
  color: #fff; font-size: 15px; font-weight: 600;
  letter-spacing: 1.4px; text-transform: uppercase;
  text-align: center; margin-bottom: 12px; opacity: .85;
}
body.painel .geral { gap: 10px; }
body.painel .geral .lado {
  border: none; border-radius: 14px; padding: 12px 8px;
  box-shadow: 0 3px 10px rgba(0,0,0,.22);
}
body.painel .geral .v { background: linear-gradient(160deg, #dcf0dc, #b9e2b9); }
body.painel .geral .r { background: linear-gradient(160deg, #fde3ea, #f7c3d2); }
body.painel .geral .nome { font-size: 10px; font-weight: 700; letter-spacing: 1.4px; opacity: .75; }
body.painel .geral .pts { font-size: 42px; font-weight: 800; letter-spacing: -1.5px; }
body.painel .geral .saldo { font-size: 11px; opacity: .7; }
body.painel .status { color: #9ca3af; text-align: center; margin-top: 9px; }
body.painel .status.erro { color: #fca5a5; }

body.painel .abas { background: transparent; border-bottom: none; padding: 12px 10px 4px; justify-content: center; }
body.painel .abas button { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.07); border-color: transparent; }
body.painel .abas button.ativa { background: #111827; box-shadow: 0 2px 8px rgba(17,24,39,.3); }

/* faixa com o placar da categoria */
.placar-cat {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  background: #fff; border-radius: 14px; padding: 14px 12px; margin-bottom: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  font-size: 20px; font-weight: 700;
}
.placar-cat .v { color: var(--verde-forte); }
.placar-cat .r { color: var(--rosa-forte); }
.placar-cat .sep { color: #cbd5e1; font-weight: 400; }
.placar-cat small { flex-basis: 100%; text-align: center; font-size: 11px; font-weight: 400; color: var(--fraco); }

body.painel h2 { text-align: center; margin: 18px 0 8px; }
body.painel .rodada { text-align: center; margin: 14px 0 6px; }

body.painel table { border-radius: 12px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.06); border-collapse: separate; border-spacing: 0; }
body.painel table th, body.painel table td { border: none; border-bottom: 1px solid #eee; }
body.painel table tr:last-child td { border-bottom: none; }

/* linha de jogo do painel: nome | placar | nome */
body.painel .jogo {
  grid-template-columns: 1fr auto 1fr;
  border: none; border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.06);
  padding: 10px 12px; gap: 8px;
}
body.painel .jogo.aguardando { opacity: .5; }
body.painel .jogo .lado { font-size: 13.5px; }
body.painel .jogo .lado.v { text-align: right; }
body.painel .jogo .lado.r { text-align: left; }
.jogo .resultado {
  min-width: 62px; text-align: center; font-size: 17px; font-weight: 800;
  background: var(--fundo); border-radius: 8px; padding: 5px 8px; color: #111;
  font-variant-numeric: tabular-nums;
}
.jogo.aguardando .resultado { font-size: 11px; font-weight: 600; color: var(--fraco); }
body.painel .jogo.final { border: 2px solid #fbbf24; background: #fffdf5; }
.campea {
  text-align: center; background: #fef3c7; border-radius: 10px;
  padding: 9px 12px; margin: -2px 0 8px; font-weight: 700; font-size: 14px; color: #92400e;
}

@media (min-width: 700px) {
  body.painel .geral .pts { font-size: 56px; }
  body.painel h1 { font-size: 18px; }
  .placar-cat { font-size: 26px; }
  body.painel main { max-width: 720px; }
}

@media (max-width: 380px) {
  body.painel .geral .pts { font-size: 34px; }
  body.painel .jogo .lado { font-size: 12.5px; }
  .jogo .resultado { min-width: 54px; font-size: 15px; padding: 4px 6px; }
}

.parcial {
  text-align: center; background: #eef2ff; border: 1px solid #c7d2fe; color: #3730a3;
  border-radius: 10px; padding: 7px 12px; margin: 10px 0 2px; font-size: 12px; font-weight: 600;
}
