:root {
  --crt-color: #33ff33;
  --crt-dim: #0a3a0a;
  --crt-bg: #0a0a0a;
  --crt-panel: #111111;
  --crt-border: #1a3a1a;
  --crt-glow: 0 0 4px #33ff3366, 0 0 8px #33ff3322;
  --crt-text-glow: 0 0 3px #33ff3388;
  --crt-color-rgb: 51, 255, 51;
}

[data-theme="amber"] {
  --crt-color: #ffaa00;
  --crt-dim: #3a2a00;
  --crt-bg: #0a0a0a;
  --crt-panel: #111111;
  --crt-border: #3a2a00;
  --crt-glow: 0 0 4px #ffaa0066, 0 0 8px #ffaa0022;
  --crt-text-glow: 0 0 3px #ffaa0088;
  --crt-color-rgb: 255, 170, 0;
}

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

body {
  background: var(--crt-bg);
  color: var(--crt-color);
  font-family: 'Fira Code', 'Courier New', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

body::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.06) 2px, rgba(0,0,0,0.06) 4px);
}

.crt-panel {
  background: var(--crt-panel);
  border: 1px solid var(--crt-border);
  box-shadow: var(--crt-glow);
  border-radius: 2px;
}

.crt-text {
  color: var(--crt-color);
  text-shadow: var(--crt-text-glow);
}

.crt-btn {
  background: #1a1a1a;
  color: var(--crt-color);
  border: 1px solid var(--crt-border);
  font-family: 'Fira Code', monospace;
  cursor: pointer;
  padding: 4px 10px;
  font-size: 12px;
  transition: all 0.15s;
  text-shadow: var(--crt-text-glow);
}
.crt-btn:hover { background: #2a2a2a; box-shadow: var(--crt-glow); }
.crt-btn:active, .crt-btn.active { background: var(--crt-color); color: #000; text-shadow: none; }
.crt-btn:disabled { opacity: 0.4; cursor: default; }

textarea.crt-input {
  background: #0d0d0d;
  color: var(--crt-color);
  border: 1px solid var(--crt-border);
  font-family: 'Fira Code', monospace;
  font-size: 12px;
  resize: none;
  outline: none;
  text-shadow: var(--crt-text-glow);
  width: 100%;
  padding: 6px;
}
textarea.crt-input:focus { border-color: var(--crt-color); box-shadow: inset 0 0 5px rgba(0,0,0,0.5); }

select.crt-select {
  background: #1a1a1a;
  color: var(--crt-color);
  border: 1px solid var(--crt-border);
  font-family: 'Fira Code', monospace;
  font-size: 11px;
  outline: none;
  padding: 3px 6px;
  cursor: pointer;
}

.led-on {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--crt-color);
  box-shadow: 0 0 6px var(--crt-color), 0 0 12px var(--crt-color), 0 0 20px rgba(var(--crt-color-rgb), 0.3);
  display: inline-block;
  transition: all 0.2s;
}
.led-off {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #1a1a1a;
  border: 1px solid #333;
  display: inline-block;
  transition: all 0.2s;
}

@keyframes regPulse {
  0% { transform: scale(1); box-shadow: none; }
  50% { transform: scale(1.03); box-shadow: 0 0 8px rgba(var(--crt-color-rgb), 0.4); }
  100% { transform: scale(1); box-shadow: none; }
}
.reg-changed { animation: regPulse 0.4s ease; background: rgba(var(--crt-color-rgb), 0.08) !important; }

@keyframes bytePulse {
  0% { background: transparent; }
  50% { background: rgba(var(--crt-color-rgb), 0.25); }
  100% { background: transparent; }
}
.byte-changed { animation: bytePulse 0.5s ease; }

.scrollbar-crt::-webkit-scrollbar { width: 6px; height: 6px; }
.scrollbar-crt::-webkit-scrollbar-track { background: #0a0a0a; }
.scrollbar-crt::-webkit-scrollbar-thumb { background: var(--crt-border); border-radius: 3px; }
.scrollbar-crt::-webkit-scrollbar-thumb:hover { background: var(--crt-color); }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  background: #1a1a1a; height: 4px; border-radius: 2px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--crt-color); cursor: pointer;
  box-shadow: 0 0 4px var(--crt-color);
}

.hex-highlight { background: rgba(var(--crt-color-rgb), 0.2); }

.section-title {
  font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  border-bottom: 1px solid var(--crt-border);
  padding-bottom: 3px; margin-bottom: 6px; opacity: 0.8;
}

.reg-subsection {
  border: 1px solid rgba(var(--crt-color-rgb), 0.15);
  border-radius: 3px;
  padding: 6px;
  margin-bottom: 6px;
}
.reg-subsection-title {
  font-size: 9px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--crt-color); opacity: 0.6; margin-bottom: 4px;
  text-shadow: var(--crt-text-glow);
}

.hilo-cell {
  display: inline-flex;
  border: 1px solid rgba(var(--crt-color-rgb), 0.2);
  border-radius: 2px;
  overflow: hidden;
}
.hilo-half {
  padding: 1px 4px;
  font-size: 11px;
  min-width: 28px;
  text-align: center;
}
.hilo-divider {
  width: 1px;
  background: rgba(var(--crt-color-rgb), 0.3);
}

.bit-diagram {
  display: flex; gap: 1px; font-size: 9px;
}
.bit-cell {
  width: 22px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid #333; border-radius: 1px;
}
.bit-cell.active { border-color: rgba(var(--crt-color-rgb), 0.4); }
.bit-cell.set { background: rgba(var(--crt-color-rgb), 0.2); color: var(--crt-color); }
.bit-cell.reserved { opacity: 0.25; }

.phys-addr {
  font-size: 10px; opacity: 0.5; font-style: italic;
}

@media (max-width: 1200px) {
  .main-grid { grid-template-columns: 1fr 1fr !important; }
}
@media (max-width: 768px) {
  .main-grid { grid-template-columns: 1fr !important; }
}