/*
  SportZone: values from the student's design sheet.
  Azul marino #101B35 (principal), azul brillante #2864F0 (botones y acciones),
  verde lima #C8F169 (marcadores e indicadores), blanco / gris claro #FFFFFF / #F2F5FA (lectura).
  Sans serif (Helvetica / Arial), títulos gruesos y grandes, tarjetas redondeadas, fondo oscuro.
*/
:root {
  --navy: #101B35;
  --blue: #2864F0;
  --lime: #C8F169;
  --white: #FFFFFF;
  --mist: #F2F5FA;
  --navy-2: #17264A;   /* card surface: navy, one step lighter */
  --navy-3: #22355F;   /* raised controls on cards */
  --text-2: #A9B6D3;   /* secondary text on navy (7.9:1) */

  --bg: var(--navy);
  --surface: var(--navy-2);
  --surface-2: var(--navy-3);
  --ink: var(--white);
  --ink-2: var(--text-2);
  --line: rgb(242 245 250 / 12%);
  --accent: var(--blue);
  --accent-ink: var(--white);
  --accent-soft: rgb(40 100 240 / 22%);
  --good: var(--lime);
  --bad: #FF7A6B;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 0 rgb(255 255 255 / 4%) inset, 0 8px 24px rgb(0 0 0 / 28%);
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-display: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --max: 920px;
  color-scheme: dark;
}
/* The sheet asks for a dark background always, so ignore the shared light/dark switch. */
@media (prefers-color-scheme: dark) { :root { --bg: var(--navy); --surface: var(--navy-2); --surface-2: var(--navy-3); --ink: var(--white); --ink-2: var(--text-2); } }

body { background: var(--navy); color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 800; letter-spacing: -.01em; line-height: 1.1; }
:focus-visible { outline: 3px solid var(--lime); outline-offset: 2px; }
#app:focus { outline: none; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; padding: 10px 14px; border-radius: 10px; background: var(--lime); color: var(--navy); font-weight: 700; }
.skip-link:focus { top: calc(8px + var(--safe-top)); }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Top bar ---------- */
.topbar { background: rgb(16 27 53 / 88%); border-bottom-color: var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: var(--tap); color: var(--white); text-decoration: none; font-weight: 800; font-size: 1.25rem; letter-spacing: .06em; }
.brand b { color: var(--lime); }
.brand-mark { width: 32px; height: 32px; }
.live-indicator { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: rgb(200 241 105 / 14%); color: var(--lime); font-size: .8rem; font-weight: 700; }
.live-indicator[hidden] { display: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--lime); display: inline-block; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; transform: scale(.8); } }

/* ---------- Bottom menu: four options, icon + word ---------- */
.tabbar { background: rgb(16 27 53 / 94%); border-top-color: var(--line); }
.tabbar a { color: var(--text-2); font-size: .78rem; font-weight: 600; min-height: 54px; }
.tabbar .icon { width: 24px; height: 24px; }
.tabbar [aria-current="page"] { color: var(--lime); background: rgb(200 241 105 / 10%); }

/* ---------- Common ---------- */
.app-main { padding-top: 12px; }
.page-head h1 { font-size: clamp(1.9rem, 6vw, 2.6rem); margin: 8px 0 4px; text-transform: none; }
.page-head p { margin: 0 0 14px; }
.section-title { margin: 26px 0 12px; }
.section-title h2 { font-size: 1.3rem; }
.see-all { color: var(--lime); font-weight: 700; text-decoration: none; min-height: var(--tap); display: inline-flex; align-items: center; padding: 0 4px; }
.btn { min-height: 48px; border-color: var(--line); background: var(--navy-3); color: var(--white); font-weight: 700; }
.btn.primary { background: var(--blue); }
.btn.big { min-height: 52px; padding: 0 22px; font-size: 1.05rem; }
.btn.danger { color: var(--bad); }
.btn.small { min-height: var(--tap); min-width: var(--tap); }
.chips { margin-bottom: 10px; padding: 2px 2px 6px; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip { min-height: var(--tap); padding: 0 16px; background: var(--navy-2); border-color: var(--line); color: var(--white); font-weight: 600; text-decoration: none; }
.chip[aria-pressed="true"], .chip[aria-current="page"] { background: var(--blue); color: var(--white); border-color: transparent; }
.chip-count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: rgb(255 255 255 / 14%); font-size: .75rem; }
.chip[aria-pressed="true"] .chip-count { background: var(--lime); color: var(--navy); }
.card { background: var(--navy-2); }
.empty-state { color: var(--text-2); }
.empty-state.small { padding: 24px 12px; }
.muted { color: var(--text-2); }
.back-link { display: inline-flex; align-items: center; gap: 4px; min-height: var(--tap); color: var(--lime); font-weight: 700; text-decoration: none; margin-bottom: 6px; }

