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

body {
    font-family: 'JetBrains Mono', monospace;
    background: linear-gradient(135deg, #1a0a2e 0%, #0f0518 100%);
    min-height: 100vh;
    color: #e0e0e0;
    overflow-x: hidden;
}

/* Noise texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%' height='100%' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
    z-index: 1000;
}

/* Init Screen */
.init-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: radial-gradient(circle at center, #2a1a4e 0%, #1a0a2e 70%);
}

.init-content {
    text-align: center;
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.gba-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.init-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 2rem;
    color: #00d4aa;
    text-shadow: 0 0 20px #00d4aa50;
    margin-bottom: 0.5rem;
}

.init-subtitle {
    color: #888;
    font-size: 0.875rem;
    margin-bottom: 2rem;
}

.init-button {
    background: linear-gradient(180deg, #00d4aa 0%, #00a884 100%);
    color: #0a0a0a;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.75rem;
    padding: 1rem 2rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 20px #00d4aa40, inset 0 2px 0 #00ffcc;
    transition: all 0.2s;
}

.init-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px #00d4aa60;
}

.init-hint {
    margin-top: 2rem;
    font-size: 0.75rem;
    color: #666;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: linear-gradient(180deg, #2d2d3a 0%, #1f1f2a 100%);
    border-radius: 12px;
    margin-bottom: 1rem;
    border: 1px solid #3d3d4a;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.power-led {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #1a1a2e;
    border: 2px solid #333;
    transition: all 0.3s;
}

.power-led.active {
    background: #00ff41;
    box-shadow: 0 0 10px #00ff41, 0 0 20px #00ff4180;
    animation: led-pulse 1s ease-in-out infinite;
}

@keyframes led-pulse {
    0%, 100% { box-shadow: 0 0 10px #00ff41, 0 0 20px #00ff4180; }
    50% { box-shadow: 0 0 15px #00ff41, 0 0 30px #00ff4180; }
}

.app-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 1.25rem;
    color: #00d4aa;
    text-shadow: 2px 2px 0 #0a0a0a;
}

.app-subtitle {
    font-size: 0.625rem;
    color: #888;
    margin-top: 0.25rem;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 1rem;
    flex: 1;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .oscilloscope-section {
        order: -1;
    }
}

/* Channels Section */
.channels-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.channel-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 640px) {
    .channel-row {
        grid-template-columns: 1fr;
    }
}

/* Channel Panel */
.channel-panel {
    background: linear-gradient(180deg, #2d2d3a 0%, #232330 100%);
    border-radius: 12px;
    padding: 1rem;
    border: 2px solid #3d3d4a;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: all 0.3s;
    opacity: 0.7;
}

.channel-panel.active {
    opacity: 1;
    border-color: #00d4aa40;
    box-shadow: 0 0 20px rgba(0, 212, 170, 0.1), inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.channel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #3d3d4a;
}

.channel-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.625rem;
    color: #00d4aa;
}

.channel-number {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.5rem;
    color: #666;
    margin-left: 0.5rem;
}

.channel-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* LED */
.led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: all 0.3s;
}

/* Toggle Switch */
.toggle-switch {
    width: 40px;
    height: 20px;
    background: #1a1a2e;
    border-radius: 10px;
    border: 2px solid #3d3d4a;
    cursor: pointer;
    position: relative;
    transition: all 0.3s;
}

.toggle-switch.active {
    background: #00d4aa30;
    border-color: #00d4aa;
}

