:root {
    --bg-dark: #0f0f1a;
    --bg-panel: #1a1a2e;
    --bg-control: #252542;
    --scope-color: #00ff41;
    --scope-glow: rgba(0, 255, 65, 0.5);
    --accent-red: #ff3d3d;
    --accent-blue: #3d9eff;
    --text-primary: #e0e0e0;
    --text-secondary: #888;
    --metal-dark: #2a2a3a;
    --metal-light: #3a3a4a;
}

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

body {
    background: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    min-height: 100vh;
    overflow-x: hidden;
}

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

/* Header */
#header {
    text-align: center;
    padding: 15px 20px;
    background: linear-gradient(180deg, #1a1a2e 0%, #0f0f1a 100%);
    border-bottom: 2px solid var(--scope-color);
    position: relative;
    overflow: hidden;
}

#header h1 {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(1.2rem, 4vw, 1.8rem);
    color: var(--scope-color);
    text-shadow: 0 0 20px var(--scope-glow);
    letter-spacing: 2px;
}

#header .chip-icon {
    margin-right: 10px;
}

#header .subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 5px;
    letter-spacing: 1px;
}

.scanline-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.1) 2px,
        rgba(0, 0, 0, 0.1) 4px
    );
    pointer-events: none;
}

/* Main Content */
#main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    padding: 15px 0;
}

@media (min-width: 768px) {
    #main-content {
        grid-template-columns: 1.5fr 1fr;
        grid-template-rows: auto auto;
    }
    
    #oscilloscope-section {
        grid-row: 1 / 3;
    }
}

/* Oscilloscope Section */
#oscilloscope-section {
    background: var(--bg-panel);
    border-radius: 10px;
    padding: 15px;
    border: 1px solid #333;
}

#oscilloscope-container {
    position: relative;
}

.crt-frame {
    position: relative;
    background: #050505;
    border-radius: 15px;
    padding: 10px;
    box-shadow: 
        inset 0 0 30px rgba(0, 0, 0, 0.8),
        0 0 20px rgba(0, 0, 0, 0.5);
    border: 3px solid #222;
}

#oscilloscope {
    width: 100%;
    height: 250px;
    border-radius: 10px;
    background: #0a0a0a;
}

@media (min-width: 768px) {
    #oscilloscope {
        height: 300px;
    }
}

.crt-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 1px,
        rgba(0, 0, 0, 0.05) 1px,
        rgba(0, 0, 0, 0.05) 2px
    );
    pointer-events: none;
    border-radius: 10px;
}

.phosphor-glow {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    box-shadow: inset 0 0 60px rgba(0, 255, 65, 0.05);
    pointer-events: none;
    border-radius: 10px;
}

/* Scope Readout */
#scope-readout {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 15px;
    padding: 10px;
    background: #0a0a0a;
    border-radius: 8px;
    border: 1px solid #222;
}

.readout-item {
    text-align: center;
}

.readout-item .label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-bottom: 3px;
}

.readout-item .value {
    font-family: 'Share Tech Mono', monospace;
    font-size: 1.2rem;
    color: var(--scope-color);
    text-shadow: 0 0 10px var(--scope-glow);
}

.readout-item .unit {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-left: 2px;
}

/* Scope Controls */
#scope-controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 15px;
    padding: 15px;
    background: linear-gradient(180deg, var(--metal-light) 0%, var(--metal-dark) 100%);
    border-radius: 8px;
    border: 1px solid #444;
}

@media (min-width: 500px) {
    #scope-controls {
        grid-template-columns: repeat(4, 1fr);
    }
}

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

.control-group label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Knobs */
.knob-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.knob {
    width: 50px;
    height: 50px;
    background: radial-gradient(circle at 30% 30%, #4a4a5a, #2a2a3a);
    border-radius: 50%;
    border: 2px solid #555;
    cursor: pointer;
    position: relative;
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.4),
        inset 0 1px 1px rgba(255, 255, 255, 0.1);
    transition: box-shadow 0.2s;
}

.knob:hover {
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.5),
        inset 0 1px 1px rgba(255, 255, 255, 0.15),
        0 0 10px var(--scope-glow);
}

.knob.small {
    width: 40px;
    height: 40px;
}

.knob-indicator {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 3px;
    height: 12px;
    background: var(--scope-color);
    border-radius: 2px;
    box-shadow: 0 0 5px var(--scope-glow);
}

.knob-value {
    font-size: 0.7rem;
    color: var(--scope-color);
}

/* Range Slider */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: #1a1a2e;
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--scope-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px var(--scope-glow);
}

/* Buttons */
.scope-btn {
    padding: 8px 16px;
    background: linear-gradient(180deg, #3a3a4a 0%, #2a2a3a 100%);
    border: 1px solid #555;
    border-radius: 5px;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
}

.scope-btn:hover {
    background: linear-gradient(180deg, #4a4a5a 0%, #3a3a4a 100%);
    border-color: var(--scope-color);
}

.scope-btn.active {
    background: var(--scope-color);
    color: #000;
    box-shadow: 0 0 15px var(--scope-glow);
}

.buttons-row {
    flex-direction: row !important;
    gap: 10px;
}

/* Chip Section */
#chip-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#chip-panel {
    background: var(--bg-panel);
    border-radius: 10px;
    padding: 20px;
    border: 1px solid #333;
}

/* Chip Visual */
#chip-visual {
    display: flex;
    justify-content: center;
    padding: 20px;
}

