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

body {
  background: #1a1a1a;
  color: #ccc;
  font-family: 'JetBrains Mono', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

header {
  text-align: center;
  padding: 18px 0 10px;
}

header h1 {
  font-family: 'VT323', monospace;
  font-size: 42px;
  color: #fff;
  letter-spacing: 3px;
}

.blink-cursor {
  animation: blink 1s step-end infinite;
  color: #FFB000;
}

@keyframes blink {
  50% { opacity: 0; }
}

.subtitle {
  font-size: 13px;
  color: #666;
  margin-top: 2px;
  font-family: 'VT323', monospace;
  letter-spacing: 1px;
}

#main-container {
  display: flex;
  gap: 16px;
  margin-top: 16px;
  align-items: flex-start;
}

#screen-section {
  flex: 0 0 auto;
}

#crt-bezel {
  background: #2a2a2a;
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 0 30px rgba(0,0,0,0.6), inset 0 0 60px rgba(0,0,0,0.3);
  border: 2px solid #333;
}

#crt-inner {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #e8e8e8;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.15);
}

#canvas {
  display: block;
  width: 512px;
  height: 384px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#scanlines {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    rgba(0,0,0,0.04) 1px,
    rgba(0,0,0,0.04) 2px
  );
  pointer-events: none;
}

#controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  align-items: center;
}

.ctrl-btn {
  font-family: 'VT323', monospace;
  font-size: 16px;
  background: #333;
  color: #ddd;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.ctrl-btn:hover {
  background: #444;
  border-color: #FFB000;
  color: #FFB000;
}

.ctrl-btn:active, .ctrl-btn.active {
  background: #FFB000;
  color: #1a1a1a;
  border-color: #FFB000;
}

.ctrl-btn.small {
  font-size: 14px;
  padding: 4px 8px;
}

#clock-display {
  font-family: 'VT323', monospace;
  font-size: 14px;
  color: #FFB000;
  margin-left: auto;
}

#side-panel {
  flex: 1;
  min-width: 240px;
}

.file-group {
  margin-bottom: 12px;
}

.file-group label {
  display: block;
  font-size: 12px;
  color: #999;
  margin-bottom: 4px;
  font-family: 'VT323', monospace;
  font-size: 16px;
}

.file-group input[type="file"] {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: #ccc;
  width: 100%;
}

.file-info {
  font-size: 11px;
  color: #666;
  display: block;
  margin-top: 2px;
}

#debug-panel {
  background: #000;
  border: 1px solid #0a0;
  border-radius: 6px;
  padding: 10px;
  margin-top: 12px;
  font-size: 11px;
  max-height: 450px;
  overflow-y: auto;
}

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

#debug-panel h3 {
  color: #0f0;
  font-family: 'VT323', monospace;
  font-size: 16px;
  margin: 8px 0 4px;
  border-bottom: 1px solid #030;
}

#debug-panel h3:first-child {
  margin-top: 0;
}

#reg-display, #disasm-display, #mem-display {
  color: #0f0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  white-space: pre;
  line-height: 1.4;
}

#debug-controls {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

#debug-controls label {
  color: #0f0;
  font-size: 11px;
}

#breakpoint-input {
  width: 50px;
  background: #111;
  border: 1px solid #0a0;
  color: #0f0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 2px 4px;
}

#cycle-count {
  color: #0a0;
  font-size: 11px;
  margin-left: auto;
}

#keyboard-section {
  margin-top: 16px;
}

#keyboard {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 560px;
  margin: 0 auto;
}

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

.kb-key {
  font-family: 'VT323', monospace;
  font-size: 15px;
  background: #eee;
  color: #111;
  border: 1px solid #aaa;
  border-radius: 4px;
  padding: 8px 4px;
  min-width: 44px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.1s;
  line-height: 1.1;
}

.kb-key:hover {
  background: #ddd;
}

.kb-key.pressed {
  background: #FFB000;
  color: #000;
  transform: scale(0.95);
}

.kb-key.wide {
  min-width: 70px;
}

#paste-section {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-end;
}

#paste-section label {
  width: 100%;
  font-size: 12px;
  color: #666;
  font-family: 'VT323', monospace;
  font-size: 15px;
}

#paste-basic {
  flex: 1;
  min-width: 200px;
  background: #222;
  color: #ccc;
  border: 1px solid #444;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  padding: 6px;
  resize: vertical;
}

footer {
  text-align: center;
  margin-top: 30px;
  padding: 16px 0;
  border-top: 1px solid #333;
}

footer p {
  font-family: 'VT323', monospace;
  font-size: 16px;
  color: #555;
  margin: 4px 0;
}

footer a {
  color: #FFB000;
  text-decoration: none;
}

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

footer .small {
  font-size: 13px;
  color: #444;
}

@media (max-width: 800px) {
  #main-container {
    flex-direction: column;
  }
  #canvas {
    width: 100%;
    height: auto;
  }
  #side-panel {
    width: 100%;
  }
  .kb-key {
    min-width: 28px;
    font-size: 12px;
    padding: 6px 2px;
  }
  .kb-key.wide {
    min-width: 50px;
  }
}