/* =========================================================================
   PORRA 26 — Sistema de diseño
   Identidad inspirada en el Mundial 2026: sistema multicolor vibrante
   (rosa, cian, lima, amarillo) + oro del trofeo, sobre base oscura glass.
   Tema claro y oscuro. Mucho dinamismo.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&family=Geist+Mono:wght@400;500;600&display=swap');

/* Polyfill de banderas para Windows (Edge/Chrome): Segoe UI Emoji no
   renderiza los pares "regional indicator" como bandera. Cargamos una
   webfont con SOLO los glifos de bandera y unicode-range restringido,
   así no afecta al resto del texto. */
@font-face {
  font-family: 'Twemoji Country Flags';
  unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E0063, U+E0065, U+E0067,
                 U+E006C, U+E006E, U+E0073-E0074, U+E0077, U+E007F;
  src: url('https://cdn.jsdelivr.net/npm/country-flag-emoji-polyfill@0.1/dist/TwemojiCountryFlags.woff2') format('woff2');
  font-display: swap;
}

:root {
  /* --- Acentos multicolor Mundial 26 (fijos en ambos temas) --- */
  --c-pink:   oklch(0.68 0.24 5);     /* rosa/magenta */
  --c-cyan:   oklch(0.78 0.15 210);   /* cian */
  --c-lime:   oklch(0.85 0.21 130);   /* lima */
  --c-yellow: oklch(0.86 0.18 95);    /* amarillo */
  --c-gold:   oklch(0.80 0.13 85);    /* oro trofeo */
  --c-blue:   oklch(0.62 0.20 250);   /* USA */
  --c-green:  oklch(0.70 0.18 150);   /* MEX */
  --c-red:    oklch(0.63 0.23 25);    /* CAN */

  /* acento primario (Mundial 26 → azul, igual que en design-reference/app.jsx) */
  --accent: var(--c-blue);
  --accent-2: var(--c-cyan);

  --font-display: 'Twemoji Country Flags', 'Sora', system-ui, sans-serif;
  --font-sans: 'Twemoji Country Flags', 'Inter', system-ui, sans-serif;
  --font-mono: 'Twemoji Country Flags', 'Geist Mono', ui-monospace, monospace;

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 32px;

  --anim: 1; /* multiplicador de intensidad de animación (0–1) controlado por Tweaks */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---------------- TEMA OSCURO (por defecto) ---------------- */
:root, [data-theme="dark"] {
  --bg-0: oklch(0.16 0.02 275);
  --bg-1: oklch(0.20 0.025 275);
  --bg-grad-a: oklch(0.19 0.05 300);
  --bg-grad-b: oklch(0.17 0.04 250);
  --surface: oklch(0.24 0.025 275 / 0.55);
  --surface-solid: oklch(0.22 0.025 275);
  --surface-hi: oklch(0.30 0.03 275 / 0.7);
  --border: oklch(0.95 0.02 275 / 0.10);
  --border-hi: oklch(0.95 0.02 275 / 0.22);
  --text: oklch(0.97 0.01 275);
  --text-dim: oklch(0.78 0.02 275);
  --text-faint: oklch(0.62 0.02 275);
  --glass-blur: 22px;
  --shadow-glow: 0 0 0 1px oklch(0.95 0.02 275 / 0.06), 0 24px 60px -20px oklch(0.05 0.05 280 / 0.7);
  color-scheme: dark;
}

/* ---------------- TEMA CLARO ---------------- */
[data-theme="light"] {
  --bg-0: oklch(0.97 0.012 270);
  --bg-1: oklch(0.99 0.008 270);
  --bg-grad-a: oklch(0.95 0.04 320);
  --bg-grad-b: oklch(0.95 0.035 220);
  --surface: oklch(1 0 0 / 0.7);
  --surface-solid: oklch(1 0 0);
  --surface-hi: oklch(1 0 0 / 0.95);
  --border: oklch(0.25 0.02 275 / 0.10);
  --border-hi: oklch(0.25 0.02 275 / 0.18);
  --text: oklch(0.22 0.03 275);
  --text-dim: oklch(0.42 0.03 275);
  --text-faint: oklch(0.58 0.025 275);
  --glass-blur: 18px;
  --shadow-glow: 0 1px 0 oklch(1 0 0 / 0.6) inset, 0 20px 50px -24px oklch(0.4 0.06 280 / 0.35);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-0);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  /* Sin overflow:hidden — el documento debe poder scrollear verticalmente
     en pantallas pequeñas para mostrar listas largas (partidos, jugadores,
     rankings). El fondo ambiente es position:fixed, así que no se mueve. */
}

