.assignment-context-card {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    color: #14532d;
}

.assignment-context-card span {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
}

.assignment-context-card h2 {
    margin: 0.25rem 0;
    font-size: 1.2rem;
    color: #14532d;
}

.assignment-context-card p,
.assignment-context-card strong {
    margin: 0;
}

.assignment-context-card--error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #7f1d1d;
}

.assignment-context-card--error h2 {
    color: #7f1d1d;
}

@media (max-width: 640px) {
    .assignment-context-card {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Modern Piano Interface /* Piano Section */
.piano-section {
    background: linear-gradient(135deg, #2a2a3a 0%, #1a1a2a 100%);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    box-sizing: border-box;
}overflow: hidden;
}

.piano-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 20%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 70% 80%, rgba(168, 85, 247, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

/* Digital Display */
.piano-display {
    background: linear-gradient(135deg, #0f0f0f 0%, #1a1a1a 100%);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    text-align: center;
    border: 2px solid rgba(139, 92, 246, 0.3);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.2);
    position: relative;
    z-index: 2;
}

.piano-display-note {
    font-family: 'JetBrains Mono', monospace;
    font-size: 3rem;
    font-weight: 700;
    color: #8b5cf6;
    text-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
    margin-bottom: 0.5rem;
    letter-spacing: 0.1em;
}

.piano-display-instrument {
    font-family: 'Inter', sans-serif;
    font-size: 1.1rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Piano Controls */
.piano-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 2;
}

.piano-control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.piano-control-group label {
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.control-select {
    background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    border: 2px solid rgba(139, 92, 246, 0.3);
    border-radius: 8px;
    color: #ffffff;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    min-width: 140px;
    transition: all 0.3s ease;
}

.control-select:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.3);
}

.control-select option {
    background: #2a2a2a;
    color: #ffffff;
}

/* Volume Slider */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 120px;
    height: 6px;
    background: linear-gradient(to right, #8b5cf6 0%, #8b5cf6 80%, rgba(255, 255, 255, 0.2) 80%, rgba(255, 255, 255, 0.2) 100%);
    border-radius: 3px;
    outline: none;
    transition: all 0.3s ease;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
    transition: all 0.3s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.8);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
    transition: all 0.3s ease;
}

/* Checkbox Toggle - Only for specific piano controls */
#key-label-toggle {
    appearance: none;
    width: 50px;
    height: 26px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

#key-label-toggle:checked {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    border-color: #8b5cf6;
}

#key-label-toggle::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #ffffff;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#key-label-toggle:checked::before {
    transform: translateX(24px);
}

/* Standard checkboxes for settings */
.settings-grid input[type="checkbox"],
.settings-options input[type="checkbox"],
.select-all-checkbox {
    appearance: auto;
    width: auto;
    height: auto;
    background: initial;
    border-radius: initial;
    position: initial;
}

/* Piano Keys Container */
.piano {
    display: flex;
    justify-content: center;
    position: relative;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
    border-radius: 15px;
    padding: 3rem 2rem;
    box-shadow: inset 0 10px 30px rgba(0, 0, 0, 0.8);
    z-index: 2;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    min-height: 280px;
}

