:root {
    --bg-deep: #000000;
    --bg-surface: #111111;
    --accent-primary: #8b5cf6;
    /* Violet Glow */
    --accent-secondary: #10b981;
    /* Green Success */
    --text-main: #ffffff;
    --text-dim: #666666;
}

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

/* MOBILE BLOCKER STYLES */
.mobile-warning-overlay {
    display: none;
    /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 10000;
    /* Above EVERYTHING */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.mobile-warning-card {
    text-align: center;
    max-width: 300px;
    color: #fff;
}

.mobile-warning-card .mobile-icon {
    font-size: 40px;
    margin-bottom: 20px;
}

.mobile-warning-card h2 {
    color: #ef4444;
    font-size: 20px;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.mobile-warning-card p {
    color: #888;
    line-height: 1.5;
    margin-bottom: 10px;
}

/* ACTIVATION TRIGGER */
@media screen and (max-width: 768px) {
    .mobile-warning-overlay {
        display: flex !important;
    }

    /* Hide the rest of the app to prevent heavy rendering */
    .container,
    #licenseWall,
    #cinematicOverlay {
        display: none !important;
    }
}

body {
    background-color: var(--bg-deep);
    color: var(--text-main);
    font-family: 'Inter', system-ui, sans-serif;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    /* Zen Mode */
}

/* LICENSE WALL */
.license-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.license-card {
    background: #111;
    padding: 40px;
    border-radius: 12px;
    border: 1px solid #333;
    text-align: center;
    box-shadow: 0 0 50px rgba(139, 92, 246, 0.2);
    width: 350px;
}

.license-card h2 {
    color: #fff;
    margin-bottom: 15px;
    font-size: 18px;
}

.license-card p {
    color: #888;
    margin-bottom: 20px;
    font-size: 13px;
    line-height: 1.5;
}

.license-card input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    background: #000;
    border: 1px solid #333;
    color: #fff;
    border-radius: 6px;
    text-align: center;
    letter-spacing: 2px;
}

.license-card .error-msg {
    color: #ef4444;
    font-size: 12px;
    margin-top: 10px;
    min-height: 20px;
}

.license-card .small {
    font-size: 11px;
    margin-top: 20px;
    color: #555;
}

.license-card a {
    color: #8b5cf6;
    text-decoration: none;
}

.container {
    width: 100%;
    max-width: 1100px;
    /* Expanded for Widescreen comfort */
    min-height: 100vh;
    margin: 0 auto;
    background: transparent;
    /* Was var(--bg-surface), blocking body visuals */
    border: none;
    position: relative;
    /* z-index removed to avoid trapping children above global overlay */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
    /* Minimal padding */
    gap: 15px;
    /* Minimal gap */
}

/* --- HEADER & TEXT --- */
h1 {
    font-size: 14px;
    /* Compact */
    text-transform: uppercase;
    letter-spacing: 4px;
    color: var(--text-dim);
    margin-bottom: 2px;
    font-weight: 400;
    text-align: center;
}

.instruction {
    font-size: 18px;
    /* Compact */
    font-weight: 300;
    text-align: center;
    margin-bottom: 10px;
    color: #fff;
    background: none;
    border: none;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

/* --- LANGUAGE SWITCHER --- */
.lang-switcher {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    gap: 5px;
    background: rgba(0, 0, 0, 0.5);
    padding: 4px;
    border-radius: 8px;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.lang-btn {
    background: transparent;
    border: none;
    color: #666;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.lang-btn:hover {
    color: #fff;
}

.lang-btn.active {
    background: var(--accent-primary);
    color: #fff;
}

/* --- COACHING INDICATORS --- */
.phase-indicator {
    display: inline-block;
    padding: 2px 8px;
    /* Compact */
    border-radius: 50px;
    font-size: 10px;
    /* Compact */
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 auto 5px;
    align-self: center;
    text-align: center;
}

/* --- PSYCHO-ACTIVE AMBIENT FEEDBACK (BALANCED) --- */
/* Applied to BODY by JS */

.coach-display {
    display: none !important;
}

/* Flow State (Streak) - ELEGANT AURA */
.psy-flow::before {
    content: "";
    position: fixed;
    inset: 0;
    background: transparent;
    /* Softer Glow */
    box-shadow: inset 0 0 60px 10px rgba(59, 130, 246, 0.4);
    pointer-events: none;
    z-index: 900;
    animation: pulseFlow 2.5s infinite alternate;
}

/* Stress State (Error) - ALERT FLASH */
.psy-stress::after {
    content: "";
    position: fixed;
    inset: 0;
    /* Visible but not blinding Red */
    background: rgba(220, 38, 38, 0.05);
    box-shadow: inset 0 0 100px 30px rgba(220, 38, 38, 0.5);
    pointer-events: none;
    z-index: 950;
    animation: flashStress 0.5s ease-out forwards;
}

/* Focus State (Hesitation) - PROMPT */
.psy-focus {
    animation: flashFocus 0.4s ease-out;
}

@keyframes pulseFlow {
    from {
        opacity: 0.4;
        box-shadow: inset 0 0 40px 5px rgba(59, 130, 246, 0.3);
    }

    to {
        opacity: 0.8;
        box-shadow: inset 0 0 80px 15px rgba(59, 130, 246, 0.5);
    }
}

@keyframes flashStress {
    0% {
        opacity: 0;
        transform: scale(1.02);
    }

    10% {
        opacity: 1;
        transform: scale(1);
    }

    100% {
        opacity: 0;
    }
}

@keyframes flashFocus {
    0% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.3) contrast(1.1);
    }

    100% {
        filter: brightness(1);
    }
}

.coach-success {
    color: #fbbf24;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.4);
}


.phase-exposition {
    border: 1px solid var(--accent-secondary);
    color: var(--accent-secondary);
    background: rgba(16, 185, 129, 0.1);
}

.phase-test {
    border: 1px solid #f59e0b;
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
}

/* --- VISUAL CORE (Zen Focus Layout) --- */
/* The Wrapper handles the layout/sizing in the flex container */
.notation-wrapper {
    flex: 0 0 380px;
    width: 100%;
    max-width: 1100px;
    height: 380px;
    position: relative;
    /* Wrapper dictates the space */
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

#notation {
    position: absolute;
    /* Stack on top of background */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

    background: transparent !important;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    box-shadow: none !important;
    padding: 0;
    overflow: hidden;
}

/* New shared class for the background layer */
.notation-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 1;
    /* Lowest layer */
}

#notation svg {
    filter: none;
    overflow: visible;
    width: 100%;
}

