/* DESKTOP LAYOUT - 3 Colonnes séparées */

/* Masquer l'interface mobile compacte sur desktop */
.tools-compact {
    display: none !important;
}

/* Base background pour desktop */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(180deg, 
        #4a90e2 0%, 
        #7b68ee 25%, 
        #9966cc 50%, 
        #ba55d3 75%, 
        #da70d6 100%);
    overflow-x: hidden;
    user-select: none;
    -webkit-user-select: none;
}

*, *:before, *:after {
    box-sizing: border-box;
}

/* Container principal desktop - Grid 3 colonnes */
.editor-container {
    display: grid;
    grid-template-columns: 240px 1fr 200px; /* Gauche | Centre | Droite */
    grid-template-rows: auto 1fr auto;
    grid-template-areas: 
        "left-sidebar header-center right-sidebar"
        "left-sidebar main-grid right-sidebar"
        "pub-area pub-area pub-area";
    height: 100vh;
    width: 100vw;
    padding: 10px;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    max-width: 1800px;
    margin: 0 auto;
}

/* TITRE centré en haut */
.project-info {
    grid-area: header-center;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    position: relative;
}

.project-info h2 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    text-align: center;
}

/* Repositionner le profil utilisateur pour éviter le chevauchement avec le bouton play */
.project-info .user-profile {
    position: absolute;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
}

.project-info .user-email {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 8px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-info .logout-btn {
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.project-info .logout-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Menu hamburger caché sur desktop */
.menu-hamburger {
    display: none;
}

/* SIDEBAR GAUCHE - Nuancier + Outils */
.tools-secondary {
    grid-area: left-sidebar;
    display: flex;
    flex-direction: column;
    padding: 16px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(25px) saturate(200%);
    -webkit-backdrop-filter: blur(25px) saturate(200%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    gap: 20px;
}

/* Toolbar original cachée sur desktop */
.toolbar {
    display: none;
}

/* Styles pour les couleurs */
.color-palette {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: visible; /* Pas de scroll sur le conteneur principal */
    position: relative;
}

/* Suppression du scroll sur .color-palette pour éviter la double scrollbar */
.color-palette.scrollable {
    overflow: visible; /* Pas de scroll ici */
}

.color-picker-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
    align-items: stretch;
    position: relative;
}

/* Container pour afficher la couleur actuelle */
.desktop-current-color-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.color-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.desktop-current-color {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background-color: #000000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    transition: all 0.3s ease;
    cursor: pointer;
}

.desktop-current-color:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.desktop-current-color:focus-visible {
    outline: 3px solid rgba(0, 122, 255, 0.75);
    outline-offset: 3px;
}

#colorPicker {
    position: absolute;
    top: 50%;
    left: 16px;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 8px;
    opacity: 0;
    cursor: pointer;
    transform: translateY(-50%);
    z-index: 5;
}

.validate-color-btn {
    width: 100%;
    padding: 10px;
    border: 2px solid rgba(0, 255, 100, 0.4);
    border-radius: 10px;
    background: linear-gradient(135deg, 
        rgba(0, 255, 100, 0.2), 
        rgba(0, 200, 80, 0.2));
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.validate-color-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, 
        rgba(0, 255, 100, 0.3), 
        rgba(0, 200, 80, 0.3));
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 255, 100, 0.3);
    border-color: rgba(0, 255, 100, 0.6);
}

.validate-color-btn:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    transform: none !important;
}

/* Le contenu du bouton est géré dynamiquement par JavaScript */
.validate-color-btn:empty::before {
    content: '✓ ';
    font-size: 1.1rem;
}

/* Modale custom de sélection de couleur */
.custom-color-modal {
    width: min(460px, 94vw);
    padding: 0;
    margin: clamp(16px, 4vh, 32px);
    background: linear-gradient(160deg, rgba(45, 46, 80, 0.95), rgba(25, 26, 60, 0.92));
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 20px 60px rgba(10, 10, 30, 0.45);
    color: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
    max-height: 92vh;
}

.custom-color-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.custom-color-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.custom-color-body {
    flex: 1;
    padding: clamp(18px, 3vw, 24px);
    display: flex;
    flex-direction: column;
    gap: 18px;
    overflow-y: auto;
}

.custom-color-preview {
    width: 100%;
    height: 120px;
    border-radius: 14px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
    background: #000;
}

.custom-color-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 10px 14px;
}

