:root {
  --bg-deep: #0a0a1a;
  --bg-primary: #0d1117;
  --bg-surface: #131a24;
  --bg-chip: #1a1a2e;
  --trace-green: #00ff41;
  --electric-blue: #00d4ff;
  --magenta: #ff006e;
  --amber: #ffbe0b;
  --text-primary: #e0e6ed;
  --text-dim: #6e7a8a;
  --pin-gold: #c4a43e;
}

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

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

#pcb-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}

#root {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

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

/* Power LED */
@keyframes powerPulse {
  0%, 100% { box-shadow: 0 0 4px #00ff41, 0 0 8px #00ff41; opacity: 0.8; }
  50% { box-shadow: 0 0 8px #00ff41, 0 0 20px #00ff41, 0 0 30px #00ff4166; opacity: 1; }
}

.power-led {
  width: 8px; height: 8px;
  background: #00ff41;
  border-radius: 50%;
  animation: powerPulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

/* Chip blocks */
.chip-block {
  background: linear-gradient(135deg, #1a1a2e 0%, #16162b 50%, #1e1e35 100%);
  border: 1px solid #2a2a4a;
  border-radius: 4px;
  position: relative;
  transition: all 0.3s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.chip-block:hover {
  border-color: var(--electric-blue);
  box-shadow: 0 0 15px rgba(0, 212, 255, 0.2);
  transform: translateY(-1px);
}

.chip-block::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--electric-blue), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.chip-block:hover::before { opacity: 1; }

.pin {
  width: 3px; height: 6px;
  background: var(--pin-gold);
  border-radius: 1px;
  flex-shrink: 0;
}

.pin-h {
  width: 6px; height: 3px;
  background: var(--pin-gold);
  border-radius: 1px;
  flex-shrink: 0;
}

/* Register inputs */
.register-cell {
  background: #0d0d1a;
  border: 1px solid #1e1e35;
  border-radius: 3px;
  padding: 3px 6px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--amber);
  font-size: 12px;
  transition: all 0.2s;
  min-height: 28px;
}

.register-cell:focus {
  border-color: var(--electric-blue);
  outline: none;
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.3);
}

/* Flag toggles */
.flag-toggle {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 3px;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.flag-on {
  background: var(--electric-blue);
  color: #000;
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.4);
}

.flag-off {
  background: #1a1a2e;
  color: var(--text-dim);
  border: 1px solid #2a2a4a;
}

/* LED indicators */
.led-indicator {
  width: 6px; height: 6px;
  border-radius: 50%;
  transition: all 0.3s;
  flex-shrink: 0;
}

.led-on {
  background: #00ff41;
  box-shadow: 0 0 6px #00ff41;
}

.led-off {
  background: #1a2a1a;
}

/* DMA bars */
.dma-bar {
  height: 14px;
  background: #0d0d1a;
  border-radius: 2px;
  overflow: hidden;
}

@keyframes dataFlow {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

.dma-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--electric-blue), var(--magenta), var(--electric-blue));
  background-size: 200% 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
  animation: dataFlow 1s linear infinite;
}

/* Palette cells */
.palette-cell {
  aspect-ratio: 1;
  border-radius: 1px;
  cursor: pointer;
  transition: transform 0.1s;
  border: 1px solid transparent;
  min-width: 0;
}

.palette-cell:hover {
  transform: scale(1.5);
  z-index: 10;
  border-color: white;
}

/* Section panels */
.section-panel {
  background: rgba(13, 17, 23, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid #1e2a3a;
  border-radius: 6px;
  overflow: hidden;
}

.section-header {
  background: linear-gradient(90deg, #131a24, #1a2030);
  padding: 10px 12px;
  border-bottom: 1px solid #1e2a3a;
  font-size: 11px;
  font-weight: 600;
  color: var(--electric-blue);
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  -webkit-tap-highlight-color: transparent;
  min-height: 40px;
}

.section-header:hover { background: linear-gradient(90deg, #162030, #1e2840); }

/* Preview screen */
.preview-screen {
  background: #000;
  border: 2px solid #2a2a4a;
  border-radius: 4px;
  image-rendering: pixelated;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5), inset 0 0 30px rgba(0, 0, 0, 0.3);
}

/* Mode buttons */
.mode-btn {
  padding: 6px 10px;
  border-radius: 3px;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid #2a2a4a;
  background: #131a24;
  color: var(--text-dim);
  min-height: 32px;
  -webkit-tap-highlight-color: transparent;
}

.mode-btn:hover { border-color: var(--electric-blue); color: var(--text-primary); }
.mode-btn:active { transform: scale(0.95); }

.mode-btn.active {
  background: var(--electric-blue);
  color: #000;
  border-color: var(--electric-blue);
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

/* Waveform bars */
.waveform-bar {
  background: linear-gradient(0deg, var(--electric-blue), var(--magenta));
  border-radius: 2px;
  transition: height 0.15s;
  min-height: 2px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2a4a; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a5a; }

/* Konami */
.konami-effect {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 9999;
  background: radial-gradient(circle at center, rgba(255, 0, 110, 0.4), transparent 70%);
  animation: konamiFlash 2s ease-out forwards;
}

@keyframes konamiFlash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  padding: 16px;
}

/* Responsive */
@media (max-width: 768px) {
  .palette-cell {
    min-width: 12px;
    min-height: 12px;
  }
  
  .register-cell {
    font-size: 11px;
    padding: 4px 5px;
  }
  
  .section-header {
    padding: 12px;
    font-size: 10px;
    min-height: 44px;
  }
  
  .flag-toggle {
    width: 32px;
    height: 32px;
    font-size: 11px;
  }
  
  .mode-btn {
    padding: 8px 12px;
    font-size: 11px;
    min-height: 36px;
  }
}