:root {
  --bg: #070c15;
  --panel: #0f172a;
  --panel2: #16213a;
  --line: #24304a;
  --txt: #e8eefb;
  --muted: #8ea0bd;
  --red: #e11d48;
  --green: #22c55e;
  --gold: #f5b301;
  --blue: #3b82f6;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 50% -200px, #14203a 0%, var(--bg) 55%) no-repeat, var(--bg);
  color: var(--txt);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: #7db3ff; text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { width: min(1240px, 94vw); margin: 0 auto; }

/* ───────── topbar ───────── */
.topbar {
  background: rgba(9, 14, 25, .92);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(10px);
}
.topbar .wrap { display: flex; align-items: center; gap: 12px; height: 58px; }
.brand { font-weight: 800; letter-spacing: .4px; color: #fff; font-size: 16px; display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.brand em { font-style: normal; font-weight: 500; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1.4px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 12px var(--red); }
.mainnav { display: flex; gap: 2px; margin-left: 4px; flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a {
  color: var(--muted); padding: 7px 9px; border-radius: 8px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.mainnav a:hover { background: #182238; color: #fff; text-decoration: none; }
.mainnav a.on { background: #1d2b47; color: #fff; box-shadow: inset 0 0 0 1px #2c3d5e; }
.topright { margin-left: auto; display: flex; gap: 8px; flex: 0 0 auto; }
.ghost {
  font-size: 12.5px; color: var(--muted); border: 1px solid var(--line);
  padding: 6px 10px; border-radius: 8px; font-weight: 600;
}
.ghost:hover { color: #fff; border-color: #3a4c70; text-decoration: none; }
.ghost.danger:hover { color: #ffb4c4; border-color: #5e2437; background: #2a1420; }

main.wrap { padding: 22px 0 40px; }
.foot { text-align: center; color: #4f6180; font-size: 12px; padding: 26px 0; }

/* ───────── bloques ───────── */
.pagehead { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.pagehead h1 { font-size: 22px; margin: 0; letter-spacing: -.3px; }
.pagehead .sub { color: var(--muted); font-size: 13px; }
.spacer { margin-left: auto; }

.card {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); margin: 0 0 14px; font-weight: 700; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) {
  .g2, .g3 { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .v { font-size: 21px; }
  .pagehead h1 { font-size: 19px; }
}

.kpi { background: #0d1526; border: 1px solid var(--line); border-radius: 10px; padding: 13px 15px; }
.kpi .k { font-size: 11px; text-transform: uppercase; letter-spacing: 1.1px; color: var(--muted); font-weight: 700; }
.kpi .v { font-size: 25px; font-weight: 800; margin-top: 3px; letter-spacing: -.6px; }
.kpi .v small { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi.gold .v { color: var(--gold); }
.kpi.green .v { color: var(--green); }
.kpi.red .v { color: var(--red); }

/* ───────── controles ───────── */
label { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 700; display: block; margin-bottom: 5px; }
input[type=text], input[type=password], input[type=number], input[type=datetime-local], input[type=file], select, textarea {
  width: 100%; background: #0a1120; border: 1px solid var(--line); color: var(--txt);
  padding: 9px 11px; border-radius: 9px; font-size: 14px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #3d6dd8; box-shadow: 0 0 0 3px rgba(61,109,216,.16); }
textarea { resize: vertical; min-height: 90px; }
form.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
form.inline label { margin: 0; }
form.inline select { width: auto; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  background: #1e2b45; color: #fff; border: 1px solid #2d3f60;
  padding: 9px 15px; border-radius: 9px; font-weight: 700; font-size: 13.5px;
  cursor: pointer; font-family: inherit; transition: .15s;
}
.btn:hover { background: #26364f; text-decoration: none; }
.btn.primary { background: linear-gradient(180deg, #e11d48, #b30f36); border-color: #f04467; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.green { background: linear-gradient(180deg, #16a34a, #0f7a37); border-color: #22c55e; }
.btn.gold { background: linear-gradient(180deg, #e0a800, #b98600); border-color: #f5b301; color: #1a1200; }
.btn.ghostbtn { background: transparent; border-color: var(--line); color: var(--muted); }
.btn.ghostbtn:hover { color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ───────── badges / estados ───────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 800; letter-spacing: .9px; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px; border: 1px solid transparent;
}
.st-draft  { background: #1a2338; color: #93a4c1; border-color: #2a3a58; }
.st-open   { background: #0f2e1d; color: #4ade80; border-color: #1f6b3f; }
.st-locked { background: #2f2410; color: #fbbf24; border-color: #6b4e1a; }
.st-live   { background: #3a0f1c; color: #fb7185; border-color: #7a1e33; }
.st-final  { background: #101d33; color: #93c5fd; border-color: #2a4570; }
.pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #1b2740; color: var(--muted); }

.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; font-weight: 600; }
/* Con JS activo el flash se oculta (lo muestra SweetAlert como toast). Sin JS, se ve la banda. */
.js-swal .flash[data-swal] { display: none; }
.flash.ok { background: #0d2a1b; border: 1px solid #1c6b3f; color: #7ff0ab; }
.flash.err { background: #2c1020; border: 1px solid #7a1e33; color: #ffb4c4; }
.flash.warn { background: #2c2410; border: 1px solid #6b541a; color: #fcd97a; }

/* ───────── tablas ───────── */
.tablewrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  background: #111c31; color: #9fb1cd; text-align: center; padding: 9px 8px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .7px; font-weight: 800;
  border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0;
}
thead th.left, td.left { text-align: left; }
tbody td { padding: 8px; border-bottom: 1px solid #1a2438; text-align: center; }
tbody tr:hover { background: #131e33; }
tbody tr:last-child td { border-bottom: 0; }
td.name { font-weight: 700; white-space: nowrap; }
td.num { font-variant-numeric: tabular-nums; font-weight: 700; }
/* Empate en aciertos: los que pelean el desempate (azul) */
tr.contender td { background: rgba(56,189,248,.08); }
tr.contender td.name { color: #9ad8ff; }
tr.contender td.rank { color: #38bdf8; }
tr.contender td:first-child { box-shadow: inset 3px 0 0 #38bdf8; }

/* 1er lugar: resaltado fuerte (oro) — manda sobre contender */
tr.top1 td { background: linear-gradient(90deg, rgba(245,179,1,.24), rgba(245,179,1,.09)); }
tr.top1 td.name { color: var(--gold); font-size: 15px; font-weight: 900; letter-spacing: .3px; }
tr.top1 td.rank { color: var(--gold); font-size: 17px; }
tr.top1 td.num { color: var(--gold); }
tr.top1 td:first-child { box-shadow: inset 4px 0 0 var(--gold); }
.rank { font-weight: 800; color: var(--muted); width: 40px; }

.pk { display: inline-block; min-width: 34px; padding: 3px 6px; border-radius: 6px; font-size: 11.5px; font-weight: 800; }
.pk.hit { background: #0f3320; color: #6ee7a0; }
.pk.miss { background: #33101c; color: #ff9db1; }
.pk.none { background: #1a2338; color: #64748b; }
.pk.wait { background: #1c2740; color: #a9bbd8; }

/* ───────── juegos ───────── */
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.game {
  background: #0c1526; border: 1px solid var(--line); border-radius: 11px; padding: 12px 13px;
  position: relative; overflow: hidden;
}
.game.live { border-color: #7a1e33; box-shadow: 0 0 0 1px rgba(225,29,72,.25), 0 0 22px rgba(225,29,72,.12); }
.game.final { opacity: .92; }
.game .top { display: flex; justify-content: space-between; align-items: center; font-size: 10.5px; color: var(--muted); font-weight: 700; letter-spacing: .6px; text-transform: uppercase; margin-bottom: 9px; }
.game .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; min-width: 0; }
.game .team { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; }
.game .team .nm { display: flex; flex-direction: column; line-height: 1.18; min-width: 0; }
.game .team .abbr { font-size: 14px; font-weight: 800; letter-spacing: .3px; }
.game .team .ab { font-size: 10px; color: var(--muted); font-weight: 700; letter-spacing: .2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game .sc { flex: 0 0 auto; }

/* escudos */
.tlogo {
  width: 28px; height: 28px; object-fit: contain; flex: 0 0 auto;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, .55));
}
.tlogo.sm { width: 20px; height: 20px; }
.tlogo.xs { width: 17px; height: 17px; }
.game .team.lose .tlogo { opacity: .55; filter: grayscale(.55) drop-shadow(0 2px 5px rgba(0,0,0,.55)); }
.game .sc { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.game .win { color: #fff; }
.game .lose { color: #6b7f9c; }
.game .dotlive { width: 7px; height: 7px; border-radius: 50%; background: var(--red); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

/* ───────── público ───────── */
.hero { text-align: center; padding: 18px 0 6px; }
.hero h1 { font-size: clamp(26px, 5vw, 42px); margin: 0; letter-spacing: -1.2px; font-weight: 900; }
.hero h1 span { color: var(--red); }
.hero .sub { color: var(--muted); margin-top: 6px; font-size: 14px; }
.countdown { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--gold); }

/* ───────── carga IA ───────── */
.drop {
  border: 2px dashed #2c3d5e; border-radius: 14px; padding: 30px; text-align: center;
  background: #0a1220; cursor: pointer; transition: .18s;
}
.drop:hover, .drop.over { border-color: var(--blue); background: #0d1830; }
.drop .big { font-size: 30px; }
.drop p { color: var(--muted); margin: 8px 0 0; font-size: 13.5px; }

.review { display: grid; grid-template-columns: 220px 1fr; gap: 16px; align-items: start; }
@media (max-width: 760px) { .review { grid-template-columns: 1fr; } }
.review img { width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.pickrow { display: grid; grid-template-columns: 26px 1fr 1fr; gap: 6px; align-items: center; margin-bottom: 4px; font-size: 12.5px; }
.pickrow .no { color: var(--muted); font-weight: 800; text-align: right; font-size: 11px; }
.opt {
  display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 7px;
  border: 1px solid var(--line); background: #0b1322; cursor: pointer; font-weight: 700; font-size: 12.5px;
}
.opt:hover { border-color: #3a4c70; }
.opt.on { background: #10331f; border-color: #1f6b3f; color: #7ff0ab; }
.opt input { display: none; }

.outbox-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: #0b1322; }
.outbox-item .meta { display: flex; gap: 8px; align-items: center; margin-bottom: 7px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .7px; font-weight: 700; }
.outbox-item pre { margin: 0; white-space: pre-wrap; font-family: inherit; font-size: 13px; color: #cfdcf2; }

.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.hr { height: 1px; background: var(--line); margin: 16px 0; border: 0; }
.chip { display: inline-block; padding: 3px 9px; border-radius: 999px; background: #17233c; color: #a9bbd8; font-size: 11.5px; font-weight: 700; margin: 0 4px 4px 0; }

.loginbox { max-width: 380px; margin: 10vh auto; }

/* ───────── Ganador (festejo) ───────── */
.winner {
  position: relative; margin: 0 0 18px; padding: 26px 20px 30px; border-radius: 16px;
  text-align: center; overflow: hidden;
  background: radial-gradient(120% 130% at 50% 0%, rgba(245,179,1,.32), rgba(245,179,1,.05) 62%, transparent);
  border: 1px solid rgba(245,179,1,.5);
  box-shadow: 0 0 46px rgba(245,179,1,.22), inset 0 0 30px rgba(245,179,1,.06);
}
.winner.hidden { display: none; }
.winner .crown { font-size: 44px; line-height: 1; filter: drop-shadow(0 0 12px rgba(245,179,1,.6)); animation: crownPop .7s ease-out both; }
.winner .k { margin-top: 8px; font-size: 12px; letter-spacing: 3px; text-transform: uppercase; color: #f5b301; font-weight: 800; }
.winner .nm {
  font-size: clamp(38px, 8vw, 74px); font-weight: 900; line-height: 1.02; color: #ffd75e;
  text-shadow: 0 0 28px rgba(245,179,1,.55), 0 2px 0 rgba(0,0,0,.25); margin: 8px 0 6px;
  animation: namePop .6s cubic-bezier(.2,.9,.25,1.2) both;
}
.winner .sub { color: #cbd5e1; font-weight: 700; font-size: 15px; }
@keyframes crownPop { from { transform: scale(.4) rotate(-18deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes namePop { from { transform: translateY(14px) scale(.85); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 9999; display: none; }
#confetti.on { display: block; }

/* Confeti CSS dentro del banner del ganador (sin JavaScript) */
.winner .confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.winner .confetti i {
  position: absolute; top: -16px; width: 8px; height: 12px; border-radius: 2px;
  animation-name: confettiFall; animation-timing-function: linear; animation-iteration-count: infinite;
}
@keyframes confettiFall {
  0%   { transform: translateY(-30px) rotate(0deg); opacity: 0; }
  10%  { opacity: 1; }
  100% { transform: translateY(320px) rotate(540deg); opacity: 0; }
}
