:root {
  --bg: #0a0a0a;
  --panel: #111111;
  --soft: #161616;
  --txt: #ededed;
  --muted: #8a8a8a;
  --line: #262626;
  --line-strong: #3a3a3a;
  --ink: #ededed;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--txt);
  background: var(--bg);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--txt); text-decoration: none; border-bottom: 1px solid var(--line-strong); }
a:hover { border-color: var(--txt); }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 24px; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(10,10,10,.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; color: var(--txt); border: none; font-weight: 600; }
.brand:hover { border: none; }
.brand strong { font-weight: 800; }
.ball { font-size: 1.3rem; filter: grayscale(1) brightness(1.6); }
.nav { display: flex; align-items: center; gap: 22px; }
.nav a { color: var(--muted); font-weight: 500; border: none; font-size: .95rem; }
.nav a:hover { color: var(--txt); border: none; }
.who { color: var(--txt); font-weight: 600; font-size: .95rem; }

/* Buttons */
.btn {
  display: inline-block; background: var(--ink); color: #0a0a0a; font-weight: 600;
  padding: 9px 18px; border-radius: 8px; border: 1px solid var(--ink); cursor: pointer;
  transition: opacity .15s ease;
}
.btn:hover { opacity: .82; border: 1px solid var(--ink); }
.btn.big { padding: 12px 24px; font-size: 1rem; }
.btn.small { padding: 6px 13px; font-size: .85rem; }
.btn-ghost {
  display: inline-block; border: 1px solid var(--line-strong); color: var(--txt);
  padding: 8px 17px; border-radius: 8px; font-weight: 600; cursor: pointer; background: transparent;
}
.btn-ghost:hover { border-color: var(--txt); }
.btn-ghost.small { padding: 5px 12px; font-size: .85rem; }
.danger { color: var(--muted); }
.danger:hover { color: var(--txt); border-color: var(--txt); }

/* Flash */
.flashes { margin: 20px 0; display: grid; gap: 8px; }
.flash { padding: 11px 16px; border-radius: 8px; font-weight: 500; border: 1px solid var(--line); background: var(--soft); border-left: 3px solid var(--ink); }
.flash-ok { border-left-color: var(--ink); }
.flash-error { border-left-color: #fff; background: #1c1c1c; font-weight: 600; }
.flash-warn { border-left-color: var(--muted); }

/* Hero */
.hero {
  display: grid; grid-template-columns: 1.7fr 1fr; gap: 36px; align-items: center;
  margin: 44px 0 28px; padding: 0;
}
.hero h1 { font-size: 2.8rem; line-height: 1.05; margin: 0 0 14px; font-weight: 800; letter-spacing: -.02em; }
.grad { color: var(--txt); }
.hero p { color: var(--muted); font-size: 1.1rem; margin: 0 0 24px; max-width: 46ch; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.rules-mini { display: flex; gap: 22px; flex-wrap: wrap; color: var(--muted); font-size: .9rem; }
.rules-mini strong { color: var(--txt); }
.hero-stats { display: grid; gap: 14px; }
.stat { background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; text-align: center; }
.stat .num { font-size: 2.1rem; font-weight: 800; color: var(--txt); letter-spacing: -.02em; }
.stat .lbl { color: var(--muted); font-size: .85rem; }

/* Card */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px; margin: 20px 0;
}
.card h2 { margin-top: 0; font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* Cómo funciona (compacto) */
.howto.compact { padding: 18px 22px; }
.howto.compact h2 { font-size: 1.05rem; margin-bottom: 10px; }
.howto .steps { list-style: none; counter-reset: step; margin: 0 0 12px; padding: 0; display: grid; gap: 7px; }
.howto .steps li {
  counter-increment: step; position: relative; padding-left: 30px; color: var(--muted);
  font-size: .9rem; line-height: 1.45;
}
.howto .steps li::before {
  content: counter(step); position: absolute; left: 0; top: 1px;
  width: 19px; height: 19px; border-radius: 999px; background: var(--ink); color: #0a0a0a;
  font-size: .7rem; font-weight: 700; display: grid; place-items: center;
}
.howto .steps li strong { color: var(--txt); font-weight: 600; }
.howto-note { color: var(--muted); margin: 0; font-size: .85rem; }

/* Featured: tabla destacada */
.card.featured { border: 1.5px solid var(--line-strong); background: var(--soft); padding: 8px 26px 22px; }
.featured-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 6px; }
.featured-head h2 { margin: 18px 0 0; font-size: 1.45rem; }
.featured-head .muted { font-size: .85rem; }
.card.featured .leaderboard tbody tr:hover { background: rgba(255,255,255,.03); }

/* Leaderboard */
.table-scroll { overflow-x: auto; }
.leaderboard { width: 100%; border-collapse: collapse; }
.leaderboard th, .leaderboard td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); }
.leaderboard th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.leaderboard .rank { font-weight: 700; width: 50px; }
.leaderboard .player { font-weight: 600; }
.leaderboard .pts strong { color: var(--txt); font-size: 1.1rem; font-weight: 800; }
.leaderboard tbody tr:hover { background: rgba(255,255,255,.03); }
.leaderboard tr.top1 { background: rgba(255,255,255,.06); }
.leaderboard tr.top1 .player { font-weight: 800; }

