:root {
  --ink: #12202c; --muted: #5b6d7b; --paper: #eef1f4; --card: #ffffff; --line: #d3dce3; --soft: #e4eaef;
  --home: #1c4fd6; --home-ink: #ffffff; --away: #b8650b; --away-ink: #ffffff;
  --good: #0f8a5a; --warn: #b17800; --bad: #cf2f38;
  --wood: #e6c48d; --wood-line: #fbf6ea; --wood-ink: #7a5524;
  --radius: 10px;
  --display: 'Barlow Condensed', 'Arial Narrow', 'Roboto Condensed', system-ui, sans-serif;
  --body: 'Public Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8eef2; --muted: #93a6b3; --paper: #0e1820; --card: #16242e; --line: #2b4352; --soft: #1e3140;
    --home: #4d7bff; --away: #e08a35; --good: #3ddc97; --warn: #f2b632; --bad: #ff6b6b;
    --wood: #8f7048; --wood-line: #e9dcc0; --wood-ink: #e9dcc0;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.4 var(--body); -webkit-text-size-adjust: 100%; }
body { padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--home); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; letter-spacing: .01em; }
h1 { font-size: 30px; } h2 { font-size: 24px; } h3 { font-size: 19px; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 14px; }
.stack > * + * { margin-top: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Botões */
.btn { min-height: 44px; padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); font-weight: 600; touch-action: manipulation; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--home); border-color: var(--home); color: #fff; }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 4px 12px; font-size: 14px; }
.btn[disabled], .btn.off { opacity: .42; cursor: not-allowed; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.list { display: grid; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); text-align: left; width: 100%; }
a.item { text-decoration: none; color: inherit; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; background: var(--soft); font-size: 13px; font-weight: 600; }
.pill.live { background: var(--bad); color: #fff; }
.pill.ok { background: var(--good); color: #fff; }

/* Campos */
label.field { display: block; font-size: 14px; font-weight: 600; }
label.field > span { display: block; margin-bottom: 4px; color: var(--muted); font-weight: 500; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
}
textarea { min-height: 120px; font-family: var(--body); }
.err { color: var(--bad); font-weight: 600; margin: 8px 0 0; }

/* Topo */
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar .title { font-family: var(--display); font-size: 22px; font-weight: 700; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); display: inline-block; }
.dot.on { background: var(--good); }

/* Login */
.login { max-width: 380px; margin: 12vh auto 0; padding: 14px; }
.login h1 { font-size: 38px; line-height: 1; margin-bottom: 4px; }

/* Marcador */
.board { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 6; }
.board-main { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 8px 12px 4px; max-width: 1100px; margin: 0 auto; }
.team-box { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.team-box.away { text-align: right; align-items: flex-end; }
.team-name { font-family: var(--display); font-size: 20px; font-weight: 600; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.team-box.home .team-name { color: var(--home); } .team-box.away .team-name { color: var(--away); }
.score { font-family: var(--display); font-size: 58px; font-weight: 700; line-height: .95; font-variant-numeric: tabular-nums; }
.clock-box { text-align: center; }
.clock { font-family: var(--display); font-size: 46px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; min-width: 4.4ch; }
.clock.run { color: var(--good); } .clock.end { color: var(--bad); }
.period { font-weight: 600; font-size: 14px; color: var(--muted); }
.team-meta { display: flex; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.team-box.away .team-meta { justify-content: flex-end; }
.chip { padding: 1px 8px; border-radius: 99px; background: var(--soft); font-weight: 600; }
.chip.bonus { background: var(--bad); color: #fff; }
.board-actions { display: flex; gap: 8px; justify-content: center; padding: 4px 12px 8px; flex-wrap: wrap; max-width: 1100px; margin: 0 auto; }
.tabs { display: flex; gap: 2px; padding: 0 8px; border-top: 1px solid var(--line); max-width: 1100px; margin: 0 auto; }
.tab { flex: 1; min-height: 44px; border: 0; background: none; font-weight: 600; border-bottom: 3px solid transparent; color: var(--muted); }
.tab.on { color: var(--ink); border-bottom-color: var(--home); }
.net { position: fixed; right: 10px; bottom: 10px; background: var(--bad); color: #fff; padding: 6px 12px; border-radius: 99px; font-weight: 600; font-size: 14px; z-index: 30; }

/* Mesa */
.mesa { display: grid; gap: 12px; padding: 12px; max-width: 1100px; margin: 0 auto; }
@media (min-width: 900px) { .mesa { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: start; } }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg button { min-height: 46px; border-radius: var(--radius); border: 2px solid var(--line); background: var(--card); font-family: var(--display); font-size: 20px; font-weight: 700; }
.seg button.home.on { background: var(--home); border-color: var(--home); color: #fff; }
.seg button.away.on { background: var(--away); border-color: var(--away); color: #fff; }
.court { width: 100%; height: auto; display: block; border-radius: var(--radius); border: 1px solid var(--line); background: var(--wood); touch-action: manipulation; }
.court .ln { fill: none; stroke: var(--wood-line); stroke-width: 3; }
.court .pl { cursor: pointer; }
.court .pl .disc { stroke-width: 4; }
.court .pl:focus-visible .disc { stroke: var(--ink); }
.court .num { font-family: var(--display); font-weight: 700; font-size: 38px; fill: #fff; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.court .nm { font-family: var(--body); font-weight: 700; font-size: 17px; fill: var(--ink); text-anchor: middle; paint-order: stroke; stroke: var(--wood); stroke-width: 4px; }
.court .st { font-family: var(--body); font-weight: 600; font-size: 15px; fill: var(--ink); text-anchor: middle; paint-order: stroke; stroke: var(--wood); stroke-width: 4px; }
.court .empty { fill: none; stroke: var(--wood-line); stroke-width: 3; stroke-dasharray: 6 6; }
.bench { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.chip-p { display: flex; flex-direction: column; align-items: flex-start; gap: 0; min-height: 66px; padding: 8px 10px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); text-align: left; }
.chip-p .n { font-family: var(--display); font-size: 28px; font-weight: 700; line-height: 1; }
.chip-p .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.chip-p.out { opacity: .5; text-decoration: line-through; }
.fdots { display: inline-flex; gap: 3px; margin-top: 2px; }
.fdots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.fdots i.f { background: var(--warn); } .fdots i.x { background: var(--bad); }

/* Pop-up */
#modal-root .scrim { position: fixed; inset: 0; background: rgba(8, 16, 24, .55); display: flex; align-items: flex-end; justify-content: center; z-index: 40; }
.sheet { background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0)); }
@media (min-width: 700px) { #modal-root .scrim { align-items: center; } .sheet { border-radius: 18px; } }
.sheet h2 { font-size: 26px; }
.sheet .sub { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.grp { margin-top: 12px; }
.grp > b { display: block; font-size: 14px; margin-bottom: 6px; color: var(--muted); font-weight: 600; }
.btns { display: grid; gap: 8px; }
.btns.c3 { grid-template-columns: repeat(3, 1fr); } .btns.c4 { grid-template-columns: repeat(4, 1fr); } .btns.c2 { grid-template-columns: repeat(2, 1fr); } .btns.c6 { grid-template-columns: repeat(3, 1fr); }
.act { min-height: 52px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--soft); font-weight: 600; line-height: 1.15; padding: 4px 6px; touch-action: manipulation; }
.act.pos { background: var(--good); border-color: var(--good); color: #fff; }
.act.neg { background: var(--card); }
.act.foul { background: var(--card); border-color: var(--warn); }
.act small { display: block; font-weight: 500; font-size: 12px; opacity: .85; }
.act.off { opacity: .4; }
.pick { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); text-align: left; }
.pick .n { font-family: var(--display); font-size: 28px; font-weight: 700; min-width: 2ch; }

/* Toast */
#toast-root { position: fixed; left: 0; right: 0; bottom: calc(14px + env(safe-area-inset-bottom, 0)); display: flex; justify-content: center; z-index: 50; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; background: var(--ink); color: var(--paper); padding: 8px 8px 8px 16px; border-radius: 99px; font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
.toast button { min-height: 36px; padding: 4px 14px; border-radius: 99px; border: 0; background: var(--paper); color: var(--ink); font-weight: 700; }

/* Tabelas */
.tscroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table.box { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 15px; }
.box th, .box td { padding: 8px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.box th { font-weight: 600; color: var(--muted); font-size: 13px; position: sticky; top: 0; background: var(--card); }
.box td:first-child, .box th:first-child { text-align: left; position: sticky; left: 0; background: var(--card); }
.box tr.tot td { font-weight: 700; border-top: 2px solid var(--ink); }
.box td.on-court::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); margin-right: 6px; }
.box .pm.pos { color: var(--good); } .box .pm.neg { color: var(--bad); }

/* Registo */
.log { display: grid; gap: 6px; }
.log-i { display: grid; grid-template-columns: 74px 1fr auto; gap: 10px; align-items: center; padding: 8px 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.log-i.void { opacity: .5; } .log-i.void .what { text-decoration: line-through; }
.log-i .when { font-family: var(--display); font-weight: 700; font-size: 18px; line-height: 1.1; }
.log-i .when small { display: block; font-family: var(--body); font-weight: 500; font-size: 12px; color: var(--muted); }
.tag { display: inline-block; padding: 0 8px; border-radius: 99px; font-weight: 700; font-size: 12px; color: #fff; margin-right: 6px; }
.tag.home { background: var(--home); } .tag.away { background: var(--away); }

/* Tarefas */
.matrix th, .matrix td { text-align: center; } .matrix td:first-child, .matrix th:first-child { text-align: left; }
.matrix input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--home); }

.empty-state { text-align: center; padding: 28px 14px; color: var(--muted); }
.sel-row { display: grid; grid-template-columns: 38px 1fr 120px; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.sel-row .n { font-family: var(--display); font-weight: 700; font-size: 22px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.act b { display: block; font-family: var(--display); font-size: 24px; line-height: 1; font-weight: 700; }