/* ---------------- Fondo ambiente animado ---------------- */
.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: var(--bg-0);
}
.ambient::before {
  content: "";
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(40% 40% at 18% 22%, oklch(0.68 0.24 5 / 0.28), transparent 70%),
    radial-gradient(38% 38% at 82% 18%, oklch(0.78 0.15 210 / 0.24), transparent 70%),
    radial-gradient(45% 45% at 75% 85%, oklch(0.85 0.21 130 / 0.20), transparent 72%),
    radial-gradient(40% 40% at 22% 82%, oklch(0.86 0.18 95 / 0.18), transparent 72%);
  filter: blur(20px);
  animation: drift calc(28s / (var(--anim) + 0.15)) var(--ease-out) infinite alternate;
}
[data-theme="light"] .ambient::before { opacity: 0.55; }

@keyframes drift {
  0%   { transform: translate3d(-3%, -2%, 0) scale(1.05) rotate(0deg); }
  100% { transform: translate3d(4%, 3%, 0) scale(1.15) rotate(8deg); }
}

/* grano/pitch lines sutiles */
.ambient::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    90deg,
    transparent 0 119px,
    oklch(0.95 0.02 275 / 0.025) 119px 120px
  );
  mask-image: linear-gradient(180deg, transparent, black 40%, black 60%, transparent);
}

/* ---------------- Glass surfaces ---------------- */
.glass {
  background: var(--surface);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.3);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.3);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-glow);
}

/* ---------------- Tipografía utilidades ---------------- */
.display { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.02em; }
.mono { font-family: var(--font-mono); }
.eyebrow {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  color: var(--text-faint);
}

/* ---------------- Botones ---------------- */
.btn {
  font-family: var(--font-display);
  font-weight: 700;
  border: none;
  border-radius: var(--r-sm);
  padding: 12px 20px;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.25s var(--ease-spring), box-shadow 0.3s var(--ease-out), background 0.2s;
  position: relative;
  color: white;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 24px -8px var(--accent), 0 0 0 1px oklch(1 0 0 / 0.12) inset;
}
.btn-primary:hover {
  transform: translateY(calc(-2px * var(--anim)));
  box-shadow: 0 14px 34px -8px var(--accent), 0 0 22px -2px var(--accent-2), 0 0 0 1px oklch(1 0 0 / 0.2) inset;
}
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-ghost {
  background: var(--surface-hi);
  color: var(--text);
  border: 1px solid var(--border-hi);
  backdrop-filter: blur(10px);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--text); transform: translateY(calc(-1px * var(--anim))); }

/* ---------------- Navegación principal (topbar) ---------------- */
.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 13px;
  border: none;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  background: transparent;
  color: var(--text-dim);
  text-decoration: none;
  transition: background 0.25s var(--ease-out), color 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
  position: relative;
}
.nav-item svg { color: currentColor; transition: color 0.25s var(--ease-out); }
.nav-item:hover { color: var(--text); }
.nav-item.is-active {
  background: var(--surface-hi);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border-hi);
}
.nav-item.is-active svg { color: var(--accent); }
.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 3px;
  background: linear-gradient(var(--accent), var(--accent-2));
}

