:root {
  --bg: #f2f5f3; --card: #ffffff; --txt: #142019; --muted: #627068; --line: #dde5e0;
  --pri: #0a8f4a; --pri-txt: #ffffff; --pri-soft: #e1f4e9; --acc: #f5b301;
  --p6: #0a8f4a; --p3: #2f9e5b; --p2: #79b93c; --p1: #b9a31a; --p0: #c9d1cc;
  --danger: #c62828; --warn: #b26a00; --warn-soft: #fff3dc; --info: #1565c0; --info-soft: #e3eefc;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
  --r: 14px; --tab-h: 64px; --head-h: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1411; --card: #16201b; --txt: #e6eee9; --muted: #92a39a; --line: #26332c;
    --pri: #22b765; --pri-txt: #04140a; --pri-soft: #183526; --acc: #ffc933;
    --p6: #22b765; --p3: #3fa868; --p2: #8cc84b; --p1: #cdb83a; --p0: #3a4740;
    --danger: #ff6b6b; --warn: #ffb74d; --warn-soft: #3a2c12; --info: #64a8ff; --info-soft: #14263f;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--txt);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-top: calc(var(--head-h) + env(safe-area-inset-top));
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px);
}
body.no-scroll { overflow: hidden; }
a { color: var(--pri); }
h2, h3, h4 { margin: 0 0 8px; line-height: 1.2; }
h2 { font-size: 1.35rem; } h3 { font-size: 1.05rem; } h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
code { background: var(--pri-soft); padding: 1px 5px; border-radius: 5px; }

