/* ══════════════════════════════════════════
   Variables
══════════════════════════════════════════ */
:root {
  --grass:     #1a3a1a;
  --pitch:     #0b200b;
  --lime:      #b5ff4d;
  --lime-dim:  #7dbf2e;
  --lime-glow: rgba(181,255,77,.15);
  --white:     #f0f5e8;
  --muted:     #7a9068;
  --card:      #132213;
  --card2:     #1a2e1a;
  --border:    #263e26;
  --red:       #ff4d4d;
  --yellow:    #ffd94d;
  --blue:      #4da6ff;
  --verde:     #4caf50;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 4px 24px rgba(0,0,0,.4);
  --shadow-header: 0 4px 32px rgba(0,0,0,.6);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Body como columna ── */
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--pitch);
  color: var(--white);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(181,255,77,.04) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(77,166,255,.03) 0%, transparent 60%),
    repeating-linear-gradient(
      0deg, transparent, transparent 32px,
      rgba(255,255,255,.012) 32px, rgba(255,255,255,.012) 64px
    );
}

/* ══════════════════════════════════════════
   Header
══════════════════════════════════════════ */
header {
  background: linear-gradient(135deg, #1e3e1e 0%, var(--grass) 100%);
  border-bottom: 2px solid var(--lime);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-header);
  flex-shrink: 0;
}

header .logo {
  font-size: 1.6rem;
  line-height: 1;
  filter: drop-shadow(0 0 10px var(--lime));
  flex-shrink: 0;
}

header h1 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.5rem;
  letter-spacing: .12em;
  color: var(--lime);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-admin {
  background: var(--lime-glow);
  border: 1px solid rgba(181,255,77,.3);
  color: var(--lime);
  font-size: .65rem;
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: .12em;
  padding: .2rem .55rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  flex-shrink: 0;
}

.header-links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

.header-links a {
  font-size: .75rem;
  text-decoration: none;
  padding: .35rem .9rem;
  border-radius: var(--radius-sm);
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: .08em;
  transition: all .2s;
  white-space: nowrap;
}

.btn-ver {
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ver:hover { border-color: var(--lime-dim); color: var(--white); background: rgba(255,255,255,.04); }

.btn-salir {
  background: var(--lime-dim);
  border: 1px solid var(--lime-dim);
  color: var(--pitch);
  font-weight: 700;
}
.btn-salir:hover { background: var(--lime); border-color: var(--lime); }

/* ══════════════════════════════════════════
   Tabs
══════════════════════════════════════════ */
.tabs {
  display: flex;
  gap: .5rem;
  padding: 1.2rem 2rem .4rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.tab {
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: .1em;
  font-size: 1rem;
  padding: .45rem 1.3rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all .2s;
}
.tab:hover { border-color: var(--lime-dim); color: var(--white); background: rgba(255,255,255,.03); }
.tab.active {
  background: var(--lime);
  border-color: var(--lime);
  color: var(--pitch);
  box-shadow: 0 0 16px rgba(181,255,77,.25);
}

/* ══════════════════════════════════════════
   Main / Layout
══════════════════════════════════════════ */
main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 1.2rem 2rem 3rem;
}

section { display: none; }
section.active { display: block; }

h2 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.5rem;
  letter-spacing: .1em;
  color: var(--lime);
  margin-bottom: 1rem;
}