.custom-color-hex-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.6);
}

.custom-color-hex-value {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.95);
}

.custom-color-spectrum {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
}

.custom-color-spectrum canvas {
    width: 100%;
    height: auto;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    cursor: crosshair;
    background: #000;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 8px 24px rgba(0, 0, 0, 0.2);
}

.custom-color-spectrum::before {
    content: '';
    display: block;
    width: 100%;
    padding-top: min(62%, 240px);
}

.custom-color-spectrum canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.custom-color-spectrum-hint {
    margin: 0;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    text-align: right;
}

.custom-color-swatches {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(36px, 1fr));
    gap: 10px;
}

.custom-color-swatch {
    width: 100%;
    padding-top: 100%;
    position: relative;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    background-clip: padding-box;
}

.custom-color-swatch::after {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 8px;
    background: inherit;
}

.custom-color-swatch:hover,
.custom-color-swatch:focus-visible {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.7);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    outline: none;
}

.custom-color-swatch.selected {
    border-color: #ffffff;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.4);
}


.custom-color-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.custom-color-actions-right {
    display: flex;
    gap: 10px;
    flex: 1 1 200px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.custom-color-actions .dialog-button {
    flex: 1 1 clamp(120px, 32%, 160px);
    min-width: 0;
}

@media (max-width: 768px) {
    .custom-color-modal {
        width: 92vw;
    }
}

@media (max-width: 560px) {
    .custom-color-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .custom-color-actions-right {
        width: 100%;
        justify-content: flex-start;
    }
    .custom-color-actions .dialog-button {
        flex: 1 1 100%;
        width: 100%;
    }
}
.validate-color-btn:empty:not(:disabled)::after {
    content: 'Ajouter à la palette';
}

.validate-color-btn:empty:disabled::after {
    content: 'Sélectionnez une couleur';
    font-size: 0.8rem;
}

.tools-row {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.eraser-btn, .undo-redo-btn {
    flex: 1;
    padding: 8px 4px;
    font-size: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: all 0.2s ease;
}

.eraser-btn:hover, .undo-redo-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.preset-colors {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    justify-items: center;
    max-height: clamp(120px, 16vh, 180px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 12px;
    scrollbar-gutter: stable;
}

.preset-colors::-webkit-scrollbar {
    width: 6px;
}

.preset-colors::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
}

.preset-colors::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.35);
    border-radius: 999px;
}

.color-btn {
    width: 26px;
    height: 26px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    position: relative; /* Important pour le positionnement de l'étoile */
}

.color-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* ===================================================================
   STYLES POUR LES COULEURS PERSONNALISÉES
   =================================================================== */

/* Bouton de couleur personnalisée - bordure bleue distinctive */
.color-btn.custom-color {
    border: 2px solid #007AFF;
    box-shadow: 
        0 0 0 1px rgba(0, 122, 255, 0.3), 
        0 2px 8px rgba(0, 122, 255, 0.2);
}

.color-btn.custom-color .color-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid #007AFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 700;
    color: #007AFF;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    pointer-events: auto;
    z-index: 2;
}

.color-btn.custom-color:hover {
    border-color: #0056b3;
    transform: scale(1.15);
    box-shadow: 
        0 0 0 2px rgba(0, 122, 255, 0.4), 
        0 4px 16px rgba(0, 122, 255, 0.3);
}

.color-btn.custom-color:hover .color-badge {
    color: #0056b3;
    border-color: #0056b3;
    transform: scale(1.05);
}

.color-btn.custom-color.show-remove {
    border-color: rgba(255, 59, 48, 0.9);
    box-shadow: 
        0 0 0 2px rgba(255, 59, 48, 0.35),
        0 6px 18px rgba(255, 59, 48, 0.25);
}

.color-btn.custom-color.show-remove .color-badge {
    background: linear-gradient(135deg, rgba(255, 93, 95, 0.95), rgba(255, 59, 48, 0.95));
    color: #ffffff;
    border-color: rgba(255, 59, 48, 0.8);
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(255, 59, 48, 0.35);
}

/* TOUS les boutons dans sidebar gauche */
.extra-tools {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: none;
    overflow-y: auto;
}

.extra-tools button {
    padding: 10px 14px;
    font-size: 0.85rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.95);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex-shrink: 0;
    width: 100%;
}

.extra-tools button:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.extra-tools button:active {
    transform: translateY(0);
}