/* White Keys */
.white-key {
    width: 60px;
    height: 220px;
    background: linear-gradient(to bottom, 
        #ffffff 0%, 
        #f8f8f8 20%, 
        #f0f0f0 40%, 
        #e8e8e8 60%, 
        #e0e0e0 80%, 
        #d8d8d8 100%);
    border: 3px solid #c0c0c0;
    border-top: 4px solid #ffffff;
    border-left: 4px solid #f0f0f0;
    border-right: 4px solid #c0c0c0;
    border-bottom: 4px solid #a0a0a0;
    border-radius: 0 0 12px 12px;
    margin: 0 1px;
    position: relative;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 
        0 15px 30px rgba(0, 0, 0, 0.5),
        inset 0 2px 4px rgba(255, 255, 255, 0.8),
        inset 0 -2px 4px rgba(0, 0, 0, 0.1);
}

.white-key:hover {
    background: linear-gradient(to bottom, 
        #f0f0f0 0%, 
        #e8e8e8 20%, 
        #e0e0e0 40%, 
        #d8d8d8 60%, 
        #d0d0d0 80%, 
        #c8c8c8 100%);
    transform: translateY(3px);
    box-shadow: 
        0 12px 24px rgba(0, 0, 0, 0.6),
        inset 0 2px 4px rgba(255, 255, 255, 0.7),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2);
}

.white-key:active,
.white-key.key-pressed {
    background: linear-gradient(to bottom, 
        #e0e0e0 0%, 
        #d8d8d8 20%, 
        #d0d0d0 40%, 
        #c8c8c8 60%, 
        #c0c0c0 80%, 
        #b8b8b8 100%);
    transform: translateY(8px);
    box-shadow: 
        0 8px 16px rgba(0, 0, 0, 0.7),
        inset 0 4px 8px rgba(0, 0, 0, 0.4),
        inset 0 -1px 2px rgba(255, 255, 255, 0.3);
    border-top: 2px solid #d0d0d0;
    border-left: 2px solid #c0c0c0;
    border-right: 2px solid #a0a0a0;
    border-bottom: 2px solid #808080;
}

/* Black Keys */
.black-key {
    width: 36px;
    height: 140px;
    background: linear-gradient(to bottom, 
        #4a4a4a 0%, 
        #3a3a3a 20%, 
        #2a2a2a 40%, 
        #1a1a1a 60%, 
        #0a0a0a 80%, 
        #000000 100%);
    border: 3px solid #000000;
    border-top: 3px solid #666666;
    border-left: 3px solid #444444;
    border-right: 3px solid #000000;
    border-bottom: 3px solid #000000;
    border-radius: 0 0 8px 8px;
    position: absolute;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 
        0 15px 30px rgba(0, 0, 0, 0.8),
        inset 0 2px 4px rgba(255, 255, 255, 0.2),
        inset 0 -2px 4px rgba(0, 0, 0, 0.8);
    z-index: 10;
}

.black-key:hover {
    background: linear-gradient(to bottom, 
        #5a5a5a 0%, 
        #4a4a4a 20%, 
        #3a3a3a 40%, 
        #2a2a2a 60%, 
        #1a1a1a 80%, 
        #0a0a0a 100%);
    transform: translateY(3px);
    box-shadow: 
        0 12px 24px rgba(0, 0, 0, 0.9),
        inset 0 2px 4px rgba(255, 255, 255, 0.3),
        inset 0 -2px 4px rgba(0, 0, 0, 0.9);
}

.black-key:active,
.black-key.key-pressed {
    background: linear-gradient(to bottom, 
        #2a2a2a 0%, 
        #1a1a1a 20%, 
        #0a0a0a 40%, 
        #000000 60%, 
        #000000 80%, 
        #000000 100%);
    transform: translateY(6px);
    box-shadow: 
        0 8px 16px rgba(0, 0, 0, 1.0),
        inset 0 4px 8px rgba(0, 0, 0, 0.9),
        inset 0 -1px 2px rgba(255, 255, 255, 0.1);
    border-top: 2px solid #333333;
    border-left: 2px solid #222222;
    border-right: 2px solid #000000;
    border-bottom: 2px solid #000000;
}

/* Key Labels */
.key-label {
    position: absolute;
    bottom: 20px;
    width: 100%;
    text-align: center;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: #666;
    display: none;
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.black-key .key-label {
    color: #ccc;
    bottom: 15px;
    font-size: 12px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Show labels when toggle is active */
.show-labels .key-label {
    display: block;
}

/* Active key highlighting */
.key-active {
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.8);
    border-color: #8b5cf6;
}

.white-key.key-active {
    /* Stronger purple tint for active white keys */
    background: linear-gradient(to bottom, #ede9fe 0%, #ddd6fe 50%, #c4b5fd 100%);
}

.black-key.key-active {
    /* Opaque brand purple to avoid underlying gaps showing through */
    background: linear-gradient(to bottom, #8b5cf6 0%, #7c3aed 50%, #6d28d9 100%);
}

/* Responsive Design */
@media (max-width: 768px) {
    .piano-controls {
        flex-direction: column;
        gap: 1rem;
    }
    
    .piano-control-group {
        flex-direction: row;
        width: 100%;
        justify-content: space-between;
    }
    
    .piano-display-note {
        font-size: 2rem;
    }
    
    .white-key {
        width: 45px;
        height: 180px;
    }
    
    .black-key {
        width: 28px;
        height: 110px;
    }
    
    .piano {
        padding: 2rem 1rem;
        min-height: 240px;
    }
}

/* Legacy styles for compatibility */
.progress-bar {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    min-height: 4px;
}

.progress-line {
    width: 20px;
    height: 4px;
    background-color: #555;
    margin: 0 2px;
    border-radius: 2px;
}

.progress-step.correct {
    background-color: #22c55e;
}

.progress-step.incorrect {
    background-color: #ef4444;
}

.progress-step.player1-first {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-color: #16a34a;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.35);
}

.progress-step.player2-second {
    background: linear-gradient(135deg, #f97373, #dc2626);
    border-color: #dc2626;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.35);
}

.progress-step.player1-first.player2-second {
    background: linear-gradient(135deg, #22c55e 0%, #22c55e 50%, #dc2626 50%, #dc2626 100%);
    border-color: #dc2626;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.45);
}

.ear-symbol {
    font-size: 5rem;
    color: #777;
    animation: none;
}

.ear-symbol.playing {
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.ear-training-panel {
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(to bottom, #444, #333);
    border-radius: 0 0 0.5rem 0.5rem;
    padding: 1rem;
    margin-top: 1rem;
    min-height: 60px;
}

.ear-training-btn {
    background-color: #555;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    margin: 0 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.ear-training-btn:hover {
    background-color: #777;
}

.ear-training-btn:active {
    transform: scale(0.95);
}

.ear-training-btn.new-question {
    background-color: #f59e0b;
}

.ear-training-btn.new-question:hover {
    background-color: #d97706;
}

.answer-btn {
    background-color: #8b5cf6;
    color: white;
    padding: 0.8rem 1rem;
    border-radius: 0.5rem;
    margin: 0.3rem 0.3rem;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s, border 0.2s;
    font-size: 1rem;
    min-width: 50px;
    text-align: center;
    border: 2px solid transparent;
}

.answer-btn.comparison {
    padding: 1rem 2rem;
    font-size: 1.5rem;
    margin: 0 1rem;
}

.answer-btn:hover {
    background-color: #22c55e;
}

.answer-btn:active {
    transform: scale(0.95);
}

.answer-btn.answer-feedback-correct {
    background-color: #16a34a;
    border-color: #bbf7d0;
    transform: scale(1.05);
}

.answer-btn.answer-feedback-incorrect {
    background-color: #dc2626;
    border-color: #fecaca;
    animation: shake 0.5s;
}

.answer-btn.answer-feedback-reveal {
    border-color: #16a34a;
    box-shadow: 0 0 10px #16a34a;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

.instrument-btn {
    background-color: #666;
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 0.3rem;
    margin: 0 0.3rem;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 0.9rem;
}

.instrument-btn:hover {
    background-color: #8b5cf6;
}

.instrument-btn.active {
    background-color: #8b5cf6;
}

.settings-modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
    padding-top: 60px;
}

.settings-modal-content {
    background-color: #2d2d2d;
    margin: 5% auto;
    padding: 25px;
    border: 1px solid #888;
    width: 80%;
    max-width: 700px;
    border-radius: 1rem;
    color: white;
}

.settings-close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.settings-close-btn:hover,
.settings-close-btn:focus {
    color: #fff;
    text-decoration: none;
}

.settings-section {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #3a3a3a;
    border-radius: 0.5rem;
}

.settings-section h3 {
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 1px solid #555;
    padding-bottom: 5px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 10px;
}

.settings-grid label {
    display: flex;
    align-items: center;
    background-color: #4a4a4a;
    padding: 5px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.settings-grid input[type="checkbox"],
.settings-options input[type="checkbox"],
.select-all-checkbox {
    margin-right: 8px;
    cursor: pointer;
}

.settings-options label {
    margin-right: 15px;
}

.settings-slider-container {
    display: flex;
    align-items: center;
    margin: 10px 0;
}

.settings-slider-container label {
    width: 120px;
    margin-right: 10px;
}

.settings-slider-container input[type="range"] {
    flex-grow: 1;
}

.settings-slider-container span {
    margin-left: 10px;
    min-width: 60px;
    text-align: right;
}

.settings-button-container {
    text-align: right;
    margin-top: 20px;
}

.settings-button {
    background-color: #555;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-left: 10px;
    transition: background-color 0.2s;
}

.settings-button:hover {
    background-color: #777;
}

.settings-button.primary {
    background-color: #3b82f6;
}

.settings-button.primary:hover {
    background-color: #2563eb;
}

.settings-gear-icon {
    font-size: 1.5rem;
    cursor: pointer;
    margin-left: 10px;
    color: #ccc;
    transition: color 0.2s;
}

.settings-gear-icon:hover {
    color: white;
}

.notation-section svg {
    max-width: 100%;
    height: auto;
    background-color: white;
    border-radius: 4px;
    padding: 10px;
}

.navbar-content {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    max-width: 95% !important;
    margin: 0 auto !important;
    gap: 1.5rem !important;
}

.navbar-links {
    display: flex !important;
    justify-content: flex-end !important;
    flex-grow: 1 !important;
    gap: 2rem !important;
    flex-wrap: wrap !important;
    padding: 0rem 1rem !important;
    margin: 0 !important;
}

/* ============================================================
   Styles moved from inline <style> block in ear-training.php
   ============================================================ */
        /* Ear Training Specific Overrides */
        .ear-training-hero {
            padding: 2rem;
            padding-top: 6rem;
            margin-bottom: 1.5rem;
            text-align: center;
            position: relative;
            overflow: hidden;
        }
        
        .ear-training-hero::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: radial-gradient(circle at 20% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
                        radial-gradient(circle at 80% 20%, rgba(168, 85, 247, 0.1) 0%, transparent 50%);
            pointer-events: none;
        }
        
        .hero-content {
            background: linear-gradient(135deg, var(--primary-bg) 0%, var(--secondary-bg) 100%);
            max-width: 1200px;
            margin: 0 auto;
            padding: 3rem;
            position: relative;
            z-index: 2;
            border-radius: 1.5rem;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }
        
        .hero-title {
            font-size: clamp(2.5rem, 5vw, 3.5rem);
            font-weight: 800;
            background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            margin-bottom: 1rem;
            line-height: 1.1;
        }
        
        .hero-subtitle {
            font-size: clamp(1.1rem, 2.5vw, 1.3rem);
            color: var(--text-secondary);
            margin-bottom: 1.5rem;
            line-height: 1.6;
            max-width: 800px;
            margin-left: auto;
            margin-right: auto;
        }
        
        /* Main Training Container */
        .training-container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 1.5rem;
        }
        
        /* Session Status Panel */
        .session-status {
            background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
            border-radius: var(--border-radius-large);
            padding: 1rem 2rem;
            margin-bottom: 1.5rem;
            box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
        }
        
        .session-info {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
            gap: 1.5rem;
            align-items: center;
        }
        
        .session-stat {
            display: flex;
            flex-direction: column;
            align-items: center;
            text-align: center;
        }
        
        .stat-label {
            color: rgba(255, 255, 255, 0.9);
            font-size: 0.85rem;
            font-weight: 500;
            margin-bottom: 0.25rem;
        }
        
        .stat-value {
            color: white;
            font-size: 1.1rem;
            font-weight: 700;
        }
        
        /* Section 1: Control Panel */
        .control-section {
            background: var(--card-bg);
            backdrop-filter: blur(20px);
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius-large);
            padding: 2rem;
            box-shadow: var(--shadow-medium);
            margin-bottom: 1.5rem;
        }
        
        .control-header {
            display: grid;
            grid-template-columns: 1fr auto;
            gap: 2rem;
            align-items: center;
            margin-bottom: 1.5rem;
        }
        
        .training-selector {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
        }
        
        .training-selector label {
            font-size: 1.2rem;
            font-weight: 700;
            color: var(--text-primary);
        }
        
        .mode-select {
            width: 100%;
            max-width: 400px;
            padding: 0.875rem 1rem;
            background: #2a2a2a;
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius);
            color: var(--text-primary);
            font-size: 1rem;
            font-weight: 500;
        }
        
        .mode-select option {
            background: #2a2a2a;
            color: #ffffff;
            padding: 0.5rem;
        }
        
        .mode-select:focus {
            outline: none;
            border-color: #8b5cf6;
            box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
        }
        
        .settings-icon {
            background: var(--card-bg);
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius);
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: var(--transition-fast);
            color: var(--text-secondary);
        }
        
        .settings-icon:hover {
            background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
            transform: scale(1.05);
            box-shadow: 0 6px 16px rgba(139, 92, 246, 0.4);
        }
        
        /* Instruction Text */
        .instruction-text {
            margin: 1.5rem 0;
            padding: 1rem;
            background: rgba(255, 255, 255, 0.05);
            border-radius: var(--border-radius);
            border: 1px solid var(--border-color);
        }
        
        /* Progress Bar */
        .progress-container {
            margin-bottom: 1.5rem;
        }
        
        .progress-bar {
            width: 100%;
            height: 24px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 12px;
            padding: 3px;
            border: 1px solid var(--border-color);
            display: flex;
            gap: 2px;
        }
        
        .progress-step {
            flex: 1;
            height: 100%;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 8px;
            transition: all 0.3s ease;
            border: 1px solid rgba(255, 255, 255, 0.1);
        }
        
        .progress-step.completed {
            background: linear-gradient(135deg, #22c55e, #16a34a);
            border-color: #16a34a;
            box-shadow: 0 0 8px rgba(34, 197, 94, 0.3);
        }
        
        .progress-step.current {
            background: linear-gradient(135deg, #8b5cf6, #7c3aed);
            border-color: #7c3aed;
            box-shadow: 0 0 8px rgba(139, 92, 246, 0.4);
            transform: scaleY(1.1);
        }

        .progress-step.player1-first {
            background: linear-gradient(135deg, #22c55e, #16a34a);
            border-color: #16a34a;
            box-shadow: 0 0 8px rgba(34, 197, 94, 0.35);
        }

        .progress-step.player2-second {
            background: linear-gradient(135deg, #f97373, #dc2626);
            border-color: #dc2626;
            box-shadow: 0 0 8px rgba(239, 68, 68, 0.35);
        }

        .progress-step.player1-first.player2-second {
            background: linear-gradient(135deg, #22c55e 0%, #22c55e 50%, #dc2626 50%, #dc2626 100%);
            border-color: #dc2626;
            box-shadow: 0 0 10px rgba(239, 68, 68, 0.45);
        }

        /* Control Buttons */
        .control-buttons {
            display: flex;
            gap: 1rem;
            justify-content: center;
            flex-wrap: wrap;
        }
        
        .control-btn {
            padding: 0.875rem 1.5rem;
            background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
            color: white;
            border: none;
            border-radius: var(--border-radius);
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
            font-size: 0.95rem;
        }
        
        .control-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
        }
        
        .control-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            transform: none;
        }
        
        .control-btn.secondary {
            background: rgba(255, 255, 255, 0.1);
            color: var(--text-primary);
            border: 1px solid var(--border-color);
        }
        
        .control-btn.secondary:hover {
            background: rgba(255, 255, 255, 0.2);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        }
        
        /* Section 2: Answer Selection */
        .answer-section {
            background: var(--card-bg);
            backdrop-filter: blur(20px);
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius-large);
            padding: 2rem;
            box-shadow: var(--shadow-medium);
            text-align: center;
            margin-bottom: 1.5rem;
        }
        
        .answer-section h3 {
            color: var(--text-primary);
            font-size: 1.2rem;
            font-weight: 700;
            margin-bottom: 1.5rem;
        }
        
        /* Section 3: Piano Interface */
        .piano-section {
            background: var(--card-bg);
            backdrop-filter: blur(20px);
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius-large);
            padding: 2rem;
            box-shadow: var(--shadow-medium);
            margin-bottom: 1.5rem;
        }
        
        /* Notation Container */
        .notation-container {
            background: white;
            backdrop-filter: blur(20px);
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius-large);
            padding: 0.75rem;
            box-shadow: var(--shadow-medium);
            margin-bottom: 1rem;
        }
        
        .notation-container h3,
        .notation-container h4 {
            color: black !important;
        }
        
        /* Modal Overrides */
        .settings-modal {
            display: none;
            position: fixed;
            z-index: 100;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background: rgba(0, 0, 0, 0.8);
            backdrop-filter: blur(10px);
            padding-top: 60px;
        }
        
        .settings-modal-content {
            background: var(--card-bg);
            margin: 5% auto;
            padding: 25px;
            border: 1px solid var(--border-color);
            width: 80%;
            max-width: 700px;
            border-radius: var(--border-radius-large);
            box-shadow: var(--shadow-heavy);
            color: white;
        }

        .settings-close-btn {
            color: #aaa;
            float: right;
            font-size: 28px;
            font-weight: bold;
            cursor: pointer;
        }

        .settings-close-btn:hover,
        .settings-close-btn:focus {
            color: #fff;
            text-decoration: none;
        }

        .settings-section {
            margin-bottom: 20px;
            padding: 15px;
            background-color: rgba(255, 255, 255, 0.05);
            border-radius: 0.5rem;
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .settings-section h3 {
            margin-top: 0;
            margin-bottom: 15px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
            padding-bottom: 5px;
            color: var(--text-primary);
        }

        .settings-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
            gap: 10px;
            max-height: 200px;
            overflow-y: auto;
            padding-right: 10px;
        }

        .settings-grid label {
            display: flex;
            align-items: center;
            background-color: rgba(255, 255, 255, 0.08);
            padding: 5px 8px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 0.9rem;
            color: var(--text-secondary);
            transition: background-color 0.2s;
        }

        .settings-grid label:hover {
            background-color: rgba(255, 255, 255, 0.12);
        }

        .settings-grid input[type="checkbox"],
        .settings-options input[type="checkbox"] {
            margin-right: 8px;
        }
        
        /* Checkbox styling to match relative-ear-training */
        .form-checkbox {
            width: 1.25rem !important;
            height: 1.25rem !important;
            cursor: pointer;
            appearance: auto !important;
            position: static !important;
            background: initial !important;
            border-radius: initial !important;
        }
        
        .form-checkbox::before {
            display: none !important;
        }
        
        .text-gray-300 {
            color: #d1d5db;
        }
        
        .text-blue-600 {
            accent-color: #2563eb;
        }
        
        .h-5 { height: 1.25rem !important; }
        .w-5 { width: 1.25rem !important; }

        .settings-options label {
            margin-right: 15px;
            color: var(--text-secondary);
        }

        .settings-slider-container {
            display: flex;
            align-items: center;
            margin: 10px 0;
        }

        .settings-slider-container label {
            width: 120px;
            margin-right: 10px;
            color: var(--text-secondary);
        }

        .settings-slider-container input[type="range"] {
            flex-grow: 1;
        }

        .settings-slider-container span {
            margin-left: 10px;
            min-width: 60px;
            text-align: right;
            color: var(--text-primary);
        }

        .settings-button-container {
            text-align: right;
            margin-top: 20px;
        }

        .settings-button {
            background-color: rgba(255, 255, 255, 0.1);
            color: white;
            padding: 10px 20px;
            border: 1px solid var(--border-color);
            border-radius: 5px;
            cursor: pointer;
            margin-left: 10px;
            transition: background-color 0.2s;
        }

        .settings-button:hover {
            background-color: rgba(255, 255, 255, 0.2);
        }

        .settings-button.primary {
            background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
            border: none;
        }

        .settings-button.primary:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow-heavy);
        }

        .mb-2 {
            margin-bottom: 0.5rem;
        }

        .ml-2 {
            margin-left: 0.5rem;
        }

        .inline-flex {
            display: inline-flex;
        }

        .items-center {
            align-items: center;
        }

        .select-all-checkbox {
            margin-right: 8px;
        }
        
        /* Trial Limit Modal */
        .trial-modal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.8);
            backdrop-filter: blur(10px);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 9999;
        }
        
        .trial-modal-content {
            background: var(--card-bg);
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius-large);
            padding: 3rem;
            max-width: 500px;
            text-align: center;
            box-shadow: var(--shadow-heavy);
        }
        
        .trial-modal h2 {
            color: var(--text-primary);
            font-size: 1.8rem;
            font-weight: 700;
            margin-bottom: 1rem;
        }
        
        .trial-modal p {
            color: var(--text-secondary);
            margin-bottom: 2rem;
            line-height: 1.6;
        }
        
        .trial-modal-buttons {
            display: flex;
            gap: 1rem;
            justify-content: center;
            flex-wrap: wrap;
        }
        
        .trial-btn {
            padding: 0.875rem 2rem;
            border-radius: var(--border-radius);
            font-weight: 600;
            text-decoration: none;
            transition: var(--transition-smooth);
            display: inline-block;
        }
        
        .trial-btn.primary {
            background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
            color: white;
        }
        
        .trial-btn.primary:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow-heavy);
        }
        
        .trial-btn.secondary {
            background: rgba(255, 255, 255, 0.1);
            color: var(--text-primary);
            border: 1px solid var(--border-color);
        }
        
        .trial-btn.secondary:hover {
            background: rgba(255, 255, 255, 0.2);
        }
        
        /* Vertical Video Styles for Mobile */
        .vertical-video {
            aspect-ratio: 9/16;
            width: auto !important;
            max-width: 100%;
            margin: 0 auto;
            display: block;
        }
        
        @media (max-width: 768px) {
            /* Mobile specific vertical video styling */
            #study-media {
                height: auto !important;
                min-height: 480px;
            }
            
            #study-media-content video {
                max-height: 460px !important;
            }
            
            #study-media-content video.vertical-video {
                max-height: 600px !important;
                width: 100%;
                max-width: 340px;
            }
            
            /* Fullscreen video on mobile */
            video:fullscreen {
                object-fit: contain;
                background: #000;
            }
            
            video:-webkit-full-screen {
                object-fit: contain;
                background: #000;
            }
            
            video:-moz-full-screen {
                object-fit: contain;
                background: #000;
            }
            
            video:-ms-fullscreen {
                object-fit: contain;
                background: #000;
            }
        }
        
        /* Responsive Design */
        @media (max-width: 768px) {
            .ear-training-hero {
                padding: 1rem;
                padding-top: 5rem;
                margin-top: 1.5rem;
            }
            
            .hero-content {
                padding: 2rem 1.5rem;
                max-width: calc(100% - 2rem);
            }
            
            .training-container {
                padding: 1rem;
            }
            
            .control-section,
            .answer-section,
            .piano-section,
            .notation-container {
                padding: 0.75rem;
            }
            
            .control-header {
                grid-template-columns: 1fr;
                gap: 1rem;
            }
            
            .control-buttons {
                flex-direction: column;
                align-items: stretch;
            }
            
            .control-btn {
                width: 100%;
            }
            
            .trial-modal-content {
                margin: 1rem;
                padding: 2rem;
            }
            
            /* Piano section compact controls responsive */
            .piano-section > div:first-child {
                flex-direction: column !important;
                gap: 1rem !important;
                align-items: stretch !important;
            }
            
            .piano-section > div:first-child > div {
                justify-content: space-between !important;
            }
        }
        
        /* Feature Navigation */
        .feature-navigation {
            background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
            border-radius: 12px;
            padding: 1.5rem;
            margin-bottom: 1.5rem;
            color: white;
            text-align: center;
        }
        
        .feature-navigation h3 {
            margin: 0 0 1rem 0;
            font-size: 1.2rem;
            font-weight: 600;
        }
        
        .feature-buttons {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
            gap: 1rem;
        }
        
        .feature-btn {
            background: rgba(255, 255, 255, 0.2);
            color: white;
            padding: 0.75rem 1rem;
            border-radius: 8px;
            text-decoration: none;
            font-weight: 500;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            transition: all 0.2s ease;
            backdrop-filter: blur(10px);
        }
        
        .feature-btn:hover {
            background: rgba(255, 255, 255, 0.3);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        }
        
        .feature-btn i {
            font-size: 1.1rem;
        }
        
        
        /* Enhanced Volume Slider - Inspired by dev reverb/chorus sliders */
        input[type="range"] {
            -webkit-appearance: none;
            appearance: none;
            height: 6px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 3px;
            outline: none;
            transition: all 0.15s ease;
        }
        
        input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 20px;
            height: 20px;
            background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
            border-radius: 50%;
            cursor: pointer;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            transition: all 0.15s ease;
        }
        
        input[type="range"]::-webkit-slider-thumb:hover {
            transform: scale(1.1);
            box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
        }
        
        input[type="range"]::-moz-range-thumb {
            width: 20px;
            height: 20px;
            background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
            border-radius: 50%;
            cursor: pointer;
            border: none;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            transition: all 0.15s ease;
        }
        
        input[type="range"]::-moz-range-thumb:hover {
            transform: scale(1.1);
            box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
        }
        
        /* Piano Interface Styling - From Working Dev Version */
        .piano-container {
            background: linear-gradient(135deg, #2d2d2d, #1a1a1a);
            border-radius: 1rem;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
        }

        .white-key {
            background: linear-gradient(to bottom, #ffffff, #e5e5e5);
            border: 1px solid #666;
            transition: all 0.1s ease;
            position: relative;
        }

        .black-key {
            background: linear-gradient(to bottom, #333, #000);
            border: 1px solid #000;
            transition: all 0.1s ease;
            position: relative;
        }

        .key-pressed {
            transform: translateY(4px);
            box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.4);
        }

        .key-label {
            position: absolute;
            bottom: 10px;
            width: 100%;
            text-align: center;
            font-size: 12px;
            color: #000;
            display: none;
            pointer-events: none;
        }

        .black-key .key-label {
            color: #fff;
        }

        .speaker {
            width: 60px;
            height: 60px;
            background: radial-gradient(circle, #555 10%, #333 50%, #222 100%);
            border-radius: 50%;
            position: relative;
            overflow: hidden;
        }

        .speaker::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 40px;
            height: 40px;
            background: radial-gradient(circle, #777 20%, #444 60%);
            border-radius: 50%;
            transform: translate(-50%, -50%);
        }

        .speaker::after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 20px;
            height: 20px;
            background: #111;
            border-radius: 50%;
            transform: translate(-50%, -50%);
        }

        .control-panel {
            display: flex;
            align-items: center;
            justify-content: space-between;
            background: linear-gradient(to bottom, #444, #333);
            border-radius: 0.5rem 0.5rem 0 0;
            padding: 1rem;
        }

        .arrow-btn {
            background-color: #555;
            color: white;
            width: 30px;
            height: 30px;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: background-color 0.2s;
        }

        .arrow-btn:hover {
            background-color: #777;
        }

        .index-display {
            background-color: #222;
            color: white;
            width: 40px;
            height: 30px;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1rem;
            margin: 0 5px;
        }

        .ear-training-panel {
            display: flex;
            justify-content: center;
            align-items: center;
            background: linear-gradient(to bottom, #444, #333);
            border-radius: 0 0 0.5rem 0.5rem;
            padding: 1rem;
            margin-top: 1rem;
            min-height: 60px;
        }

        .ear-training-btn {
            background-color: #555;
            color: white;
            padding: 0.5rem 1rem;
            border-radius: 0.5rem;
            margin: 0 0.5rem;
            cursor: pointer;
            transition: background-color 0.2s, transform 0.1s;
        }

        .ear-training-btn:hover {
            background-color: #777;
        }

        .ear-training-btn:active {
            transform: scale(0.95);
        }

        .ear-training-btn.new-question {
            background-color: #f59e0b;
        }

        .ear-training-btn.new-question:hover {
            background-color: #d97706;
        }

        .answer-btn {
            background-color: #8b5cf6;
            color: white;
            padding: 0.8rem 1rem;
            border-radius: 0.5rem;
            margin: 0.3rem 0.3rem;
            cursor: pointer;
            transition: background-color 0.2s, transform 0.1s, border 0.2s;
            font-size: 1rem;
            min-width: 50px;
            text-align: center;
            border: 2px solid transparent;
        }

        .answer-btn.comparison {
            padding: 1rem 2rem;
            font-size: 1.5rem;
            margin: 0 1rem;
        }

        .answer-btn:hover {
            background-color: #22c55e;
        }

        .answer-btn:active {
            transform: scale(0.95);
        }

        .answer-btn.answer-feedback-correct {
            background-color: #16a34a;
            border-color: #bbf7d0;
            transform: scale(1.05);
        }

        .answer-btn.answer-feedback-incorrect {
            background-color: #dc2626;
            border-color: #fecaca;
            animation: shake 0.5s;
        }

        .answer-btn.answer-feedback-reveal {
            border-color: #16a34a;
            box-shadow: 0 0 10px #16a34a;
        }

        @keyframes shake {
            0%, 100% {
                transform: translateX(0);
            }
            25% {
                transform: translateX(-5px);
            }
            75% {
                transform: translateX(5px);
            }
        }

        .instrument-btn {
            background-color: #666;
            color: white;
            padding: 0.3rem 0.8rem;
            border-radius: 0.3rem;
            margin: 0 0.3rem;
            cursor: pointer;
            transition: background-color 0.2s;
            font-size: 0.9rem;
        }

        .instrument-btn:hover {
            background-color: #8b5cf6;
        }

        .instrument-btn.active {
            background-color: #8b5cf6;
        }

        /* Piano Layout - Critical for horizontal arrangement */
        .piano {
            display: flex !important;
            justify-content: center !important;
            align-items: center !important; /* vertically center keys */
            position: relative !important;
            margin-top: 2rem !important;
            height: 240px; /* +20% height in ratio with keys */
            min-height: 240px !important; /* override external min-height */
            width: 100%;
            /* Removed max-width cap so piano can take full container width */
            padding: 0.5rem !important; /* reduce inner spacing around keys */
            margin-left: auto;
            margin-right: auto;
        }

        .white-key {
            width: 40px;
            height: 216px; /* +20% height */
            margin: 0 1px;
            border-radius: 0 0 8px 8px;
            cursor: pointer;
            z-index: 1;
        }

        .black-key {
            width: 24px;
            height: 132px; /* +20% height */
            margin: 0 -12px;
            border-radius: 0 0 4px 4px;
            cursor: pointer;
            z-index: 2;
            position: relative;
        }

        .key {
            display: inline-block;
            vertical-align: top;
        }
        
        /* Challenge Mode Styles */
        .challenge-status {
            padding: 0.5rem 1rem;
            border-radius: 0.25rem;
            font-weight: 500;
            text-align: center;
            font-size: 0.9rem;
        }
        
        .challenge-status.connected {
            background-color: #10B981;
            color: white;
        }
        
        .challenge-status.disconnected {
            background-color: #EF4444;
            color: white;
        }

        #challenge-mode-controls {
            display: flex;
            flex-wrap: wrap;
            gap: 0.5rem;
            align-items: center;
        }

        #challenge-mode-controls button {
            padding: 0.35rem 0.75rem;
            border: none;
            border-radius: 0.25rem;
            font-size: 0.85rem;
            cursor: pointer;
            transition: background-color 0.2s;
        }

        .btn-primary {
            background-color: #8B5CF6;
            color: white;
        }

        .btn-primary:hover {
            background-color: #7C3AED;
        }

        .btn-secondary {
            background-color: #6B7280;
            color: white;
        }

        #challenge-participants {
            margin-top: 0.75rem;
            padding: 0.75rem 1rem;
            border: 1px solid rgba(139, 92, 246, 0.2);
            border-radius: var(--border-radius);
            background: rgba(139, 92, 246, 0.08);
            display: none;
        }

        #challenge-participants-title {
            font-size: 0.95rem;
            font-weight: 600;
            color: var(--text-primary);
            margin-bottom: 0.5rem;
        }

        #challenge-participants-list {
            list-style: none;
            padding: 0;
            margin: 0;
            display: flex;
            flex-wrap: wrap;
            gap: 0.35rem 0.75rem;
        }

        #challenge-participants-list li {
            padding: 0.3rem 0.65rem;
            background: rgba(255, 255, 255, 0.12);
            border-radius: 999px;
            font-size: 0.9rem;
            color: var(--text-primary);
        }

        .btn-secondary:hover {
            background-color: #4B5563;
        }
        
        #channel-id-input {
            border: 1px solid #D1D5DB;
            border-radius: 0.25rem;
            padding: 0.35rem;
            font-size: 0.85rem;
            min-width: 100px;
        }

