:root {
  --bg:       #080b14;
  --card:     #0f1623;
  --card2:    #141d2e;
  --border:   #1e2d45;
  --accent:   #00d4ff;
  --green:    #00ff88;
  --red:      #ff3b5c;
  --yellow:   #ffd600;
  --text:     #e8edf5;
  --muted:    #5a6a82;
  --nav-h:    64px;
  --header-h: 56px;
}

* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html { height:100%; }
body { min-height:100%; height:100%; background:#080b14; background:var(--bg); color:var(--text); font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; overflow-x:hidden; }

/* SPLASH */
#splash {
  position:fixed; top:0; left:0; right:0; bottom:0; display:flex; flex-direction:column;
  align-items:center; justify-content:center; background:#080b14; background:var(--bg); z-index:999;
  transition:opacity .4s;
}
#splash.fade-out { opacity:0; pointer-events:none; }
.splash-logo { display:flex; align-items:center; gap:12px; }
.splash-icon { font-size:52px; animation:spin 1s ease-out; }
.splash-name  { font-size:48px; font-weight:800; letter-spacing:6px; color:var(--accent); }
.splash-sub   { margin-top:12px; color:var(--muted); font-size:14px; letter-spacing:2px; }
@keyframes spin { from{transform:rotate(-30deg) scale(.6)} to{transform:rotate(0) scale(1)} }

/* LAYOUT */
#app { height:100vh; min-height:100%; display:flex; flex-direction:column; }
#app.hidden { display:none; }
.hidden { display:none !important; }

/* HEADER */
.header {
  height:var(--header-h); background:var(--card); border-bottom:1px solid var(--border);
  display:flex; align-items:center; justify-content:space-between; padding:0 16px;
  flex-shrink:0;
}
.header-left  { display:flex; align-items:center; gap:8px; }
.header-logo  { font-size:22px; }
.header-title { font-size:22px; font-weight:800; letter-spacing:3px; color:var(--accent); }
.header-right { display:flex; align-items:center; gap:8px; }
.icon-btn     { background:none; border:none; font-size:20px; cursor:pointer; }

