@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;500;700;800&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

:root {
    color-scheme: light only;
}

body {
    background: #ffffff !important;
    color: #333 !important;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    width: 100vw;
}

.header {
    background: #ffffff !important;
    color: #3a3171 !important;
    padding: 2vh 4vw;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    z-index: 10;
    height: 12vh;
}

.header-logo img {
    height: 8vh;
    object-fit: contain;
}

.header-title {
    font-size: 4vh;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    white-space: nowrap;
    text-align: center;
    flex: 1;
}

.header-time {
    font-size: 4vh !important;
    font-weight: 500;
}

.main-content {
    flex: 1;
    padding: 2vh 2vw; /* Reducido para dar espacio a 3 tarjetas */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 88vh;
}

/* Category Title for Cycle */
.category-title {
    text-align: center;
    font-size: 5vh;
    font-weight: 800;
    color: #f37630 !important;
    margin-bottom: 2vh;
    text-transform: uppercase;
    animation: fadeIn 0.5s ease-in-out;
}

/* Match Grid */
.match-grid {
    display: grid;
    /* Forzar 3 tarjetas por fila siempre */
    grid-template-columns: repeat(3, 1fr);
    gap: 2vw;
    animation: slideUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
    overflow-y: auto;
    padding-bottom: 2vh;
    align-content: start;
}

.match-card {
    background: #ffffff !important;
    border: 2px solid #d9dadd !important;
    border-radius: 16px;
    padding: 2vh 1.5vw;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    height: 100%;
}

.match-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 8px;
    background: linear-gradient(90deg, #3a3171, #78aa42) !important;
}

/* Live Badge (ahora dice el Set) */
.live-badge {
    position: absolute;
    top: 1.5vh;
    right: 1.5vw;
    background: #e63946 !important;
    color: #ffffff !important;
    padding: 0.5vh 1vw;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1.8vh;
    display: flex;
    align-items: center;
    gap: 0.5vw;
    animation: pulse 2s infinite;
}
.live-badge .dot {
    width: 1.2vh;
    height: 1.2vh;
    background: #ffffff !important;
    border-radius: 50%;
}

.match-header {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.5vh;
    font-size: 2vh;
    color: #666 !important;
    font-weight: 500;
}

.cancha-name {
    color: #78aa42 !important; /* Verde */
    font-weight: 800;
    text-transform: uppercase;
    font-size: 2.5vh;
}
.fase-name {
    font-weight: 700;
    color: #f37630 !important;
    font-size: 1.8vh;
    text-transform: uppercase;
}

.teams-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
}

.team {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    text-align: center;
    width: 30%;
}

.team-logo {
    width: 12vh; /* Reducido para 3 columnas */
    height: 12vh;
    object-fit: contain;
    margin-bottom: 1vh;
    border-radius: 0;
    background: transparent !important;
    padding: 0;
    border: none !important;
}

.team-name {
    font-size: 5vh; /* Duplicado para abreviaturas */
    font-weight: 700;
    color: #333 !important;
    width: 100%;
    /* Truco para forzar siempre 2 líneas de altura */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 6vh; /* Altura fija para 2 líneas */
    line-height: 3vh;
    word-wrap: break-word;
}

.score-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 40%;
}

.sets-won {
    font-size: 2.2vh;
    font-weight: 800;
    color: #ffffff !important;
    background: #3a3171 !important;
    padding: 0.5vh 1.5vw;
    border-radius: 20px;
    margin-bottom: 0.5vh;
    letter-spacing: 1px;
}

.main-score {
    font-size: 8vh; /* Puntos del set actual */
    font-weight: 800;
    color: #3a3171 !important; /* Morado */
    display: flex;
    align-items: center;
    gap: 1.5vw;
    text-shadow: 2px 2px 0px rgba(0,0,0,0.05);
}

.score-separator {
    color: #d9dadd !important;
}

.sets-container {
    display: flex;
    gap: 0.8vw;
    margin-top: 0.5vh;
}

.set-score {
    background: #f0f2f5 !important;
    padding: 0.4vh 0.8vw;
    border-radius: 8px;
    font-size: 2vh;
    font-weight: 700;
    color: #666 !important;
    border: 2px solid #d9dadd !important;
}

.set-score.active-set {
    background: #f37630 !important; /* Naranja */
    color: #ffffff !important;
    border-color: #f37630 !important;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(5vh); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(230, 57, 70, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 1vh rgba(230, 57, 70, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(230, 57, 70, 0); }
}

.no-matches {
    text-align: center;
    font-size: 5vh;
    color: #666 !important;
    margin-top: 15vh;
    font-weight: 500;
}

/* --- LIVE TV REDESIGN --- */
.live-tv-body {
    position: relative;
    background: #000000 !important;
}

#video-bg-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background: #000;
    overflow: hidden;
}

#video-bg-container iframe {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100vw;
    height: 56.25vw; /* 16:9 ratio */
    min-height: 100vh;
    min-width: 177.77vh; /* 16:9 ratio */
    transform: translate(-50%, -50%);
    pointer-events: none;
    border: none;
}

