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

:root {
  --fg-color: #33ff33;
  --bg-color: #001a00;
  --glow-color: rgba(51, 255, 51, 0.4);
  --bezel-color: #2a2520;
  --panel-bg: #111;
  --accent: #33ff33;
}

body {
  background: #0a0a0a;
  color: #ccc;
  font-family: 'Share Tech Mono', 'Courier New', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px;
}

/* Header */
#header {
  text-align: center;
  padding: 15px 0 10px;
}

.rainbow-stripe {
  height: 4px;
  background: linear-gradient(90deg, #e24b2c 0%, #e24b2c 20%, #f39c12 20%, #f39c12 40%, #f1c40f 40%, #f1c40f 60%, #27ae60 60%, #27ae60 80%, #2980b9 80%, #2980b9 100%);
  margin-bottom: 10px;
  border-radius: 2px;
}

#header h1 {
  font-family: 'VT323', monospace;
  font-size: 2.2rem;
  color: #fff;
  text-shadow: 0 0 10px var(--glow-color);
  letter-spacing: 2px;
}

.subtitle {
  font-size: 0.85rem;
  color: #888;
  margin-top: 2px;
}

/* Main Layout */
#main-layout {
  display: flex;
  gap: 15px;
  margin-top: 10px;
}

#monitor-section {
  flex: 1;
  min-width: 0;
}

/* ROM Upload */
#rom-upload-area {
  margin-bottom: 10px;
}

#drop-zone {
  border: 2px dashed #444;
  border-radius: 8px;
  padding: 15px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: #0f0f0f;
  font-size: 0.85rem;
  position: relative;
}

#drop-zone:hover, #drop-zone.drag-over {
  border-color: var(--accent);
  background: #0a1a0a;
}

#drop-zone .drop-icon {
  font-size: 1.5rem;
  margin-right: 8px;
}

#rom-file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

#rom-checklist {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  font-size: 0.72rem;
}

.rom-item {
  padding: 4px 10px;
  border-radius: 4px;
  background: #1a1a1a;
  border: 1px solid #333;
  font-family: 'Share Tech Mono', monospace;
  display: block;
}

.rom-item.loaded {
  border-color: #2a5;
  color: #3f3;
}

.rom-item.missing {
  border-color: #533;
  color: #a55;
}

.rom-item.warn {
  border-color: #a80;
  color: #fa0;
}

#rom-log {
  margin-top: 6px;
  font-size: 0.75rem;
  padding: 4px 8px;
  color: #888;
}

.rom-log-ready {
  color: #3f3 !important;
}

.rom-log-waiting {
  color: #a55 !important;
}

/* CRT Frame */
#crt-frame {
  display: flex;
  justify-content: center;
}

#crt-bezel {
  background: linear-gradient(145deg, #3a342e, #1a1714);
  border-radius: 20px;
  padding: 20px 20px 12px;
  box-shadow: 0 4px 30px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,255,255,0.05);
  position: relative;
}

#screen-container {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-color);
  box-shadow: 0 0 40px var(--glow-color), inset 0 0 60px rgba(0,0,0,0.5);
}

#canvas {
  display: block;
  width: 640px;
  height: 400px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border-radius: 8px;
}

#scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 1px,
    rgba(0,0,0,0.15) 1px,
    rgba(0,0,0,0.15) 2px
  );
  pointer-events: none;
  border-radius: 8px;
}

#bezel-label {
  text-align: center;
  margin-top: 8px;
  font-family: 'VT323', monospace;
  font-size: 0.9rem;
  color: #665;
  letter-spacing: 3px;
}

/* Demo Bar */
#demo-bar {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.demo-btn, .paste-btn, .screenshot-btn {
  padding: 6px 12px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.75rem;
  background: #1a1a1a;
  color: #aaa;
  border: 1px solid #333;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.demo-btn:hover, .paste-btn:hover, .screenshot-btn:hover {
  background: #222;
  border-color: var(--accent);
  color: var(--accent);
}

/* Control Panel */
#control-panel {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-section {
  background: #111;
  border: 1px solid #222;
  border-radius: 8px;
  padding: 10px;
}

.panel-section h3 {
  font-family: 'VT323', monospace;
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 8px;
  letter-spacing: 2px;
}

.chunky-btn {
  display: block;
  width: 100%;
  padding: 10px;
  font-family: 'VT323', monospace;
  font-size: 1.1rem;
  letter-spacing: 1px;
  background: linear-gradient(180deg, #333, #1a1a1a);
  color: #ccc;
  border: 2px solid #444;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 6px;
  transition: all 0.15s;
  box-shadow: 0 3px 0 #000;
  text-align: center;
}

.chunky-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #000;
}

