/* ==========================================================================
   1. VARIABLES & RESET & BASES
   ========================================================================== */
:root {
    /* Paleta Neon Dark */
    --bg-dark: #020617;
    --bg-card: rgba(30, 41, 59, 0.4); /* Efecto vidrio base */
    --border-color: rgba(255, 255, 255, 0.08);
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --primary: #6366f1; /* Indigo */
    --secondary: #ec4899; /* Rosa */
    --accent-gold: #fbbf24;
    --accent-red: #ef4444;
    --accent-green: #10b981;
    
    /* Sombras */
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --shadow-hover: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 0 10px rgba(99, 102, 241, 0.2);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background: radial-gradient(circle at top right, #1e293b, #0f172a 60%, var(--bg-dark));
    color: var(--text-main);
    min-height: 100vh;
    margin: 0;
    line-height: 1.5;
    overflow-x: hidden; /* Evita scroll horizontal */
}

/* Scrollbar Global Personalizada */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

h1, h2, h3, h4, h5, h6 { color: #ffffff; margin-top: 0; }
a { text-decoration: none; color: inherit; }

/* ==========================================================================
   2. CONTENEDORES & TARJETAS GENERALES
   ========================================================================== */
.container {
    background: var(--bg-card) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-glass);
    border-radius: 1rem;
    
    /* MODIFICACIÓN PARA PANTALLAS GRANDES */
    width: 96%;
    max-width: 1800px; 
    margin-left: auto;
    margin-right: auto;
    
    padding: 1.5rem;
    margin-bottom: 2rem;
    position: relative;
}

/* Tarjetas de Entidades (Federación/Comité) */
.card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
    min-height: 160px;
}
.card:hover {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: var(--shadow-hover);
}
.selectable-card { cursor: pointer; height: 100%; }
.selectable-card img { filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3)); transition: transform 0.3s ease; margin-bottom: 1rem; }
.selectable-card:hover img { transform: scale(1.1); }

/* ==========================================================================
   3. CONTENEDORES CON SCROLL (VIVO Y RECIENTES) - NUEVO
   ========================================================================== */
/* Aplicamos scroll y grid a las listas de partidos */
#live-matches-container,
#recent-results-container {
    /* Altura máxima para evitar página infinita */
    max-height: 500px; 
    overflow-y: auto;        /* Scroll vertical activado */
    overflow-x: hidden;
    
    /* Layout Grid Automático */
    display: grid;
    /* Las tarjetas tendrán mínimo 300px, si hay espacio caben más */
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 12px;
    align-content: start; /* Evita que se estiren verticalmente si son pocos */
    
    /* Estética del contenedor scrollable */
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    
    /* Scrollbar interna */
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

/* Ajuste específico para móvil */
@media (max-width: 640px) {
    #live-matches-container,
    #recent-results-container {
        grid-template-columns: 1fr; /* Una sola columna en celular */
        max-height: 60vh; /* Usamos porcentaje de pantalla en móvil */
    }
}

/* Estilos de la Scrollbar interna de estos contenedores */
#live-matches-container::-webkit-scrollbar,
#recent-results-container::-webkit-scrollbar {
    width: 6px;
}
#live-matches-container::-webkit-scrollbar-track,
#recent-results-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}
#live-matches-container::-webkit-scrollbar-thumb,
#recent-results-container::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

/* ==========================================================================
   4. ESTILOS DE CRUCES / BRACKETS
   ========================================================================== */

/* Contenedor Flex que permite centrado Y grilla */
.bracket-wrapper {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important; /* CENTRA las tarjetas si hay pocas (<4) */
    gap: 15px !important;
    width: 100%;
    padding: 10px;
}

/* --- TARJETA DE CRUCE (Diseño Unificado) --- */
.matchup-card {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.98));
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    position: relative;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.matchup-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.3);
}

/* --- TAMAÑOS RESPONSIVOS BRACKETS --- */