.piano-keyboard {
    flex: 0 0 150px;
    width: 100%;
    max-width: 1100px;
    /* Constrain width again */
    height: 150px;
    background: transparent;
    margin-top: 10px;
    position: relative;
    z-index: 10;

    /* FIXED LAYOUT (No Scroll) */
    display: flex;
    justify-content: center;
    overflow: hidden;
    /* No scrollbars */
}

/* Essential for JS positioning */
.key {
    position: absolute;
    cursor: pointer;
    user-select: none;
}

/* --- KEYS RESTYLING (Realism) --- */
.white-key {
    background: linear-gradient(to bottom, #fff 0%, #eee 100%);
    /* Real White */
    border: 1px solid #bbb;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 1;
    color: transparent;
}

/* Mark Middle C subtly if needed, but keep it white-ish */
/* Mark Middle C (C4) clearly as visual anchor */
.white-key[data-note="C4"] {
    background: linear-gradient(to bottom, #f3f4f6 0%, #e5e7eb 100%);
    /* Slightly distinctive grey-white */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    border: 1px solid #9ca3af;
}

/* Add a visual dot marker on C4 */
/* Add a visual dot marker on C4 */
.white-key[data-note="C4"]::after {
    content: "";
    position: absolute;
    bottom: 22px;
    /* Lifted up to avoid text overlap */
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    background-color: #8b5cf6;
    /* Primary Violet Accent */
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(139, 92, 246, 0.5);
    opacity: 0.8;
}

.black-key {
    background: linear-gradient(45deg, #222, #000);
    /* Real Black */
    border: 1px solid #000;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
    z-index: 2;
}

/* ACTIVE STATES - Clear & Bright */
.key.active {
    background: #3b82f6 !important;
    /* Bright Blue */
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.6) !important;
}

.key.correct {
    background: #10b981 !important;
    /* Green */
}

.key.error {
    background: #ef4444 !important;
    /* Red */
}

/* --- CONNECTION BEAMS (Solid Laser) --- */
.connections-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
}

.connections-overlay svg {
    width: 100%;
    height: 100%;
}

.conn-line-glow {
    stroke: rgba(124, 58, 237, 0.4);
    /* Soft Purple Aura */
    stroke-width: 8;
    filter: blur(4px);
    opacity: 0.6;
    fill: none;
    transition: opacity 0.2s;
}

.conn-line-core {
    stroke: #8b5cf6;
    /* Solid Purple Core */
    stroke-width: 3;
    stroke-dasharray: none;
    /* NO DASHES */
    fill: none;
    filter: drop-shadow(0 0 2px rgba(139, 92, 246, 0.8));
}

/* --- CONTROLS (Hidden/Minimal) --- */
.controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    z-index: 30;
    /* Ensure clickable */
}

button {
    background: transparent;
    border: 1px solid #444;
    color: #888;
    padding: 12px 30px;
    border-radius: 50px;
    font-size: 12px;
    letter-spacing: 1px;
    transition: all 0.3s;
    cursor: pointer;
    text-transform: uppercase;
}

button:hover {
    border-color: #fff;
    color: #fff;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

#startBtn {
    background: var(--text-main);
    color: #000;
    font-weight: bold;
    border: none;
}

#startBtn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.3);
}

.btn-danger-small {
    background: #dc2626;
    color: white;
    border: none;
    padding: 8px 16px;
    font-size: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.btn-danger-small:hover {
    background: #b91c1c;
    transform: scale(1.02);
}

/* Settings Panel - Hidden by default, toggled via JS */
#settings-panel {
    display: none;
    /* Controlled by JS toggle */
    position: fixed;
    /* Modal Center */
    top: 50%;
    left: 50%;
    bottom: auto;
    transform: translate(-50%, -50%);
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid #444;
    padding: 20px;
    border-radius: 12px;
    z-index: 2000;
    width: 600px;
    max-width: 90vw;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

.duration-control {
    display: flex;
    gap: 8px;
    margin-top: 5px;
}

.duration-btn {
    width: 60px;
    /* Fixed width for uniformity */
    padding: 8px 0;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid #555;
    background: rgba(255, 255, 255, 0.05);
    color: #ccc;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.duration-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.duration-btn.active {
    background: #3b82f6 !important;
    border-color: #3b82f6 !important;
    color: #fff !important;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.5);
}

#settings-panel.active {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
    transform: translate(-50%, -50%);
    /* Force Center */
    animation: fadeInModal 0.3s ease-out;
}

