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

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

.intervals-container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

main {
    padding: 40px;
}

/* Keyboard Section */
.keyboard-section {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
}

.keyboard-section h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

#keyboardCanvas {
    width: 100%;
    height: 120px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: block;
    cursor: pointer;
}

.keyboard-info {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.selected-notes {
    display: flex;
    gap: 20px;
    font-size: 0.95rem;
    color: #2c3e50;
}

/* Controls Section */
.controls-section {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
}

.playback-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.play-button, .stop-button {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.play-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.play-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.stop-button {
    background: #e74c3c;
    color: white;
}

.stop-button:hover:not(:disabled) {
    background: #c0392b;
}

.play-button:disabled, .stop-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.interval-selection, .note-selection, .waveform-control {
    margin-bottom: 20px;
}

.interval-selection h4, .note-selection h4, .waveform-control h4 {
    color: #2c3e50;
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.preset-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.preset-btn {
    padding: 10px 15px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    color: #2c3e50;
}

.preset-btn:hover {
    border-color: #667eea;
    background: #f0f3ff;
}

.note-controls {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.note-control-group {
    flex: 1;
    min-width: 200px;
}

.note-control-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
}

.note-control-group select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
    margin-right: 8px;
}

.note-control-group input[type="range"] {
    width: calc(100% - 60px);
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    vertical-align: middle;
}

.note-control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
}

#semitonesValue {
    display: inline-block;
    width: 40px;
    text-align: center;
    font-weight: 600;
    color: #667eea;
}

.wave-type-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.wave-type-btn {
    padding: 10px 15px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    color: #2c3e50;
}

.wave-type-btn:hover {
    border-color: #667eea;
    background: #f0f3ff;
}

.wave-type-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Interval Info Section */
.interval-info-section {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
}

.interval-info-section h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

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

.info-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.info-card h4 {
    color: #7f8c8d;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.info-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #667eea;
}

/* Waveform Section */
.waveform-section {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
}

.waveform-section h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.waveform-display {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.wave-row {
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.wave-label {
    color: #2c3e50;
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.wave-row canvas {
    width: 100%;
    height: 80px;
    display: block;
}

/* Spectrum Section */
.spectrum-section {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
}

.spectrum-section h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

#spectrumCanvas {
    width: 100%;
    height: 250px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: block;
}

.spectrum-legend {
    display: flex;
    gap: 20px;
    margin-top: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #2c3e50;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.root-fundamental {
    background: #27ae60;
}

.interval-fundamental {
    background: #e74c3c;
}

.harmonics {
    background: #f39c12;
}

/* Harmonics Section */
.harmonics-section {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
}

.harmonics-section h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.harmonics-table {
    overflow-x: auto;
}

.harmonics-table table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
}

.harmonics-table th {
    background: #667eea;
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: 600;
}

.harmonics-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #ecf0f1;
    color: #2c3e50;
}

.harmonics-table tr:last-child td {
    border-bottom: none;
}

.harmonics-table tr:nth-child(even) {
    background: #f8f9fa;
}

/* Formulas Section */
.formulas-section {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
}

.formulas-section h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

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

.formula-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.formula-card.highlight {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.formula-card.highlight h4,
.formula-card.highlight .formula-variables {
    color: white;
}

.formula-card h4 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1rem;
}

.formula {
    font-size: 1.3rem;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 10px;
    font-family: 'Courier New', monospace;
}

.formula-card.highlight .formula {
    color: white;
}

.formula-list {
    font-size: 0.9rem;
    color: #667eea;
}

.formula-list div {
    margin-bottom: 5px;
}

.formula-variables {
    font-size: 0.85rem;
    color: #7f8c8d;
}

/* Explanation Section */
.explanation {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 30px;
}

.explanation h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.8rem;
}

.explanation h3 {
    color: #34495e;
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 1.4rem;
}

.explanation p {
    color: #555;
    line-height: 1.8;
    margin-bottom: 15px;
}

.applications-list {
    list-style: none;
    padding: 0;
}

.applications-list li {
    background: white;
    padding: 15px;
    margin-bottom: 12px;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    color: #555;
    line-height: 1.6;
}

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

.tip-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tip-card h4 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.tip-card p {
    color: #555;
    line-height: 1.6;
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }

    main {
        padding: 20px;
    }

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

    .wave-type-buttons {
        grid-template-columns: repeat(2, 1fr);
    }

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