.fps-sidebar-panel {
    display: none;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    margin-top: -4px;
    background: rgba(16, 22, 48, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 8px 20px rgba(0, 0, 0, 0.25);
    animation: fadeIn 0.2s ease;
}

.fps-sidebar-panel.open {
    display: flex;
}

.fps-sidebar-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    color: rgba(255, 255, 255, 0.9);
}

.fps-sidebar-value {
    font-size: 1.1rem;
    font-weight: 600;
}

.fps-sidebar-value span {
    font-size: 1.35rem;
}

.fps-sidebar-desc {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}

.fps-sidebar-slider {
    display: flex;
    align-items: center;
    gap: 12px;
}

.fps-sidebar-slider input[type="range"] {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.8), rgba(118, 75, 162, 0.8));
    -webkit-appearance: none;
    appearance: none;
    outline: none;
}

.fps-sidebar-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid rgba(102, 126, 234, 0.9);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

.fps-sidebar-slider input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid rgba(102, 126, 234, 0.9);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

.fps-sidebar-presets {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.fps-sidebar-preset {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 8px;
    border-radius: 10px;
    border: 1px solid rgba(102, 126, 234, 0.5);
    background: rgba(102, 126, 234, 0.2);
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    min-height: 54px;
}

.fps-sidebar-preset small {
    font-size: 0.7rem;
    opacity: 0.8;
}

.fps-sidebar-preset:hover {
    background: rgba(102, 126, 234, 0.35);
    border-color: rgba(102, 126, 234, 0.8);
    transform: translateY(-1px);
}

.fps-sidebar-preset.active {
    background: rgba(102, 126, 234, 0.55);
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 6px 14px rgba(102, 126, 234, 0.35);
}

.fps-sidebar-hint {
    margin: 0;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.65);
    text-align: left;
}

/* Styling spécifique pour certains boutons */
.extra-tools button[id*="preview"] {
    background: rgba(0, 255, 100, 0.2);
    border-color: rgba(0, 255, 100, 0.4);
}

.extra-tools button[id*="preview"]:hover {
    background: rgba(0, 255, 100, 0.3);
}

.extra-tools button[id*="clear"], 
.extra-tools button[id*="delete"] {
    background: rgba(255, 70, 70, 0.2);
    border-color: rgba(255, 70, 70, 0.4);
}

.extra-tools button[id*="clear"]:hover, 
.extra-tools button[id*="delete"]:hover {
    background: rgba(255, 70, 70, 0.3);
}

.extra-tools button[id*="save"], 
.extra-tools button[id*="export"] {
    background: rgba(0, 122, 255, 0.2);
    border-color: rgba(0, 122, 255, 0.4);
}

.extra-tools button[id*="save"]:hover, 
.extra-tools button[id*="export"]:hover {
    background: rgba(0, 122, 255, 0.3);
}

/* ZONE CENTRALE - Grille ÉNORME */
.grid-container {
    grid-area: main-grid;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    overflow: hidden; /* Empêcher le débordement */
    min-width: 0; /* Permettre le rétrécissement */
    min-height: 0; /* Permettre le rétrécissement */
}

/* Grille 32×32 massive */
#pixelGrid {
    --cell-size: min(
        calc((100vw - 480px) / 32), /* Largeur - sidebars - gaps */
        calc((100vh - 200px) / 32), /* Hauteur - header - pub */
        28px  /* Cellules ÉNORMES pour desktop */
    );
    
    width: calc(var(--cell-size) * 32);
    height: calc(var(--cell-size) * 32);
    
    display: grid;
    grid-template-columns: repeat(32, 1fr);
    grid-template-rows: repeat(32, 1fr);
    gap: 0;
    
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 
        0 12px 48px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    overflow: hidden; /* Pour que les pixels ne débordent pas et respectent les angles arrondis */
    aspect-ratio: 1; /* Garantir que la grille reste carrée */
    
    /* Contraintes desktop avec responsivité améliorée */
    min-width: calc(20px * 32);
    min-height: calc(20px * 32);
    max-width: calc(28px * 32);
    max-height: calc(28px * 32);
    
    /* Assurer que la grille reste carrée même en cas de redimensionnement */
}

.pixel {
    width: 100%;
    height: 100%;
    border: 0.5px solid rgba(0, 0, 0, 0.08);
    box-sizing: border-box;
    cursor: crosshair;
    transition: none;
    position: relative;
    margin: 0;
    padding: 0;
    /* Assurer que les pixels respectent les angles arrondis de la grille */
    overflow: hidden;
    background-color: #FFFFFF;
}

