@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* -------------------- RESET GENERAL Y FUENTE -------------------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Press Start 2P', cursive;
    -webkit-user-select: none;
    /* Safari */
    -ms-user-select: none;
    /* IE10+ */
    user-select: none;
    /* Estándar */
}

body,
html {
    height: 100%;
    margin: 0;
    overflow-y: hidden;
    position: fixed;
    background: #000;
    touch-action: none;
    overscroll-behavior: none;
}

button {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.pantalla {
    height: 100vh;
    width: 100vw;
}

.hidden {
    display: none;
}

/* -------------------- FONDO Y ANIMACIÓN DE NUBES -------------------- */
.loading-background {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.cloud {
    position: absolute;
    width: 220px;
    height: 140px;
    background: url('img/cloud.png') no-repeat center/contain;
    opacity: 0.85;
    animation: cloudMove 40s linear infinite;
    z-index: 1;
}

/* Posicionamiento específico de cada nube */
.cloud1 {
    top: 10%;
    left: -200px;
}

.cloud2 {
    top: 25%;
    left: -300px;
}

.cloud3 {
    top: 50%;
    left: -250px;
}

.cloud4 {
    top: 70%;
    left: -400px;
}

.cloud5 {
    top: 85%;
    left: -350px;
}

.cloud.reverse {
    animation: cloudMoveReverse 40s linear infinite;
    right: -300px;
    left: auto;
}

@keyframes cloudMove {
    from {
        transform: translateX(-300px);
    }

    to {
        transform: translateX(200vw);
    }
}

@keyframes cloudMoveReverse {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(-200vw);
    }
}

/* -------------------- PANTALLA DE CARGA -------------------- */
#loading-screen {
    position: relative;
    top: 0;
    left: 0;
    z-index: 1;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #7ec0ee url('SuperMarioBros.jpg') no-repeat center center;
    background-size: cover;
    color: #fff;
    text-shadow: 2px 2px #000;
}

#loading-screen h1 {
    font-size: 1.2rem;
    background: #c1440e;
    padding: 20px;
    border: 4px solid #000;
}

#start-button {
    animation: zoomBlink 1.2s infinite ease-in-out;
}

@keyframes zoomBlink {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    25% {
        transform: scale(1.05);
        opacity: 0.6;
    }

    50% {
        transform: scale(1);
        opacity: 1;
    }

    75% {
        transform: scale(1.05);
        opacity: 0.6;
    }
}

#start-button,
#restart-button,
#contact-button {
    margin-top: 20px;
    padding: 10px 20px;
    font-size: 1rem;
    background-color: #ffcc00;
    border: 4px solid #000;
    cursor: pointer;
}

#restart-button,
#contact-button {
    margin-top: 30px;
    background-color: #00ccff;
    animation: blink 1s infinite;
}

#loading-screen h1,
#loading-screen button {
    position: relative;
    z-index: 2;
}

@keyframes blink {

    0%,
    50%,
    100% {
        opacity: 1;
    }

    25%,
    75% {
        opacity: 0;
    }
}

/* -------------------- POPUP DE INSTRUCCIONES -------------------- */
#instructions-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: #432818;
    border: 5px solid #d4a373;
    color: #fff3e0;
    padding: 35px;
    font-size: 0.9rem;
    width: 500px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    font-family: 'Press Start 2P', cursive;
    z-index: 10000;
    text-align: left;
    display: none;
    box-shadow: 0 0 20px #d4a373;
    line-height: 1.8;
    letter-spacing: 0.5px;
    opacity: 0;
    animation: popupFadeIn 0.8s ease-out forwards;
}

@keyframes popupFadeIn {
    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* Botón del popup de instrucciones */
#instructions-popup button {
    margin-top: 25px;
    font-family: 'Press Start 2P', cursive;
    background: #d4a373;
    border: 3px solid #000;
    color: #000;
    padding: 12px 24px;
    cursor: pointer;
    font-size: 0.8rem;
    box-shadow: 2px 2px 0 #000;
    text-transform: uppercase;
    transition: all 0.2s ease;
    animation: pulseBtn 1.2s infinite alternate;
    display: inline-block;
}

