/* ===================
   PONG SOLO PARA EXPERTOS - Estilos Retro
   =================== */

/* ----- ESTILOS GENERALES ----- */

/* Fondo negro como las pantallas viejas */
body {
    background-color: black;
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    /* Prevenir scroll en móvil durante el juego */
    overflow: hidden;
    /* Prevenir selección de texto */
    user-select: none;
    -webkit-user-select: none;
    /* Prevenir zoom con doble tap */
    touch-action: manipulation;
}

/* ----- TÍTULO DEL JUEGO ----- */

h1 {
    /* Color verde neón como las pantallas de arcade */
    color: #00ff00;

    /* Fuente pixelada estilo retro */
    font-family: 'Courier New', monospace;
    font-size: 48px;
    text-transform: uppercase;
    letter-spacing: 4px;

    /* Efecto de brillo (glow) */
    text-shadow:
        0 0 10px #00ff00,
        0 0 20px #00ff00,
        0 0 30px #00ff00;

    margin-bottom: 20px;
}

/* ----- CANVAS DEL JUEGO ----- */

#gameCanvas {
    /* Borde AZUL brillante */
    border: 4px solid #0066ff;

    /* Efecto glow en el borde (AZUL) */
    box-shadow:
        0 0 10px #0066ff,
        0 0 20px #0066ff,
        inset 0 0 10px rgba(0, 102, 255, 0.1);

    /* Fondo negro dentro del canvas */
    background-color: #000000;
}

/* ----- INSTRUCCIONES ----- */

.instructions {
    color: #00ff00;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    margin-top: 20px;

    /* Brillo más suave para las instrucciones */
    text-shadow: 0 0 5px #00ff00;
}

/* ----- CONTENEDOR DEL JUEGO ----- */

#game-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 100vw;
}

/* ----- BOTONES TÁCTILES ----- */

/* Por defecto ocultos (se muestran en móvil) */
.touch-controls {
    display: none;
    flex-direction: column;
    gap: 10px;
}

.touch-btn {
    /* Tamaño grande para dedos */
    width: 60px;
    height: 60px;
    font-size: 24px;

    /* Estilo retro */
    background-color: #000000;
    color: #00ff00;
    border: 3px solid #00ff00;
    border-radius: 10px;

    /* Efecto glow */
    box-shadow: 0 0 10px #00ff00;

    /* Cursor pointer para saber que es clickeable */
    cursor: pointer;

    /* Prevenir zoom al tocar */
    touch-action: manipulation;
}

/* Efecto cuando se presiona el botón */
.touch-btn:active {
    background-color: #00ff00;
    color: #000000;
    box-shadow: 0 0 20px #00ff00;
}

/* ----- BOTONES DE CONTROL (PAUSA Y MENÚ) ----- */

.control-btn {
    padding: 8px 16px;
    font-size: 14px;
    font-family: 'Courier New', monospace;

    /* Estilo retro */
    background-color: #000000;
    color: #00ff00;
    border: 2px solid #00ff00;
    border-radius: 5px;

    /* Efecto glow suave */
    box-shadow: 0 0 5px #00ff00;

    cursor: pointer;
    touch-action: manipulation;
}

.control-btn:active {
    background-color: #00ff00;
    color: #000000;
}

/* ----- RESPONSIVE: MÓVIL ----- */

/* Cuando la pantalla es pequeña (móvil) */
@media (max-width: 900px) {
    /* Menos padding en móvil para maximizar espacio */
    body {
        padding: 5px;
    }

    /* Reducir gap entre controles y canvas */
    #game-container {
        gap: 2px;
    }

    /* Título más pequeño */
    h1 {
        font-size: 24px;
        letter-spacing: 2px;
        margin-bottom: 5px;
    }

    /* Botones táctiles más pequeños para dar espacio al canvas */
    .touch-btn {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }

    /* Reducir gap entre botones */
    .touch-controls {
        gap: 5px;
    }

    /* Botones de control (pausa/menú) dentro de touch-controls */
    .touch-controls .control-btn {
        width: 45px;
        padding: 8px 0;
        font-size: 16px;
        margin-top: 5px;
    }

    /* Ocultar título durante el juego para maximizar espacio vertical */
    body.playing h1 {
        display: none;
    }

    /* Botones táctiles: solo visibles cuando body tiene clase "playing" */
    body.playing .touch-controls {
        display: flex;
    }

    /* Canvas que se adapte al espacio disponible */
    #gameCanvas {
        max-width: calc(100vw - 100px);
        height: auto;
        /* Limitar altura para que quepa en pantalla sin scroll */
        max-height: calc(100vh - 90px);
    }

    /* Cuando estamos jugando, el canvas necesita espacio para botones */
    /* Cálculo: 45px×2 botones + 2px×2 gaps + 5px×2 padding = ~100px */
    body.playing #gameCanvas {
        max-width: calc(100vw - 100px);
        /* Sin título ni barra de controles, solo padding arriba/abajo */
        max-height: calc(100vh - 20px);
    }

    /* En el menú, el canvas puede usar casi todo el ancho (sin botones) */
    body:not(.playing) #gameCanvas {
        max-width: calc(100vw - 10px);
    }

    /* Ocultar instrucciones de teclado en móvil */
    .instructions {
        display: none;
    }
}

/* Pantalla muy pequeña (teléfonos pequeños) */
@media (max-width: 500px) {
    h1 {
        font-size: 18px;
    }

    /* Botones aún más pequeños en pantallas muy pequeñas */
    .touch-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    /* Botones de control más pequeños también */
    .touch-controls .control-btn {
        width: 40px;
        font-size: 14px;
    }

    /* Cuando estamos jugando, el canvas necesita espacio para botones */
    /* Cálculo: 40px×2 botones + 2px×2 gaps + 5px×2 padding = ~90px */
    body.playing #gameCanvas {
        max-width: calc(100vw - 90px);
        max-height: calc(100vh - 20px);
    }

    /* En el menú, el canvas puede usar casi todo el ancho */
    body:not(.playing) #gameCanvas {
        max-width: calc(100vw - 10px);
    }
}

/* ----- DESKTOP: OCULTAR BOTONES TÁCTILES ----- */

/* En pantallas grandes, asegurar que los controles táctiles nunca se muestren */
@media (min-width: 901px) {
    .touch-controls,
    body .touch-controls,
    body.playing .touch-controls,
    #game-container .touch-controls {
        display: none !important;
        visibility: hidden !important;
    }
}

/* ----- MENSAJE DE ROTACIÓN (MÓVIL PORTRAIT) ----- */

/* Por defecto oculto */
.rotate-message {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh; /* Para iOS Safari - viewport dinámico */
    background-color: rgba(0, 0, 0, 0.98);
    z-index: 9999;

    /* Estilo retro */
    color: #00ff00;
    font-family: 'Courier New', monospace;
    text-shadow: 0 0 10px #00ff00;
}

.rotate-icon {
    font-size: 60px;
}

.rotate-message p {
    font-size: 24px;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.rotate-arrow {
    font-size: 48px;
    animation: rotate-hint 2s ease-in-out infinite;
}

@keyframes rotate-hint {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

/* Mostrar SOLO en móvil + portrait */
@media (max-width: 900px) and (orientation: portrait) {
    .rotate-message {
        display: flex;
        display: -webkit-flex;
        flex-direction: column;
        -webkit-flex-direction: column;
        justify-content: center;
        -webkit-justify-content: center;
        align-items: center;
        -webkit-align-items: center;
        gap: 20px;
    }
}
