:root {
  color-scheme: light;
  --bg: #f3f2ef;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e1dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7974;
  --accent: #2a78d6;
  --over: #2a78d6;
  --under: #e34948;
  --push: #a3a29d;
  --grid: #e8e7e3;
  --focus: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #2e2e2b;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8e88;
    --accent: #3987e5;
    --over: #3987e5;
    --under: #e66767;
    --push: #6b6a65;
    --grid: #2a2a27;
    --focus: #6da7ec;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1a1a19;
  --surface-2: #232321;
  --border: #2e2e2b;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #8f8e88;
  --accent: #3987e5;
  --over: #3987e5;
  --under: #e66767;
  --push: #6b6a65;
  --grid: #2a2a27;
  --focus: #6da7ec;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Encabezado */
.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.top-in {
  max-width: 1100px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.logo { font-weight: 800; letter-spacing: -0.02em; font-size: 18px; text-decoration: none; }
.logo span { color: var(--accent); }
.sports { display: flex; gap: 4px; }
.sport {
  padding: 6px 10px; border-radius: 8px; text-decoration: none; font-weight: 600; font-size: 14px;
  color: var(--text-2);
}
.sport[aria-current="page"] { background: var(--surface-2); color: var(--text); }
.sport[aria-disabled="true"] { opacity: .5; cursor: default; }
.search { position: relative; flex: 1 1 220px; max-width: 420px; margin-left: auto; }
.search input {
  width: 100%; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg);
}
.results {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgb(0 0 0 / .18); overflow: hidden; display: none;
}
.results.open { display: block; }
.results a {
  display: flex; justify-content: space-between; gap: 8px; padding: 9px 12px; text-decoration: none;
}
.results a:hover, .results a.sel { background: var(--surface-2); }
.results small { color: var(--muted); }
.theme-btn {
  border: 1px solid var(--border); background: transparent; border-radius: 8px;
  width: 36px; height: 36px; cursor: pointer; color: var(--text-2); display: inline-grid; place-items: center; padding: 0;
}

main { max-width: 1100px; margin: 0 auto; padding: 16px; }
h1 { font-size: 24px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 0 0 10px; }
.sub { color: var(--text-2); margin: 2px 0 0; }
.muted { color: var(--muted); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; margin-top: 14px;
}

/* Partidos del día */
.day-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.game {
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--bg);
}
.game-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 0; }
.game-row a { text-decoration: none; font-weight: 600; }
.game-row a:hover { text-decoration: underline; }
.game-meta { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.score { font-weight: 700; }
.rec { color: var(--muted); font-size: 12px; font-weight: 400; margin-left: 4px; white-space: nowrap; }

/* Controles */
.controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: flex-end; }
.ctl { display: flex; flex-direction: column; gap: 4px; }
.ctl > span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  border: 1px solid var(--border); background: var(--bg); border-radius: 999px;
  padding: 5px 11px; cursor: pointer; font-size: 14px; color: var(--text-2);
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
select {
  border: 1px solid var(--border); background: var(--bg); border-radius: 8px; padding: 6px 8px;
}
.line { display: flex; align-items: center; gap: 4px; }
.line input {
  width: 72px; text-align: center; padding: 6px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); font-weight: 700;
}
.line button {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); cursor: pointer; font-size: 18px; line-height: 1;
}

/* Tiles de acierto */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-top: 14px; }
.tile { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.tile .d { font-size: 13px; color: var(--text-2); }
.tile .bar { height: 4px; border-radius: 2px; background: var(--surface-2); margin-top: 6px; overflow: hidden; }
.tile .bar i { display: block; height: 100%; background: var(--over); border-radius: 2px; }

/* Gráfico */
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--text-2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legend .dash { width: 16px; height: 0; border-top: 2px dashed var(--text-2); border-radius: 0; vertical-align: 3px; }
.legend .solid { width: 16px; height: 0; border-top: 2px solid var(--muted); border-radius: 0; vertical-align: 3px; }
.chart { position: relative; margin-top: 8px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .ref-line { stroke: var(--text-2); stroke-width: 2; stroke-dasharray: 6 5; }
.chart .avg-line { stroke: var(--muted); stroke-width: 1.5; }
.chart .ref-label { fill: var(--text-2); font-size: 11px; font-weight: 700; }
.chart .hit { fill: transparent; cursor: pointer; }
.tip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px; font-size: 13px; box-shadow: 0 8px 24px rgb(0 0 0 / .2);
  white-space: nowrap; display: none; z-index: 5;
}
.tip b { font-size: 16px; }

/* Tablas */
.table-wrap { overflow-x: auto; margin-top: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 7px 8px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
th:first-child, td:first-child, th.l, td.l { text-align: left; }
tbody tr:hover { background: var(--surface-2); }
td a { text-decoration: none; font-weight: 600; }
td a:hover { text-decoration: underline; }
.res { font-weight: 700; }
.mark { font-weight: 700; }
.mark.o { color: var(--over); }
.mark.u { color: var(--under); }
.mark.p { color: var(--muted); }

.player-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.avgs { display: flex; gap: 18px; flex-wrap: wrap; }
.avgs div { text-align: center; }
.avgs b { display: block; font-size: 20px; }
.avgs small { color: var(--muted); font-size: 12px; }
.badge {
  display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2); margin-left: 6px; vertical-align: 3px;
}
.empty { color: var(--muted); padding: 18px 0; }
.loading { color: var(--muted); padding: 24px 0; }
.foot { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; color: var(--muted); font-size: 13px; }
@media (max-width: 560px) {
  h1 { font-size: 20px; }
  .search { order: 3; max-width: none; flex-basis: 100%; }
  .theme-btn { margin-left: auto; }
  .sport { padding: 6px 8px; }
  .top-in { gap: 8px 10px; }
  .tile .v { font-size: 19px; }
}
