:root {
  --pcb-green: #2a4a1a;
  --pcb-light: #3d6b2e;
  --pcb-edge: #1e3812;
  --led-on: #ff3300;
  --led-off: #3a0800;
  --led-glow: rgba(255, 51, 0, 0.6);
  --key-bg: #2a2a2a;
  --key-hover: #3a3a3a;
  --key-active: #1a1a1a;
  --cream: #e8dcc8;
  --amber: #ffaa00;
  --board-bg: #1a1a1a;
}

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

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

.vt323 { font-family: 'VT323', monospace; }
.share-tech { font-family: 'Share Tech Mono', monospace; }

/* Seven Segment Display */
.segment-display {
  background: #0a0a0a;
  border: 2px solid #333;
  border-radius: 4px;
  padding: 12px 16px;
  display: flex;
  gap: 4px;
  align-items: center;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.8);
}

.segment-digit {
  position: relative;
  width: 28px;
  height: 48px;
}

.segment-separator {
  width: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.seg {
  position: absolute;
  background: var(--led-off);
  border-radius: 1px;
  transition: background 0.05s, box-shadow 0.05s;
}

.seg.on {
  background: var(--led-on);
  box-shadow: 0 0 6px var(--led-glow), 0 0 12px var(--led-glow);
}

/* Horizontal segments */
.seg-a, .seg-d, .seg-g {
  width: 18px;
  height: 3px;
  left: 5px;
}
.seg-a { top: 0; }
.seg-d { bottom: 0; }
.seg-g { top: 50%; transform: translateY(-50%); }

/* Vertical segments */
.seg-b, .seg-c, .seg-e, .seg-f {
  width: 3px;
  height: 20px;
}
.seg-b { right: 2px; top: 3px; }
.seg-c { right: 2px; bottom: 3px; }
.seg-e { left: 2px; bottom: 3px; }
.seg-f { left: 2px; top: 3px; }

/* DP */
.seg-dp {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  right: -2px;
  bottom: 0;
}

/* PCB texture */
.pcb-board {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.02) 25%, transparent 25%),
    linear-gradient(225deg, rgba(255,255,255,0.02) 25%, transparent 25%),
    linear-gradient(45deg, rgba(255,255,255,0.02) 25%, transparent 25%),
    linear-gradient(315deg, rgba(255,255,255,0.02) 25%, transparent 25%),
    linear-gradient(to bottom, var(--pcb-green), #1e3a10);
  background-size: 20px 20px, 20px 20px, 20px 20px, 20px 20px, 100% 100%;
  border: 3px solid var(--pcb-edge);
  border-radius: 8px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.05),
    0 8px 32px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.05);
}

/* Keypad button */
.kim-key {
  font-family: 'VT323', monospace;
  font-size: 18px;
  color: #eee;
  background: linear-gradient(to bottom, #444, #2a2a2a);
  border: 1px solid #555;
  border-bottom: 3px solid #1a1a1a;
  border-radius: 4px;
  padding: 8px 4px;
  cursor: pointer;
  user-select: none;
  text-align: center;
  min-width: 48px;
  min-height: 40px;
  transition: all 0.05s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.kim-key:hover {
  background: linear-gradient(to bottom, #555, #3a3a3a);
  border-color: #666;
}

.kim-key:active, .kim-key.pressed {
  background: linear-gradient(to bottom, #222, #333);
  border-bottom: 1px solid #1a1a1a;
  transform: translateY(2px);
  box-shadow: 0 0 2px rgba(0,0,0,0.3);
}

.kim-key.control {
  background: linear-gradient(to bottom, #8b4513, #5a2d0e);
  border-color: #a0522d;
  color: #ffddaa;
}

.kim-key.control:hover {
  background: linear-gradient(to bottom, #a0522d, #6b3410);
}

.kim-key.control:active {
  background: linear-gradient(to bottom, #4a2008, #5a2d0e);
}

/* Flag LED indicators */
.flag-led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #1a3a1a;
  border: 1px solid #333;
  display: inline-block;
}

.flag-led.set {
  background: #00ff44;
  box-shadow: 0 0 4px rgba(0,255,68,0.5), 0 0 8px rgba(0,255,68,0.3);
}

/* Memory viewer */
.mem-viewer {
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  background: #0d0d0d;
  border: 1px solid #333;
  border-radius: 4px;
  overflow-y: auto;
  max-height: 300px;
}

.mem-row {
  display: flex;
  padding: 1px 8px;
  border-bottom: 1px solid #1a1a1a;
}

.mem-row:hover {
  background: #1a1a1a;
}

.mem-addr {
  color: var(--amber);
  width: 50px;
  flex-shrink: 0;
}

.mem-byte {
  width: 24px;
  text-align: center;
  cursor: pointer;
  color: #aaa;
  padding: 0 1px;
}

.mem-byte:hover {
  background: #333;
  color: #fff;
}

.mem-byte.highlight {
  background: rgba(255,170,0,0.2);
  color: var(--amber);
}

.mem-byte.rom {
  color: #6a9;
}

.mem-ascii {
  color: #666;
  margin-left: 8px;
  flex-shrink: 0;
}

/* TTY terminal */
.tty-terminal {
  background: #0a0a0a;
  border: 2px solid #1a3a1a;
  border-radius: 4px;
  padding: 8px;
  font-family: 'VT323', monospace;
  font-size: 16px;
  color: #33ff33;
  min-height: 80px;
  max-height: 150px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.tty-cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: #33ff33;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* Silkscreen text */
.silkscreen {
  color: rgba(255,255,255,0.7);
  font-family: 'VT323', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Speed slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: #333;
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--amber);
  cursor: pointer;
}

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

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

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

/* Easter egg */
.easter-apple {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 120px;
  z-index: 2000;
  animation: fadeInOut 2s ease-in-out;
  pointer-events: none;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

@media (max-width: 768px) {
  .segment-digit {
    width: 22px;
    height: 38px;
  }
  .seg-a, .seg-d, .seg-g { width: 14px; }
  .seg-b, .seg-c, .seg-e, .seg-f { height: 15px; }
  .kim-key {
    font-size: 14px;
    min-width: 38px;
    min-height: 34px;
    padding: 6px 2px;
  }
  .mem-viewer { font-size: 10px; }
}