:root {
  --bg: #0b0f17;
  --panel: #131a26;
  --panel-2: #1a2333;
  --line: #263247;
  --text: #e8edf5;
  --muted: #a3b0c4;
  --faint: #6f7d93;
  --accent: #7c3aed;
  --ok: #22c55e;
  --warn: #f59e0b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; }
h1 { font-size: 1.6rem; margin: 0 0 4px; line-height: 1.2; }
h2 { font-size: 1.05rem; margin: 18px 0 10px; color: var(--muted); }
h2::first-letter { text-transform: uppercase; }
h3 { font-size: .8rem; margin: 0 0 8px; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .82rem; }
.strong { font-weight: 700; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 6px; }
.empty { color: var(--muted); padding: 24px 0; }
button { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; font: inherit; cursor: pointer; }

.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: rgba(11, 15, 23, .92); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; }
.brand img { width: 32px; height: 32px; object-fit: contain; border-radius: 6px; }
.live { font-size: .78rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .live i { animation: none; } }

main { max-width: 1100px; margin: 0 auto; padding: 16px; min-height: 70vh; }
.foot { max-width: 1100px; margin: 0 auto; padding: 16px; color: var(--faint); font-size: .8rem; border-top: 1px solid var(--line); }

.hero { padding: 6px 0 4px; }
.champion { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: color-mix(in srgb, var(--ok) 14%, var(--panel)); border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); font-weight: 700; }
.champion div { margin-top: 4px; font-weight: 600; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.badge.accent { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--text); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.badge.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: #bbf7d0; border-color: transparent; }
.badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: #fde68a; border-color: transparent; }
.warn-text { color: #fde68a; }

.tabs { display: flex; gap: 4px; overflow-x: auto; margin: 16px -16px 8px; padding: 0 16px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 10px 12px; text-decoration: none; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--text); border-color: var(--accent); font-weight: 600; }

.cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.tcard { display: flex; flex-direction: column; gap: 4px; text-decoration: none; }
.tcard:hover { border-color: var(--accent); }
.tcard .badge { align-self: flex-start; margin-top: 6px; }

.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.match { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.match .meta { font-size: .78rem; color: var(--faint); }
.match .teams { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; font-weight: 600; }
.match .teams > span:last-child { text-align: right; }
.match .win { color: #fff; }
.match .teams > span:not(.score):not(.vs):not(.win) { color: var(--muted); }
.score { font-size: 1.25rem; font-weight: 800; padding: 2px 10px; border-radius: 8px; background: var(--panel-2); font-variant-numeric: tabular-nums; }
.vs { color: var(--faint); font-size: .85rem; }
.sets { text-align: center; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--faint); font-weight: 600; font-size: .78rem; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.out td { color: var(--faint); text-decoration: line-through; }
tbody tr:nth-child(-n+2) td:first-child { color: var(--accent); font-weight: 700; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filter { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; color: var(--faint); min-width: 150px; flex: 1 1 150px; }
.filter select { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font: inherit; font-size: .95rem; }

.bracket { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 8px; }
.round { display: flex; flex-direction: column; min-width: 210px; }
.round .col { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 12px; }
.bm { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; }
.bm > div { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); }
.bm > div.win { color: var(--text); font-weight: 700; }
.bm b { font-variant-numeric: tabular-nums; }
.bm.bye { opacity: .6; }
.bm small { font-size: .74rem; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); text-decoration: none; }
.chip:hover { border-color: var(--accent); }

@media (max-width: 520px) {
  h1 { font-size: 1.35rem; }
  .grid { grid-template-columns: 1fr; }
}

/* Marcador en vivo */
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.big { padding: 14px 18px; font-size: 1.05rem; }
button:disabled { opacity: .45; cursor: default; }
.match.is-live { border-color: color-mix(in srgb, #ef4444 55%, var(--line)); }
.live-badge { background: color-mix(in srgb, #ef4444 20%, transparent); color: #fecaca; border-color: transparent; display: inline-flex; align-items: center; gap: 6px; }
.live-badge i { width: 7px; height: 7px; border-radius: 50%; background: #ef4444; animation: pulse 1.4s infinite; }
@media (prefers-reduced-motion: reduce) { .live-badge i { animation: none; } }
.error { color: #fecaca; background: color-mix(in srgb, #ef4444 15%, transparent); border-radius: 8px; padding: 10px 12px; margin: 0; }

/* Planillero */
.pinbox { max-width: 360px; margin: 24px auto; display: flex; flex-direction: column; gap: 12px; }
.pin { font-size: 2rem; letter-spacing: .4em; text-align: center; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); width: 100%; }
.scorer { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.sc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.sc-set { margin: 0; text-align: center; color: var(--muted); font-weight: 600; }
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.side { display: flex; flex-direction: column; gap: 8px; }
.tap { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px 8px; min-height: 220px; justify-content: center; border-radius: 16px; background: var(--panel); border: 2px solid var(--line); touch-action: manipulation; user-select: none; }
.tap:not(:disabled):active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--panel)); }
.tname { font-weight: 700; text-align: center; overflow-wrap: anywhere; }
.tpoints { font-size: 4.5rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.tsets { color: var(--muted); font-size: .9rem; }
.minus { touch-action: manipulation; }
.sc-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sc-actions button { flex: 1 1 140px; padding: 12px; }
