html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
    overscroll-behavior: none; /* Empêche le rebond sur mobile */
    touch-action: none; /* Désactive le zoom et scroll tactile */
    font-family: 'Orbitron', sans-serif;
}

body {
    padding-top: 0 !important;
}

/* Zone du Joystick (Cercle extérieur) */
#joystick-zone {
    position: absolute;
    bottom: 30px;
    left: 30px;
    width: 130px;
    height: 130px;
    background: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    touch-action: none;
    display: none; /* Caché par défaut, affiché en JS si touch detecté ou tout le temps */
    z-index: 5;
    transition: all 0.2s;
}

#joystick-zone.active {
    background: rgba(0, 100, 255, 0.2);
    border-color: rgba(0, 150, 255, 0.7);
    box-shadow: 0 0 20px rgba(0, 100, 255, 0.5);
}

/* Le bouton du Joystick (Cercle intérieur) */
#joystick-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 70px;
    height: 70px;
    background: rgba(0, 100, 255, 0.6);
    border: 2px solid rgba(0, 150, 255, 0.8);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none; /* Laisse passer les clics au travers */
    box-shadow: 0 0 15px rgba(0, 100, 255, 0.9);
}

#joystick-zone-right {
    position: absolute;
    bottom: 30px;
    right: 30px; /* À droite */
    width: 130px;
    height: 130px;
    background: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 0, 0, 0.4); /* Bordure un peu rouge pour différencier le tir */
    border-radius: 50%;
    touch-action: none;
    display: none; 
    z-index: 5;
    transition: all 0.2s;
}

#joystick-zone-right.active {
    background: rgba(255, 50, 50, 0.2);
    border-color: rgba(255, 50, 50, 0.7);
    box-shadow: 0 0 20px rgba(255, 50, 50, 0.5);
}

#joystick-knob-right {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 70px;
    height: 70px;
    background: rgba(255, 50, 50, 0.6); /* Bouton rouge pour le tir */
    border: 2px solid rgba(255, 100, 100, 0.8);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: 0 0 15px rgba(255, 50, 50, 0.9);
}

@media (max-width: 1024px) {
    #joystick-zone, #joystick-zone-right {
        display: block; 
    }
}

/* Ajustements supplémentaires pour petits écrans */
@media (max-width: 480px) {
    #joystick-zone, #joystick-zone-right {
        width: 110px;
        height: 110px;
        bottom: 15px;
    }
    
    #joystick-zone {
        left: 15px;
    }
    
    #joystick-zone-right {
        right: 15px;
    }
    
    #joystick-knob, #joystick-knob-right {
        width: 55px;
        height: 55px;
    }
}

/* Labels pour les joysticks */
#joystick-zone::after {
    content: 'Déplacement';
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
    font-family: 'Orbitron', sans-serif;
    white-space: nowrap;
    pointer-events: none;
}

#joystick-zone-right::after {
    content: 'Tir';
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
    font-family: 'Orbitron', sans-serif;
    white-space: nowrap;
    pointer-events: none;
}

/* Bouton Dash pour Mobile */
.dash-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(0, 86, 179, 0.7);
    border: 3px solid rgba(0, 170, 255, 0.9);
    color: rgba(200, 240, 255, 1);
    cursor: pointer;
    z-index: 6;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(0, 170, 255, 0.8);
    transition: all 0.2s;
    overflow: visible;
}

.dash-button:active {
    transform: scale(0.9);
    box-shadow: 0 0 30px rgba(0, 170, 255, 1);
}

.dash-button.available {
    display: flex;
}

.dash-button.available:active {
    animation: none;
}

.dash-button.cooldown {
    display: flex;
    opacity: 0.5;
    cursor: not-allowed;
    color: rgba(100, 100, 100, 0.5);
}

.dash-arrows {
    width: 50%;
    height: 50%;
    z-index: 2;
    pointer-events: none;
}

.dash-cooldown-ring {
    position: absolute;
    width: 125%;
    height: 125%;
    border-radius: 50%;
    border: 0;
    background: conic-gradient(
        rgba(0, 170, 255, 1) 0deg,
        rgba(0, 170, 255, 1) var(--cooldown-angle, 0deg),
        rgba(40, 40, 40, 0.15) var(--cooldown-angle, 0deg),
        rgba(40, 40, 40, 0.15) 360deg
    );
    pointer-events: none;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    clip-path: circle(68% / 68%);
}