/* ============================================================
   DROPDOWN CONTAINER CLASSES  (replaces inline styles)
   ============================================================ */
.dropdowns-container {
    display: flex;
    gap: 3rem;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
}

.dropdown-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 250px;
    flex: 1;
    max-width: 400px;
}

.dropdown-spacer {
    margin-top: 2rem;
}

/* ============================================================
   NOTATION SIDE-BY-SIDE  (replaces inline styles)
   ============================================================ */
.notation-side-by-side {
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    gap: 2rem;
    flex-wrap: wrap;
}

.notation-side-by-side > div {
    flex: 1;
    min-width: 140px;
}

/* ============================================================
   PIANO SCROLL WRAPPER
   ============================================================ */
.piano-scroll-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(139,92,246,0.4) transparent;
    padding-bottom: 4px;
}

.piano-scroll-container::-webkit-scrollbar {
    height: 4px;
}
.piano-scroll-container::-webkit-scrollbar-track {
    background: transparent;
}
.piano-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.4);
    border-radius: 2px;
}

/* ============================================================
   MOBILE OVERRIDES  (max-width: 768px)
   ============================================================ */
@media (max-width: 768px) {

    /* --- Dropdown container --- */
    .dropdowns-container {
        gap: 1rem;
        flex-direction: column;
        align-items: stretch;
    }

    .dropdown-group {
        min-width: unset;
        max-width: 100%;
        width: 100%;
    }

    .dropdown-spacer {
        margin-top: 0.75rem;
    }

    /* --- Mode selects --- */
    .mode-select {
        max-width: 100%;
        font-size: 0.95rem;
        padding: 0.75rem 0.875rem;
    }

    /* --- Section padding --- */
    .control-section,
    .answer-section,
    .piano-section,
    .notation-container {
        padding: 1rem 0.875rem;
    }

    /* --- Control buttons: full-width stack --- */
    .control-buttons {
        flex-direction: column;
        align-items: stretch;
        gap: 0.6rem;
    }

    .control-btn {
        width: 100%;
        padding: 0.875rem 1rem;
        font-size: 1rem;
        min-height: 48px;
    }

    /* --- Answer buttons --- */
    .answer-btn {
        font-size: 0.9rem;
        padding: 0.65rem 0.75rem;
        min-width: 44px;
        min-height: 44px;
    }

    .answer-btn.comparison {
        padding: 0.75rem 1rem;
        font-size: 1.1rem;
        margin: 0 0.25rem;
    }

    /* --- Piano: horizontal scroll --- */
    .piano-scroll-container .piano {
        width: max-content;
        min-width: 100%;
        justify-content: flex-start;
        overflow: visible;
        padding: 1.5rem 1rem;
        min-height: 200px;
    }

    .piano-scroll-container .white-key {
        width: 34px;
        height: 180px;
    }

    .piano-scroll-container .black-key {
        width: 20px;
        height: 110px;
        margin: 0 -10px;
    }

    /* Piano controls: stack vertically */
    .piano-controls {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .piano-control-group {
        flex-direction: row;
        width: 100%;
        justify-content: space-between;
        align-items: center;
    }

    .control-select {
        min-width: unset;
        flex: 1;
        max-width: 200px;
    }

    input[type="range"] {
        width: 100%;
        max-width: 180px;
    }

    .piano-display {
        margin-bottom: 1rem;
        padding: 1rem;
    }

    .piano-display-note {
        font-size: 2rem;
    }

    .piano-display-instrument {
        font-size: 0.9rem;
    }

    /* --- Notation panels: stack on mobile --- */
    .notation-side-by-side {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
    }

    .notation-side-by-side > div {
        width: 100%;
        min-width: unset;
    }

    /* --- Settings modal: bottom-sheet on mobile ---
       IMPORTANT: do NOT override display here — JS controls show/hide.
       Instead position the content panel at the bottom of the fixed backdrop. */
    .settings-modal {
        padding-top: 0;
    }

    .settings-modal-content {
        /* Stick to bottom of the fixed full-screen backdrop */
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 1.25rem;
        border-radius: 1rem 1rem 0 0;
        max-height: 85vh;
        overflow-y: auto;
    }

    /* Settings grid: 2 columns */
    .settings-grid {
        grid-template-columns: repeat(2, 1fr);
        max-height: 160px;
    }

    .settings-slider-container {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .settings-slider-container label {
        width: 100%;
        margin-right: 0;
    }

    .settings-slider-container input[type="range"] {
        width: 100%;
        flex-grow: 1;
        max-width: 100%;
    }

    .settings-slider-container span {
        margin-left: 0;
    }

    /* Settings buttons */
    .settings-button-container {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }

    .settings-button {
        width: 100%;
        margin-left: 0;
        padding: 0.875rem;
        min-height: 48px;
        text-align: center;
    }

    /* --- Challenge mode controls: stack --- */
    #challenge-mode-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    #channel-id-input {
        width: 100% !important;
        min-width: unset !important;
        margin-left: 0 !important;
        padding: 0.5rem;
        font-size: 1rem;
        min-height: 44px;
        box-sizing: border-box;
    }

    #challenge-mode-controls button {
        width: 100%;
        min-height: 44px;
        font-size: 0.9rem;
    }

    /* --- Hero section --- */
    .ear-training-hero {
        padding: 0.75rem;
        padding-top: 5rem;
        margin-top: 1rem;
    }

    .hero-content {
        padding: 1.5rem 1rem;
    }

    /* --- Training container --- */
    .training-container {
        padding: 0.75rem;
    }

    /* --- Trial modal --- */
    .trial-modal-content {
        margin: 1rem;
        padding: 1.5rem;
        max-width: calc(100% - 2rem);
    }

    .trial-modal-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .trial-btn {
        width: 100%;
        text-align: center;
    }

    /* --- Session stats --- */
    .session-info {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    /* --- Settings gear icon --- */
    .settings-icon {
        width: 70px !important;
        height: 70px !important;
    }

    .settings-icon i {
        font-size: 1.8rem !important;
    }

    /* --- Study mode --- */
    #study-media {
        height: auto !important;
        min-height: 280px;
    }
}

/* ============================================================
   EXTRA SMALL MOBILE  (max-width: 480px)
   ============================================================ */
@media (max-width: 480px) {

    .settings-modal-content {
        padding: 1rem;
    }

    .settings-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .settings-grid label {
        font-size: 0.8rem;
        padding: 4px 6px;
    }

    /* Comparison buttons: full-width stack on tiny screens */
    #answer-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .answer-btn.comparison {
        width: 100%;
        font-size: 1rem;
        margin: 0.2rem 0;
    }

    .piano-display-note {
        font-size: 1.75rem;
    }

    .hero-content {
        padding: 1rem 0.75rem;
    }
}