@keyframes fadeInModal {
    from {
        opacity: 0;
        transform: translate(-50%, -45%);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.confirm-danger {
    background-color: #dc2626 !important;
    color: white !important;
    border-color: #ef4444 !important;
    animation: pulseRed 0.8s infinite;
    font-weight: bold;
}

@keyframes pulseRed {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(220, 38, 38, 0.4);
    }

    50% {
        transform: scale(1.02);
        box-shadow: 0 0 15px rgba(220, 38, 38, 0.7);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(220, 38, 38, 0.4);
    }
}

.setting-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.setting-label {
    font-size: 10px;
    text-transform: uppercase;
    color: #666;
    font-weight: bold;
    letter-spacing: 1px;
}

/* Ensure these are visible inside the panel */
.speed-control,
.volume-control,
.duration-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Hide only elements that should truly be hidden in Zen mode */
.stats,
.history,
.key-cues,
.score,
.level-info,
.message {
    display: none !important;
}

/* STREAK DISPLAY */
.streak-display {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 2px solid #0f3460;
    border-radius: 16px;
    padding: 16px 24px;
    margin: 16px auto;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(15, 52, 96, 0.3);
}

.streak-main {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.streak-emoji {
    font-size: 32px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.streak-count {
    font-size: 48px;
    font-weight: 800;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.streak-label {
    font-size: 16px;
    color: #a0a0a0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.streak-stats {
    font-size: 13px;
    color: #6c757d;
    margin-top: 4px;
}

.streak-stats.at-risk {
    color: #ff6b6b;
    font-weight: 600;
    animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.progress-bar {
    display: none;
}

/* --- Deep Focus Mode --- */
/* --- Deep Focus Mode --- */
body.deep-focus header,
body.deep-focus footer,
body.deep-focus .license-key-display {
    opacity: 0.1;
    pointer-events: none;
    /* Header/Footer really non-clickable */
    transition: opacity 2s ease-in-out;
    filter: blur(2px);
}

body.deep-focus .controls {
    opacity: 0.2;
    /* Faded but visible enough */
    transition: opacity 0.5s ease;
    filter: blur(1px);
    /* CRITICAL FIX: controls MUST remain clickable/hoverable */
    pointer-events: auto;
}

/* Switch Toggle & Select Styles */
.settings-select {
    background: #333;
    color: #fff;
    border: 1px solid #555;
    padding: 8px 12px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    width: 100%;
    min-width: 150px;
    cursor: pointer;
}

.mode-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

#modeLabel {
    font-size: 12px;
    color: #aaa;
    width: 120px;
    /* Fixed width prevents jitter */
}

/* The Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #444;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #8b5cf6;
    /* Main Accent */
}

input:checked+.slider:before {
    transform: translateX(20px);
}

/* Allow interaction if user really intends to via hover */
body.deep-focus .controls:hover {
    opacity: 1;
    filter: none;
    cursor: default;
}

/* Isolate the main task */
body.deep-focus #main-container {
    /* No blur here! The only clear thing in the world. */
    transition: transform 1s ease;
}

/* Psycho Pulse Animation for Note & Key */
/* Psycho Pulse Animation for Key (NO SCALE to avoid overlap) */
@keyframes pulseTargetKey {
    0% {
        filter: brightness(1);
        box-shadow: 0 0 0 rgba(139, 92, 246, 0);
    }

    50% {
        filter: brightness(1.5);
        box-shadow: 0 0 25px rgba(139, 92, 246, 0.9);
    }

    100% {
        filter: brightness(1);
        box-shadow: 0 0 0 rgba(139, 92, 246, 0);
    }
}

/* Psycho Pulse Animation for Note (Scale allowed here) */
@keyframes pulseTargetNote {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }

    50% {
        transform: scale(1.4);
        filter: brightness(1.3) drop-shadow(0 0 5px rgba(139, 92, 246, 0.8));
    }

    100% {
        transform: scale(1);
        filter: brightness(1);
    }
}

/* Pulse the Note on Staff */
.highlighted,
.highlighted path,
g.highlighted path {
    animation: pulseTargetNote 0.4s ease-out;
    transform-origin: center;
    transform-box: fill-box;
}

/* Pulse the Keyboard Key */
/* Pulse the Keyboard Key & Synesthesia */
.key {
    transition: background-color 1.5s ease-out, box-shadow 1.2s ease-out, transform 0.1s;
}

.key.active {
    animation: none;
    /* Disable genetic pulse */
    transition: background-color 0s, box-shadow 0s, transform 0.05s;
    transform: scale(0.95);
    z-index: 100 !important;
}

/* KANDINSKY COLOR MAP */
.key.note-c.active {
    background-color: #ff3b30 !important;
    box-shadow: 0 0 25px #ff3b30;
}

.key.note-d.active {
    background-color: #ff9500 !important;
    box-shadow: 0 0 25px #ff9500;
}

.key.note-e.active {
    background-color: #ffcc00 !important;
    box-shadow: 0 0 25px #ffcc00;
}

.key.note-f.active {
    background-color: #2ecc71 !important;
    box-shadow: 0 0 25px #2ecc71;
}

.key.note-g.active {
    background-color: #3498db !important;
    box-shadow: 0 0 25px #3498db;
}

.key.note-a.active {
    background-color: #9b59b6 !important;
    box-shadow: 0 0 25px #9b59b6;
}

.key.note-b.active {
    background-color: #e91e63 !important;
    box-shadow: 0 0 25px #e91e63;
}

/* Black Keys Support */
.black-key.note-c.active {
    background-color: #c0392b !important;
}

.black-key.note-d.active {
    background-color: #d35400 !important;
}

.black-key.note-f.active {
    background-color: #27ae60 !important;
}

.black-key.note-g.active {
    background-color: #2980b9 !important;
}

.black-key.note-a.active {
    background-color: #8e44ad !important;
}

/* Z-INDEX HIERARCHY FIX */
.white-key {
    z-index: 1;
}

.white-key.active {
    z-index: 5 !important;
}

/* Glows above other whites, still below blacks */
.black-key {
    z-index: 10;
}

.black-key.active {
    z-index: 15 !important;
}

/* SESSION DEBRIEF MODAL */
.debrief-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(8px);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    animation: fadeInModal 0.5s forwards;
}

.debrief-card {
    background: #1e293b;
    border: 1px solid #475569;
    padding: 30px;
    border-radius: 24px;
    text-align: center;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    transform: scale(0.9);
    animation: popInModal 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards 0.1s;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    border-radius: 8px;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transform: rotate(90deg);
}

.debrief-card h2 {
    font-size: 20px;
    letter-spacing: 2px;
    color: #e2e8f0;
    margin-bottom: 5px;
}

.debrief-coach-msg {
    font-size: 16px;
    color: #fbbf24;
    font-style: italic;
    margin: 15px 0 25px;
    line-height: 1.5;
    font-weight: 500;
}

.debrief-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 30px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
}

.d-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.d-label {
    font-size: 11px;
    color: #94a3b8;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.d-value {
    font-size: 28px;
    font-weight: 800;
    color: #f1f5f9;
}

.debrief-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

@keyframes fadeInModal {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes popInModal {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* =========================================
   AMBIENT BACKGROUNDS (Hypnotic Breathe)
   ========================================= */
@keyframes deep-breathe {
    0% {
        background-size: 100% 100%;
    }

    50% {
        background-size: 140% 140%;
    }

    /* Slow expansion */
    100% {
        background-size: 100% 100%;
    }
}

body {
    transition: background-color 3s ease-in-out;
    background-color: #000;
}

#bg-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -5;
    pointer-events: none;
    transition: background-image 3s ease-in-out;
    background-size: 100% 100%;
    background-position: center;
}

/* Specific Mood Atmospheres applied to Layer */
#bg-layer.ambient-neutral {
    background-image: radial-gradient(circle, #2a2a2a 0%, #000000 80%);
    animation: deep-breathe 20s ease-in-out infinite;
}

#bg-layer.ambient-happy {
    background-image: radial-gradient(circle, #423510 0%, #000000 75%);
    /* Deep Amber */
    animation: deep-breathe 15s ease-in-out infinite;
}

#bg-layer.ambient-sad {
    background-image: radial-gradient(circle, #0f1730 0%, #000000 80%);
    /* Deep Navy */
    animation: deep-breathe 25s ease-in-out infinite;
}

#bg-layer.ambient-jazz_kenny {
    background-image: radial-gradient(circle, #052e33 0%, #000000 80%);
    /* Cyan Abyss */
    animation: deep-breathe 18s ease-in-out infinite;
}

#bg-layer.ambient-dorian {
    background-image: radial-gradient(circle, #0a2e15 0%, #000000 80%);
    /* Forest */
}

#bg-layer.ambient-phrygian {
    background-image: radial-gradient(circle, #331d06 0%, #000000 80%);
    /* Magma */
}

#bg-layer.ambient-jazz_sowhat {
    background-image: radial-gradient(circle, #1a0b38 0%, #000000 85%);
    /* Void Purple */
    animation: deep-breathe 30s ease-in-out infinite;
}

#bg-layer.ambient-tense {
    background-image: radial-gradient(circle, #330606 0%, #000000 80%);
    /* Blood */
    animation: deep-breathe 5s ease-in-out infinite;
    /* Nervous pulse */
}

#bg-layer.ambient-lydian {
    background-image: radial-gradient(circle, #330628 0%, #000000 80%);
    /* Neon Dark */
    animation: deep-breathe 12s ease-in-out infinite;
}

/* =========================================
   TACTILE KEYS (Electric Flow)
   ========================================= */
@keyframes flow-up {
    0% {
        background-position: 0% 100%;
    }

    100% {
        background-position: 0% 0%;
    }
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 15px 2px rgba(139, 92, 246, 0.5);
    }

    50% {
        box-shadow: 0 0 35px 10px rgba(139, 92, 246, 0.9);
    }

    100% {
        box-shadow: 0 0 15px 2px rgba(139, 92, 246, 0.5);
    }
}