.pixel:hover {
    border-color: rgba(0, 0, 0, 0.15);
}

/* Arrondir les pixels des coins pour suivre la forme arrondie de la grille */
/* Angles arrondis pour les pixels aux coins de la grille */
#pixelGrid .pixel:nth-child(1) {
    border-top-left-radius: 13px; /* 16px - 3px de border */
    overflow: hidden;
}

#pixelGrid .pixel:nth-child(32) {
    border-top-right-radius: 13px;
    overflow: hidden;
}

#pixelGrid .pixel:nth-child(993) {
    border-bottom-left-radius: 13px; /* 32 * 31 + 1 = 993 */
    overflow: hidden;
}

#pixelGrid .pixel:nth-child(1024) {
    border-bottom-right-radius: 13px; /* 32 * 32 = 1024 */
    overflow: hidden;
}


/* Mode pipette - curseur spécial */
#pixelGrid.eyedropper-mode .pixel {
    cursor: crosshair;
}

#pixelGrid.eyedropper-mode .pixel:hover {
    border-color: rgba(0, 122, 255, 0.6);
    border-width: 2px;
    box-shadow: 0 0 8px rgba(0, 122, 255, 0.4);
}

/* Bouton pipette actif */
.eyedropper-btn.active,
#eyedropperBtn.active {
    background: rgba(0, 122, 255, 0.3) !important;
    border-color: rgba(0, 122, 255, 0.6) !important;
    box-shadow: 0 0 12px rgba(0, 122, 255, 0.4) !important;
}

/* Animations pour les notifications pipette */
@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
    15%, 85% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
}

/* SIDEBAR DROITE - Frames */
.frames-container {
    grid-area: right-sidebar;
    display: flex;
    flex-direction: column;
    padding: 12px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(25px) saturate(200%);
    -webkit-backdrop-filter: blur(25px) saturate(200%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    gap: 10px;
}

.frames-container h3 {
    margin: 0 0 12px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    text-align: center;
}

#addFrameBtn {
    padding: 12px 16px;
    font-size: clamp(0.85rem, 1.8vw, 1rem);
    font-weight: 600;
    background: rgba(0, 255, 100, 0.2);
    border: 1px solid rgba(0, 255, 100, 0.4);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.95);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.2;
    white-space: normal;
}

#addFrameBtn:hover {
    background: rgba(0, 255, 100, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 255, 100, 0.2);
}

/* ========================================
   BOUTONS FRAME ACTIONS DESKTOP (Copier/Coller)
   ======================================== */

.frame-actions {
    display: flex;
    align-items: stretch;
    gap: 6px;
    margin-bottom: 10px;
    padding: 0 4px;
    flex-shrink: 0;
}

.frame-action-btn {
    width: clamp(34px, 2.2vw, 40px);
    height: clamp(34px, 2.2vw, 40px);
    border: none;
    border-radius: 9px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: clamp(13px, 1.3vw, 18px);
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.frame-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.frame-action-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.copy-btn {
    background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%);
}

.paste-btn {
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
}

#addFrameBtn {
    flex: 1;
    min-height: clamp(42px, 3vw, 50px);
    font-size: clamp(0.72rem, 1.3vw, 0.95rem);
    border-radius: 11px;
    padding-inline: clamp(6px, 1vw, 12px);
}

/* Styles obsolètes pour .frame - remplacés par .frame-preview */

.frame-thumbnail {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 6px;
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    grid-template-rows: repeat(16, 1fr);
    gap: 0;
    overflow: hidden;
    box-sizing: border-box;
}

.thumbnail-pixel {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: block;
    box-sizing: border-box;
}

.frame-number {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    font-weight: 500;
}

/* Liste des frames avec scroll indépendant */
#framesList {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

/* Indicateur visuel pour la frame en cours d'exécution */
.frame-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 6px;
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.frame-preview {
    position: relative;
    width: 100%;
    min-width: 110px;
    max-width: 110px;
    min-height: 110px;
    max-height: 110px;
    padding: 3px;
    background: rgba(135, 206, 250, 0.2);
    border: 1px solid rgba(0, 122, 255, 0.4);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    aspect-ratio: 1;
}