/* MÓVIL: Scroll Vertical para Brackets */
@media (max-width: 639px) {
    .matchup-card {
        width: 100% !important;
        margin-bottom: 8px;
    }
    
    .bracket-wrapper {
        display: block !important; 
        max-height: 65vh;          
        overflow-y: auto;          
        padding: 5px;
        background: rgba(0,0,0,0.2);
        border-radius: 12px;
        border: 1px solid rgba(255,255,255,0.05);
    }
}

/* TABLET: 2 por fila */
@media (min-width: 640px) and (max-width: 1023px) {
    .matchup-card { width: calc(50% - 15px) !important; }
}

/* PC ESTÁNDAR: 4 por fila */
@media (min-width: 1024px) and (max-width: 1535px) {
    .matchup-card {
        width: calc(25% - 15px) !important;
        min-width: 260px;
    }
}

/* MONITORES GRANDES (22"+): 5 por fila (MODIFICACIÓN PANTALLA GRANDE) */
@media (min-width: 1536px) {
    .matchup-card {
        width: calc(20% - 15px) !important;
        min-width: 260px;
    }
}

/* --- PARTES INTERNAS DE LA TARJETA --- */
.matchup-header {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.5rem 0.5rem 0.5rem 2.5rem;
    display: flex; justify-content: space-between;
    font-size: 0.7rem; color: var(--text-muted);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.matchup-content {
    padding: 0.75rem;
    display: flex; flex-direction: column; gap: 0.6rem;
    flex-grow: 1;
}

.matchup-team {
    display: flex; align-items: center; padding: 0.35rem;
    border-radius: 6px; background: rgba(255,255,255,0.02);
    transition: background 0.2s;
}

.matchup-team img {
    width: 28px; height: 28px; object-fit: contain; margin-right: 0.6rem;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.5));
}

.team-name {
    font-weight: 600; font-size: 0.85rem; color: var(--text-main);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}

/* Equipo Ganador */
.winner-text .team-name, .winner-text .font-bold {
    color: #4ade80 !important; font-weight: 800 !important;
    text-shadow: 0 0 8px rgba(74, 222, 128, 0.25);
}

/* ==========================================================================
   5. BADGES Y ELEMENTOS UI
   ========================================================================== */
.match-id-badge {
    position: absolute; top: 0; left: 0;
    background: #4f46e5; color: white;
    font-size: 10px; font-weight: 800; padding: 2px 10px;
    border-bottom-right-radius: 8px; z-index: 10;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.3); font-family: monospace;
}

.live-badge {
    position: absolute; top: 8px; right: 8px;
    background: rgba(0, 0, 0, 0.7); border: 1px solid rgba(239, 68, 68, 0.6);
    border-radius: 999px; padding: 2px 8px;
    font-size: 0.65rem; font-weight: bold; color: #ef4444;
    display: flex; align-items: center; gap: 5px;
    z-index: 20; box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}
.live-dot {
    width: 6px; height: 6px; background-color: #ef4444;
    border-radius: 50%; animation: livePulse 1.5s infinite;
}
@keyframes livePulse {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1); }
}

.stream-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 999px;
    font-size: 10px; text-decoration: none;
    transition: all 0.2s; background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1); color: #94a3b8;
}
.stream-btn:hover {
    background: rgba(255, 255, 255, 0.1); transform: translateY(-1px); color: white;
}

.penalties-score {
    font-size: 0.7rem; color: #94a3b8; margin-left: 6px; font-family: monospace;
}

/* ==========================================================================
   6. DETALLE DEL PARTIDO (Responsive & Tablas de Eventos)
   ========================================================================== */

/* Límite de altura GARANTIZADO para todas las tablas (Goles, Tarjetas, Faltas, Penales) */
/* El ":has(> table)" atrapa a CUALQUIER contenedor directo de una tabla sin importar su clase */
#match-details .overflow-x-auto,
#match-details div:has(> table) {
    max-height: 350px; 
    overflow-y: auto;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
    border-radius: 0.5rem;
}

/* Mantenemos los encabezados fijos al scrollear hacia abajo dentro de estas tablas */
#match-details div:has(> table) th {
    position: sticky;
    top: 0;
    z-index: 20;
    background-color: rgba(15, 23, 42, 0.95);
}

