:root {
  --pcb-dark: #0a1a0a;
  --pcb-green: #0d2e0d;
  --pcb-trace: #1a4a1a;
  --led-on: #ff3300;
  --led-off: #2a0800;
  --led-glow: #ff4400;
  --terminal-green: #33ff33;
  --terminal-amber: #ffaa00;
  --copper: #b87333;
  --btn-dark: #2a2a2a;
  --btn-func: #6b4226;
}

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

body {
  background: var(--pcb-dark);
  font-family: 'VT323', monospace;
  color: #ccc;
  min-height: 100vh;
  overflow-x: hidden;
}

/* PCB background pattern */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(26,74,26,0.15) 39px, rgba(26,74,26,0.15) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(26,74,26,0.15) 39px, rgba(26,74,26,0.15) 40px);
  pointer-events: none;
  z-index: 0;
}

/* Seven segment display */
.seg-display {
  background: #0a0a0a;
  border: 2px solid #222;
  border-radius: 4px;
  padding: 12px 16px;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.8), 0 0 10px rgba(0,0,0,0.5);
}

.segment {
  fill: var(--led-off);
  transition: fill 0.05s;
}

.segment.on {
  fill: var(--led-on);
  filter: drop-shadow(0 0 3px var(--led-glow)) drop-shadow(0 0 8px rgba(255,51,0,0.4));
}

/* KIM key buttons */
.kim-key {
  background: linear-gradient(180deg, #444 0%, #2a2a2a 100%);
  border: 1px solid #555;
  border-bottom: 3px solid #111;
  border-radius: 4px;
  color: #eee;
  font-family: 'VT323', monospace;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.08s;
  user-select: none;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kim-key:hover {
  background: linear-gradient(180deg, #555 0%, #3a3a3a 100%);
}

.kim-key:active, .kim-key.pressed {
  background: linear-gradient(180deg, #222 0%, #333 100%);
  border-bottom: 1px solid #111;
  transform: translateY(2px);
}

.kim-key.func {
  background: linear-gradient(180deg, #8b5e3c 0%, #6b4226 100%);
  border-color: #9b6e4c;
  border-bottom-color: #3a2010;
  min-width: 52px;
  font-size: 16px;
}

.kim-key.func:hover {
  background: linear-gradient(180deg, #9b6e4c 0%, #7b5236 100%);
}

.kim-key.func:active, .kim-key.func.pressed {
  background: linear-gradient(180deg, #5b3216 0%, #6b4226 100%);
}

/* Status LED */
.status-led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.status-led.running {
  background: #33ff33;
  box-shadow: 0 0 6px #33ff33, 0 0 12px rgba(51,255,51,0.4);
  animation: ledPulse 1s ease-in-out infinite;
}

.status-led.halted {
  background: #ff3333;
  box-shadow: 0 0 4px #ff3333;
}

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

/* Scrollbar styling */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #111; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

/* Memory viewer */
.mem-cell {
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  padding: 1px 2px;
}

.mem-cell.rom { color: #6699ff; }
.mem-cell.io { color: #ffcc00; }
.mem-cell.ram { color: #aaa; }
.mem-cell.pc-highlight { background: #ff330044; color: #ff6633; font-weight: bold; }

/* Panel styling */
.panel {
  background: linear-gradient(180deg, #111 0%, #0a0a0a 100%);
  border: 1px solid #2a2a2a;
  border-radius: 6px;
}

/* KIM-1 board frame */
.kim-board {
  background: linear-gradient(135deg, #0d2e0d 0%, #0a1f0a 50%, #0d2e0d 100%);
  border: 3px solid var(--copper);
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(0,0,0,0.6), inset 0 0 30px rgba(0,0,0,0.3), 0 0 2px var(--copper);
  position: relative;
}

/* Copper trace decoration */
.kim-board::before {
  content: '';
  position: absolute;
  top: 4px; left: 4px; right: 4px; bottom: 4px;
  border: 1px solid rgba(184,115,51,0.2);
  border-radius: 4px;
  pointer-events: none;
}

/* Tab buttons */
.tab-btn {
  font-family: 'VT323', monospace;
  font-size: 16px;
  padding: 6px 16px;
  border: 1px solid #333;
  background: #1a1a1a;
  color: #888;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn.active {
  background: #222;
  color: var(--terminal-green);
  border-color: var(--terminal-green);
}

.tab-btn:hover:not(.active) {
  color: #ccc;
  background: #222;
}

/* Toast message */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #222;
  border: 1px solid var(--copper);
  color: var(--terminal-amber);
  padding: 10px 20px;
  border-radius: 6px;
  font-family: 'VT323', monospace;
  font-size: 18px;
  z-index: 1000;
  animation: toastIn 0.3s ease-out, toastOut 0.3s ease-in 2.7s forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Control button */
.ctrl-btn {
  font-family: 'VT323', monospace;
  font-size: 16px;
  padding: 6px 14px;
  border: 1px solid #444;
  border-radius: 4px;
  background: #222;
  color: #ccc;
  cursor: pointer;
  transition: all 0.1s;
}

.ctrl-btn:hover {
  background: #333;
  border-color: #666;
}

.ctrl-btn.run { border-color: #2a7a2a; color: #33ff33; }
.ctrl-btn.run:hover { background: #1a3a1a; }
.ctrl-btn.pause { border-color: #7a7a2a; color: #ffaa00; }
.ctrl-btn.pause:hover { background: #3a3a1a; }
.ctrl-btn.reset { border-color: #7a2a2a; color: #ff4444; }
.ctrl-btn.reset:hover { background: #3a1a1a; }

@media (max-width: 768px) {
  .kim-key { min-width: 38px; min-height: 38px; font-size: 15px; }
  .kim-key.func { min-width: 44px; font-size: 14px; }
}