/* style.css (Versión Final Definitiva) */

/* --- Colores de la Paleta del Logo --- */
:root {
    --background-dark: #1a1a1a;
    --card-background: #2c2c2c;
    --text-light: #f0f0f0;
    --text-secondary: #a0a0a0;
    --main-blue: #005697;
    --light-blue: #42b2e8;
    --border-color: #444;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background-dark);
    color: var(--text-light);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
}

main {
    width: 100%;
    max-width: 700px;
    background-color: var(--card-background);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    margin-bottom: 50px;
}

/* --- Títulos y Divisores --- */
header h1, header h2 { text-align: center; margin: 0; padding: 0; }
header h2 { color: var(--text-secondary); font-weight: 500; margin-bottom: 30px; }
hr { border: none; border-top: 1px solid var(--border-color); margin: 30px 0; }
.subtitle { text-align: center; color: var(--main-blue); font-weight: 700; margin: -5px 0 20px 0; letter-spacing: 1px; }

/* --- Formulario y Botones --- */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; }
.form-group input[type="text"] { width: 100%; padding: 12px; background-color: var(--background-dark); border: 1px solid var(--border-color); color: var(--text-light); border-radius: 6px; font-size: 16px; box-sizing: border-box; }
button[type="submit"], .cta-button { background-color: var(--main-blue); color: var(--text-light); border: none; border-radius: 6px; width: 100%; padding: 15px; font-size: 18px; font-weight: 600; cursor: pointer; transition: background-color 0.2s ease; text-align: center; text-decoration: none; display: block; box-sizing: border-box; }
button[type="submit"]:hover, .cta-button:hover { background-color: var(--light-blue); }
.cta-button.secondary { background-color: #333; margin-bottom: 10px; }
.cta-button.secondary:hover { background-color: #555; }

/* --- Mensaje de Error --- */
.error-message { background-color: #5d1a1a; color: #f7d7da; border: 1px solid #a23b47; padding: 15px; margin-bottom: 20px; border-radius: 6px; text-align: center; font-weight: 600; }

/* --- Estructura de Partido (Formularios) --- */
.partido { display: flex; justify-content: space-between; align-items: center; padding: 15px 5px; border-bottom: 1px solid var(--border-color); }
.partido:last-child { border-bottom: none; }
.equipos-container { display: flex; align-items: center; justify-content: center; width: 100%; gap: 15px; }
.equipo { display: flex; align-items: center; gap: 10px; flex-basis: 50%; }
.equipo.visitante { justify-content: flex-end; }
.equipo.local { justify-content: flex-start; }
.equipo img { width: 40px; height: 40px; object-fit: contain; }
.equipo span { font-size: 17px; font-weight: 500; }
.opcion { flex-shrink: 0; padding: 0 10px; }
.opcion input[type="radio"] { display: none; }
.opcion label { display: inline-block; width: 30px; height: 30px; border: 2px solid var(--main-blue); border-radius: 50%; cursor: pointer; transition: all 0.2s ease; position: relative; }
.opcion label::after { content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0); width: 18px; height: 18px; background-color: var(--light-blue); border-radius: 50%; transition: transform 0.2s ease; }
.opcion input[type="radio"]:checked + label { border-color: var(--light-blue); }
.opcion input[type="radio"]:checked + label::after { transform: translate(-50%, -50%) scale(1); }
.game-time { color: var(--text-secondary); font-size: 14px; font-weight: 700; text-align: center; flex-shrink: 0; padding: 0 10px; }
.game-time span { display: block; font-size: 11px; font-weight: 500; }

/* --- Botón de Limpiar en Admin Panel --- */
.admin-partido { position: relative; }
.clear-selection-container { position: absolute; right: -10px; top: 50%; transform: translateY(-50%); }
.clear-selection { display: flex; justify-content: center; align-items: center; width: 24px; height: 24px; background-color: #555; color: #fff; border-radius: 50%; cursor: pointer; font-size: 20px; line-height: 1; transition: background-color 0.2s ease; }
.clear-selection:hover { background-color: #F44336; }

/* --- Estilos para la Lista del Recibo (Definitivo) --- */
.receipt-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.receipt-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 5px;
    border-bottom: 1px solid var(--border-color);
    font-size: 16px;
    gap: 15px;
}
.receipt-item:last-child {
    border-bottom: none;
}
.receipt-item .matchup-text {
    color: var(--text-secondary);
    text-align: left;
    flex-grow: 1;
    flex-shrink: 1;
}
.receipt-item .user-pick {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    white-space: nowrap;
    flex-shrink: 0;
}
.user-pick img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}
.user-pick .pick-text {
    color: var(--light-blue);
    font-weight: 700;
}

/* --- Estilos para Leaderboard de Tabla Consolidada --- */
.table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.leaderboard-table { width: 100%; border-collapse: collapse; margin-top: 20px; min-width: 600px; }
.leaderboard-table th, .leaderboard-table td { padding: 8px; text-align: center; vertical-align: middle; }
.leaderboard-table thead { background-color: var(--background-dark); }
.leaderboard-table th { border-bottom: 2px solid var(--main-blue); white-space: nowrap; }
.leaderboard-table .header-partido { text-align: left; font-size: 14px; }
.leaderboard-table .header-jugador { font-size: 15px; font-weight: 600; }
.leaderboard-table .header-jugador .score { display: block; font-size: 12px; font-weight: 500; color: var(--light-blue); margin-top: 2px; }
.leaderboard-table tbody tr { border-bottom: 1px solid var(--border-color); }
.leaderboard-table tbody tr:last-child { border-bottom: none; }
.leaderboard-table .game-info-cell .equipo-info { display: flex; align-items: center; gap: 5px; }
.leaderboard-table .game-info-cell img { width: 25px; height: 25px; }
.leaderboard-table .pick-cell img { width: 30px; height: 30px; opacity: 0.8; }
.leaderboard-table td.pick-cell.correct { background-color: rgba(76, 175, 80, 0.15); }
.leaderboard-table td.pick-cell.correct img { opacity: 1; }
.leaderboard-table td.pick-cell.incorrect { background-color: rgba(244, 67, 54, 0.1); }
.leaderboard-table td.pick-cell.incorrect img { opacity: 0.3; }

/* --- Diseño Responsivo (Móvil) --- */
@media (max-width: 650px) {
    /* Estilos del formulario en móvil */
    .partido .equipo span { display: none; }
    .equipo img { width: 35px; height: 35px; }
    .game-time { font-size: 12px; }
    .game-time span { font-size: 10px; }
    
    /* Ajustes para el recibo en móvil */
    .receipt-item { 
        font-size: 13px;
        flex-wrap: wrap; /* Permite que el pick se ponga debajo si no cabe */
        gap: 5px;
        padding: 10px 2px;
    }
    .receipt-item .matchup-text {
        flex-basis: 100%; /* El enfrentamiento ocupa toda la línea */
        text-align: center;
        margin-bottom: 5px;
    }
    .receipt-item .user-pick {
        flex-basis: 100%; /* La predicción ocupa toda la línea de abajo */
        justify-content: center;
        margin-left: 0;
    }
    .user-pick img { 
        width: 18px;
        height: 18px; 
    }
}

/* ===== HOTFIX: mostrar abreviaturas en móvil ===== */
@media (max-width: 640px){
  /* Asegura que las abreviaturas NO se oculten */
  .equipos-container .equipo .abbr,
  .partido-cell .match .abbr,
  .match .abbr {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    text-indent: 0 !important;
    clip: auto !important;
    width: auto !important;
    height: auto !important;
    font-size: 12px !important;   /* el tamaño que estás usando en móvil */
    letter-spacing: .4px;
    text-transform: uppercase;
  }

  /* Por si el contenedor tenía font-size:0 (truco común para centrar logos) */
  .equipos-container .equipo,
  .match {
    font-size: inherit !important;
  }

  /* Y por si había una regla genérica que ocultaba spans en móvil */
  .equipos-container .equipo span,
  .match span {
    display: inline !important;
  }
}

/* Local: mostrar primero la abreviatura y después el logo */
.equipo.local{
  display: inline-flex;      /* por si alguna regla lo cambió */
  flex-direction: row-reverse;
  align-items: center;
  gap: 10px;
}
@media (max-width: 640px){
  .equipo.local{ gap: 8px; }
}

/* Centrar SIEMPRE el bloque del equipo local dentro de la celda */
.equipos-container .equipo{
  justify-self: center !important;   /* centra el item en la celda de grid */
  text-align: center !important;
  margin: 0 auto !important;
}

/* Local: abbr primero y luego logo, pero centrado */
.equipo.local{
  display: inline-flex;              /* por si otra regla lo cambió */
  flex-direction: row-reverse;       /* invierte el orden: ABR → LOGO */
  align-items: center;
  justify-content: center !important;/* centra el contenido del flex */
  gap: 10px;
}

@media (max-width: 640px){
  .equipo.local{ gap: 8px; }
}

/* ===== Radios custom: 50% más chicos y SIEMPRE centrados ===== */

/* Columna angosta y centrada */
.partido .opcion{
  width: 28px;
  min-width: 28px;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 1) Saca el radio nativo del layout (iOS ya no lo “pinta”) */
.partido .opcion input[type="radio"]{
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  left: -9999px;              /* fuera de pantalla */
  width: 1px; height: 1px;    /* accesible para lectores, pero no visible */
  overflow: hidden;
  margin: 0;
  accent-color: transparent;  /* extra por si Safari insiste */
}

/* 2) Círculo del label (≈50% del tamaño típico) */
.partido .opcion label{
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--primary, #30a7ff);
  position: relative;
  box-sizing: border-box;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent; /* sin mancha azul en iOS */
}

/* Punto interior perfectamente centrado cuando está seleccionado */
.partido .opcion input[type="radio"]:checked + label::after{
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--primary, #30a7ff);
  border-radius: 50%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%); /* siempre centrado */
}

/* (Opcional) foco/hover accesible */
.partido .opcion input[type="radio"]:focus + label,
.partido .opcion label:hover{
  box-shadow: 0 0 0 3px rgba(48,167,255,.15);
}

/* Móvil un pelín más compacto (ajusta si quieres) */
@media (max-width: 640px){
  .partido .opcion label{ width: 16px; height: 16px; }
  .partido .opcion input[type="radio"]:checked + label::after{ width: 8px; height: 8px; }
}

/* Evitar salto de línea en la hora */
.equipos-container .game-time{
  display: inline-flex;          /* apila hora arriba y la línea de abajo */
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: max-content;            /* la celda mide lo que ocupa el texto */
  justify-self: center;          /* centrada en la grilla 1fr | auto | 1fr */
}

/* "7:20 PM" siempre en una sola línea */
.equipos-container .game-time > :first-child{
  white-space: nowrap;           /* sin salto entre "7:20" y "PM" */
}


/* Centra el bloque dentro del <td> que abarca las 7 columnas */
.td-center{ display:flex; justify-content:center; }

/* Fallback por si alguna fila no lleva la clase */
.tabla tbody td[colspan="7"]{ display:flex; justify-content:center; }