/* Scrollbar personalizada para las tablas del detalle de partido */
#match-details .overflow-x-auto::-webkit-scrollbar,
#match-details div:has(> table)::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
#match-details .overflow-x-auto::-webkit-scrollbar-track,
#match-details div:has(> table)::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}
#match-details .overflow-x-auto::-webkit-scrollbar-thumb,
#match-details div:has(> table)::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

@media (max-width: 640px) {
    #match-details .flex-col.md\:flex-row {
        flex-direction: row !important; flex-wrap: nowrap !important;
        align-items: flex-start !important; justify-content: center !important;
    }
    #match-score-details { font-size: 2.5rem !important; }
    #home-club-logo-details, #away-club-logo-details {
        width: 60px !important; height: 60px !important; padding: 5px !important;
    }
    #home-club-name-details, #away-club-name-details {
        font-size: 0.8rem !important; margin-top: 5px !important;
    }
}

/* ==========================================================================
   7. TABLAS, RESULTADOS Y UTILS
   ========================================================================== */
.responsive-table {
    width: 100%; overflow-x: auto;
    border-radius: 0.5rem; border: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.6);
    /* Scroll vertical para listas de partidos de liga */
    max-height: 400px; overflow-y: auto; scrollbar-width: thin;
    /* Suaviza el desplazamiento táctil en celulares */
    -webkit-overflow-scrolling: touch; 
}

/* --- TABLA GLOBAL (RESTAURADA A SU DISEÑO ORIGINAL) --- */
table { 
    width: 100%; 
    border-collapse: separate; 
    border-spacing: 0; 
    min-width: 100%; /* Vuelve a ocupar el espacio de su contenedor */
}

th, td { 
    padding: 0.75rem 1rem; /* Padding original relajado */
    border-bottom: 1px solid var(--border-color); 
}

th { background-color: rgba(15, 23, 42, 0.95); font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); position: sticky; top: 0; z-index: 10; }
td { color: var(--text-main); font-size: 0.875rem; }
tr:hover { background-color: rgba(255, 255, 255, 0.05); }

/* --- FIX: SÓLO APLICA A LA TABLA DE FECHAS/PARTIDOS --- */
/* Aislamos el truco del scroll para que solo afecte a las listas de partidos */
.responsive-table table { 
    min-width: 550px; 
}
.responsive-table th, .responsive-table td { 
    padding: 0.5rem 0.5rem; 
    white-space: nowrap; 
}

/* Tablas compactas (Goleadores, Tarjetas, Faltas) */
.stats-vertical-scroll {
    max-height: 350px; overflow-y: auto;
    border-radius: 0.5rem; background-color: rgba(31, 41, 55, 0.4);
}

/* --- FIX: PROTECCIÓN EXTRA PARA TABLAS COMPACTAS --- */
/* Forzamos que retomen su diseño original por si heredan la clase de partidos */
.stats-vertical-scroll table {
    min-width: 100% !important;
}
.stats-vertical-scroll th, .stats-vertical-scroll td {
    white-space: normal !important; 
    padding: 0.75rem 1rem !important; 
}

/* Sticky Columns para Posiciones */
.standings-scroll-wrapper {
    max-height: 450px; overflow: auto;
    border-radius: 0.5rem; background-color: #111827; position: relative;
}
.col-sticky-1 {
    position: sticky; left: 0; z-index: 30;
    background-color: #1e293b; border-right: 1px solid rgba(75, 85, 99, 0.4);
}
.col-sticky-2 {
    position: sticky; left: 40px; z-index: 30;
    background-color: #1e293b; border-right: 2px solid rgba(75, 85, 99, 0.5);
}
thead th.col-sticky-1, thead th.col-sticky-2 { z-index: 40; background-color: #0f172a; }

/* Utilidades */
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Contenedor Fases */
/* Se quitó el tope de 1400px: la fase ocupa todo el ancho (igual que la tabla de arriba) y no queda pegada a la izquierda.
   Las tarjetas de adentro ya tienen su propio ancho máximo y se centran solas. */
.bracket-phase-container {
    width: 100%; max-width: none; margin-left: auto; margin-right: auto;
    display: flex; flex-direction: column; align-items: center;
    background: rgba(255, 255, 255, 0.01);
    border-radius: 16px; padding: 1rem 0; margin-bottom: 2rem;
}
.bracket-phase-container h3 {
    text-align: center; font-size: 1.3rem; color: var(--primary);
    margin-bottom: 1rem; text-transform: uppercase;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1); padding-bottom: 0.5rem; display: inline-block;
}