@keyframes pulseBtn {
    0% {
        transform: scale(1);
        box-shadow: 2px 2px 0 #000;
    }

    100% {
        transform: scale(1.04);
        box-shadow: 3px 3px 0 #000;
    }
}

/* Clase para resaltar teclas en instrucciones */
.key {
    background: #000;
    color: #fff3e0;
    padding: 4px 10px;
    margin: 0 4px;
    border: 2px solid #d4a373;
    font-size: 0.75rem;
    display: inline-block;
    font-family: 'Press Start 2P', cursive;
    text-shadow: none;
    vertical-align: middle;
    box-shadow: 2px 2px 0 #000;
}

/* -------------------- PANTALLA PRINCIPAL DEL JUEGO -------------------- */
#main-screen {
    display: flex;
    flex-direction: column;
    height: 100vh;
    z-index: 1;
}

#main-screen.hidden {
    display: none !important;
}

/* Barra de navegación superior */
nav {
    background-color: #222;
    color: white;
    border-bottom: 4px solid #ffcc00;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    width: 100%;
}

nav img.logo {
    height: 100px;
    cursor: pointer;
}

nav img.logo:hover {
    transform: scale(1.05);
    filter: brightness(1.3);
}

nav a {
    color: white;
    text-decoration: none;
    font-size: 1rem;
}

/* Boton CONTACTO para ir a la pantalla de contacto */
#go-contact {
    color: #fff;
    text-decoration: none;
    font-family: 'Press Start 2P', cursive;
    padding: 8px 12px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

#go-contact:hover {
    border: 2px solid #fff;
    background-color: #ffcc00;
    color: #000;
    text-shadow: 1px 1px 0 #fff;
    transform: scale(1.05);
}

/* Barra informativa de mision (visible cuando se cierran las instrucciones y se va a empezar a jugar) */
#mission-bar {
    display: none;
    background-color: #ffcc00;
    color: #000;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.65rem;
    text-align: center;
    padding: 10px;
    box-shadow: 0 4px 0 #222;
    width: 100%;
    z-index: 99;
    opacity: 0;
    transform: translateY(-100%);
    transition: transform 0.6s ease-out, opacity 0.6s ease-out;
}

#mission-bar.visible {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

#mission-bar.hidden {
    display: block;
}

/* Vista principal del juego */
#game-viewport {
    position: relative;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#game-container {
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
    height: 100%;
    position: relative;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE y Edge */
}

#game-container::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari */
}

/* Escenario horizontal del juego (zona jugable) */
#game-area {
    height: 100%;
    width: 8000px;
    background: url('img/fondo_juego2.png');
    background-repeat: repeat-x;
    background-position: bottom;
    background-size: auto 100%;
    position: relative;
}

/* Jugador o personaje jugable */
#player {
    width: 60px;
    height: 60px;
    background-image: url('img/players/player3.png');
    background-size: cover;
    position: absolute;
    bottom: 0;
    left: 50px;
    transform: scaleX(1);
    transition: transform 0.1s ease;
}

/* El jugador brilla al abrir las 12 cajas */
.player-glow::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(255, 255, 0, 0.5) 0%, rgba(255, 255, 0, 0) 70%);
    z-index: -1;
    border-radius: 50%;
    filter: blur(8px);
    animation: pulse-glow 1.5s ease-in-out infinite;
}

/* Animacion de brillo */
@keyframes pulse-glow {

    0%,
    100% {
        opacity: 0.6;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Al jugador le salen unas sombras fantasma al abrir las 12 cajas */
.player-trail {
    position: absolute;
    width: 60px;
    height: 60px;
    background-image: inherit;
    background-size: cover;
    background-repeat: no-repeat;
    opacity: 0.4;
    pointer-events: none;
    transform: scaleX(1);
    animation: trailFade 0.4s ease-out forwards;
    z-index: 2;
}

/* Animacion de sombras fantasma */
@keyframes trailFade {
    0% {
        opacity: 0.4;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateY(10px);
    }
}

/* Bandera final del recorrido (META) */
#flag {
    width: 85px;
    height: 150px;
    background-image: url('img/flag.png');
    background-size: cover;
    position: absolute;
    right: 50px;
    bottom: 0;
}

/* Mensaje de victoria al llegar a la bandera final */
#victory-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: repeating-linear-gradient(45deg, #ffd700, #ffd700 10px, #ffa500 10px, #ffa500 20px);
    color: #000;
    padding: 40px;
    margin: 8px;
    border: 5px solid #000;
    font-size: 1rem;
    text-align: center;
    z-index: 10001;
    display: none;
    font-family: 'Press Start 2P', cursive;
}