.chunky-btn.small {
  padding: 6px;
  font-size: 0.85rem;
}

.chunky-btn.power-on {
  border-color: #2a5;
  color: #3f3;
  text-shadow: 0 0 8px rgba(51,255,51,0.5);
}

.chunky-btn.power-off {
  border-color: #444;
  color: #888;
}

.chunky-btn.step-btn {
  background: linear-gradient(180deg, #2a2a3a, #1a1a2a);
  border-color: #55a;
  color: #aaf;
  font-size: 0.95rem;
}

.chunky-btn.step-btn:hover {
  border-color: #77c;
  color: #ccf;
  text-shadow: 0 0 6px rgba(170,170,255,0.4);
}

.step-info {
  margin-top: 4px;
  font-size: 0.65rem;
  color: #aaf;
  background: #0a0a14;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 4px 6px;
  font-family: 'Share Tech Mono', monospace;
  white-space: pre-wrap;
  line-height: 1.3;
  max-height: 100px;
  overflow-y: auto;
  display: none;
}

.step-info.visible {
  display: block;
}

.chunky-btn.step-btn {
  background: linear-gradient(180deg, #2a2a3a, #1a1a2a);
  border-color: #55a;
  color: #aaf;
  font-size: 0.95rem;
}

.chunky-btn.step-btn:hover {
  border-color: #77c;
  color: #ccf;
  text-shadow: 0 0 6px rgba(170,170,255,0.4);
}

.step-info {
  margin-top: 4px;
  font-size: 0.65rem;
  color: #aaf;
  background: #0a0a14;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 4px 6px;
  font-family: 'Share Tech Mono', monospace;
  white-space: pre-wrap;
  line-height: 1.3;
  max-height: 100px;
  overflow-y: auto;
  display: none;
}

.step-info.visible {
  display: block;
}

#speed-slider {
  width: 100%;
  accent-color: var(--accent);
}

#speed-label {
  display: block;
  text-align: center;
  font-size: 0.75rem;
  color: #888;
  margin-top: 4px;
}

#color-theme {
  width: 100%;
  padding: 6px;
  background: #1a1a1a;
  color: #ccc;
  border: 1px solid #333;
  border-radius: 4px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.8rem;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}

.toggle-label input[type="checkbox"] {
  accent-color: var(--accent);
}

/* Status */
#status-indicators {
  font-size: 0.75rem;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
}

.led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #500;
  display: inline-block;
  margin-right: 6px;
  box-shadow: 0 0 4px rgba(255,0,0,0.3);
}

.led.on {
  background: #0f0;
  box-shadow: 0 0 8px rgba(0,255,0,0.5);
}

/* Debug Panel */
#debug-panel {
  margin-top: 8px;
  font-size: 0.7rem;
  max-height: 300px;
  overflow-y: auto;
}

#debug-panel.hidden {
  display: none;
}

#registers-display {
  background: #0a0a0a;
  padding: 6px;
  border-radius: 4px;
  margin-bottom: 6px;
  font-family: 'Share Tech Mono', monospace;
  color: var(--accent);
  white-space: pre;
  line-height: 1.4;
}

#disassembly-display {
  background: #0a0a0a;
  padding: 6px;
  border-radius: 4px;
  margin-bottom: 6px;
  font-family: 'Share Tech Mono', monospace;
  color: #aaa;
  white-space: pre;
  line-height: 1.3;
  max-height: 120px;
  overflow-y: auto;
}

#memory-viewer {
  margin-top: 6px;
}

#mem-addr {
  width: 100%;
  padding: 4px;
  background: #0a0a0a;
  color: var(--accent);
  border: 1px solid #333;
  border-radius: 3px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.75rem;
  margin-bottom: 4px;
}

#mem-dump {
  background: #0a0a0a;
  padding: 6px;
  border-radius: 4px;
  font-family: 'Share Tech Mono', monospace;
  color: #888;
  white-space: pre;
  line-height: 1.3;
  max-height: 100px;
  overflow-y: auto;
  font-size: 0.65rem;
}

/* Footer */
#footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 15px;
  padding: 10px 0;
  border-top: 1px solid #222;
  font-size: 0.75rem;
  color: #555;
}

#footer a {
  color: var(--accent);
  text-decoration: none;
}

#footer a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 900px) {
  #main-layout {
    flex-direction: column;
  }
  #control-panel {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .panel-section {
    flex: 1;
    min-width: 150px;
  }
  #canvas {
    width: 100%;
    height: auto;
  }
}

@media (max-width: 500px) {
  #header h1 {
    font-size: 1.4rem;
  }
  #crt-bezel {
    padding: 10px 10px 8px;
    border-radius: 12px;
  }
}