        body {
            margin: 0;
            padding: 0;
            overflow-x: hidden;
            overscroll-behavior-y: none; /* évite le pull-to-refresh sur Android */
        }
        
        #gameWrapper {
            min-height: calc(100vh - 80px);
            background: #f9fafb;
        }
        
        #gameContainer {
            display: flex;
            align-items: flex-start;
            gap: 2rem;
            max-width: 1400px;
            margin: 0 auto;
            padding: 2rem 1rem;
        }
        
        #gameArea {
            flex: 1;
            min-width: 0; /* Permet au gameArea de rétrécir si nécessaire */
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        
        /* Wrapper pour le canvas et ses contrôles */
        .canvas-wrapper {
            position: relative;
            width: fit-content; /* S'adapte à la taille exacte du canvas */
            max-width: 100%;
            margin: 0 auto; /* Centre le wrapper */
        }
        
        #gameCanvas {
            border-radius: 10px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.1);
            background: white;
            cursor: pointer;
            display: block;
            /* Canvas dimensions contrôlées par JS */
        }

        /* Contrôles plein écran - alignés avec le coin supérieur droit du canvas */
        .fullscreen-controls {
            position: absolute;
            top: 10px;
            right: 10px;
            z-index: 30; /* Au-dessus du canvas */
            display: flex;
            gap: 8px;
        }
        .fs-btn {
            width: 40px;
            height: 40px;
            border-radius: 9999px;
            border: none;
            background: rgba(0,0,0,0.5);
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            backdrop-filter: blur(2px);
        }
        .fs-btn:hover { background: rgba(0,0,0,0.6); }

        /* Contrôles de mode + chrono - alignés avec le coin supérieur gauche du canvas */
        .mode-controls {
            position: absolute;
            top: 10px;
            left: 10px;
            z-index: 30; /* Au-dessus du canvas */
            display: flex;
            flex-direction: column; /* Superposition verticale */
            align-items: flex-start;
            gap: 8px;
        }
        .mode-btn {
            padding: 6px 10px;
            border-radius: 16px;
            border: 1px solid rgba(0,0,0,0.2);
            background: rgba(255,255,255,0.8);
            backdrop-filter: blur(2px);
            cursor: pointer;
            font-size: 13px;
        }
        .mode-btn.active { background: var(--color-primary-600); color: white; border-color: var(--color-primary-600); }
        .timer-pill {
            background: rgba(0,0,0,0.6);
            color: white;
            padding: 6px 10px;
            border-radius: 16px;
            font-weight: bold;
            min-width: 46px;
            text-align: center;
        }
        .start-btn { padding: 6px 10px; border-radius: 16px; border: none; background: #10b981; color: white; cursor: pointer; }
        .start-btn:hover { background: #0ea773; }

        /* Styles en plein écran (API native) */
        #gameWrapper:fullscreen { background: #000; }
        #gameWrapper:fullscreen #gameContainer { max-width: none; padding: 0; }
        #gameWrapper:fullscreen #gameArea { width: 100vw; height: 100vh; justify-content: center; }
        #gameWrapper:fullscreen .canvas-wrapper { width: fit-content; height: fit-content; max-width: 100%; margin: auto; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
        #gameWrapper:fullscreen #gameCanvas { box-shadow: none; border-radius: 0; }
        #gameWrapper:fullscreen .scores-sidebar, 
        #gameWrapper:fullscreen .game-instructions, 
        #gameWrapper:fullscreen .show-scores-btn { display: none !important; }

        /* WebKit prefix */
        #gameWrapper:-webkit-full-screen { background: #000; }
        #gameWrapper:-webkit-full-screen #gameContainer { max-width: none; padding: 0; }
        #gameWrapper:-webkit-full-screen #gameArea { width: 100vw; height: 100vh; justify-content: center; }
        #gameWrapper:-webkit-full-screen .canvas-wrapper { width: fit-content; height: fit-content; max-width: 100%; margin: auto; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
        #gameWrapper:-webkit-full-screen #gameCanvas { box-shadow: none; border-radius: 0; }
        #gameWrapper:-webkit-full-screen .scores-sidebar,
        #gameWrapper:-webkit-full-screen .game-instructions,
        #gameWrapper:-webkit-full-screen .show-scores-btn { display: none !important; }

        /* Fallback pseudo-fullscreen */
        #gameWrapper.pseudo-fullscreen { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: #000; z-index: 2000; }
        #gameWrapper.pseudo-fullscreen #gameContainer { max-width: none; padding: 0; }
        #gameWrapper.pseudo-fullscreen #gameArea { width: 100vw; height: 100vh; justify-content: center; }
        #gameWrapper.pseudo-fullscreen .canvas-wrapper { width: fit-content; height: fit-content; max-width: 100%; margin: auto; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
        #gameWrapper.pseudo-fullscreen #gameCanvas { box-shadow: none; border-radius: 0; }
        #gameWrapper.pseudo-fullscreen .scores-sidebar,
        #gameWrapper.pseudo-fullscreen .game-instructions,
        #gameWrapper.pseudo-fullscreen .show-scores-btn { display: none !important; }
        
        /* Sidebar des scores pour grandes résolutions */
        .scores-sidebar {
            width: 320px;
            background: white;
            border-radius: 10px;
            padding: 1.5rem;
            box-shadow: 0 4px 20px rgba(0,0,0,0.1);
            max-height: calc(100vh - 120px);
            overflow-y: auto;
            position: sticky;
            top: 80px;
        }
        
        /* Modal pour petites résolutions */
        #scoresModal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0,0,0,0.7);
            z-index: 1000;
            align-items: center;
            justify-content: center;
            padding: 1rem;
        }
        
        #scoresModal.show {
            display: flex;
        }
        
        .modal-scores-content {
            background: white;
            padding: 2rem;
            border-radius: 10px;
            max-width: 500px;
            width: 100%;
            max-height: 80vh;
            overflow-y: auto;
        }
        
        @media (max-width: 480px) {
            .modal-scores-content {
                padding: 1.5rem;
                margin: 0.5rem;
                max-height: 85vh;
                border-radius: 8px;
            }
            
            .modal-content {
                padding: 1.5rem;
                margin: 0.5rem;
                border-radius: 8px;
            }
            
            /* Adaptation des contrôles pour mobile - restent alignés aux coins du canvas */
            .mode-controls {
                flex-direction: row;
                align-items: center;
                top: 5px;
                left: 5px;
            }
            
            .fullscreen-controls {
                top: 5px;
                right: 5px;
            }
            
            .mode-btn {
                font-size: 12px;
                padding: 5px 8px;
            }
            
            .fs-btn {
                width: 35px;
                height: 35px;
            }
        }
        
        .score-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0.75rem;
            border-bottom: 1px solid #e5e7eb;
            transition: background-color 0.2s;
        }
        
        .score-row:hover {
            background-color: #f9fafb;
        }
        
        .score-row.current-user {
            background-color: #fef3c7;
            font-weight: bold;
        }
        
        .score-row.new-record {
            animation: highlight 2s ease-in-out;
        }
        
        @keyframes highlight {
            0% { background-color: #34d399; }
            100% { background-color: #fef3c7; }
        }
        
        .score-rank {
            width: 40px;
            text-align: center;
            font-weight: bold;
            font-size: 1.1rem;
        }
        
        .score-initials {
            flex: 1;
            padding: 0 1rem;
            font-size: 1rem;
        }
        
        .score-value {
            font-weight: bold;
            color: var(--color-primary-600);
            font-size: 1.1rem;
        }
        
        .gold { color: #FFD700; }
        .silver { color: #C0C0C0; }
        .bronze { color: #CD7F32; }
        
        #saveScoreModal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0,0,0,0.7);
            z-index: 3006; /* au-dessus du wrapper plein écran */
            align-items: center;
            justify-content: center;
            padding: 1rem;
        }
        
        #saveScoreModal.show {
            display: flex;
        }
        
        .modal-content {
            background: white;
            padding: 2rem;
            border-radius: 10px;
            max-width: 400px;
            width: 100%;
        }
        
        .game-instructions {
            background: white;
            padding: 1rem;
            border-radius: 10px;
            margin-top: 1rem;
            box-shadow: 0 2px 10px rgba(0,0,0,0.05);
            text-align: center;
            color: #4b5563;
        }
        
        /* Responsive - seuil ajusté pour conserver la sidebar plus longtemps */
        @media (max-width: 1130px) {
            #gameContainer {
                flex-direction: column;
                align-items: center;
            }
            
            .canvas-wrapper {
                width: fit-content;
                max-width: 100%;
                margin: 0 auto;
            }
            
            .scores-sidebar {
                width: 100%;
                max-width: 600px;
                margin-top: 1rem;
                position: static;
                max-height: 400px;
            }
        }
        
        @media (max-width: 768px) {
            .scores-sidebar {
                display: none;
            }
            
            #gameContainer {
                justify-content: center;
            }
            
            .show-scores-btn {
                display: inline-block;
                margin-top: 1rem;
                padding: 0.5rem 1rem;
                background: var(--color-primary-600);
                color: white;
                border-radius: 5px;
                cursor: pointer;
                transition: background-color 0.2s;
            }
            
            .show-scores-btn:hover {
                background: var(--color-primary-700);
            }
        }
        
        @media (min-width: 769px) {
            .show-scores-btn {
                display: none;
            }
        }
        
        @media (max-width: 640px) {
            #gameContainer {
                padding: 0.5rem;
                gap: 1rem;
                flex-direction: column;
                align-items: center;
            }
            
            .canvas-wrapper {
                width: fit-content;
                max-width: 100%;
                margin: 0 auto;
            }
            
            #gameCanvas {
                /* Supprimer toutes les limitations CSS, laisser JavaScript gérer */
                width: auto !important;
                height: auto !important;
                max-width: none !important;
                max-height: none !important;
                min-height: none !important;
                touch-action: none; /* éviter le scroll/pull-to-refresh pendant le jeu */
            }
            
            .game-instructions {
                margin-top: 0.5rem;
                padding: 0.75rem;
            }
        }
        
        /* Optimisation pour très petits écrans (smartphones en portrait) */
        @media (max-width: 480px) and (orientation: portrait) {
            
            #gameContainer {
                padding: 0.25rem;
                gap: 0.5rem;
            }
            
            #gameCanvas {
                /* JavaScript contrôle complètement la taille */
                width: auto !important;
                height: auto !important;
                max-width: none !important;
                max-height: none !important;
            }
            
            .game-instructions {
                font-size: 0.875rem;
                padding: 0.5rem;
                margin-top: 0.25rem;
            }
            
            .show-scores-btn {
                margin-top: 0.5rem;
                padding: 0.75rem 1rem;
                font-size: 0.875rem;
            }
        }
        
        .success-toast {
            position: fixed;
            top: 100px;
            right: 20px;
            background: #10b981;
            color: white;
            padding: 1rem 1.5rem;
            border-radius: 8px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.2);
            z-index: 1002;
            animation: slideIn 0.3s ease-out;
        }
        
        @keyframes slideIn {
            from {
                transform: translateX(400px);
                opacity: 0;
            }
            to {
                transform: translateX(0);
                opacity: 1;
            }
        }
        
        /* Styles adaptés pour écrans moyens - préserve la largeur de la sidebar */
        @media (min-width: 1131px) and (max-width: 1400px) {
            #gameContainer {
                gap: 1.5rem;
            }
            
            .scores-sidebar {
                width: 300px;
                min-width: 300px;
            }
        }
        
        /* Pour très grands écrans */
        @media (min-width: 1600px) {
            #gameContainer {
                max-width: 1800px;
            }
            
            .scores-sidebar {
                width: 350px;
                min-width: 350px;
            }
        }
        
        /* Garantir l'alignement des contrôles sur toutes les tailles */
        @supports (width: fit-content) {
            .canvas-wrapper {
                width: fit-content !important;
            }
        }
        
        /* Fallback pour navigateurs ne supportant pas fit-content */
        @supports not (width: fit-content) {
            .canvas-wrapper {
                display: inline-block;
                width: auto !important;
            }
        }
