: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;
  --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; }
.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 #222; box-shadow: inset 0 0 30px rgba(0,0,0,0.8), 0 0 8px rgba(0,255,247,0.05); }

::-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); }

.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; }

/* ROM Analysis Panel Styles */
.rom-analysis-panel {
  background: #0a0a0a;
  border: 2px solid #ff8c00;
  border-radius: 4px;
  margin-bottom: 16px;
  overflow: hidden;
}

.rom-analysis-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(90deg, #1a0f00, #0a0a0a);
  border-bottom: 1px solid #332200;
}

.rom-analysis-header span:first-child {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
}

.rom-format-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  padding: 3px 8px;
  background: #2a1a00;
  color: #ff8c00;
  border: 1px solid #ff8c0066;
  border-radius: 2px;
}

.rom-terminal {
  background: #000;
  padding: 12px 14px;
  max-height: 250px;
  overflow-y: auto;
  border-bottom: 1px solid #1a1a1a;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  line-height: 1.6;
}

.rom-terminal-line {
  white-space: pre-wrap;
  word-break: break-all;
}

.rom-results-panel {
  padding: 14px;
  background: #0f0a05;
}

.rom-results-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #ff8c00;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.rom-confidence {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.rom-confidence-bar {
  flex: 1;
  height: 8px;
  background: #111;
  border: 1px solid #333;
  border-radius: 1px;
  overflow: hidden;
}

.rom-confidence-fill {
  height: 100%;
  transition: width 0.3s;
  border-radius: 1px;
}

.rom-addr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.rom-addr-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rom-addr-field label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px;
  color: #888;
  text-transform: uppercase;
}

.rom-hex-input {
  display: flex;
  align-items: center;
  background: #111;
  border: 1px solid #333;
  padding: 3px 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
}

.rom-hex-input span {
  color: #666;
  margin-right: 2px;
}

.rom-hex-input input {
  background: none;
  border: none;
  color: #00fff7;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  width: 40px;
  outline: none;
}

.rom-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.rom-limitations {
  border-top: 1px solid #1a1a0a;
  padding-top: 8px;
}

.rom-limitations p {
  margin-bottom: 2px;
}

@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; }
  .rom-addr-grid { grid-template-columns: 1fr 1fr; }
}