:root {
    --bg-primary: #1a0a2e;
    --bg-secondary: #12071f;
    --bg-panel: #0d0518;
    --accent-teal: #00a8a8;
    --accent-magenta: #ff6ec7;
    --accent-lime: #00ff41;
    --accent-cyan: #00ffff;
    --accent-yellow: #ffff00;
    --text-primary: #e8e8e8;
    --text-muted: #888;
    --border-color: #2a1a4a;
}

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

body {
    font-family: 'Press Start 2P', cursive;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #0f0520 50%, var(--bg-secondary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px;
}

/* Header */
.header {
    background: linear-gradient(180deg, #2a1a5a 0%, var(--bg-panel) 100%);
    border: 4px solid var(--accent-teal);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
}

.header:hover {
    transform: scale(1.01);
    box-shadow: 0 0 30px rgba(0, 168, 168, 0.3);
}

.header:active {
    transform: scale(0.99);
}

.header-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

.title {
    font-size: clamp(14px, 4vw, 28px);
    color: var(--accent-teal);
    text-shadow: 
        0 0 10px var(--accent-teal),
        0 0 20px var(--accent-teal),
        3px 3px 0 var(--bg-secondary);
    margin-bottom: 8px;
    letter-spacing: 2px;
}

.subtitle {
    font-size: clamp(8px, 2vw, 12px);
    color: var(--accent-magenta);
    text-shadow: 0 0 10px var(--accent-magenta);
}

.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.15) 2px,
        rgba(0, 0, 0, 0.15) 4px
    );
    pointer-events: none;
    z-index: 1;
}

/* Main Content */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Sections */
.oscilloscope-section,
.channels-section,
.master-section,
.keyboard-section {
    background: var(--bg-panel);
    border: 4px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
}

.section-header {
    margin-bottom: 12px;
}

.section-title {
    font-size: 10px;
    color: var(--accent-lime);
    text-shadow: 0 0 8px var(--accent-lime);
}

/* Oscilloscope */
.oscilloscope-container {
    position: relative;
    background: #0a0a12;
    border: 3px solid #1a1a2a;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 
        inset 0 0 30px rgba(0, 0, 0, 0.8),
        0 0 20px rgba(0, 255, 65, 0.1);
}

.oscilloscope-canvas {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

/* Channels Grid */
.channels-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (min-width: 768px) {
    .channels-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.channel-wrapper {
    cursor: pointer;
    transition: transform 0.1s;
}

.channel-wrapper:hover {
    transform: translateY(-2px);
}

.channel-wrapper.selected .channel-strip {
    box-shadow: 0 0 15px var(--channel-color);
}

/* Channel Strip */
.channel-strip {
    background: linear-gradient(180deg, #1a1030 0%, #0d0518 100%);
    border: 3px solid var(--channel-color);
    border-radius: 8px;
    padding: 12px;
    transition: box-shadow 0.2s;
}

.channel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--channel-color);
}

.led {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #333;
    transition: all 0.1s;
}

.led.active {
    background: var(--channel-color);
    box-shadow: 0 0 10px var(--channel-color);
    animation: pulse 0.5s ease-in-out infinite;
}

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

.channel-name {
    font-size: 10px;
    color: var(--channel-color);
    text-shadow: 0 0 5px var(--channel-color);
}

.channel-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

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

.control-group label {
    font-size: 7px;
    color: var(--text-muted);
}

.freq-display {
    font-family: 'VT323', monospace;
    font-size: 14px;
    color: var(--accent-lime);
    background: #0a0a0a;
    padding: 2px 6px;
    border-radius: 3px;
    text-align: center;
}

/* Sliders */
.retro-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: #1a1a2a;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

.retro-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-teal);
    border-radius: 2px;
    cursor: pointer;
    box-shadow: 0 0 8px var(--accent-teal);
}

.retro-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--accent-teal);
    border-radius: 2px;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 8px var(--accent-teal);
}

.volume-slider::-webkit-slider-thumb {
    background: var(--accent-magenta);
    box-shadow: 0 0 8px var(--accent-magenta);
}

.volume-slider::-moz-range-thumb {
    background: var(--accent-magenta);
    box-shadow: 0 0 8px var(--accent-magenta);
}

/* Duty Cycle Buttons */
.duty-buttons,
.noise-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
}

.duty-btn,
.noise-btn,
.preset-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 6px;
    padding: 6px 4px;
    background: #1a1a2a;
    border: 2px solid #2a2a4a;
    border-radius: 3px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.1s;
}

.duty-btn:hover,
.noise-btn:hover,
.preset-btn:hover {
    border-color: var(--accent-teal);
}

.duty-btn.active,
.noise-btn.active {
    background: var(--accent-teal);
    color: var(--bg-primary);
    border-color: var(--accent-teal);
    box-shadow: 0 0 10px var(--accent-teal);
}

