/* --- RESET & BASE --- */
* {
    box-sizing: border-box;
}

html, body {
    min-height: 100vh;
    background-color: #b0b0b0; /* Neutral background provides contrast for the toy */
    font-family: system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px; /* Vertical spacing between header/controls and the toy */
}

h1 {
    margin: 0;
    color: #333;
    font-size: 2.5rem;
    text-shadow: 0 1px 2px rgba(255,255,255,0.5);
}

/* =========================================
   Control Bar
   ========================================= */

.controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 972px; /* Aligned with etch-frame width for visual consistency */
    background: #e0e0e0;
    padding: 12px 24px;
    border-radius: 16px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    flex-wrap: wrap;
    gap: 20px;
    border: 1px solid rgba(255,255,255,0.4);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.control-group.tools {
    flex-grow: 1;
    justify-content: center;
}

.button-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.separator {
    width: 1px;
    height: 32px;
    background-color: rgba(0,0,0,0.2);
    margin: 0 12px;
}

/* Button Styles */
.btn {
    height: 40px;
    padding: 0 16px;
    border: 1px solid rgba(0,0,0,0.1);
    background-color: #f5f5f5;
    border-radius: 8px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.1s ease-in-out;
    box-shadow: 0 3px 0 rgba(0,0,0,0.15);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:hover:not([aria-pressed="true"]) {
    background-color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 5px 0 rgba(0,0,0,0.15);
}

.btn:active, 
.btn[aria-pressed="true"] {
    background-color: #d4d4d4;
    color: #000;
    transform: translateY(2px);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
    border-color: rgba(0,0,0,0.2);
}

.btn-destructive {
    color: #c00;
    background-color: #fff5f5;
    border: 1px solid #ffcccc;
}
.btn-destructive:hover {
    background-color: #ffe0e0;
}

/* Sliders & Inputs */
.range-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.range-wrapper.brightness-wrapper {
    flex-direction: row;
    gap: 8px;
}

.control-label {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #555;
}

.value-display {
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 50px;
    text-align: center;
}

.icon-label { font-size: 1.2rem; }

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 6px;
    background: rgba(0,0,0,0.15);
    border-radius: 10px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #333;
    cursor: pointer;
    transition: transform 0.1s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* Color Picker Wrapper */
.color-picker-wrapper {
    height: 40px;
    width: 40px;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 3px 0 rgba(0,0,0,0.15);
    cursor: pointer;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
}

.color-picker-wrapper:hover { transform: translateY(-2px); box-shadow: 0 5px 0 rgba(0,0,0,0.15); }
.color-picker-wrapper:active { transform: translateY(2px); box-shadow: inset 0 2px 4px rgba(0,0,0,0.2); }

input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    width: 150%;
    height: 150%;
    cursor: pointer;
    background: none;
    padding: 0;
    margin: -10px;
}

/* =========================================
   Etch-a-Sketch Toy Frame
   ========================================= */

.etch-frame {
    position: relative;
    background-color: #d02026; /* Classic red frame color */
    border-radius: 40px;
    /* Extended horizontal padding mimics the physical toy's proportions */
    padding: 24px 150px 40px 150px; 
    
    /* 3D shadow effect creates depth for the plastic toy aesthetic */
    box-shadow: 0 10px 18px rgba(0, 0, 0, 0.4);
        
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* Screen bezel provides depth and frames the drawing area */
.screen-bezel {
    background-color: #4f4f55; /* Dark grey plastic bezel */
    padding: 16px;
    border-radius: 24px;
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.6);
}

/* Drawing canvas container */
.container {
    display: flex;
    flex-wrap: wrap;
    width: 640px;
    height: 640px;
    border: 2px solid #111;
    background-color: #2b2b30; /* Dark background for contrast */
    box-sizing: content-box;
    cursor: crosshair;
}

.square {
    border: 1px solid rgba(0, 0, 0, 0.06);
    background-color: #fff;
}

/* Decorative knobs positioned at the bottom of the frame */
.knob {
    position: absolute;
    bottom: 16px; /* Aligned with the bottom edge of the red frame */
    width: 64px;
    height: 64px;
    background: radial-gradient(circle at 30% 30%, #ffffff 0, #e6e6e6 40%, #cccccc 70%, #b0b0b0 100%);
    border-radius: 50%;
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.5), 
        inset 0 0 6px rgba(0, 0, 0, 0.35);
    border: 2px solid #f5f5f5;
}

.knob-left {
    left: 40px;
}

.knob-right {
    right: 40px;
}