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

:root {
    /* Colors based on the mascot */
    --coral: #E07850;
    --coral-light: #F0956D;
    --coral-dark: #C45A35;
    --coral-deep: #A04020;
    --brown: #5C3D2E;
    --brown-light: #8B5A42;
    --cream: #FFF5E6;
    --cream-dark: #FFE4CC;
    --sky-blue: #7DD3FC;
    --sky-dark: #38BDF8;
    
    /* UI Colors */
    --bg-primary: #1A1210;
    --bg-secondary: #241A16;
    --bg-tertiary: #2E221C;
    --surface: #3A2A22;
    --surface-light: #4A3A30;
    --border: #5C4A3E;
    --text-primary: #FFF5E6;
    --text-secondary: #D4B8A8;
    --text-muted: #9A7A68;
    --accent: var(--coral);
    --accent-light: var(--coral-light);
    --accent-dark: var(--coral-dark);
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --white-key: #FFFAF5;
    --white-key-active: var(--coral-light);
    --black-key: var(--brown);
    --black-key-active: var(--coral-dark);
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--bg-tertiary) 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

.app {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
}

.logo-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.mascot-container {
    position: relative;
}

.mascot {
    width: 280px;
    height: auto;
    filter: drop-shadow(0 12px 35px rgba(224, 120, 80, 0.5));
    transition: transform 0.1s ease;
}

/* Mascot animations */
.mascot.playing {
    animation: mascotJam 0.3s ease;
}

.mascot.sway {
    animation: mascotSway 0.5s ease-in-out;
}

.mascot.jump {
    animation: mascotJump 0.4s ease;
}

.mascot.continuous-play {
    animation: mascotDance 0.6s ease-in-out infinite;
}

@keyframes mascotJam {
    0% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(-8deg) scale(1.05); }
    50% { transform: rotate(8deg) scale(1.1); }
    75% { transform: rotate(-5deg) scale(1.05); }
    100% { transform: rotate(0deg) scale(1); }
}

@keyframes mascotSway {
    0% { transform: translateX(0) rotate(0deg); }
    25% { transform: translateX(-15px) rotate(-10deg); }
    75% { transform: translateX(15px) rotate(10deg); }
    100% { transform: translateX(0) rotate(0deg); }
}

@keyframes mascotJump {
    0% { transform: translateY(0) scale(1); }
    30% { transform: translateY(-30px) scale(1.1); }
    50% { transform: translateY(-35px) scale(1.05); }
    100% { transform: translateY(0) scale(1); }
}

@keyframes mascotDance {
    0%, 100% { transform: translateX(0) rotate(0deg) scale(1); }
    25% { transform: translateX(-10px) rotate(-8deg) scale(1.05) translateY(-10px); }
    50% { transform: translateX(0) rotate(0deg) scale(1.1) translateY(-15px); }
    75% { transform: translateX(10px) rotate(8deg) scale(1.05) translateY(-10px); }
}

.logo-text {
    text-align: center;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: var(--coral);
    text-shadow: 0 2px 10px rgba(224, 120, 80, 0.3);
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
}

/* Controls Panel */
.controls-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.controls-panel > div {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 1.25rem;
}

.controls-panel label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--coral-light);
    margin-bottom: 0.75rem;
}

.instrument-buttons,
.record-buttons {
    display: flex;
    gap: 0.5rem;
}

.instrument-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 10px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.instrument-btn:hover {
    border-color: var(--coral);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.instrument-btn.active {
    background: linear-gradient(135deg, var(--coral) 0%, var(--coral-dark) 100%);
    border-color: var(--coral);
    color: white;
    box-shadow: 0 4px 15px rgba(224, 120, 80, 0.4);
}

.instrument-btn .icon {
    font-size: 1.3rem;
}

/* Recording Buttons */
.record-btn,
.play-btn,
.stop-btn,
.clear-btn,
.download-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 0.9rem;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.record-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid var(--border);
}

.record-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--danger);
    transform: translateY(-2px);
}

.record-btn.recording {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
    animation: pulse 1.5s infinite;
}

.record-icon {
    width: 10px;
    height: 10px;
    background: var(--danger);
    border-radius: 50%;
}

.record-btn.recording .record-icon {
    background: white;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { opacity: 0.8; box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

.play-btn {
    background: var(--success);
    color: white;
}

.play-btn:hover:not(:disabled) {
    background: #16a34a;
    transform: translateY(-2px);
}

.stop-btn {
    background: var(--warning);
    color: white;
}

.stop-btn:hover:not(:disabled) {
    background: #d97706;
    transform: translateY(-2px);
}

.clear-btn {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 2px solid var(--border);
}

.clear-btn:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border-color: var(--danger);
}

.download-btn {
    background: linear-gradient(135deg, var(--sky-blue) 0%, var(--sky-dark) 100%);
    color: #1a1a1a;
    border: none;
}

.download-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #93e0ff 0%, var(--sky-blue) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(125, 211, 252, 0.4);
}

.record-btn:disabled,
.play-btn:disabled,
.stop-btn:disabled,
.clear-btn:disabled,
.download-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Recording Status */
.recording-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.status-indicator {
    width: 10px;
    height: 10px;
    background: var(--text-muted);
    border-radius: 50%;
}

.recording-status.recording .status-indicator {
    background: var(--danger);
    animation: blink 1s infinite;
    box-shadow: 0 0 10px var(--danger);
}

.recording-status.playing .status-indicator {
    background: var(--success);
    animation: blink 0.5s infinite;
    box-shadow: 0 0 10px var(--success);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.status-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.timer {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    color: var(--coral-light);
    font-weight: 600;
}

/* Keyboard Section */
.keyboard-section {
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-light) 100%);
    border: 2px solid var(--border);
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.keyboard {
    display: flex;
    position: relative;
    height: 180px;
}