/* ══════════════════════════════════════════
   Tabla de posiciones
══════════════════════════════════════════ */
.standings-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.standings-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.standings-table thead tr {
  background: linear-gradient(90deg, #1f3f1f, var(--grass));
  border-bottom: 2px solid var(--lime);
}

.standings-table th {
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: .1em;
  font-size: .9rem;
  color: var(--lime);
  padding: .7rem .9rem;
  text-align: center;
}
.standings-table th:nth-child(2) { text-align: left; }

.standings-table td {
  padding: .65rem .9rem;
  text-align: center;
  font-size: .88rem;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.standings-table td:nth-child(2) { text-align: left; }
.standings-table tbody tr:last-child td { border-bottom: none; }
.standings-table tbody tr:hover td { background: var(--card2); }

/* ── Zonas ── */
.zona-verde td { background: rgba(76,175,80,.06); }
.zona-rojo  td { background: rgba(255,77,77,.06); }
.zona-verde td:first-child { border-left: 3px solid var(--verde); }
.zona-rojo  td:first-child { border-left: 3px solid var(--red); }
.zona-verde .pos-num { color: var(--verde); }
.zona-rojo  .pos-num { color: var(--red); }
.zona-verde:hover td { background: rgba(76,175,80,.14) !important; }
.zona-rojo:hover  td { background: rgba(255,77,77,.14) !important; }

/* ── Número posición ── */
.pos-num {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.05rem;
}
tr:not(.zona-verde):not(.zona-rojo).pos-1 .pos-num { color: var(--yellow); }
tr:not(.zona-verde):not(.zona-rojo).pos-2 .pos-num { color: #c0c8d0; }
tr:not(.zona-verde):not(.zona-rojo).pos-3 .pos-num { color: #cd8c52; }

/* ── Celda equipo ── */
.team-cell { display: flex; align-items: center; gap: .6rem; }
.team-crest {
  width: 26px; height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.team-crest.placeholder {
  background: var(--grass);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  font-size: .65rem;
  font-weight: 700;
}

.pts-cell {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem;
  color: var(--lime);
}
.gd-pos { color: var(--verde); }
.gd-neg { color: var(--red); }
.gd-zero { color: var(--muted); }

/* ── Leyenda ── */
.leyenda {
  display: flex;
  gap: 1.2rem;
  margin-top: .8rem;
  flex-wrap: wrap;
  padding-left: .2rem;
}
.leyenda-item {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .75rem;
  color: var(--muted);
}
.leyenda-barra {
  width: 3px; height: 13px;
  border-radius: 2px;
  flex-shrink: 0;
}
.leyenda-barra.verde { background: var(--verde); }
.leyenda-barra.rojo  { background: var(--red); }

/* ══════════════════════════════════════════
   Partidos
══════════════════════════════════════════ */
.match-filters {
  display: flex;
  gap: .45rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filter-btn {
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: .08em;
  font-size: .9rem;
  padding: .3rem .95rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all .2s;
}
.filter-btn:hover { border-color: var(--lime-dim); color: var(--white); }
.filter-btn.active {
  background: var(--lime);
  border-color: var(--lime);
  color: var(--pitch);
  box-shadow: 0 0 12px rgba(181,255,77,.2);
}

.jornada-group { margin-bottom: 1.8rem; }
.jornada-label {
  font-family: 'Bebas Neue', sans-serif;
  font-size: .9rem;
  letter-spacing: .18em;
  color: var(--red);
  text-transform: uppercase;
  padding: .35rem 0;
  border-bottom: 2px solid var(--verde);
  margin-bottom: .7rem;
}

.match-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: .85rem 1.1rem;
  margin-bottom: .5rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: .8rem;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.match-card:hover {
  border-color: var(--lime-dim);
  background: var(--card2);
  box-shadow: 0 2px 16px rgba(181,255,77,.07);
}

.match-team {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-size: .9rem;
  font-weight: 500;
}
.match-team.away { flex-direction: row-reverse; text-align: right; }

.match-center { text-align: center; min-width: 80px; }

.score {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.7rem;
  letter-spacing: .05em;
  color: var(--white);
  line-height: 1;
}
.score .dash { color: var(--muted); margin: 0 .08em; }

.badge {
  display: inline-block;
  font-family: 'Bebas Neue', sans-serif;
  font-size: .65rem;
  letter-spacing: .08em;
  padding: .15rem .5rem;
  border-radius: 3px;
  margin-top: .25rem;
}
.badge-prog { background: rgba(77,166,255,.12); color: var(--blue);  border: 1px solid rgba(77,166,255,.25); }
.badge-fin  { background: rgba(181,255,77,.1);  color: var(--lime);  border: 1px solid rgba(181,255,77,.22); }
.badge-live { background: rgba(255,77,77,.12);  color: var(--red);   border: 1px solid rgba(255,77,77,.25); animation: pulse 1.4s infinite; }

@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.45; } }

.match-info-small {
  font-size: .7rem;
  color: var(--muted);
  margin-top: .2rem;
}

/* ══════════════════════════════════════════
   Loader
══════════════════════════════════════════ */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
  color: var(--muted);
  font-size: .88rem;
}
.spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--lime);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-right: .6rem;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════
   Footer
══════════════════════════════════════════ */
footer {
  background: linear-gradient(135deg, #1e3e1e 0%, var(--grass) 100%);
  border-top: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-family: 'Bebas Neue', sans-serif;
  font-size: .9rem;
  letter-spacing: .1em;
  color: var(--lime);
}
.footer-brand span.ico {
  font-size: 1.1rem;
  filter: drop-shadow(0 0 6px var(--lime));
}

.footer-info {
  font-size: .72rem;
  color: var(--muted);
  letter-spacing: .05em;
  text-align: center;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: .8rem;
}
.footer-links a {
  font-size: .72rem;
  color: var(--muted);
  text-decoration: none;
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: .08em;
  transition: color .2s;
}
.footer-links a:hover { color: var(--lime); }
.footer-links .sep { color: var(--border); }

/* ══════════════════════════════════════════
   Responsive — Tablet (≤ 768px)
══════════════════════════════════════════ */
@media (max-width: 768px) {
  header { padding: 0 1.2rem; gap: .7rem; }
  header h1 { font-size: 1.2rem; }
  .badge-admin { display: none; }

  .tabs, main { padding-left: 1.2rem; padding-right: 1.2rem; }

  .match-card { padding: .75rem .9rem; gap: .6rem; }
  .match-team { font-size: .85rem; gap: .4rem; }
  .score { font-size: 1.5rem; }

  footer { padding: .8rem 1.2rem; }
  .footer-info { display: none; }
}

/* ══════════════════════════════════════════
   Responsive — Mobile (≤ 480px)
══════════════════════════════════════════ */
@media (max-width: 480px) {
  header { padding: 0 1rem; height: 54px; gap: .5rem; }
  header h1 { font-size: 1rem; letter-spacing: .08em; }
  header .logo { font-size: 1.3rem; }

  .header-links a { padding: .28rem .6rem; font-size: .7rem; }

  .tabs { padding: 1rem 1rem .3rem; gap: .4rem; }
  .tab { font-size: .9rem; padding: .38rem 1rem; }

  main { padding: 1rem 1rem 2rem; }

  /* Tabla: ocultar columnas menos importantes */
  .standings-table th:nth-child(n+6):not(:last-child),
  .standings-table td:nth-child(n+6):not(:last-child) { display: none; }

  .match-card {
    grid-template-columns: 1fr auto 1fr;
    padding: .65rem .75rem;
    gap: .4rem;
  }
  .match-team { font-size: .8rem; gap: .3rem; }
  .match-team span { 
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90px;
  }
  .score { font-size: 1.35rem; }
  .match-center { min-width: 68px; }

  .team-crest { width: 22px; height: 22px; }

  footer {
    flex-direction: column;
    align-items: center;
    gap: .4rem;
    padding: .8rem 1rem;
    text-align: center;
  }
  .footer-links { gap: .6rem; }
}