.white-key.active {
    /* Flowing Energy Gradient */
    background: linear-gradient(to top, #8b5cf6, #d8b4fe, #8b5cf6) !important;
    background-size: 100% 200% !important;
    animation: flow-up 0.5s linear infinite, pulse-glow 0.8s ease-in-out infinite;

    transform: scale(0.98);
    border-bottom: 2px solid #6d28d9;
    /* Deep anchor */
    z-index: 10;
}

.black-key.active {
    background: linear-gradient(to top, #6d28d9, #a78bfa) !important;
    background-size: 100% 200% !important;
    animation: flow-up 0.5s linear infinite, pulse-glow 0.8s ease-in-out infinite;

    transform: scale(0.96);
    border: 1px solid #fff;
    z-index: 10;
}

/* --- PREMIUM HEADER STYLES --- */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 16px 24px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.01) 100%);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    font-size: 32px;
    filter: drop-shadow(0 0 15px rgba(139, 92, 246, 0.4));
    animation: floatingIcon 3s ease-in-out infinite;
}

@keyframes floatingIcon {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-3px);
    }
}

.title-group {
    display: flex;
    flex-direction: column;
}

.app-header h1 {
    font-size: 24px;
    font-weight: 800;
    color: #fff;
    margin: 0;
    letter-spacing: -0.5px;
    text-transform: none;
    /* Override previous uppercase */
    background: linear-gradient(to right, #fff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: left;
}

.subtitle {
    font-size: 11px;
    color: #8b5cf6;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 600;
    opacity: 0.9;
}

.level-badge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 12px;
    min-width: 80px;
}

.level-label {
    font-size: 9px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    margin-bottom: 2px;
}

.level-value {
    font-size: 24px;
    font-weight: 800;
    color: #fff;
    line-height: 1;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

/* Hide old elements if they persist */
.level-info {
    display: none !important;
}

@media (max-width: 600px) {
    .app-header {
        padding: 12px;
    }

    .app-header h1 {
        font-size: 18px;
    }

    .logo-icon {
        font-size: 24px;
    }

    .subtitle {
        font-size: 9px;
        letter-spacing: 1px;
    }
}

/* --- MINIMAL ELEGANCE HEADER --- */
.minimal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 4px;
    /* Wide tracking = elegance */
    color: #fff;
    text-transform: uppercase;
}

.meta-info {
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 2px;
    color: #64748b;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 8px;
}

.meta-info span {
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

/* --- ULTRA COMPACT SERIF HEADER --- */
.minimal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    /* Ultra compact */
    margin-bottom: 8px;
    /* Ultra compact */
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.brand {
    font-family: 'Playfair Display', serif;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
    font-style: italic;
    color: #f1f5f9;
    text-transform: none;
    /* Serifs look better in Title Case */
}

.meta-info {
    font-family: 'Inter', sans-serif;
    font-size: 9px;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 8px;
    border-radius: 4px;
}

.meta-info span {
    font-size: 11px;
    color: #94a3b8;
}

/* --- MODERN MINIMAL HEADER --- */
.brand {
    font-family: 'Inter', sans-serif;
    font-size: 20px;
    font-weight: 800;
    /* Bold geometric */
    letter-spacing: -0.5px;
    /* Tight tracking */
    font-style: normal;
    color: #fff;
    text-transform: none;
}

/* --- INSTRUCTION CLEANUP --- */
#instruction {
    min-height: 24px;
    margin-bottom: 4px;
    font-size: 14px;
    color: #94a3b8;
    font-weight: 500;
}

/* Hide initial redundant text if needed via JS (usually sets textContent) */
/* Ideally, JS should set instruction to empty or meaningful tip */

/* --- DIGITAL TIMER --- */
#timer {
    font-family: 'Courier New', monospace;
    /* or a digital font */
    font-size: 12px;
    color: #64748b;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px 8px;
    border-radius: 4px;
    letter-spacing: 1px;
    display: inline-block;
    margin-top: 10px;
}

/* --- CINEMATIC WIDE HEADER --- */
.minimal-header {
    display: flex;
    flex-direction: column;
    /* Stack vertically for impact */
    align-items: center;
    justify-content: center;
    padding: 30px 0 20px 0;
    margin-bottom: 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
    font-family: 'Inter', sans-serif;
    font-size: 32px;
    /* Bigger */
    font-weight: 800;
    letter-spacing: 12px;
    /* VERY Wide tracking */
    color: #fff;
    text-transform: uppercase;
    margin-bottom: 8px;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
    text-align: center;
    width: 100%;
}

.meta-info {
    font-size: 11px;
    letter-spacing: 4px;
    /* Wide tracking matches brand */
    color: #64748b;
    background: transparent;
    padding: 0;
    opacity: 0.8;
}

.meta-info span {
    color: #94a3b8;
    font-size: 11px;
}

/* --- REFINED WIDE HEADER --- */
.brand {
    font-size: 24px;
    /* Reduced from 32 */
    letter-spacing: 8px;
    /* Reduced from 12 */
    margin-bottom: 6px;
}

.minimal-header {
    padding: 20px 0 15px 0;
    /* Slightly more compact */
    margin-bottom: 20px;
}

/* --- COLLAPSE EMPTY INDICATORS --- */
.phase-indicator:empty,
.instruction:empty,
.message:empty {
    display: none;
    padding: 0;
    margin: 0;
}

