* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

body {
    overflow: hidden;
    font-family: 'Source Code Pro', sans-serif;
    background-color: #111;
    touch-action: manipulation;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#background {
    position: absolute;
    width: 10000%;
    height: 100%;
    background-image: url('img/bg-game.jpg');
    background-size: auto 100%;
    background-repeat: repeat-x;
    top: 0;
    left: 0;
}

/* Para PC */
#player {
    position: absolute;
    width: 200px;
    height: 210px;
    bottom: 30%;
    left: 50px; /* Movido más a la izquierda */
    background-image: url('img/sydney-moto.png');
    background-size: contain;
    background-repeat: no-repeat;
    transition: bottom 0.3s ease-out;
    z-index: 5;
}

.obstacle {
    position: absolute;
    width: 200px;
    height: 210px;
    bottom: 30%;
    right: -200px;
    background-image: url('img/troopers.png');
    background-size: contain;
    background-repeat: no-repeat;
    z-index: 10;
}

#score {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 32px;
    color: #d0a06f;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    z-index: 20;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 10px;
    display: none; /* Oculto inicialmente */
}

/* Pantalla de advertencia de orientación */
#orientation-warning {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    display: none; /* Inicialmente oculta */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: white;
    text-align: center;
}

.orientation-content {
    max-width: 500px;
    padding: 40px;
    background-color: rgba(30, 30, 30, 0.9);
    border-radius: 20px;
    border: 3px solid #d0a06f;
}

.phone-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: rotatePhone 2s infinite ease-in-out;
}

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

.orientation-content .message {
    font-size: 28px;
    color: #ff9900;
    margin-bottom: 20px;
}

.arrow {
    font-size: 60px;
    margin: 20px 0;
    animation: bounce 1s infinite alternate;
}

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-20px); }
}

.orientation-content p {
    font-size: 18px;
    color: #ccc;
    line-height: 1.5;
}

/* Pantallas del juego */
#start-screen, #game-over, #game-won {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    color: white;
    text-align: center;
}

#start-screen {
    display: flex;
}

#game-over, #game-won {
    display: none;
}

.message {
    font-size: 52px;
    margin-bottom: 30px;
    color: #FF0000;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.8);
    font-weight: bold;
}

.start-message {
    color: white;
    font-size: 60px;
    text-shadow: 0 0 20px rgba(208, 160, 111, 0.7);
    letter-spacing: 3px;
    margin-bottom: 15px;
}

.win-message {
    color: #00FF00;
}

.instructions-content {
    background-color: rgba(30, 30, 30, 0.9);
    padding: 30px;
    border-radius: 20px;
    max-width: 800px;
    margin: 0 auto;
    border: 3px solid #d0a06f;
    box-shadow: 0 0 30px rgba(208, 160, 111, 0.3);
    overflow-y: auto;
    max-height: 80vh;
}

.instructions-content h2 {
    color: #d0a06f;
    font-size: 28px;
    margin-bottom: 25px;
    text-transform: uppercase;
}

.text-instructions {
    text-align: left;
    margin-bottom: 30px;
}

.instruction-section {
    margin-bottom: 25px;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
}

.instruction-section h3 {
    color: #d0a06f;
    font-size: 22px;
    margin-bottom: 15px;
    text-align: center;
}

.instruction-section p {
    font-size: 14px;
    margin-bottom: 10px;
    line-height: 1.5;
    padding-left: 10px;
}

.instruction-section .note {
    color: #ff9900;
    font-style: italic;
    font-weight: bold;
    margin-top: 15px;
}

.instruction-section strong {
    color: #d0a06f;
}

.start-btn {
    padding: 20px 40px;
    font-family: 'Source Code Pro', sans-serif;
    font-size: 28px;
    background: linear-gradient(45deg, #d0a06f, #ff9900);
    color: black;
    border: none;
    cursor: pointer;
    font-weight: bold;
    border-radius: 15px;
    transition: all 0.3s;
    letter-spacing: 2px;
    text-transform: uppercase;
    box-shadow: 0 8px 0 rgba(168, 123, 71, 0.8);
    width: 100%;
    max-width: 400px;
}

.start-btn:hover {
    transform: translateY(-5px);
    background: linear-gradient(45deg, #ff9900, #d0a06f);
    box-shadow: 0 12px 0 rgba(168, 123, 71, 0.8);
}

.start-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 0 rgba(168, 123, 71, 0.8);
}

.restart-btn {
    padding: 15px 40px;
    font-family: 'Source Code Pro', sans-serif;
    font-size: 18px;
    background-color: rgba(0, 0, 0, 0.75);
    color: #d0a06f;
    border-color: #d0a06f;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    font-weight: bold;
    margin-top: 15px;
    transition: all 0.3s;
    border-radius: 10px;
}

.restart-btn:hover {
    transform: scale(1.05);
    background-color: rgba(74, 52, 90, 0.75);
}

#final-score, #win-score {
    font-size: 27px;
    margin-bottom: 22px;
    color: white;
}

