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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

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

h1 {
    text-align: center;
    color: #2d3748;
    margin-bottom: 10px;
    font-size: 2.5rem;
}

.subtitle {
    text-align: center;
    color: #718096;
    margin-bottom: 30px;
    font-size: 1.1rem;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.toggle-group {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f7fafc;
    padding: 12px 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.toggle-group label {
    font-weight: 600;
    color: #4a5568;
}

input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.time-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 8px 16px;
    margin: 0 2px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.time-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.time-btn.active {
    background: rgba(255, 255, 255, 0.5);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.preset-btn {
    background: white;
    border: 2px solid #e2e8f0;
    color: #4a5568;
    padding: 6px 14px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.preset-btn:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
}

.preset-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

.chart-container {
    display: flex;
    gap: 15px;
    margin: 30px 0;
}

.chart-wrapper {
    flex: 1;
    position: relative;
    height: 600px;
    background: white;
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chart-sidebar {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 140px;
}

.rainbow-key, .zoom-controls {
    background: white;
    border-radius: 10px;
    padding: 15px 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.zoom-controls {
    gap: 10px;
}

.zoom-btn {
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    color: #4a5568;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    width: 100%;
}

.zoom-btn:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.zoom-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

.key-title {
    font-weight: bold;
    color: #2d3748;
    text-align: center;
    font-size: 0.9rem;
    margin-bottom: 5px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
}

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

.key-color {
    width: 20px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}

.key-item span {
    font-size: 0.75rem;
    color: #4a5568;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.stat-card h3 {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 5px;
}

.stat-card p {
    font-size: 1.8rem;
    font-weight: bold;
}

/* Custom controls specific styles */
#customControls .toggle-group {
    background: #f7fafc;
    padding: 15px;
}

#customControls label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #4a5568;
}

#customControls input[type="range"] {
    width: 100%;
}

/* Explainer Section */
.explainer {
    margin-top: 60px;
    padding: 40px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border-radius: 20px;
    border: 2px solid rgba(102, 126, 234, 0.2);
}

.explainer h2 {
    text-align: center;
    color: #2d3748;
    font-size: 2rem;
    margin-bottom: 40px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.insight-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.insight-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 15px;
    padding: 25px;
    transition: transform 0.3s, box-shadow 0.3s;
}

.insight-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.insight-card h3 {
    color: #2d3748;
    font-size: 1.2rem;
    margin-bottom: 15px;
}

.insight-card p {
    color: #4a5568;
    line-height: 1.6;
    font-size: 0.95rem;
}

.key-insight {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 20px;
    padding: 30px;
    color: white;
    text-align: center;
}

.key-insight h3 {
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.key-insight p {
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 20px;
    opacity: 0.95;
}

.key-insight .formula {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 20px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    text-align: left;
    display: inline-block;
    margin: 0 auto;
}

.key-insight .formula strong {
    color: #ffd700;
}

/* Responsive design */
@media (max-width: 768px) {
    h1 {
        font-size: 1.8rem;
    }

    .chart-container {
        flex-direction: column;
    }

    .chart-wrapper {
        height: 400px;
    }

    .chart-sidebar {
        width: 100%;
        flex-direction: row;
        gap: 10px;
    }

    .rainbow-key, .zoom-controls {
        flex: 1;
    }

    .rainbow-key {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 5px;
    }

    .rainbow-key .key-title {
        grid-column: 1 / -1;
    }

    .zoom-controls {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }

    .zoom-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .insight-grid {
        grid-template-columns: 1fr;
    }

    .explainer {
        padding: 20px;
    }
}