.ui-overlay {
    position: relative;
    z-index: 10;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.translucent-header {
    background: linear-gradient(to bottom, rgba(0,0,0,0.85), rgba(0,0,0,0)) !important;
    box-shadow: none !important;
    border: none !important;
}

.overlay-content {
    width: 26vw; /* Ligeramente más ancho para darle respiro */
    padding-left: 3vw;
    padding-top: 2vh;
}

.match-grid-vertical {
    display: flex;
    flex-direction: column;
    gap: 2vh;
    height: 100%;
    overflow-y: auto;
    padding-bottom: 15vh; /* Espacio extra para que se pueda hacer scroll bien */
}

.match-grid-vertical .match-card {
    height: auto;
    padding: 2vh 1.5vw;
    background: rgba(255, 255, 255, 0.95) !important;
    border-radius: 16px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.match-grid-vertical .match-card.has-video {
    cursor: pointer !important;
}

.match-grid-vertical .match-card.has-video:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.2) !important;
}
.match-grid-vertical .team-logo {
    width: 7vh;
    height: 7vh;
    margin-bottom: 0.8vh;
}
.match-grid-vertical .team-name {
    font-size: 3vh;
    height: auto;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.match-grid-vertical .main-score {
    font-size: 4.5vh;
    gap: 1vw; /* Reduce el espacio entre puntos */
}
.match-grid-vertical .sets-won {
    font-size: 1.3vh;
    padding: 0.4vh 1vw;
    margin-bottom: 0.8vh;
    letter-spacing: 0.5px;
}
.match-grid-vertical .cancha-name {
    font-size: 1.8vh;
    margin-bottom: 0.3vh;
}
.match-grid-vertical .fase-name {
    font-size: 1.4vh;
}
.match-grid-vertical .sets-container {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 0.5vw;
    margin-top: 1vh;
}
.match-grid-vertical .set-score {
    white-space: nowrap;
    padding: 0.3vh 0.6vw;
    font-size: 1.5vh;
}

/* =========================================
   📱 MOBILE FIRST / RESPONSIVE DESIGN
   ========================================= */
@media (max-width: 768px) {
    /* Ajustes Generales de Header para todas las pantallas */
    .header { height: auto; padding: 15px 5vw; flex-wrap: wrap; justify-content: center; gap: 10px; }
    .header-logo img { height: 40px; }
    .header-title { font-size: 1.5rem; flex: 100%; text-align: center; order: 3; }
    .header-time { font-size: 1.2rem !important; }
    
    .category-title { font-size: 1.8rem; margin-bottom: 15px; }
    .main-content { padding: 15px 3vw; height: calc(100vh - 60px); }

    /* Match Grid - Calendario y Ranking (1 Columna) */
    .match-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    /* Ajuste de tipografía en las tarjetas generales (Quitar vh y vw dependientes) */
    .match-card { padding: 15px; border-radius: 12px; }
    .cancha-name { font-size: 1.2rem; }
    .fase-name { font-size: 0.9rem; }
    .live-badge { font-size: 0.8rem; top: 15px; right: 15px; padding: 4px 10px; }
    .live-badge .dot { width: 8px; height: 8px; }
    
    .team-logo { width: 70px; height: 70px; padding: 0; margin-bottom: 5px; border: none; background: transparent; }
    .team-name { font-size: 4vh; height: auto; line-height: 1.2; -webkit-line-clamp: unset; }
    
    .score-container { width: 45%; }
    .main-score { font-size: 3.5rem; gap: 10px; }
    .sets-won { font-size: 0.85rem; padding: 4px 12px; }
    .sets-container { gap: 5px; flex-wrap: wrap; justify-content: center; }
    .set-score { font-size: 0.9rem; padding: 4px 8px; }
    .no-matches { font-size: 1.5rem; margin-top: 50px; }

    /* Live TV Standings - Ajustes */
    .overlay-content {
        width: 100vw;
        padding-left: 4vw;
        padding-right: 4vw;
        padding-top: 15px;
    }
    
    .match-grid-vertical {
        gap: 15px;
        padding-bottom: 20vh;
    }
    
    .match-grid-vertical .match-card {
        padding: 15px;
        border-radius: 12px;
    }
    
    /* Reajuste de tamaños en Live Standings vertical */
    .match-grid-vertical .team-logo { width: 50px; height: 50px; margin-bottom: 5px; }
    .match-grid-vertical .team-name { font-size: 3vh; }
    .match-grid-vertical .main-score { font-size: 2.5rem; gap: 8px; }
    .match-grid-vertical .sets-won { font-size: 0.75rem; padding: 3px 8px; margin-bottom: 5px; }
    .match-grid-vertical .cancha-name { font-size: 1.1rem; }
    .match-grid-vertical .fase-name { font-size: 0.8rem; }
    .match-grid-vertical .set-score { font-size: 0.85rem; padding: 3px 6px; }

    /* Video Background Fix para Modo Vertical */
    #video-bg-container iframe {
        /* En móvil vertical, el iframe necesita ser mucho más alto para cubrir los lados sin deformarse */
        width: 300vw;
        height: 300vh;
        min-width: unset;
        min-height: unset;
    }
}

/* Selector Deslizante */
.set-selector-new { display: flex; overflow-x: auto; gap: 1vw; padding: 1vh 0; margin-bottom: 2vh; scrollbar-width: none; align-items: center; justify-content: center; }
.set-selector-new::-webkit-scrollbar { display: none; }
.set-btn { background: #e2e8f0; color: #64748b; padding: 1.5vh 3vw; border-radius: 50px; font-weight: 700; font-size: 2vh; cursor: pointer; transition: all 0.3s ease; white-space: nowrap; border: 2px solid transparent; }
.set-btn.active { background: #3b82f6; color: white; border-color: #2563eb; box-shadow: 0 4px 10px rgba(59, 130, 246, 0.4); }