/* ---------------- Tarjeta de partido ---------------- */
.match-card {
  display: flex;
  flex-direction: column;
  gap: 13px;
  border-radius: 20px;
  padding: 16px;
  border: 1px solid var(--border);
  color: var(--text);
  text-align: left;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s var(--ease-spring), box-shadow 0.3s var(--ease-out), border-color 0.3s var(--ease-out);
}
a.match-card { cursor: pointer; }
a.match-card:hover {
  transform: translateY(calc(-4px * var(--anim)));
  border-color: oklch(from var(--accent) l c h / 0.5);
  box-shadow: 0 22px 50px -22px var(--accent), var(--shadow-glow);
}
.match-card-live::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 60% at 50% 0%, oklch(from var(--c-red) l c h / 0.16), transparent 60%);
  pointer-events: none;
}
.match-card-head { display: flex; align-items: center; justify-content: space-between; }
.match-card-teams { display: flex; align-items: center; gap: 10px; }
.team-side { display: flex; flex-direction: column; align-items: center; gap: 7px; flex: 1; min-width: 0; }
.team-flag { font-size: 38px; line-height: 1; filter: drop-shadow(0 4px 8px oklch(0 0 0 / 0.25)); }
.team-name { font-size: 13px; font-weight: 700; text-align: center; letter-spacing: -0.01em; }
.match-score { display: flex; align-items: center; gap: 6px; }
.match-vs { font-size: 15px; color: var(--text-faint); font-weight: 700; }
.score-bubble {
  min-width: 38px;
  height: 46px;
  padding: 0 8px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  background: linear-gradient(135deg, oklch(from var(--accent) l c h / 0.22), oklch(from var(--accent-2) l c h / 0.12));
  border: 1px solid var(--border-hi);
  color: var(--text);
}
.score-sep { color: var(--text-faint); font-weight: 700; }
.match-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  font-size: 11.5px;
  color: var(--text-dim);
}
.match-card-meta svg { color: var(--text-faint); }
.match-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.match-card-foot-info { font-size: 12px; color: var(--text-faint); }
.chip-accent {
  color: var(--accent);
  border-color: oklch(from var(--accent) l c h / 0.5);
  background: oklch(from var(--accent) l c h / 0.10);
}
.chip-earned-full {
  color: var(--c-lime);
  border-color: oklch(from var(--c-lime) l c h / 0.4);
  background: oklch(from var(--c-lime) l c h / 0.10);
}
.chip-earned-partial {
  color: var(--c-yellow);
  border-color: oklch(from var(--c-yellow) l c h / 0.4);
  background: oklch(from var(--c-yellow) l c h / 0.10);
}

/* ---------------- Inputs ---------------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}
.input {
  background: var(--surface-hi);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-sm);
  padding: 13px 15px;
  font-size: 15px;
  color: var(--text);
  font-family: var(--font-sans);
  transition: border-color 0.2s, box-shadow 0.25s, background 0.2s;
  width: 100%;
}
.input::placeholder { color: var(--text-faint); }
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px oklch(from var(--accent) l c h / 0.18), 0 0 18px -6px var(--accent);
}

/* ---------------- Chips / badges ---------------- */
.chip {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border-hi);
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.chip-live {
  color: var(--c-red);
  border-color: oklch(from var(--c-red) l c h / 0.5);
  background: oklch(from var(--c-red) l c h / 0.12);
}
.chip-open {
  color: var(--c-lime);
  border-color: oklch(from var(--c-lime) l c h / 0.45);
  background: oklch(from var(--c-lime) l c h / 0.10);
}
.chip-closed { color: var(--text-faint); }
.chip-done {
  color: var(--c-cyan);
  border-color: oklch(from var(--c-cyan) l c h / 0.4);
  background: oklch(from var(--c-cyan) l c h / 0.08);
}

.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
}
.dot-pulse { animation: pulse calc(1.6s / (var(--anim) + 0.2)) ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
  50% { box-shadow: 0 0 0 5px transparent; opacity: 0.55; }
}

/* ---------------- Scrollbars ---------------- */
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: var(--accent); }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------------- Animaciones de entrada ---------------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(calc(20px * var(--anim))); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn {
  0% { opacity: 0; transform: scale(0.92) translateY(calc(14px * var(--anim))); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.rise { animation: rise 0.6s var(--ease-out) both; }
.fade { animation: fade 0.5s ease both; }
.pop { animation: popIn 0.5s var(--ease-spring) both; }

.stagger > * { animation: rise 0.55s var(--ease-out) both; }
.stagger > *:nth-child(1) { animation-delay: calc(0.04s * 1); }
.stagger > *:nth-child(2) { animation-delay: calc(0.04s * 2); }
.stagger > *:nth-child(3) { animation-delay: calc(0.04s * 3); }
.stagger > *:nth-child(4) { animation-delay: calc(0.04s * 4); }
.stagger > *:nth-child(5) { animation-delay: calc(0.04s * 5); }
.stagger > *:nth-child(6) { animation-delay: calc(0.04s * 6); }
.stagger > *:nth-child(7) { animation-delay: calc(0.04s * 7); }
.stagger > *:nth-child(8) { animation-delay: calc(0.04s * 8); }
.stagger > *:nth-child(9) { animation-delay: calc(0.04s * 9); }
.stagger > *:nth-child(10) { animation-delay: calc(0.04s * 10); }
.stagger > *:nth-child(11) { animation-delay: calc(0.04s * 11); }
.stagger > *:nth-child(12) { animation-delay: calc(0.04s * 12); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.05s !important; }
}

/* ---------------- Layout responsive ---------------- */

/* Dashboard de competición: lista + clasificación */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
}
.leaderboard-aside {
  padding: 18px;
  border-radius: 20px;
  position: sticky;
  /* Deja hueco para el topbar sticky encima. */
  top: 88px;
  max-height: calc(100vh - 110px);
  overflow: auto;
}
/* Por debajo de ~1000px apilamos el sidebar bajo los partidos para que
   ambos puedan crecer y la página pueda scrollear de forma natural. */
