:root {
    --bg-dark: #0a0a0f;
    --panel-bg: rgba(22, 22, 35, 0.4);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #8b5cf6;
    --accent-glow: rgba(139, 92, 246, 0.4);
    --accent-hover: #a78bfa;
    --danger: #ef4444;
    --secondary-glow: rgba(56, 189, 248, 0.1);
    
    --white-key-bg: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
    --white-key-pressed: linear-gradient(180deg, #e2e8f0 0%, #cbd5e1 100%);
    --black-key-bg: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    --black-key-pressed: linear-gradient(180deg, #020617 0%, #000000 100%);
    
    --key-shadow: 0 8px 10px rgba(0,0,0,0.5), inset 0 1px 1px rgba(255,255,255,0.6);
    --key-pressed-shadow: 0 2px 4px rgba(0,0,0,0.4), inset 0 2px 4px rgba(0,0,0,0.2);
    --black-key-shadow: 0 5px 6px rgba(0,0,0,0.8), inset 0 1px 2px rgba(255,255,255,0.2);
    --black-key-pressed-shadow: 0 1px 2px rgba(0,0,0,0.6), inset 0 -1px 3px rgba(0,0,0,0.5);
    
    --font-ui: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Theme Overrides */
[data-theme="epiano"] {
    --accent: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.4);
    --accent-hover: #7dd3fc;
    --secondary-glow: rgba(139, 92, 246, 0.1);
}
[data-theme="synth"] {
    --accent: #ec4899;
    --accent-glow: rgba(236, 72, 153, 0.4);
    --accent-hover: #f472b6;
    --secondary-glow: rgba(234, 179, 8, 0.1);
}
[data-theme="organ"] {
    --accent: #f59e0b;
    --accent-glow: rgba(245, 158, 11, 0.4);
    --accent-hover: #fbbf24;
    --secondary-glow: rgba(239, 68, 68, 0.1);
}
[data-theme="marimba"] {
    --accent: #10b981;
    --accent-glow: rgba(16, 185, 129, 0.4);
    --accent-hover: #34d399;
    --secondary-glow: rgba(59, 130, 246, 0.1);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-ui);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 40px 0;
}

/* Ambient Background Lights */
.app-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background: radial-gradient(circle at center, #13111c 0%, var(--bg-dark) 100%);
}

.ambient-light {
    position: absolute;
    top: -20%;
    left: 30%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 60%);
    filter: blur(80px);
    animation: pulse-slow 10s infinite alternate ease-in-out;
    transition: background 0.5s ease;
}

.ambient-light-bottom {
    position: absolute;
    bottom: -10%;
    right: 10%;
    width: 40vw;
    height: 40vw;
    background: radial-gradient(circle, var(--secondary-glow) 0%, transparent 60%);
    filter: blur(60px);
    animation: pulse-slow 15s infinite alternate-reverse ease-in-out;
    transition: background 0.5s ease;
}

@keyframes pulse-slow {
    0% { transform: scale(1) translate(0, 0); opacity: 0.8; }
    100% { transform: scale(1.1) translate(-5%, 5%); opacity: 1; }
}

/* Main Container */
.piano-container {
    width: 95%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    position: relative;
    z-index: 10;
}

/* Glassmorphism Panels */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    padding: 20px 26px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* Top Navigation / Controls */
.top-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.brand h1 {
    font-size: 1.7rem;
    font-weight: 600;
    letter-spacing: -0.8px;
    background: linear-gradient(90deg, #f8fafc, #c084fc);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 2px;
}

.brand p {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Controls Section */
.controls {
    display: flex;
    gap: 30px;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px 24px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
}

/* Custom Select */
.premium-select {
    appearance: none;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 8px 36px 8px 16px;
    color: var(--text-main);
    font-family: var(--font-ui);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}

.premium-select:hover, .premium-select:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.premium-select option {
    background: var(--bg-dark);
    color: var(--text-main);
}

.custom-select-wrapper {
    position: relative;
}

.custom-select-wrapper::after {
    content: '▼';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: var(--text-muted);
    pointer-events: none;
}

/* Slider */
.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.volume-icon {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.premium-slider {
    appearance: none;
    -webkit-appearance: none;
    width: 120px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
}

.premium-slider::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-main);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    transition: transform 0.1s;
}

.premium-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

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

.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 34px;
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-main);
    transition: .4s;
    border-radius: 50%;
}