.frame-preview:hover {
    background: rgba(135, 206, 250, 0.3);
    border-color: rgba(0, 122, 255, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.2);
}

.frame-preview.active {
    background: rgba(135, 206, 250, 0.35);
    border-color: rgba(0, 122, 255, 0.7);
    box-shadow: 0 0 20px rgba(0, 122, 255, 0.3), 0 4px 16px rgba(0, 122, 255, 0.2);
}

/* Bouton "+" pour insérer une frame */
.insert-frame-btn {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    border: 1px solid rgba(0, 122, 255, 0.4);
    background: rgba(135, 206, 250, 0.2);
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: rgba(0, 122, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.insert-frame-btn:hover {
    background: rgba(135, 206, 250, 0.3);
    border-color: rgba(0, 122, 255, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.2);
}

/* Pastille bleue pour la frame active (en cours de travail) */
.frame-container .frame-preview.active::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #007AFF;
    box-shadow: 0 0 8px rgba(0, 122, 255, 0.8), 0 0 16px rgba(0, 122, 255, 0.5);
    z-index: 10;
}

/* Pastille verte pour la frame en cours d'animation (priorité sur la bleue) */
.frame-container .frame-preview.playing::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #00FF00;
    box-shadow: 0 0 8px rgba(0, 255, 0, 0.8), 0 0 16px rgba(0, 255, 0, 0.5);
    animation: pulse-playing 1s ease-in-out infinite;
    z-index: 11;
}

@keyframes pulse-playing {
    0%, 100% {
        transform: translateY(-50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translateY(-50%) scale(1.3);
        opacity: 0.8;
    }
}

/* ZONE PUB en bas - Barre visible sans référence publicitaire */
.ad-space {
    grid-area: pub-area;
    min-height: 64px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 24px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

/* Masquer tout contenu texte dans la barre */
.ad-space span,
.ad-space * {
    display: none;
    visibility: hidden;
}

/* Responsive pour très grands écrans */
@media (min-width: 1600px) {
    .editor-container {
        grid-template-columns: 280px 1fr 240px;
        max-width: 2000px;
    }
    
    #pixelGrid {
        --cell-size: min(
            calc((100vw - 560px) / 32),
            calc((100vh - 200px) / 32),
            32px
        );
        aspect-ratio: 1;
    }
    
    /* Plus d'espace pour le user-profile sur grands écrans */
    .project-info .user-email {
        max-width: 250px;
    }
}

/* Responsive pour écrans moyens */
@media (min-width: 1024px) and (max-width: 1400px) {
    .editor-container {
        grid-template-columns: 220px 1fr 180px;
    }
    
    #pixelGrid {
        --cell-size: min(
            calc((100vw - 420px) / 32),
            calc((100vh - 200px) / 32),
            24px
        );
        aspect-ratio: 1;
    }
}

/* Responsive pour petits écrans desktop */
@media (min-width: 1024px) and (max-width: 1200px) {
    .editor-container {
        grid-template-columns: 200px 1fr 160px;
        padding: 8px;
        gap: 8px;
    }
    
    #pixelGrid {
        --cell-size: min(
            calc((100vw - 380px) / 32),
            calc((100vh - 180px) / 32),
            20px
        );
        border-radius: 12px;
        aspect-ratio: 1;
    }
    
    /* Ajuster les coins arrondis pour les petits écrans */
    #pixelGrid .pixel:nth-child(1) {
        border-top-left-radius: 9px; /* 12px - 3px de border */
        overflow: hidden;
    }
    #pixelGrid .pixel:nth-child(32) {
        border-top-right-radius: 9px;
        overflow: hidden;
    }
    #pixelGrid .pixel:nth-child(993) {
        border-bottom-left-radius: 9px;
        overflow: hidden;
    }
    #pixelGrid .pixel:nth-child(1024) {
        border-bottom-right-radius: 9px;
        overflow: hidden;
    }
}


/* ===================================================================
   MARQUEURS DE PIXELS - REPÈRES COLORÉS POUR ANIMATION
   =================================================================== */

/* Marqueur du pixel précédent (frame d'avant) */
.previous-pixel-marker {
    position: absolute;
    width: 25%;
    height: 25%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
}

/* Marqueurs des pixels suivants (frames d'après) */
.next-pixel-marker-1, .next-pixel-marker-2 {
    position: absolute;
    width: 20%;
    height: 20%;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
}

