* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height para móviles */
    overflow: hidden;
    touch-action: none;
}

#start-screen {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 40px 20px;
}

#game-logo {
    width: 100%;
    max-width: 500px;
    height: auto;
    object-fit: contain;
    margin: 0 auto;
}

#instructions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

#game-container {
    position: relative;
    max-width: 800px;
    width: 100%;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height para móviles */
    background: #2a2a2a;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

#game-header {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    padding: 15px 20px;
    display: flex;
    justify-content: space-around;
    color: white;
    font-weight: bold;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.stat {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
}

.stat-label {
    font-size: 20px;
}

#game-canvas {
    flex: 1;
    background: #3a3a3a;
    display: block;
    touch-action: none;
}

/* Pantallas de juego */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 100;
    padding: 20px;
    text-align: center;
}

.screen.hidden {
    display: none !important;
}

.screen h1 {
    font-size: 2.5em;
    margin-bottom: 20px;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.screen h2 {
    font-size: 2em;
    margin-bottom: 20px;
    color: #ffd700;
}

.screen p {
    font-size: 1.2em;
    margin: 10px 0;
    line-height: 1.6;
}

.game-btn {
    margin-top: 30px;
    padding: 15px 40px;
    font-size: 1.3em;
    font-weight: bold;
    color: white;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(245, 87, 108, 0.4);
    transition: all 0.3s ease;
    text-transform: uppercase;
}

.game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 20px rgba(245, 87, 108, 0.6);
}

.game-btn:active {
    transform: translateY(0);
}

/* Barra de carga */
.loading-bar-container {
    width: 80%;
    max-width: 400px;
    height: 30px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    overflow: hidden;
    margin: 30px auto;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.loading-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4CAF50 0%, #8BC34A 100%);
    transition: width 0.3s ease;
    border-radius: 15px;
}

/* Joystick virtual */
#joystick-container {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 50;
    touch-action: none;
    display: block;  /* Visible por defecto (para tablets y móviles) */
}

/* Ocultar joystick solo en desktop (dispositivos con mouse preciso) */
@media (hover: hover) and (pointer: fine) {
    #joystick-container {
        display: none;
    }
}

#joystick-base {
    width: 160px;
    height: 160px;
    background: rgba(255, 255, 255, 0.25);
    border: 4px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    position: relative;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
}

#joystick-stick {
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 4px solid white;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    transition: all 0.1s ease;
}

/* Responsive */
@media (max-width: 600px) {
    #game-header {
        padding: 10px 15px;
    }
    
    .stat {
        font-size: 16px;
    }
    
    .stat-label {
        font-size: 18px;
    }
    
    .screen h1 {
        font-size: 2em;
    }
    
    .screen h2 {
        font-size: 1.6em;
    }
    
    .screen p {
        font-size: 1em;
    }
    
    .game-btn {
        padding: 12px 30px;
        font-size: 1.1em;
    }

    #joystick-container {
        bottom: 20px;
        left: 20px;
    }

    #joystick-base {
        width: 140px;
        height: 140px;
    }

    #joystick-stick {
        width: 55px;
        height: 55px;
    }
}

/* iPhone específico y pantallas pequeñas */
@media (max-width: 428px) and (max-height: 926px) {
    #joystick-container {
        bottom: 20px;
        left: 20px;
    }

    #joystick-base {
        width: 130px;
        height: 130px;
    }

    #joystick-stick {
        width: 52px;
        height: 52px;
    }
}

/* iPhone SE y pantallas muy pequeñas */
@media (max-width: 375px) {
    #joystick-container {
        bottom: 20px;
        left: 20px;
    }

    #joystick-base {
        width: 120px;
        height: 120px;
    }

    #joystick-stick {
        width: 48px;
        height: 48px;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    .screen h1 {
        font-size: 1.5em;
        margin-bottom: 10px;
    }
    
    .screen p {
        font-size: 0.9em;
        margin: 5px 0;
    }
    
    .game-btn {
        margin-top: 15px;
        padding: 10px 25px;
        font-size: 1em;
    }

    /* Joystick en landscape a la izquierda */
    #joystick-container {
        bottom: 20px;
        left: 20px;
        transform: none;
    }

    #joystick-base {
        width: 110px;
        height: 110px;
    }

    #joystick-stick {
        width: 44px;
        height: 44px;
    }
}