/* ---------- Inicio ---------- */
.greeting { margin: 4px 0 12px; color: var(--text-2); font-size: 1.05rem; }
.greeting strong { color: var(--white); }
.hero { position: relative; overflow: hidden; border-radius: 24px; min-height: 230px; background: var(--navy-2); box-shadow: var(--shadow); isolation: isolate; }
.action-art { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; }
.hero-copy { padding: 26px 22px 22px; max-width: 70%; }
.hero h1 { font-size: clamp(2rem, 8vw, 3.2rem); margin: 0 0 8px; font-style: italic; letter-spacing: -.02em; text-shadow: 0 2px 16px rgb(16 27 53 / 60%); }
.hero p { margin: 0 0 18px; color: var(--mist); font-weight: 600; }

.match-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
@media (min-width: 760px) { .match-list:not(.featured) { grid-template-columns: 1fr 1fr; } }
.match-card { display: block; padding: 14px 16px; border-radius: var(--radius); background: var(--navy-2); color: var(--white); text-decoration: none; box-shadow: var(--shadow); border: 1px solid var(--line); }
.match-card.is-live { border-color: rgb(200 241 105 / 40%); }
.match-card:active { transform: scale(.99); }
.mc-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .78rem; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.mc-body { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 12px 0 8px; }
.mc-team { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 800; }
.mc-team.away { flex-direction: row-reverse; text-align: right; }
.mc-team.lost { opacity: .6; }
.mc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav-mark .icon { width: 14px; height: 14px; fill: var(--lime); stroke: var(--lime); }
.mc-score { display: flex; gap: 6px; align-items: baseline; font-size: 1.9rem; font-weight: 800; color: var(--lime); font-variant-numeric: tabular-nums; border-radius: 10px; padding: 0 6px; }
.match-card.is-scheduled .mc-score { color: var(--text-2); }
.mc-score .sep { color: var(--text-2); font-weight: 400; }
.mc-foot { font-size: .85rem; color: var(--text-2); font-weight: 600; text-align: center; min-height: 1.2em; }
.match-card.big { padding: 18px; }
.match-card.big .mc-body { grid-template-columns: 1fr auto 1fr; }
.match-card.big .mc-team { flex-direction: column; text-align: center; font-size: 1.05rem; }
.match-card.big .mc-score { font-size: clamp(2.6rem, 11vw, 3.6rem); }
.flash { animation: flash 1.2s ease; }
@keyframes flash { 0% { background: var(--lime); color: var(--navy); } 100% { background: transparent; } }

.state-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .72rem; font-weight: 800; letter-spacing: .06em; }
.state-badge.live { background: var(--lime); color: var(--navy); }
.state-badge.live .dot { background: var(--navy); }
.state-badge.final { background: rgb(242 245 250 / 14%); color: var(--mist); }
.state-badge.scheduled { background: var(--accent-soft); color: #9DBBFF; }

.quick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .quick-grid { grid-template-columns: repeat(4, 1fr); } }
.quick { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; min-height: 92px; padding: 16px; border: 0; border-radius: var(--radius); background: var(--blue); color: var(--white); font: inherit; font-weight: 800; font-size: 1.02rem; text-decoration: none; cursor: pointer; text-align: left; }
.quick:nth-child(2) { background: var(--navy-3); }
.quick:nth-child(3) { background: var(--navy-3); }
.quick .icon { width: 28px; height: 28px; }
.quick:nth-child(2) .icon { fill: var(--lime); stroke: var(--lime); }
.quick-count { position: absolute; top: 14px; right: 14px; min-width: 28px; height: 28px; padding: 0 8px; display: grid; place-items: center; border-radius: 999px; background: var(--lime); color: var(--navy); font-size: .85rem; }