/* -------------------- VENTANA RETRO EMERGENTE AL ABRIR UNA CAJA -------------------- */

/* Ventana emergente estilo retro con contenido multimedia al abrir una caja */
#retro-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    overflow-y: auto;
    transform: translate(-50%, -50%);
    width: 80vw;
    height: 80vh;
    max-height: 80vh;
    padding: 20px;
    background: #ffffff;
    border: 4px solid #000;
    image-rendering: pixelated;
    z-index: 10000;
    display: none;
    box-sizing: border-box;
    box-shadow: 4px 4px 0 #000;
    -webkit-overflow-scrolling: touch; /* Inercia en iOS */
    overscroll-behavior: contain; /* Evita que el scroll se propague al body */
}

/* Boton de cierre en la ventana emergente */
#retro-popup-close {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #ffcc00;
    color: #000;
    font-family: 'Press Start 2P', cursive;
    padding: 5px 10px;
    cursor: pointer;
    border: 3px solid #000;
    z-index: 10001;
}

#retro-popup h2 {
    font-size: 20px;
    margin-top: 0;
    color: black;
    margin-bottom: 10px;
    text-shadow: 1px 1px 0 #ec407a;
}

#retro-popup p {
    font-size: 14px;
    line-height: 2;
    margin-bottom: 16px;
    white-space: pre-wrap;
}

/* Con esto conseguimos bloquear toda funcionalidad fuera de la ventana emergente, pudiendo solo tocar dentro de la ventana */
#overlay-blocker {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: transparent;
    z-index: 9999;
    cursor: not-allowed;
}

#overlay-blocker.hidden {
    display: none;
}

/* -------------------- CAJA 1: OUIGO ROSA -------------------- */
.popup-image-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
    margin-top: 20px;
}

.column-images img {
    width: 100%;
    margin-top: 20px;
    border-radius: 12px;
    border: 3px solid #ec407a;
    box-shadow: 0 0 10px #ec407aaa;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.row-images {
    display: flex;
    justify-content: center;
    width: 100%;
    gap: 20px;
}

.row-images img {
    width: 30%;
    max-width: 240px;
    min-width: 180px;
    flex: 1 1 auto;
    object-fit: contain;
}

.row-images img,
.single-image img {
    height: auto;
    border-radius: 12px;
    border: 3px solid #ec407a;
    box-shadow: 0 0 10px #ec407aaa;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

@media (max-width: 768px) {
    .row-images {
        flex-direction: column;
        align-items: center;
    }

    .row-images img {
        width: 90%;
        max-width: none;
    }
}

.single-image {
    margin-top: 20px;
    text-align: center;
}

.single-image img {
    width: 100%;
    max-width: 500px;
    border-radius: 12px;
    border: 3px solid #ec407a;
    box-shadow: 0 0 10px #ec407aaa;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#popup-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
    padding: 20px;
}

#popup-content img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    border: 4px solid #ec407a;
    box-shadow: 0 0 12px #ec407aaa;
}

#retro-popup .popup-content {
    text-align: center;
}

@media (max-width: 768px) {
    #retro-popup {
        font-size: 12px;
    }

    #retro-popup h2 {
        font-size: 16px;
    }

    #retro-popup p {
        font-size: 12px;
    }
}

/* -------------------- CAJA 2: OUIGO AZUL -------------------- */
.ouigo100k-title {
    text-shadow: 1px 1px 0 #2ca9d3 !important;
}

.popup-video-grid {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.popup-video-grid video {
    width: calc(25% - 15px);
    max-height: 80vh;
    border-radius: 12px;
    border: 3px solid #2ca9d3;
    box-shadow: 0 0 10px #2ca9d3aa;
}

.popup-image-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: 30px;
}

.popup-image-grid img {
    width: 100%;
    height: auto;
    border-radius: 12px;
    border: 3px solid #2ca9d3 !important;
    box-shadow: 0 0 10px #2ca9d3 !important;
}

