body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #f0f0f0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

canvas {
    display: block;
    flex-grow: 1;
    touch-action: none;
    background-color: #ffffff;
}

/* Barre d'outils */
#toolbar {
    background: #ffffff;
    border-top: 2px solid #ddd;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 10;
}

.tool-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.color-palette {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 5px;
    max-width: 100%;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #ddd;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.color-swatch.active {
    transform: scale(1.2);
    border-color: #333;
}

.tool-group {
    display: flex;
    gap: 5px;
    align-items: center;
    background: #f8f8f8;
    padding: 5px;
    border-radius: 8px;
}

.tool-btn {
    width: 44px;
    height: 44px;
    font-size: 20px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-btn.active {
    background: #e0f0ff;
    border-color: #007bff;
}

/* Taille du pinceau */
.size-picker {
    display: flex;
    align-items: center;
    gap: 10px;
}

#size-slider {
    width: 100px;
}

#size-preview {
    width: 20px;
    height: 20px;
    background: #333;
    border-radius: 50%;
}

/* Galerie Overlay */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.overlay-content {
    background: white;
    width: 100%;
    max-width: 800px;
    max-height: 80vh;
    border-radius: 15px;
    padding: 20px;
    overflow-y: auto;
    text-align: center;
}

.drawing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.drawing-item {
    cursor: pointer;
    transition: transform 0.2s;
    border: 3px solid transparent;
    border-radius: 10px;
    overflow: hidden;
    background: #f9f9f9;
}

.drawing-item:hover {
    transform: scale(1.05);
    border-color: #007bff;
}

.drawing-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    display: block;
}

.drawing-item span {
    display: block;
    padding: 8px;
    font-size: 14px;
    font-weight: bold;
    background: white;
}

.loading {
    padding: 40px;
    font-style: italic;
    color: #666;
}

/* Responsive tweaks */
@media (max-width: 600px) {
    .tool-btn { width: 40px; height: 40px; font-size: 18px; }
    #size-slider { width: 60px; }
}