:root {
  --bg-dark: #0d0d0d;
  --bg-panel: #141414;
  --pcb-green: #1a3a18;
  --pcb-green-light: #245522;
  --pcb-trace: #2a6a24;
  --led-red: #ff2200;
  --led-dim: #330800;
  --led-glow: #ff4400;
  --amber: #ff8c00;
  --amber-dim: #3d2200;
  --terminal-green: #33ff33;
  --text-muted: #666;
  --btn-dark: #2a2420;
  --btn-face: #3d3530;
  --btn-light: #4a4038;
  --border-gold: #8a7a5a;
}

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

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

/* Scanline overlay */
.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.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
  pointer-events: none;
  z-index: 10;
}

/* 7-segment display */
.segment {
  position: absolute;
  background: var(--led-dim);
  border-radius: 1px;
  transition: background 0.05s, box-shadow 0.05s;
}

.segment.on {
  background: var(--led-red);
  box-shadow: 0 0 8px var(--led-glow), 0 0 16px rgba(255,68,0,0.4);
}

.segment.horizontal {
  width: 18px;
  height: 4px;
}

.segment.vertical {
  width: 4px;
  height: 16px;
}

.digit-container {
  position: relative;
  width: 32px;
  height: 48px;
  margin: 0 4px;
}

/* KIM-1 button styles */
.kim-btn {
  background: linear-gradient(180deg, #4a4038 0%, #3d3530 40%, #2a2420 100%);
  border: 1px solid #1a1410;
  border-radius: 3px;
  color: #eee;
  font-family: 'VT323', monospace;
  font-size: 18px;
  cursor: pointer;
  padding: 8px 4px;
  min-width: 48px;
  min-height: 44px;
  text-align: center;
  box-shadow: 0 3px 0 #1a1410, 0 4px 6px rgba(0,0,0,0.5);
  transition: all 0.08s;
  user-select: none;
  -webkit-user-select: none;
}

.kim-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #1a1410, 0 2px 3px rgba(0,0,0,0.3);
  background: linear-gradient(180deg, #3d3530 0%, #2a2420 100%);
}

.kim-btn:hover {
  background: linear-gradient(180deg, #5a5048 0%, #4d4540 40%, #3a3430 100%);
}

.kim-btn.control {
  background: linear-gradient(180deg, #6a3030 0%, #5a2020 40%, #4a1515 100%);
  border-color: #300a0a;
  box-shadow: 0 3px 0 #300a0a, 0 4px 6px rgba(0,0,0,0.5);
}

.kim-btn.control:active {
  box-shadow: 0 1px 0 #300a0a, 0 2px 3px rgba(0,0,0,0.3);
  background: linear-gradient(180deg, #5a2020 0%, #4a1515 100%);
}

.kim-btn.control:hover {
  background: linear-gradient(180deg, #7a4040 0%, #6a3030 40%, #5a2525 100%);
}

/* PCB texture */
.pcb-board {
  background: 
    radial-gradient(circle at 10% 10%, rgba(42,106,36,0.3) 0%, transparent 50%),
    radial-gradient(circle at 90% 90%, rgba(42,106,36,0.2) 0%, transparent 50%),
    linear-gradient(135deg, #1a3a18 0%, #173215 50%, #142a12 100%);
  border: 2px solid #0a1a08;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.5), 0 8px 32px rgba(0,0,0,0.6);
}

/* PCB holes decoration */
.pcb-hole {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #0a0a0a;
  border: 1px solid #2a6a24;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.8);
}

/* Memory viewer */
.mem-row {
  font-size: 11px;
  line-height: 1.6;
  white-space: nowrap;
}

.mem-row.highlight {
  background: rgba(255,140,0,0.15);
}

.mem-row.rom {
  background: rgba(42,106,36,0.15);
}

.mem-byte {
  cursor: pointer;
  padding: 0 1px;
  border-radius: 2px;
}

.mem-byte:hover {
  background: rgba(255,140,0,0.3);
}

/* Control buttons */
.ctrl-btn {
  background: linear-gradient(180deg, #2a2a2a, #1a1a1a);
  border: 1px solid #333;
  color: var(--amber);
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  transition: all 0.1s;
}

.ctrl-btn:hover {
  background: linear-gradient(180deg, #3a3a3a, #2a2a2a);
  border-color: var(--amber);
}

.ctrl-btn:active {
  transform: scale(0.97);
}

.ctrl-btn.running {
  border-color: var(--terminal-green);
  color: var(--terminal-green);
  box-shadow: 0 0 8px rgba(51,255,51,0.2);
}

/* Speed slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: #333;
  border-radius: 2px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--amber);
  cursor: pointer;
  box-shadow: 0 0 6px rgba(255,140,0,0.4);
}

/* Collapsible panels */
.panel-header {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.panel-header:hover {
  color: var(--amber);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #111; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* Flag display */
.flag-bit {
  display: inline-block;
  width: 20px;
  text-align: center;
  padding: 2px 0;
  border-radius: 2px;
  font-size: 12px;
}

.flag-bit.set {
  background: rgba(255,140,0,0.3);
  color: var(--amber);
}

.flag-bit.clear {
  background: rgba(100,100,100,0.1);
  color: #555;
}

/* Title glow */
.title-glow {
  text-shadow: 0 0 10px rgba(255,140,0,0.5), 0 0 20px rgba(255,140,0,0.2);
}

/* About modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  max-width: 500px;
  width: 90%;
  padding: 24px;
  max-height: 80vh;
  overflow-y: auto;
}

@media (max-width: 1024px) {
  .digit-container {
    width: 28px;
    height: 42px;
    margin: 0 3px;
  }
  .segment.horizontal { width: 15px; height: 3px; }
  .segment.vertical { width: 3px; height: 13px; }
}

@media (max-width: 640px) {
  .kim-btn { min-width: 40px; min-height: 38px; font-size: 15px; padding: 6px 2px; }
  .digit-container { width: 24px; height: 36px; margin: 0 2px; }
  .segment.horizontal { width: 12px; height: 3px; }
  .segment.vertical { width: 3px; height: 11px; }
}