.jumping {
    animation: jump 0.8s ease-out;
}

@keyframes jump {
    0% { bottom: 30%; } 
    50% { bottom: calc(30% + 300px) } 
    100% { bottom: 30%; }
}

/* Controles táctiles para móviles */
#mobile-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 150px;
    display: none; /* Oculto por defecto, se activa en móviles */
    z-index: 50;
    pointer-events: none; /* Permite clics a través de los controles */
}

.touch-zone {
    position: absolute;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto; /* Permite clics en las zonas táctiles */
    opacity: 0.7;
    transition: opacity 0.3s, transform 0.2s;
}

.touch-zone:active {
    opacity: 0.9;
    transform: scale(0.98);
}

.left-touch-zone {
    left: 0;
    width: 50%;
    background: linear-gradient(to right, rgba(76, 175, 80, 0.3), rgba(76, 175, 80, 0.1));
    border-right: 2px solid rgba(139, 195, 74, 0.5);
}

.right-touch-zone {
    right: 0;
    width: 50%;
    background: linear-gradient(to left, rgba(33, 150, 243, 0.3), rgba(33, 150, 243, 0.1));
    border-left: 2px solid rgba(3, 169, 244, 0.5);
}

.touch-label {
    font-size: 24px;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
}

/* Estilos para cuando no se encuentran las imágenes */
.image-error {
    border: 2px dashed red;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: bold;
    text-align: center;
}

#player.image-error::after {
    content: "img/sydney-moto.png";
    font-size: 14px;
}

.obstacle.image-error::after {
    content: "img/troopers.png";
    font-size: 14px;
}

#background.image-error::after {
    content: "img/bg-game.jpg";
    font-size: 24px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Media queries para dispositivos móviles */
@media (max-width: 768px) {
    .message {
        font-size: 39px;
    }
    
    .start-message {
        font-size: 45px;
    }
    
    .instructions-content {
        padding: 20px;
        max-height: 70vh;
    }
    
    .instructions-content h2 {
        font-size: 24px;
    }
    
    .instruction-section h3 {
        font-size: 20px;
    }
    
    .instruction-section p {
        font-size: 16px;
    }
    
    .start-btn {
        font-size: 24px;
        padding: 15px 40px;
    }
    
    /* Para móvil - Reducir tamaño a 50% y ajustar posición */
    #player {
        width: 100px; /* Reducido a 50% de 200px */
        height: 105px; /* Reducido a 50% de 210px */
        left: 30px; /* Más a la izquierda */
        bottom: 30vh; /* 20% del alto de la ventana */
    }
    
    .obstacle {
        width: 90px; /* Reducido a 50% de 180px */
        height: 90px; /* Reducido a 50% de 180px */
        bottom: 30vh; /* 20% del alto de la ventana */
    }
    
    /* Ajustar animación de salto para móvil */
    @keyframes jump {
        0% { bottom: 30vh; }
        50% { bottom: calc(30vh + 100px); } /* Salto más bajo */
        100% { bottom: 30vh; }
    }
    
    #score {
        font-size: 20px; /* Reducido para móvil */
        padding: 6px 12px;
        left: 10px; /* Más a la izquierda */
    }
    
    /* Ajustar controles táctiles para móvil */
    #mobile-controls {
        height: 120px;
    }
    
    .touch-zone {
        height: 120px;
    }
    
    .touch-label {
        font-size: 18px; /* Reducido para móvil */
        padding: 8px 16px;
    }
}

/* Para dispositivos muy pequeños */
@media (max-width: 480px) {
    .message {
        font-size: 30px;
    }
    
    .start-message {
        font-size: 35px;
    }
    
    .instructions-content {
        padding: 15px;
    }
    
    .instructions-content h2 {
        font-size: 20px;
    }
    
    .instruction-section h3 {
        font-size: 18px;
    }
    
    .instruction-section p {
        font-size: 14px;
    }
    
    .start-btn {
        font-size: 20px;
        padding: 12px 30px;
    }
    
    /* Ajustes adicionales para pantallas muy pequeñas */
    #player {
        width: 90px; /* Un poco más pequeño */
        height: 95px;
        left: 20px; /* Aún más a la izquierda */
        bottom: 30vh; /* ← AÑADIR ESTA LÍNEA */
    }
    
    .obstacle {
        width: 80px;
        height: 80px;
        bottom: 30vh; /* ← AÑADIR ESTA LÍNEA */
    }
    
    #score {
        font-size: 18px;
        padding: 5px 10px;
    }
}

/* Para PC - ajustar animación de salto */
@media (min-width: 769px) {
    /* Mantener posición original para PC */
    #player {
        bottom: 30%;
        left: 50px; /* Movido más a la izquierda también en PC */
    }
    
    .obstacle {
        bottom: 30%;
    }
    
    @keyframes jump {
        0% { bottom: 30%; }
        50% { bottom: calc(30% + 300px); }
        100% { bottom: 30%; }
    }
}