:root {
  --table: #0d2b4e;
  --table-2: #133a66;
  --table-3: #1a4a80;
  --line: rgba(255, 255, 255, 0.16);
  --text: #f5f7fa;
  --muted: #a9bbd0;
  --ball: #ff8a2a;
  --ball-ink: #2a1400;
  --win: #7fe0a8;
  --red: #ff8f87;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--table); color: var(--text);
  font: 16px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
main { max-width: 560px; margin: 0 auto; padding: 16px 14px calc(40px + env(safe-area-inset-bottom)); }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 13px; margin: 24px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 14px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.top small { color: var(--muted); font-size: 14px; white-space: nowrap; }

button {
  font: inherit; font-weight: 600; color: inherit; border: 0; border-radius: 10px; min-height: 48px; padding: 0 16px;
  background: var(--table-3); cursor: pointer; touch-action: manipulation;
}
button:active:not(:disabled) { filter: brightness(1.2); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--ball); color: var(--ball-ink); }
button.ghost { background: transparent; border: 1px solid var(--line); }
button.danger { background: transparent; border: 1px solid var(--line); color: var(--red); }
button.wide { width: 100%; }

nav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; border-bottom: 2px solid var(--line); margin: 0 -14px 16px; position: sticky; top: 0; background: var(--table); z-index: 2; }
nav button { padding: 0 2px; font-size: 14px; background: none; border-radius: 0; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; }
nav button[aria-current="true"] { color: var(--text); border-bottom-color: var(--ball); }

.card { background: var(--table-2); border-radius: 12px; padding: 12px 14px; }
.next { background: var(--table-2); border-radius: 12px; padding: 14px; margin-bottom: 8px; }
.next .who { font-size: 20px; font-weight: 700; margin: 6px 0 12px; overflow-wrap: anywhere; }
.next .who span { color: var(--muted); font-weight: 400; font-size: 15px; margin: 0 4px; }
.eyebrow { font-size: 13px; color: var(--muted); }
.progress { height: 4px; border-radius: 2px; background: var(--table-2); overflow: hidden; margin-bottom: 14px; }
.progress i { display: block; height: 100%; background: var(--ball); }

.match {
  display: grid; grid-template-columns: 36px 1fr auto; gap: 2px 10px; align-items: center; width: 100%; text-align: left;
  background: var(--table-2); border-radius: 10px; padding: 10px 12px; min-height: 60px; margin-bottom: 6px; font-weight: 400;
}
.match:disabled { opacity: 1; }
.match.is-next { outline: 2px solid var(--ball); outline-offset: -2px; }
.match .tag { grid-row: span 2; font-weight: 700; font-size: 13px; color: var(--muted); text-align: center; }
.match .name { overflow-wrap: anywhere; }
.match .name.won { font-weight: 700; color: var(--win); }
.match .name.tbd { color: var(--muted); }
.match .score { font-weight: 700; text-align: right; min-width: 18px; }
.match .detail { grid-column: 2 / 4; font-size: 13px; color: var(--muted); }

.table { width: 100%; border-collapse: collapse; background: var(--table-2); border-radius: 12px; overflow: hidden; font-size: 15px; }
.table th { font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 4px; text-align: center; }
.table td { padding: 10px 4px; text-align: center; border-top: 1px solid var(--line); }
.table .left { text-align: left; }
.table .pos { width: 30px; padding-left: 10px; color: var(--muted); }
.table tr.through td { background: rgba(127, 224, 168, 0.1); }
.table tr.through .pos { color: var(--win); font-weight: 700; }
.table tr.pool td { background: rgba(255, 138, 42, 0.12); }
.table tr.pool .pos { color: var(--ball); font-weight: 700; }
.star { color: var(--ball); font-size: 12px; margin-left: 4px; }
.table .nm { overflow-wrap: anywhere; font-weight: 600; }
.table button.nm { background: none; padding: 0; min-height: 0; text-align: left; font-weight: 600; border-radius: 0; }
.note { margin-top: 8px; font-size: 13px; color: var(--muted); }
.note.warn { color: var(--ball); }