/* Group standings grid */
.groups-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
/* En la página de pronósticos las columnas son más anchas (caben nombres largos + inputs). */
.groups-grid.pred { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.group-box { background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.group-box h3 { margin: 0 0 10px; color: var(--txt); font-size: 1rem; font-weight: 700; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.standings { width: 100%; border-collapse: collapse; font-size: .88rem; }
.standings th, .standings td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: center; }
.standings th { color: var(--muted); font-weight: 600; font-size: .78rem; }
.standings th:first-child, .standings td.team { text-align: left; }
.standings .qualified td { font-weight: 600; }
.standings .qualified td.team::before { content: "— "; color: var(--txt); }

/* Match row (predictions) */
.match { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 9px; }
.match.locked { background: var(--soft); opacity: .75; }
.match-slot { font-size: .76rem; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.match-row { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); align-items: center; gap: 12px; }
.team { font-weight: 600; font-size: .92rem; line-height: 1.25; overflow-wrap: anywhere; }
.team.home { text-align: right; }
.team.away { text-align: left; }
.score { display: flex; align-items: center; gap: 8px; }
.score-in {
  width: 50px; height: 42px; text-align: center; font-size: 1.15rem; font-weight: 700;
  background: #0a0a0a; color: var(--txt); border: 1px solid var(--line-strong); border-radius: 8px;
}
.score-in:focus { outline: none; border-color: var(--txt); box-shadow: 0 0 0 2px rgba(255,255,255,.12); }
.score-in:disabled { background: var(--soft); color: var(--muted); }
.sep { color: var(--muted); font-weight: 600; }
.match-meta { margin-top: 8px; font-size: .8rem; text-align: center; }
.match-meta .result { color: var(--txt); font-weight: 700; }
.match-meta .lock { color: var(--muted); }
.match-meta .kickoff { color: var(--muted); }
.ko-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 9px; }

/* Predictions header */
.sticky-head { position: sticky; top: 64px; z-index: 30; }
.pred-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.pred-header h1 { margin: 0 0 4px; font-size: 1.5rem; font-weight: 800; }
.save-area { display: flex; align-items: center; gap: 12px; }
#save-status.ok { color: var(--txt); font-weight: 600; }
#save-status.err { color: var(--txt); font-weight: 700; text-decoration: underline; }

/* Auth */
.auth-card { max-width: 400px; margin: 56px auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 34px; }
.auth-card h1 { margin-top: 0; font-size: 1.6rem; font-weight: 800; }
.auth-form { display: grid; gap: 16px; margin: 22px 0; }
.auth-form label { display: grid; gap: 6px; font-weight: 600; font-size: .92rem; }
.auth-form small { color: var(--muted); font-weight: 400; }
.auth-form input { padding: 11px 13px; border-radius: 8px; border: 1px solid var(--line-strong); background: #0a0a0a; color: var(--txt); font-size: 1rem; }
.auth-form input:focus { outline: none; border-color: var(--txt); }

/* Admin */
.new-match { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.new-match input, .new-match select { padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line-strong); background: #0a0a0a; color: var(--txt); }
.admin-list { display: grid; gap: 10px; }
.admin-match { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.admin-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-line.second { margin-top: 10px; }
.chip { background: var(--ink); color: #0a0a0a; padding: 3px 9px; border-radius: 6px; font-size: .72rem; font-weight: 700; }
.chip.alt { background: transparent; color: var(--muted); border: 1px solid var(--line-strong); }
.t-in { flex: 1; min-width: 120px; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--line-strong); background: #0a0a0a; color: var(--txt); }
.s-in { width: 48px; text-align: center; padding: 8px; border-radius: 6px; border: 1px solid var(--line-strong); background: #0a0a0a; color: var(--txt); }
.admin-line input[type=datetime-local] { padding: 8px 10px; border-radius: 6px; border: 1px solid var(--line-strong); background: #0a0a0a; color: var(--txt); color-scheme: dark; }
.fin { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .9rem; }

/* Footer */
.footer { border-top: 1px solid var(--line); margin-top: 48px; padding: 26px 0; color: var(--muted); font-size: .88rem; text-align: center; }

@media (max-width: 760px) {
  .wrap { padding: 0 14px; }

  /* Header: no amontonar; ocultar saludo y achicar */
  .topbar .wrap { height: auto; min-height: 56px; padding-top: 8px; padding-bottom: 8px; }
  .brand { font-size: .98rem; }
  .nav { gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
  .nav a { font-size: .9rem; }
  .who { display: none; }

  .hero { grid-template-columns: 1fr; gap: 22px; margin: 26px 0 22px; }
  .hero h1 { font-size: 2rem; }
  .hero p { font-size: 1rem; }
  .hero-stats { grid-template-columns: 1fr 1fr; }
  .hero-cta .btn, .hero-cta .btn-ghost { flex: 1; text-align: center; }

  .sticky-head { position: static; }

  /* Tarjetas más compactas */
  .card { padding: 18px 15px; }
  .card.featured { padding: 6px 15px 18px; }
  .featured-head h2 { font-size: 1.25rem; }

  /* Todas las rejillas a una sola columna (evita desborde horizontal) */
  .groups-grid, .groups-grid.pred, .ko-list, .howto .steps { grid-template-columns: 1fr; }

  /* Tabla de posiciones: ocultar columnas secundarias en móvil */
  .leaderboard th:nth-child(4), .leaderboard td:nth-child(4),
  .leaderboard th:nth-child(5), .leaderboard td:nth-child(5) { display: none; }
  .leaderboard th, .leaderboard td { padding: 11px 9px; }

  /* Pronósticos: header apilado */
  .pred-header { flex-direction: column; align-items: stretch; }
  .save-area { justify-content: space-between; }

  /* Inputs de marcador un poco más chicos */
  .score-in { width: 46px; height: 40px; font-size: 1.05rem; }

  /* Admin: que los inputs de equipo no fuercen ancho */
  .t-in { min-width: 90px; }
}

@media (max-width: 380px) {
  .hero h1 { font-size: 1.75rem; }
  .hero-stats { grid-template-columns: 1fr; }
  .team { font-size: .86rem; }
}
