/* --- ESTILOS GENERALES (VERSIÓN ORDENADOR) --- */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap');

body {
    font-family: 'Orbitron', sans-serif;
    background-color: #0c0a1f;
    color: #a2f2ef;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px 0;
    text-shadow: 0 0 5px #00f6ff;
}

.main-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

/* --- ELEMENTOS EXTERNOS AL JUEGO --- */
.logo-img {
    display: block;
    margin-bottom: 5px;
    width: 120px;
}

.main-title {
    font-size: 28px;
    text-align: center;
    margin: 0;
    color: #ffffff;
}

#start-screen {
    text-align: center;
    margin-top: 10px;
}

#start-screen p {
    font-size: 14px;
}

#start-screen .game-selection button {
    margin-top: 5px;
}

#timer-display {
    font-size: 36px;
    font-weight: bold;
    color: #ffcc00;
    text-shadow: 0 0 10px #ffcc00;
    padding: 5px 20px;
    background: rgba(14, 23, 51, 0.8);
    border: 2px solid #00f6ff;
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(0, 246, 255, 0.5);
    display: none;
}

.game-container {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 50px;
    background: rgba(14, 23, 51, 0.8);
    border: 2px solid #00f6ff;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 0 25px rgba(0, 246, 255, 0.5);
}

.music-control {
    position: absolute;
    top: -25px;
    right: 5px;
    font-size: 25px;
    cursor: pointer;
    z-index: 10;
    transition: transform 0.2s, box-shadow 0.2s;
    background-color: #0c0a1f;
    border-radius: 50%;
    border: 2px solid #00f6ff;
    width: 45px;
    height: 45px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.music-control:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px #00f6ff;
}

.controls {
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.controls p {
    text-align: center;
    font-size: 14px;
    min-height: 50px;
    margin: 0;
}

.game-selection button,
.game-controls button,
.question-area button {
    width: 100%;
    padding: 12px;
    font-family: 'Orbitron', sans-serif;
    background: #1b2a61;
    color: #a2f2ef;
    border: 1px solid #00f6ff;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s, box-shadow 0.3s;
}

.game-selection button:hover,
.game-controls button:hover,
.question-area button:hover {
    background: #2c449c;
    box-shadow: 0 0 15px #00f6ff;
}

.item-list {
    list-style: none;
    padding: 0;
    margin: 0;
    height: 350px;
    overflow-y: auto;
    border: 1px dashed #00f6ff;
    padding: 10px;
    border-radius: 5px;
}

.item-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 5px;
    background: rgba(44, 68, 156, 0.3);
    border-radius: 5px;
}

.item-list li.completed {
    opacity: 0.4;
    text-decoration: line-through;
}

.item-list img {
    width: 40px;
    height: 40px;
    margin-right: 10px;
    cursor: grab;
}

.item-list img[draggable="false"] {
    cursor: not-allowed;
}

.item-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.item-name {
    font-size: 13px;
    line-height: 1.2;
}

.item-coords {
    font-family: 'Lucida Console', monospace;
    font-size: 18px;
    color: #ffffff;
    background: #0c0a1f;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid #00f6ff;
    margin-top: 4px;
}

.question-area {
    text-align: center;
}

.question-area img {
    width: 80px;
    height: 80px;
    margin-bottom: 10px;
    border: 2px solid #00f6ff;
    border-radius: 5px;
    background: rgba(44, 68, 156, 0.5);
}

.coord-inputs {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 10px;
}

.coord-inputs label {
    font-family: 'Orbitron', sans-serif;
    font-size: 24px;
}

.coord-inputs input {
    width: 60px;
    height: 60px;
    text-align: center;
    background: #0c0a1f;
    border: 2px solid #00f6ff;
    color: #a2f2ef;
    border-radius: 8px;
    font-size: 28px;
}

.game-controls {
    margin-top: 20px;
}

.plane-wrapper {
    position: relative;
    padding-left: 30px;
    padding-bottom: 30px;
}

.cartesian-plane {
    width: 750px;
    height: 500px;
    position: relative;
    border: 2px solid #00f6ff;
    box-sizing: content-box;
    background-color: #0c0a1f;
}

.cartesian-plane::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('fondo.webp');
    background-size: cover;
    opacity: 0.5;
    z-index: 0;
}

.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: repeating-linear-gradient(#00f6ff88 0 1px, transparent 1px 100%), repeating-linear-gradient(90deg, #00f6ff88 0 1px, transparent 1px 100%);
    background-size: 50px 50px;
    z-index: 1;
}

.axes-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

.axis-label {
    position: absolute;
    color: #fff;
    text-shadow: 0 0 3px black;
    font-size: 14px;
}

.x-axis {
    transform: translateX(-50%);
}

.y-axis {
    transform: translateY(-50%);
    width: 25px;
    text-align: right;
}

.placed-item {
    position: absolute;
    width: 50px;
    height: 50px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 0.2s, opacity 0.5s;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.placed-item.disappearing {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.1);
}

.placed-item:hover {
    transform: translate(-50%, -50%) scale(1.1);
}