/* --- PRO CONTROL BAR --- */
.control-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 8px 12px;
    margin-top: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    width: 100%;
    margin-bottom: 20px;
    flex-wrap: wrap;
    /* Safe wrapping for mobile */
    gap: 12px;
}

.control-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.control-tools {
    display: flex;
    gap: 8px;
    align-items: center;
    border-left: 1px solid #333;
    padding-left: 12px;
}

/* BUTTON RESETS & STYLES */
.control-bar button {
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    border: none;
    outline: none;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    height: 36px;
    padding: 0 16px;
}

/* Start Button */
.btn-primary {
    background: #e2e8f0;
    /* White/Grey */
    color: #0f172a;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

.btn-primary:hover {
    background: #fff;
    transform: translateY(-1px);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

/* Adaptive Button (Special) */
.btn-adaptive {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: white;
    box-shadow: 0 0 10px rgba(124, 58, 237, 0.3);
}

.btn-adaptive:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 0 15px rgba(124, 58, 237, 0.5);
}

/* Stop/Danger */
.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3) !important;
}

.btn-danger:hover {
    background: #ef4444;
    color: white;
}

/* Secondary Actions */
.btn-secondary {
    background: transparent;
    color: #94a3b8;
    border: 1px solid #333 !important;
}

.btn-secondary:hover {
    border-color: #64748b !important;
    color: #e2e8f0;
}

/* Tool Icons */
.btn-tool {
    width: 36px;
    padding: 0 !important;
    /* Icon only */
    background: transparent;
    color: #64748b;
    border-radius: 6px;
    font-size: 16px !important;
}

.btn-tool:hover {
    background: #333;
    color: #fff;
}

/* --- FORCE SINGLE LINE CONTROLS --- */
.control-bar {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    /* Safety scroll if extremely small */
    white-space: nowrap;
}

/* Ensure tools don't wrap internally */
.control-actions,
.control-tools {
    flex-shrink: 0;
}

/* Hide scrollbar */
.control-bar::-webkit-scrollbar {
    display: none;
}

/* --- STABLE LAYOUT DECK --- */
.status-deck {
    height: 50px;
    /* Reserved space to prevent jumps */
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    transition: all 0.3s ease;
}

.progress-container-fixed {
    height: 6px;
    /* Space for thin progress bar */
    width: 100%;
    margin-bottom: 20px;
    /* Space before Notation */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Override previous hiding rules to work inside deck */
.status-deck .phase-indicator,
.status-deck .instruction,
.status-deck .timer {
    margin: 0 !important;
}

/* Ensure progress bar fits */
.progress-bar {
    width: 100%;
    max-width: 400px;
    height: 4px;
}

/* --- HUD LAYER (No Layout Shift) --- */
.container {
    position: relative;
    /* Anchor for HUD */
}

.hud-layer {
    position: absolute;
    top: 60px;
    /* Below header roughly */
    left: 0;
    width: 100%;
    height: 0;
    /* Zero height to not affect flow */
    z-index: 50;
    display: flex;
    justify-content: space-between;
    padding: 0 10px;
    pointer-events: none;
    /* Let clicks pass through */
}

.phase-indicator {
    background: rgba(139, 92, 246, 0.9);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    margin: 0 !important;
}

.timer {
    background: rgba(0, 0, 0, 0.6);
    color: #cbd5e1;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 12px;
    margin: 0 !important;
}

.overlay-message-area {
    position: absolute;
    top: 150px;
    /* Position over the staff or below it */
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.instruction {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 14px;
    backdrop-filter: blur(4px);
    margin: 0 !important;
}

.message {
    font-size: 16px;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    margin: 0 !important;
    min-height: 0 !important;
    /* Override layout shifting props */
}

/* --- INFO STRIP ABOvE CONTROLS --- */
.control-bar {
    position: relative;
    /* Anchor for info strip */
    margin-top: 40px;
    /* Space for info strip */
}

.info-strip {
    position: absolute;
    bottom: 100%;
    /* Sits on top */
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding-bottom: 8px;
    /* Visual gap */
    pointer-events: none;
    /* Let clicks pass */
}

.info-badge {
    background: rgba(15, 23, 42, 0.9);
    color: #e2e8f0;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
}

.info-text {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
    background: rgba(0, 0, 0, 0.5);
    padding: 2px 8px;
    border-radius: 4px;
}

.info-text.highlight {
    color: #fbbf24;
    font-weight: 700;
}

/* Ensure monospace for timer */
.monospace {
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
}

/* --- Z-INDEX SAFETY --- */
.control-bar {
    z-index: 1000;
    position: relative;
}

.info-strip {
    z-index: 1001;
}

/* --- INTEGRATED INFO CENTER --- */
.control-info-center {
    flex-grow: 1;
    /* Takes available space */
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    height: 100%;
}

.info-tag {
    font-size: 11px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.05);
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.info-tag.phase {
    color: #a78bfa;
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.2);
}

.info-tag.time {
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
    color: #fff;
}

.info-tag.msg {
    color: #fbbf24;
    font-weight: 700;
}

/* Hide if empty to collapse space or keep if needed */
.info-tag:empty {
    display: none;
}

/* Remove margin top from bar since we no longer have info strip above */
.control-bar {
    margin-top: 20px !important;
}

/* Hide old info strip if rule persists */
.info-strip {
    display: none !important;
}

/* --- FORCE ROW LAYOUT & COMPACT --- */
.control-bar {
    flex-direction: row !important;
    align-items: center !important;
    white-space: nowrap !important;
}

.control-info-center {
    flex-direction: row !important;
    display: flex !important;
    overflow: hidden;
    /* Prevent breaking layout */
    text-overflow: ellipsis;
}

.info-tag {
    display: inline-block;
    /* Force inline behavior */
}

/* --- TIGHT LAYOUT (Notation + Piano) --- */
#notation {
    margin-bottom: 0px !important;
    /* Remove gap below staff */
    padding-bottom: 0px !important;
}

.piano-keyboard {
    margin-top: 10px !important;
    /* Close gap */
    padding-top: 0 !important;
}

/* Ensure intermediate elements don't push content */
#coachDisplay:empty,
#keyCues:empty,
.score:empty,
#testProgress:empty {
    display: none !important;
    margin: 0 !important;
    height: 0 !important;
}

/* --- PULL PIANO CLOSER --- */
#pianoContainer {
    margin-top: -30px !important;
    /* Pull up closer to staff */
    position: relative;
    z-index: 10;
    /* Ensure piano is above staff whitespace */
}

/* Trim bottom of notation if needed */
#notation {
    margin-bottom: 0 !important;
    overflow: hidden;
    /* Cut off excess whitespace */
    display: flex;
    justify-content: center;
    /* max-height: 180px; Optional: limit height of notation block */
}