input:checked + .switch-slider {
    background-color: var(--accent);
}

input:checked + .switch-slider:before {
    transform: translateX(20px);
    box-shadow: 0 0 10px var(--accent-glow);
}

/* Recording and Learning Panel */
.recording-panel {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.learning-label {
    color: #f59e0b !important;
}

.learning-stats {
    display: none;
    align-items: center;
    gap: 20px;
    background: rgba(0,0,0,0.4);
    padding: 8px 20px;
    border-radius: 50px;
    border: 1px solid rgba(255,255,255,0.05);
}

.song-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.song-info a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.song-info a:hover {
    text-decoration: underline;
}

.score-box {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
}

#score-val {
    color: var(--accent);
    font-size: 1.1rem;
}

.feedback {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.feedback.perfect { color: #10b981; text-shadow: 0 0 10px rgba(16,185,129,0.5); }
.feedback.good { color: #38bdf8; text-shadow: 0 0 10px rgba(56,189,248,0.5); }
.feedback.miss { color: #ef4444; text-shadow: 0 0 10px rgba(239,68,68,0.5); }

/* Status Display */
.status-display {
    font-size: 0.85rem;
    color: var(--accent);
    background: var(--accent-glow);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(139, 92, 246, 0.2);
    font-weight: 400;
    transition: all 0.3s;
}

.status-display.recording-active {
    color: #f87171;
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    animation: flash 1.5s infinite;
}

@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.rec-buttons {
    display: flex;
    gap: 8px;
}

.action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: 8px;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.action-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.action-btn:active:not(:disabled) {
    transform: translateY(1px);
}

.action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pulse-dot {
    width: 8px; height: 8px;
    background: var(--danger);
    border-radius: 50%;
    display: inline-block;
}

.rec-btn:not(:disabled):hover .pulse-dot {
    box-shadow: 0 0 8px var(--danger);
}

/* Learning Track System */
.learning-track-container {
    width: 100%;
    height: 120px;
    background: rgba(10, 10, 15, 0.6);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    margin-bottom: -10px;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.8);
}

.learning-track {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.learning-hit-zone {
    position: absolute;
    left: 80px; /* target hit position */
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 100px;
    border: 2px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 0 15px var(--accent-glow), inset 0 0 15px var(--accent-glow);
    z-index: 5;
    background: rgba(255,255,255,0.02);
}

.sliding-note {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 40px;
    background: var(--accent);
    border-radius: 6px;
    box-shadow: 0 0 10px var(--accent-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--bg-dark);
    text-transform: uppercase;
    z-index: 4;
    transition: none; /* handled by JS */
}

.sliding-note.black-note {
    background: #475569;
    color: white;
    height: 30px;
    border: 1px solid #1e293b;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.sliding-note.hit {
    background: #10b981;
    box-shadow: 0 0 20px #10b981;
    opacity: 0;
    transform: translateY(-50%) scale(1.5);
    transition: all 0.3s ease-out;
}

.sliding-note.missed {
    background: #ef4444;
    opacity: 0.3;
}

/* Keyboard System Setup */
.keyboard-wrapper {
    position: relative;
    padding: 30px 40px 40px 40px;
    background: linear-gradient(180deg, rgba(30, 30, 40, 0.8) 0%, rgba(10, 10, 15, 0.9) 100%);
    border-radius: 12px;
    border-top: 20px solid #1a1a24;
    border-bottom: 5px solid #050508;
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.8),
        inset 0 1px 0 rgba(255,255,255,0.1),
        inset 0 0 20px rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    overflow-x: auto;
    
    /* Adds subtle wood texture hint to top */
    background-image: linear-gradient(90deg, transparent 50%, rgba(255,255,255,0.01) 50%), 
                      linear-gradient(180deg, rgba(30, 30, 40, 0.8) 0%, rgba(10, 10, 15, 0.9) 100%);
    background-size: 4px 100%, 100% 100%;
}

.keyboard {
    display: flex;
    position: relative;
    user-select: none;
    perspective: 1000px;
}

/* White Key */
.white-key {
    width: 65px;
    height: 280px;
    background: var(--white-key-bg);
    border: 1px solid #ccc;
    border-top: none;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
    position: relative;
    margin: 0 1px;
    box-shadow: var(--key-shadow);
    transition: box-shadow 0.1s, transform 0.1s, background 0.1s;
    cursor: pointer;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 15px;
    transform-origin: top;
    z-index: 1;
}

/* Black Key container logic */
.black-key {
    width: 42px;
    height: 170px;
    background: var(--black-key-bg);
    border: 1px solid #000;
    border-top: none;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    position: absolute;
    /* Absolute position relative to the left white key */
    left: 100%;
    top: 0;
    transform: translateX(-50%);
    box-shadow: var(--black-key-shadow);
    z-index: 2;
    cursor: pointer;
    transition: box-shadow 0.1s, transform 0.1s, background 0.1s;
    transform-origin: top;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 12px;
}

/* Glowing Highlights - Edge details */
.white-key::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 15px transparent;
    transition: box-shadow 0.2s ease;
    pointer-events: none;
}
.black-key::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: inherit;
    border-bottom: 2px solid rgba(255,255,255,0.1);
    box-shadow: inset 0 0 10px transparent;
    transition: box-shadow 0.2s ease;
    pointer-events: none;
}

/* Pressed States */
.white-key.active {
    background: var(--white-key-pressed);
    transform: rotateX(1.5deg);
    box-shadow: var(--key-pressed-shadow);
}

.white-key.active::after {
    box-shadow: inset 0 0 20px var(--accent-glow);
}

/* Note: we target .active inside .black-key so it doesn't affect the root transform translation */
.black-key.active {
    background: var(--black-key-pressed);
    box-shadow: var(--black-key-pressed-shadow);
    /* Retain X translation, apply minimal rotation/scale for press */
    transform: translateX(-50%) rotateX(2deg) scaleY(0.99);
}

.black-key.active::after {
    box-shadow: inset 0 0 15px rgba(139, 92, 246, 0.6);
}

/* Key Labels */
.key-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #94a3b8;
    pointer-events: none;
    transition: color 0.1s;
    text-transform: uppercase;
}