@media (max-width: 1000px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .leaderboard-aside {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

/* Topbar: en pantallas pequeñas permitimos que envuelva en varias filas.
   La barra de navegación pasa a una segunda línea y puede scrollear
   horizontalmente si no cabe; el bloque de usuario se compacta. */
.topbar { position: sticky; top: 0; }
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .topbar-nav {
    order: 3;
    width: 100%;
    margin-left: 0 !important;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .topbar-nav::-webkit-scrollbar { display: none; }
  .topbar-nav .nav-item { flex-shrink: 0; }
  .topbar-actions { margin-left: auto; }
  .topbar-user-meta { display: none; }
}

/* Estadísticas: apila gráfico y comparativa en pantallas estrechas */
@media (max-width: 920px) {
  .stats-grid { grid-template-columns: 1fr !important; }
}
/* KPIs de estadísticas: 4 columnas → 2 → 1 según ancho */
.stats-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 860px) {
  .stats-kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 460px) {
  .stats-kpis { grid-template-columns: 1fr; }
}

/* Tablas con grid de columnas fijas: en pantallas pequeñas habilitamos
   scroll horizontal en lugar de aplastar las columnas. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll > .table-row,
.table-scroll > .glass > .table-row { min-width: 720px; }

/* Encabezados y filas grid genéricas (manage_players, rankings, audit_log,
   manage_results) usan la clase .table-row para mantener un ancho mínimo. */
@media (max-width: 760px) {
  .table-row { min-width: 720px; }
}

/* Selectores de ronda/jornada: permitir wrap si no caben */
.glass[aria-label="Jornadas"],
.round-selector { flex-wrap: wrap; }

/* Scroll interno sin barras visibles (gráfico de evolución con todos los jugadores) */
.no-scrollbar { scrollbar-width: none; -ms-overflow-style: none; }
.no-scrollbar::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* Red de seguridad: si las animaciones de entrada quedan pausadas (pestaña en
   segundo plano), forzamos el estado final visible tras un instante. */
html.fv .rise, html.fv .pop, html.fv .fade, html.fv .ovl, html.fv .stagger > * {
  opacity: 1 !important;
  transform: none !important;
}

/* ---------------- Logo wordmark ---------------- */
.logo {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.03em;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
.logo-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: conic-gradient(from 210deg, var(--c-pink), var(--c-yellow), var(--c-lime), var(--c-cyan), var(--c-pink));
  display: grid;
  place-items: center;
  font-size: 15px;
  color: oklch(0.18 0.02 275);
  font-weight: 800;
  box-shadow: 0 4px 16px -4px var(--accent), 0 0 0 1px oklch(1 0 0 / 0.18) inset;
  position: relative;
}
.logo-mark span { position: relative; z-index: 1; mix-blend-mode: hard-light; }

/* gradient text */
.grad-text {
  background: linear-gradient(100deg, var(--c-pink), var(--c-yellow) 40%, var(--c-lime) 65%, var(--c-cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* progress bar */
.bar {
  height: 7px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  position: relative;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 1.1s var(--ease-out);
  box-shadow: 0 0 12px -2px var(--accent);
}

/* ---------------- Modal overlay ---------------- */
.ovl {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 20px;
  background: oklch(0.1 0.03 280 / 0.6);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: fade .25s ease both;
}

/* Selects con look de input glass */
select.input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%238a8aa8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><polyline points='1 1.5 6 6.5 11 1.5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* Checkboxes de los formularios glass */
.check {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--text);
  cursor: pointer;
}
.check input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--accent);
}

/* ============================================================
   Página /reglas/ — estilos específicos
   ============================================================ */

.rules-example-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--surface-hi);
  border: 1px solid var(--border);
}
.rules-example-card[data-variant="exact"] {
  border-color: oklch(from var(--c-lime) l c h / 0.4);
}
.rules-example-card[data-variant="partial"] {
  border-color: oklch(from var(--c-cyan) l c h / 0.4);
}
.rules-example-card[data-variant="miss"] {
  opacity: 0.85;
}
.rules-example-card .match-card-teams {
  /* Compacta el patrón de /competicion/ para que quepa en la mini-tarjeta. */
  gap: 6px;
}
.rules-example-card .team-flag { font-size: 28px; }
.rules-example-card .team-name { font-size: 12px; }
.rules-example-card .score-bubble {
  min-width: 30px;
  height: 38px;
  font-size: 20px;
}
.rules-example-card p {
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
}

