/* FUTLP — estilos. Sin dependencias, claro/oscuro, accesible. */

:root {
  --bg: #f4f6fb;              /* gris con un punto del azul de la marca */
  --surface: #ffffff;
  --surface-2: #f9fafd;
  --ink: #141a2b;
  --ink-2: #4f5568;
  --ink-3: #7d8396;
  --line: rgba(1, 24, 80, .09);
  --line-strong: rgba(1, 24, 80, .17);
  --accent: #0038a7;          /* azul FUTLP */
  --accent-ink: #ffffff;
  --accent-soft: rgba(0, 56, 167, .09);
  --logo-blue: #0038a7;
  --logo-ball: #ffcc00;
  --logo-green: #078930;
  --logo-red: #da131a;
  --sun: #ffcc00;             /* amarillo canario */
  --live: #d70015;
  --live-soft: rgba(215, 0, 21, .10);
  --win: #1a7f37;
  --draw: #8a8a8e;
  --loss: #c4161c;
  --z-ascenso: #1a9d4b;
  --z-playoff: #0a63d1;
  --z-promocion: #c77800;
  --z-copa: #7b3fd1;
  --z-descenso: #d22d2d;
  --bar: rgba(244, 246, 251, .8);
  --seg-on: #ffffff;
  --on-badge: #ffffff;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.05);
  --radius: 18px;
  --radius-s: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --surface: #161a24;
    --surface-2: #1d2230;
    --ink: #f3f5fa;
    --ink-2: #b3b8c6;
    --ink-3: #8a90a0;
    --line: rgba(255, 255, 255, .10);
    --line-strong: rgba(255, 255, 255, .18);
    --accent: #7ea6ff;
    --accent-ink: #00112f;
    --accent-soft: rgba(126, 166, 255, .15);
    --logo-blue: #9dbbff;
    --logo-ball: #ffcc00;
    --logo-green: #2fbf5f;
    --logo-red: #ff4d55;
    --live: #ff453a;
    --live-soft: rgba(255, 69, 58, .16);
    --win: #32d36f;
    --draw: #98989d;
    --loss: #ff6961;
    --z-ascenso: #32d36f;
    --z-playoff: #4c9dff;
    --z-promocion: #ffb340;
    --z-copa: #bf8cff;
    --z-descenso: #ff6961;
    --bar: rgba(0, 0, 0, .74);
    --shadow: none;
    color-scheme: dark;
    --seg-on: #3a4152;
    --on-badge: #000000;
  }
}
:root[data-theme="dark"] {
    --bg: #000000;
    --surface: #161a24;
    --surface-2: #1d2230;
    --ink: #f3f5fa;
    --ink-2: #b3b8c6;
    --ink-3: #8a90a0;
    --line: rgba(255, 255, 255, .10);
    --line-strong: rgba(255, 255, 255, .18);
    --accent: #7ea6ff;
    --accent-ink: #00112f;
    --accent-soft: rgba(126, 166, 255, .15);
    --logo-blue: #9dbbff;
    --logo-ball: #ffcc00;
    --logo-green: #2fbf5f;
    --logo-red: #ff4d55;
    --live: #ff453a;
    --live-soft: rgba(255, 69, 58, .16);
    --win: #32d36f;
    --draw: #98989d;
    --loss: #ff6961;
    --z-ascenso: #32d36f;
    --z-playoff: #4c9dff;
    --z-promocion: #ffb340;
    --z-copa: #bf8cff;
    --z-descenso: #ff6961;
    --bar: rgba(0, 0, 0, .74);
    --shadow: none;
    color-scheme: dark;
    --seg-on: #3a4152;
    --on-badge: #000000;
}