.white-key:hover .key-label:not(.black-label) {
    color: #475569;
}

.white-key.active .key-label:not(.black-label) {
    color: var(--accent);
}

.black-label {
    color: rgba(255,255,255,0.3);
    font-size: 0.75rem;
}

.black-key:hover .black-label {
    color: rgba(255,255,255,0.6);
}

.black-key.active .black-label {
    color: var(--accent-hover);
}

/* Instructions Panel */
.instructions {
    display: flex;
    justify-content: center;
    gap: 40px;
    align-items: center;
    padding: 16px 32px;
}

.instruction-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.key-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.keys-visual {
    background: rgba(0,0,0,0.3);
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.05);
    font-family: monospace;
    font-size: 1rem;
    color: var(--accent-hover);
}

.mouse-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Responsive */
@media (max-width: 900px) {
    .instructions {
        flex-direction: column;
        gap: 15px;
    }
    .white-key {
        width: 45px;
        height: 220px;
    }
    .black-key {
        width: 30px;
        height: 130px;
    }
}

.dev-button {
    display: inline-flex;
    align-items: center;
    padding: 8px 22px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(10px);
    margin-top: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.dev-button strong {
    color: var(--accent);
    margin-left: 6px;
    font-weight: 600;
    transition: all 0.4s;
}

.dev-button:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--accent);
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3), 0 0 20px var(--accent-glow);
    color: var(--text-main);
}

.dev-button:hover strong {
    color: #fff;
    text-shadow: 0 0 10px var(--accent-glow);
}
