body {
    min-height: 100vh;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: 'Segoe UI', 'Roboto', 'Arial', sans-serif;
    background: linear-gradient(135deg, #e0e7ff 0%, #f8fafc 100%);
}

.main-card {
    background: #fff;
    border-radius: 22px;
    box-shadow: 0 6px 32px rgba(60,60,120,0.10), 0 1.5px 6px rgba(60,60,120,0.08);
    padding: 32px 28px 28px 28px;
    margin: 32px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 98vw;
}

h1 {
    font-size: 2.1em;
    font-weight: 700;
    letter-spacing: -1px;
    color: #222034;
    margin-bottom: 18px;
    margin-top: 0;
    text-align: center;
}

/* Workspace principal */
.workspace {
    display: flex;
    gap: 24px;
    width: 100%;
    max-width: 1200px;
    align-items: flex-start;
}

.drawing-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
}

/* Panel de layers */
.layers-panel {
    width: 320px;
    background: #f8fafc;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(60,60,120,0.08);
    flex-shrink: 0;
}

.layers-header {
    margin-bottom: 16px;
}

.layers-header h3 {
    margin: 0 0 12px 0;
    color: #222034;
    font-size: 1.2em;
}

.layers-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.layer-btn {
    background: linear-gradient(90deg, #e0e7ff 0%, #cbdbfc 100%);
    color: #3f3f74;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    min-width: 0;
}

.layer-btn:hover {
    background: linear-gradient(90deg, #cbdbfc 0%, #639bff 100%);
    transform: translateY(-1px);
}

.layers-list {
    max-height: 250px;
    overflow-y: auto;
    margin-bottom: 16px;
    border: 1px solid #e0e7ff;
    border-radius: 8px;
    background: #fff;
    padding: 8px;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fff;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.layer-item:last-child {
    margin-bottom: 0;
}

.layer-item:hover {
    background: #f0f4ff;
    transform: translateX(2px);
}

.layer-item.active {
    border-color: #639bff;
    background: #f0f4ff;
}

.layer-item.selected {
    border-color: #5fcde4;
    background: #f0f8ff;
}

.layer-thumbnail {
    width: 32px;
    height: 32px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f8fafc;
    flex-shrink: 0;
}

.layer-info {
    flex: 1;
    min-width: 0;
}

.layer-name {
    font-size: 0.9em;
    font-weight: 600;
    color: #222034;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-duration {
    font-size: 0.8em;
    color: #666;
    margin: 0;
}

.layer-checkbox {
    margin: 0;
}

.layer-actions {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
}

.move-up-btn, .move-down-btn {
    background: linear-gradient(90deg, #e0e7ff 0%, #cbdbfc 100%);
    color: #3f3f74;
    border: none;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 0.8em;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 24px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.move-up-btn:hover:not(:disabled), .move-down-btn:hover:not(:disabled) {
    background: linear-gradient(90deg, #cbdbfc 0%, #639bff 100%);
    transform: scale(1.1);
}

.move-up-btn:disabled, .move-down-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: #f0f0f0;
    color: #999;
}

/* Contrôles d'animation */
.animation-controls {
    margin-bottom: 16px;
    padding: 16px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e0e7ff;
}

.animation-controls h4 {
    margin: 0 0 12px 0;
    color: #222034;
    font-size: 1em;
}

.control-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.control-btn {
    background: linear-gradient(90deg, #639bff 0%, #5fcde4 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
}

.control-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(60,60,120,0.2);
}

.speed-control {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.speed-control label {
    font-size: 0.9em;
    color: #666;
    margin: 0;
}

.speed-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e0e7ff;
    outline: none;
    -webkit-appearance: none;
}

.speed-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3f3f74;
    cursor: pointer;
}

#speedValue {
    font-weight: 600;
    color: #3f3f74;
}

.export-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.export-btn {
    background: linear-gradient(90deg, #99e550 0%, #6abe30 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.export-btn:hover {
    background: linear-gradient(90deg, #6abe30 0%, #99e550 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(60,60,120,0.2);
}

#palette {
    margin: 18px 0 8px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 14px 28px;
    align-items: center;
    justify-content: center;
}
#palette label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 1.08em;
    color: #3f3f74;
    background: #f3f4f8;
    border-radius: 7px;
    padding: 4px 10px;
    box-shadow: 0 1px 2px rgba(60,60,120,0.04);
}

canvas {
    border: 3px solid #3f3f74;
    background: #f8fafc;
    image-rendering: pixelated;
    width: 90vw;
    max-width: 500px;
    height: auto;
    aspect-ratio: 1 / 1;
    display: block;
    box-sizing: border-box;
    border-radius: 18px;
    margin-bottom: 18px;
    box-shadow: 0 2px 16px rgba(60,60,120,0.08);
}

.pixel-palette {
    max-width: 100vw;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px 14px;
    display: flex;
    margin-bottom: 18px;
}
.pixel-color {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    border: 2px solid #bbb;
    border-radius: 7px;
    cursor: pointer;
    box-sizing: border-box;
    transition: border 0.2s, transform 0.15s;
    flex: 0 0 auto;
    background: #fff;
    box-shadow: 0 1px 4px rgba(60,60,120,0.06);
}
.pixel-color.selected {
    border: 2.5px solid #3f3f74;
    transform: scale(1.12);
    z-index: 1;
}
.pixel-color:hover {
    border: 2.5px solid #222034;
    transform: scale(1.08);
    z-index: 1;
}

#resetBtn, #downloadBtn {
    background: linear-gradient(90deg, #e74c3c 0%, #c0392b 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 13px 38px;
    font-size: 1.18em;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(60,60,120,0.10);
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    letter-spacing: 0.5px;
    margin: 0;
    min-height: 0;
    line-height: 1.1;
    display: inline-block;
}
#downloadBtn {
    background: linear-gradient(90deg, #3f3f74 0%, #222034 100%);
}
#resetBtn:hover, #resetBtn:focus {
    background: linear-gradient(90deg, #c0392b 0%, #e74c3c 100%);
    transform: translateY(-2px) scale(1.04);
    outline: none;
    box-shadow: 0 4px 18px rgba(60,60,120,0.13);
}
#downloadBtn:hover, #downloadBtn:focus {
    background: linear-gradient(90deg, #524b24 0%, #3f3f74 100%);
    transform: translateY(-2px) scale(1.04);
    outline: none;
    box-shadow: 0 4px 18px rgba(60,60,120,0.13);
}

.animation-toggle-btn {
    background: linear-gradient(90deg, #99e550 0%, #6abe30 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 13px 38px;
    font-size: 1.18em;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(60,60,120,0.10);
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    letter-spacing: 0.5px;
    margin: 0;
    min-height: 0;
    line-height: 1.1;
    display: inline-block;
}

.animation-toggle-btn:hover, .animation-toggle-btn:focus {
    background: linear-gradient(90deg, #6abe30 0%, #99e550 100%);
    transform: translateY(-2px) scale(1.04);
    outline: none;
    box-shadow: 0 4px 18px rgba(60,60,120,0.13);
}

.animation-toggle-btn.active {
    background: linear-gradient(90deg, #639bff 0%, #5fcde4 100%);
    box-shadow: 0 4px 18px rgba(60,60,120,0.15);
}

#pipetteBtn, #undoBtn, #redoBtn {
    background: linear-gradient(90deg, #e0e7ff 0%, #99e550 100%);
    color: #222034;
    border: none;
    border-radius: 8px;
    padding: 8px 22px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(60,60,120,0.08);
    transition: background 0.2s, color 0.2s, transform 0.15s, box-shadow 0.2s;
    margin: 0;
    min-height: 0;
    line-height: 1.1;
    display: inline-block;
}
#pipetteBtn {
    background: #e0e0e0;
    color: #888;
}
#pipetteBtn img {
    filter: grayscale(1) brightness(0.7);
    transition: filter 0.2s;
}
#pipetteBtn.active {
    background: linear-gradient(90deg, #639bff 0%, #5fcde4 100%);
    outline: 2px solid #639bff;
    color: #222034;
}
#pipetteBtn.active img {
    filter: none;
}
#undoBtn, #redoBtn {
    background: linear-gradient(90deg, #cbdbfc 0%, #847e87 100%);
    color: #222034;
}
#undoBtn:disabled, #redoBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
#pipetteBtn:hover, #undoBtn:hover, #redoBtn:hover {
    filter: brightness(0.95);
    transform: translateY(-1px) scale(1.04);
    box-shadow: 0 2px 8px rgba(60,60,120,0.13);
}

@media (max-width: 1000px) {
    .workspace {
        flex-direction: column;
        gap: 16px;
    }
    
    .layers-panel {
        width: 100%;
        max-width: none;
    }
    
    canvas {
        width: 90vw;
        max-width: 90vw;
        aspect-ratio: 1 / 1;
        display: block;
        box-sizing: border-box;
    }
}

@media (max-width: 600px) {
    body { 
        margin-top: 0; 
        padding: 8px;
    }
    
    .main-card { 
        padding: 16px 12px; 
        margin: 8px 0;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    h1 { 
        font-size: 1.4em; 
        margin-bottom: 12px;
    }
    
    .workspace {
        width: 100%;
        gap: 12px;
    }
    
    .drawing-area {
        width: 100%;
        max-width: 100%;
    }
    
    canvas {
        width: 100%;
        max-width: 100%;
        aspect-ratio: 1 / 1;
        display: block;
        box-sizing: border-box;
        border-radius: 12px;
        margin-bottom: 12px;
    }
    
    #palette {
        margin: 12px 0 8px 0;
        gap: 8px;
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
        flex-direction: column;
        align-items: center;
    }
    
    #palette label {
        font-size: 0.85em;
        padding: 6px 10px;
        white-space: nowrap;
        width: auto;
        min-width: 0;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        gap: 6px;
        margin: 0;
    }
    
    #palette label input[type="color"] {
        width: 30px;
        height: 30px;
        padding: 0;
        border: none;
        border-radius: 4px;
    }
    
    #palette label input[type="checkbox"] {
        margin: 0;
        width: 16px;
        height: 16px;
    }
    
    #darkerBtn {
        margin-left: 6px !important;
        padding: 4px 8px !important;
        font-size: 0.8em !important;
    }
    
    .pixel-palette {
        max-width: 100%;
        gap: 6px 8px;
        margin-bottom: 12px;
        justify-content: center;
    }
    
    .pixel-color {
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
    }
    
    #resetBtn, #downloadBtn, .animation-toggle-btn {
        font-size: 1em; 
        padding: 10px 16px;
        margin: 0 4px;
    }
    
    .layers-panel {
        padding: 12px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .layers-header h3 {
        font-size: 1.1em;
    }
    
    .layers-actions {
        flex-direction: column;
        gap: 6px;
    }
    
    .layer-btn {
        font-size: 0.8em;
        padding: 8px 12px;
    }
    
    .layers-list {
        max-height: 200px;
        padding: 6px;
    }
    
    .layer-item {
        padding: 6px 8px;
        gap: 6px;
    }
    
    .layer-thumbnail {
        width: 28px;
        height: 28px;
    }
    
    .layer-name {
        font-size: 0.85em;
    }
    
    .layer-duration {
        font-size: 0.75em;
    }
    
    .move-up-btn, .move-down-btn {
        width: 20px;
        height: 18px;
        font-size: 0.7em;
        padding: 2px 4px;
    }
    
    .animation-controls {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .animation-controls h4 {
        font-size: 0.9em;
        margin-bottom: 8px;
    }
    
    .control-buttons {
        flex-direction: column;
        gap: 6px;
    }
    
    .control-btn {
        font-size: 0.8em;
        padding: 8px 12px;
    }
    
    .speed-control label {
        font-size: 0.8em;
    }
    
    .export-btn {
        font-size: 0.85em;
        padding: 8px 12px;
    }
    
    #pipetteBtn, #undoBtn, #redoBtn {
        padding: 6px 16px;
        font-size: 0.9em;
    }
    
    #pipetteBtn img, #undoBtn img, #redoBtn img {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 400px) {
    .main-card {
        padding: 8px 4px;
        margin: 2px 0;
    }
    
    h1 {
        font-size: 1.1em;
        margin-bottom: 8px;
    }
    
    #palette {
        gap: 4px;
        padding: 0 2px;
        margin: 8px 0 6px 0;
    }
    
    #palette label {
        font-size: 0.75em;
        padding: 3px 6px;
        width: 100%;
        justify-content: center;
        max-width: 240px;
        min-height: 28px;
        box-sizing: border-box;
    }
    
    #palette label input[type="color"] {
        width: 20px;
        height: 20px;
        min-width: 20px;
        min-height: 20px;
    }
    
    #palette label input[type="checkbox"] {
        width: 12px;
        height: 12px;
        min-width: 12px;
        min-height: 12px;
    }
    
    #darkerBtn {
        margin-left: 3px !important;
        padding: 2px 4px !important;
        font-size: 0.7em !important;
        min-width: 0;
        white-space: nowrap;
    }
    
    .pixel-palette {
        gap: 3px 4px;
        margin-bottom: 8px;
    }
    
    .pixel-color {
        width: 18px;
        height: 18px;
        min-width: 18px;
        min-height: 18px;
    }
    
    #resetBtn, #downloadBtn, .animation-toggle-btn {
        font-size: 0.8em;
        padding: 6px 10px;
        margin: 1px;
    }
    
    .layers-panel {
        padding: 6px;
    }
    
    .layer-item {
        padding: 3px 4px;
    }
    
    .layer-thumbnail {
        width: 20px;
        height: 20px;
    }
    
    .layer-name {
        font-size: 0.75em;
    }
    
    .layer-duration {
        font-size: 0.65em;
    }
}