@keyframes pulse-dash {
    0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(0, 170, 255, 0.8); }
    50% { transform: scale(1.05); box-shadow: 0 0 30px rgba(0, 170, 255, 1); }
}

@media (max-width: 768px) {
    .dash-button {
        width: 70px;
        height: 70px;
        bottom: 180px; /* Plus haut pour éviter le joystick droit */
        right: 30px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .dash-button {
        width: 60px;
        height: 60px;
        bottom: 175px; /* Plus haut pour éviter le joystick droit */
        right: 15px;
        font-size: 11px;
    }
}


#gameCanvas {
    display: block;
    width: 100vw;
    height: 100vh;
}

#modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10; 
}

#modal-background-canvas {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    z-index: 1 !important;
    pointer-events: none !important;
}

#modal-content {
    background-color: #222;
    padding: 35px;
    border-radius: 15px;
    text-align: center;
    color: white;
    border: 2px solid blue;
    width: 350px;
    z-index: 2;
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
}

@media (min-width: 1024px) {
    #modal-content {
        width: 350px;
        padding: 35px;
    }
}

#coop-panel-wrapper {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

#coop-panel-btn {
    border: 1px solid rgba(255, 255, 255, 0.5);
    background: rgba(20, 20, 20, 0.8);
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    border-radius: 0 0 16px 16px;
    height: 40px;
    min-width: 132px;
    padding: 0 18px;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
    border-top: none;
    margin-top: 0;
}

#coop-panel-btn:hover {
    transform: scale(1.04);
    background: rgba(0, 86, 179, 0.85);
    border-color: rgba(0, 170, 255, 0.9);
}

#coop-panel {
    display: block;
    width: 180px;
    padding: 0 12px;
    background: rgba(20, 20, 20, 0.93);
    border-left: 1px solid rgba(255, 255, 255, 0);
    border-right: 1px solid rgba(255, 255, 255, 0);
    border-bottom: 1px solid rgba(255, 255, 255, 0);
    border-top: none;
    border-radius: 0 0 10px 10px;
    color: #fff;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transform: translateY(-14px);
    pointer-events: none;
    transition: max-height 0.55s ease-in-out, opacity 0.55s ease-in-out, transform 0.55s ease-in-out;
}

#coop-panel.open {
    max-height: 180px;
    padding: 12px;
    border-left-color: rgba(255, 255, 255, 0.25);
    border-right-color: rgba(255, 255, 255, 0.25);
    border-bottom-color: rgba(255, 255, 255, 0.25);
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#coop-enabled-toggle {
    width: 18px;
    height: 18px;
    accent-color: #00aaff;
    cursor: pointer;
}

.coop-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 6px 0;
    font-size: 11px;
    letter-spacing: 0.4px;
    font-family: 'Orbitron', sans-serif;
    text-transform: uppercase;
}

#coop-player-count {
    background: rgba(20, 20, 20, 0.95);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 11px;
    font-family: 'Orbitron', sans-serif;
    cursor: pointer;
}

@media (max-width: 768px) {
    #modal-content {
        padding: 25px;
        width: calc(85vw - 50px);
        max-height: 85vh;
        margin: 0 auto;
    }
    
    #modal-content h1 {
        font-size: 22px !important;
        margin-bottom: 10px !important;
    }
    
    #modal-content p {
        font-size: 12px !important;
    }
    
    .mode-options {
        gap: 8px !important;
        max-width: 100%;
    }
    
    .mode-btn span {
        padding: 12px 16px !important;
        font-size: 14px !important;
        min-width: 70px !important;
    }
    
    #start-btn {
        padding: 12px 20px !important;
        font-size: 16px !important;
    }
    
    #leaderboard-btn, #bestiary-btn {
        font-size: 12px !important;
        height: 45px !important;
    }
}

#modal-content h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    font-weight: 900;
    letter-spacing: 1px;
    margin-bottom: 15px;
}

#modal-content p {
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

#settings-btn {
    position: fixed;
    left: 16px;
    bottom: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.5);
    background: rgba(20, 20, 20, 0.8);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    z-index: 9999;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

#changelog-btn {
    position: fixed;
    left: 64px;
    bottom: 16px;
    height: 40px;
    padding: 0 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    background: rgba(20, 20, 20, 0.8);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    font-family: 'Orbitron', sans-serif;
    line-height: 1;
    cursor: pointer;
    z-index: 9999;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