.key {
    position: relative;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 12px;
    transition: all 0.08s ease;
    user-select: none;
}

.key.white {
    width: 52px;
    height: 180px;
    background: linear-gradient(180deg, var(--white-key) 0%, #f5f0eb 100%);
    border-radius: 0 0 8px 8px;
    border: 1px solid #d4c4b4;
    margin: 0 1px;
    z-index: 1;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2), inset 0 -4px 0 #e8e0d8;
}

.key.white:hover {
    background: linear-gradient(180deg, #fff 0%, #faf5f0 100%);
}

.key.white.active {
    background: linear-gradient(180deg, var(--coral-light) 0%, var(--coral) 100%);
    transform: translateY(3px);
    box-shadow: 0 4px 10px rgba(224, 120, 80, 0.5), inset 0 -2px 0 var(--coral-dark);
}

.key.black {
    width: 34px;
    height: 110px;
    background: linear-gradient(180deg, #3a3a3a 0%, var(--black-key) 100%);
    border-radius: 0 0 5px 5px;
    margin: 0 -17px;
    z-index: 2;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.5), inset 0 -3px 0 rgba(0, 0, 0, 0.3);
}

.key.black:hover {
    background: linear-gradient(180deg, #4a4a4a 0%, #6a4a3a 100%);
}

.key.black.active {
    background: linear-gradient(180deg, var(--coral) 0%, var(--coral-dark) 100%);
    transform: translateY(2px);
    box-shadow: 0 3px 8px rgba(224, 120, 80, 0.6), inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

.key-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    font-weight: 700;
    opacity: 0.5;
    margin-bottom: 4px;
}

.key.white .key-label {
    color: var(--brown);
}

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

.key.active .key-label {
    color: white;
    opacity: 1;
}

.note-label {
    font-size: 0.7rem;
    color: var(--brown-light);
    font-weight: 700;
}

.key.white.active .note-label {
    color: white;
}

/* Recorded Section */
.recorded-section {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    display: none;
}

.recorded-section.visible {
    display: block;
}

.recorded-section h3 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--coral-light);
    margin-bottom: 0.75rem;
}

.notes-timeline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-height: 40px;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 10px;
}

.note-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.7rem;
    background: linear-gradient(135deg, var(--coral) 0%, var(--coral-dark) 100%);
    color: white;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(224, 120, 80, 0.3);
}

.note-chip.playing {
    animation: noteGlow 0.3s ease;
}

@keyframes noteGlow {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); background: var(--coral-light); box-shadow: 0 0 20px var(--coral); }
}

/* Sample Songs Section */
.samples-section {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.samples-section h3 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--coral-light);
    margin-bottom: 1rem;
    text-align: center;
}

.sample-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

@media (max-width: 900px) {
    .sample-buttons {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 500px) {
    .sample-buttons {
        grid-template-columns: 1fr;
    }
}

.sample-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1.2rem;
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sample-btn:hover {
    border-color: var(--coral);
    background: rgba(224, 120, 80, 0.1);
    transform: translateY(-2px);
}

.sample-btn.playing {
    background: linear-gradient(135deg, var(--coral) 0%, var(--coral-dark) 100%);
    border-color: var(--coral);
    box-shadow: 0 4px 20px rgba(224, 120, 80, 0.4);
}

.sample-icon {
    font-size: 1.5rem;
}

.sample-name {
    flex: 1;
}

/* Terminal Section */
.terminal-section {
    margin-bottom: 1.5rem;
}

.terminal {
    background: #0a0806;
    border: 2px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    font-family: 'JetBrains Mono', monospace;
}

.terminal-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-bottom: 2px solid var(--border);
}

.terminal-dots {
    display: flex;
    gap: 6px;
}

.terminal-dots span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.terminal-dots span:nth-child(1) { background: #ff5f56; }
.terminal-dots span:nth-child(2) { background: #ffbd2e; }
.terminal-dots span:nth-child(3) { background: #27ca40; }

.terminal-title {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.terminal-body {
    padding: 1rem;
    min-height: 150px;
    max-height: 250px;
    display: flex;
    flex-direction: column;
}

.terminal-output {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    line-height: 1.6;
}

.terminal-output p {
    margin-bottom: 0.3rem;
}

.terminal-output .system-msg {
    color: var(--text-muted);
}

.terminal-output .user-input {
    color: var(--success);
}

.terminal-output .music-output {
    color: var(--coral-light);
}

.terminal-output .error-msg {
    color: var(--danger);
}

.terminal-input-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.prompt {
    color: var(--coral);
    font-weight: 700;
}

#terminalInput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
}

#terminalInput::placeholder {
    color: var(--text-muted);
}

/* Footer */
footer {
    text-align: center;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border);
}

.key-hints p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0.25rem 0;
}

.key-hints strong {
    color: var(--coral-light);
}

/* Note burst effect */
.note-burst {
    position: fixed;
    pointer-events: none;
    font-size: 2rem;
    z-index: 1000;
    animation: noteBurst 1s ease-out forwards;
}

@keyframes noteBurst {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(-150px) scale(1.5) rotate(20deg);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .app {
        padding: 1rem;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    .mascot {
        width: 200px;
    }
    
    .controls-panel {
        grid-template-columns: 1fr;
    }
    
    .keyboard {
        transform: scale(0.7);
        transform-origin: center;
    }
    
    .keyboard-section {
        padding: 1rem;
    }
}

@media (max-width: 500px) {
    .keyboard {
        transform: scale(0.55);
    }
    
    .record-buttons {
        flex-wrap: wrap;
    }
}
