/* ============================================
   CONTENEDORES DE PARTIDOS (GRID)
   ============================================ */
#results-container,
#upcoming-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: var(--spacing-md);
}

@media (max-width: 480px) {

    #results-container,
    #upcoming-container {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   TARJETAS DE PARTIDOS
   ============================================ */
.match-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    border: 1px solid #E2E8F0;
    border-left: 5px solid var(--primary-color);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.match-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
    border-color: var(--primary-color);
}

.match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid #F1F5F9;
}

.match-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.match-body {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: var(--spacing-sm);
    align-items: center;
    margin-bottom: var(--spacing-md);
    flex-grow: 1;
}

.team {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
}

.team-flag {
    width: 40px !important;
    height: 30px !important;
    margin-right: 0 !important;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.team-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.2;
}

.match-score,
.match-vs {
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 70px;
}

.match-score .score {
    background: var(--bg-dark);
    color: var(--text-white);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 1px;
    font-family: 'Outfit', sans-serif;
}

.match-vs span {
    background: #F1F5F9;
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 800;
}

.match-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding-top: var(--spacing-sm);
    border-top: 1px dashed #E2E8F0;
}

.match-footer i {
    color: var(--primary-color);
}

/* ============================================
   RESPONSIVE PARA TARJETAS DE PARTIDOS
   ============================================ */
@media (max-width: 768px) {
    .match-body {
        gap: var(--spacing-xs);
    }

    .team-flag {
        width: 30px !important;
        height: 22px !important;
    }

    .team-name {
        font-size: 0.85rem;
    }

    .match-score .score {
        font-size: 1.2rem;
        padding: 4px 10px;
    }
}

@media (max-width: 400px) {
    .match-header {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
}

/* ============================================
   LOADER
   ============================================ */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loader-content {
    text-align: center;
}

.loader-content p {
    margin-top: var(--spacing-md);
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================
   BOTÓN DE IMPRESIÓN
   ============================================ */
.btn-print {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.btn-print:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-print i {
    font-size: 1rem;
}

@media (max-width: 576px) {
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .btn-print {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   BRACKET DE CUARTOS DE FINAL
   ============================================ */

/* Contenedor raíz del bracket */
.bkt-bracket {
    display: flex;
    align-items: stretch;
    gap: 0;
    padding: 2rem 1rem;
    min-height: 380px;
    background: #0B1328;
    border-radius: 16px;
    overflow-x: auto;
}

/* ── Columnas laterales (izquierda / derecha) ── */
.bkt-side {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    gap: 1.5rem;
    min-width: 180px;
}

/* ── Tarjeta de un enfrentamiento ── */
.bkt-matchup {
    background: #1E2D4F;
    border: 1px solid #2A4080;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s;
}
.bkt-matchup:hover { transform: scale(1.02); }

.bkt-llave-label {
    background: #1B3A8C;
    color: #93C5FD;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    padding: 5px 10px;
}

/* Fila de un equipo dentro del enfrentamiento */
.bkt-team-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
}
.bkt-team-row + .bkt-sep + .bkt-team-row,
.bkt-team-row:first-of-type {
    border-bottom: 1px dashed #2A4080;
}

.bkt-shield {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 50%;
    background: #0B1328;
    padding: 2px;
    border: 1px solid #2A4080;
    flex-shrink: 0;
}

.bkt-shield-ph {
    width: 36px;
    height: 36px;
    background: #2A4080;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #93C5FD;
    font-size: 1rem;
    flex-shrink: 0;
}

.bkt-team-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #E2E8F0;
    flex: 1;
    line-height: 1.2;
}

.bkt-team-pos {
    font-size: 0.7rem;
    font-weight: 700;
    color: #FFD700;
    white-space: nowrap;
}

.bkt-sep { display: none; }

/* ── Columnas de conectores (líneas dashed) ── */
.bkt-conn {
    display: flex;
    align-items: stretch;
    width: 60px;
    flex-shrink: 0;
}

.bkt-conn-left  { flex-direction: row; }
.bkt-conn-right { flex-direction: row-reverse; }

.bkt-conn-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Mitad superior: esquina derecha hacia abajo */
.bkt-conn-h-top {
    flex: 1;
    border-bottom: 2px dashed #3A86FF;
    border-right: 2px dashed #3A86FF;
    border-radius: 0 0 8px 0;
    margin-right: -1px;
}

/* Mitad inferior: esquina derecha hacia arriba */
.bkt-conn-h-bot {
    flex: 1;
    border-top: 2px dashed #3A86FF;
    border-right: 2px dashed #3A86FF;
    border-radius: 0 8px 0 0;
    margin-right: -1px;
}

/* Punto de unión vertical entre las dos mitades */
.bkt-conn-v {
    height: 2px;
    background: #3A86FF;
    margin-right: -1px;
}

/* Línea horizontal de salida hacia el FINAL */
.bkt-conn-exit {
    width: 20px;
    border-top: 2px dashed #3A86FF;
    align-self: center;
}

/* ── Lado derecho: invertir dirección de bordes ── */
.bkt-conn-right .bkt-conn-h-top {
    border-right: none;
    border-left: 2px dashed #3A86FF;
    border-radius: 0 0 0 8px;
    margin-right: 0;
    margin-left: -1px;
}
.bkt-conn-right .bkt-conn-h-bot {
    border-right: none;
    border-left: 2px dashed #3A86FF;
    border-radius: 8px 0 0 0;
    margin-right: 0;
    margin-left: -1px;
}
.bkt-conn-right .bkt-conn-v {
    margin-right: 0;
    margin-left: -1px;
}

/* ── Columna central: GRAN FINAL ── */
.bkt-center-col {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 130px;
}

.bkt-final-box {
    background: linear-gradient(135deg, #1B8A4E, #06D6A0);
    border-radius: 12px;
    padding: 1.2rem 1rem;
    text-align: center;
    box-shadow: 0 0 30px rgba(6, 214, 160, 0.4);
    border: 2px solid #06D6A0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.bkt-trophy {
    font-size: 2rem;
    color: #FFD700;
    filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.6));
    animation: bkt-pulse 2s ease-in-out infinite;
}

@keyframes bkt-pulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.12); }
}