#settings-btn:hover {
    transform: rotate(20deg) scale(1.06);
    background: rgba(0, 86, 179, 0.85);
    border-color: rgba(0, 170, 255, 0.9);
}

#changelog-btn:hover {
    transform: scale(1.04);
    background: rgba(0, 86, 179, 0.85);
    border-color: rgba(0, 170, 255, 0.9);
}

#settings-panel {
    position: fixed;
    left: 16px;
    bottom: 64px;
    width: 230px;
    padding: 12px;
    background: rgba(20, 20, 20, 0.93);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    color: #fff;
    z-index: 9999;
    display: none;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

#settings-panel.open {
    display: block;
}

#changelog-panel {
    position: fixed;
    left: 64px;
    bottom: 64px;
    width: 300px;
    max-height: 360px;
    padding: 12px;
    background: rgba(12, 12, 12, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 10px;
    color: #fff;
    z-index: 9999;
    display: none;
    overflow-y: auto;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

#changelog-panel.open {
    display: block;
}

#settings-panel h3 {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}

#changelog-panel h3 {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 8px 0 4px;
    font-size: 11px;
    letter-spacing: 0.4px;
}

.settings-toggle {
    margin-top: 12px;
    margin-bottom: 2px;
}

#trail-mode-select {
    background: rgba(20, 20, 20, 0.95);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 11px;
    font-family: 'Orbitron', sans-serif;
    cursor: pointer;
}

#cheat-mode-toggle {
    width: 18px;
    height: 18px;
    accent-color: #ff7a00;
    cursor: pointer;
}

#settings-panel input[type="range"] {
    width: 100%;
    accent-color: #00aaff;
}

.changelog-entry {
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.changelog-entry:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.changelog-version {
    margin: 0 0 4px;
    font-size: 12px;
    font-weight: 700;
    color: #4fc3ff;
}

.changelog-date {
    margin: 0 0 6px;
    font-size: 10px;
    opacity: 0.7;
}

.changelog-items {
    margin: 0;
    padding-left: 16px;
    font-size: 11px;
    line-height: 1.45;
}

.changelog-empty {
    margin: 0;
    font-size: 11px;
    opacity: 0.8;
}

@media (max-width: 768px) {
    #settings-btn {
        width: 36px;
        height: 36px;
        font-size: 20px;
        left: 10px;
        bottom: 10px;
    }

    #changelog-btn {
        left: 54px;
        bottom: 10px;
        height: 36px;
        padding: 0 10px;
        font-size: 10px;
    }

    #settings-panel {
        left: 10px;
        bottom: 52px;
        width: 200px;
        padding: 10px;
    }

    #changelog-panel {
        left: 54px;
        bottom: 52px;
        width: 220px;
        max-height: 220px;
        padding: 10px;
    }
}

#player-name {
    width: 100%;
    padding: 10px 14px;
    margin-bottom: 12px;
    background-color: rgba(60, 60, 60, 0.7);
    border: 1px solid rgba(150, 150, 150, 0.5);
    border-radius: 6px;
    color: white;
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.5s ease-in-out;
    box-sizing: border-box;
}

#player-name::placeholder {
    color: rgba(200, 200, 200, 0.7);
}

.mode-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    justify-items: stretch;
}

@media (min-width: 1024px) {
    .mode-options {
        max-width: 280px;
        margin: 0 auto;
        gap: 8px;
    }
}

.mode-options input[type="radio"] {
    display: none;
}

.mode-btn {
    display: flex;
    justify-content: center;
}

.mode-btn span {
    display: inline-block;
    padding: 20px 24px;
    background: #333;
    color: #aaa;
    border: 2px solid #555;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 700;
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    letter-spacing: 0.5px;
    min-width: 100px;
    text-align: center;
    flex: 1;
    max-width: 150px;
}

@media (min-width: 1024px) {
    .mode-btn span {
        padding: 8px 10px;
        font-size: 11px;
        min-width: 60px;
    }
}

.mode-btn:hover span {
    background: #444;
    border-color: #888;
    color: white;
}

.mode-options input[type="radio"]:checked + span {
    background: #0056b3; 
    border-color: #00aaff;
    box-shadow: 0 0 15px rgb(8, 110, 174);
    color: white;
    transform: scale(1.02);
}

