@import url('https://fonts.googleapis.com/css2?family=Alfa+Slab+One&family=Roboto:wght@400;700;900&display=swap');

:root { 
    --azul-tiburones: #0A437A; 
    --verde-cancha: #1EAA41; 
    --naranja-acento: #CD4A24; 
    --madera-clara: #d8b082;
    --madera-oscura: #c29a6b;
}

body { 
    margin: 0; 
    background-color: var(--azul-tiburones); 
    font-family: 'Roboto', sans-serif; 
    overflow: hidden; 
    color: white;
}

/* --- BLOQUEO DE ORIENTACIÓN (OBLIGAR HORIZONTAL) --- */
#orientacion-aviso {
    display: none;
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: var(--azul-tiburones); color: white;
    z-index: 9999; justify-content: center; align-items: center; 
    text-align: center; flex-direction: column; padding: 20px;
}
@media screen and (orientation: portrait) {
    #orientacion-aviso { display: flex; }
    #contenedor-principal { display: none; }
}

/* --- FORMULARIO CONFIGURACIÓN --- */
.modal { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: linear-gradient(135deg, var(--azul-tiburones) 0%, #052342 100%); 
    display: flex; justify-content: center; align-items: center; z-index: 100; 
}
.modal-content { 
    background: white; color: #333; padding: 20px 30px; border-radius: 20px; 
    text-align: center; width: 85%; max-width: 500px; max-height: 95vh; overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); border: 4px solid var(--verde-cancha);
}
.logo-modal { width: 65px; height: auto; margin-bottom: 5px; }
.modal-content h2 { color: var(--azul-tiburones); margin: 0 0 15px 0; font-size: 1.4rem; font-weight: 900; }

.form-group { margin-bottom: 8px; text-align: left; display: flex; align-items: center; }
.form-group label { width: 38%; font-weight: bold; color: var(--azul-tiburones); font-size: 0.85rem; }
input, select { 
    width: 62%; padding: 8px 12px; border: 2px solid #ddd; 
    border-radius: 8px; font-size: 0.85rem; box-sizing: border-box; font-family: 'Roboto', sans-serif;
}
input:focus, select:focus { border-color: var(--naranja-acento); outline: none; }

/* --- DISEÑO DE LA DUELA DE MADERA --- */
.cancha {
    display: flex; justify-content: space-between; align-items: stretch;
    height: 100vh; padding: 10px; box-sizing: border-box;
    background-color: var(--madera-clara);
    background-image: 
        radial-gradient(rgba(205, 74, 36, 0.15) 2px, transparent 2px),
        linear-gradient(90deg, var(--madera-oscura) 1px, transparent 1px);
    background-size: 20px 20px, 100px 100px; border: 5px solid white; position: relative;
}

/* --- DIBUJO DE LÍNEAS BLANCAS REGLAMENTARIAS EN EL FONDO --- */
.cancha-marcas {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 1; pointer-events: none;
}
/* Línea central de la cancha */
.cancha-marcas::before {
    content: ''; position: absolute;
    top: 0; left: 50%; transform: translateX(-50%);
    width: 4px; height: 100%;
    background-color: rgba(255, 255, 255, 0.6);
}
/* Círculo exterior de salto oficial FIBA */
.cancha-marcas::after {
    content: ''; position: absolute;
    top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 260px; height: 260px;
    border: 4px solid rgba(255, 255, 255, 0.7);
    border-radius: 50%; box-sizing: border-box;
}

/* --- LOGO EN LA DUELA (CÍRCULO PERFECTO CON TRANSPARENCIA DETRÁS DEL RELOJ) --- */
.logo-duela-central {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 252px;  /* Ajustado sutilmente para rellenar de borde a borde el círculo blanco */
    height: 252px;
    aspect-ratio: 1 / 1;    /* Súper estricto: Círculo perfecto garantizado */
    object-fit: cover;
    border-radius: 50%;
    opacity: 0.35;          /* Nivel ideal de transparencia estilo pintura barnizada */
    z-index: 2;             /* Pasa exactamente por detrás de tableros y del reloj digital */
    pointer-events: none;   /* No interfiere con los clics de la pantalla */
}

/* --- CABECERA UNIVERSITARIA GIGANTE CON LETRAS MÁS ALTAS --- */
/* --- CABECERA UNIVERSITARIA AUTOADAPTABLE Y CONTROLADA --- */
.texto-universitario {
    position: absolute; 
    top: 6px;                  /* Distancia exacta respecto al borde superior */
    left: 50%;
    
    /* Centra horizontalmente y aplica un estiramiento vertical elegante y seguro */
    transform: translateX(-50%) scaleY(1.2); 
    transform-origin: top center; 
    
    font-family: 'Alfa Slab One', cursive, sans-serif; 
    font-size: 3.5vw;          /* REGLA DE ORO: Se adapta dinámicamente al ancho del celular */
    color: var(--azul-tiburones); 
    letter-spacing: 2px; 
    text-align: center; 
    width: 90%; 
    
    text-shadow: 
        2px 2px 0px white, 
       -2px -2px 0px white, 
        2px -2px 0px white, 
       -2px 2px 0px white, 
        3px 3px 6px rgba(0,0,0,0.4);
        
    z-index: 5; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis;    /* Puntos suspensivos si el nombre del rival es masivo */
}