.next-pixel-marker-1 {
    top: 25%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.next-pixel-marker-2 {
    top: 75%;
    left: 50%;
    transform: translate(-50%, -50%);
}


/* ===================================================================
   AJUSTEMENTS DES MINIATURES - DESKTOP UNIQUEMENT
   =================================================================== */

@media (min-width: 1024px) {
    /* Fix pour les miniatures de frames */
    .thumbnail-pixel {
        min-width: 2px !important;
        min-height: 2px !important;
    }
}


/* ===================================================================
   CORRECTIONS SUPPLÉMENTAIRES - DESKTOP UNIQUEMENT
   =================================================================== */

@media (min-width: 1024px) {
    /* Fixer la taille des miniatures pour éviter le redimensionnement */
    .frame-thumbnail {
        width: 100% !important;
        height: 100% !important;
        min-height: 100% !important;
        max-height: 100% !important;
        flex-shrink: 0 !important;
    }
    
    /* Améliorer la visibilité des miniatures */
    .frame-container {
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 6px !important;
        position: relative;
    }
    
    /* Assurer que toutes les frames ont la même taille (carré) */
    .frame-preview {
        width: 110px !important;
        min-width: 110px !important;
        max-width: 110px !important;
        height: 110px !important;
        min-height: 110px !important;
        max-height: 110px !important;
        aspect-ratio: 1 !important;
    }
}


/* ===================================================================
   BOUTON PLAY DANS LA BARRE DU HAUT - DESKTOP
   =================================================================== */

.play-button {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.play-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.play-button:active {
    transform: translateY(-50%) scale(0.95);
}

.play-button.playing {
    background: rgba(255, 0, 0, 0.3);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: translateY(-50%) scale(1); }
    50% { transform: translateY(-50%) scale(1.1); }
    100% { transform: translateY(-50%) scale(1); }
}

.compact-preset-colors {
    display: flex;
    gap: 3px;
    justify-content: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 1;
    min-width: 0;
    padding: 2px 0 18px;
    position: relative;
}

.palette-scroll-hint {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    margin: -12px 0 0;
}

/* ===================================================================
   FENÊTRE DE DIALOGUE DE SAUVEGARDE - DESKTOP
   =================================================================== */

.save-dialog {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(0, 0, 0, 0.6) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 9998 !important;
    padding: 20px !important;
    animation: fadeIn 0.3s ease !important;
}

.save-dialog-content {
    background: linear-gradient(155deg, rgba(36, 48, 94, 0.98), rgba(28, 38, 80, 0.95)) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 24px !important;
    padding: 32px !important;
    width: 100% !important;
    max-width: 420px !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6) !important;
    animation: fadeIn 0.3s ease !important;
    color: rgba(255, 255, 255, 0.95) !important;
}

.save-dialog h3 {
    margin: 0 0 20px 0 !important;
    text-align: center !important;
    font-size: 1.3rem !important;
    color: rgba(255, 255, 255, 0.95) !important;
    font-weight: 600 !important;
}

.save-dialog input {
    width: 100% !important;
    padding: 16px !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    border-radius: 16px !important;
    font-size: 1rem !important;
    margin-bottom: 20px !important;
    outline: none !important;
    background: rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    color: white !important;
    box-sizing: border-box !important;
}

.save-dialog input::placeholder {
    color: rgba(255, 255, 255, 0.6) !important;
}

.save-dialog input:focus {
    border-color: rgba(0, 122, 255, 0.6) !important;
    background: rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2) !important;
}

.save-dialog .dialog-buttons {
    display: flex !important;
    gap: 12px !important;
    margin-top: 20px !important;
}

.save-dialog .dialog-buttons button {
    flex: 1 !important;
    padding: 12px 24px !important;
    border: none !important;
    border-radius: 10px !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

.save-dialog .dialog-buttons button#dialogSave {
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.9), rgba(0, 86, 179, 0.9)) !important;
    color: white !important;
}

.save-dialog .dialog-buttons button#dialogSave:hover {
    background: linear-gradient(135deg, rgba(0, 122, 255, 1), rgba(0, 86, 179, 1)) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4) !important;
}

.save-dialog .dialog-buttons button#dialogCancel {
    background: rgba(255, 255, 255, 0.15) !important;
    color: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
}

.save-dialog .dialog-buttons button#dialogCancel:hover {
    background: rgba(255, 255, 255, 0.25) !important;
    transform: translateY(-1px) !important;
}