.mode-options input[type="radio"][value="speeder"]:checked + span {
    background: #0d4d06;
    border-color: #1eff00;
    box-shadow: 0 0 15px rgb(22, 174, 8);
}

.mode-options input[type="radio"][value="architect"]:checked + span {
    background: #aa9a0e;
    border-color: #cbeb15;
    box-shadow: 0 0 15px rgb(238, 235, 12);
}

.mode-options input[type="radio"][value="boss"]:checked + span {
    background: #5a0000;
    border-color: #ff0000;
    box-shadow: 0 0 15px red;
}

/* Version PC: boutons modes taille normale */
@media (min-width: 1024px) {
    .mode-options {
        max-width: 240px;
        margin: 0 auto;
        gap: 10px;
    }
    
    .mode-btn span {
        padding: 10px 12px;
        font-size: 13px;
        min-width: 70px;
    }
}

#start-btn {
    padding: 15px 30px;
    font-size: 18px;
    font-weight: 700;
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 1px;
    background-color: blue;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 16px;
}

#leaderboard-btn {
    color: rgb(253, 253, 253) !important;
    font-size: 20px;
}

body{
    overflow: hidden;
    background-color: black;
}

#score-value, #score-board, #wave-board, #wave-value, #bestiary-btn{
    color: white !important;
    font-size: large;
}

#ui-container {
    position: absolute; 
    top: 10px;
    left: 10px;
    pointer-events: none; 
    border: solid white 1px;
    width: 9vw;
    border-radius: 2px;
    display: block;
}

#modal:not([style*="display: none"]) ~ #ui-container {
    display: none;
}

body:not(.game-active) #ui-container {
    display: none !important;
}

@media (max-width: 768px) {
    #ui-container {
        width: 30vw;
        top: 10px;
        left: 10px;
        transform: none;
        z-index: 98;
    }
}

@media (min-width: 769px) and (max-width: 1200px) {
    /* Sur tablette : position en haut à gauche */
    #ui-container {
        top: 10px;
        left: 10px;
        transform: none;
        width: 20vw;
        min-width: 150px;
        z-index: 98;
    }
}

.helmet {
    position: absolute;
    width: 40px;  
    height: 40px;
    background-image: url('img/helmet.png'); 
    background-size: contain;
    background-repeat: no-repeat;
    transform: translate(-50%, -130%); 
    transition: transform 0.1s linear; 
}

.helmet_b {
    position: absolute;
    width: 65px;  
    height: 80px;
    background-image: url('img/helmet.png');
    background-size: contain;
    background-repeat: no-repeat;
    transform: translate(-49%, -100%); 
    pointer-events: none;
    z-index: 5;
}

#champ{
    display: flex;
    flex-direction: column;
}

#score-list li {
    background: rgba(255, 255, 255, 0.1);
    padding: 8px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
}

#game-mode:focus {
    outline: none;
    border-color: gold;
}

h1{
    margin-top: 0;
}

/* --- STYLE DU BESTIAIRE --- */

.bestiary-item {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.05);
    padding: 10px;
    border-radius: 8px;
    gap: 15px;
    transition: background 0.3s;
}
.bestiary-item:hover {
    background: rgba(255,255,255,0.1);
}

.enemy-preview {
    position: relative;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.enemy-circle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    box-sizing: border-box; 
}

.preview-orbite-orb {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #FFD700;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    animation: orbit-preview 2s linear infinite;
}

.preview-helmet {
    position: absolute;
    width: 30px;
    height: 30px;
    background-image: url('img/helmet.png');
    background-size: contain;
    background-repeat: no-repeat;
    top: -5px; 
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}
.preview-helmet-boss {
    width: 40px;
    height: 60px;
    top: -15px;
}

.helmet-royale {
    position: absolute;
    width: 80px; 
    height: 80px;
    background-image: url('img/crown.png');
    background-size: contain;
    background-repeat: no-repeat;
    pointer-events: none;
    z-index: 10;
    transform: translate(-49%, -110%); 
}

.preview-crown-royale {
    position: absolute;
    width: 40px;
    height: 40px;
    background-image: url('img/crown.png');
    background-size: contain;
    background-repeat: no-repeat;
    top: -20px; 
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

.boss-aura {
    position: absolute;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,0,0,0.4) 0%, transparent 70%);
    animation: aura-oscillation 4s infinite ease-in-out;
    z-index: -1;
}

