:root {
  --bg-primary: #0a0e14;
  --bg-panel: #0d1117;
  --bg-toolbar: #1a1a2e;
  --border: #21262d;
  --green: #33ff33;
  --amber: #ffb000;
  --gray: #8b949e;
  --yellow: #ffd700;
  --red: #ff4444;
  --blue: #58a6ff;
  --font-mono: 'IBM Plex Mono', 'Consolas', monospace;
  --font-retro: 'VT323', monospace;
}

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

body {
  background: var(--bg-primary);
  color: #c9d1d9;
  font-family: var(--font-mono);
  overflow: hidden;
  height: 100vh;
}

#root { height: 100vh; display: flex; flex-direction: column; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #484f58; }

.led {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: all 0.15s;
}

.led-on {
  background: var(--green);
  box-shadow: 0 0 4px var(--green), 0 0 8px var(--green);
}

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

.led-red {
  background: var(--red);
  box-shadow: 0 0 4px var(--red), 0 0 8px var(--red);
}

.led-amber {
  background: var(--amber);
  box-shadow: 0 0 4px var(--amber), 0 0 8px var(--amber);
}

.register-changed {
  animation: flash-yellow 0.5s ease-out;
}

@keyframes flash-yellow {
  0% { color: var(--yellow); text-shadow: 0 0 6px var(--yellow); }
  100% { color: var(--green); text-shadow: none; }
}

@keyframes scanline {
  0% { transform: translateY(0); }
  100% { transform: translateY(4px); }
}

.crt-container {
  position: relative;
  border-radius: 16px;
  padding: 12px;
  background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
  box-shadow: inset 0 0 30px rgba(0,0,0,0.5), 0 0 20px rgba(0,0,0,0.8);
}

.crt-screen {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
}

.crt-screen::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.15) 0px,
    rgba(0,0,0,0.15) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 2;
}

.crt-screen::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.4) 100%);
  pointer-events: none;
  z-index: 3;
}

.crt-canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  width: 100%;
  height: auto;
}

.panel-section {
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 6px;
  background: rgba(13,17,23,0.8);
}

.panel-header {
  padding: 4px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: var(--amber);
  background: rgba(30,35,44,0.6);
  border-bottom: 1px solid var(--border);
  user-select: none;
}

.panel-body {
  padding: 6px 8px;
  font-size: 11px;
}

.reg-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px 8px;
}

.reg-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1px 0;
}

.reg-name {
  color: var(--amber);
  font-size: 10px;
  font-weight: 600;
  min-width: 24px;
}

.reg-val {
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
}

.flags-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.flag-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.flag-label {
  font-size: 8px;
  color: var(--gray);
}

.hex-row {
  display: flex;
  font-size: 10px;
  line-height: 16px;
  font-family: var(--font-mono);
}

.hex-addr {
  color: var(--gray);
  min-width: 50px;
}

.hex-bytes {
  color: var(--green);
  flex: 1;
  letter-spacing: 0.5px;
}

.hex-ascii {
  color: #6e7681;
  min-width: 80px;
  margin-left: 8px;
}

.btn-hw {
  padding: 4px 10px;
  border: 1px solid #333;
  border-radius: 3px;
  background: linear-gradient(180deg, #3a3a4a 0%, #2a2a3a 100%);
  color: #ccc;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.1s;
  white-space: nowrap;
}

.btn-hw:hover {
  background: linear-gradient(180deg, #4a4a5a 0%, #3a3a4a 100%);
  border-color: var(--blue);
}

.btn-hw:active {
  transform: translateY(1px);
  background: linear-gradient(180deg, #2a2a3a 0%, #1a1a2a 100%);
}

.btn-hw.active {
  border-color: var(--green);
  color: var(--green);
  box-shadow: 0 0 4px rgba(51,255,51,0.3);
}

.log-entry {
  font-size: 10px;
  padding: 1px 4px;
  border-bottom: 1px solid rgba(33,38,45,0.5);
  font-family: var(--font-mono);
}

.io-log-entry {
  display: flex;
  gap: 8px;
  font-size: 10px;
  padding: 2px 4px;
  border-bottom: 1px solid rgba(33,38,45,0.5);
}

.tab-btn {
  padding: 3px 10px;
  font-size: 10px;
  font-family: var(--font-mono);
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--gray);
  cursor: pointer;
  border-bottom: none;
  border-radius: 3px 3px 0 0;
}

.tab-btn.active {
  background: var(--bg-primary);
  color: var(--green);
  border-color: var(--green);
}

.dot-bg {
  background-image: radial-gradient(circle, rgba(33,38,45,0.4) 1px, transparent 1px);
  background-size: 12px 12px;
}

.speed-display {
  font-family: var(--font-retro);
  font-size: 16px;
  color: var(--green);
  padding: 0 8px;
  letter-spacing: 1px;
}

.floppy-slot {
  position: relative;
  padding: 4px 12px;
  border: 2px solid #444;
  border-radius: 3px;
  background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 160px;
}

.floppy-slot::before {
  content: '';
  display: block;
  width: 40px;
  height: 3px;
  background: #333;
  border: 1px solid #555;
  border-radius: 1px;
}

.mode-toggle {
  display: flex;
  border: 1px solid #444;
  border-radius: 3px;
  overflow: hidden;
}

.mode-toggle button {
  padding: 4px 10px;
  border: none;
  background: #1a1a2e;
  color: var(--gray);
  font-family: var(--font-mono);
  font-size: 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.mode-toggle button.active {
  background: #2a3a4a;
  color: var(--green);
}

.disasm-current {
  color: var(--green);
  font-weight: 600;
  padding: 2px 4px;
  background: rgba(51,255,51,0.1);
  border-radius: 2px;
}

.disasm-upcoming {
  color: #4a5568;
  padding: 1px 4px;
}

.disasm-prev {
  color: #3a3a4a;
  padding: 1px 4px;
}

@media (max-width: 768px) {
  .main-layout {
    flex-direction: column !important;
  }
  .left-panel, .right-panel {
    display: none;
  }
  .left-panel.mobile-active, .right-panel.mobile-active {
    display: block;
    position: fixed;
    top: 40px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    overflow: auto;
  }
}