.step { background: var(--table-2); border-radius: 12px; padding: 14px; margin-bottom: 8px; }
.step p { margin-bottom: 12px; }
.step p:last-child { margin-bottom: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 20px; }
.chip { min-height: 44px; padding: 0 14px; border-radius: 22px; background: var(--table-2); border: 1px solid var(--line); font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--ball); color: var(--ball-ink); border-color: var(--ball); font-weight: 700; }
.pair { background: var(--table-2); border-radius: 12px; padding: 10px 14px 12px; margin-bottom: 8px; }
.pair table { width: 100%; border-collapse: collapse; }
.pair th { font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; padding: 2px 0 4px; width: 44px; }
.pair td { text-align: center; padding: 3px 0; }
.pair td.who { text-align: left; overflow-wrap: anywhere; }
.pair td.who.won { font-weight: 700; color: var(--win); }
.pair .sum { font-weight: 700; }
.pair .status { font-size: 13px; color: var(--muted); margin-top: 6px; }
.pair .status.warn { color: var(--ball); font-weight: 600; }
.table td.fase { font-size: 13px; color: var(--muted); }
.table tr.first td { background: rgba(255, 138, 42, 0.16); }
.table tr.first .pos, .table tr.first .fase { color: var(--ball); font-weight: 700; }
.bet-form { display: grid; gap: 12px; background: var(--table-2); border-radius: 12px; padding: 14px; }
.bet-label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.bet-form input, .bet-form select {
  width: 100%; min-width: 0; min-height: 48px; font: inherit; font-size: 16px; color: var(--text);
  background: var(--table); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px;
}
.bet-form input:focus, .bet-form select:focus { outline: 2px solid var(--ball); outline-offset: -1px; }
.bet-form input::placeholder { color: var(--muted); opacity: 0.7; }
.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--table); border-radius: 12px; padding: 4px; }
.segmented.two { grid-template-columns: 1fr 1fr; }
.min-points { font-size: 24px !important; font-weight: 700; text-align: center; height: 56px; }
.segmented button { min-height: 44px; padding: 0 2px; font-size: 14px; background: none; color: var(--muted); }
.segmented button[aria-pressed="true"] { background: var(--table-3); color: var(--text); }
.picks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pick { display: grid; align-content: center; gap: 2px; min-height: 68px; padding: 8px; background: var(--table); border: 2px solid var(--line); overflow-wrap: anywhere; }
.pick small { font-size: 12px; font-weight: 400; color: var(--muted); }
.pick[aria-pressed="true"] { border-color: var(--ball); background: var(--table-3); }
.score-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.score-pick input { height: 56px; font-size: 24px; font-weight: 700; text-align: center; }
.score-pick .bet-label { overflow-wrap: anywhere; align-content: end; }
.side { display: grid; gap: 8px; background: var(--table); border-radius: 10px; padding: 10px; }
.side-head { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.side-row { display: flex; gap: 6px; }
.side-row input { flex: 1; background: var(--table-2); }
.side-row .side-amount { flex: none; width: 72px; text-align: center; }
.side-add { min-height: 40px; font-size: 14px; font-weight: 500; }
.join-form { background: none; padding: 12px 0 0; }
.wager { background: var(--table-2); border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.wager-title { font-weight: 700; margin-bottom: 8px; overflow-wrap: anywhere; }
.wager-side { background: var(--table); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; border-left: 3px solid transparent; }
.wager-side.won { border-left-color: var(--win); }
.wager-side.lost { opacity: 0.75; }
.wager-label { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 2px; overflow-wrap: anywhere; }
.wager-side.won .wager-label { color: var(--win); }
.wager-person { display: flex; align-items: center; gap: 10px; min-height: 28px; font-size: 15px; }
.wager-name { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.wager-x { flex: none; min-height: 28px; width: 28px; padding: 0; background: none; color: var(--muted); font-size: 18px; font-weight: 400; }
.wager-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; min-height: 40px; }
.wager.incomplete .bet-sub { color: var(--ball); font-weight: 600; }
.wager-join { flex: none; min-height: 40px; padding: 0 10px; font-size: 14px; font-weight: 500; }
.debts { background: var(--table-2); border-radius: 12px; padding: 4px 14px; }
.debt { padding: 10px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.debt:first-child { border-top: 0; }
.debt-value { color: var(--ball); }
.debt-line { display: block; color: var(--text); font-size: 14px; margin-top: 2px; }
.table .bet-who { padding-left: 14px; }
.net-up { color: var(--win); font-weight: 700; }
.net-down { color: var(--red); font-weight: 700; }
.bet { display: flex; align-items: center; gap: 8px; background: var(--table-2); border-radius: 10px; padding: 10px 12px; margin-bottom: 6px; overflow-wrap: anywhere; }
.bet-main { flex: 1; min-width: 0; font-size: 15px; }
.bet-sub { font-size: 13px; color: var(--muted); }
.bet.won .bet-status { color: var(--win); font-weight: 600; }
.bet.lost .bet-status { color: var(--red); }
.bet-del { flex: none; min-height: 40px; width: 40px; padding: 0; background: none; border: 1px solid var(--line); color: var(--muted); font-size: 20px; }
.champion { text-align: center; background: var(--ball); color: var(--ball-ink); border-radius: 12px; padding: 20px 14px; margin-bottom: 16px; }
.champion b { display: block; font-size: 30px; line-height: 1.1; overflow-wrap: anywhere; }

textarea {
  display: block; width: 100%; height: 42dvh; min-height: 220px; font: inherit; line-height: 1.6; color: var(--text); background: var(--table-2);
  border: 2px solid var(--muted); border-radius: 12px; padding: 12px 14px; margin: 12px 0 8px; resize: vertical;
}
.field { display: block; font-weight: 600; margin-top: 16px; }
.field textarea { margin-top: 6px; font-weight: 400; }
textarea::placeholder { color: var(--muted); opacity: 0.7; }
textarea:focus { outline: none; border-color: var(--ball); }
.count { margin-bottom: 12px; font-size: 14px; color: var(--muted); }
.count.bad { color: var(--ball); }
.tools { display: grid; gap: 8px; margin-top: 28px; }

dialog { width: min(100%, 560px); max-width: 100%; border: 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); background: var(--table-2); color: var(--text); border-radius: 16px 16px 0 0; margin: auto auto 0; }
dialog::backdrop { background: rgba(0, 12, 28, 0.7); }
.sets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: center; margin: 12px 0; }
.sets .head { font-weight: 700; text-align: center; overflow-wrap: anywhere; font-size: 15px; align-self: end; }
.sets.bo3 { grid-template-columns: 52px 1fr 1fr; }
.sets label { color: var(--muted); font-size: 14px; }
.sets input {
  width: 100%; min-width: 0; height: 56px; font: inherit; font-size: 24px; font-weight: 700; text-align: center; color: var(--text);
  background: var(--table); border: 1px solid var(--line); border-radius: 10px;
}
.sets input:focus { outline: 2px solid var(--ball); outline-offset: -1px; }
.hint { min-height: 22px; margin-bottom: 12px; font-size: 15px; color: var(--muted); }
.hint.ok { color: var(--win); font-weight: 600; }
.hint.bad { color: var(--ball); }
.row { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.sheet-del { margin-top: 8px; }

#toast {
  position: fixed; left: 14px; right: 14px; top: calc(12px + env(safe-area-inset-top)); max-width: 532px; margin: 0 auto; z-index: 10;
  background: #fff; color: #10233a; padding: 12px 14px; border-radius: 10px; font-weight: 600; font-size: 15px;
}