@media (max-width: 320px) {
    .main-card {
        padding: 4px 2px;
        margin: 1px 0;
        border-radius: 16px;
    }
    
    h1 {
        font-size: 1em;
        margin-bottom: 6px;
    }
    
    #palette {
        gap: 3px;
        padding: 0 1px;
        margin: 6px 0 4px 0;
    }
    
    #palette label {
        font-size: 0.7em;
        padding: 2px 4px;
        max-width: 200px;
        min-height: 24px;
    }
    
    #palette label input[type="color"] {
        width: 18px;
        height: 18px;
        min-width: 18px;
        min-height: 18px;
    }
    
    #palette label input[type="checkbox"] {
        width: 10px;
        height: 10px;
        min-width: 10px;
        min-height: 10px;
    }
    
    #darkerBtn {
        margin-left: 2px !important;
        padding: 1px 3px !important;
        font-size: 0.65em !important;
    }
    
    .pixel-palette {
        gap: 2px 3px;
        margin-bottom: 6px;
    }
    
    .pixel-color {
        width: 16px;
        height: 16px;
        min-width: 16px;
        min-height: 16px;
    }
    
    #resetBtn, #downloadBtn, .animation-toggle-btn {
        font-size: 0.75em;
        padding: 5px 8px;
        margin: 1px;
    }
    
    canvas {
        border-radius: 8px;
        margin-bottom: 8px;
    }
    
    .layers-panel {
        padding: 4px;
        border-radius: 12px;
    }
    
    .layer-item {
        padding: 2px 3px;
    }
    
    .layer-thumbnail {
        width: 18px;
        height: 18px;
    }
    
    .layer-name {
        font-size: 0.7em;
    }
    
    .layer-duration {
        font-size: 0.6em;
    }
    
    .move-up-btn, .move-down-btn {
        width: 16px;
        height: 14px;
        font-size: 0.6em;
        padding: 1px 2px;
    }
} 