.news-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
@media (min-width: 760px) { .news-list { grid-template-columns: 1fr 1fr; } }
.news-card { width: 100%; display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: var(--radius); border: 0; background: var(--mist); color: var(--navy); font: inherit; text-align: left; cursor: pointer; min-height: var(--tap); }
.news-card strong { font-size: 1.05rem; line-height: 1.25; }
.news-meta { font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--blue); }
.news-summary { color: #43506E; font-size: .92rem; }
.over-card { margin-top: 16px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid rgb(200 241 105 / 40%); }
.over-card p { margin: 0; }

/* Reading sheet for news: the sheet's light reading surface */
dialog.sheet.reading { background: var(--white); color: var(--navy); }
dialog.sheet.reading .news-article h2 { font-size: 1.5rem; margin: 6px 0 10px; }
dialog.sheet.reading .lead { font-weight: 700; }
dialog.sheet.reading p { line-height: 1.55; }
dialog.sheet.reading .chip { background: var(--mist); color: var(--navy); border-color: #DCE3EF; margin-right: 8px; }
dialog.sheet { background: var(--navy-2); color: var(--white); }

/* ---------- Partido ---------- */
.scoreboard { padding: 18px 16px; border-radius: 24px; background: linear-gradient(160deg, #1D3270, var(--navy-2) 60%); box-shadow: var(--shadow); text-align: center; }
.sb-league { margin: 0 0 12px; font-size: .8rem; color: var(--text-2); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.sb-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.sb-team { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--white); text-decoration: none; font-weight: 800; min-height: var(--tap); }
.sb-center { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.sb-score { margin: 0; display: flex; gap: 10px; font-size: clamp(3rem, 14vw, 4.6rem); color: var(--lime); font-variant-numeric: tabular-nums; border-radius: 14px; padding: 0 10px; }
.scoreboard.is-scheduled .sb-score { color: var(--text-2); }
.sb-score .sep { color: var(--text-2); font-weight: 400; }
.sb-status { font-weight: 700; color: var(--mist); }
.sb-follow { display: flex; justify-content: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.star-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: var(--tap); min-height: var(--tap); padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--text-2); font: inherit; font-weight: 700; cursor: pointer; }
.star-btn .icon { width: 24px; height: 24px; }
.star-btn[aria-pressed="true"] { color: var(--lime); border-color: rgb(200 241 105 / 45%); }
.star-btn[aria-pressed="true"] .icon { fill: var(--lime); }
.star-btn.with-text { padding: 0 16px; }

.segmented { display: flex; gap: 4px; padding: 4px; margin: 18px 0 12px; border-radius: 999px; background: var(--navy-2); }
.segmented button { flex: 1; min-height: var(--tap); border: 0; border-radius: 999px; background: transparent; color: var(--text-2); font: inherit; font-weight: 800; cursor: pointer; }
.segmented [aria-selected="true"], .segmented [aria-pressed="true"] { background: var(--blue); color: var(--white); }
.segmented.compact { margin: 0; flex: none; }
.segmented.compact button { padding: 0 14px; }

.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.event { display: grid; grid-template-columns: 92px 1fr auto; gap: 10px; align-items: center; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--navy-2); }
.event-at { font-weight: 800; color: var(--lime); font-size: .85rem; }
.event-score { font-weight: 800; font-variant-numeric: tabular-nums; }
.event.start .event-at, .event.final .event-at { color: var(--mist); }
.event.final { background: var(--navy-3); }

.stats { list-style: none; margin: 0; padding: 16px; display: grid; gap: 16px; background: var(--navy-2); border-radius: var(--radius); }
.stat-row { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; row-gap: 6px; text-align: center; }
.stat-val { font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--text-2); font-weight: 600; font-size: .9rem; }
.stat-bar { grid-column: 1 / -1; display: flex; gap: 4px; height: 8px; }
.stat-bar i { display: block; height: 100%; border-radius: 4px; background: var(--lime); }
.stat-bar i:last-child { background: var(--blue); }

/* ---------- Equipos ---------- */
.team-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
@media (min-width: 760px) { .team-list:not(.favorites) { grid-template-columns: 1fr 1fr; } }
.team-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius); background: var(--navy-2); }
.favorites .team-row { padding: 14px; border: 1px solid rgb(200 241 105 / 22%); }
.team-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; min-height: var(--tap); color: var(--white); text-decoration: none; }
.team-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.team-text strong { font-size: 1.08rem; }
.team-text .muted { font-size: .88rem; }
.team-today { font-size: .82rem; font-weight: 700; color: var(--lime); }
.search-box { position: relative; margin-bottom: 12px; }
.search-box .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-2); }
.search-box input { padding-left: 46px; border-radius: 999px; background: var(--navy-2); border-color: var(--line); color: var(--white); min-height: 50px; }
.search-box input::placeholder { color: var(--text-2); }

