:root {
  --bg: #f5f1ea;
  --surface: #ffffff;
  --surface-2: #efe9df;
  --text: #1d2420;
  --muted: #6b7069;
  --line: #e2dbcf;
  --accent: #c2562b;      /* polvo de ladrillo */
  --accent-ink: #ffffff;
  --court: #2f6b4f;       /* verde cancha */
  --ball: #d7e84a;
  --zone-a: #2f6b4f;
  --zone-b: #3a5ba8;
  --win: #1f8a4c;
  --lose: #b23b3b;
  --radius: 14px;
  color-scheme: light;
}
/* Siempre abre en claro; el oscuro se elige con el selector del encabezado. */
:root[data-theme="dark"] {
  --bg: #121614; --surface: #1b211e; --surface-2: #232b27; --text: #eef1ec; --muted: #9aa39d;
  --line: #2d3631; --accent: #e07245; --court: #5fae86; --zone-a: #5fae86; --zone-b: #7d9be3;
  --win: #4cc27f; --lose: #e26a6a; color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  max-width: 980px; margin-inline: auto; padding: 0 16px 32px;
}
h1, h2 { margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin: 24px 0 12px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
button { font: inherit; cursor: pointer; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 20px 0 12px; }
.brand { display: flex; gap: 12px; align-items: center; }
.brand h1 { font-size: 1.4rem; }
.sub { margin: 0; color: var(--muted); font-size: .8rem; }
.theme { display: flex; flex: none; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.theme button { background: none; border: 0; border-radius: 999px; padding: 5px 10px; color: var(--muted); font-size: .8rem; }
.theme button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / .12); }
@media (max-width: 480px) { .theme button span { display: none; } }
.ball { width: 34px; height: 34px; border-radius: 50%; background: var(--ball); flex: none;
  background-image: radial-gradient(circle at -20% 50%, transparent 58%, #fff 60%, #fff 64%, transparent 66%),
                    radial-gradient(circle at 120% 50%, transparent 58%, #fff 60%, #fff 64%, transparent 66%); }

.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 8px; scrollbar-width: none; }
.tabs button { background: none; border: 0; padding: 10px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--text); border-color: var(--accent); font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 8px; align-content: start; }
.zone { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #fff; border-radius: 6px; padding: 1px 6px; justify-self: start; }
.zA { background: var(--zone-a); } .zB { background: var(--zone-b); }
details summary { cursor: pointer; color: var(--muted); font-size: .85rem; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:last-child td { border-bottom: 0; }
tr.in td:first-child { box-shadow: inset 3px 0 var(--court); }
.bar { display: inline-block; width: 60px; height: 6px; border-radius: 3px; background: var(--surface-2); margin-right: 8px; vertical-align: middle; position: relative; overflow: hidden; }
.bar::after { content: ""; position: absolute; inset: 0; width: var(--w); background: var(--court); }
.up { color: var(--win); } .down { color: var(--lose); }
.note { font-size: .85rem; }
.plink { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--muted); }

.h2h-pick { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
select { font: inherit; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); flex: 1; min-width: 140px; }
.split { display: flex; margin-top: 12px; border-radius: 10px; overflow: hidden; font-weight: 600; font-size: .85rem; }
.split span { padding: 10px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.split span:first-child { background: var(--court); }
.split span:last-child { background: var(--accent); text-align: right; }

.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.person { display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; color: inherit; text-decoration: none; }
.person:hover { border-color: var(--accent); }
.person p { margin: 2px 0 0; font-size: .85rem; }
.avatar { width: 52px; height: 52px; border-radius: 50%; flex: none; object-fit: cover; display: grid; place-items: center;
  color: #fff; font-weight: 700; letter-spacing: .02em; }
.avatar.big { width: 120px; height: 120px; font-size: 2.2rem; }
.profile { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-top: 12px; }
.profile p { margin: 4px 0; }
.bio { max-width: 60ch; }
.back { display: inline-block; margin-top: 12px; text-decoration: none; }
.fixture { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.fixture li { display: grid; grid-template-columns: 70px 1fr auto; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.fixture li:last-child { border-bottom: 0; }
.fixture li.w span:last-child { color: var(--win); font-weight: 600; }
.fixture li.l span:last-child { color: var(--lose); }



.help { max-width: 760px; }
.help section { scroll-margin-top: 16px; }
.help p, .help li { line-height: 1.6; }
.help ul { padding-left: 20px; }
.help code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.help details { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; }
.help details summary { color: var(--text); font-weight: 600; font-size: .95rem; }
.help details p { margin: 8px 0 0; }
.help .table-wrap { margin: 8px 0; }
.toc { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.toc a { background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px; font-size: .85rem; text-decoration: none; color: var(--text); }
.toc a:hover { border-color: var(--accent); }

a.brand { color: inherit; text-decoration: none; }
.hero { background: var(--court); color: #fff; border-radius: 20px; padding: 32px 28px; margin-top: 16px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%;
  background: var(--ball); opacity: .9;
  background-image: radial-gradient(circle at -20% 50%, transparent 58%, #fff 60%, #fff 63%, transparent 65%),
                    radial-gradient(circle at 120% 50%, transparent 58%, #fff 60%, #fff 63%, transparent 65%); }
.hero > * { position: relative; z-index: 1; max-width: 560px; }
.hero h2 { font-size: clamp(1.6rem, 5vw, 2.3rem); margin: 4px 0 10px; line-height: 1.15; }
.eyebrow { text-transform: uppercase; letter-spacing: .1em; font-size: .75rem; opacity: .8; margin: 0; }
.lead { font-size: 1.05rem; line-height: 1.55; opacity: .95; margin: 0 0 20px; }
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; }
.big { padding: 12px 20px; font-size: 1rem; border-radius: 99px; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.hero .ghost { color: #fff; border-color: rgb(255 255 255 / .5); }
.hero .ghost:hover { background: rgb(255 255 255 / .1); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-top: 10px; }
.stat { display: grid; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  color: inherit; text-decoration: none; }
.stat:hover, .mini-match:hover { border-color: var(--accent); }
.stat strong { font-size: 1.5rem; }
.stat > span:not(.bar) { color: var(--muted); font-size: .85rem; }
.bar.wide { width: 100%; margin: 6px 0 0; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; margin-top: 10px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.panel h3 { margin: 0; font-size: 1rem; }
.panel .more { margin-top: auto; font-size: .85rem; text-decoration: none; font-weight: 600; }
.mini-match { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 8px; align-items: center; color: inherit; text-decoration: none;
  background: var(--surface-2); border: 1px solid transparent; border-radius: 10px; padding: 8px 10px; }
.mini-match .zone { grid-row: span 2; }
.mini-match strong { color: var(--accent); font-variant-numeric: tabular-nums; }
.mm-p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.list li { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 8px; align-items: baseline; }
.list li > a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; justify-self: start; max-width: 100%; }
.list .pos { color: var(--muted); font-variant-numeric: tabular-nums; }
.list li > .muted:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }

details summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
.ghost { background: none; border: 1px solid var(--line); color: var(--text); }
.hero .light { background: #fff; color: var(--court); }
.hero .light:hover { background: rgb(255 255 255 / .9); }
.card-head { display: flex; justify-content: space-between; align-items: center; font-size: .8rem; }
.res-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.res-row.win > span:first-child { font-weight: 700; }
.sets { display: flex; gap: 4px; font-variant-numeric: tabular-nums; }
.sets b { width: 26px; text-align: center; font-weight: 500; color: var(--muted); background: var(--surface-2); border-radius: 6px; padding: 2px 0; }
.sets b.won { color: var(--text); font-weight: 700; }
.prob-row { display: flex; justify-content: space-between; gap: 10px; }
.prob-row strong { font-variant-numeric: tabular-nums; }
.split.thin { margin: 0; height: 6px; border-radius: 3px; }
.split.thin span { padding: 0; }
.scores { margin: 6px 0 0; font-size: .85rem; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.panel.wide { grid-column: span 2; }
.mini-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }
@media (max-width: 700px) { .panel.wide { grid-column: auto; } }
.two-col h4 { margin: 0 0 6px; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.results li { grid-template-columns: minmax(0, 1fr) auto; }
.mini-match strong { color: var(--text); }

.foot { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }

@media (max-width: 560px) {
  .hero { padding: 24px 18px; }
  .hero::after { width: 140px; height: 140px; right: -70px; top: -70px; }
  .hero-cta .big { width: 100%; justify-content: center; white-space: normal; text-align: center; }
  .brand h1 { font-size: 1.15rem; }
}