/* Match Card General (Listas) */
.match-card-content {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.5rem; width: 100%; cursor: pointer; padding: 0.5rem;
    border-radius: 0.5rem; transition: background-color 0.2s;
}
.match-card-content:hover { background-color: rgba(255, 255, 255, 0.03); }
.match-card-team { display: flex; align-items: center; gap: 0.5rem; flex: 1; min-width: 0; }
.match-card-team.home { justify-content: flex-start; }
.match-card-team.away { justify-content: flex-end; text-align: right; }
.team-name-small { font-size: 0.875rem; font-weight: 600; color: #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-display { font-family: 'Inter', monospace; font-size: 1.5rem; font-weight: 800; color: #ffffff; min-width: 60px; text-align: center; }

/* Badges de estado */
.badge { padding: 0.25rem 0.6rem; border-radius: 9999px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; }
.badge-live { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); border: 1px solid rgba(239, 68, 68, 0.3); animation: pulse-live 2s infinite; }
.badge-completed { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-scheduled { background: rgba(245, 158, 11, 0.15); color: var(--accent-gold); border: 1px solid rgba(245, 158, 11, 0.3); }

/* Login Button */
.login-btn-glass {
    background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1.25rem; border-radius: 9999px; color: white; font-weight: 600; transition: 0.3s;
}
.login-btn-glass:hover { background: var(--primary); border-color: transparent; }

/* Toast */
#messageBox {
    position: fixed; bottom: 20px; right: 20px; padding: 1rem 1.5rem; border-radius: 0.5rem;
    color: white; font-weight: 500; z-index: 2000; opacity: 0; visibility: hidden; transform: translateY(20px); transition: 0.3s;
}
#messageBox.show { opacity: 1; visibility: visible; transform: translateY(0); }
#messageBox.success { background-color: var(--accent-green); }
#messageBox.error { background-color: var(--accent-red); }

/* ==========================================================================
   AJUSTE PARA MONITORES GRANDES (22 PULGADAS O MÁS)
   ========================================================================== */

/* Limita el ancho del panel principal y lo centra */
.main-content {
    max-width: 1152px; 
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

/* Agrupa los botones de eventos para que no queden tan separados */
.event-buttons-row {
    max-width: 896px; 
    margin-left: auto;
    margin-right: auto;
    justify-content: center; 
}

/* ==========================================================================
   8. ALERTA FLOTANTE (NO STREAM TOAST)
   ========================================================================== */
.no-stream-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-glass);
    color: var(--text-main);
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none; /* Evita clics accidentales en el cartel */
}

/* Estado activo del toast */
.no-stream-toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.no-stream-toast i {
    color: var(--accent-red);
    font-size: 1.25rem;
}

.no-stream-toast span {
    font-weight: 500;
    font-size: 0.95rem;
}
/* =======================================
   ESTILOS TARJETA PREMIUM (FINALES) 
======================================= */
.premium-header { padding: 8px 10px !important; flex-direction: row !important; }
.premium-header-title { font-size: 10px !important; letter-spacing: 1px !important; }
.premium-header-date { font-size: 9px !important; }
.premium-ring { padding: 15px 5px !important; flex-direction: row !important; gap: 5px !important; width: 100% !important; }

/* Ajustado margen para despegar la etiqueta del logo en móvil */
.premium-col { margin-top: 24px !important; width: 33% !important; }
.premium-badge { top: -22px !important; padding: 2px 6px !important; font-size: 8px !important; border-width: 1px !important; }

.premium-logo { width: 55px !important; height: 55px !important; min-width: 55px !important; min-height: 55px !important; padding: 4px !important; border-width: 2px !important; }
.premium-name { font-size: 11px !important; margin-top: 8px !important; padding: 0 2px !important; white-space: normal !important; }
.premium-icon { font-size: 28px !important; margin-bottom: 10px !important; }