/* Ensure no other spacer exists */
.progress-container-fixed {
    margin-bottom: 5px !important;
}

/* --- FIX INFO TAGS ALIGNMENT & COLOR --- */
.control-info-center {
    align-items: center !important;
    /* Force center vertical */
}

.info-tag {
    display: inline-flex !important;
    /* Use flex inside to center text */
    align-items: center;
    justify-content: center;
    height: 32px;
    /* Fixed height for all */
    box-sizing: border-box;
    vertical-align: middle;

    color: #fff !important;
    /* Brighter white */
    background: rgba(255, 255, 255, 0.1) !important;
    /* More visible bg */
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    margin: 0 2px;
    /* Small gap */
}

/* Specific overrides */
.info-tag.phase {
    color: #c4b5fd !important;
    /* Brighter violet */
}

.info-tag.msg {
    color: #fcd34d !important;
    /* Brighter gold */
}

.info-tag.time {
    font-family: 'Courier New', monospace;
    font-size: 13px !important;
    letter-spacing: 0.5px;
    padding-top: 2px;
    /* Optical fix for mono font baseline */
}

/* --- CONTROL BAR NORMALIZE --- */

/* 1. Force the Bar Height */
.control-bar {
    height: 52px;
    /* Fixed height container */
    padding: 0 8px !important;
    display: flex !important;
    align-items: center !important;
    overflow: hidden;
    /* Clip anything sticking out */
}

/* 2. Normalize ALL children (Buttons AND Info Tags) */
.control-bar button,
.info-tag {
    height: 36px !important;
    /* Unified Height */
    line-height: normal !important;
    /* Remove line-height variance */
    display: inline-flex;
    /* Removed !important so hidden buttons stay hidden */
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    margin: 0 4px !important;
    /* Uniform horizontal gap */
    padding: 0 12px !important;
    /* Uniform padding */
    vertical-align: middle !important;
}

/* 3. Button Specifics Fix */
.control-bar button .icon {
    font-size: 14px;
    margin-right: 6px;
    display: block;
    /* Ensure no inline shift */
}

/* 4. Timer Font Fix */
.info-tag.time {
    font-family: 'Courier New', monospace;
    font-size: 14px !important;
    padding-top: 0 !important;
    /* Reset layout shift adjustments */
}

/* 5. Center Container Fix */
.control-info-center {
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* --- HIDE DEV TOOLS --- */
#debugBtn,
#resetDataBtn {
    display: none !important;
}

/* --- CINEMATIC OVERLAY --- */
.cinematic-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    text-align: center;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.cinematic-message {
    font-family: 'Inter', sans-serif;
    font-size: 48px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    background: rgba(0, 0, 0, 0.6);
    padding: 20px 40px;
    border-radius: 16px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transform: scale(0.9);
    transition: transform 0.5s ease;
}

.cinematic-visible {
    opacity: 1;
}

.cinematic-visible .cinematic-message {
    transform: scale(1);
}

/* --- HIDE EMPTY MESSAGE BOX --- */
#message:empty,
#message[style*="display: none"],
#message[style*="display:none"] {
    display: none !important;
    width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    opacity: 0 !important;
}

/* --- UNIFIED BUTTON STYLE (Minimal) --- */
.control-bar button {
    background: transparent !important;
    color: #e2e8f0 !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: none !important;
    transition: all 0.2s ease !important;
}

.control-bar button:hover {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
    transform: translateY(-1px);
}

.control-bar button:active {
    transform: translateY(0);
}

/* Stop button - subtle red accent on hover only */
#stopBtn:hover {
    border-color: rgba(239, 68, 68, 0.6) !important;
    color: #fca5a5 !important;
}

/* Remove old colorful styles */
.btn-primary,
.btn-adaptive,
.btn-danger,
.btn-secondary {
    /* Styles unified above */
}

/* --- HELP BUTTON ACTIVE STATE --- */
.btn-tool.active {
    background: rgba(34, 197, 94, 0.15) !important;
    /* Green tint */
    border-color: rgba(34, 197, 94, 0.5) !important;
    color: #86efac !important;
}

.btn-tool.active:hover {
    background: rgba(34, 197, 94, 0.25) !important;
}

/* --- HELP BUTTON SUBTLE ACTIVE (Override) --- */
.btn-tool.active {
    background: transparent !important;
    /* No background */
    border-color: rgba(34, 197, 94, 0.6) !important;
    /* Green border */
    color: #4ade80 !important;
    /* Green icon */
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.3) !important;
    /* Subtle glow */
}

.btn-tool.active:hover {
    border-color: rgba(34, 197, 94, 0.8) !important;
    color: #86efac !important;
}

/* --- HELP BUTTON HIGHLY VISIBLE ACTIVE STATE --- */
.btn-tool.active {
    background: rgba(34, 197, 94, 0.25) !important;
    /* Stronger green bg */
    border-color: rgba(34, 197, 94, 0.8) !important;
    /* Bright green border */
    color: #22c55e !important;
    /* Bright green icon */
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.5) !important;
    /* Strong glow */
}

.btn-tool.active:hover {
    background: rgba(34, 197, 94, 0.35) !important;
    box-shadow: 0 0 16px rgba(34, 197, 94, 0.6) !important;
}

/* Add visual indicator - small dot */
.btn-tool.active::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 6px;
    height: 6px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 4px #22c55e;
}

/* Ensure btn-tool can have absolute children */
.btn-tool {
    position: relative !important;
}

/* --- OVERRIDE KEY ACTIVE COLORS (Simpler & Clearer) --- */

/* White keys: Bright yellow */
.white-key.active {
    background: #fbbf24 !important;
    /* Bright yellow */
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.8) !important;
}

/* Black keys: Dark purple with bright border */
.black-key.active {
    background: #6b21a8 !important;
    /* Dark purple */
    border: 2px solid #a78bfa !important;
    /* Bright purple border */
    box-shadow: 0 0 20px rgba(167, 139, 250, 0.6) !important;
}

/* --- BRUTAL OVERRIDE: DISABLE KANDINSKY, USE SIMPLE COLORS --- */

/* Override ALL note-specific colors for white keys */
.key.note-c.active,
.key.note-d.active,
.key.note-e.active,
.key.note-f.active,
.key.note-g.active,
.key.note-a.active,
.key.note-b.active,
.white-key.note-c.active,
.white-key.note-d.active,
.white-key.note-e.active,
.white-key.note-f.active,
.white-key.note-g.active,
.white-key.note-a.active,
.white-key.note-b.active {
    background-color: #fbbf24 !important;
    /* Bright yellow */
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.8) !important;
}

