:root {
  --bg-deep: #0f0f23;
  --bg-panel: #1a1a2e;
  --bg-darker: #0a0a1a;
  --bg-filter: #0a1a0a;
  --cyan: #00fff7;
  --green: #39ff14;
  --magenta: #ff00ff;
  --red: #ff3333;
  --orange: #ff8c00;
  --blue: #4488ff;
  --white-dim: #aabbcc;
  --text: #e0e0e0;
  --border: #2a2a4e;
  --border-filter: #1a3a1a;
}

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

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

.pixel-font {
  font-family: 'Press Start 2P', monospace;
}

.scanlines {
  position: relative;
}
.scanlines::after {
  content: '';
  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;
}

.panel {
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 4px;
  position: relative;
}
.panel::before {
  content: '';
  position: absolute;
  top: -1px; left: -1px; right: -1px; bottom: -1px;
  border-radius: 5px;
  background: linear-gradient(135deg, rgba(0,255,247,0.1), transparent, rgba(255,0,255,0.05));
  z-index: -1;
}

.panel-filter {
  background: var(--bg-filter);
  border: 2px solid var(--border-filter);
  border-radius: 4px;
  position: relative;
}
.panel-filter::before {
  content: '';
  position: absolute;
  top: -1px; left: -1px; right: -1px; bottom: -1px;
  border-radius: 5px;
  background: linear-gradient(135deg, rgba(57,255,20,0.08), transparent, rgba(0,255,247,0.04));
  z-index: -1;
}

.pcb-traces {
  background-image:
    linear-gradient(90deg, rgba(57,255,20,0.03) 1px, transparent 1px),
    linear-gradient(0deg, rgba(57,255,20,0.03) 1px, transparent 1px);
  background-size: 20px 20px;
}

.pixel-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  padding: 8px 16px;
  border: 3px solid;
  border-color: #555 #222 #222 #555;
  background: #333;
  color: var(--text);
  cursor: pointer;
  transition: all 0.05s;
  text-transform: uppercase;
  image-rendering: pixelated;
}
.pixel-btn:hover {
  background: #444;
}
.pixel-btn:active {
  border-color: #222 #555 #555 #222;
  transform: translateY(1px);
}
.pixel-btn.active {
  background: var(--cyan);
  color: #000;
  border-color: #00cccc #006666 #006666 #00cccc;
}

.led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  transition: all 0.1s;
  flex-shrink: 0;
}
.led.active {
  box-shadow: 0 0 6px currentColor, 0 0 12px currentColor;
}

.cartridge-slot {
  background: linear-gradient(180deg, #111 0%, #1a1a1a 10%, #0d0d0d 90%, #000 100%);
  border: 3px solid #333;
  border-top: 5px solid #444;
  border-bottom: 5px solid #222;
  position: relative;
}
.cartridge-slot::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 4px;
  background: linear-gradient(90deg, transparent, #555, transparent);
}

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

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

.bounce-bars {
  display: inline-flex;
  gap: 2px;
  align-items: flex-end;
  height: 12px;
}
.bounce-bars span {
  display: block;
  width: 3px;
  background: var(--green);
  animation: bounce-bar 0.6s ease-in-out infinite;
}
.bounce-bars span:nth-child(2) { animation-delay: 0.1s; }
.bounce-bars span:nth-child(3) { animation-delay: 0.2s; }
.bounce-bars span:nth-child(4) { animation-delay: 0.3s; }

@keyframes bounce-bar {
  0%, 100% { height: 3px; }
  50% { height: 12px; }
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: #333;
  border-radius: 0;
  outline: none;
  border: 1px solid #555;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 18px;
  background: #666;
  border: 2px solid;
  border-color: #999 #333 #333 #999;
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 18px;
  background: #666;
  border: 2px solid;
  border-color: #999 #333 #333 #999;
  cursor: pointer;
  border-radius: 0;
}

.viz-canvas {
  background: #000;
  border: 2px solid #333;
  image-rendering: auto;
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-darker); }
::-webkit-scrollbar-thumb { background: #333; border: 1px solid #555; }

.track-list-item {
  padding: 6px 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.1s;
  font-size: 11px;
}
.track-list-item:hover {
  background: rgba(0,255,247,0.05);
  border-color: rgba(0,255,247,0.2);
}
.track-list-item.active {
  background: rgba(0,255,247,0.1);
  border-color: var(--cyan);
  box-shadow: 0 0 10px rgba(0,255,247,0.1);
}

.apu-ref-panel {
  border-color: #3a2a1a;
}
.apu-ref-panel::before {
  background: linear-gradient(135deg, rgba(255,140,0,0.08), transparent, rgba(255,140,0,0.04));
}

.apu-ref-heading {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: #ff8c00;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #2a2a1a;
  text-shadow: 0 0 8px rgba(255,140,0,0.3);
}

.apu-ref-p {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 1.7;
  color: #bbb;
  margin-bottom: 10px;
}

.apu-ref-pre {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  line-height: 1.5;
  color: #39ff14;
  background: #050510;
  border: 1px solid #1a1a3a;
  border-radius: 3px;
  padding: 10px 12px;
  margin-bottom: 12px;
  overflow-x: auto;
  white-space: pre;
  tab-size: 4;
}

.apu-ref-note {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  line-height: 1.6;
  color: #00fff7;
  background: #0a0a1a;
  border-left: 3px solid #00fff7;
  padding: 8px 12px;
  margin-bottom: 12px;
}

.filter-toggle {
  position: relative;
  width: 40px;
  height: 20px;
  background: #222;
  border: 2px solid #444;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-toggle.active {
  border-color: var(--green);
}
.filter-toggle .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: #555;
  border: 1px solid #777;
  transition: all 0.15s;
}
.filter-toggle.active .knob {
  left: 22px;
  background: var(--green);
  border-color: #5f5;
  box-shadow: 0 0 6px var(--green);
}

.bypass-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 8px 14px;
  border: 3px solid;
  border-color: #555 #222 #222 #555;
  background: #2a2a2a;
  color: #888;
  cursor: pointer;
  transition: all 0.1s;
  text-transform: uppercase;
}
.bypass-btn:hover { background: #333; }
.bypass-btn.active {
  background: #3a1111;
  color: var(--red);
  border-color: #ff3333 #990000 #990000 #ff3333;
  box-shadow: 0 0 12px rgba(255,51,51,0.3);
}

.filter-preset-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  padding: 4px 8px;
  border: 1px solid #333;
  background: #1a1a1a;
  color: #888;
  cursor: pointer;
  transition: all 0.1s;
}
.filter-preset-btn:hover { background: #252525; color: #aaa; }
.filter-preset-btn.active {
  background: #1a2a1a;
  color: var(--green);
  border-color: var(--green);
}

.signal-flow-line {
  height: 2px;
  flex: 1;
  min-width: 10px;
}

.freq-response-mini {
  width: 80px;
  height: 32px;
  background: #000;
  border: 1px solid #333;
}

.channel-card {
  transition: transform 0.1s, box-shadow 0.15s;
}
.channel-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

.channel-card canvas {
  width: 100% !important;
  display: block;
}

@media (max-width: 640px) {
  .filter-flow-diagram { flex-direction: column !important; align-items: stretch !important; }
  .filter-flow-diagram .signal-flow-line { height: 16px; width: 2px; min-width: 2px; min-height: 16px; margin: 0 auto; }
}