* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    font-family: 'Arial', sans-serif;
}

:root {
    --ui-scale: 1;
}

@media (max-width: 1024px) {
    :root {
        --ui-scale: 1.2;
    }
}

@media (max-width: 600px) {
    :root {
        --ui-scale: 1.5;
    }
}

#game-container {
    position: relative;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    max-width: 95vw;
    max-height: 90vh;
}

#gameCanvas {
    display: block;
    background: #1a1a2e;
    border: 3px solid #fff;
    max-width: 100%;
    max-height: 100%;
}

#ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Menu de démarrage */
#start-menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #fff;
    pointer-events: all;
}

#start-menu.hidden {
    display: none;
}

#start-menu h1 {
    font-size: calc(12vmin * var(--ui-scale));
    margin-bottom: 2vmin;
    color: #4ecdc4;
    text-shadow: 0.4vmin 0.4vmin 0.8vmin rgba(0, 0, 0, 0.5);
    letter-spacing: 0.3vmin;
}

#start-menu .subtitle {
    font-size: calc(3vmin * var(--ui-scale));
    margin-bottom: 4vmin;
    color: #ccc;
}

#start-btn {
    padding: 2vmin 6vmin;
    font-size: calc(4vmin * var(--ui-scale));
    background: linear-gradient(135deg, #4ecdc4 0%, #44a08d 100%);
    color: #fff;
    border: none;
    border-radius: 1vmin;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 0.5vmin 1.5vmin rgba(78, 205, 196, 0.4);
}

#start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0.8vmin 2vmin rgba(78, 205, 196, 0.6);
}

#start-menu .controls-hint {
    margin-top: 4vmin;
    font-size: calc(2vmin * var(--ui-scale));
    color: #888;
    display: flex;
    justify-content: center;
    gap: 3vmin;
}

#score {
    position: absolute;
    top: 2vmin;
    left: 2vmin;
    color: #fff;
    font-size: 3vmin;
    font-weight: bold;
    text-shadow: 0.2vmin 0.2vmin 0.4vmin rgba(0, 0, 0, 0.5);
}

#score.hidden {
    display: none;
}

#game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 4vmin;
    border-radius: 1.5vmin;
    text-align: center;
    color: #fff;
    pointer-events: all;
}

#game-over.hidden {
    display: none;
}

#game-over h2 {
    font-size: calc(6vmin * var(--ui-scale));
    margin-bottom: 2vmin;
    color: #ff6b6b;
}

#game-over p {
    font-size: calc(3vmin * var(--ui-scale));
    margin-bottom: 3vmin;
}

#restart-btn {
    padding: 1.5vmin 4vmin;
    font-size: calc(2.5vmin * var(--ui-scale));
    background: #4ecdc4;
    color: #fff;
    border: none;
    border-radius: 0.8vmin;
    cursor: pointer;
    transition: background 0.3s;
}

#restart-btn:hover {
    background: #45b7aa;
}

#main-menu-btn {
    padding: 1.5vmin 4vmin;
    font-size: 2.5vmin;
    background: #666;
    color: #fff;
    border: none;
    border-radius: 0.8vmin;
    cursor: pointer;
    transition: background 0.3s;
}

#main-menu-btn:hover {
    background: #888;
}

#game-over .controls-hint {
    margin-top: 2vmin;
    font-size: calc(2vmin * var(--ui-scale));
    color: #888;
    display: flex;
    justify-content: center;
    gap: 4vmin;
}

/* Écran de fin de niveau (victoire) */
#level-complete {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 4vmin;
    border-radius: 1.5vmin;
    text-align: center;
    color: #fff;
    pointer-events: all;
}

#level-complete.hidden {
    display: none;
}

#level-complete h2 {
    font-size: calc(6vmin * var(--ui-scale));
    margin-bottom: 2vmin;
    color: #00ff88;
}

#level-complete p {
    font-size: calc(3vmin * var(--ui-scale));
    margin-bottom: 3vmin;
}

#level-restart-btn {
    padding: 1.5vmin 4vmin;
    font-size: 2.5vmin;
    background: #00ff88;
    color: #000;
    border: none;
    border-radius: 0.8vmin;
    cursor: pointer;
    transition: background 0.3s;
}

#level-restart-btn:hover {
    background: #00cc6a;
}

#level-main-menu-btn {
    padding: 1.5vmin 4vmin;
    font-size: 2.5vmin;
    background: #666;
    color: #fff;
    border: none;
    border-radius: 0.8vmin;
    cursor: pointer;
    transition: background 0.3s;
}

#level-main-menu-btn:hover {
    background: #888;
}

#level-complete .controls-hint {
    margin-top: 2vmin;
    font-size: calc(2vmin * var(--ui-scale));
    color: #888;
    display: flex;
    justify-content: center;
    gap: 4vmin;
}

/* Menu de sélection de niveau */
.menu-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5vmin;
}

#select-level-btn {
    padding: 2vmin 2.5vmin;
    font-size: 4vmin;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 1vmin;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 0.5vmin 1.5vmin rgba(102, 126, 234, 0.4);
}