.rules-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.rules-table th,
.rules-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}
.rules-table thead th {
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  font-weight: 500;
}
.rules-table .chip[data-round="groups"] { color: var(--c-lime); border-color: oklch(from var(--c-lime) l c h / 0.4); }
.rules-table .chip[data-round="r32"]    { color: var(--c-cyan); border-color: oklch(from var(--c-cyan) l c h / 0.4); }
.rules-table .chip[data-round="r16"]    { color: var(--c-yellow); border-color: oklch(from var(--c-yellow) l c h / 0.4); }
.rules-table .chip[data-round="qf"]     { color: var(--c-gold); border-color: oklch(from var(--c-gold) l c h / 0.4); }
.rules-table .chip[data-round="sf"],
.rules-table .chip[data-round="final"]  { color: var(--c-pink); border-color: oklch(from var(--c-pink) l c h / 0.4); }

.rules-timeline {
  list-style: none;
  margin: 4px 0 8px;
  padding: 28px 8px 24px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  position: relative;
  background:
    linear-gradient(90deg,
      oklch(from var(--c-lime) l c h / 0.6) 0%,
      oklch(from var(--c-yellow) l c h / 0.6) 35%,
      oklch(from var(--text-faint) l c h / 0.5) 55%,
      oklch(from var(--c-red) l c h / 0.6) 75%,
      oklch(from var(--c-cyan) l c h / 0.6) 100%) 0 50% / 100% 2px no-repeat;
}
.rules-timeline li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
.rules-timeline .chip {
  /* Tapa el gradiente que pasa por detrás para que no se vea atravesando la pill. */
  background: var(--surface-solid);
  position: relative;
  z-index: 1;
}
.rules-timeline-hint {
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-faint);
}

.rules-state-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.rules-state-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface-hi);
  border: 1px solid var(--border);
}
.rules-state-card[data-state="live"] {
  border-color: oklch(from var(--c-red) l c h / 0.4);
}
.rules-state-card[data-state="done"] {
  border-color: oklch(from var(--c-cyan) l c h / 0.4);
}
.rules-state-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.rules-state-score strong {
  font-family: Sora, sans-serif;
  font-size: 20px;
  letter-spacing: -0.02em;
}
.rules-state-card p {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
}

.rules-medals {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.rules-medals li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-hi);
}
.rules-medals li[data-position="1"] { border-color: oklch(from var(--c-gold) l c h / 0.55); }
.rules-medals li[data-position="2"] { border-color: oklch(from var(--text-dim) l c h / 0.45); }
.rules-medals li[data-position="3"] { border-color: oklch(from var(--c-yellow) l c h / 0.45); }
.rules-medal-badge {
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  color: var(--text-faint);
}
.rules-medals strong {
  font-family: Sora, sans-serif;
  font-size: 24px;
}
.rules-medal-label {
  font-size: 12px;
  color: var(--text-dim);
}

.rules-matchday-prize {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid oklch(from var(--c-cyan) l c h / 0.35);
  background: oklch(from var(--c-cyan) l c h / 0.06);
  align-items: center;
}
.rules-matchday-prize-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm, 10px);
  background: oklch(from var(--c-cyan) l c h / 0.15);
  color: var(--c-cyan);
}
.rules-matchday-prize-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rules-matchday-prize-body strong {
  font-family: Sora, sans-serif;
  font-weight: 800;
  font-size: 26px;
  color: var(--c-cyan);
  line-height: 1.1;
}
.rules-matchday-prize-body p {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 13px;
}

