* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg-dark: #0A0A0A;
  --bg-panel: #0D0D1A;
  --bg-panel-alt: #111128;
  --cga-blue: #0000AA;
  --cga-cyan: #00AAAA;
  --cga-magenta: #AA00AA;
  --cga-white: #AAAAAA;
  --cga-bright-white: #FFFFFF;
  --cga-green: #00AA00;
  --cga-bright-green: #00FF00;
  --cga-amber: #FFAA00;
  --cga-red: #AA0000;
  --cga-bright-red: #FF5555;
  --cga-bright-cyan: #55FFFF;
  --cga-bright-blue: #5555FF;
  --cga-yellow: #FFFF55;
  --border-color: #333366;
  --text-primary: #AAAAAA;
  --text-highlight: #FFFFFF;
}
body {
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  overflow: hidden;
  height: 100vh;
}
/* Theme variations */
body.theme-green { --text-primary: #33cc33; --text-highlight: #00FF00; --cga-amber: #00FF00; }
body.theme-amber { --text-primary: #cc9933; --text-highlight: #FFAA00; --cga-amber: #FFAA00; }
body.theme-white { --text-primary: #AAAAAA; --text-highlight: #FFFFFF; }

.scanlines {
  pointer-events: none;
  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
  );
  z-index: 100;
}
.panel-border {
  border: 1px solid var(--border-color);
  background: var(--bg-panel);
}
.panel-title {
  background: #1a1a3e;
  padding: 2px 6px;
  font-size: 11px;
  color: var(--cga-cyan);
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.register-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1px 4px;
  font-size: 11px;
}
.register-row:hover {
  background: rgba(0,170,170,0.1);
}
.reg-name {
  color: var(--cga-cyan);
  width: 28px;
  font-weight: 600;
}
.reg-value {
  color: var(--cga-bright-white);
  cursor: pointer;
  padding: 0 3px;
  border: 1px solid transparent;
  min-width: 40px;
  text-align: right;
}
.reg-value:hover {
  border-color: var(--cga-amber);
}
.reg-value.changed {
  animation: flash-amber 0.6s ease-out;
  color: var(--cga-amber);
}
@keyframes flash-amber {
  0% { background: var(--cga-amber); color: #000; }
  100% { background: transparent; color: var(--cga-amber); }
}
.flag-bit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 18px;
  margin: 1px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid #333;
  border-radius: 2px;
  transition: all 0.15s;
}
.flag-bit.set {
  background: var(--cga-bright-green);
  color: #000;
  border-color: var(--cga-bright-green);
}
.flag-bit.unset {
  background: #1a1a1a;
  color: #555;
  border-color: #333;
}
.code-editor {
  background: #050510;
  color: var(--text-primary);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  border: none;
  resize: none;
  outline: none;
  width: 100%;
  padding: 4px;
  line-height: 1.5;
}
.code-editor::selection {
  background: var(--cga-blue);
  color: white;
}
.disasm-line {
  display: flex;
  padding: 1px 4px;
  font-size: 11px;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.disasm-line.current {
  background: rgba(0,170,170,0.2);
  border-left-color: var(--cga-bright-cyan);
}
.disasm-line.breakpoint {
  border-left-color: var(--cga-bright-red);
}
.disasm-line:hover {
  background: rgba(255,255,255,0.05);
}
.btn-retro {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border: 2px outset #666;
  background: #333;
  color: var(--cga-bright-white);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.1s;
}
.btn-retro:hover {
  background: #444;
  border-color: var(--cga-cyan);
}
.btn-retro:active {
  border-style: inset;
  background: #222;
}
.btn-retro.running {
  background: #003300;
  color: var(--cga-bright-green);
  border-color: var(--cga-green);
}
.hex-dump {
  font-size: 10px;
  line-height: 1.4;
}
.hex-dump .addr { color: var(--cga-cyan); }
.hex-dump .byte { color: var(--cga-bright-white); }
.hex-dump .byte.zero { color: #444; }
.hex-dump .ascii { color: var(--cga-green); }
.console-output {
  background: #000;
  color: var(--cga-bright-green);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 4px;
  overflow-y: auto;
  line-height: 1.4;
}
.console-output .error { color: var(--cga-bright-red); }
.console-output .info { color: var(--cga-cyan); }
.console-output .warn { color: var(--cga-amber); }
.blink-cursor {
  animation: blink 1s step-end infinite;
}
@keyframes blink {
  50% { opacity: 0; }
}
.title-bar {
  background: var(--cga-blue);
  color: var(--cga-bright-white);
  padding: 4px 8px;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}
.cga-badge {
  background: #003300;
  color: var(--cga-bright-green);
  font-size: 9px;
  padding: 2px 6px;
  border: 1px solid var(--cga-green);
  font-weight: 700;
  letter-spacing: 1px;
}
.status-bar {
  background: #1a1a2e;
  border-top: 1px solid var(--border-color);
  padding: 3px 8px;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-primary);
}
.port-led {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 3px;
  background: #330000;
  border: 1px solid #550000;
}
.port-led.active {
  background: var(--cga-bright-green);
  border-color: var(--cga-green);
  box-shadow: 0 0 4px var(--cga-bright-green);
}
/* Opcode grid */
.opcode-grid {
  display: grid;
  grid-template-columns: 30px repeat(16, 1fr);
  gap: 1px;
  font-size: 8px;
  background: #111;
}
.opcode-cell {
  padding: 2px;
  text-align: center;
  cursor: pointer;
  border: 1px solid #222;
  min-height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7px;
  line-height: 1.1;
  transition: all 0.15s;
  overflow: hidden;
}
.opcode-cell:hover {
  z-index: 10;
  transform: scale(1.8);
  border-color: var(--cga-bright-white);
  font-size: 8px;
}
.opcode-cell.cat-misc { background: #000044; color: #5555FF; }
.opcode-cell.cat-jump { background: #003300; color: #55FF55; }
.opcode-cell.cat-move { background: #333300; color: #FFFF55; }
.opcode-cell.cat-string { background: #332200; color: #FFAA55; }
.opcode-cell.cat-arith { background: #330000; color: #FF5555; }
.opcode-cell.cat-group { background: #220033; color: #AA55FF; }
.opcode-cell.cat-prefix { background: #1a1a1a; color: #888; }
.opcode-cell.cat-empty { background: #0a0a0a; color: #333; }
.opcode-header {
  background: #1a1a2e;
  color: var(--cga-cyan);
  font-weight: 700;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tooltip-box {
  position: fixed;
  background: #1a1a3e;
  border: 1px solid var(--cga-cyan);
  padding: 6px 8px;
  font-size: 10px;
  color: var(--cga-bright-white);
  z-index: 1000;
  max-width: 250px;
  pointer-events: none;
  box-shadow: 0 0 10px rgba(0,170,170,0.3);
}
.cga-display {
  background: #000;
  image-rendering: pixelated;
  border: 2px solid #333;
}
/* Scrollbar styling */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #0a0a0a; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: #555; }
/* Toast */
.toast {
  position: fixed;
  top: 50px;
  right: 20px;
  background: var(--cga-magenta);
  color: white;
  padding: 10px 16px;
  font-weight: 700;
  z-index: 2000;
  animation: toast-in 0.3s ease-out, toast-out 0.3s ease-in 2.7s;
  border: 2px solid #FF55FF;
}
@keyframes toast-in { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; } }
/* Mobile */
@media (max-width: 768px) {
  .main-layout { flex-direction: column !important; }
  .panel-left, .panel-right { width: 100% !important; max-height: 200px; }
  .panel-center { min-height: 300px; }
}