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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 30px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    color: white;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

header .subtitle {
    font-size: 1.2em;
    opacity: 0.9;
}

/* Main Content */
.main-content {
    margin-bottom: 30px;
}

/* Canvas Section */
.canvas-section {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.canvas-container {
    background: #000;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 20px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}

#colorCanvas {
    display: block;
    width: 100%;
    height: 500px;
    border-radius: 5px;
    background: #000;
}

/* Legend */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 15px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-color {
    width: 30px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid #333;
}

.legend-color.red {
    background: #ff0000;
}

.legend-color.green {
    background: #00ff00;
}

.legend-color.blue {
    background: #0000ff;
}

/* Controls Section */
.controls-section {
    margin-bottom: 20px;
}

.controls-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
}

.control-card {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.control-card h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.3em;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
}

.control-item {
    margin-bottom: 15px;
}

.control-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.value-display {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: bold;
    min-width: 40px;
    text-align: center;
}

input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    border: none;
}

/* Color Preview */
.color-preview {
    height: 30px;
    border-radius: 4px;
    margin-top: 8px;
    border: 2px solid #ddd;
}

/* Preset Buttons */
.preset-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.preset-btn {
    padding: 12px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.preset-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.6);
}

.preset-btn:active {
    transform: translateY(0);
}

.preset-btn[data-preset="white"] { background: #ffffff; color: #000; }
.preset-btn[data-preset="yellow"] { background: #ffff00; color: #000; }
.preset-btn[data-preset="magenta"] { background: #ff00ff; color: #fff; }
.preset-btn[data-preset="cyan"] { background: #00ffff; color: #000; }
.preset-btn[data-preset="red"] { background: #ff0000; color: #fff; }
.preset-btn[data-preset="green"] { background: #00ff00; color: #000; }
.preset-btn[data-preset="blue"] { background: #0000ff; color: #fff; }

/* Radio Group */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px;
    background: white;
    border-radius: 8px;
    transition: background 0.3s;
}

.radio-group label:hover {
    background: #e9ecef;
}

.radio-group input[type="radio"] {
    margin: 0;
    cursor: pointer;
}

/* Mixed Color Section */
.mixed-color-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.color-display-card,
.formulas-card,
.display-options-card {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.color-display-card h3,
.formulas-card h3,
.display-options-card h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.3em;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
}

.mixed-color-preview {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.1);
}

.color-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.color-value {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.color-value .label {
    font-weight: 600;
    color: #555;
}

.color-value .value {
    font-family: 'Courier New', monospace;
    color: #667eea;
    font-weight: bold;
}

/* Formula Display */
.formula-display {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.formula-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.formula-label {
    font-weight: 600;
    color: #333;
}

.formula-result {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #667eea;
}

/* Checkbox Group */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s;
}

.checkbox-item:hover {
    background: #e9ecef;
}

.checkbox-item input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.checkbox-item label {
    cursor: pointer;
    margin: 0;
    flex: 1;
}

/* Comparison Section */
.comparison-section {
    margin-bottom: 30px;
}

.comparison-card {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.comparison-card h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.3em;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
}

.comparison-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comparison-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.comparison-row.header {
    background: #667eea;
    color: white;
    font-weight: bold;
}

.comparison-cell {
    padding: 8px;
    text-align: center;
}

.comparison-cell.white {
    background: #ffffff;
    color: #000;
    font-weight: bold;
}

.comparison-cell.black {
    background: #000000;
    color: #fff;
    font-weight: bold;
}

/* Educational Content */
.educational-content {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.education-section {
    margin-bottom: 25px;
    padding: 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.education-section h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.4em;
}

.education-section p {
    line-height: 1.8;
    color: #333;
    text-align: justify;
}

.education-section strong {
    color: #667eea;
    font-weight: 700;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .controls-row {
        grid-template-columns: 1fr;
    }

    .mixed-color-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 1.8em;
    }

    header .subtitle {
        font-size: 1em;
    }

    #colorCanvas {
        height: 350px;
    }

    .preset-buttons {
        grid-template-columns: 1fr;
    }

    .comparison-row {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .legend {
        flex-direction: column;
    }
}