@font-face {
  font-family: 'HelveticaNeueLT';
  src: url('font/Helvetica%20Neue%20LT%20Std%2045%20Light.ttf') format('truetype');
  font-weight: 300; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'HelveticaNeueLT';
  src: url('font/Helvetica%20Neue%20LT%20Std%2065%20Medium.ttf') format('truetype');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'HelveticaNeueLT';
  src: url('font/Helvetica%20Neue%20LT%20Std%2075%20Bold.ttf') format('truetype');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Poppins';
  src: url('font/Poppins-Regular.ttf') format('truetype');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Poppins';
  src: url('font/Poppins-SemiBold.ttf') format('truetype');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Poppins';
  src: url('font/Poppins-Bold.ttf') format('truetype');
  font-weight: 700; font-style: normal; font-display: swap;
}

* { box-sizing: border-box; }
:root {
  --brand: #1570ef;
  --brand-dark: #0f56b9;
  --ink: #000000;
  --paper: #ffffff;
  --muted: #6b7280;
  --line: #e5e7eb;
  --soft: #f5f8ff;
}
[data-theme="dark"] {
  --brand: #4b9aff;
  --brand-dark: #1570ef;
  --ink: #f0f4ff;
  --paper: #0f1117;
  --muted: #9ca3af;
  --line: #2a2d3a;
  --soft: #1a1d27;
}
html, body {
  font-family: 'HelveticaNeueLT', 'Poppins', -apple-system, Segoe UI, Roboto, sans-serif;
  font-weight: 500;
  margin: 0; padding: 0;
  background: var(--paper) !important; color: var(--ink) !important;
  min-height: 100vh; width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}
main { background: var(--paper) !important; }

/* Quita el auto-link / auto-color del navegador en móvil sobre texto plano */
a[x-apple-data-detectors],
a[x-apple-data-detectors] *,
.muted, .reglas-list, .auth-foot { color: inherit; }
.muted { color: var(--muted) !important; }
.auth-foot { color: var(--muted) !important; }
header {
  background: var(--paper);
  padding: 1rem 2rem; color: var(--ink);
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  border-bottom: 3px solid var(--brand);
}
header h1 { margin: 0; font-size: 1.4rem; display: flex; align-items: center; gap: .6rem; color: var(--ink); }
header h1 .logo { height: 70px; width: auto; display: block; }
header nav { color: var(--ink); }
header nav a { color: var(--ink); margin-left: 1rem; text-decoration: none; font-weight: 700; }
header nav a:hover { color: var(--brand); }
main { max-width: 1100px; margin: 2rem auto; padding: 0 1rem; }
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 1.5rem;
  margin-bottom: 1.5rem; box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
h1, h2, h3 { font-family: 'HelveticaNeueLT', 'Poppins', sans-serif; font-weight: 700; }
h2 { margin-top: 0; color: var(--ink); }
h3 { color: var(--brand); }
button, .btn { font-family: 'HelveticaNeueLT', 'Poppins', sans-serif; font-weight: 700; }
input, select { font-family: 'HelveticaNeueLT', 'Poppins', sans-serif; }
form label { display: block; margin: .5rem 0 .25rem; font-size: .9rem; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=datetime-local], select {
  width: 100%; padding: .5rem; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); border-radius: 8px;
}
input[type=number] { width: 70px; text-align: center; }
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(21,112,239,.18); }
button, .btn {
  background: var(--brand); color: var(--paper); border: 0; padding: .6rem 1.2rem;
  border-radius: 8px; font-weight: 700; cursor: pointer; text-decoration: none;
  display: inline-block; margin-top: .5rem;
}
button:hover { background: var(--brand-dark); }
table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
th, td { padding: .6rem; text-align: left; border-bottom: 1px solid var(--line); }
th { background: var(--soft); color: var(--ink); }
tr:hover { background: var(--soft); }
.fila-yo { background: var(--soft); font-weight: 700; }
.fila-yo td { color: var(--ink); }

