/* ===== Tokens ===== */
:root {
  --bg: #0b1220;
  --surface: #131c2e;
  --surface-2: #1a2540;
  --border: #243150;
  --text: #e8edf6;
  --muted: #8f9cb5;
  --faint: #5d6a85;
  --accent: #5cc3f5;
  --on-accent: #06121f;
  --live: #ff4d5e;
  --win: #34d399;
  --draw: #fbbf24;
  --loss: #f87171;
  --shadow: 0 1px 2px rgb(0 0 0 / .3);
  --radius: 14px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f2f4f8;
    --surface: #ffffff;
    --surface-2: #eef1f6;
    --border: #e1e6ee;
    --text: #0f172a;
    --muted: #5b6780;
    --faint: #94a0b6;
    --shadow: 0 1px 3px rgb(15 23 42 / .08);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --border: #e1e6ee;
  --text: #0f172a;
  --muted: #5b6780;
  --faint: #94a0b6;
  --shadow: 0 1px 3px rgb(15 23 42 / .08);
  color-scheme: light;
}

/* ===== Base ===== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
img { display: block; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ===== Layout ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  height: calc(56px + var(--safe-t));
  padding: var(--safe-t) 12px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-title h1 { font-size: 19px; font-weight: 750; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-logo { width: 28px; height: 28px; object-fit: contain; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; margin-left: -6px; }
.icon-btn:active { background: var(--surface-2); }

main {
  max-width: 720px; margin: 0 auto;
  padding: 12px 16px calc(var(--tabbar-h) + var(--safe-b) + 24px);
  outline: none;
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11px; font-weight: 600;
}
.tabbar svg { width: 25px; height: 25px; }
.tabbar a.active { color: var(--accent); }

/* ===== Componentes ===== */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.section { margin: 20px 0 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.section a { font-size: 13px; color: var(--accent); font-weight: 600; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chip.on, .chip.install { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 12px;
  background: var(--accent); color: var(--on-accent); font-weight: 700;
}
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }

.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--live); display: inline-block; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .25 } }