/* Topo */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 20; height: calc(var(--head-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0; display: flex; align-items: center; gap: 8px;
  background: var(--pri); color: var(--pri-txt); box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.05rem; color: inherit; text-decoration: none; }
.brand img { width: 30px; height: 30px; }
.chip { margin-left: auto; min-height: 36px; padding: 0 12px; border-radius: 99px; border: 1px solid rgba(255,255,255,.4); background: rgba(255,255,255,.12); color: inherit; font: inherit; font-size: .85rem; cursor: pointer; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-admin { font-size: .7rem; font-weight: 800; background: var(--acc); color: #111; border-radius: 6px; padding: 2px 6px; }
.topbar .icon-btn { color: inherit; }
.topbar .icon-btn.ativo { background: rgba(255,255,255,.2); }

main { max-width: 760px; margin: 0 auto; padding: 12px 12px 0; }

/* Navegação inferior */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 20; display: flex; justify-content: center;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; max-width: 152px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .7rem; font-weight: 600; min-height: 44px;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.ativo { color: var(--pri); }
.tabbar a.ativo svg { transform: translateY(-1px); }

/* Componentes */
.card { background: var(--card); border-radius: var(--r); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.hero { background: linear-gradient(135deg, var(--pri), #066a37); color: #fff; border: 0; }
.hero .muted, .hero .small { color: rgba(255,255,255,.85); }
.hero .btn { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.4); }
.hero .btn.primary { background: #fff; color: #066a37; }
.countdown { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .card { margin-bottom: 12px; }
.lider-nome { font-size: 1.2rem; font-weight: 800; overflow-wrap: anywhere; }
.lider-pts { color: var(--pri); font-weight: 700; }
.stats4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; margin: 4px 0 8px; }
.stats4 b { display: block; font-size: 1.3rem; }
.stats4 span { font-size: .72rem; color: var(--muted); }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; gap: 8px; }
.row.end { justify-content: flex-end; }
.row.gap { gap: 8px; } .row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--muted); } .small { font-size: .82rem; } .center { text-align: center; }
.sub { color: var(--muted); font-size: .85rem; margin: 4px 2px 12px; }
.titulo-tela { margin: 4px 2px 12px; }
.vazio-box { text-align: center; color: var(--muted); padding: 28px 16px; }
.aviso { background: var(--warn-soft); color: var(--warn); padding: 10px; border-radius: 10px; font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--txt);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--pri); color: var(--pri-txt); border-color: var(--pri); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.block { display: flex; width: 100%; margin-top: 8px; }
.btn.sm { min-height: 40px; padding: 0 10px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { min-width: 44px; min-height: 44px; border: 0; background: transparent; color: var(--txt); font-size: 1.2rem; border-radius: 12px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.icon-btn.lg { font-size: 1.8rem; background: var(--card); border: 1px solid var(--line); }
.icon-btn:disabled { opacity: .35; }
.tag { display: inline-block; font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--line); color: var(--muted); white-space: nowrap; vertical-align: middle; }
.tag.ok { background: var(--pri-soft); color: var(--pri); }
.tag.info { background: var(--info-soft); color: var(--info); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.hero .tag { background: rgba(255,255,255,.2); color: #fff; }

input, select, textarea {
  font: inherit; color: var(--txt); background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  min-height: 44px; padding: 8px 10px; width: 100%; max-width: 100%;
}
textarea { resize: vertical; margin: 8px 0; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible, tr:focus-visible { outline: 2px solid var(--pri); outline-offset: 1px; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.field > span { font-size: .78rem; color: var(--muted); font-weight: 600; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 22px; height: 22px; min-height: 0; }
.admin-box { border: 1px dashed var(--acc); }
details summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; }

.seletor { display: flex; gap: 8px; align-items: center; }
.seletor select { flex: 1; font-weight: 700; text-align: center; }
.segmented { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 8px; }
.segmented button { flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-weight: 700; cursor: pointer; }
.segmented button.on { background: var(--pri); color: var(--pri-txt); }

/* Ranking */
.ranking { list-style: none; padding: 0; margin: 0; }
.ranking li { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--line); min-height: 44px; }
.ranking li:last-child { border-bottom: 0; }
.ranking .pos { width: 26px; height: 26px; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-size: .78rem; font-weight: 800; flex: none; }
.ranking li:nth-child(1) .pos { background: var(--acc); color: #111; }
.ranking .nome { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.pgv { font-size: 1.1rem; min-width: 36px; text-align: right; }
li.eu, tr.eu { background: var(--pri-soft); }
.mini-rank { margin: 6px 0; padding-left: 20px; }
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); min-height: 48px; }
.lista li > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.lista select { width: auto; max-width: 60%; }
.totais { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin-top: 10px; }
.totais div { background: var(--bg); border-radius: 10px; padding: 8px; text-align: center; }
.totais span { display: block; font-size: .7rem; color: var(--muted); font-weight: 700; }

/* Jogos */
.jogo-top, .palp-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 28px; }
.jogo-top .icon-btn { margin-left: auto; }
.placar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin: 6px 0 10px; }
.time { font-weight: 700; overflow-wrap: anywhere; }
.time.casa { text-align: right; } .time.fora { text-align: left; }
.gols { font-size: 1.5rem; font-weight: 800; min-width: 74px; text-align: center; background: var(--bg); border-radius: 10px; padding: 2px 8px; font-variant-numeric: tabular-nums; }
.gols small { font-size: .9rem; color: var(--muted); margin: 0 6px; }
.palpites { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 6px; }
.pchip { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: var(--bg); border-radius: 10px; padding: 8px 6px; text-align: center; min-height: 68px; }
.pchip .ptop { display: flex; align-items: center; justify-content: center; gap: 6px; max-width: 100%; min-height: 24px; }
.pchip .pn { min-width: 0; font-size: .85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pchip .pl { display: flex; align-items: center; justify-content: center; gap: 6px; }
.pchip .pv { font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.pchip .pv small { font-size: .7rem; font-weight: 400; opacity: .6; margin: 0 2px; }
.pchip.vazio { opacity: .55; }
.star { color: var(--acc); margin-left: 2px; }
.star.anulada { text-decoration: line-through; opacity: .6; }
.pts { display: inline-grid; place-items: center; min-width: 24px; height: 24px; border-radius: 7px; font-size: .8rem; font-weight: 800; color: #fff; padding: 0 4px; }
.pts.p6 { background: var(--p6); box-shadow: 0 0 0 2px var(--acc); } .pts.p3 { background: var(--p3); } .pts.p2 { background: var(--p2); }
.pts.p1 { background: var(--p1); } .pts.p0 { background: var(--p0); color: var(--muted); }

/* Palpitar */
.palp.bloq { opacity: .7; }
.palp.sorte { border-color: var(--acc); box-shadow: 0 0 0 1px var(--acc), var(--shadow); }
.palp-grid { display: grid; grid-template-columns: 1fr auto auto auto 1fr; align-items: center; gap: 6px; margin-top: 6px; }
.stepper { display: flex; flex-direction: column; align-items: center; background: var(--bg); border-radius: 12px; overflow: hidden; }
.stepper button { width: 48px; height: 40px; border: 0; background: transparent; color: var(--pri); font-size: 1.5rem; font-weight: 800; cursor: pointer; }
.stepper button:disabled { color: var(--muted); opacity: .4; }
.stepper output { font-size: 1.6rem; font-weight: 800; min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; }
.star-btn { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); background: var(--card); color: var(--line); font-size: 1.3rem; cursor: pointer; }
.star-btn.on { color: #111; background: var(--acc); border-color: var(--acc); }
.palp-grid .time { font-size: .9rem; }
.acoes-fixas {
  position: sticky; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 8px); z-index: 5; display: flex; gap: 8px;
  padding: 8px; margin: 0 -4px 12px; background: var(--card); border-radius: 14px; box-shadow: 0 4px 18px rgba(0,0,0,.18); border: 1px solid var(--line);
}

/* Tabelas */
.tabela-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 0; }
.tabela { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
.tabela th, .tabela td { padding: 10px 8px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tabela th { font-size: .72rem; color: var(--muted); text-transform: uppercase; position: sticky; top: 0; background: var(--card); }
.tabela .l { text-align: left; }
.tabela td.nome { font-weight: 700; position: sticky; left: 0; background: var(--card); }
.tabela tbody tr[data-nome] { cursor: pointer; }
.tabela tr.eu td.nome { background: var(--pri-soft); }
.tabela tr.top1 td:first-child { color: var(--acc); font-weight: 800; }
.tabela tr.corte td { border-bottom: 2px dashed var(--pri); }
.tabela tr.fora { opacity: .6; }
.tabela.compacta th, .tabela.compacta td { padding: 6px; font-size: .75rem; }
.grafico { width: 100%; height: 130px; margin: 6px 0 10px; }
.grafico .bar { fill: var(--p3); } .grafico .bar.max { fill: var(--acc); }
.grafico text { font-size: 8px; fill: var(--muted); }

.regras ul { padding-left: 18px; margin: 0; } .regras li { margin-bottom: 6px; }

/* Modal e toast */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--card); width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 0 16px calc(16px + env(safe-area-inset-bottom)); animation: sobe .2s ease-out; }
.modal-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--card); padding: 10px 0; }
.modal-head h2 { margin: 0; font-size: 1.1rem; }
@keyframes sobe { from { transform: translateY(30px); opacity: 0; } }
#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 12px); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; padding: 0 12px; }
.toast { background: #1d2a23; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: .9rem; max-width: 480px; box-shadow: 0 4px 16px rgba(0,0,0,.3); opacity: 0; transform: translateY(10px); transition: .25s; }
.toast.show { opacity: 1; transform: none; }
.toast.ok { background: #0a7a3f; } .toast.erro { background: #b3261e; }

@media (min-width: 768px) {
  .modal-bg { align-items: center; }
  .modal { border-radius: 18px; }
  main { padding-top: 20px; }
}
@media (max-width: 380px) {
  .stepper button { width: 40px; } .stepper output { min-width: 40px; font-size: 1.4rem; }
  .palp-grid .time { font-size: .8rem; }
  .stats4 b { font-size: 1.1rem; }
}

/* Login e menu do usuário */
.login-wrap { min-height: 70vh; display: flex; align-items: center; justify-content: center; }
.login { width: 100%; max-width: 380px; text-align: center; }
.login img { width: 72px; height: 72px; margin: 4px auto 8px; display: block; }
.login form { text-align: left; }
body.deslogado .tabbar, body.deslogado #temporada-chip, body.deslogado #cfg-btn, body.deslogado #user-btn { display: none; }
#user-btn { margin-left: 0; max-width: 32vw; }
.senha-gerada { font: 700 1.3rem/1.2 ui-monospace, Consolas, monospace; letter-spacing: .08em; text-align: center; padding: 12px; border: 2px dashed var(--pri); border-radius: var(--r); background: var(--pri-soft); user-select: all; }
.pchip.oculto .pv { font-size: .8rem; font-weight: 600; }
.pchip.oculto.sim .pv { color: var(--pri); }
.usuario-linha { display: flex; flex-direction: column; gap: 6px; align-items: stretch !important; }
.usuario-linha .row { flex-wrap: wrap; }

/* Topo no celular: esconde o texto da marca e encurta os chips para caber tudo */
@media (max-width: 420px) {
  .topbar .brand span { display: none; }
  .topbar .chip { max-width: 34vw; padding: 0 10px; font-size: .8rem; }
  .topbar #temporada-chip { margin-left: auto; }
  .topbar #user-btn { margin-left: 0; }
}