.chip-body {
    position: relative;
    width: 120px;
    height: 160px;
    background: linear-gradient(180deg, #1a1a1a 0%, #0a0a0a 100%);
    border-radius: 5px;
    border: 2px solid #333;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.chip-notch {
    position: absolute;
    top: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 10px;
    background: var(--bg-panel);
    border-radius: 0 0 10px 10px;
    border: 2px solid #333;
    border-top: none;
}

.chip-label {
    font-size: 0.6rem;
    color: #666;
    text-align: center;
    line-height: 1.4;
}

.pins {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.left-pins {
    left: -30px;
    top: 20px;
}

.right-pins {
    right: -30px;
    top: 20px;
}

.pin {
    position: relative;
    width: 25px;
    height: 8px;
    background: linear-gradient(90deg, #888 0%, #aaa 50%, #888 100%);
    border-radius: 2px;
}

.left-pins .pin-label {
    position: absolute;
    right: 30px;
    font-size: 0.55rem;
    color: #666;
    white-space: nowrap;
}

.right-pins .pin-label {
    position: absolute;
    left: 30px;
    font-size: 0.55rem;
    color: #666;
    white-space: nowrap;
}

.pin-glow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #333;
    transition: all 0.2s;
}

.left-pins .pin-glow {
    right: -3px;
}

.right-pins .pin-glow {
    left: -3px;
}

.pin.active .pin-glow {
    background: var(--scope-color);
    box-shadow: 0 0 10px var(--scope-glow);
}

/* Melody Controls */
#melody-controls {
    background: var(--bg-panel);
    border-radius: 10px;
    padding: 20px;
    border: 1px solid #333;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 15px;
}

.control-row label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    min-width: 100px;
}

#melody-select {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-control);
    border: 1px solid #444;
    border-radius: 5px;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    cursor: pointer;
}

#melody-select:focus {
    outline: none;
    border-color: var(--scope-color);
}

.button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

.big-btn {
    padding: 15px 20px;
    border: none;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.big-btn .btn-icon {
    font-size: 1.2rem;
}

.big-btn.trigger {
    background: linear-gradient(180deg, #2a5a2a 0%, #1a3a1a 100%);
    color: #4ade80;
    border: 2px solid #3a7a3a;
}

.big-btn.trigger:hover {
    background: linear-gradient(180deg, #3a6a3a 0%, #2a4a2a 100%);
    box-shadow: 0 0 20px rgba(74, 222, 128, 0.3);
}

.big-btn.trigger.playing {
    background: linear-gradient(180deg, #5a2a2a 0%, #3a1a1a 100%);
    color: #f87171;
    border-color: #7a3a3a;
}

.big-btn.reset {
    background: linear-gradient(180deg, #3a3a4a 0%, #2a2a3a 100%);
    color: var(--text-primary);
    border: 2px solid #4a4a5a;
}

.big-btn.reset:hover {
    background: linear-gradient(180deg, #4a4a5a 0%, #3a3a4a 100%);
}

/* Toggle switches */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.toggle-label input {
    display: none;
}

.toggle-slider {
    width: 36px;
    height: 18px;
    background: #2a2a3a;
    border-radius: 9px;
    position: relative;
    transition: background 0.2s;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: #666;
    border-radius: 50%;
    transition: all 0.2s;
}

.toggle-label input:checked + .toggle-slider {
    background: var(--scope-color);
}

.toggle-label input:checked + .toggle-slider::after {
    left: 20px;
    background: #fff;
}

/* Spectrum Section */
#spectrum-section {
    background: var(--bg-panel);
    border-radius: 10px;
    padding: 15px;
    border: 1px solid #333;
}

#spectrum-section h3 {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    letter-spacing: 1px;
}

#spectrum {
    width: 100%;
    height: 60px;
    border-radius: 5px;
    background: #0a0a0a;
}

/* Footer */
#footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    margin-top: 10px;
    border-top: 1px solid #333;
    font-size: 0.7rem;
}

.disclaimer {
    color: var(--text-secondary);
}

.powered-by {
    color: var(--scope-color);
    text-decoration: none;
    transition: text-shadow 0.2s;
}

.powered-by:hover {
    text-shadow: 0 0 10px var(--scope-glow);
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: #1a1a2e;
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 0.7rem;
    border: 1px solid var(--scope-color);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    max-width: 200px;
    pointer-events: none;
}

.tooltip.hidden {
    display: none;
}

/* Mobile adjustments */
@media (max-width: 500px) {
    #scope-readout {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .control-row {
        flex-direction: column;
        align-items: flex-start;
    }
    
    #melody-select {
        width: 100%;
    }
    
    #footer {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}