.rules-tiebreak {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rules-tiebreak li {
  display: flex;
  align-items: center;
  gap: 12px;
}
.rules-tiebreak li > span {
  font-family: Sora, sans-serif;
  font-weight: 800;
  font-size: 20px;
  width: 28px;
  text-align: center;
  color: var(--accent);
}
.rules-tiebreak li > p { margin: 0; }

.rules-access {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.rules-access li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.rules-access li svg {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--accent);
}
.rules-access strong { display: block; }
.rules-access p {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 13px;
}

@media (max-width: 920px) {
  .rules-timeline {
    grid-template-columns: 1fr;
    background:
      linear-gradient(180deg,
        oklch(from var(--c-lime) l c h / 0.6) 0%,
        oklch(from var(--c-yellow) l c h / 0.6) 35%,
        oklch(from var(--text-faint) l c h / 0.5) 55%,
        oklch(from var(--c-red) l c h / 0.6) 75%,
        oklch(from var(--c-cyan) l c h / 0.6) 100%) 14px 0 / 2px 100% no-repeat;
    padding: 18px 8px 18px 36px;
    gap: 18px;
  }
  .rules-timeline li {
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
    text-align: left;
  }
  .rules-medals { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .rules-table thead { display: none; }
  .rules-table tr { display: flex; flex-direction: column; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .rules-table td { border: none; padding: 2px 0; }
}

/* ============================================================
   Avatar (foto de perfil + fallback de iniciales)
   ============================================================ */

.avatar {
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: white;
  box-shadow: 0 2px 8px -2px oklch(0 0 0 / 0.4);
  overflow: hidden;
}
span.avatar {
  background: linear-gradient(
    135deg,
    oklch(0.62 0.19 var(--hue, 250)),
    oklch(0.66 0.20 calc(var(--hue, 250) + 60))
  );
  font-size: calc(var(--avatar-size, 32px) * 0.36);
}
img.avatar { object-fit: cover; }

/* /mi-cuenta/ — bloque de edición del avatar */
.avatar-edit {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-bottom: 8px;
}
.avatar-edit .avatar-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
.avatar-input { display: none; }
.hint { font-size: 12px; color: var(--text-faint); margin: 4px 0 0; }

/* ============================================================
   Clasificación: header, podio top-3 y filas (#4+)
   ============================================================ */
.leaderboard {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.leaderboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}
.leaderboard-header svg { color: var(--c-gold); }

/* Rankings · tab Clasificación: dos columnas centradas con selector vertical
   de jornadas pegado al board de la derecha. */
.rankings-clas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: start;
}
.rankings-clas__col {
  display: flex;
  justify-content: center;
  gap: 16px;
  min-width: 0;
}
.rankings-clas__col--scope { align-items: flex-start; }
.rankings-clas__board {
  width: 100%;
  max-width: 440px;
  padding: 18px;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.rankings-md-selector {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border-radius: 14px;
  position: sticky;
  top: 88px;
  min-width: 140px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
}
.rankings-md-selector__item {
  text-align: left;
  white-space: nowrap;
}
.rankings-md-selector__item.is-active { font-weight: 700; }
@media (max-width: 1100px) {
  .rankings-clas { grid-template-columns: 1fr; }
  .rankings-clas__col--scope { flex-direction: column; align-items: center; }
  .rankings-md-selector {
    position: static;
    max-height: none;
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
    max-width: 440px;
  }
}

/* Tabs Global / Jornada-Ronda (radio CSS, sin JS) */
.lb-scope-input { position: absolute; opacity: 0; pointer-events: none; }
.lb-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: oklch(from var(--text) l c h / 0.04);
  margin-bottom: 12px;
}
.lb-tab {
  flex: 1;
  text-align: center;
  cursor: pointer;
  user-select: none;
}
.lb-scope-rank__global,
.lb-scope-rank__local { display: none; }
.lb-pane { display: none; flex-direction: column; min-height: 0; }
#lb-scope-global:checked ~ .lb-pane--global,
#lb-scope-local:checked ~ .lb-pane--local { display: flex; }
#lb-scope-global:checked ~ .leaderboard-header .lb-scope-rank__global,
#lb-scope-local:checked ~ .leaderboard-header .lb-scope-rank__local { display: inline-flex; }
#lb-scope-global:checked ~ .lb-tabs .lb-tab[data-scope="global"],
#lb-scope-local:checked ~ .lb-tabs .lb-tab[data-scope="local"] {
  background: oklch(from var(--accent) l c h / 0.16);
  border-color: oklch(from var(--accent) l c h / 0.45);
  color: var(--accent);
}

/* Podio top-3 — orden visual 2º · 1º · 3º */
.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  padding: 8px 4px 0;
}
.podium-slot {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.podium-slot--1 { flex: 1.15; }
.podium-slot--empty { visibility: hidden; }

.podium-medal {
  font-size: 22px;
  line-height: 1;
}
.podium-slot--1 .podium-medal { filter: drop-shadow(0 4px 10px var(--c-gold)); }
.podium-slot--2 .podium-medal { filter: drop-shadow(0 4px 10px oklch(0.82 0.02 250)); }
.podium-slot--3 .podium-medal { filter: drop-shadow(0 4px 10px oklch(0.68 0.10 50)); }

.podium-info {
  text-align: center;
  line-height: 1.15;
  width: 100%;
  min-width: 0;
}
.podium-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.podium-name.is-me { color: var(--accent); }
.podium-pts {
  font-size: 17px;
  font-weight: 700;
}

.podium-pedestal {
  width: 100%;
  border-radius: 12px 12px 0 0;
  border: 1px solid var(--border-hi);
  border-bottom: none;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}
.podium-pedestal--1 {
  height: 112px;
  background: linear-gradient(180deg, oklch(from var(--c-gold) l c h / 0.5), oklch(from var(--c-gold) l c h / 0.08));
  box-shadow: 0 -8px 30px -14px var(--c-gold);
}
.podium-pedestal--2 {
  height: 84px;
  background: linear-gradient(180deg, oklch(0.82 0.02 250 / 0.5), oklch(0.82 0.02 250 / 0.08));
  box-shadow: 0 -8px 30px -14px oklch(0.82 0.02 250);
}
.podium-pedestal--3 {
  height: 62px;
  background: linear-gradient(180deg, oklch(0.68 0.10 50 / 0.5), oklch(0.68 0.10 50 / 0.08));
  box-shadow: 0 -8px 30px -14px oklch(0.68 0.10 50);
}
.podium-rank-number {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 800;
  opacity: 0.85;
}
.podium-pedestal--1 .podium-rank-number { color: var(--c-gold); }
.podium-pedestal--2 .podium-rank-number { color: oklch(0.82 0.02 250); }
.podium-pedestal--3 .podium-rank-number { color: oklch(0.68 0.10 50); }

/* Cabecera de la lista (debajo del podio) */
.leaderboard-table-header {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 11px;
  padding: 8px 12px 6px;
  border-bottom: 1px solid var(--border);
  margin-top: 6px;
}

/* Lista de posiciones 4+ */
.leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  padding-right: 2px;
  min-height: 0;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  position: relative;
}
.leaderboard-row.is-me {
  background: linear-gradient(100deg, oklch(from var(--accent) l c h / 0.16), oklch(from var(--accent-2) l c h / 0.06));
  border-color: oklch(from var(--accent) l c h / 0.4);
  box-shadow: 0 0 22px -10px var(--accent);
}
.leaderboard-row__pos {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-faint);
  text-align: center;
}
.leaderboard-row.is-me .leaderboard-row__pos { color: var(--accent); }

