:root {
    --background: #18181b;
    --foreground: #fafafa;
    --muted: #27272a;
    --muted-foreground: #a1a1aa;
    --border: #27272a;
    --input: #27272a;
    --primary: #fafafa;
    --primary-foreground: #18181b;
    --ring: #27272a;
    --radius: 0.5rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

body {
    display: flex;
    min-height: 100vh;
    background-color: var(--background);
    color: var(--foreground);
    flex-direction: row;
    /* Default flex-direction for larger screens */
    flex-wrap: wrap;
    /* Allow for wrapping */
}

#sidebar {
    width: 300px;
    max-width: 100%;
    /* Ensure sidebar can shrink on smaller screens */
    padding: 1.5rem;
    background-color: var(--background);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground);
}

input[type="range"] {
    width: 100%;
    height: 0.25rem;
    background-color: var(--muted);
    border-radius: var(--radius);
    appearance: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 1rem;
    height: 1rem;
    background-color: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background-color: var(--muted-foreground);
}

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

.slider-info span {
    min-width: 3.5rem;
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

select {
    width: 100%;
    padding: 0.5rem;
    border-radius: var(--radius);
    background-color: var(--input);
    border: 1px solid var(--border);
    color: var(--foreground);
    font-size: 0.875rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

select:focus {
    border-color: var(--ring);
}

button {
    width: 100%;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    background-color: var(--primary);
    color: var(--primary-foreground);
    border: none;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
}

button:hover {
    opacity: 0.9;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.stats {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

#main-content {
    flex: 1;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--background);
    max-width: 100%;
    /* Prevent content from being too wide */
}

canvas {
    background-color: var(--muted);
}

/* Mobile-first responsiveness */
@media (max-width: 768px) {
    body {
        flex-direction: column;
        /* Stack the sidebar and main content vertically */
    }

    #sidebar {
        width: 100%;
        padding: 1rem;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    #main-content {
        padding: 1rem;
    }

    .slider-info {
        flex-direction: column;
        align-items: flex-start;
    }

    button,
    select,
    input[type="range"] {
        width: 100%;
    }
}

@media (max-width: 480px) {
    #sidebar {
        padding: 0.5rem;
    }

    .control-group {
        gap: 0.5rem;
    }

    label {
        font-size: 0.75rem;
    }

    .slider-info span {
        font-size: 0.75rem;
    }

    button {
        padding: 0.5rem;
        font-size: 0.75rem;
    }

    .stats {
        font-size: 0.75rem;
    }
}

/* Ensure flexibility on larger screens */
@media (min-width: 1200px) {
    body {
        flex-direction: row;
        /* Ensure sidebar and content are side by side */
    }

    #sidebar {
        width: 300px;
        /* Fixed width for sidebar on larger screens */
        padding: 1.5rem;
    }

    #main-content {
        flex: 1;
        /* Main content takes up remaining space */
    }
}