/* Selector de campeón con banderas */
.campeon-picker { position: relative; flex: 1; min-width: 240px; }
.cp-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  background: var(--paper); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: .55rem .75rem; font-weight: 600; margin: 0; cursor: pointer;
}
.cp-toggle:hover { background: var(--soft); }
.cp-toggle .flag-img { width: 26px; height: 17px; }
.cp-list {
  position: absolute; z-index: 50; top: calc(100% + 4px); left: 0; right: 0;
  max-height: 320px; overflow-y: auto; background: var(--paper);
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 24px rgba(0,0,0,.18); padding: .25rem;
}
.cp-group { font-size: .72rem; font-weight: 700; color: var(--muted); padding: .5rem .6rem .2rem; text-transform: uppercase; letter-spacing: .05em; }
.cp-item {
  display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left;
  background: none; color: var(--ink); border: 0; padding: .45rem .6rem;
  border-radius: 8px; cursor: pointer; font-weight: 600; margin: 0;
}
.cp-item:hover { background: var(--soft); color: var(--ink); }
.cp-item .flag-img { width: 28px; height: 19px; }
.campeon-elegido { display: flex; align-items: center; gap: .6rem; font-size: 1.1rem; }
.campeon-elegido .flag-img { width: 36px; height: 24px; }

/* Tabla del ranking */
.tabla-ranking .col-num { text-align: center; white-space: nowrap; width: 1%; }
.tabla-ranking .col-nombre { word-break: break-word; }
.tabla-ranking td.col-num:first-child { font-size: 1.1rem; }

@media (max-width: 520px) {
  .tabla-ranking { margin-top: .5rem; font-size: .85rem; }
  .tabla-ranking th, .tabla-ranking td { padding: .5rem .4rem; }
  .tabla-ranking th { font-size: .7rem; text-transform: uppercase; letter-spacing: .03em; }
  .tabla-ranking .col-nombre { line-height: 1.25; }
  .tabla-ranking td.col-num:first-child { font-size: 1rem; }
  .pag-btn { padding: .35rem .65rem; font-size: .8rem; }
}