.team-hero { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; padding: 20px; border-radius: 24px; background: linear-gradient(135deg, color-mix(in srgb, var(--team) 45%, var(--navy-2)), var(--navy-2) 70%); }
.team-hero h1 { margin: 0 0 4px; font-size: clamp(1.8rem, 6vw, 2.4rem); }
.team-hero p { margin: 0; }
.team-hero .star-btn { grid-column: 1 / -1; justify-self: start; }
.stat-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: var(--radius); background: var(--navy-2); color: var(--text-2); font-size: .82rem; font-weight: 600; }
.tile-num { font-size: 1.8rem; font-weight: 800; color: var(--lime); }
.tile-num.small { font-size: 1rem; color: var(--white); }
.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.results li { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--navy-2); }
.outcome { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; font-weight: 800; }
.outcome.G { background: var(--lime); color: var(--navy); }
.outcome.E { background: var(--navy-3); color: var(--mist); }
.outcome.P { background: rgb(255 122 107 / 20%); color: var(--bad); }
.result-score { font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- Posiciones ---------- */
.table-wrap { padding: 6px 4px; overflow-x: auto; }
.standings { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.standings caption { text-align: left; padding: 10px 12px; font-weight: 800; }
.standings th, .standings td { padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--line); }
.standings thead th { color: var(--text-2); font-size: .78rem; }
.standings .t-team { text-align: left; }
.standings .t-team a { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); color: var(--white); text-decoration: none; font-weight: 700; }
.standings .t-pts { color: var(--lime); font-weight: 800; }
.standings tr.mine { background: rgb(200 241 105 / 8%); }
.standings tbody tr:last-child th, .standings tbody tr:last-child td { border-bottom: 0; }

/* ---------- Perfil ---------- */
.profile-head { display: flex; align-items: center; gap: 16px; margin: 6px 0; }
.profile-head h1 { margin: 0; font-size: 1.9rem; }
.profile-head p { margin: 4px 0 0; }
.avatar { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: var(--lime); color: var(--navy); font-weight: 800; font-size: 1.6rem; flex: none; }
.form { margin-top: 16px; }
.form input { background: var(--navy); color: var(--white); border-color: var(--line); }
.field > span { color: var(--text-2); }
.form-error { margin: 0 0 10px; color: var(--bad); font-weight: 600; min-height: 1.2em; }
.form-error:empty { display: none; }
.prefs { display: grid; gap: 4px; padding: 6px 16px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row > span { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 180px; }
.toggle-row input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 56px; height: 44px; margin: 0; padding: 0;
  border: 0; background: transparent; cursor: pointer;
}
.toggle-row input[type="checkbox"]::before { content: ""; position: absolute; left: 0; top: 8px; width: 56px; height: 28px; border-radius: 999px; background: var(--navy-3); transition: background .15s; }
.toggle-row input[type="checkbox"]::after { content: ""; position: absolute; left: 3px; top: 11px; width: 22px; height: 22px; border-radius: 50%; background: var(--mist); transition: transform .15s; }
.toggle-row input[type="checkbox"]:checked::before { background: var(--lime); }
.toggle-row input[type="checkbox"]:checked::after { transform: translateX(28px); background: var(--navy); }
.about { margin-top: 24px; text-align: center; }

/* ---------- Toasts, install tip, offline pill ---------- */
.toast { background: var(--lime); color: var(--navy); font-weight: 700; }
.offline-pill { background: var(--lime); color: var(--navy); }
.install-tip { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px calc(16px + var(--safe-right)) 8px calc(16px + var(--safe-left)); background: var(--blue); font-size: .9rem; }
.install-tip p { margin: 0; }

@media (max-width: 520px) {
  .hero-copy { max-width: 66%; padding-right: 0; }
  .hero p { font-size: .95rem; }
  .mc-name { white-space: normal; overflow-wrap: anywhere; line-height: 1.15; }
}
@media (max-width: 420px) {
  .mc-score { font-size: 1.6rem; }
  .event { grid-template-columns: 78px 1fr auto; }
  .stat-tiles { gap: 8px; }
  .tile { padding: 12px 10px; }
}