/* Override ALL note-specific colors for black keys */
.black-key.note-c.active,
.black-key.note-d.active,
.black-key.note-e.active,
.black-key.note-f.active,
.black-key.note-g.active,
.black-key.note-a.active,
.black-key.note-b.active {
    background-color: #7c3aed !important;
    /* Bright purple */
    border: 2px solid #c4b5fd !important;
    box-shadow: 0 0 20px rgba(196, 181, 253, 0.8) !important;
}

/* --- TIMER VISIBILITY FIX --- */
#timer {
    z-index: 2000 !important;
    /* Above everything */
    position: relative;
}

/* --- FIX PIANO OVERLAP --- */
#pianoContainer {
    margin-top: 10px !important;
    /* Remove negative margin that covers control bar */
}

/* --- HIDE SCORE BETWEEN NOTATION AND PIANO --- */
#score {
    display: none !important;
}

/* --- TIMER STAY IN CONTROL BAR --- */
#timer {
    position: static !important;
    /* Remove relative positioning */
    display: inline-flex !important;
    /* Keep inline with buttons */
}

/* --- TIGHT RIGO-PIANO SPACING --- */
#pianoContainer {
    margin-top: -20px !important;
    /* Pull piano closer to staff */
}

#notation {
    margin-bottom: 0 !important;
}

/* --- REMOVE PIANO NEGATIVE MARGIN (CAUSING OVERLAP) --- */
#pianoContainer {
    margin-top: 5px !important;
    /* Small positive margin */
}

/* --- HIDE TIMER COMPLETELY --- */
/* HIDE TIMER COMPLETELY REMOVED */

/* --- DISABLE ALL KEY ANIMATIONS WHEN ACTIVE --- */
.key.active {
    animation: none !important;
    transition: none !important;
}

/* --- FINAL COLOR FIX (Added safely at end) --- */

/* White Keys Active (Yellow) */
.white-key.active,
.white-key.active[data-note] {
    background-color: #fbbf24 !important;
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.6) !important;
}

/* Black Keys Active (Violet) */
.black-key.active,
.black-key.active[data-note] {
    background-color: #7c3aed !important;
    border: 1px solid #a78bfa !important;
    box-shadow: 0 0 15px rgba(124, 58, 237, 0.6) !important;
}

/* Correct (Green) */
.key.correct,
.white-key.correct,
.black-key.correct {
    background-color: #10b981 !important;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.6) !important;
}

/* Error (Red) */
.key.error,
.white-key.error,
.black-key.error {
    background-color: #ef4444 !important;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.6) !important;
}

/* Hide ghost timer if present */
/* #timer rule removed to allow visibility */

/* --- ULTIMATE QUIZ KEY COLORS FIX --- */

/* Force Active Color (Pressing) - Override everything */
.white-key:active,
.white-key.active,
.piano-keyboard .white-key:active,
.piano-keyboard .white-key.active {
    background-color: #fbbf24 !important;
    /* Yellow */
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.8) !important;
    background-image: none !important;
}

.black-key:active,
.black-key.active,
.piano-keyboard .black-key:active,
.piano-keyboard .black-key.active {
    background-color: #7c3aed !important;
    /* Violet */
    border-color: #a78bfa !important;
    box-shadow: 0 0 15px rgba(124, 58, 237, 0.8) !important;
    background-image: none !important;
}

/* Force Feedback Colors (Green/Red) */
.key.correct,
.white-key.correct,
.black-key.correct {
    background-color: #10b981 !important;
    /* Green */
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.8) !important;
}

.key.error,
.white-key.error,
.black-key.error {
    background-color: #ef4444 !important;
    /* Red */
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.8) !important;
}

/* --- INSTANT FEEDBACK (No Fade) --- */
.key {
    transition: background-color 0.1s, transform 0.05s;
}

/* When highlighted/active/correct/error, change color INSTANTLY */
.key.active,
.key.correct,
.key.error,
.white-key.active,
.white-key.correct,
.white-key.error,
.black-key.active,
.black-key.correct,
.black-key.error,
.key:active {
    transition: none !important;
    animation: none !important;
}

/* --- FIX PROGRESS BAR ALIGNMENT IN CONTROL BAR --- */
#testProgress {
    align-self: center !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    position: relative !important;
    top: 0 !important;
    display: block !important;
    /* JS sets this, but flex handles it */
}

/* Ensure it's hidden when JS says so */
#testProgress[style*="display: none"] {
    display: none !important;
}

/* --- ULTIMATE PROGRESS BAR ALIGNMENT --- */
#testProgress {
    /* Override JS display:block */
    display: flex !important;
    align-items: center;
    justify-content: flex-start;
    line-height: 0;

    /* Ensure sizing */
    width: 80px !important;
    height: 8px !important;
    border-radius: 4px !important;

    /* Perfect Center */
    margin: 0 12px !important;
    align-self: center !important;
    position: relative;
    z-index: 1000;
}

/* BUT hide it if explicitly hidden by logic (using attribute selector trick) */
#testProgress[style*="display: none"] {
    display: none !important;
}

/* --- UNCRUMPLE PROGRESS BAR --- */
#testProgress {
    /* Solid dimensions */
    min-width: 80px !important;
    min-height: 8px !important;
    height: 8px !important;
    /* Force explicit height */

    /* Prevent squashing */
    flex-shrink: 0 !important;
    flex-grow: 0 !important;

    /* Structure */
    display: block !important;
    /* Back to block, flex parent handles alignment */
    background: rgba(255, 255, 255, 0.15) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    overflow: hidden !important;
}

#testProgressFill {
    height: 100% !important;
    min-height: 100% !important;
    display: block !important;
    border-radius: 2px !important;
}

/* --- ULTIMATE PROGRESS BAR DEBUG --- */
#testProgress {
    display: inline-flex !important;
    /* Try inline-flex */
    width: 100px !important;
    height: 10px !important;
    min-height: 10px !important;
    background-color: #334155 !important;
    /* Visible slate bg */
    border: 1px solid #94a3b8 !important;
    /* Visible border */
    border-radius: 5px !important;

    margin: 0 15px !important;
    padding: 0 !important;

    flex-shrink: 0 !important;
    align-self: center !important;

    overflow: hidden !important;
}

#testProgressFill {
    height: 100% !important;
    width: 50%;
    /* Force 50% for debug to see it */
    background-color: #fbbf24 !important;
    display: block !important;
}