/* Paginación del ranking */
.paginacion { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; margin-top: 1.25rem; }
.pag-btn {
  display: inline-block; padding: .45rem .85rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  font-weight: 700; text-decoration: none; font-size: .9rem;
}
a.pag-btn:hover { background: var(--soft); color: var(--brand); }
.pag-actual { background: var(--brand); color: var(--paper); border-color: var(--brand); }
.partido { display: grid; grid-template-columns: 1fr 80px 1fr; align-items: center; gap: .5rem; padding: .75rem; border-bottom: 1px solid var(--line); }
.partido .equipo { font-weight: 700; color: var(--ink); }
.partido .equipo.local { text-align: right; }
.partido .marcador { display: flex; gap: .25rem; align-items: center; justify-content: center; }
.partido .info { grid-column: 1 / -1; font-size: .8rem; color: var(--muted); }
.cerrado { opacity: .55; }
.badge { display: inline-block; padding: .2rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--brand); color: var(--paper); }
.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; padding: .75rem; border-radius: 8px; margin-bottom: 1rem; }
.ok { background: var(--soft); color: var(--brand-dark); border: 1px solid var(--brand); padding: .75rem; border-radius: 8px; margin-bottom: 1rem; }
.muted { color: var(--muted); font-size: .85rem; }
.reglas { background: var(--soft); padding: 1rem; border-radius: 8px; border: 1px solid var(--line); }
.reglas li { margin: .25rem 0; }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
.flag { font-size: 1.4rem; vertical-align: middle; }
.admin-tag { font-size: .85rem; font-weight: 700; background: var(--brand); color: var(--paper); padding: .2rem .6rem; border-radius: 999px; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 1rem; }
.modal[hidden] { display: none; }
.modal-card { background: var(--paper); border-radius: 14px; padding: 1.75rem; max-width: 440px; width: 100%; box-shadow: 0 20px 40px rgba(0,0,0,.25); animation: pop .15s ease-out; }
.modal-card h3 { margin: 0 0 .75rem; color: var(--ink); font-size: 1.25rem; }
.modal-card p { margin: .5rem 0; line-height: 1.4; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.5rem; }
.btn-cancel { background: var(--soft); color: var(--ink); border: 1px solid var(--line); padding: .6rem 1.2rem; border-radius: 8px; font-weight: 700; cursor: pointer; }
.btn-cancel:hover { background: var(--line); }
.btn-danger { background: #dc2626; color: var(--paper); border: 0; padding: .6rem 1.2rem; border-radius: 8px; font-weight: 700; cursor: pointer; }
.btn-danger:hover { background: #b91c1c; }
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Tarjeta de foto */
.foto-card {
  display: flex; align-items: center; gap: 1rem;
  text-decoration: none; color: var(--ink) !important;
  cursor: pointer;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: var(--paper) !important; padding: 1.25rem;
  border: 0;
  transition: transform .15s, box-shadow .15s;
}
.foto-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(21,112,239,.3); }
.foto-card .muted { color: rgba(255,255,255,.85) !important; }
.foto-icon { font-size: 2rem; flex-shrink: 0; background: rgba(255,255,255,.18); width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.foto-title { font-size: 1.05rem; font-weight: 700; color: var(--paper); }
.foto-arrow { margin-left: auto; font-size: 1.5rem; font-weight: 700; opacity: .85; }

/* Pantalla de login / registro */
.auth-wrap { max-width: 460px; width: 100%; margin: 2rem auto; padding: 0 1rem; }
.auth-card { padding: 2rem; }
.auth-head { text-align: center; margin-bottom: 1.5rem; }
.auth-head h2 { color: var(--ink); margin-bottom: .25rem; font-size: 1.5rem; }
.auth-form label { display: block; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-top: 1rem; }
.auth-form input { width: 100%; padding: .75rem .9rem; font-size: 1rem; }
.btn-block { width: 100%; padding: .85rem; font-size: 1rem; margin-top: 1.5rem; }
.auth-foot { text-align: center; margin-top: 1.5rem; color: var(--muted); font-size: .9rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.auth-foot a { font-weight: 700; }

/* Mobile: auth fill width */
@media (max-width: 520px) {
  /* Encabezado en columna: logo arriba, menú centrado abajo */
  header { flex-direction: column; gap: .5rem; padding: .6rem .75rem .55rem; }
  header h1 .logo { height: 44px; }
  header nav { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .3rem 1rem; }
  header nav a { margin-left: 0; font-size: .85rem; white-space: nowrap; }
  .theme-toggle { margin-left: 0; padding: .25rem .6rem; font-size: .9rem; }
  .card { padding: 1rem; }
  .auth-wrap { margin: 1rem auto; padding: 0 .75rem; max-width: 100%; }
  .auth-card { padding: 1.25rem; }
  .auth-head h2 { font-size: 1.25rem; }
  .reglas-card { padding: 1.25rem; }
  .reglas-list li { padding: .6rem 0; gap: .75rem; }
  .pts { width: 38px; height: 38px; font-size: 1rem; }
  main { margin: 1rem auto; }
}

/* Reglas */
.reglas-card { padding: 1.75rem; }
.reglas-list { list-style: none; padding: 0; margin: 1rem 0 0; }
.reglas-list li { display: flex; align-items: center; gap: 1rem; padding: .75rem 0; border-bottom: 1px solid var(--line); }
.reglas-list li:last-child { border-bottom: 0; }
.pts { flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.1rem; color: var(--paper); }
.pts-5 { background: var(--brand); }
.pts-3 { background: #0f56b9; }
.pts-2 { background: #4b9aff; }
.pts-0 { background: #9ca3af; }

/* Banderas reales */
.flag-img { width: 36px; height: 24px; object-fit: cover; border-radius: 3px; box-shadow: 0 1px 3px rgba(0,0,0,.18); display: inline-block; vertical-align: middle; }
.td-partido { white-space: nowrap; }
.td-partido .flag-img { width: 28px; height: 19px; margin: 0 .25rem; }
.flag-placeholder { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 24px; background: var(--soft); border-radius: 3px; font-size: 1rem; }

/* Resumen del usuario */
.user-summary { display: flex; justify-content: space-between; align-items: center; background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%); color: var(--paper); border-radius: 12px; padding: 1.25rem 1.75rem; margin-bottom: 1.5rem; box-shadow: 0 4px 14px rgba(21,112,239,.25); }
.user-hello { font-size: 1.2rem; }
.user-summary,
.user-summary * { color: #ffffff !important; }
.user-summary .muted { color: rgba(255,255,255,.9) !important; }
.user-stats { text-align: right; }
.stat-num { font-size: 2.5rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .7rem; letter-spacing: .15em; opacity: .85; margin-top: .25rem; }

/* Título de fase */
.fase-title { margin: 2rem 0 1rem; padding-bottom: .5rem; border-bottom: 2px solid var(--brand); color: var(--ink); font-size: 1.3rem; }

/* Tarjeta de partido */
.match-card { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.25rem; margin-bottom: .85rem; transition: box-shadow .2s, transform .1s; }
.match-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.match-card.cerrado { background: var(--soft); }
.match-card.jugado { background: linear-gradient(0deg, rgba(21,112,239,.04), rgba(21,112,239,.04)), var(--paper); border-color: var(--brand); }

.match-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; font-size: .8rem; color: var(--muted); margin-bottom: .75rem; padding-bottom: .75rem; border-bottom: 1px dashed var(--line); }
.match-meta { flex: 1; min-width: 200px; }
.chip { display: inline-block; padding: .2rem .65rem; border-radius: 999px; font-size: .7rem; font-weight: 700; background: var(--soft); color: var(--brand-dark); border: 1px solid var(--line); text-transform: uppercase; letter-spacing: .05em; }
.chip-success { background: var(--brand); color: var(--paper); border-color: var(--brand); }
.chip-warn { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.chip-open { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.chip-cierre { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }

.match-body { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; }
.team { display: flex; align-items: center; gap: .75rem; }
.team-local { justify-content: flex-end; text-align: right; }
.team-visita { justify-content: flex-start; }
.team-name { font-size: 1.05rem; font-weight: 700; color: var(--ink); }

.score-box { display: flex; align-items: center; gap: .6rem; background: var(--soft); padding: .5rem .75rem; border-radius: 10px; border: 1px solid var(--line); }
.score-side { display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.score-side input { width: 50px; padding: .4rem; font-size: 1.2rem; font-weight: 700; text-align: center; border: 1px solid var(--line); background: var(--paper); border-radius: 6px; }
.score-side input:disabled { background: var(--soft); color: var(--muted); cursor: not-allowed; }
.score-label { font-size: .65rem; font-weight: 700; letter-spacing: .08em; color: var(--brand-dark); background: var(--paper); padding: .1rem .35rem; border-radius: 4px; border: 1px solid var(--line); min-width: 38px; text-align: center; }
.score-sep { font-size: .8rem; color: var(--muted); font-weight: 700; align-self: center; }

.match-foot { margin-top: .75rem; padding-top: .5rem; border-top: 1px dashed var(--line); font-size: .85rem; color: var(--muted); text-align: center; }

/* Botón guardar fijo abajo (móvil y desktop) */
.sticky-save {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--paper); padding: .85rem 1.25rem;
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(0,0,0,.1);
  z-index: 100;
  display: flex; justify-content: center; align-items: center;
}
.sticky-save .btn-block {
  display: block;
  margin: 0; max-width: 420px; width: 100%;
}
/* Espacio al final para que el botón fijo no tape el último partido */
form#forma-pronosticos { padding-bottom: 6rem; }

/* Responsivo */
@media (max-width: 640px) {
  .user-summary { flex-direction: column; gap: 1rem; text-align: center; padding: 1rem; }
  .user-stats { text-align: center; }
  .stat-num { font-size: 2rem; }

  .match-card { padding: .75rem; margin-bottom: .6rem; }
  .match-head { font-size: .7rem; gap: .35rem; margin-bottom: .5rem; padding-bottom: .5rem; }
  .match-meta { min-width: 0; flex-basis: 100%; }
  .chip { padding: .15rem .5rem; font-size: .65rem; }

  /* Apilado vertical en móvil: equipo arriba, vs en medio, equipo abajo */
  .match-body { grid-template-columns: 1fr; gap: .5rem; text-align: center; }
  .team { justify-content: center; min-width: 0; }
  .team-local, .team-visita { justify-content: center; text-align: center; }
  .team-name { font-size: 1rem; line-height: 1.2; white-space: normal; word-break: break-word; }
  .flag-img { width: 32px; height: 22px; flex-shrink: 0; }

  .score-box { padding: .5rem .75rem; gap: .5rem; justify-content: center; }
  .score-side input { width: 56px; padding: .45rem; font-size: 1.2rem; }
  .score-label { font-size: .7rem; min-width: 42px; padding: .15rem .4rem; }
  .score-sep { font-size: .75rem; }

  .fase-title { font-size: 1.1rem; margin: 1.25rem 0 .75rem; }
  .sticky-save { padding: .75rem; bottom: .5rem; }
}

@media (max-width: 380px) {
  .team-name { font-size: .9rem; }
  .flag-img { width: 28px; height: 19px; }
}


/* Banner institucional */
.banner-wrap { max-width: 1100px; margin: 1.25rem auto 0; padding: 0 1rem; }
.banner-img { display: block; width: 100%; height: auto; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
@media (max-width: 520px) {
  .banner-wrap { margin-top: .75rem; padding: 0 .75rem; }
  .banner-img { border-radius: 8px; }
}

/* Dark mode toggle */
.theme-toggle {
  background: var(--soft); border: 1px solid var(--line); color: var(--ink);
  border-radius: 999px; padding: .35rem .75rem; font-size: 1rem;
  cursor: pointer; margin-left: 1rem; display: inline-flex; align-items: center;
  transition: background .2s;
}
.theme-toggle:hover { background: var(--line); }

/* ===== Bracket de eliminatorias ===== */
.bracket-card { padding: 1.25rem 1.25rem 1rem; }
.bracket-summary {
  list-style: none; cursor: pointer; display: flex; align-items: center;
  justify-content: space-between; gap: 1rem; font-weight: 800; font-size: 1.15rem;
  color: var(--ink);
}
.bracket-summary::-webkit-details-marker { display: none; }
.bracket-ico { margin-right: .35rem; }
.bracket-hint { font-size: .72rem; font-weight: 600; color: var(--muted); }
.bracket-card[open] .bracket-summary { margin-bottom: .5rem; }

.bracket-scroll {
  overflow-x: auto; padding: .5rem .25rem 1rem;
  -webkit-overflow-scrolling: touch;
}
.bracket-cols { display: inline-flex; gap: 1.25rem; min-width: 100%; }
.bracket-col { display: flex; flex-direction: column; gap: .75rem; min-width: 190px; }
.bracket-col-title {
  font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em;
  color: var(--brand); text-align: center; padding-bottom: .25rem;
  border-bottom: 2px solid var(--line);
}

.bk-match {
  border: 1px solid var(--line); border-radius: 10px; background: var(--soft);
  padding: .4rem .5rem; display: flex; flex-direction: column; gap: .25rem;
}
.bk-match.bk-jugado { border-color: var(--brand); }
.bk-meta {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .68rem; color: var(--muted);
}
.bk-fin { color: var(--brand); font-weight: 700; }

.bk-team {
  display: flex; align-items: center; gap: .45rem;
  padding: .2rem .15rem; border-radius: 6px;
}
.bk-team.bk-gana { background: rgba(21,112,239,.12); font-weight: 800; }
.bk-flag { width: 22px; display: inline-flex; flex: 0 0 auto; }
.bk-flag .flag-img { width: 22px; height: auto; border-radius: 2px; }
.bk-flag .flag-placeholder { color: var(--muted); }
.bk-name {
  flex: 1 1 auto; font-size: .82rem; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bk-score {
  flex: 0 0 auto; min-width: 1.1rem; text-align: center; font-weight: 800;
  color: var(--ink); font-variant-numeric: tabular-nums;
}

/* ===== Bracket en móvil ===== */
@media (max-width: 600px) {
  .bracket-card { padding: 1rem .75rem; }
  /* El área scrolleable usa todo el ancho de la tarjeta (rompe el padding) */
  .bracket-scroll {
    margin-left: -.75rem; margin-right: -.75rem;
    padding: .5rem .75rem 1rem;
    scroll-snap-type: x proximity;
  }
  .bracket-cols { gap: .75rem; }
  .bracket-col { min-width: 168px; scroll-snap-align: start; }
  .bracket-col-title { font-size: .72rem; }
  .bk-name { font-size: .78rem; }
  .bk-meta { font-size: .64rem; }
}