#select-level-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0.8vmin 2vmin rgba(102, 126, 234, 0.6);
}

.level-name {
    margin-top: 2vmin;
    font-size: calc(2.5vmin * var(--ui-scale));
    color: #aaa;
    font-style: italic;
}

#level-select-menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    padding: 4vmin;
    border-radius: 1.5vmin;
    text-align: center;
    color: #fff;
    pointer-events: all;
    min-width: 40vmin;
}

#level-select-menu.hidden {
    display: none;
}

#level-select-menu h2 {
    font-size: calc(5vmin * var(--ui-scale));
    margin-bottom: 3vmin;
    color: #4ecdc4;
}

#level-buttons-container {
    display: flex;
    flex-direction: column;
    gap: 1.5vmin;
    margin-bottom: 3vmin;
    max-height: 40vh;
    overflow: hidden;
}

.level-select-btn {
    padding: 1.5vmin 3vmin;
    font-size: 2.5vmin;
    background: linear-gradient(135deg, #4ecdc4 0%, #44a08d 100%);
    color: #fff;
    border: none;
    border-radius: 0.8vmin;
    cursor: pointer;
    transition: transform 0.2s, background 0.3s;
    text-align: left;
}

.level-select-btn:hover {
    transform: scale(1.02);
    background: linear-gradient(135deg, #5de0d7 0%, #52b89e 100%);
}

.level-select-btn.current {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.level-select-btn.extreme {
    background: linear-gradient(135deg, #ff4e50 0%, #f9d423 100%);
    font-weight: bold;
    box-shadow: 0 0 2vmin rgba(255, 78, 80, 0.5);
}

.level-select-btn.extreme:hover {
    background: linear-gradient(135deg, #ff6b6d 0%, #ffd93d 100%);
    box-shadow: 0 0 3vmin rgba(255, 78, 80, 0.7);
}

.level-select-btn.extreme.current {
    background: linear-gradient(135deg, #d63031 0%, #e17055 100%);
    box-shadow: 0 0 3vmin rgba(214, 48, 49, 0.8);
}

#cancel-level-select-btn {
    padding: 1.5vmin 4vmin;
    font-size: 2.5vmin;
    background: #666;
    color: #fff;
    border: none;
    border-radius: 0.8vmin;
    cursor: pointer;
    transition: background 0.3s;
}

#cancel-level-select-btn:hover {
    background: #888;
}

#level-select-menu .controls-hint {
    margin-top: 2vmin;
    font-size: calc(2vmin * var(--ui-scale));
    color: #888;
}

/* Indicateur mode Debug */
#debug-indicator {
    position: absolute;
    top: 2vmin;
    right: 2vmin;
    background: rgba(255, 100, 100, 0.9);
    color: #fff;
    padding: 0.8vmin 1.5vmin;
    border-radius: 0.5vmin;
    font-size: 2vmin;
    font-weight: bold;
    pointer-events: none;
    z-index: 100;
    animation: debug-pulse 1.5s ease-in-out infinite;
}

#debug-indicator.hidden {
    display: none;
}

@keyframes debug-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Menu Pause */
#pause-menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 4vmin;
    border-radius: 1.5vmin;
    text-align: center;
    color: #fff;
    pointer-events: all;
    z-index: 50;
}

#pause-menu.hidden {
    display: none;
}

#pause-menu h2 {
    font-size: calc(6vmin * var(--ui-scale));
    margin-bottom: 3vmin;
    color: #ffd93d;
}

#resume-btn {
    padding: 1.5vmin 4vmin;
    font-size: 2.5vmin;
    background: #ffd93d;
    color: #000;
    border: none;
    border-radius: 0.8vmin;
    cursor: pointer;
    transition: background 0.3s;
}

#resume-btn:hover {
    background: #ffec8b;
}

#pause-main-menu-btn {
    padding: 1.5vmin 4vmin;
    font-size: 2.5vmin;
    background: #666;
    color: #fff;
    border: none;
    border-radius: 0.8vmin;
    cursor: pointer;
    transition: background 0.3s;
}

#pause-main-menu-btn:hover {
    background: #888;
}

#pause-menu .controls-hint {
    margin-top: 2vmin;
    font-size: calc(2vmin * var(--ui-scale));
    color: #888;
    display: flex;
    justify-content: center;
    gap: 4vmin;
}

/* Effet de flou sur le canvas en pause */
#gameCanvas.paused {
    filter: blur(5px);
    transition: filter 0.2s ease;
}

/* Bouton pause mobile (coin bas droite) */
#pause-mobile-btn {
    position: absolute;
    bottom: 1vmin;
    right: 2vmin;
    width: 10vmin;
    height: 10vmin;
    font-size: 5vmin;
    background: rgba(255, 217, 61, 0.8);
    color: #000;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: all;
    z-index: 40;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0.5vmin 1.5vmin rgba(0, 0, 0, 0.3);
    transition: transform 0.2s, background 0.2s;
}