.boss-eye {
    position: absolute;
    width: 12px;
    height: 12px;
    background-color: red;
    border-radius: 50%;
    box-shadow: 0 0 10px red;
    animation: eye-blink 3.6s infinite;
}

@keyframes aura-oscillation {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.3); opacity: 0.3; }
}

@keyframes eye-blink {
    0%, 100% { background-color: red; box-shadow: 0 0 10px red; }
    50% { background-color: white; box-shadow: 0 0 15px white; }
}

@keyframes pulse { 0% { transform: scale(0.8); } 50% { transform: scale(1); } 100% { transform: scale(0.8); } }
@keyframes shake { 0% { transform: translateX(0); } 25% { transform: translateX(-2px); } 75% { transform: translateX(2px); } 100% { transform: translateX(0); } }
@keyframes orbit-preview { from { transform: translate(-50%, -50%) rotate(0deg) translateX(18px); } to { transform: translate(-50%, -50%) rotate(360deg) translateX(18px); } }
@keyframes boom-flicker { 0% { background-color: #FF0000; } 50% { background-color: #000000; } 100% { background-color: #FF0000; } }

.anim-pulse { animation: pulse 8s infinite; }
.anim-shake { animation: shake 0.5s infinite; }
.anim-boom-flicker { animation: boom-flicker 0.2s infinite; }

#size-warning {
    display: none; 
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: black;
    color: white;
    z-index: 10001; 
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

#size-warning h1 {
    font-size: 4rem;
    color: red;
    text-transform: uppercase;
}

#size-warning h2 {
    font-size: 1.5rem;
    color: rgb(255, 72, 72);
    text-transform: uppercase;
}

.boss-eye-preview {
    width: 50px;
    height: 50px;
    background: radial-gradient(circle at 30% 30%, #4B0082, #2a004a);
    border-radius: 50%;
    position: relative;
    box-shadow: 0 0 15px rgba(75, 0, 130, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid rgba(255, 255, 255, 0.5);
    animation: boss-float 3s ease-in-out infinite;
}

.boss-sclera {
    width: 30px;
    height: 30px;
    background: #fff;
    border-radius: 50%;
    position: relative;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.5);
    overflow: hidden; 
}

.boss-iris {
    width: 18px;
    height: 18px;
    background: radial-gradient(circle, #ff5e5e 0%, #ff0000 50%, #520000 100%);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: iris-look 4s infinite; 
}

.boss-pupil {
    width: 4px;
    height: 12px;
    background: black;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    animation: pupil-pulse 2s infinite;
}

/* Animations CSS */
@keyframes boss-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@keyframes iris-look {
    0%, 100% { transform: translate(-50%, -50%); }
    25% { transform: translate(-80%, -50%); } 
    75% { transform: translate(-20%, -50%); } 
}

@keyframes pupil-pulse {
    0%, 100% { height: 12px; width: 4px; }
    50% { height: 10px; width: 6px; }
}

/* --- MODE PANEL --- */
#mode-panel {
    position: absolute;
    top: 10vh;
    right: 2vw;
    width: 25vw;
    min-width: 280px;
    max-width: 400px;
    max-height: 80vh;
    background-color: #2a2a2a;
    border: 2px solid #0056b3; 
    border-radius: 10px;
    padding: 0; 
    color: white;
    font-size: clamp(12px, 1vw, 14px);
    z-index: 100;
    box-shadow: 0 0 20px rgba(0, 86, 179, 0.4);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

@media (min-width: 1201px) {
    /* Sur PC les panneaux sont toujours visibles */
    #mode-panel, #user-panel {
        display: flex !important;
        position: absolute !important;
    }
    
    /* Les boutons toggle ne sont jamais visibles sur PC */
    .mobile-toggle-btn {
        display: none !important;
    }
}

/* Quand le jeu est actif, tout cacher */
body.game-active #mode-panel,
body.game-active #user-panel,
body.game-active #coop-panel-wrapper {
    display: none !important;
}

body.game-active .mobile-toggle-btn,
body.game-active .mobile-panel-overlay {
    display: none !important;
}

#mode-panel.normal-mode {
    border-color: #0056b3;
    box-shadow: 0 0 20px rgba(0, 86, 179, 0.4);
}