/* LIVE DOT */
.live-dot {
  width:8px; height:8px; border-radius:50%; background:var(--green);
  box-shadow:0 0 8px var(--green); animation:pulse 1.4s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* PAGES */
.page { flex:1; overflow-y:auto; padding:12px 12px calc(var(--nav-h) + 12px); }
.page.active { display:block; }
.page.hidden  { display:none; }

/* LOADING */
.loading-wrap { display:flex; flex-direction:column; align-items:center; gap:12px; padding:60px 0; color:var(--muted); }
.spinner { width:36px; height:36px; border:3px solid var(--border); border-top-color:var(--accent); border-radius:50%; animation:rot .8s linear infinite; }
@keyframes rot { to{transform:rotate(360deg)} }

/* LIGA SECTION */
.liga-section { margin-bottom:24px; }
.liga-header {
  display:flex; align-items:center; gap:8px; padding:8px 4px 10px;
  font-size:12px; font-weight:700; letter-spacing:1.5px; color:var(--muted); text-transform:uppercase;
}
.liga-emoji { font-size:16px; }

/* MATCH CARD */
.match-card {
  background:var(--card); border:1px solid var(--border); border-radius:14px;
  padding:14px 16px; margin-bottom:10px; position:relative; overflow:hidden;
  transition:border-color .2s;
}
.match-card.live { border-color:var(--green); }
.match-card.live::before {
  content:''; position:absolute; top:0; left:0; right:0; height:2px;
  background:linear-gradient(90deg,var(--green),var(--accent));
}

.match-status {
  font-size:11px; font-weight:700; letter-spacing:1px; margin-bottom:10px;
  display:flex; align-items:center; gap:6px;
}
.status-live  { color:var(--green); }
.status-pre   { color:var(--muted); }
.status-post  { color:var(--muted); }
.live-badge   { background:var(--green); color:#000; border-radius:4px; padding:1px 5px; font-size:10px; }

.match-teams {
  display:grid; grid-template-columns:1fr auto 1fr; align-items:center; gap:8px;
}
.team { display:flex; flex-direction:column; align-items:center; gap:6px; }
.team-logo { width:40px; height:40px; object-fit:contain; }
.team-logo-placeholder { width:40px; height:40px; border-radius:50%; background:var(--card2); display:flex; align-items:center; justify-content:center; font-size:18px; }
.team-name { font-size:12px; font-weight:600; text-align:center; line-height:1.2; }
.team-score { font-size:30px; font-weight:800; color:var(--text); }
.team-score.winner { color:var(--green); }

.scoreboard {
  display:flex; flex-direction:column; align-items:center; gap:2px;
}
.score-display { font-size:28px; font-weight:800; letter-spacing:2px; }
.score-vs      { font-size:13px; color:var(--muted); font-weight:600; }
.score-clock   { font-size:11px; color:var(--accent); font-weight:700; }

.match-footer {
  margin-top:12px; display:flex; justify-content:space-between; align-items:center;
}

/* FOLLOW BUTTON */
.btn-seguir {
  display:flex; align-items:center; gap:6px; border:none; border-radius:8px;
  padding:7px 14px; font-size:13px; font-weight:700; cursor:pointer;
  transition:all .2s; background:var(--card2); color:var(--muted); border:1px solid var(--border);
}
.btn-seguir.siguiendo {
  background:rgba(0,255,136,.1); color:var(--green); border-color:var(--green);
}
.btn-seguir:active { transform:scale(.95); }

.match-time { font-size:11px; color:var(--muted); }

/* EMPTY STATE */
.empty-state {
  display:flex; flex-direction:column; align-items:center; gap:10px;
  padding:80px 20px; text-align:center; color:var(--muted);
}
.empty-state span { font-size:48px; }
.empty-state p  { font-size:16px; }
.empty-state small { font-size:13px; }

/* SETTINGS */
.settings-wrap { padding:8px 4px 20px; }
.settings-title { font-size:20px; font-weight:800; margin-bottom:4px; }
.settings-sub   { font-size:13px; color:var(--muted); margin-bottom:20px; }
.settings-group {
  background:var(--card); border:1px solid var(--border); border-radius:14px; overflow:hidden;
}
.toggle-row {
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 16px; cursor:pointer; border-bottom:1px solid var(--border); position:relative;
}
.toggle-row:last-child { border-bottom:none; }
.toggle-row span:first-child { font-size:14px; }
.toggle-row input[type=checkbox] { display:none; }
.toggle-slider {
  width:44px; height:24px; border-radius:12px; background:var(--border);
  flex-shrink:0; position:relative; transition:background .2s;
}
.toggle-slider::after {
  content:''; position:absolute; width:18px; height:18px; border-radius:50%;
  background:#fff; top:3px; left:3px; transition:transform .2s;
}
input[type=checkbox]:checked ~ .toggle-slider { background:var(--accent); }
input[type=checkbox]:checked ~ .toggle-slider::after { transform:translateX(20px); }

.btn-guardar {
  width:100%; margin-top:24px; padding:14px; border-radius:12px; border:none;
  background:var(--accent); color:#000; font-size:16px; font-weight:800; cursor:pointer;
  transition:opacity .2s;
}
.btn-guardar:active { opacity:.8; }
.cfg-ok { text-align:center; margin-top:10px; color:var(--green); font-size:14px; }

/* BOTTOM NAV */
.bottom-nav {
  height:var(--nav-h); background:var(--card); border-top:1px solid var(--border);
  display:flex; flex-shrink:0;
}
.nav-btn {
  flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:2px; border:none; background:none; cursor:pointer; color:var(--muted);
  font-size:22px; transition:color .2s;
}
.nav-btn small { font-size:10px; font-weight:600; letter-spacing:.5px; }
.nav-btn.active { color:var(--accent); }

/* ── TABLAS DE POSICIONES ──────────────────────────────────── */
.tablas-ligas {
  display:flex; gap:8px; overflow-x:auto; padding:12px 12px 4px;
  scrollbar-width:none; flex-shrink:0;
}
.tablas-ligas::-webkit-scrollbar { display:none; }
.liga-chip {
  flex-shrink:0; padding:6px 12px; border-radius:20px; font-size:12px; font-weight:700;
  border:1px solid var(--border); background:var(--card); color:var(--muted); cursor:pointer;
  white-space:nowrap; transition:all .2s;
}
.liga-chip.active { background:var(--accent); color:#000; border-color:var(--accent); }

#page-tablas { padding:0 0 calc(var(--nav-h) + 8px); display:flex; flex-direction:column; }
#tablas-container { flex:1; overflow-y:auto; padding:8px 12px 12px; }

.standings-wrap { overflow-x:auto; }
.standings-table {
  width:100%; border-collapse:collapse; font-size:13px; min-width:280px;
}
.standings-table thead tr {
  background:var(--card2); color:var(--muted); font-size:11px; font-weight:700; letter-spacing:.5px;
}
.standings-table th, .standings-table td {
  padding:8px 6px; text-align:center; border-bottom:1px solid var(--border);
}
.standings-table .col-team { text-align:left; display:flex; align-items:center; gap:6px; min-width:120px; }
.standings-table .col-pos { width:28px; color:var(--muted); font-weight:700; }
.standings-table .col-pts { color:var(--accent); font-weight:800; }
.standings-table tbody tr:nth-child(odd)  { background:var(--card); }
.standings-table tbody tr:nth-child(even) { background:var(--card2); }
.team-logo-sm { width:20px; height:20px; object-fit:contain; }

/* ── HISTORIAL ─────────────────────────────────────────────── */
.historial-header {
  display:flex; justify-content:space-between; align-items:center;
  padding:12px 16px 4px; font-size:12px; color:var(--muted); font-weight:700; letter-spacing:1px;
}
.btn-borrar-hist {
  background:none; border:none; color:var(--muted); font-size:12px; cursor:pointer; padding:4px 8px;
}
.historial-item {
  display:flex; gap:12px; padding:12px 16px; border-bottom:1px solid var(--border);
  align-items:flex-start;
}
.historial-icon {
  width:36px; height:36px; border-radius:10px; background:var(--card2);
  display:flex; align-items:center; justify-content:center; font-size:18px; flex-shrink:0;
}
.historial-body { flex:1; min-width:0; }
.historial-titulo { font-size:14px; font-weight:700; margin-bottom:2px; }
.historial-cuerpo { font-size:12px; color:var(--muted); margin-bottom:4px; line-height:1.4; }
.historial-tiempo { font-size:11px; color:var(--border); }

/* ── MATCH DETAIL BOTTOM SHEET ─────────────────────────────── */
.detalle-overlay {
  position:fixed; inset:0; z-index:400; background:rgba(0,0,0,.6);
  opacity:0; pointer-events:none; transition:opacity .25s;
}
.detalle-overlay.open { opacity:1; pointer-events:all; }
.detalle-sheet {
  position:absolute; bottom:0; left:0; right:0;
  background:var(--card); border-radius:20px 20px 0 0;
  max-height:88vh; display:flex; flex-direction:column;
  transform:translateY(100%); transition:transform .3s cubic-bezier(.16,1,.3,1);
}
.detalle-overlay.open .detalle-sheet { transform:translateY(0); }
.detalle-handle {
  width:40px; height:4px; border-radius:2px; background:var(--border);
  margin:10px auto 0; flex-shrink:0;
}
.detalle-close {
  position:absolute; top:8px; right:14px; background:none; border:none;
  color:var(--muted); font-size:18px; cursor:pointer; padding:4px 8px;
}
.detalle-content {
  overflow-y:auto; padding:8px 16px 32px; flex:1;
}

/* Cabecera del detalle */
.detalle-header {
  display:flex; align-items:center; justify-content:space-between;
  padding:16px 0 12px; border-bottom:1px solid var(--border); margin-bottom:16px;
}
.team-logo-lg { width:56px; height:56px; object-fit:contain; }
.team-logo-lg-ph { width:56px; height:56px; display:flex; align-items:center; justify-content:center; font-size:28px; }
.detalle-score-block { text-align:center; flex:1; }
.detalle-team-name { font-size:12px; color:var(--muted); font-weight:600; margin:2px 0; }
.detalle-marcador { font-size:34px; font-weight:900; letter-spacing:2px; margin:4px 0; }
.detalle-status { font-size:11px; color:var(--accent); margin-top:4px; }

/* Sección título */
.detalle-section-title {
  font-size:11px; font-weight:700; color:var(--muted); letter-spacing:1.5px;
  text-transform:uppercase; margin:20px 0 10px;
}

/* Timeline eventos */
.timeline { display:flex; flex-direction:column; gap:4px; }
.timeline-ev {
  display:grid; grid-template-columns:36px 28px 1fr;
  align-items:center; padding:8px 10px; border-radius:10px;
  background:var(--card2); gap:6px;
}
.timeline-ev.ev-gol { background:rgba(0,255,136,.08); border:1px solid rgba(0,255,136,.2); }
.ev-min { font-size:11px; color:var(--muted); font-weight:700; text-align:right; }
.ev-icon { font-size:16px; text-align:center; }
.ev-texto { display:flex; flex-direction:column; gap:1px; min-width:0; }
.ev-equipo { font-size:12px; font-weight:700; }
.ev-desc { font-size:11px; color:var(--muted); line-height:1.3; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* Stats */
.stats-grid { display:flex; flex-direction:column; gap:6px; }
.stats-header {
  display:grid; grid-template-columns:1fr auto 1fr; font-size:11px;
  color:var(--muted); font-weight:700; padding:0 4px; text-align:center;
}
.stat-row {
  display:grid; grid-template-columns:1fr auto 1fr;
  align-items:center; padding:6px 10px; background:var(--card2); border-radius:8px;
}
.stat-val { font-size:14px; font-weight:700; text-align:center; }
.stat-name { font-size:11px; color:var(--muted); text-align:center; padding:0 8px; font-weight:600; }

/* GOL OVERLAY */
.gol-overlay {
  position:fixed; inset:0; z-index:500; display:flex; flex-direction:column;
  align-items:center; justify-content:center; background:rgba(0,0,0,.85);
  animation:gol-in .3s ease;
}
.gol-overlay.hidden { display:none; }
@keyframes gol-in { from{opacity:0;transform:scale(.8)} to{opacity:1;transform:scale(1)} }
.gol-text {
  font-size:52px; font-weight:900; color:var(--green);
  text-shadow:0 0 30px var(--green),0 0 60px var(--green);
  animation:gol-pulse .5s infinite alternate;
  letter-spacing:4px;
}
@keyframes gol-pulse { from{transform:scale(1)} to{transform:scale(1.08)} }
.gol-info { margin-top:16px; font-size:18px; color:#fff; text-align:center; line-height:1.5; }