#pause-mobile-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 217, 61, 1);
}

#pause-mobile-btn:active {
    transform: scale(0.95);
}

#pause-mobile-btn.hidden {
    display: none;
}

/* Afficher le bouton pause uniquement sur mobile/tactile */
@media (hover: none) and (pointer: coarse) {
    #pause-mobile-btn:not(.hidden) {
        display: flex;
    }
}

/* Cacher sur desktop par défaut */
@media (hover: hover) and (pointer: fine) {
    #pause-mobile-btn {
        display: none !important;
    }
}

/* ========== Menu de sélection de skin ========== */

#select-skin-btn {
    padding: 2vmin 2.5vmin;
    font-size: 4vmin;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
    color: #fff;
    border: none;
    border-radius: 1vmin;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 0.5vmin 1.5vmin rgba(255, 107, 107, 0.4);
}

#select-skin-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0.8vmin 2vmin rgba(255, 107, 107, 0.6);
}

#skin-select-menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    padding: 3vmin;
    border-radius: 1.5vmin;
    text-align: center;
    color: #fff;
    pointer-events: all;
    min-width: 50vmin;
    max-width: 80vmin;
}

#skin-select-menu.hidden {
    display: none;
}

#skin-select-menu h2 {
    font-size: calc(5vmin * var(--ui-scale));
    margin-bottom: 2vmin;
    color: #ff6b6b;
}

/* Onglets de catégorie */
#skin-category-tabs {
    display: flex;
    justify-content: center;
    gap: 1vmin;
    margin-bottom: 2vmin;
}

.skin-tab {
    padding: 1vmin 2vmin;
    font-size: 2vmin;
    background: #444;
    color: #aaa;
    border: none;
    border-radius: 0.5vmin;
    cursor: pointer;
    transition: all 0.2s;
}

.skin-tab:hover {
    background: #555;
    color: #fff;
}

.skin-tab.active {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
    color: #fff;
}

/* Grille de skins */
#skin-grid-container {
    max-height: 35vh;
    overflow-y: auto;
    margin-bottom: 2vmin;
    padding: 1vmin;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 1vmin;
}

#skin-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1.5vmin;
    justify-items: center;
}

.skin-item {
    width: 8vmin;
    height: 8vmin;
    border-radius: 0.8vmin;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 0.3vmin solid transparent;
    overflow: hidden;
    position: relative;
}

.skin-item:hover {
    transform: scale(1.1);
    box-shadow: 0 0.5vmin 1.5vmin rgba(255, 255, 255, 0.3);
}

.skin-item.selected {
    border-color: #ffd700;
    box-shadow: 0 0 1.5vmin rgba(255, 215, 0, 0.6);
}

.skin-item canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Badge pour les skins animés */
.skin-item.animated::after {
    content: '✨';
    position: absolute;
    top: 0.3vmin;
    right: 0.3vmin;
    font-size: 1.5vmin;
}

/* Zone de prévisualisation */
#skin-preview-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2vmin;
    margin-bottom: 2vmin;
    padding: 1.5vmin;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 1vmin;
}

#skin-preview-canvas {
    width: 10vmin;
    height: 10vmin;
    border-radius: 0.5vmin;
    border: 0.2vmin solid #fff;
}

#skin-preview-name {
    font-size: calc(3vmin * var(--ui-scale));
    font-weight: bold;
    color: #fff;
}

#cancel-skin-select-btn {
    padding: 1.5vmin 4vmin;
    font-size: 2.5vmin;
    background: #666;
    color: #fff;
    border: none;
    border-radius: 0.8vmin;
    cursor: pointer;
    transition: background 0.3s;
}

#cancel-skin-select-btn:hover {
    background: #888;
}

#confirm-skin-select-btn {
    padding: 1.5vmin 4vmin;
    font-size: 2.5vmin;
    background: linear-gradient(135deg, #4ecdc4 0%, #44a08d 100%);
    color: #fff;
    border: none;
    border-radius: 0.8vmin;
    cursor: pointer;
    transition: transform 0.2s, background 0.3s;
}

#confirm-skin-select-btn:hover {
    transform: scale(1.02);
    background: linear-gradient(135deg, #5de0d7 0%, #52b89e 100%);
}

#skin-select-menu .controls-hint {
    margin-top: 2vmin;
    font-size: calc(2vmin * var(--ui-scale));
    color: #888;
}

/* Espacement plus large pour les contrôles du menu skin */
.skin-controls-hint {
    display: flex;
    justify-content: center;
    gap: 5vmin;
}

/* Scrollbar personnalisée pour la grille */
#skin-grid-container::-webkit-scrollbar {
    width: 0.8vmin;
}

#skin-grid-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0.4vmin;
}

#skin-grid-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 0.4vmin;
}

#skin-grid-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Responsive : moins de colonnes sur petit écran */
@media (max-width: 600px) {
    #skin-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .skin-item {
        width: 10vmin;
        height: 10vmin;
    }
}