.feedback-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    font-size: 6vw;
    text-align: center;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s;
}

.feedback-overlay.show {
    display: flex;
    opacity: 1;
}

.feedback-overlay.correct {
    color: #00ff00;
    text-shadow: 0 0 25px #00ff00;
}

.feedback-overlay.incorrect {
    color: #ff0000;
    text-shadow: 0 0 25px #ff0000;
}

#invaders-animation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: none;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: flex-start;
    background: rgba(10, 0, 20, 0.7);
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.5s;
    pointer-events: none;
}

#invaders-animation-overlay.show {
    display: flex;
    opacity: 1;
}

.invader-alien {
    width: 60px;
    height: auto;
    margin: 10px;
    animation: descendAnimation 4s linear forwards;
}

@keyframes descendAnimation {
    0% { transform: translateY(-100px); opacity: 0; }
    15% { opacity: 1; }
    85% { opacity: 1; }
    100% { transform: translateY(100vh); opacity: 0; }
}

.external-link-btn {
    padding: 12px 25px;
    font-family: 'Orbitron', sans-serif;
    background: #1b2a61;
    color: #a2f2ef;
    border: 1px solid #00f6ff;
    border-radius: 5px;
    cursor: pointer;
    font-size: 18px;
    text-decoration: none;
    text-align: center;
    transition: background 0.3s, box-shadow 0.3s;
    margin-bottom: 20px;
}

.external-link-btn:hover {
    background: #2c449c;
    box-shadow: 0 0 15px #00f6ff;
}

.touch-clone {
    position: fixed;
    width: 50px;
    height: 50px;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.8;
    transform: translate(-50%, -50%);
}

/* --- INICIO: CÓDIGO AÑADIDO PARA MÓVILES --- */
#rotate-prompt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #0c0a1f;
    color: #a2f2ef;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 10000;
}

#rotate-prompt-overlay::before {
    content: '🔄';
    font-size: 60px;
    margin-bottom: 20px;
}

/* Aplica los estilos solo en pantallas "pequeñas" (tablets y móviles) */
@media (max-width: 1150px) {
    body {
        padding: 5px 0;
    }
    .main-wrapper {
        width: 100%;
        padding: 0 5px;
        box-sizing: border-box;
    }
    .main-title {
        font-size: 20px;
    }
    .logo-img {
        width: 100px;
    }
    .external-link-btn {
        margin-top: 15px;
    }

    /* Muestra el mensaje de rotación solo en modo vertical */
    @media (orientation: portrait) {
        #rotate-prompt-overlay {
            display: flex;
        }
        .main-wrapper {
            display: none; /* Oculta el juego */
        }
    }

    /* Estilos para el juego en modo horizontal */
    @media (orientation: landscape) {
        .game-container {
            flex-direction: row;
            width: 100vw;
            height: 100vh;
            padding: 10px;
            box-sizing: border-box;
            gap: 15px;
            overflow: hidden;
        }
        
        /* --- Columna de Controles (Izquierda) --- */
        .controls {
            width: 130px;
            flex-shrink: 0;
            height: 100%;
            display: flex;
            flex-direction: column;
        }
        
        #game-ui {
            display: flex;
            flex-direction: column;
            height: 100%;
            min-height: 0; /* Clave para que el scroll interno funcione en flexbox */
        }

        .controls p#feedback-text {
            display: none;
        }
        
        #game1-ui {
            flex: 1; /* Hace que este contenedor crezca y ocupe el espacio disponible */
            min-height: 0; /* Permite que el contenedor se encoja si es necesario */
            display: flex;
            flex-direction: column;
        }

        .item-list {
            flex-grow: 1;
            overflow-y: auto; /* Habilita el scroll solo para la lista */
            height: 100%;
            padding: 5px;
        }
        .item-list li {
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 5px;
            padding: 8px 5px;
        }
        .item-name {
            display: none;
        }
        .item-list img {
            margin-right: 0;
            width: 35px;
            height: 35px;
        }
        .item-coords {
            font-size: 16px;
        }
        
        .game-controls {
            margin-top: 0; /* Quitamos el margen superior para que se pegue al fondo */
            padding-top: 10px;
            flex-shrink: 0;
        }
        .game-controls button {
            padding: 8px;
            font-size: 13px;
        }

        /* --- Área del Tablero (Derecha) --- */
        .plane-wrapper {
            flex-grow: 1;
            height: 100%;
            padding: 0;
            box-sizing: border-box;
            display: flex;
            justify-content: center;
            align-items: center;
            overflow: hidden;
        }
        
        .scalable-plane-content {
            position: relative;
            width: 780px;
            height: 530px;
            transform: scale(0.7);
            transform-origin: center;
        }
        
        /* Corrección para la posición del plano */
        .cartesian-plane {
            position: absolute;
            top: 0;
            left: 30px; /* Desplaza el grid para dejar espacio al eje Y */
            height: 500px;
            width: 750px;
        }

        .axes-container {
            width: 100%;
            height: 100%;
        }
    }
}
/* --- FIN: CÓDIGO AÑADIDO PARA MÓVILES --- */