:root {
    --bg-color: #f9fbfd;
    --card-bg: #ffffff;
    --text-color: #2c3e50;
    --border-color: #dfe6e9;
    --primary-color: #0984e3;
    --secondary-color: #00b894;
    --danger-color: #d63031;
    --accent-color: #fdcb6e;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 15px;
    text-align: center;
}

.app-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}

header h1 { 
    margin-top: 0; 
    color: var(--primary-color); 
}

/* Toolbar & Button Controls */
.toolbar {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin: 20px 0;
    background: #f1f2f6;
    padding: 12px;
    border-radius: 10px;
}

button, .btn-upload {
    padding: 12px 20px;
    font-size: 15px;
    font-weight: bold;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: transform 0.1s;
    display: inline-block;
}

button:active, .btn-upload:active { 
    transform: scale(0.96); 
}

.btn-primary { background: var(--primary-color); color: white; }
.btn-danger { background: var(--danger-color); color: white; }
.btn-upload { background: var(--secondary-color); color: white; }

/* Palette Styling */
.palette { 
    display: flex; 
    gap: 8px; 
    align-items: center;
    flex-wrap: wrap;
}

.color-swatch {
    width: 32px; 
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
    box-sizing: border-box;
}

.color-swatch:hover { transform: scale(1.1); }
.color-swatch.active { 
    transform: scale(1.25); 
    border: 3px solid #222; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Custom Color Wheel Picker Input */
#customColorPicker {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 36px;
    height: 36px;
    background-color: transparent;
    border: none;
    cursor: pointer;
    border-radius: 50%;
    padding: 0;
    margin-right: 4px;
}

#customColorPicker::-webkit-color-swatch-wrapper { padding: 0; }
#customColorPicker::-webkit-color-swatch {
    border: 2px solid #222;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
#customColorPicker::-moz-color-swatch {
    border: 2px solid #222;
    border-radius: 50%;
}

/* Layered Canvas System */
.game-area {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 15px;
}

.canvas-container { 
    position: relative;
    display: inline-block; 
    width: 500px;
    height: 500px;
    background: #ffffff; 
    border: 3px solid #2c3e50; 
    border-radius: 8px; 
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

#coloringCanvas {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    cursor: crosshair;
}

#outlineCanvas {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    pointer-events: none;
    mix-blend-mode: multiply; /* Allows painting under white background uploaded artwork! */
}

/* Matching Game Layout */
.split-view { display: flex; gap: 40px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.match-source-column, .match-target-column { display: flex; flex-direction: column; gap: 15px; width: 280px; }
.draggable-card {
    padding: 15px; background: #ffeaa7; border: 2px solid #fdcb6e;
    border-radius: 8px; cursor: grab; font-weight: bold; font-size: 16px;
    user-select: none; touch-action: none;
}
.draggable-card.matched { background: #b2bec3; border-color: #636e72; cursor: default; opacity: 0.6; }
.target-slot {
    padding: 15px; min-height: 24px; background: #f1f2f6;
    border: 2px dashed #b2bec3; border-radius: 8px; font-weight: bold;
}
.target-slot.drag-over { background: rgba(9, 132, 227, 0.15); border-color: var(--primary-color); }

/* Quiz Styling Layout */
.quiz-box { padding: 20px; background: #f8f9fa; border-radius: 12px; border: 2px solid var(--border-color); }
.quiz-question { font-size: 22px; color: #2c3e50; margin-bottom: 25px; }
.quiz-options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.option-btn { padding: 15px; background: white; border: 2px solid var(--border-color); font-size: 16px; text-align: left; }
.option-btn:hover { background: #e8f4fd; border-color: var(--primary-color); }

/* Timeline Components */
.timeline-track { display: flex; gap: 15px; justify-content: center; margin: 20px 0; flex-wrap: wrap; }
.timeline-box {
    width: 140px; height: 140px; background: #f1f2f6;
    border: 2px dashed #b2bec3; border-radius: 10px;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
}
.timeline-box.drag-over { background: rgba(0, 184, 148, 0.15); border-color: var(--secondary-color); }
.timeline-pool { display: flex; gap: 15px; justify-content: center; flex-wrap: wrap; padding: 15px; background: #f5f6fa; border-radius: 12px; min-height: 140px; }
.story-panel {
    width: 130px; height: 130px; background: #6c5ce7; color: white;
    border-radius: 8px; display: flex; justify-content: center; align-items: center;
    padding: 10px; box-sizing: border-box; font-size: 14px; font-weight: bold;
    cursor: grab; text-align: center; box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    user-select: none; touch-action: none;
}
.story-panel.placed { cursor: default; box-shadow: none; }

@media (max-width: 550px) { 
    .quiz-options-grid { grid-template-columns: 1fr; } 
    .canvas-container { width: 100%; max-width: 350px; height: 350px; }
    #coloringCanvas, #outlineCanvas { width: 100% !important; height: 100% !important; }
}