/* Ajustado para ganar espacio en pantallas pequeñas */
.premium-score-box { padding: 6px 10px !important; gap: 8px !important; border-radius: 10px !important; border-width: 1px !important; }
.premium-score-num { font-size: 22px !important; }
.premium-score-dash { font-size: 14px !important; }
.premium-pen-title { font-size: 8px !important; margin-bottom: 4px !important; }

/* white-space: nowrap !important evita que los penales se apilen verticalmente */
.premium-pen-box { padding: 4px 8px !important; font-size: 12px !important; border-radius: 8px !important; white-space: nowrap !important; }

.premium-footer { padding: 10px 15px !important; }
.premium-footer-ref { font-size: 10px !important; gap: 6px !important; }
.premium-footer-ref-text { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }
.premium-footer-info { font-size: 10px !important; gap: 4px !important; }
.premium-footer-info-text { display: none; }

@media (min-width: 640px) {
    .premium-header { padding: 12px 30px !important; }
    .premium-header-title { font-size: 14px !important; letter-spacing: 2px !important; }
    .premium-header-date { font-size: 13px !important; }
    .premium-ring { padding: 40px 20px !important; gap: 30px !important; }
    .premium-col { margin-top: 25px !important; }
    .premium-badge { top: -35px !important; padding: 4px 14px !important; font-size: 11px !important; border-width: 2px !important; }
    .premium-logo { width: 140px !important; height: 140px !important; min-width: 140px !important; min-height: 140px !important; padding: 10px !important; border-width: 4px !important; }
    .premium-name { font-size: 26px !important; margin-top: 20px !important; }
    .premium-icon { font-size: 75px !important; margin-bottom: 30px !important; }
    .premium-score-box { padding: 20px 40px !important; gap: 30px !important; border-radius: 20px !important; border-width: 2px !important; }
    .premium-score-num { font-size: 60px !important; }
    .premium-score-dash { font-size: 40px !important; }
    .premium-pen-title { font-size: 12px !important; margin-bottom: 8px !important; }
    .premium-pen-box { padding: 8px 30px !important; font-size: 24px !important; border-radius: 12px !important; white-space: nowrap !important; }
    .premium-footer { padding: 16px 30px !important; }
    .premium-footer-ref { font-size: 14px !important; gap: 10px !important; }
    .premium-footer-ref-text { max-width: none; overflow: visible; display: inline; }
    .premium-footer-info { font-size: 13px !important; gap: 6px !important; }
    .premium-footer-info-text { display: inline; }
}

/* ==========================================================================
   9. VISTA DE LLAVES (CUADRO DE ELIMINATORIAS) — prefijo .bt-
   Bloque nuevo: no modifica ninguna regla anterior.
   ========================================================================== */