.leaderboard-row__main { min-width: 0; }
.leaderboard-row__top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.leaderboard-row__id { min-width: 0; flex: 1; }
.leaderboard-row__name-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.leaderboard-row__name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.leaderboard-row__name.is-me { color: var(--accent); }

.leaderboard-streak {
  padding: 1px 6px;
  color: var(--c-yellow);
  border-color: oklch(from var(--c-yellow) l c h / 0.4);
  gap: 3px;
  flex-shrink: 0;
}

.leaderboard-row__bar {
  margin-top: 5px;
  height: 5px;
}

.leaderboard-row__right {
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: right;
}
.leaderboard-row__hits {
  font-size: 11px;
  color: var(--text-faint);
}
.leaderboard-row__exacts { color: var(--c-lime); }

.leaderboard-row__trend {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
}
.leaderboard-row__trend--up svg { color: var(--c-lime); }
.leaderboard-row__trend--down svg { color: var(--c-red); }
.leaderboard-row__trend-flat {
  width: 13px;
  height: 2px;
  background: var(--text-faint);
  border-radius: 2px;
  display: inline-block;
}

.leaderboard-row__pts {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  min-width: 30px;
  text-align: right;
}
.leaderboard-row__pts.is-me { color: var(--accent); }

/* === Pantalla de configuración de premios ============================ */
.prizes-podium {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.prizes-podium li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-hi);
}
.prizes-podium li[data-position="1"] { border-color: oklch(from var(--c-gold) l c h / 0.55); }
.prizes-podium li[data-position="2"] { border-color: oklch(from var(--text-dim) l c h / 0.45); }
.prizes-podium li[data-position="3"] { border-color: oklch(from var(--c-yellow) l c h / 0.45); }
.prizes-podium-badge {
  font-family: Sora, sans-serif;
  font-weight: 800;
  font-size: 22px;
  color: var(--text);
}
.prizes-podium li[data-position="1"] .prizes-podium-badge { color: var(--c-gold); }
.prizes-podium li[data-position="2"] .prizes-podium-badge { color: var(--text-dim); }
.prizes-podium li[data-position="3"] .prizes-podium-badge { color: var(--c-yellow); }
.prizes-podium-label {
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
}
.prizes-podium-input {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}
.prizes-podium-input .input {
  flex: 1;
  text-align: right;
  font-family: Sora, sans-serif;
  font-weight: 700;
  font-size: 18px;
}