@media (prefers-contrast: more) {
  :root { --ink-2: var(--ink); --ink-3: var(--ink); --line: var(--line-strong); }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.45 var(--font);   /* 17px, base de iOS */
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: 100%; max-width: 780px; margin: 0 auto; padding: 0 16px 48px; outline: none; }
a { color: var(--accent); }
img { display: block; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
h1:focus, main:focus { outline: none; }
abbr[title] { text-decoration: none; cursor: help; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; text-decoration: none; font-weight: 600; }
.skip:focus { top: 12px; }

/* ---------- barra superior ---------- */
.bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.bar.is-scrolled { border-bottom-color: var(--line); }
.bar__inner { max-width: 780px; margin: 0 auto; height: 52px; padding: 0 16px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.bar__back { justify-self: start; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; text-decoration: none; font-weight: 500; color: var(--accent); max-width: 40vw; }
.bar__back[hidden] { display: none; }
.bar__back span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar__title { grid-column: 2; font-weight: 600; font-size: .95rem; opacity: 0; transform: translateY(4px); transition: opacity .2s, transform .2s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.bar.is-scrolled .bar__title { opacity: 1; transform: none; }
.bar__brand { grid-column: 3; justify-self: end; display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; }
#back[hidden] ~ .bar__brand { grid-column: 1; justify-self: start; }
.logo { display: block; height: 26px; width: auto; aspect-ratio: 512 / 101.86; }
.logo__blue { fill: var(--logo-blue); }
.logo__ball { fill: var(--logo-ball); }
.logo__green { fill: var(--logo-green); }
.logo__red { fill: var(--logo-red); }
@media (max-width: 380px) { .bar__back:not([hidden]) ~ .bar__brand .logo { height: 20px; } }

/* ---------- títulos ---------- */
.hero { padding: 18px 0 8px; }
.eyebrow { margin: 0 0 4px; font-size: .8125rem; font-weight: 600; letter-spacing: .02em; color: var(--ink-3); text-transform: uppercase; }
h1 { margin: 0; font: 700 clamp(1.9rem, 6vw, 2.5rem)/1.08 var(--font-display); letter-spacing: -.022em; }
.hero__meta { margin: 8px 0 0; color: var(--ink-2); font-size: .95rem; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
h2.section { margin: 30px 4px 10px; font: 700 1.3rem/1.2 var(--font-display); letter-spacing: -.012em; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
h2.section small { font: 500 .875rem var(--font); color: var(--ink-3); letter-spacing: 0; }
h3.day { margin: 22px 4px 8px; font-size: .8125rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-3); }

/* ---------- tarjetas y listas ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 16px; text-decoration: none; color: inherit; }
a.row:hover { background: var(--surface-2); }
a.row:active { background: var(--line); }
.row__main { flex: 1; min-width: 0; }
.row__title { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__sub { display: block; font-size: .875rem; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { flex: none; width: 8px; height: 14px; color: var(--ink-3); opacity: .6; }
.cat-ico { flex: none; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font: 700 .8rem/1 var(--font-display); color: #fff; letter-spacing: .02em; }

/* rejilla de grupos (alevín, benjamín...) */
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; padding: 12px; }
.groups a { display: grid; place-items: center; min-height: 48px; border-radius: 12px; background: var(--bg); color: var(--ink); text-decoration: none; font-weight: 600; font-variant-numeric: tabular-nums; }
.groups a:hover { background: var(--accent-soft); color: var(--accent); }
details.card > summary { list-style: none; cursor: pointer; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary .chev { transition: transform .2s; }
details.card[open] > summary .chev { transform: rotate(90deg); }
details.card[open] > summary { border-bottom: 1px solid var(--line); }

/* ---------- buscador ---------- */
.search { position: relative; margin: 14px 0 4px; }
.search input {
  width: 100%; min-height: 44px; border: 0; border-radius: 12px; padding: 10px 14px 10px 40px;
  background: var(--surface); color: var(--ink); font: inherit; box-shadow: inset 0 0 0 1px var(--line);
}
.search input::placeholder { color: var(--ink-3); }
.search input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }

/* ---------- control segmentado ---------- */
.seg { position: sticky; top: calc(52px + env(safe-area-inset-top, 0px)); z-index: 10; margin: 14px -16px 0; padding: 8px 16px 10px; background: var(--bg); }
.seg__track { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 3px; border-radius: 12px; background: var(--line); }
.seg button { min-height: 38px; border: 0; border-radius: 9px; background: transparent; font-size: .9375rem; font-weight: 500; color: var(--ink-2); cursor: pointer; padding: 0 6px; white-space: nowrap; }
.seg button[aria-selected="true"] { background: var(--seg-on); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* ---------- selector de jornada ---------- */
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 14px 0 0; }
.stepper button { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface); color: var(--accent); display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow), inset 0 0 0 1px var(--line); }
.stepper button:disabled { color: var(--ink-3); opacity: .45; cursor: default; }
.stepper__label { text-align: center; }
.stepper__label strong { display: block; font: 700 1.25rem/1.2 var(--font-display); }
.stepper__label span { font-size: .875rem; color: var(--ink-3); }

/* ---------- partido ---------- */
.match { display: grid; grid-template-columns: 62px 1fr; gap: 0 12px; padding: 12px 16px; align-items: center; }
.match__state { grid-row: span 2; text-align: center; font-size: .8125rem; color: var(--ink-3); font-variant-numeric: tabular-nums; line-height: 1.25; border-right: 1px solid var(--line); padding-right: 10px; align-self: stretch; display: flex; flex-direction: column; justify-content: center; }
.match__state strong { display: block; font-size: 1rem; color: var(--ink); font-weight: 600; }
.match__state.is-live strong, .match__state.is-live { color: var(--live); }
.match__state.is-off strong { color: var(--ink-3); font-size: .8125rem; }
.team { display: flex; align-items: center; gap: 10px; min-height: 32px; }
.team__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team__name a { color: inherit; text-decoration: none; }
.team__name a:hover { text-decoration: underline; }
.team__score { min-width: 1.6em; text-align: right; font: 700 1.125rem/1 var(--font-display); font-variant-numeric: tabular-nums; }
.team.is-loser .team__name, .team.is-loser .team__score { color: var(--ink-3); font-weight: 400; }
.team.is-winner .team__name { font-weight: 600; }
.team.is-fav .team__name::after { content: "★"; color: var(--sun); margin-left: 6px; font-size: .85em; text-shadow: 0 0 1px rgba(0,0,0,.4); }
.match__foot { grid-column: 2; display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: .8125rem; color: var(--ink-3); }
.match__foot a { color: var(--ink-2); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; min-height: 24px; }
.match__foot a:hover { color: var(--accent); text-decoration: underline; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; padding: 3px 8px; border-radius: 99px; background: var(--live-soft); color: var(--live); }
.pill--muted { background: var(--line); color: var(--ink-2); }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* escudos */
.crest { flex: none; width: 26px; height: 26px; object-fit: contain; }
.crest--lg { width: 64px; height: 64px; }
.crest--md { width: 30px; height: 30px; }
.crest-ph { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-size: .65rem; font-weight: 700; color: var(--ink-2); }

/* ---------- clasificación ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.std { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .9375rem; }
table.std caption { text-align: left; }
table.std th { font-size: .75rem; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .03em; padding: 10px 6px; text-align: center; white-space: nowrap; }
table.std th:first-child, table.std td:first-child { padding-left: 14px; }
table.std th:last-child, table.std td:last-child { padding-right: 14px; }
table.std td { padding: 0 6px; height: 48px; text-align: center; border-top: 1px solid var(--line); white-space: nowrap; }
table.std .t-team { text-align: left; width: 100%; max-width: 0; }
table.std .t-team a { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-height: 44px; }
table.std .t-team a span { overflow: hidden; text-overflow: ellipsis; }
table.std .t-team a:hover span { text-decoration: underline; }
table.std .t-pts { font-weight: 700; }
table.std .t-pos { width: 2.4em; position: relative; font-weight: 600; }
table.std .t-pos::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 4px; border-radius: 0 3px 3px 0; background: var(--zone, transparent); }
table.std tr.is-fav td { background: color-mix(in srgb, var(--sun) 14%, transparent); }
.mv { position: absolute; left: 0; right: 0; bottom: 5px; font-size: .55rem; line-height: 1; }
.mv--up { color: var(--win); } .mv--down { color: var(--loss); }
.col-wide { display: none; }
@media (min-width: 620px) { .col-wide { display: table-cell; } }
.form { display: inline-flex; gap: 3px; }
.form i { font-style: normal; width: 18px; height: 18px; border-radius: 5px; display: grid; place-items: center; font-size: .625rem; font-weight: 700; color: var(--on-badge); }
.form .V { background: var(--win); } .form .E { background: var(--draw); } .form .D { background: var(--loss); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 12px 6px 0; font-size: .8125rem; color: var(--ink-2); padding: 0; list-style: none; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend li::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--zone); }

/* ---------- equipo ---------- */
.team-hero { display: flex; align-items: center; gap: 16px; padding: 18px 0 6px; }
.team-hero h1 { font-size: clamp(1.7rem, 6vw, 2.25rem); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border-radius: var(--radius); overflow: hidden; margin-top: 16px; box-shadow: var(--shadow); }
.stats div { background: var(--surface); padding: 14px 8px; text-align: center; }
.stats strong { display: block; font: 700 clamp(1.15rem, 5.2vw, 1.5rem)/1.1 var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats span { font-size: .75rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.fav-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 99px; border: 0; cursor: pointer; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: .9375rem; }
.fav-btn[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.fav-btn svg { width: 18px; height: 18px; }
.res-badge { flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: .75rem; font-weight: 700; color: var(--on-badge); }
.res-badge.V { background: var(--win); } .res-badge.E { background: var(--draw); } .res-badge.D { background: var(--loss); }

/* tarjetas de mis equipos */
.fav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.fav-card { display: block; text-decoration: none; color: inherit; padding: 14px 16px; }
.fav-card__head { display: flex; align-items: center; gap: 10px; }
.fav-card__head strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav-card__pos { font: 700 .9375rem var(--font-display); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.fav-card__liga { display: block; font-size: .8125rem; color: var(--ink-3); margin: 2px 0 10px; }
.fav-card__line { display: flex; gap: 8px; align-items: baseline; font-size: .9rem; color: var(--ink-2); }
.fav-card__line + .fav-card__line { margin-top: 4px; }
.fav-card__line b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.fav-card__k { flex: none; width: 4.6em; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-3); font-weight: 600; }

/* ---------- goleadores ---------- */
.scorer { display: grid; grid-template-columns: 2em 26px 1fr auto; align-items: center; gap: 12px; padding: 10px 16px; min-height: 56px; }
.scorer__pos { font-weight: 600; color: var(--ink-3); text-align: center; font-variant-numeric: tabular-nums; }
.scorer__goals { font: 700 1.25rem/1 var(--font-display); font-variant-numeric: tabular-nums; text-align: right; }
.scorer__goals small { display: block; font: 500 .7rem var(--font); color: var(--ink-3); margin-top: 3px; }

/* ---------- estados ---------- */
.empty { padding: 36px 20px; text-align: center; color: var(--ink-2); }
.empty strong { display: block; color: var(--ink); font-size: 1.05rem; margin-bottom: 4px; }
.skeleton { background: linear-gradient(90deg, var(--line) 25%, var(--surface-2) 50%, var(--line) 75%); background-size: 200% 100%; animation: sk 1.2s linear infinite; border-radius: 10px; }
@keyframes sk { to { background-position: -200% 0; } }
.updated { font-size: .8125rem; color: var(--ink-3); text-align: center; margin: 18px 0 0; }
.btn-text { border: 0; background: none; color: var(--accent); font-weight: 600; cursor: pointer; min-height: 44px; padding: 0 8px; }

.foot { text-align: center; font-size: .8125rem; color: var(--ink-3); padding: 0 16px calc(28px + env(safe-area-inset-bottom)); }
.foot a { color: inherit; }
.foot p { margin: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.seg .lg { display: none; }
@media (min-width: 560px) { .seg .lg { display: inline; } .seg .sm { display: none; } }
.fav-card__line .res-badge { width: 20px; height: 20px; border-radius: 6px; font-size: .65rem; align-self: center; }
