* { margin:0; padding:0; box-sizing:border-box; }
body {
  background: #0d0d1a;
  color: #e0dcc8;
  font-family: 'IBM Plex Mono', monospace;
  overflow-x: hidden;
  min-height: 100vh;
}

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

.header {
  text-align: center;
  padding: 16px 12px 8px;
  border-bottom: 1px solid #2a2a3e;
  background: linear-gradient(180deg, #151528 0%, #0d0d1a 100%);
}
.header h1 {
  font-family: 'Press Start 2P', monospace;
  font-size: 20px;
  color: #e74c3c;
  text-shadow: 0 0 20px rgba(231,76,60,0.5), 0 0 40px rgba(231,76,60,0.2);
  letter-spacing: 2px;
}
.header .subtitle {
  font-size: 10px;
  color: #666;
  margin-top: 6px;
  letter-spacing: 1px;
}
.status-led {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-left: 8px;
  vertical-align: middle;
  transition: all 0.3s;
}
.status-led.off { background: #333; box-shadow: none; }
.status-led.running { background: #2ecc71; box-shadow: 0 0 8px #2ecc71; animation: pulse-led 1.5s infinite; }
.status-led.paused { background: #f39c12; box-shadow: 0 0 8px #f39c12; }

@keyframes pulse-led {
  0%,100% { opacity:1; }
  50% { opacity:0.6; }
}

.main-layout {
  display: flex;
  flex: 1;
  gap: 0;
}

.sidebar-left {
  width: 220px;
  min-width: 220px;
  padding: 12px;
  border-right: 1px solid #1a1a2e;
  background: #0f0f1f;
  overflow-y: auto;
  max-height: calc(100vh - 60px);
}
.sidebar-right {
  width: 280px;
  min-width: 280px;
  padding: 12px;
  border-left: 1px solid #1a1a2e;
  background: #0f0f1f;
  overflow-y: auto;
  max-height: calc(100vh - 60px);
}

.center-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
}

.crt-bezel {
  background: #1a1a1a;
  border-radius: 16px;
  padding: 16px;
  box-shadow:
    inset 0 0 30px rgba(0,0,0,0.8),
    0 0 40px rgba(231,76,60,0.08),
    0 4px 20px rgba(0,0,0,0.6);
  position: relative;
  overflow: hidden;
}

.screen-container {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}

.screen-container canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.scanlines {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.15) 2px,
    rgba(0,0,0,0.15) 4px
  );
  z-index: 2;
}

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

.control-bar {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 5px 12px;
  border: 1px solid #333;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  background: #1a1a2e;
  color: #ccc;
}
.btn:hover { background: #252540; border-color: #555; }
.btn:active { transform: scale(0.96); }
.btn-danger { background: #8b1a1a; border-color: #e74c3c; color: #fff; }
.btn-danger:hover { background: #a82020; }
.btn-primary { background: #1a3a5c; border-color: #3498db; color: #8cc; }
.btn-primary:hover { background: #1e4a70; }
.btn-warning { background: #5c4a1a; border-color: #f39c12; color: #fc9; }
.btn-warning:hover { background: #705a20; }

.speed-indicator {
  font-size: 10px;
  color: #666;
  padding: 4px 8px;
}

.panel {
  margin-bottom: 12px;
}
.panel-title {
  font-size: 10px;
  font-weight: 700;
  color: #e74c3c;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
  padding-bottom: 3px;
  border-bottom: 1px solid #1a1a2e;
}

.drop-zone {
  border: 2px dashed #333;
  border-radius: 8px;
  padding: 16px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #0a0a16;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: #e74c3c;
  background: #1a0a0a;
}
.drop-zone-text {
  font-size: 10px;
  color: #666;
}
.drop-zone-icon {
  font-size: 24px;
  margin-bottom: 4px;
  color: #444;
}

.rom-info {
  font-size: 10px;
  color: #888;
  margin-top: 6px;
  padding: 6px;
  background: #0a0a16;
  border-radius: 4px;
}
.rom-info .loaded { color: #2ecc71; }

.memory-map {
  display: flex;
  flex-direction: column;
  height: 200px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #222;
}
.mem-section {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7px;
  font-weight: 700;
  color: #000;
  cursor: pointer;
  position: relative;
  transition: opacity 0.2s;
}
.mem-section:hover { opacity: 0.8; }
.mem-tooltip {
  position: absolute;
  left: 110%;
  top: 50%;
  transform: translateY(-50%);
  background: #222;
  color: #ddd;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  font-size: 9px;
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.register-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  font-size: 10px;
}
.reg-item {
  background: #0a0a16;
  padding: 3px 6px;
  border-radius: 3px;
  display: flex;
  justify-content: space-between;
}
.reg-label { color: #f39c12; font-weight: 700; }
.reg-value { color: #2ecc71; font-family: 'IBM Plex Mono', monospace; }

.flags-row {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.flag-led {
  width: 24px;
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  padding: 2px;
  border-radius: 3px;
  border: 1px solid #222;
}
.flag-led.on { background: #2ecc71; color: #000; border-color: #2ecc71; }
.flag-led.off { background: #1a1a1a; color: #444; }

.disasm-view {
  font-size: 9px;
  background: #050510;
  border-radius: 4px;
  padding: 4px;
  max-height: 150px;
  overflow-y: auto;
  font-family: 'IBM Plex Mono', monospace;
}
.disasm-line {
  padding: 1px 4px;
  color: #888;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}
.disasm-line.current { background: #1a2a1a; color: #2ecc71; }
.disasm-line:hover { background: #151528; }
.breakpoint-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.breakpoint-dot.active { background: #e74c3c; }
.breakpoint-dot.inactive { background: transparent; }

.ay-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  font-size: 8px;
}
.ay-reg {
  background: #0a0a16;
  padding: 2px 4px;
  border-radius: 2px;
  text-align: center;
}
.ay-reg-label { color: #666; }
.ay-reg-value { color: #3498db; font-weight: 700; }
.ay-reg.highlight { border: 1px solid #f39c12; }

.keyboard-container {
  padding: 10px;
  background: linear-gradient(180deg, #1a1a2e 0%, #0d0d1a 100%);
  border-top: 1px solid #2a2a3e;
}
.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 3px;
  margin-bottom: 3px;
}
.key {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  min-width: 32px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #f5f0e1 0%, #ddd8c8 100%);
  color: #222;
  border: 1px solid #999;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 2px 0 #888, 0 3px 4px rgba(0,0,0,0.3);
  transition: all 0.08s;
  padding: 0 6px;
}
.key:active, .key.pressed {
  background: linear-gradient(180deg, #ccc8b8 0%, #bbb8a8 100%);
  box-shadow: 0 0 0 #888, 0 1px 2px rgba(0,0,0,0.3);
  transform: translateY(2px);
}
.key.modifier {
  background: linear-gradient(180deg, #e74c3c 0%, #c0392b 100%);
  color: #fff;
  border-color: #a33;
  box-shadow: 0 2px 0 #922, 0 3px 4px rgba(0,0,0,0.3);
}
.key.modifier:active, .key.modifier.pressed {
  background: linear-gradient(180deg, #c0392b 0%, #962d22 100%);
  box-shadow: 0 0 0 #711, 0 1px 2px rgba(0,0,0,0.3);
  transform: translateY(2px);
}
.key.space { min-width: 200px; }
.key.wide { min-width: 56px; }
.key.return-key { min-width: 72px; }
.key.arrow { min-width: 28px; font-size: 12px; }

.via-info, .channel-info {
  font-size: 9px;
  color: #888;
  margin-top: 4px;
}
.via-info span { color: #f39c12; }

.footer {
  text-align: center;
  padding: 8px;
  font-size: 10px;
  color: #444;
  border-top: 1px solid #1a1a2e;
}
.footer a { color: #e74c3c; text-decoration: none; }
.footer a:hover { text-decoration: underline; }

.preset-btns {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.preset-btns .btn { font-size: 9px; padding: 3px 6px; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #0a0a16; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

@media (max-width: 1100px) {
  .main-layout { flex-direction: column; }
  .sidebar-left, .sidebar-right {
    width: 100%; min-width: auto;
    max-height: none;
    border: none;
    border-bottom: 1px solid #1a1a2e;
  }
  .sidebar-right { border-top: 1px solid #1a1a2e; border-bottom: none; }
  .memory-map { height: 60px; flex-direction: row; }
  .mem-section { writing-mode: vertical-rl; }
}