:root {
  color-scheme: dark;
  --bg: #04060d;
  --bg-2: #0a0f1c;
  --surface: #111a2e;
  --surface-2: #1a2540;
  --line: rgba(255, 255, 255, 0.10);
  --line-strong: rgba(255, 255, 255, 0.20);
  --text: #ffffff;
  --muted: #aab3c7;
  --red: #ff1d40;
  --red-2: #ff4d68;
  --green: #18e05a;
  --blue: #3aa0ff;
  --gold: #ffcb2e;
  --radius: 14px;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
}

/* ---------- temas ---------- */
[data-theme="amoled"] {
  --bg: #000000; --bg-2: #000000; --surface: #0a0a0c; --surface-2: #15151a;
  --line: rgba(255,255,255,0.08); --line-strong: rgba(255,255,255,0.18);
  --text: #ffffff; --muted: #9aa0ad;
}
[data-theme="contrast"] {
  --bg: #000000; --bg-2: #060606; --surface: #0c0c0c; --surface-2: #1a1a1a;
  --line: rgba(255,255,255,0.25); --line-strong: rgba(255,255,255,0.45);
  --text: #ffffff; --muted: #d6d6d6;
  --red: #ff0036; --red-2: #ff5c7a; --green: #00ff6a; --blue: #19b5ff; --gold: #ffe000;
}
[data-theme="aurora"] {
  --bg: #070318; --bg-2: #0e0830; --surface: #181048; --surface-2: #241a5e;
  --line: rgba(255,255,255,0.10); --line-strong: rgba(255,255,255,0.22);
  --text: #f4f0ff; --muted: #b3a8d6;
  --red: #ff4db8; --red-2: #ff7ccb; --green: #2bdcc0; --blue: #8a6bff; --gold: #ffd166;
}
[data-theme="emerald"] {
  --bg: #03100b; --bg-2: #061a12; --surface: #0a2419; --surface-2: #103326;
  --line: rgba(255,255,255,0.10); --line-strong: rgba(255,255,255,0.20);
  --text: #ecfff6; --muted: #8fc7ad;
  --red: #ff5566; --green: #25e58a; --blue: #34d399; --gold: #ffd86b;
}
[data-theme="light"] {
  --bg: #eaeef5; --bg-2: #ffffff; --surface: #ffffff; --surface-2: #f1f4fa;
  --line: rgba(10,20,40,0.10); --line-strong: rgba(10,20,40,0.20);
  --text: #0c1426; --muted: #5a6679;
  --red: #e11d48; --red-2: #f43f5e; --green: #16a34a; --blue: #2563eb; --gold: #d97706;
  --shadow: 0 10px 30px rgba(20,30,60,0.12);
}
[data-theme="light"] body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(37,99,235,0.08), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(225,29,72,0.07), transparent 55%),
    var(--bg);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(25, 137, 250, 0.12), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(238, 10, 36, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px clamp(14px, 3vw, 28px);
  background: rgba(11, 16, 32, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-weight: 900;
  font-size: 20px;
  color: #fff;
  background: linear-gradient(135deg, var(--red), #b3001b);
  box-shadow: 0 6px 18px rgba(238, 10, 36, 0.4);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text strong { font-size: 18px; letter-spacing: 0.2px; }
.brand-text small { color: var(--muted); font-size: 11px; }

.quick-search {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex: 0 1 360px;
}

.quick-search input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.quick-search input:focus { border-color: var(--blue); }

.quick-search button,
.refresh-btn {
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  transition: transform 0.08s ease, background 0.15s ease;
}
.quick-search button { background: linear-gradient(135deg, var(--blue), #0a63c9); border-color: transparent; }
.quick-search button:hover, .refresh-btn:hover { transform: translateY(-1px); }

.top-actions { display: flex; align-items: center; gap: 10px; }
.theme-btn {
  padding: 8px 14px 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: border-color .15s ease, transform .08s ease;
}
.theme-btn::before {
  content: "";
  width: 14px; height: 14px;
  border-radius: 50%;
  background: conic-gradient(var(--red), var(--gold), var(--green), var(--blue), var(--red));
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line-strong);
}
.theme-btn span { color: var(--muted); font-weight: 700; }
.theme-btn:hover { border-color: var(--line-strong); transform: translateY(-1px); }

/* ---------- sports nav ---------- */
.sports-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px clamp(14px, 3vw, 28px);
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.sports-nav::-webkit-scrollbar { display: none; }

.sports-nav button {
  white-space: nowrap;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  transition: all 0.15s ease;
}
.sports-nav button b { color: var(--green); }
.sports-nav button:hover { color: var(--text); border-color: var(--line-strong); }
.sports-nav button.active {
  color: #fff;
  background: linear-gradient(135deg, var(--red), #c20620);
  border-color: transparent;
  box-shadow: 0 6px 16px rgba(238, 10, 36, 0.35);
}

/* ---------- shell ---------- */
.app-shell {
  display: block;
  padding: 18px clamp(14px, 3vw, 28px) 40px;
  max-width: 1080px;
  margin: 0 auto;
}

/* ---------- feed ---------- */
.feed-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.feed-head h2 { margin: 0; font-size: 20px; }
.feed-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.feed-pills { display: flex; gap: 6px; margin-left: auto; }
.feed-pills button {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}
.feed-pills button.active { color: #fff; background: var(--surface-2); border-color: var(--blue); }

.event-count {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.event-count span { color: var(--text); font-weight: 700; }

/* ---------- match list ---------- */
.match-list { display: flex; flex-direction: column; gap: 2px; }

.league-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 6px;
  padding: 8px 12px;
  background: linear-gradient(90deg, var(--surface-2), transparent);
  border-left: 3px solid var(--red);
  border-radius: 8px;
}
.league-head:first-child { margin-top: 0; }
.league-icon {
  font-size: 11px;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 0.5px;
}
.league-emblem {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-size: 15px;
  border-radius: 6px;
  overflow: hidden;
}
.league-emblem img { width: 100%; height: 100%; object-fit: contain; }
.league-flag { font-size: 16px; }
.league-name { font-weight: 700; font-size: 14px; flex: 1; }
.league-count {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
  padding: 2px 9px;
  border-radius: 999px;
}

.match-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.08s ease, background 0.15s ease;
}
.match-row:hover { border-color: var(--line-strong); background: var(--surface-2); transform: translateY(-1px); }
.match-row.active { border-color: var(--blue); background: var(--surface-2); }
.match-row.is-live { border-color: rgba(46, 187, 46, 0.4); }

.row-side { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row-home { justify-content: flex-end; text-align: right; }
.row-away { justify-content: flex-start; }
.row-team {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-badge {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #334155, #1f2a44);
  border: 1px solid var(--line-strong);
}
.row-badge.alt { background: linear-gradient(135deg, #4a2540, #3a1f33); }
.row-badge.has-logo { background: transparent; border: none; padding: 0; }
.row-badge.has-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.team-badge.has-logo { background: transparent; border: none; padding: 0; }
.team-badge.has-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.league-emblem img { background: transparent; }

.row-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 78px;
}
.row-time { font-size: 13px; font-weight: 700; color: var(--text); }
.row-vs { font-size: 10px; color: var(--muted); font-weight: 700; }
.row-live {
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  background: var(--green);
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.5px;
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(46, 187, 46, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(46, 187, 46, 0); }
}

.row-score {
  font-size: 16px;
  font-weight: 800;
  color: var(--green);
  letter-spacing: 1px;
}
.league-live {
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  background: var(--green);
  padding: 2px 9px;
  border-radius: 999px;
}
.state-chip.live {
  background: var(--green);
  color: #fff;
  border-color: transparent;
  font-size: 16px;
  font-weight: 800;
}

.row-single { display: flex; flex-direction: column; gap: 2px; min-width: 0; grid-column: 1 / 3; }
.row-single .row-team { white-space: normal; }
.row-sub { font-size: 12px; color: var(--muted); }

.row-signal { color: var(--red-2); font-size: 12px; justify-self: end; }
.hidden { display: none !important; }
.row-final { font-size: 10px; font-weight: 800; color: var(--muted); letter-spacing: 1px; }
.row-score.fin { color: var(--text); font-size: 15px; }
.match-row.is-finished { opacity: 0.82; }
.row-badge.is-flag { font-size: 20px; background: transparent; border: none; }

/* ---------- detail panel ---------- */
.detail-area { position: sticky; top: 86px; }

.detail-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.detail-meta span { background: var(--surface); padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); }

.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}
.team { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.team h3 { margin: 0; font-size: 15px; }
.team-badge {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  background: linear-gradient(135deg, #334155, #1f2a44);
  border: 1px solid var(--line-strong);
}
.team-badge.alt { background: linear-gradient(135deg, #4a2540, #3a1f33); }

.score-core { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.score-core strong { font-size: 18px; color: var(--muted); }
.score-core small { font-size: 11px; color: var(--muted); }
.state-chip {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.status-grid article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.status-grid span { font-size: 11px; color: var(--muted); }
.status-grid strong { font-size: 13px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.panel-head h3 { margin: 0; font-size: 15px; }
.panel-head button {
  padding: 7px 14px;
  border-radius: 9px;
  border: none;
  background: linear-gradient(135deg, var(--red), #c20620);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}

.channel-list { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.channel-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px 10px;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.channel-card strong { font-size: 14px; }
.channel-card span { grid-column: 1; font-size: 11px; color: var(--muted); }
.channel-card button {
  grid-row: 1 / 3;
  grid-column: 2;
  padding: 8px 14px;
  border-radius: 9px;
  border: none;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); }
.tabs button {
  padding: 9px 14px;
  border: none;
  background: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--red); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.stats-grid { display: flex; flex-direction: column; gap: 6px; }
.stat-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 13px;
}
.stat-row span:first-child { text-align: left; font-weight: 700; }
.stat-row span:last-child { text-align: right; font-weight: 700; }
.stat-row strong { color: var(--muted); font-weight: 600; font-size: 12px; }

.lineup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.lineup-grid h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.player-list { display: flex; flex-direction: column; gap: 4px; }
.player-item {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
}
.player-number { color: var(--gold); font-weight: 700; text-align: center; }
.player-role { font-size: 11px; color: var(--muted); }

#player {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  background: #000;
  display: block;
}
.player-note {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.empty {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
}
.list-empty { margin-top: 10px; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .detail-area { position: static; order: -1; }
}
@media (max-width: 560px) {
  .quick-search { flex-basis: 100%; order: 3; margin-left: 0; }
  .row-team { font-size: 13px; }
  .row-badge { width: 30px; height: 30px; }
}

/* ============ POLISH + RESPONSIVE v2 ============ */
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

/* topbar más limpio */
.topbar { gap: 12px; }
.brand-mark { transition: transform .2s ease; }
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.05); }

/* sports-nav: subrayado animado + glow activo */
.sports-nav { gap: 6px; padding-top: 10px; padding-bottom: 10px; }
.sports-nav button { backdrop-filter: blur(4px); }
.sports-nav button.active { box-shadow: 0 6px 22px -6px var(--red); }

/* feed head */
.feed-head h2 { letter-spacing: -.3px; }
.feed-pills button { transition: all .15s ease; }
.feed-pills button.active { box-shadow: 0 4px 16px -6px var(--blue); }

/* league head: barra con acento + emblema */
.league-head {
  position: sticky; top: 64px; z-index: 5;
  backdrop-filter: blur(10px);
  background: linear-gradient(90deg, color-mix(in srgb, var(--surface-2) 92%, transparent), color-mix(in srgb, var(--bg) 70%, transparent));
}
.league-live { animation: pulse 1.6s infinite; }

/* match-row: gradiente sutil + acento live animado */
.match-row {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 96%, #fff 4%), var(--surface));
}
.match-row::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: transparent; transition: background .2s ease;
}
.match-row.is-live::before { background: var(--green); box-shadow: 0 0 14px var(--green); }
.match-row.is-finished::before { background: var(--muted); }
.match-row:hover { box-shadow: 0 8px 26px -12px #000; }
.match-row:active { transform: translateY(0) scale(.997); }
.row-live { box-shadow: 0 0 0 0 var(--green); }
.row-score { text-shadow: 0 0 18px color-mix(in srgb, var(--green) 50%, transparent); }
.row-badge {
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }

/* loading shimmer cuando vacío */
.list-empty { animation: fade .4s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* ---------- MÓVIL ---------- */
@media (max-width: 720px) {
  .topbar { padding: 10px 14px; }
  .brand-text small { display: none; }
  .theme-btn span { display: none; }
  .theme-btn { padding: 8px; }
  .refresh-btn { padding: 9px 12px; font-size: 12px; }
  .app-shell { padding: 12px 12px 40px; }
  .feed-head { gap: 8px; }
  .feed-head h2 { font-size: 17px; }
  .feed-head p { display: none; }
  .feed-pills { margin-left: 0; width: 100%; order: 3; overflow-x: auto; scrollbar-width: none; }
  .feed-pills::-webkit-scrollbar { display: none; }
  .event-count { order: 2; }
  .league-head { top: 56px; }
  .match-row { grid-template-columns: 1fr auto 1fr; padding: 11px 10px; gap: 8px; }
  .row-signal { display: none; }
  .row-team { font-size: 12.5px; }
  .row-badge { width: 28px; height: 28px; }
  .row-center { min-width: 64px; }
  .row-score { font-size: 15px; }
  .sports-nav { padding: 8px 12px; }
  .sports-nav button { padding: 8px 13px; font-size: 13px; }
}
@media (max-width: 400px) {
  .row-team { max-width: 84px; }
}