/* -------------------- CAJA 3: REDPISO -------------------- */
h2.redpiso-title {
    text-shadow: 1px 1px 0 #e72020 !important;
}

.busca-hogar-video {
    width: 100%;
    margin-top: 20px;
    display: flex;
    justify-content: center;
}

.busca-hogar-video video {
    width: 100%;
    max-width: 100%;
    border-radius: 12px;
    border: 3px solid #e72020;
    box-shadow: 0 0 10px #e72020aa;
}

/* -------------------- CAJA 4: EUSKADI -------------------- */
h2.euskadi-title {
    text-shadow: 1px 1px 0 #259d52 !important;
}

.pasahitza-video {
    width: 100%;
    margin-top: 20px;
    display: flex;
    justify-content: center;
}

.pasahitza-video video {
    width: 100%;
    max-width: 100%;
    border-radius: 12px;
    border: 3px solid #259d52;
    box-shadow: 0 0 10px #259d52aa;
}

/* -------------------- CAJA 5: BANCO DE ALIMENTOS -------------------- */
h2.alimentos-title {
    text-shadow: 1px 1px 0 #204d9b !important;
}

.banco-row-fixed {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 20px;
    margin-top: 20px;
    width: 100%;
}

.banco-row-fixed .img-wrapper {
    flex: 1;
    max-width: 32%;
}

.banco-row-fixed img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
    border: 3px solid #204d9b !important;
    box-shadow: 0 0 10px #204d9baa !important;
}

/* -------------------- CAJA 6: OATLY -------------------- */
h2.oatly-title {
    text-shadow: 1px 1px 0 #add8e6 !important;
}

.video-oatly-wrapper {
    width: 100%;
    margin-top: 20px;
}

.video-oatly-wrapper video {
    width: 100%;
    height: auto;
    border-radius: 12px;
    border: 3px solid #add8e6;
    box-shadow: 0 0 10px #add8e688;
}

/* -------------------- CAJA 7: EUROSPORT -------------------- */
h2.eurosport-title {
    text-shadow: 1px 1px 0 #252a55 !important;
}

.video-eurosport-wrapper {
    width: 100%;
    margin-top: 20px;
}

.video-eurosport-wrapper video {
    width: 100%;
    height: auto;
    border-radius: 12px;
    border: 3px solid #252a55;
    box-shadow: 0 0 10px #252a5588;
}

/* -------------------- CAJA 8: FINETWORK -------------------- */
h2.finetwork-title {
    text-shadow: 1px 1px 0 #4b4995 !important;
}

.gif-finetwork-wrapper {
    width: 100%;
    margin-top: 20px;
}

.gif-finetwork-wrapper img {
    width: 100%;
    height: auto;
    border-radius: 12px;
    border: 3px solid #4b4995 !important;
    box-shadow: 0 0 10px #4b499588 !important;
}

/* -------------------- CAJA 9: POWERADE -------------------- */
h2.powerade-title {
    text-shadow: 1px 1px 0 #00AEEF !important;
}

.video-powerade-wrapper {
    width: 100%;
    margin-top: 20px;
}

.video-powerade-wrapper video {
    width: 100%;
    height: auto;
    border-radius: 12px;
    border: 3px solid #00AEEF;
    box-shadow: 0 0 10px #00AEEF;
}

/* -------------------- CAJA 10: AS -------------------- */
h2.as-title {
    text-shadow: 1px 1px 0 #E30613 !important;
}

.video-as-wrapper {
    width: 100%;
    margin-top: 20px;
}

.video-as-wrapper video {
    width: 100%;
    height: auto;
    border-radius: 12px;
    border: 3px solid #E30613;
    box-shadow: 0 0 10px #E30613;
}

/* -------------------- CAJA 11: PC COMPONENTES -------------------- */
h2.pc-title {
    text-shadow: 1px 1px 0 #F7A723 !important;
}

.video-pc-wrapper {
    width: 100%;
    margin-top: 20px;
}

.video-pc-wrapper video {
    width: 100%;
    height: auto;
    border-radius: 12px;
    border: 3px solid #F7A723;
    box-shadow: 0 0 10px #F7A723;
}