/* --- RECUADROS AZULES COMPACTOS PARA PANTALLAS DE CELULAR --- */
.equipo { 
    width: 24%; 
    height: fit-content; 
    align-self: center;         /* Se mantiene centrado verticalmente en la duela */
    background: rgba(10, 67, 122, 0.95); 
    padding: 8px 10px;          /* Reducido el padding para ahorrar valioso espacio vertical */
    border-radius: 12px; 
    text-align: center; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.5); 
    border: 2px solid rgba(255,255,255,0.1);
    z-index: 4; 
    margin-top: 15px;           /* Margen de seguridad para alejarlo del título */
}

/* --- AJUSTE DE NOMBRES DE EQUIPO EN UNA SOLA LÍNEA --- */
.nombre-equipo { 
    font-size: 1.1rem;          /* Tamaño sutilmente reducido para que quepa completo */
    margin: 0 0 4px 0; 
    color: white; 
    text-transform: uppercase; 
    font-weight: 900; 
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;    /* Protege el recuadro si el nombre es gigantesco */
}

/* --- MARCADOR DE PUNTOS OPTIMIZADO EN ALTURA --- */
.score { 
    font-size: 3.5rem;          /* Reducido de 4.2rem para compactar el alto del bloque azul */
    font-weight: 900; 
    color: white; 
    margin-bottom: 6px; 
    line-height: 1; 
    font-family: monospace;
}

/* Reducción sutil de los márgenes en los botones de control */
.controles { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-bottom: 6px; }
.controles button { background-color: var(--verde-cancha); color: white; padding: 6px; font-size: 1rem; }
.btn-falta { background-color: var(--naranja-acento); color: white; width: 100%; padding: 6px; font-size: 0.85rem; }
/* --- MARQUESINA RELOJ DIGITAL --- */
/* --- ZONA CENTRAL (RELOJ Y CONTROLES) OPTIMIZADA --- */
.centro-reloj { 
    width: 44%; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    z-index: 4; 
    
    /* REGLA DE ORO: Empuja todo el bloque del reloj hacia abajo para que jamás quede debajo del título */
    margin-top: 55px;          
}

/* --- RECUADRO DIGITAL DEL TIEMPO --- */
.reloj-contenedor { 
    background: #000; 
    padding: 6px 20px;          /* Compactamos el relleno interno vertical */
    border-radius: 12px; 
    border: 3px solid var(--naranja-acento); 
    text-align: center; 
    margin-bottom: 8px;         /* Reducido para acercar los botones y ahorrar espacio */
    box-shadow: inset 0 0 15px rgba(205, 74, 36, 0.4);
    width: fit-content;         /* Se ajusta estrictamente al tamaño de los números */
}

.reloj-cancha { 
    font-size: 2.8rem;          /* Reducido levemente de 3.2rem para garantizar aire en pantallas bajas */
    color: #ff3b30; 
    font-weight: 900; 
    line-height: 1; 
    margin-bottom: 2px; 
    font-family: monospace; 
    letter-spacing: 2px;
}

#display-cuarto { 
    color: #ddd; 
    font-size: 0.95rem;         /* Proporcional al nuevo tamaño del reloj */
    font-weight: bold; 
    letter-spacing: 2px; 
}

/* --- CONTROLES DE TIEMPO BAJOS --- */
.controles-tiempo { 
    display: flex; 
    gap: 6px; 
    margin-bottom: 6px; 
}

.controles-tiempo button { 
    background-color: var(--azul-tiburones); 
    color: white; 
    border: 2px solid white; 
    padding: 6px 10px;          /* Botones ligeramente más compactos en altura */
    font-size: 0.8rem; 
}
.btn-guardar, .btn-guardar-fin { background-color: var(--naranja-acento); color: white; padding: 12px; font-size: 1.1rem; width: 100%; border-radius: 8px; font-weight: 900; box-shadow: 0 4px 6px rgba(0,0,0,0.3);}
.btn-guardar-fin { background-color: var(--naranja-acento); width: auto; padding: 8px 18px; font-size: 0.95rem; }
.btn-guardar-fin:hover { background-color: var(--verde-cancha); }
.pantalla-oculta { display: none !important; }