html, body {
    overflow: hidden;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    touch-action: none;
    position: fixed;
}

#renderCanvas {
    width: 100%;
    height: 100%;
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 0; /* S'assurer que le canvas est en arrière-plan */
}

/* Contrôles tactiles - masqués par défaut */
.touch-controls {
    display: none; /* Masqué par défaut */
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 1000;
    touch-action: none;
}

/* Afficher uniquement sur mobile en mode paysage */
@media screen and (max-width: 1024px) and (orientation: landscape) {
    .touch-controls {
        display: block;
    }
}

/* Styles pour le panneau de débogage */
#debug-panel {
    position: fixed;
    top: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    padding: 10px;
    border-radius: 5px;
    max-width: 300px;
    z-index: 100;
    backdrop-filter: blur(5px);
    border: 1px solid #444;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    max-height: 90vh;
    overflow-y: auto;
}

#debug-panel h3 {
    margin: 0 0 10px 0;
    padding: 0;
    color: #4CAF50;
    font-size: 14px;
    text-align: center;
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
    margin-bottom: 8px;
}

#debug-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    border-bottom: 1px solid #333;
}

.stat-row:last-child {
    border-bottom: none;
}

#debug-stats span {
    color: #4CAF50;
    font-weight: bold;
    margin-left: 5px;
}

/* Style spécifique pour les valeurs importantes */
#speed { color: #ff9800; }
#acceleration { color: #00bcd4; }
#steering { color: #9c27b0; }
#rpm { color: #f44336; }
#gear { color: #ffeb3b; }
#drift { color: #ff5722; }
#slip { color: #03a9f4; }

/* Avertissement pour le mode portrait */
@media screen and (orientation: portrait) {
    .orientation-warning {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        background-color: rgba(0, 0, 0, 0.9);
        color: white;
        z-index: 2000;
    }
}

/* Cacher l'avertissement en mode paysage */
@media screen and (orientation: landscape) {
    .orientation-warning {
        display: none !important;
    }
}

/* Style du joystick gauche */
.touch-joystick {
    position: absolute;
    width: 120px;
    height: 120px;
    bottom: 50px;
    left: 50px;
    pointer-events: auto;
    touch-action: none;
    z-index: 1001;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.7);
    transition: transform 0.1s, background-color 0.1s;
    -webkit-tap-highlight-color: transparent;
}

/* Effet de pression sur le joystick */
.touch-joystick.active {
    transform: scale(0.95);
    background: rgba(0, 0, 0, 0.6);
    border-color: rgba(255, 255, 255, 0.9);
}

/* Panneau de débogage */
#debug-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 10px;
    border-radius: 5px;
    font-family: Arial, sans-serif;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
}

#debug-panel h3 {
    margin: 0 0 8px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid #444;
}

#debug-stats div {
    margin: 4px 0;
    line-height: 1.3;
}

/* Style des contrôles de droite */
.right-controls {
    position: absolute;
    right: 50px;
    bottom: 60px;
    display: flex;
    flex-direction: column;
    gap: 30px;
    pointer-events: auto;
    z-index: 1001;
    -webkit-tap-highlight-color: transparent;
}

.control-btn {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.6);
    transition: transform 0.1s, background-color 0.1s, border-color 0.1s;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.control-btn:active {
    transform: scale(0.9);
    background: rgba(0, 0, 0, 0.7);
}

/* Style pour l'indicateur du joystick */

/* Style de l'indicateur du joystick */
.touch-indicator {
    position: absolute;
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    transition: transform 0.05s ease-out, background-color 0.1s;
    pointer-events: none;
    opacity: 1 !important;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

/* Effet de mouvement du joystick */
.touch-joystick.active .touch-indicator {
    background: rgba(255, 255, 255, 0.9);
    transform: translate(-50%, -50%) scale(0.9);
}

/* Mode paysage recommandé pour les mobiles */
.orientation-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 2000;
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
}

.orientation-warning.visible {
    display: flex;
}

@media (max-width: 1024px) and (orientation: landscape) {
    .touch-controls {
        display: block;
    }
}

@media (max-width: 768px) {
    .touch-joystick {
        width: 100px;
        height: 100px;
        bottom: 30px;
        left: 30px;
    }
    
    .right-controls {
        right: 30px;
        bottom: 40px;
        gap: 25px;
    }
    
    .control-btn {
        width: 80px;
        height: 80px;
    }
    
    .touch-indicator {
        width: 50px;
        height: 50px;
    }
    
    .orientation-warning.portrait {
        display: flex;
    }
}

/* Styles pour les très petits écrans */
@media (max-width: 400px) {
    .touch-joystick {
        width: 90px;
        height: 90px;
        bottom: 20px;
        left: 20px;
    }
    
    .right-controls {
        right: 20px;
        bottom: 30px;
        gap: 20px;
    }
    
    .control-btn {
        width: 70px;
        height: 70px;
    }
    
    .touch-indicator {
        width: 45px;
        height: 45px;
    }
}
