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

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f8f9fa;
    color: #333;
    overflow-x: hidden;
}

.header {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 600;
    margin: 0;
}

.container {
    display: flex;
    max-width: 1200px;
    margin: 2rem auto;
    gap: 2rem;
    padding: 0 2rem;
    height: calc(100vh - 200px);
}

.main-content {
    flex: 1;
    position: relative;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

#canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.canvas-overlay {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    padding: 0.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.grid-toggle label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.control-panel {
    width: 280px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    height: fit-content;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.control-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e9ecef;
}

.control-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.control-section h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.control-section label {
    display: block;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: #555;
}

.control-section select,
.control-section input[type="range"] {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
}

.control-section select {
    background: white;
    cursor: pointer;
}

.control-section input[type="range"] {
    height: 6px;
    background: #e9ecef;
    outline: none;
    -webkit-appearance: none;
    border: none;
    border-radius: 3px;
}

.control-section input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #0080FF;
    border-radius: 50%;
    cursor: pointer;
}

.control-section input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #0080FF;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.play-pause-btn {
    background: #0080FF;
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    cursor: pointer;
    margin-bottom: 1rem;
    display: block;
    margin-left: auto;
    margin-right: auto;
    transition: background-color 0.2s;
}

.play-pause-btn:hover {
    background: #0066cc;
}

#speedValue {
    font-weight: 600;
    color: #0080FF;
}

.color-palette {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.color-swatch {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
}

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

.color-swatch.selected {
    border-color: #333;
    transform: scale(1.1);
}

.bottom-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
    flex-wrap: wrap;
}

.bottom-controls button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.bottom-controls button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.bottom-controls button:active {
    transform: translateY(0);
}

#generateGrid {
    background: linear-gradient(135deg, #FF1493 0%, #FF6B6B 100%);
}

#randomize {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #333;
}

#saveFrame {
    background: linear-gradient(135deg, #228B22 0%, #32CD32 100%);
}

#clearCanvas {
    background: linear-gradient(135deg, #666 0%, #888 100%);
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
        height: auto;
        padding: 0 1rem;
    }
    
    .control-panel {
        width: 100%;
        max-height: none;
    }
    
    .header-content {
        padding: 0 1rem;
    }
    
    .logo h1 {
        font-size: 1.4rem;
    }
    
    .main-content {
        height: 400px;
    }
    
    .bottom-controls {
        padding: 0 1rem;
    }
    
    .bottom-controls button {
        flex: 1;
        min-width: 120px;
    }
}

/* Scrollbar styling */
.control-panel::-webkit-scrollbar {
    width: 6px;
}

.control-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.control-panel::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.control-panel::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}