/* Channel Buttons */
.channel-buttons {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.mute-btn,
.solo-btn {
    flex: 1;
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    padding: 8px;
    border: 2px solid #2a2a4a;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.1s;
}

.mute-btn {
    background: #2a1a1a;
    color: #ff4444;
}

.mute-btn.active {
    background: #ff4444;
    color: #fff;
    box-shadow: 0 0 10px #ff4444;
}

.solo-btn {
    background: #1a2a1a;
    color: #44ff44;
}

.solo-btn.active {
    background: #44ff44;
    color: #000;
    box-shadow: 0 0 10px #44ff44;
}

/* Wave Editor */
.wave-editor {
    background: #0a0a0a;
    border-radius: 4px;
    padding: 8px;
    margin-bottom: 8px;
}

.wave-grid {
    display: flex;
    gap: 1px;
    height: 50px;
    align-items: flex-end;
}

.wave-bar {
    flex: 1;
    background: var(--accent-yellow);
    min-height: 3px;
    cursor: ns-resize;
    transition: height 0.05s;
    border-radius: 1px 1px 0 0;
}

.wave-bar:hover {
    background: #ffff88;
}

.wave-presets {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

.wave-presets .preset-btn {
    flex: 1;
    background: #2a2a1a;
    color: var(--accent-yellow);
    border-color: var(--accent-yellow);
}

/* Master Section */
.master-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    justify-content: center;
}

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

.master-volume label {
    font-size: 8px;
    color: var(--accent-magenta);
}

.master-slider {
    width: 150px;
}

.vu-meter {
    display: flex;
    gap: 3px;
}

.vu-bar {
    width: 8px;
    height: 20px;
    background: #1a1a2a;
    border-radius: 2px;
    transition: background 0.1s;
}

.vu-bar.active {
    background: var(--accent-lime);
    box-shadow: 0 0 5px var(--accent-lime);
}

.vu-bar.active.hot {
    background: #ff4444;
    box-shadow: 0 0 5px #ff4444;
}

.play-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    padding: 15px 30px;
    background: linear-gradient(180deg, #2a4a2a 0%, #1a3a1a 100%);
    border: 4px solid var(--accent-lime);
    border-radius: 8px;
    color: var(--accent-lime);
    cursor: pointer;
    transition: all 0.1s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.play-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px var(--accent-lime);
}

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

.play-btn.playing {
    background: linear-gradient(180deg, #4a2a2a 0%, #3a1a1a 100%);
    border-color: #ff4444;
    color: #ff4444;
}

.play-btn.playing:hover {
    box-shadow: 0 0 20px #ff4444;
}

.play-icon {
    font-size: 16px;
}

.preset-selector {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.preset-selector label {
    font-size: 8px;
    color: var(--accent-cyan);
}

.preset-dropdown {
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    padding: 8px 12px;
    background: #1a1a2a;
    border: 2px solid var(--accent-cyan);
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
}

.preset-dropdown:focus {
    outline: none;
    box-shadow: 0 0 10px var(--accent-cyan);
}

/* Keyboard */
.keyboard-container {
    overflow-x: auto;
    padding-bottom: 10px;
}

.keyboard-label {
    font-size: 8px;
    color: var(--accent-teal);
    margin-bottom: 10px;
    text-align: center;
}

.keyboard {
    display: flex;
    justify-content: center;
    position: relative;
    height: 100px;
    min-width: fit-content;
}

.piano-key {
    position: relative;
    cursor: pointer;
    border: none;
    transition: all 0.05s;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 8px;
}

.piano-key.white {
    width: 40px;
    height: 100px;
    background: linear-gradient(180deg, #f0f0f0 0%, #d0d0d0 100%);
    border: 2px solid #888;
    border-radius: 0 0 4px 4px;
    z-index: 1;
}

.piano-key.black {
    width: 28px;
    height: 65px;
    background: linear-gradient(180deg, #333 0%, #111 100%);
    border: 2px solid #000;
    border-radius: 0 0 4px 4px;
    margin: 0 -14px;
    z-index: 2;
}

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

.piano-key.black:hover {
    background: linear-gradient(180deg, #444 0%, #222 100%);
}

.piano-key.pressed,
.piano-key:active {
    transform: translateY(3px);
}

.piano-key.white.pressed,
.piano-key.white:active {
    background: linear-gradient(180deg, var(--accent-teal) 0%, #008888 100%);
}

.piano-key.black.pressed,
.piano-key.black:active {
    background: linear-gradient(180deg, var(--accent-magenta) 0%, #cc5599 100%);
}

.key-label {
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    color: #666;
}

.piano-key.black .key-label {
    color: #888;
}

/* Footer */
.footer {
    margin-top: 20px;
    padding: 15px;
    text-align: center;
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.api-badge {
    font-size: 8px;
    color: var(--text-muted);
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.berrry-link {
    font-size: 8px;
    color: var(--accent-magenta);
    text-decoration: none;
    transition: all 0.2s;
}

.berrry-link:hover {
    color: #fff;
    text-shadow: 0 0 10px var(--accent-magenta);
}

/* Responsive */
@media (max-width: 480px) {
    .title {
        font-size: 12px;
    }
    
    .subtitle {
        font-size: 7px;
    }
    
    .channels-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .master-controls {
        flex-direction: column;
    }
    
    .piano-key.white {
        width: 30px;
        height: 80px;
    }
    
    .piano-key.black {
        width: 22px;
        height: 50px;
        margin: 0 -11px;
    }
    
    .key-label {
        font-size: 6px;
    }
}