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

body {
  background: #0d0d1a;
  color: #ccc;
  font-family: 'Share Tech Mono', monospace;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.rainbow-stripe {
  height: 6px;
  background: linear-gradient(90deg,
    #d32f2f 0%, #d32f2f 14.28%,
    #ff9800 14.28%, #ff9800 28.57%,
    #ffeb3b 28.57%, #ffeb3b 42.85%,
    #4caf50 42.85%, #4caf50 57.14%,
    #00bcd4 57.14%, #00bcd4 71.42%,
    #2196f3 71.42%, #2196f3 85.71%,
    #9c27b0 85.71%, #9c27b0 100%
  );
}

#header {
  background: #111122;
  border-bottom: 1px solid #333;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 20px;
}

.title {
  font-size: 24px;
  color: #fff;
  text-shadow: 0 0 10px rgba(0,188,212,0.5);
  letter-spacing: 2px;
}

.badge {
  font-size: 12px;
  color: #888;
  background: #1a1a2e;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid #333;
}

#main-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 20px;
  padding: 20px;
  flex: 1;
}

#screen-area {
  display: flex;
  justify-content: center;
}

#crt-bezel {
  background: #222;
  border-radius: 20px;
  padding: 20px;
  box-shadow:
    inset 0 0 40px rgba(0,0,0,0.8),
    0 0 20px rgba(0,0,0,0.5),
    0 4px 15px rgba(0,0,0,0.3);
  position: relative;
  border: 3px solid #333;
}

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

#scanline-overlay {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  bottom: 20px;
  border-radius: 8px;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 2px,
    rgba(0,0,0,0.15) 2px,
    rgba(0,0,0,0.15) 4px
  );
}

#scanline-overlay.hidden { display: none; }

#controls-panel {
  background: #151528;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 200px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-group label {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.control-group select,
.control-group input[type="text"] {
  background: #0d0d1a;
  color: #0f0;
  border: 1px solid #444;
  padding: 6px 8px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  border-radius: 4px;
  cursor: pointer;
}

.transport {
  flex-direction: row;
  gap: 6px;
}

.transport button {
  flex: 1;
  padding: 10px;
  font-size: 18px;
  background: #1a1a2e;
  border: 2px solid #444;
  color: #ccc;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.1s;
}

.transport button:hover {
  background: #2a2a4e;
  border-color: #00bcd4;
}

.transport button:active {
  transform: scale(0.95);
  background: #0a0a1e;
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

#btn-audio {
  background: #1a1a2e;
  border: 1px solid #444;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
}

#volume-slider {
  flex: 1;
  accent-color: #00bcd4;
}

.debug-btn {
  background: #2a1a1a !important;
  border: 2px solid #d32f2f !important;
  color: #d32f2f !important;
  padding: 8px !important;
  font-family: 'Share Tech Mono', monospace !important;
  font-size: 13px !important;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 2px;
}

.debug-btn:hover {
  background: #3a2a2a !important;
}

#debug-panel {
  background: #0a0a15;
  border: 1px solid #d32f2f;
  margin: 0 20px 10px;
  padding: 15px;
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 15px;
  font-size: 12px;
}

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

.debug-section h3 {
  color: #d32f2f;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 6px;
  border-bottom: 1px solid #333;
  padding-bottom: 4px;
}

#debug-regs, #debug-status, #debug-disasm {
  color: #0f0;
  line-height: 1.6;
  white-space: pre;
}

#debug-flags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.flag-led {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border: 1px solid #333;
  border-radius: 3px;
  font-size: 11px;
}

.flag-led.on {
  color: #0f0;
  border-color: #0f0;
  text-shadow: 0 0 5px #0f0;
}

.flag-led.off {
  color: #444;
}

#debug-memory {
  color: #0f0;
  white-space: pre;
  font-size: 11px;
  max-height: 150px;
  overflow-y: auto;
  line-height: 1.5;
}

#mem-addr {
  background: #0d0d1a;
  color: #0f0;
  border: 1px solid #444;
  padding: 4px 6px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  border-radius: 3px;
  width: 120px;
  margin-bottom: 6px;
}

.debug-controls {
  display: flex;
  gap: 6px;
  grid-column: 1 / -1;
}

.debug-controls button {
  padding: 6px 14px;
  background: #1a1a2e;
  border: 1px solid #444;
  color: #ccc;
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
}

.debug-controls button:hover {
  border-color: #00bcd4;
  color: #00bcd4;
}

#keyboard-container {
  padding: 10px 20px;
  display: flex;
  justify-content: center;
}

#virtual-keyboard {
  background: #1a1a1a;
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: 800px;
  width: 100%;
  border: 2px solid #333;
}

.kb-row {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.kb-key {
  background: #2a2a2a;
  border: 1px solid #444;
  border-bottom: 3px solid #222;
  border-radius: 5px;
  padding: 4px 2px;
  min-width: 55px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.05s;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.kb-key:hover {
  background: #3a3a3a;
}

.kb-key.pressed {
  background: #444;
  border-bottom: 1px solid #222;
  transform: translateY(2px);
}

.kb-key .keyword {
  font-size: 7px;
  color: #d32f2f;
  line-height: 1;
  margin-bottom: 1px;
}

.kb-key .main-label {
  font-size: 13px;
  color: #fff;
  font-family: 'Share Tech Mono', monospace;
  line-height: 1.2;
}

.kb-key .symbol {
  font-size: 7px;
  color: #4caf50;
  line-height: 1;
  margin-top: 1px;
}

.kb-key.shift-key {
  background: #333;
  min-width: 80px;
}

.kb-key.space-key {
  flex: 1;
  max-width: 300px;
}

.kb-key.enter-key {
  min-width: 70px;
  background: #333;
}

#status-bar {
  background: #111122;
  border-top: 1px solid #333;
  padding: 6px 20px;
  display: flex;
  gap: 20px;
  font-size: 11px;
  color: #666;
  flex-wrap: wrap;
}

#footer {
  background: #111122;
  border-top: 1px solid #333;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  font-size: 11px;
  color: #555;
}

.footer-content a {
  color: #00bcd4;
  text-decoration: none;
}

.footer-content a:hover {
  text-decoration: underline;
}

@media (max-width: 900px) {
  #main-container {
    flex-direction: column;
    align-items: center;
  }
  #controls-panel {
    flex-direction: row;
    flex-wrap: wrap;
    min-width: unset;
    width: 100%;
    max-width: 700px;
  }
  .control-group {
    min-width: 100px;
  }
}

@media (max-width: 600px) {
  .title { font-size: 16px; }
  #crt-bezel { padding: 10px; border-radius: 12px; }
  .kb-key { min-width: 28px; padding: 3px 1px; }
  .kb-key .main-label { font-size: 10px; }
  .kb-key .keyword, .kb-key .symbol { font-size: 5px; }
  .kb-key.shift-key { min-width: 38px; }
}