/* --- ROBUST PROGRESS BAR WRAPPER --- */
#testProgress {
    /* Match button height to play nice in flex row */
    height: 40px !important;
    min-height: 40px !important;
    width: 120px !important;

    /* Flex alignment */
    display: flex !important;
    align-items: center !important;
    /* Vertically center the inner line */
    justify-content: flex-start !important;

    /* Invisible container */
    background: transparent !important;
    border: none !important;
    margin: 0 15px !important;
    padding: 0 !important;
    position: relative !important;
}

/* Create the visible track background */
#testProgress::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 8px;
    /* Thickness of the bar */
    margin-top: -4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    z-index: 0;
}

/* The actual fill bar */
#testProgressFill {
    height: 8px !important;
    /* Same thickness */
    background-color: #fbbf24 !important;
    border-radius: 4px !important;
    width: 0%;
    /* JS updates this */
    position: relative;
    z-index: 1;
    /* Above track */
    display: block !important;
}

/* --- NEW CLEAN CONTROL BAR (REWRITE) --- */
.control-bar-clean {
    width: 100%;
    max-width: 900px;
    height: 70px;
    margin-top: 20px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;

    padding: 0 20px;

    /* Ensure z-index wins */
    position: relative;
    z-index: 100;
}

/* Groups */
.cb-group-left,
.cb-group-right,
.cb-group-tools {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cb-group-center {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Buttons (Unified) */
.cb-btn {
    height: 40px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: transparent;
    color: #cbd5e1;
    font-family: inherit;
    font-weight: 600;
    font-size: 13px;
    padding: 0 16px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s;
}

.cb-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
    transform: translateY(-1px);
}

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

.cb-btn.active {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
}

.cb-btn-icon {
    padding: 0;
    width: 40px;
    justify-content: center;
    font-size: 16px;
}

/* Special Buttons */
.cb-btn-primary {
    /* Optional: slightly different border */
    border-color: rgba(255, 255, 255, 0.25);
}

.cb-btn-danger:hover {
    border-color: #ef4444;
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.1);
}

/* PROGRESS BAR (New & Clean) */
.cb-progress-container {
    width: 100%;
    max-width: 200px;
    /* Limit width */
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    position: relative;

    /* Ensure it behaves correctly when displayed */
    display: block !important;
    /* JS sets display: block, we adapt */
}

/* But hide if JS implies hidden */
.cb-progress-container[style*="display: none"] {
    display: none !important;
}

.cb-progress-fill {
    height: 100%;
    background: #fbbf24;
    transition: width 0.3s ease;
}

/* --- OVERRIDE OLD CONTROL BAR --- */
.control-bar {
    display: none !important;
}

/* --- PSYCHOPROGRESS COMPONENT --- */
.psy-progress-container {
    flex-grow: 1;
    max-width: 300px;
    /* Non troppo largo */
    height: 40px;
    /* Altezza pulsanti */
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin: 0 20px;
}

.psy-progress-track {
    /* The visible track */
    width: 100%;
    height: 6px !important;
    background: rgba(255, 255, 255, 0.15) !important;
    border-radius: 3px !important;
    overflow: hidden !important;
    border: none !important;

    /* Ensure it works with JS display toggles */
    display: block !important;
    position: relative !important;
    top: 0 !important;
    left: 0 !important;
}

/* Hide when JS says hide */
.psy-progress-track[style*="display: none"] {
    display: none !important;
}

.psy-progress-bar {
    height: 100% !important;
    background: #fbbf24 !important;
    width: 0%;
    transition: width 0.2s ease-out;
    border-radius: 3px;
}

.psy-feedback-message {
    position: absolute;
    top: -24px;
    width: 100%;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: #fbbf24;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    white-space: nowrap;
}

/* --- FIX MESSAGE POSITION (BELOW BAR) --- */
.psy-feedback-message {
    top: auto !important;
    bottom: -18px !important;
    /* Position below the progress bar */
    font-size: 11px !important;
    font-weight: 600 !important;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.7) !important;
    /* More subtle color */

    /* Ensure visibility */
    opacity: 1;
    z-index: 200;
}

/* Optional: Color logic for specific messages */
/* Need JS for this, but base style is cleaner now */

/* --- STATIC MESSAGE (No floating) --- */
.psy-feedback-message-static {
    font-size: 11px !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.6) !important;
    text-align: center !important;
    margin-top: 4px !important;

    /* Ensure it takes distinct vertical space */
    position: static !important;
    display: block !important;
    height: 14px;
    /* Fixed height to prevent jumping */
    line-height: 14px;
    width: 100%;
}

/* --- ABSOLUTE OVERRIDE FOR MESSAGE --- */
#message {
    position: static !important;
    /* Force flow */
    display: block !important;
    width: 100% !important;
    text-align: center !important;
    margin-top: 5px !important;
    color: #fbbf24 !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    opacity: 1 !important;
    transform: none !important;
    left: auto !important;
    top: auto !important;
}

/* --- DEBUG RED MESSAGE --- */
#message {
    background: rgba(255, 0, 0, 0.5) !important;
    border: 2px solid yellow !important;
    color: white !important;
    min-width: 200px !important;
    min-height: 20px !important;
    z-index: 9999 !important;
}

/* --- CLEANUP & POLISH --- */

/* Remove Debug */
#message {
    background: transparent !important;
    border: none !important;
    color: #fbbf24 !important;
    min-width: 0 !important;
    min-height: 0 !important;

    /* Perfect Positioning */
    margin-top: 8px !important;
    /* Space between bar and text */
    text-align: center !important;
    width: 100% !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.8 !important;
}

/* Make Progress Bar Beautiful */
.psy-progress-track {
    background: rgba(255, 255, 255, 0.2) !important;
    /* Lighter track */
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2) !important;
    height: 8px !important;
}

.psy-progress-bar {
    background: linear-gradient(90deg, #fbbf24, #f59e0b) !important;
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.4) !important;
}

/* --- FLOATING MESSAGE (NO LAYOUT IMPACT) --- */
#message {
    position: fixed !important;
    /* Total removal from layout flow */
    top: 15% !important;
    /* Move to TOP to avoid keyboard occlusion */
    bottom: auto !important;
    left: 50% !important;
    transform: translateX(-50%) !important;

    width: auto !important;
    min-width: 200px;
    background: rgba(15, 23, 42, 0.8) !important;
    padding: 8px 16px !important;
    border-radius: 20px !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(4px);

    text-align: center !important;
    color: #fbbf24 !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    z-index: 5000 !important;
    /* Above everything */

    pointer-events: none !important;
}

#message:empty {
    display: none !important;
    padding: 0 !important;
    border: none !important;
}

/* Hide empty message completely */
#message:empty,
#message[style*="display: none"] {
    display: none !important;
    padding: 0 !important;
    border: none !important;
}