.toggle-handle {
    width: 14px;
    height: 14px;
    background: linear-gradient(180deg, #666 0%, #444 100%);
    border-radius: 50%;
    position: absolute;
    top: 1px;
    left: 1px;
    transition: all 0.3s;
}

.toggle-switch.active .toggle-handle {
    left: 21px;
    background: linear-gradient(180deg, #00d4aa 0%, #00a884 100%);
}

/* Duty Selector */
.duty-btn {
    padding: 0.375rem 0.5rem;
    font-size: 0.625rem;
    font-family: 'JetBrains Mono', monospace;
    background: #1a1a2e;
    border: 1px solid #3d3d4a;
    color: #888;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.duty-btn.active {
    background: #00d4aa20;
    border-color: #00d4aa;
    color: #00d4aa;
}

.duty-btn:hover {
    border-color: #00d4aa80;
}

/* Knob */
.knob-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.knob {
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s;
}

.knob-indicator {
    width: 4px;
    height: 40%;
    border-radius: 2px;
    position: absolute;
    top: 8px;
}

.knob-row {
    display: flex;
    gap: 1rem;
    justify-content: flex-start;
    flex-wrap: wrap;
}

/* Wave Presets */
.wave-presets {
    display: flex;
    gap: 0.25rem;
}

.wave-btn {
    padding: 0.375rem 0.5rem;
    font-size: 0.5rem;
    font-family: 'JetBrains Mono', monospace;
    background: #1a1a2e;
    border: 1px solid #3d3d4a;
    color: #888;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.wave-btn.active {
    background: #ff6b9d20;
    border-color: #ff6b9d;
    color: #ff6b9d;
}

/* Noise Type */
.noise-type {
    display: flex;
    gap: 0.5rem;
}

.noise-btn {
    flex: 1;
    padding: 0.5rem;
    font-size: 0.625rem;
    font-family: 'JetBrains Mono', monospace;
    background: #1a1a2e;
    border: 1px solid #3d3d4a;
    color: #888;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.noise-btn.active {
    background: #9d4edd20;
    border-color: #9d4edd;
    color: #9d4edd;
}

/* Waveform Editor */
.waveform-editor {
    border: 2px solid #00ff4140;
    border-radius: 4px;
}

/* Oscilloscope Section */
.oscilloscope-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.oscilloscope-container {
    background: linear-gradient(180deg, #0f0f14 0%, #0a0a0e 100%);
    border-radius: 12px;
    padding: 1rem;
    border: 3px solid #1a1a24;
    box-shadow: inset 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 30px rgba(0, 255, 65, 0.05);
}

.oscilloscope-label {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.5rem;
    color: #00ff41;
    margin-bottom: 0.5rem;
    letter-spacing: 2px;
}

.oscilloscope-canvas {
    width: 100%;
    height: auto;
    border-radius: 8px;
    background: #0a0a0a;
}

.oscilloscope-info {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.625rem;
    color: #00ff4180;
    font-family: 'JetBrains Mono', monospace;
}

/* Keyboard Channel Select */
.keyboard-channel-select {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: #2d2d3a;
    border-radius: 8px;
    font-size: 0.75rem;
    color: #888;
}

.ch-select-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.625rem;
    font-family: 'JetBrains Mono', monospace;
    background: #1a1a2e;
    border: 1px solid #3d3d4a;
    color: #888;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.ch-select-btn.active {
    background: #00d4aa20;
    border-color: #00d4aa;
    color: #00d4aa;
}

/* Presets Section */
.presets-section {
    background: linear-gradient(180deg, #2d2d3a 0%, #232330 100%);
    border-radius: 12px;
    padding: 1rem;
    border: 2px solid #3d3d4a;
}

.presets-label {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.5rem;
    color: #ffaa00;
    margin-bottom: 0.75rem;
    letter-spacing: 1px;
}

.presets-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.preset-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.625rem;
    font-family: 'JetBrains Mono', monospace;
    background: linear-gradient(180deg, #3d3d4a 0%, #2d2d3a 100%);
    border: 1px solid #4d4d5a;
    color: #ccc;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-btn:hover {
    background: linear-gradient(180deg, #4d4d5a 0%, #3d3d4a 100%);
    border-color: #00d4aa80;
    color: #00d4aa;
    transform: translateY(-1px);
}

.preset-btn.randomize {
    background: linear-gradient(180deg, #9d4edd40 0%, #9d4edd20 100%);
    border-color: #9d4edd;
    color: #9d4edd;
}

/* Piano Container */
.piano-container {
    background: linear-gradient(180deg, #1a1a24 0%, #0f0f14 100%);
    border-radius: 12px;
    padding: 1rem;
    margin-top: auto;
    border: 2px solid #2d2d3a;
}

.piano-label {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.5rem;
    color: #00d4aa;
    margin-bottom: 0.75rem;
    letter-spacing: 1px;
}

.piano-keys {
    display: flex;
    justify-content: center;
    position: relative;
    height: 100px;
}

.piano-key {
    border: none;
    cursor: pointer;
    transition: all 0.1s;
    position: relative;
}

.piano-key.white {
    width: 36px;
    height: 100px;
    background: linear-gradient(180deg, #f0f0f0 0%, #d4d4d4 100%);
    border-radius: 0 0 4px 4px;
    margin: 0 1px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3), inset 0 -4px 0 #bbb;
    z-index: 1;
}

.piano-key.white:active {
    background: linear-gradient(180deg, #d4d4d4 0%, #c0c0c0 100%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), inset 0 -2px 0 #aaa;
    transform: translateY(2px);
}

.piano-key.black {
    width: 24px;
    height: 60px;
    background: linear-gradient(180deg, #333 0%, #111 100%);
    border-radius: 0 0 3px 3px;
    margin: 0 -12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

.piano-key.black:active {
    background: linear-gradient(180deg, #222 0%, #000 100%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    transform: translateY(2px);
}

.key-label {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.5rem;
    color: #666;
    font-family: 'JetBrains Mono', monospace;
}

@media (max-width: 768px) {
    .piano-keys {
        overflow-x: auto;
        justify-content: flex-start;
        padding-bottom: 10px;
    }
    
    .piano-key.white {
        width: 28px;
        min-width: 28px;
        height: 80px;
    }
    
    .piano-key.black {
        width: 18px;
        min-width: 18px;
        height: 50px;
        margin: 0 -9px;
    }
}

/* Footer */
.app-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    margin-top: 1rem;
    color: #666;
    font-size: 0.75rem;
}

.footer-link {
    color: #00d4aa;
    text-decoration: none;
    transition: all 0.2s;
}

.footer-link:hover {
    color: #00ffcc;
    text-shadow: 0 0 10px #00d4aa80;
}

.footer-info {
    color: #444;
    font-size: 0.625rem;
}

@media (max-width: 640px) {
    .app-footer {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .app-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .app-title {
        font-size: 1rem;
    }
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .app-container {
        padding: 0.5rem;
    }
    
    .channel-panel {
        padding: 0.75rem;
    }
    
    .app-title {
        font-size: 0.875rem;
    }
    
    .knob-row {
        justify-content: center;
    }
}