:root {
  --bg: #0b0f14;
  --bg-2: #121823;
  --card: #19212e;
  --card-2: #1f2937;
  --border: #2a3545;
  --text: #eaf0f7;
  --muted: #94a3b8;
  --green: #19e07a;
  --green-dark: #0fae5e;
  --orange: #ff7a18;
  --red: #ef4444;
  --gold: #fbbf24;
  --silver: #cbd5e1;
  --bronze: #d6936b;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Roboto", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #16202e 0%, var(--bg) 55%) fixed;
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--green); }

/* ---------- Header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(11, 15, 20, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0.3px;
  font-size: 18px;
}
.brand .ball { font-size: 22px; }
.brand .logo { height: 32px; width: auto; display: block; }
.brand .accent { color: var(--green); }
.topbar .spacer { flex: 1; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}
.user-chip b { color: var(--text); }

/* ---------- Layout ---------- */
.container { max-width: 920px; margin: 0 auto; padding: 16px; }

.tabs {
  display: flex;
  gap: 8px;
  margin: 8px auto 18px;
  max-width: 920px;
  padding: 0 16px;
}
.tab {
  flex: 1;
  text-align: center;
  padding: 12px 8px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  transition: 0.15s;
  font-size: 14px;
}
.tab:hover:not(.active) { background: var(--card-2); color: var(--text); }
.tab.active {
  background: linear-gradient(180deg, var(--green) 0%, var(--green-dark) 100%);
  color: #04120a;
  border-color: transparent;
  box-shadow: 0 6px 16px rgba(25, 224, 122, 0.25);
}
.tab.active:hover { background: linear-gradient(180deg, var(--green-dark) 0%, #0a8f4d 100%); }

/* ---------- Buttons / inputs ---------- */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
button:active:not(:disabled) { transform: translateY(1px); }
.btn {
  padding: 12px 16px;
  background: linear-gradient(180deg, var(--green) 0%, var(--green-dark) 100%);
  color: #04120a;
  font-size: 15px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
}
.btn-orange { background: linear-gradient(180deg, var(--orange), #e85f00); color: #1a0c00; }
.btn-danger { background: transparent; border: 1px solid var(--red); color: var(--red); padding: 8px 12px; }
.btn-sm { padding: 8px 12px; font-size: 13px; }

/* Hover: tono más oscuro para que resalte */
.btn:hover:not(:disabled) { background: linear-gradient(180deg, var(--green-dark) 0%, #0a8f4d 100%); }
.btn-orange:hover:not(:disabled) { background: linear-gradient(180deg, #e85f00, #bf4e00); color: #fff; }
.btn-ghost:hover:not(:disabled) { background: var(--card-2); border-color: #3a4860; }
.btn-danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.18); }

input, select {
  font-family: inherit;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
  width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--green); border-color: transparent; }
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; font-weight: 600; }
.field { margin-bottom: 14px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.hint { color: var(--muted); font-size: 13px; }
.error-box {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 12px;
}
.ok-box {
  background: rgba(25, 224, 122, 0.12);
  border: 1px solid rgba(25, 224, 122, 0.4);
  color: #86efac;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 12px;
}

/* ---------- Auth ---------- */
.auth-wrap { max-width: 420px; margin: 6vh auto; padding: 0 16px; }
.auth-switch { text-align: center; margin-top: 14px; font-size: 14px; color: var(--muted); }
.auth-switch span { color: var(--green); cursor: pointer; font-weight: 700; }
.tagline { text-align: center; color: var(--muted); margin: 6px 0 22px; font-size: 14px; }

/* ---------- Stage groups ---------- */
.stage-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 4px 12px;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}
.stage-title::before {
  content: "";
  width: 4px; height: 18px;
  background: var(--green);
  border-radius: 2px;
}

/* ---------- Match card ---------- */
.match {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.match-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}
.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.badge.open { color: var(--green); border-color: rgba(25, 224, 122, 0.5); }
.badge.locked { color: var(--orange); border-color: rgba(255, 122, 24, 0.5); }
.badge.done { color: var(--muted); }

.match-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}
.team {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.team.away { flex-direction: row-reverse; text-align: right; }
.team img {
  width: 34px; height: 24px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.team .name { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.score-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}
.score-inputs input {
  width: 52px;
  text-align: center;
  font-size: 18px;
  font-weight: 800;
  padding: 8px 4px;
}
.score-inputs .sep { color: var(--muted); font-weight: 800; }

.score-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 1px;
  min-width: 92px;
}
.score-display .sep { color: var(--muted); }

.btn-group { display: flex; gap: 8px; align-items: center; }
.btn-cancel { background: var(--red); color: #fff; padding: 8px 12px; }
.btn-cancel:hover:not(:disabled) { background: #c62f2f; }

.match-final {
  text-align: center;
  font-size: 13px;
  margin-top: 10px;
  color: var(--muted);
}
.match-final b { color: var(--text); font-size: 16px; }

.match-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}
.pts {
  font-size: 13px;
  font-weight: 700;
}
.pts.p10 { color: var(--green); }
.pts.p4 { color: var(--gold); }
.pts.p0 { color: var(--muted); }
.countdown { font-variant-numeric: tabular-nums; color: var(--orange); font-weight: 700; }

/* ---------- Leaderboard ---------- */
.lb-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.lb-row:last-child { border-bottom: none; }
.lb-rank {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-weight: 800;
  background: var(--card-2);
  color: var(--muted);
}
.lb-row.top1 .lb-rank { background: var(--gold); color: #1a1300; }
.lb-row.top2 .lb-rank { background: var(--silver); color: #1a1f29; }
.lb-row.top3 .lb-rank { background: var(--bronze); color: #1a0d05; }
.lb-name { font-weight: 700; }
.lb-sub { font-size: 12px; color: var(--muted); }
.lb-points { font-weight: 800; font-size: 18px; color: var(--green); }
.lb-points small { color: var(--muted); font-weight: 600; font-size: 12px; }
.trophy { font-size: 14px; }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* ---------- Tabla de apuestas (admin) ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.bets { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.bets th, table.bets td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.bets thead th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--card-2);
}
table.bets tbody tr:last-child td { border-bottom: none; }
table.bets tbody tr:hover { background: var(--card-2); }
.bets .muted-cell { color: var(--muted); }
.bets .win-team { color: var(--green); font-weight: 700; }
.bets .win-draw { color: var(--gold); font-weight: 700; }

.footer-note { text-align: center; color: var(--muted); font-size: 12px; margin: 26px 0; }
.rules {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}
.rules b { color: var(--text); }

@media (max-width: 560px) {
  .team .name { font-size: 13px; }
  .score-inputs input { width: 44px; }
}