/* -------------------- CAJA 12: SOUNDCLOUD -------------------- */
h2.sound-title {
    text-shadow: 1px 1px 0 #E25A1D !important;
}

.video-sound-wrapper {
    width: 100%;
    margin-top: 20px;
}

.video-sound-wrapper video {
    width: 100%;
    height: auto;
    border-radius: 12px;
    border: 3px solid #E25A1D;
    box-shadow: 0 0 10px #E25A1D;
}

/* -------------------- PORTADA, ESTILOS Y ANIMACIONES DE LAS CAJAS EN EL JUEGO -------------------- */

/* Caja sorpresa: posicion general en el mapa del juego */
.box {
    position: absolute;
    width: 100px;
    height: 100px;
    cursor: pointer;
}

/* Parte interior de la caja: portada y animacion */
.box-inner {
    width: 100%;
    height: 100%;
    background-size: cover;
    animation: float 1s infinite ease-in-out, blink 2s infinite steps(2);
}

/* Animación flotante para dar efecto de rebote a las cajas */
@keyframes float {
    0% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-4px);
    }

    100% {
        transform: translateY(0);
    }
}

/* Animación de brillo intermitente para las cajas */
@keyframes blink {

    0%,
    100% {
        filter: brightness(100%);
    }

    50% {
        filter: brightness(130%);
    }
}

/* Portada especifica para cada caja (imagen de la marca correspondiente) */
.box1 {
    background-image: url('img/boxes/OUIGO\ ROSA.png');
}

.box2 {
    background-image: url('img/boxes/OUIGO\ AZUL.png');
}

.box3 {
    background-image: url('img/boxes/REDPISO.png');
}

.box4 {
    background-image: url('img/boxes/EUSKADI.png');
}

.box5 {
    background-image: url('img/boxes/BANCO\ ALIMENTOS.png');
}

.box6 {
    background-image: url('img/boxes/OATLY.png');
}

.box7 {
    background-image: url('img/boxes/EUROSPORT.png');
}

.box8 {
    background-image: url('img/boxes/FINETWORK.png');
}

.box9 {
    background-image: url('img/boxes/POWERADE.png');
}

.box10 {
    background-image: url('img/boxes/AS.png');
}

.box11 {
    background-image: url('img/boxes/PC\ COMPONENTES.png');
}

.box12 {
    background-image: url('img/boxes/SOUNDCLOUD.png');
}

/*.popup-images {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.popup-images img {
    max-width: 150px;
    border-radius: 8px;
    border: 2px solid white;
}*/

/* -------------------- AÑADIDOS PARA MEJORAR EL JUEGO: PUNTOS, VIDAS, PROGRESO, FUEGOS -------------------- */

/* Indicador de puntuación en pantalla */
#score {
    position: absolute;
    top: 20px;
    right: 30px;
    font-family: 'Press Start 2P', cursive;
    font-size: 1rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 15px;
    border: 3px solid #ffcc00;
    z-index: 999;
}

/* Indicador de vidas con corazones pixelados (no es funcional, solo a modo decorativo) */
#lives {
    position: absolute;
    top: 20px;
    left: 30px;
    font-family: 'Press Start 2P', cursive;
    font-size: 1rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 15px;
    border: 3px solid #ff4d4d;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 10px;
}

#lives .hearts {
    display: flex;
    gap: 8px;
}

.heart {
    width: 35px;
    height: 35px;
    image-rendering: pixelated;
    vertical-align: middle;
}

/* Barra de progreso que indica el avance del jugador */
#progress-container {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 360px;
    height: 18px;
    background: #000;
    border: 4px solid #fff;
    box-shadow: 0 0 0 2px #ffcc00;
    z-index: 10;
}

/* Progreso dinámico dentro de la barra */
#progress-bar {
    height: 100%;
    width: 0%;
    background: #ffcc00;
    box-shadow: inset 0 0 0 2px #000;
    transition: width 0.15s ease-in-out;
}

/* Efecto de fuegos artificiales que aparecen al llegar a la meta */
#fireworks {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    pointer-events: none;
    z-index: 2;
}

.firework {
    position: absolute;
    width: 6px;
    height: 6px;
    background: yellow;
    border-radius: 50%;
    animation: explode 1s ease-out forwards;
}

