/* =========================================
   CUADRO DE TORNEO - BRACKET
   Estilo alineado a la Liga de BED
   ========================================= */

.bloque-bracket {
    max-width: 95%;
    margin: 0 auto;
    padding: 0;
    min-height: calc(100vh - 140px);
    display: flex;
    flex-direction: column;
}

.bracket-card {
    background: #fff;
    padding: 22px;
    border-radius: 34px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 140px);
}

/* Reusa .tp-header y .logo-torneo del CSS principal */

/* Contenedor con scroll horizontal */
.bracket-scroll {
    overflow-x: auto;
    padding: 10px 20px 20px;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    display: flex;
    min-height: 100%;
}

/* Grilla de rondas */
.bracket {
    display: flex;
    align-items: center;
    gap: 70px;
    min-width: max-content;
    min-height: 100%;
    padding: 0 20px;
    margin: auto 0;
}

/* Cada columna/ronda */
.round {
    display: flex;
    flex-direction: column;
    min-width: 280px;
    min-height: 100%;
}

.round-title {
    text-align: center;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #0d1b2a;
    text-transform: uppercase;
    padding-bottom: 10px;
    margin: 0 0 14px 0;
    border-bottom: 2px solid #0d1b2a;
}

/* Contenedor de partidos: se estira y distribuye */
.matches {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    flex: 1;
    min-height: 100%;
}

/* Espaciado creciente entre partidos por ronda -> forma clásica de bracket */
.round-32 .matches { gap: 8px;  --match-gap: 8px;  }
.round-16 .matches { gap: 50px; --match-gap: 50px; }
.round-8  .matches { gap: 200px; --match-gap: 210px; }
.round-4  .matches { gap: 500px; --match-gap: 600px; }
.round-2  .matches { gap: 1200px;    --match-gap:1800px; }
.round-1  .matches { gap: 0;    --match-gap: 0; justify-content: center; }

/* Tarjeta de partido */
.match {
    background: transparent;
    border-radius: 12px;
    transition: 0.25s ease;
    position: relative;
    min-height: 72px;
    z-index: 2;
}

.match:hover {
    transform: translateY(-2px);
}

.match:hover .team {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    border-color: #0d1b2a;
}

/* Cada equipo: escudo | nombre | resultado */
.team {
    display: grid;
    grid-template-columns: 34px 1fr 38px;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    font-size: 15px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-bottom: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    transition: 0.25s ease;
}

.team:first-child {
    border-radius: 12px 12px 0 0;
}

.team:last-child {
    border-radius: 0 0 12px 12px;
    border-bottom: 1px solid #e5e5e5;
}

.team + .team {
    border-top: 1px solid #ececec;
}

.team img {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

.team .name {
    font-weight: 600;
    color: #0d1b2a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.team .score {
    text-align: center;
    font-weight: 800;
    color: #333;
    background: #f2f2f2;
    border-radius: 6px;
    padding: 2px 0;
}

/* Ganador destacado */
.team.ganador {
    background: #eafaf0;
}
.team.ganador .name {
    color: #0d1b2a;
}
.team.ganador .score {
    background: #2ecc48;
    color: #fff;
}

/* Perdedor tenue */
.team:not(.ganador) {
    opacity: 0.78;
}

/* Final destacada */
.match.final .team {
    border-color: #ffd83b;
}
.match.final .team:first-child,
.match.final .team:last-child {
    box-shadow: 0 0 0 4px rgba(255, 216, 59, 0.25);
}
.match.final .team:first-child {
    border-radius: 12px 12px 0 0;
}
.match.final .team:last-child {
    border-radius: 0 0 12px 12px;
}

.trophy {
    margin-top: 14px;
    text-align: center;
    font-weight: 800;
    color: #0d1b2a;
    background: #ffd83b;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 15px;
}

/* =========================================
   LÍNEAS CONECTORAS ENTRE RONDAS
   ========================================= */

/* Línea horizontal que sale de cada partido hacia la siguiente ronda */
.match::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -36px;
    width: 35px;
    height: 2px;
    background: #0d1b2a;
    transform: translateY(-50%);
    z-index: 1;
    pointer-events: none;
}

/* Línea vertical que une dos partidos consecutivos con el partido siguiente */
.match:nth-child(odd)::before {
    content: '';
    position: absolute;
    top: 50%;
    right: -36px;
    width: 2px;
    height: calc(50% + var(--match-gap) / 2 + 36px);
    background: #0d1b2a;
    z-index: 1;
    pointer-events: none;
}

.match:nth-child(even)::before {
    content: '';
    position: absolute;
    bottom: 50%;
    right: -36px;
    width: 2px;
    height: calc(50% + var(--match-gap) / 2 + 36px);
    background: #0d1b2a;
    z-index: 1;
    pointer-events: none;
}

/* La última ronda no necesita conectores salientes */
.round-1 .match::before,
.round-1 .match::after {
    display: none;
}

/* Cuando una ronda tiene un solo partido, solo mostrar línea horizontal */
.match:only-of-type::before {
    display: none;
}

/* Responsivo */
@media (max-width: 768px) {
    .round { min-width: 240px; }
    .team { font-size: 14px; padding: 8px 12px; }
    .team img { width: 26px; height: 26px; }
    .bracket { gap: 45px; }
    .match::after { right: -23px; width: 22px; }
    .match:nth-child(odd)::before,
    .match:nth-child(even)::before { right: -23px; height: calc(50% + var(--match-gap) / 2 + 32px); }
}