#mode-panel.speeder-mode {
    border-color: #1eff00;
    box-shadow: 0 0 15px rgba(30, 255, 0, 0.4);
}

#mode-panel.architect-mode {
    border-color: #cbeb15;
    box-shadow: 0 0 15px rgba(203, 235, 21, 0.4);
}

#mode-panel.boss-mode {
    border-color: #ff0000;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.4);
}

.mode-hero {
    width: 100%;
    /* Changement Ratio : On retire la hauteur fixe pour un ratio 16:9 (large mais haut) */
    height: auto;
    aspect-ratio: 16/9;
    background-size: cover;
    background-position: center;
    margin: 0; 
    /* Suppression de la barre bleue en bas de l'image */
    border-bottom: none;
    flex-shrink: 0;
    border-radius: 8px;
}

/* Images pour chaque mode */
#mode-hero-image.mode-normal {
    background-image: url('img/mode1.png');
}

#mode-hero-image.mode-speeder {
    background-image: url('img/mode2.png');
}

#mode-hero-image.mode-architect {
    background-image: url('img/mode3.png');
}

#mode-hero-image.mode-boss {
    background-image: url('img/mode4.png');
}

#mode-content h2 {
    margin: 0 0 10px 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-family: 'Orbitron', sans-serif;
}

#mode-content p {
    margin: 0 0 15px 0;
    font-size: 12px;
    line-height: 1.5;
    color: #ddd;
}

#mode-content hr {
    border: none;
    border-top: 1px solid #666;
    margin: 12px 0;
}

#mode-stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 10px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    padding: 8px 0;
    border-bottom: 1px solid #555;
}

.stat-label {
    font-weight: 600;
    color: #bbb;
}

.stat-value {
    color: white;
    font-weight: 700;
    font-size: 14px;
}

@media (max-width: 1200px) {
    #mode-panel {
        /* Sur tablette/mobile : panneau en slide-in depuis la droite */
        position: fixed;
        top: 0;
        right: -100%;
        width: 85vw;
        max-width: 350px;
        height: 100vh;
        max-height: 100vh;
        z-index: 200;
        transition: right 0.3s ease-in-out;
        border-radius: 0;
        border-left: 3px solid #0056b3;
        border-right: none;
        border-top: none;
        border-bottom: none;
        overflow-y: auto;
        padding: 15px;
        font-size: 12px;
    }
    
    #mode-panel.visible {
        right: 0;
    }
    
    .mode-hero {
        /* Adaptation pour écran plus petits mais en gardant le ratio */
        height: auto;
        aspect-ratio: 16/9;
        margin-bottom: 12px;
    }
    
    #mode-content h2 {
        font-size: 18px;
    }
    
    #mode-content p {
        font-size: 11px;
    }
    
    .stat-row {
        font-size: 12px;
    }
}

#mode-content, #auth-section, #profile-section {
    padding: 1.5rem;
}

/* Boutons toggle mobiles */
.mobile-toggle-btn {
    position: fixed;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(0, 86, 179, 0.9);
    border: 2px solid #00aaff;
    color: white;
    font-size: 24px;
    cursor: pointer;
    z-index: 99;
    display: none; /* Caché par défaut */
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(0, 170, 255, 0.5);
    transition: all 0.3s;
    pointer-events: auto;
}

.mobile-toggle-btn:active {
    transform: scale(0.95);
    background: rgba(0, 120, 200, 0.9);
}

.mobile-toggle-btn.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

#toggle-user-panel {
    top: 10px;
    left: 10px;
}

#toggle-mode-panel {
    top: 10px;
    right: 10px;
}

@media (max-width: 1200px) {
    .mobile-toggle-btn {
        display: flex !important;
    }
}

@media (min-width: 1201px) {
    .mobile-toggle-btn {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .mobile-toggle-btn {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
    
    #toggle-user-panel {
        top: 8px;
        left: 8px;
    }
    
    #toggle-mode-panel {
        top: 8px;
        right: 8px;
    }
}

#user-panel {
    position: absolute;
    top: 10vh;
    left: 2vw;
    width: 25vw;
    min-width: 280px;
    max-width: 400px;
    max-height: 80vh;
    background-color: #2a2a2a;
    border: 2px solid #0056b3; 
    border-radius: 10px;
    padding: 0;
    color: white;
    font-size: clamp(12px, 1vw, 14px);
    z-index: 100;
    box-shadow: 0 0 20px rgba(0, 86, 179, 0.4);
    
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