.bt-toolbar { display: flex; justify-content: flex-end; margin: 0 0 12px; }
.bt-toggle {
    display: inline-flex; border: 1px solid var(--border-color); border-radius: 999px;
    overflow: hidden; background: rgba(15, 23, 42, 0.6);
}
.bt-toggle button {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 16px; font-size: 12px; font-weight: 700;
    color: var(--text-muted); background: transparent; border: 0; cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.bt-toggle button:hover { color: #fff; }
.bt-toggle button.active { background: var(--primary); color: #fff; }

.bt-wrap { width: 100%; }
.bt-loading, .bt-empty { text-align: center; color: var(--text-muted); font-style: italic; padding: 24px 0; }
.bt-hint { display: none; text-align: center; font-size: 11px; color: var(--text-muted); margin: 4px 0 0; }

/* Zona con scroll horizontal; el cuadro se centra si entra entero */
.bt-scroll {
    display: flex; overflow-x: auto; padding: 8px 4px 16px;
    -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: var(--primary) transparent;
}
.bt-board { position: relative; margin: 0 auto; flex: 0 0 auto; }
.bt-lines { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 0; overflow: visible; }
.bt-lines path { fill: none; stroke: rgba(148, 163, 184, 0.55); stroke-width: 2; stroke-linejoin: round; }

.bt-cols { position: relative; z-index: 1; display: flex; align-items: stretch; gap: var(--bt-gap, 44px); }
.bt-col { display: flex; flex-direction: column; width: var(--bt-col-w, 220px); flex: 0 0 var(--bt-col-w, 220px); min-width: 0; }
.bt-col-title {
    text-align: center; font-size: 11px; font-weight: 800; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--text-muted);
    background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 999px; padding: 4px 10px; margin-bottom: 10px;
}
.bt-col-final .bt-col-title { color: var(--accent-gold); border-color: rgba(251, 191, 36, 0.35); }
/* Cada ronda reparte sus cruces en partes iguales: así cada cruce queda centrado entre sus dos "padres" */
.bt-col-body { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 16px; }

/* Cruce */
.bt-tie {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.98));
    border: 1px solid var(--border-color); border-radius: 10px; overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.bt-tie.clickable { cursor: pointer; }
.bt-tie.clickable:hover, .bt-tie.clickable:focus-visible {
    border-color: var(--primary); transform: translateY(-2px); outline: none;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}
.bt-tie.live { border-color: rgba(239, 68, 68, 0.6); box-shadow: 0 0 14px rgba(239, 68, 68, 0.2); }
.bt-tie.final { border-color: rgba(202, 138, 4, 0.7); box-shadow: 0 0 18px rgba(251, 191, 36, 0.18); }
.bt-tie.placeholder { border-style: dashed; opacity: 0.65; }

.bt-head {
    display: flex; justify-content: space-between; align-items: center; gap: 6px;
    padding: 4px 8px; font-size: 10px; color: var(--text-muted);
    background: rgba(0, 0, 0, 0.3); border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.bt-badge {
    font-size: 9px; font-weight: 800; letter-spacing: 0.06em; padding: 1px 6px; border-radius: 999px;
    color: var(--text-muted); border: 1px solid rgba(255, 255, 255, 0.12);
}
.bt-badge.live { color: #ef4444; border-color: rgba(239, 68, 68, 0.5); background: rgba(239, 68, 68, 0.1); }
.bt-badge.wo { color: #fcd34d; border-color: rgba(245, 158, 11, 0.45); background: rgba(120, 53, 15, 0.5); }

.bt-team { display: flex; align-items: center; gap: 8px; padding: 0 8px; height: 36px; }
.bt-team + .bt-team { border-top: 1px solid rgba(255, 255, 255, 0.05); }
.bt-logo { width: 24px; height: 24px; flex: 0 0 24px; object-fit: contain; border-radius: 50%; background: #0f172a; }
.bt-logo-fb {
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 800; color: #cbd5e1; background: #334155;
}
.bt-name {
    flex: 1; min-width: 0; font-size: 13px; font-weight: 700; color: var(--text-main);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bt-score { font-size: 18px; font-weight: 900; color: #fff; min-width: 20px; text-align: right; font-variant-numeric: tabular-nums; }
.bt-pen { font-size: 10px; color: var(--text-muted); font-family: monospace; }
.bt-team.winner .bt-name, .bt-team.winner .bt-score { color: var(--accent-gold); text-shadow: 0 0 8px rgba(251, 191, 36, 0.3); }
.bt-team.loser { opacity: 0.55; }

.bt-foot { display: flex; gap: 4px; padding: 4px 6px; background: rgba(0, 0, 0, 0.25); border-top: 1px solid rgba(255, 255, 255, 0.05); }
.bt-chip {
    flex: 1; font-size: 10px; font-weight: 700; padding: 3px 4px; border-radius: 6px;
    border: 1px solid var(--border-color); background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted); cursor: pointer; transition: background 0.2s, color 0.2s;
}
.bt-chip:hover { background: rgba(99, 102, 241, 0.25); color: #fff; }


/* Modo compacto (celular / columnas angostas): sin escudos, nombres en dos líneas */
.bt-board.compact .bt-logo { display: none; }
.bt-board.compact .bt-team { height: auto; min-height: 34px; padding: 3px 5px; gap: 3px; }
.bt-board.compact .bt-name { white-space: normal; font-size: 10.5px; line-height: 1.15; overflow-wrap: break-word; word-break: normal; hyphens: auto; }
.bt-board.compact .bt-score { font-size: 15px; min-width: 14px; }
.bt-board.compact .bt-head { flex-wrap: wrap; font-size: 9px; padding: 3px 6px; }
.bt-board.compact .bt-col-title { font-size: 9px; letter-spacing: 0.04em; padding: 3px 4px; }
.bt-board.compact .bt-foot { flex-wrap: wrap; }
.bt-board.compact .bt-chip { font-size: 9px; padding: 2px 3px; }
.bt-board.compact .bt-medal-title { white-space: normal; }

/* ---------- Llaves separadas (A1, A2, A3, A4) ---------- */
.bt-group { margin-bottom: 28px; --bt-accent: #facc15; }
.bt-group + .bt-group { border-top: 1px solid var(--border-color); padding-top: 22px; }
.bt-group-title { display: flex; align-items: baseline; justify-content: center; gap: 10px; margin: 0 0 12px; }
.bt-group-code { font-size: 16px; font-weight: 900; letter-spacing: 0.14em; color: var(--primary); }
.bt-group-range { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.bt-col-final .bt-col-title { color: var(--bt-accent); border-color: rgba(255, 255, 255, 0.18); }
.bt-extra-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.bt-extra-row > .bt-tie { width: min(220px, 100%); }

/* ---------- Tarjetas con copa / medalla (finales y puestos) ---------- */
.bt-tie.medal {
    border-color: rgba(129, 140, 248, 0.5);
    border-color: color-mix(in srgb, var(--bt-accent) 60%, transparent);
    box-shadow: 0 0 16px rgba(129, 140, 248, 0.15);
    box-shadow: 0 0 18px color-mix(in srgb, var(--bt-accent) 22%, transparent);
}
.bt-medal-title {
    min-width: 0; font-weight: 800; letter-spacing: 0.05em; color: var(--bt-accent);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bt-medal-ico { color: var(--bt-accent); font-size: 12px; }
.bt-medal-foot {
    display: flex; justify-content: center; align-items: center; gap: 6px;
    padding: 4px 8px; font-size: 10px; color: var(--text-muted);
    background: rgba(0, 0, 0, 0.28); border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.bt-medal-date { white-space: nowrap; }
.bt-medal-win {
    min-width: 0; font-weight: 800; color: var(--bt-accent); text-align: center;
    white-space: normal; overflow-wrap: anywhere;
}

/* ---------- Definición de puestos ---------- */
.bt-puestos { margin-top: 20px; }
.bt-puestos-title {
    display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
    font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted);
}
.bt-puestos-title::before, .bt-puestos-title::after { content: ""; flex: 1; height: 1px; background: var(--border-color); }
.bt-puestos-grid { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 16px; }
.bt-puestos-grid > .bt-tie { width: min(220px, 100%); }
.bt-puesto-round { width: min(220px, 100%); display: flex; flex-direction: column; gap: 10px; }


/* ---------- Mini cuadro de puestos (ej. 5° al 8° -> 5 y 6 / 7 y 8) ---------- */
.bt-mini { width: 100%; max-width: 100%; }
.bt-puestos-grid > .bt-mini { flex: 1 1 100%; }
.bt-lines path.win { stroke: rgba(251, 191, 36, 0.85); }
.bt-lines path.lose { stroke: rgba(56, 189, 248, 0.85); }
.bt-legend { display: flex; justify-content: center; gap: 18px; margin: 0 0 4px; font-size: 10px; font-weight: 700; color: var(--text-muted); }
.bt-legend span { display: inline-flex; align-items: center; gap: 6px; }
.bt-legend span::before { content: ""; width: 22px; height: 0; border-top: 2px solid; }
.bt-leg-win::before { border-top-color: rgba(251, 191, 36, 0.85) !important; }
.bt-leg-lose::before { border-top-color: rgba(56, 189, 248, 0.85) !important; }