.logo { width: 24px; height: 24px; object-fit: contain; flex: none; }
.logo.sm { width: 20px; height: 20px; }
.logo.lg { width: 56px; height: 56px; }
.logo.xl { width: 72px; height: 72px; }
.logo-ph { display: inline-grid; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: 10px; font-weight: 700; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.empty p { margin: 6px 0 16px; }

.skeleton { border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0 } }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px;
  font-size: 14px; font-weight: 600; max-width: calc(100% - 32px); transition: .25s; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.seg { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; height: 36px; border-radius: 9px; font-size: 14px; font-weight: 650; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); margin: 12px -16px 0; padding: 0 16px; position: sticky; top: calc(56px + var(--safe-t)); background: var(--bg); z-index: 5; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { padding: 12px 12px; font-weight: 650; font-size: 14px; color: var(--muted); border-bottom: 2.5px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

/* ===== Tira de fechas ===== */
.dates { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px 10px; scroll-snap-type: x proximity; }
.dates::-webkit-scrollbar { display: none; }
.dates a, .dates label {
  flex: none; scroll-snap-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 54px; height: 58px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 11px; color: var(--muted); font-weight: 600; text-transform: capitalize;
}
.dates a b { font-size: 18px; color: var(--text); font-weight: 750; }
.dates a.on { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.dates a.on b { color: var(--on-accent); }
.dates label { position: relative; cursor: pointer; }
.dates label input { position: absolute; inset: 0; opacity: 0; }

/* ===== Lista de partidos ===== */
.league-head { display: flex; align-items: center; gap: 10px; margin: 18px 2px 8px; }
.league-head img { width: 22px; height: 22px; object-fit: contain; }
.league-head h3 { font-size: 14px; font-weight: 700; flex: 1; }
.league-head .muted { font-size: 12px; }
.matches { display: flex; flex-direction: column; overflow: hidden; }
.matches > * + * { border-top: 1px solid var(--border); }

.match { display: grid; grid-template-columns: 58px 1fr; align-items: center; gap: 10px; padding: 11px 14px 11px 10px; position: relative; }
.match:active { background: var(--surface-2); }
.match-status { text-align: center; font-size: 13px; font-weight: 700; color: var(--muted); line-height: 1.15; }
.match-status small { display: block; font-size: 10.5px; font-weight: 600; color: var(--faint); margin-top: 2px; }
.match.is-live .match-status { color: var(--live); }
.match-teams { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tr { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tr .name { flex: 1; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr .score { font-weight: 800; font-size: 16px; min-width: 18px; text-align: right; font-variant-numeric: tabular-nums; }
.tr .pen { font-size: 11px; color: var(--muted); font-weight: 600; }
.match.is-post .tr:not(.win) .name, .match.is-post .tr:not(.win) .score { color: var(--muted); }
.match.is-post .tr.draw .name, .match.is-post .tr.draw .score { color: var(--text); }
.tr.fav .name { font-weight: 800; color: var(--accent) !important; }
.match.is-fav::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.match-note { grid-column: 2; font-size: 12px; color: var(--muted); margin-top: -2px; font-weight: 600; }
.match-meta { grid-column: 2; font-size: 12px; color: var(--muted); margin-top: -2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.fav-banner { padding: 14px; margin-top: 6px; border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, var(--surface)), var(--surface) 70%); }
.fav-banner .label { font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; gap: 6px; }

/* ===== Hero de partido ===== */
.hero { padding: 16px 12px 18px; text-align: center; position: relative; overflow: hidden; }
.hero-league { font-size: 12.5px; color: var(--muted); font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px; }
.hero-main { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 8px; margin-top: 14px; }
.hero-team { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.hero-team .tname { font-weight: 750; font-size: 14.5px; line-height: 1.2; }
.hero-team.fav .tname { color: var(--accent); }
.hero-score { font-size: 42px; font-weight: 850; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1; padding-top: 8px; white-space: nowrap; }
.hero-score .sep { color: var(--faint); margin: 0 6px; font-weight: 500; }
.hero-score.flash { animation: flash 1.2s ease 2; }
@keyframes flash { 50% { color: var(--accent); transform: scale(1.08) } }
.hero-time { font-size: 30px; font-weight: 800; padding-top: 10px; }
.hero-status { margin-top: 8px; font-size: 13px; font-weight: 700; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.hero-status.live { color: var(--live); }
.hero-pens { font-size: 12px; color: var(--muted); margin-top: 4px; }
.scorers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.scorers div:first-child { text-align: right; }
.scorers div:last-child { text-align: left; }
.countdown { margin-top: 12px; font-size: 13px; color: var(--muted); }
.countdown b { color: var(--text); }

/* ===== Relato ===== */
.feed { list-style: none; margin: 12px 0 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 44px 28px 1fr; gap: 6px; padding: 10px 4px; border-bottom: 1px solid var(--border); align-items: start; }
.feed .min { font-weight: 800; font-size: 13px; color: var(--muted); padding-top: 2px; font-variant-numeric: tabular-nums; }
.feed .ico { font-size: 17px; line-height: 1.2; text-align: center; }
.feed .txt { font-size: 14px; }
.feed .txt small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.feed li.goal { background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: 10px; border-bottom-color: transparent; }
.feed li.goal .txt { font-weight: 700; }
.feed li.sep { grid-template-columns: 1fr; text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* ===== Estadísticas ===== */
.stat { padding: 10px 2px; }
.stat-top { display: flex; justify-content: space-between; font-weight: 750; font-size: 14px; font-variant-numeric: tabular-nums; }
.stat-top span:nth-child(2) { color: var(--muted); font-weight: 600; font-size: 13px; }
.stat-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.stat-bars div { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; display: flex; }
.stat-bars div:first-child { justify-content: flex-end; }
.stat-bars i { display: block; height: 100%; border-radius: 3px; background: var(--faint); }
.stat-bars i.lead { background: var(--accent); }

/* ===== Formaciones ===== */
.lineup-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.lineup-head b { flex: 1; }
.player { display: flex; align-items: center; gap: 12px; padding: 9px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.player:last-child { border-bottom: 0; }
.player .jersey { width: 26px; text-align: center; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.player .pname { flex: 1; min-width: 0; }
.player .pos { font-size: 11px; font-weight: 700; color: var(--faint); width: 28px; text-align: right; }
.player .tags { font-size: 12px; white-space: nowrap; }
.sub-label { padding: 10px 14px 6px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); }

/* ===== Info ===== */
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { text-align: right; font-weight: 600; }
.form { display: flex; gap: 4px; }
.form i { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; font-style: normal; font-size: 11px; font-weight: 800; color: var(--on-accent); }
.form i.G, .form i.W { background: var(--win); }
.form i.E, .form i.D { background: var(--draw); }
.form i.P, .form i.L { background: var(--loss); }
.form-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.form-row:last-child { border-bottom: 0; }
.form-row b { flex: 1; font-size: 14px; }

/* ===== Tablas ===== */
.table-wrap { overflow-x: auto; }
table.standings { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.standings th { font-size: 11px; color: var(--muted); font-weight: 700; text-align: center; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.standings td { text-align: center; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.standings tr:last-child td { border-bottom: 0; }
.standings th:nth-child(2), .standings td:nth-child(2) { text-align: left; }
.standings td.pos { width: 34px; font-weight: 700; color: var(--muted); border-left: 3px solid transparent; }
.standings td.team { max-width: 0; width: 100%; }
.standings td.team a { display: flex; align-items: center; gap: 8px; }
.standings td.team span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.standings td.pts { font-weight: 800; }
.standings tr.fav td { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.standings tr.fav td.team { font-weight: 800; color: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 10px 14px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ===== Torneos ===== */
.t-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.t-card { padding: 16px 12px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; min-height: 132px; justify-content: center; }
.t-card img { width: 52px; height: 52px; object-fit: contain; }
.t-card b { font-size: 14px; line-height: 1.2; }
.t-card small { color: var(--muted); font-size: 11.5px; }
.t-head { display: flex; align-items: center; gap: 14px; padding: 4px 2px; }
.t-head img { width: 52px; height: 52px; object-fit: contain; }
.t-head h2 { font-size: 20px; }
.month-nav { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 4px; }
.month-nav b { font-size: 15px; }
.month-nav button { width: 40px; height: 40px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); font-size: 18px; }
.day-head { font-size: 13px; font-weight: 700; color: var(--muted); margin: 16px 2px 8px; }
.day-head.today { color: var(--accent); }
.filters { display: flex; gap: 8px; margin: 10px 0 0; overflow-x: auto; scrollbar-width: none; }

/* ===== Mi equipo ===== */
.team-hero { padding: 20px 16px; display: flex; align-items: center; gap: 16px; position: relative; overflow: hidden; }
.team-hero::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 0% 0%, color-mix(in srgb, var(--accent) 28%, transparent), transparent 65%); pointer-events: none; }
.team-hero h2 { font-size: 22px; font-weight: 800; }
.team-hero p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.next-card { padding: 16px; margin-top: 12px; }
.next-card .when { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.next-card .vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 14px 0 12px; text-align: center; }
.next-card .vs div { display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; }
.next-card .big-time { font-size: 24px; font-weight: 850; }
.next-card .cd { text-align: center; font-size: 13px; color: var(--muted); }
.next-card .cd b { color: var(--text); font-size: 15px; }
.notice { padding: 12px 14px; display: flex; gap: 12px; align-items: center; margin-top: 12px; font-size: 13.5px; }
.notice .ico { font-size: 22px; }
.notice div { flex: 1; }

/* ===== Ajustes / selector de equipo ===== */
.setting { display: flex; align-items: center; gap: 12px; padding: 14px; border-bottom: 1px solid var(--border); min-height: 56px; }
.setting:last-child { border-bottom: 0; }
.setting .txt { flex: 1; min-width: 0; }
.setting .txt b { display: block; font-weight: 650; font-size: 15px; }
.setting .txt small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.setting select { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; height: 36px; padding: 0 8px; font: inherit; font-size: 14px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgb(0 0 0 / .3); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:disabled + span { opacity: .45; }

.search { width: 100%; height: 46px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 0 14px; font: inherit; font-size: 16px; margin-top: 8px; }
.search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.team-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; margin-top: 8px; }
.team-pick { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 6px; text-align: center; font-size: 12.5px; font-weight: 650; line-height: 1.2; }
.team-pick img { width: 44px; height: 44px; object-fit: contain; }
.team-pick.on { border-color: var(--accent); outline: 2px solid var(--accent); }
.welcome { text-align: center; padding: 10px 8px 4px; }
.welcome .big { font-size: 46px; }
.welcome h2 { font-size: 22px; margin-top: 6px; }
.welcome p { color: var(--muted); margin: 8px 0 0; }

.foot { text-align: center; color: var(--faint); font-size: 12px; margin-top: 24px; }
.updated { text-align: center; color: var(--faint); font-size: 11.5px; margin-top: 14px; }

@media (min-width: 560px) {
  .t-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