/* Animacion de expansion y desvanecimiento de los fuegos artificiales */
@keyframes explode {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Elemento decorativo que simula tierra bajo el cesped que pisa el jugador */
#ground-bar {
    height: 40px;
    width: 100%;
    background: repeating-linear-gradient(0deg,
            #5c3b1e 0px,
            #5c3b1e 4px,
            #4b2d17 4px,
            #4b2d17 8px);
    border-top: 4px solid #3a240f;
    box-shadow: inset 0 4px 0 #7b4a2f;
}

/* -------------------- FOOTER -------------------- */
footer {
    background-color: #222;
    color: white;
    border-top: 4px solid #ffcc00;
    text-align: center;
    padding: 10px;
    width: 100%;
}

/* -------------------- PANTALLA DE CONTACTO -------------------- */

/* También se aplican las nubes en movimiento en esta pantalla */
#contact-screen {
    background: #7ec0ee url('SuperMarioBros.jpg') no-repeat center center;
    background-size: cover;
    overflow: hidden;
    position: relative;
    z-index: 1;
    min-height: 100vh;
    padding: 40px 20px;
    font-family: 'Press Start 2P', cursive;
    text-align: center;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#contact-screen h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    color: #000;
    text-shadow: 2px 2px #fff700;
}

#contact-screen.hidden {
    display: none !important;
}

.contact-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    max-width: 500px;
    margin: 0 auto 40px;
}

/* Botones de la pantalla de contacto */
.contact-btn {
    background-color: #003399;
    color: #fff;
    border: 2px solid #000;
    border-radius: 5px;
    outline: 2px solid #ffcc00;
    padding: 12px 24px;
    font-size: 0.85rem;
    font-family: 'Press Start 2P', cursive;
    box-shadow: 0 4px 0 #000;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    transition: transform 0.15s ease;
    margin: 10px auto;
    width: 300px;
}

.contact-btn:hover {
    background-color: #0044cc;
    transform: scale(1.05);
    box-shadow: 0 2px 0 #000;
}

/* Boton en la pantalla de contacto para volver al juego */
#back-to-game {
    padding: 8px 16px;
    font-size: 0.8rem;
    background-color: #ffcc00;
    border: 4px solid #000;
    cursor: pointer;
    font-family: 'Press Start 2P', cursive;
    box-shadow: 4px 4px 0 #000;
    margin-top: 20px;
    margin-left: auto;
    margin-right: auto;
    width: fit-content;
}

#back-to-game:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 0 #000;
}

/* Con esto conseguimos que las nubes en movimiento no interfieran en la funcionalidad de la pantalla y queden de fondo */
#contact-screen h2,
#contact-screen .contact-grid,
#contact-screen .contact-btn,
#contact-screen #back-to-game {
    position: relative;
    z-index: 2;
}

/* Animacion de parpadeo para textos destacados en la pantalla de contacto */
.blink-contact {
    margin-bottom: 50px;
    animation: blink 1s infinite step-start;
}

@keyframes blink-contact {
    50% {
        opacity: 0;
    }
}

/* Estilos del mensaje que aparece cuando giras el movil a horizontal */
#orientation-lock {
    position: fixed;
    z-index: 9999;
    background: #000;
    color: white;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 2rem;
    padding: 20px;
}

#orientation-lock.hidden {
    display: none;
}

/* Estilos para la galería de imagenes en pantalla completa en el movil */
#fullscreen-gallery {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 10002;
    padding: 20px;
}

#fullscreen-gallery.hidden {
    display: none;
}

#fullscreen-gallery img {
    max-width: 90%;
    max-height: 80%;
    border-radius: 16px;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

#fullscreen-gallery button {
    background: none;
    border: none;
    color: white;
    font-size: 3rem;
    cursor: pointer;
    position: absolute;
    z-index: 10000;
}

#gallery-close {
    top: 20px;
    right: 30px;
}

#gallery-prev {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
}

#gallery-next {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

/* -------------------- CODIGO CSS PARA VERSION MOVIL (RESPONSIVE) -------------------- */