.prizes-matchday-card { border-color: oklch(from var(--c-cyan) l c h / 0.35); }
.prizes-matchday-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
}
.prizes-matchday-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  background: oklch(from var(--c-cyan) l c h / 0.12);
  color: var(--c-cyan);
}
.prizes-matchday-label {
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
}
.prizes-matchday-input {
  display: flex;
  align-items: center;
  gap: 8px;
}
.prizes-matchday-input .input {
  width: 180px;
  text-align: right;
  font-family: Sora, sans-serif;
  font-weight: 700;
  font-size: 20px;
}

@media (max-width: 720px) {
  .prizes-podium { grid-template-columns: 1fr; }
  .prizes-matchday-row { grid-template-columns: 1fr; }
  .prizes-matchday-input .input { width: 100%; }
}

/* ============================================================
   Pantalla /login/ — layout split (form + info)
   ============================================================ */
.login-screen {
  position: relative;
  z-index: 1;
  min-height: calc(100vh - clamp(32px, 4.8vw, 64px));
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 3vw, 36px);
}
.login-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.login-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(28px, 5vw, 72px);
  align-items: center;
}
.login-form-card {
  border-radius: 28px;
  padding: clamp(28px, 3vw, 44px);
  justify-self: center;
  width: 100%;
  max-width: 460px;
}
.login-input-wrap { position: relative; }
.login-input-wrap > svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}
.login-input-with-icon { padding-left: 42px; }
.login-info {
  justify-self: center;
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-info-title {
  margin: 0 0 4px;
  font-size: clamp(24px, 2.4vw, 32px);
  line-height: 1.05;
}
.login-pot-strip {
  display: flex;
  gap: 10px;
}
.login-pot-tile {
  flex: 1;
  padding: 12px 10px;
  border-radius: 14px;
  background: var(--surface-hi);
  border: 1px solid var(--border);
  text-align: center;
}
.login-pot-tile__value { font-size: 19px; font-weight: 800; }
.login-pot-tile__label { font-size: 9px; margin-top: 2px; }

.login-info-card {
  border-radius: 20px;
  padding: 16px;
}
.login-info-card__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.login-info-card__head svg { color: var(--accent); }

.login-next-matches {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.login-next-match {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 11px 13px;
  border-radius: 14px;
  background: var(--surface-hi);
  border: 1px solid var(--border);
}
.login-next-match__teams {
  display: flex;
  align-items: center;
  gap: 11px;
}
.login-next-match__flag { font-size: 22px; }
.login-next-match__id { flex: 1; min-width: 0; }
.login-next-match__name {
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.login-next-match__when {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}
.login-next-match__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.login-next-match__chip { gap: 5px; padding: 3px 9px; }
.login-next-match__close {
  font-size: 10.5px;
  color: var(--text-faint);
  text-align: right;
}

.login-top {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.login-top__row {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 12px;
  background: transparent;
  border: 1px solid transparent;
}
.login-top__row--lead {
  background: oklch(from var(--c-gold) l c h / 0.10);
  border-color: oklch(from var(--c-gold) l c h / 0.30);
}
.login-top__pos {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-faint);
  text-align: center;
}
.login-top__pos--podium { color: var(--c-gold); }
.login-top__id {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.login-top__name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.login-top__pts { font-size: 14px; font-weight: 800; }

.login-footer {
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
}

@media (max-width: 900px) {
  .login-body {
    grid-template-columns: 1fr;
    gap: 28px;
    align-items: start;
  }
  .login-form-card { order: 1; }
  .login-info { order: 2; }
}
