:root {
  --bg: #0f172a;
  --card: #1e293b;
  --card-2: #243049;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --line: #334155;
  --ok: #22c55e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  min-height: 100vh;
}

/* Foto de fondo fija con velo oscuro para mantener la legibilidad */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(rgba(15, 23, 42, .80), rgba(15, 23, 42, .92)),
    url("background.jpg") center / cover no-repeat;
}

header {
  padding: 24px 16px 8px;
  text-align: center;
}
header h1 { margin: 0; font-size: 1.6rem; }
.subtitle { color: var(--muted); margin: 6px 0 0; font-size: .95rem; }

.group-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  padding: 12px 16px;
  background: rgba(15, 23, 42, .92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.group-nav a {
  color: var(--text);
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  font-weight: 600;
  font-size: .9rem;
}
.group-nav a:hover { border-color: var(--accent); color: var(--accent); }

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 20px;
}

.loading { text-align: center; color: var(--muted); }

.group {
  background: rgba(30, 41, 59, .82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(148, 163, 184, .22);
  border-radius: 14px;
  overflow: hidden;
  scroll-margin-top: 70px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
}
.group h2 {
  margin: 0;
  padding: 14px 16px;
  font-size: 1.15rem;
  background: rgba(36, 48, 73, .65);
  border-bottom: 1px solid var(--line);
}

.matchday-label {
  color: var(--muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 12px 16px 4px;
  font-weight: 700;
}

.match {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
}
.match .meta {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: .72rem;
  margin-bottom: 2px;
}
.team {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.team.home { justify-content: flex-end; text-align: right; }
.team.away { justify-content: flex-start; }
.team .flag {
  width: 32px;
  height: 24px;
  flex: 0 0 auto;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .12);
  background: var(--card-2);
}
.team .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  font-size: .95rem;
}

.score {
  display: flex;
  align-items: center;
  gap: 6px;
}
.score .goals {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 800;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, .55);
  color: var(--text);
}
.score .dash { color: var(--muted); font-weight: 700; }

.match.played { background: rgba(34, 197, 94, .05); }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ok);
  color: #06231a;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #ef4444; color: #fff; }

/* Tablets y pantallas medianas */
@media (max-width: 600px) {
  header { padding: 18px 12px 4px; }
  header h1 { font-size: 1.3rem; }
  main { padding: 12px; gap: 14px; }
  .match { padding: 9px 12px; gap: 6px; }
  .team .name { font-size: .9rem; }
  .team .flag { width: 28px; height: 21px; }
}

/* Celulares angostos: damos prioridad a banderas + marcador */
@media (max-width: 400px) {
  .group h2 { font-size: 1.05rem; padding: 12px; }
  .match { gap: 4px; }
  .team .name { font-size: .8rem; }
  .team .flag { width: 24px; height: 18px; }
  .score .goals { width: 32px; height: 34px; font-size: 1rem; }
  .score { gap: 4px; }
  .matchday-label { padding: 10px 12px 2px; }
}