@media (max-width: 768px) {
    #mobile-controls {
        position: fixed;
        bottom: 20px;
        left: 0;
        width: 100%;
        display: none;
        justify-content: space-between;
        align-items: center;
        padding: 0 10px;
        z-index: 10000;
        pointer-events: auto;
    }

    #mobile-controls button {
        font-family: 'Press Start 2P', cursive;
        font-size: 1.5rem;
        background: #ffcc00;
        border: 3px solid #000;
        box-shadow: 2px 2px #000;
        cursor: pointer;
        padding: 16px;
        border-radius: 10px;
        user-select: none;
        /* Evita que el texto se pueda seleccionar */
        -webkit-user-select: none;
        /* Compatibilidad Safari */
        -moz-user-select: none;
        /* Compatibilidad Firefox */
        -ms-user-select: none;
        /* Compatibilidad IE/Edge */
        touch-action: manipulation;
        /* Evita efectos indeseados al pulsar */
    }

    #mobile-controls button:active {
        transform: scale(0.95);
        box-shadow: inset 2px 2px #000;
    }

    #left-btn,
    #right-btn {
        width: 100px;
        flex-shrink: 0;
    }

    #jump-btn {
        flex-grow: 1;
        margin: 0 10px;
        text-align: center;
    }
}

@media (max-width: 768px) {

    /* Bloquea zoom con dedos y arrastre lateral */
    html,
    body {
        touch-action: none;
    }

    /* Ajustamos los elementos de la pantalla de carga */
    #loading-screen h1 {
        padding: 16px;
        margin: 0 20px;
        font-size: 1rem;
        text-align: center;
        word-wrap: break-word;
    }

    /* Ajustamos la velocidad de las nubes en la pantalla de carga: van más rápido en verisón movil */
    .cloud {
        animation: cloudMove 25s linear infinite;
    }

    .cloud.reverse {
        animation: cloudMoveReverse 25s linear infinite;
    }

    /* Ajustamos el header o nav para que se vea mas estrecho en la version movil */
    nav {
        padding: 12px 16px;
    }

    nav img.logo {
        height: 80px;
    }

    nav a {
        font-size: 1.1rem;
    }

    /* Reducción del personaje */
    #player {
        width: 40px;
        height: 40px;
    }

    /* Cajas más pequeñas */
    .box {
        width: 90px;
        height: 90px;
    }

    /* Bandera más compacta */
    #flag {
        width: 60px;
        height: 100px;
    }

    /* HUD: puntuación y vidas */
    #score,
    #lives {
        font-size: 0.7rem;
        padding: 6px 10px;
        border-width: 2px;
    }

    /* Corazones más pequeños */
    .heart {
        width: 22px;
        height: 22px;
    }

    /* Barra de progreso eliminada en version movil del juego */
    #progress-container {
        display: none;
    }

    /* Footer eliminado en version movil del juego */
    footer {
        display: none;
    }

    /* Aumentamos la altura de la tierra en version movil para tener espacio con los botones */
    /* Valor por defecto para móviles */
    /* En JS controlamos la altura para IOS y Safari */
    #ground-bar {
        height: 130px;
    }

    /* Ajuste especial para Safari en móviles */
    .safari-mobile-adjust #ground-bar {
        height: 190px !important;
    }

    /* Ajustes para ventana emergente */
    #retro-popup {
        width: 95vw;
        height: 85vh;
        font-size: 12px;
    }

    /* Ajustes texto contacto */
    #contact-screen h2 {
        font-size: 1.3rem;
    }

    .contact-btn {
        font-size: 0.65rem;
        width: 90%;
    }

    #back-to-game {
        font-size: 0.7rem;
        padding: 6px 12px;
    }
}

/* Responsive del contenido de las cajas */

/* Caja 2 */
@media (max-width: 768px) {
    .popup-video-grid {
        flex-direction: column;
        align-items: center;
    }

    .popup-video-grid video {
        width: 100%;
        max-width: none;
    }
}

@media (max-width: 768px) {
    .popup-image-grid {
        grid-template-columns: 1fr;
    }
}

/* Caja 5 */
@media (max-width: 768px) {
    .banco-row-fixed {
        flex-direction: column;
        align-items: center;
    }

    .banco-row-fixed .img-wrapper {
        max-width: 90%;
    }

    .banco-row-fixed img {
        width: 100%;
    }
}