.bkt-final-text {
    font-size: 0.75rem;
    font-weight: 800;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: .1em;
    line-height: 1.3;
}

/* ── Mensaje vacío ── */
.bkt-empty {
    color: #64748B;
    text-align: center;
    padding: 3rem;
    font-size: 0.9rem;
}

/* ── RESPONSIVE: en móvil, lista vertical sin conectores ── */
@media (max-width: 700px) {
    .bkt-bracket {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
        padding: 1.5rem 1rem;
    }
    .bkt-conn { display: none; }
    .bkt-side,
    .bkt-side-right {
        width: 100%;
        flex-direction: column;
        gap: 1rem;
    }
    .bkt-center-col { width: 100%; }
    .bkt-final-box  { padding: .8rem; }
}

/* ============================================
   BRACKET COPA AMÉRICA STYLE
   ============================================ */

.copa-bracket {
    display: flex;
    align-items: stretch;
    gap: 6px;
    padding: 1.5rem 1rem;
    background: #0B1328;
    border-radius: 16px;
    overflow-x: auto;
    min-height: 360px;
}

/* ── Columnas ── */
.copa-col {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
}

.copa-col-quarters {
    flex: 2 1 0;
    min-width: 150px;
    gap: 1.5rem;
}

.copa-col-semi {
    flex: 1 1 0;
    min-width: 100px;
    justify-content: center;
    align-items: center;
}

.copa-col-center {
    flex: 1.4 1 0;
    min-width: 120px;
    justify-content: center;
    align-items: center;
    gap: 1.2rem;
}

/* ── Cuarto: tarjeta de enfrentamiento ── */
.copa-quarter {
    background: #122050;
    border: 1px solid #1E3A7A;
    border-radius: 12px;
    padding: .75rem;
    text-align: center;
}

.copa-quarter-label {
    font-size: .62rem;
    font-weight: 800;
    color: #FFD700;
    letter-spacing: .1em;
    text-transform: uppercase;
    margin-bottom: .6rem;
}

/* ── Par de equipos ── */
.copa-matchup-pair {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
}

.copa-team-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.copa-vs-text {
    font-size: .75rem;
    font-weight: 800;
    color: #64748B;
    flex-shrink: 0;
}

/* ── Círculos de equipo (estilo Copa América) ── */
.copa-circle {
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #1E3A7A;
    background: #0B1328;
    display: block;
}

.copa-circle.copa-empty,
.copa-circle.copa-ph {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #334155;
    font-size: 1.2rem;
    border: 2px dashed #334155;
    background: #0F1E3A;
}

.copa-circle-name {
    font-size: .6rem;
    font-weight: 600;
    color: #94A3B8;
    text-align: center;
    max-width: 70px;
    line-height: 1.2;
    margin-top: 3px;
}

/* Ganador: anillo destacado */
.copa-winner .copa-circle,
.copa-winner img.copa-circle {
    border-color: #06D6A0;
    box-shadow: 0 0 10px rgba(6, 214, 160, 0.5);
}

/* Score global */
.copa-score {
    margin-top: .4rem;
    font-size: .8rem;
    font-weight: 700;
    color: #E2E8F0;
    background: #0F1E3A;
    border-radius: 6px;
    padding: 2px 8px;
    display: inline-block;
}

/* ── Slot de semifinal ── */
.copa-semi {
    text-align: center;
    padding: .5rem;
}

.copa-semi-label {
    font-size: .58rem;
    font-weight: 800;
    color: #A78BFA;
    letter-spacing: .1em;
    text-transform: uppercase;
    margin-bottom: .5rem;
}

.copa-matchup-vertical {
    flex-direction: column;
    gap: .4rem;
}

/* ── Centro: Final y 3°/4° ── */
.copa-final-area {
    text-align: center;
    background: rgba(6, 214, 160, .08);
    border: 1px solid rgba(6, 214, 160, .3);
    border-radius: 12px;
    padding: .75rem .5rem;
}

.copa-final-label {
    font-size: .7rem;
    font-weight: 800;
    color: #06D6A0;
    letter-spacing: .12em;
    text-transform: uppercase;
    margin-bottom: .6rem;
}

.copa-final-pair {
    gap: .4rem;
}

.copa-third-area {
    text-align: center;
    background: rgba(205, 127, 50, .08);
    border: 1px solid rgba(205, 127, 50, .3);
    border-radius: 10px;
    padding: .6rem .5rem;
}

.copa-third-label {
    font-size: .6rem;
    font-weight: 700;
    color: #CD7F32;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin-bottom: .5rem;
}

/* ── Responsive ── */
@media (max-width: 720px) {
    .copa-bracket {
        flex-direction: column;
        gap: 1rem;
    }
    .copa-col-quarters,
    .copa-col-semi,
    .copa-col-center {
        flex: none;
        width: 100%;
        flex-direction: row;
        justify-content: center;
        flex-wrap: wrap;
        gap: .75rem;
    }
    .copa-quarter { flex: 1 1 140px; }
}