#auth-section input {
    width: 100%;
    margin-bottom: 10px;
    padding: 10px;
    background: #444;
    border: 1px solid #666;
    color: white;
    border-radius: 4px;
    box-sizing: border-box; 
}

.auth-btns {
    display: flex;
    gap: 10px;
}

.auth-btns button, #btn-logout {
    background: #0056b3;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    transition: background 0.2s;
}

.auth-btns button:hover {
    background: #0077ff;
}

#auth-msg {
    color: red;
    font-size: 12px;
    margin-top: 5px;
    text-align: center;
}

.xp-container {
    width: 100%;
    margin-bottom: 15px;
    text-align: center;
}

.xp-bar-bg {
    width: 100%;
    height: 20px;
    background-color: #444;
    border: 2px solid #666;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    margin-top: 5px;
}

.xp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #0056b3, #00aaff);
    width: 0%;
    transition: width 0.5s ease-out;
}

.xp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px black;
    z-index: 2;
}

.skin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(55px, 1fr)); 
    gap: 8px;
    margin-bottom: 10px;
}

.skin-btn {
    aspect-ratio: 1 / 1;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid #444;
    background: #1e1e1e;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px;
}

.skin-btn:hover {
    border-color: #00aaff;
    background: #252525;
}

#mode-panel::-webkit-scrollbar, #user-panel::-webkit-scrollbar {
    width: 6px;
}
#mode-panel::-webkit-scrollbar-thumb, #user-panel::-webkit-scrollbar-thumb {
    background: #0056b3;
    border-radius: 10px;
}

.shop-section-title {
    font-size: 0.8em;
    color: #00aaff;
    margin-top: 15px;
    margin-bottom: 8px;
    text-transform: uppercase;
    font-weight: bold;
}

@media (max-width: 1200px) {
    #user-panel {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85vw;
        max-width: 350px;
        height: 100vh;
        max-height: 100vh;
        z-index: 200;
        transition: left 0.3s ease-in-out;
        border-radius: 0;
        border-right: 3px solid #0056b3;
        border-left: none;
        border-top: none;
        border-bottom: none;
        overflow-y: auto;
    }
    
    #user-panel.visible {
        left: 0;
    }
    
    #user-panel #auth-section,
    #user-panel #profile-section {
        padding: 1rem !important;
    }
    
    #user-panel .skin-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)) !important;
        gap: 6px !important;
    }
}

.skin-btn.skin-selected {
    box-shadow: 0 0 12px white !important;
    border: 2px solid gold !important;
    background: #2a2a2a !important;
}

.skin-btn.skin-selected:hover {
    box-shadow: 0 0 15px white !important;
    border: 2px solid gold !important;
}
/* Amélioration responsive pour bestiaire et crédits */
@media (max-width: 768px) {
    #bestiary-modal > div {
        width: 90% !important;
        max-width: none !important;
        padding: 15px !important;
        max-height: 85vh !important;
    }
    
    #credits {
        bottom: 70px !important;
        right: 10px !important;
        font-size: 9px !important;
    }
    
    #credits p {
        font-size: 10px !important;
    }
    
    .lb-tab {
        font-size: 11px !important;
        padding: 4px !important;
    }
    
    #score-list {
        max-height: 200px !important;
        font-size: 12px !important;
    }
    
    #leaderboard-display h3 {
        font-size: 18px !important;
    }
    
    .bestiary-item {
        padding: 8px !important;
        gap: 10px !important;
    }
}

/* Overlay de fond pour panneaux mobiles */
.mobile-panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 150;
    display: none;
    pointer-events: none;
}

.mobile-panel-overlay.visible {
    display: block;
    pointer-events: auto;
}

@media (min-width: 1201px) {
    /* Sur PC, l'overlay n'est jamais affiché */
    .mobile-panel-overlay {
        display: none !important;
        pointer-events: none !important;
    }
}

/* Amélioration de la zone tactile des boutons sur mobile */
@media (max-width: 768px) {
    button, .mode-btn {
        min-height: 44px; /* Taille recommandée pour touch targets */
        touch-action: manipulation; /* Évite le double-tap zoom */
    }
}