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

body {
  background: #40318D;
  color: #6C5EB5;
  font-family: 'Press Start 2P', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

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

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

.title {
  font-size: 18px;
  color: #7B71B3;
  text-shadow: 2px 2px 0 #2a1f5e;
  margin: 8px 0 4px;
}

.subtitle {
  font-size: 8px;
  color: #9B8EC4;
  letter-spacing: 2px;
}

#rainbow-bar, #rainbow-bar2 {
  height: 6px;
  background: linear-gradient(90deg, 
    #9F4E44 0%, #CB7E75 10%, #6D5412 20%, #A9A244 30%,
    #6ABE30 40%, #75CEC8 50%, #50459B 60%, #6C5EB5 70%,
    #9F4E44 80%, #CB7E75 90%, #FFFFCC 100%);
  border-radius: 3px;
  animation: rainbow-shift 3s linear infinite;
}

@keyframes rainbow-shift {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

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

#left-panel, #right-panel {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#screen-area {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* Panels */
#controls-panel, #audio-panel, #settings-panel, #debug-panel, #sid-panel, #mem-panel {
  background: #1a1a2e;
  border: 2px solid #352879;
  border-radius: 6px;
  padding: 10px;
}

.panel-label {
  font-size: 7px;
  color: #9B8EC4;
  border-bottom: 1px solid #352879;
  padding-bottom: 4px;
  margin-bottom: 8px;
  letter-spacing: 2px;
}

/* File Drop */
#file-drop-zone {
  border: 2px dashed #6C5EB5;
  border-radius: 6px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  margin-bottom: 8px;
  transition: all 0.2s;
  background: #0d0d1a;
}

#file-drop-zone:hover, #file-drop-zone.drag-over {
  border-color: #A9A244;
  background: #1a1a3e;
}

#drop-icon { font-size: 24px; margin-bottom: 4px; }
#drop-text { font-size: 7px; color: #6C5EB5; }
#file-info { font-size: 6px; color: #9F4E44; margin-top: 4px; word-break: break-all; }

/* Controls */
.control-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.ctrl-label {
  font-size: 6px;
  color: #9B8EC4;
  min-width: 60px;
}

.hex-input-wrap {
  display: flex;
  align-items: center;
  background: #0d0d1a;
  border: 1px solid #352879;
  border-radius: 3px;
  padding: 2px 4px;
}

.hex-prefix {
  font-size: 9px;
  color: #A9A244;
}

.hex-input {
  background: transparent;
  border: none;
  color: #6ABE30;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  width: 50px;
  outline: none;
  text-transform: uppercase;
}

.hex-input.small { width: 40px; }

.checkbox-row { font-size: 6px; }
.checkbox-row label { display: flex; align-items: center; gap: 4px; cursor: pointer; color:#9B8EC4; }
.checkbox-row input[type="checkbox"] { accent-color: #6ABE30; }

/* Buttons */
.button-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.c64-key {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  padding: 8px 10px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  flex: 1;
  color: #1a1a2e;
  background: #C8B8A0;
  box-shadow: 0 4px 0 #8a7a60, 0 6px 8px rgba(0,0,0,0.3);
  transition: all 0.1s;
  text-align: center;
}

.c64-key:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #8a7a60, 0 2px 4px rgba(0,0,0,0.3);
}

.green-key { background: #6ABE30; box-shadow: 0 4px 0 #4a8e20, 0 6px 8px rgba(0,0,0,0.3); }
.green-key:active { box-shadow: 0 1px 0 #4a8e20; }
.yellow-key { background: #A9A244; box-shadow: 0 4px 0 #797430, 0 6px 8px rgba(0,0,0,0.3); }
.yellow-key:active { box-shadow: 0 1px 0 #797430; }
.red-key { background: #9F4E44; color: #fff; box-shadow: 0 4px 0 #6F3030, 0 6px 8px rgba(0,0,0,0.3); }
.red-key:active { box-shadow: 0 1px 0 #6F3030; }
.small-key { font-size: 6px; padding: 6px 8px; }

/* Retro slider */
.retro-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 6px;
  background: #352879;
  border-radius: 3px;
  outline: none;
}
.retro-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  background: #6ABE30;
  border-radius: 50%;
  cursor: pointer;
}

.retro-select {
  background: #0d0d1a;
  color: #6ABE30;
  border: 1px solid #352879;
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  padding: 3px;
  border-radius: 3px;
  outline: none;
  flex: 1;
}

#speed-label { font-size: 7px; color: #6ABE30; min-width: 30px; text-align: right; }

/* CRT Screen */
#crt-bezel {
  background: #0a0a0a;
  border-radius: 20px;
  padding: 16px;
  box-shadow: 
    inset 0 0 30px rgba(0,0,0,0.8),
    0 0 20px rgba(0,0,0,0.5),
    0 4px 20px rgba(0,0,0,0.6);
  border: 3px solid #2a2a2a;
}

#crt-screen-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  line-height: 0;
}

#canvas {
  width: 100%;
  max-width: 806px;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

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

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

/* Debug panel */
#cpu-registers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  margin-bottom: 6px;
}

.reg {
  display: flex;
  justify-content: space-between;
  padding: 2px 4px;
  background: #0d0d1a;
  border-radius: 2px;
  font-size: 7px;
}

.reg-name { color: #9B8EC4; }
.reg-val { color: #6ABE30; }

#cpu-flags {
  display: flex;
  gap: 3px;
  margin-bottom: 6px;
  justify-content: center;
}

.flag {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7px;
  border-radius: 3px;
  background: #0d0d1a;
  color: #352879;
  border: 1px solid #352879;
}

.flag.lit {
  background: #6ABE30;
  color: #0d0d1a;
  border-color: #6ABE30;
}

.flag.dim { opacity: 0.3; }

/* SID Panel */
.sid-voice {
  display: flex;
  gap: 6px;
  font-size: 6px;
  padding: 3px 0;
  border-bottom: 1px solid #1a1a3e;
}

.voice-label { color: #A9A244; min-width: 20px; }
.voice-info { color: #6C5EB5; }

/* Memory dump */
#mem-dump {
  font-size: 5px;
  color: #6ABE30;
  background: #0d0d1a;
  padding: 4px;
  border-radius: 3px;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.6;
  font-family: 'Press Start 2P', monospace;
}

/* Footer */
footer {
  text-align: center;
  padding: 16px;
  margin-top: 12px;
}

.remix-link {
  color: #6C5EB5;
  text-decoration: none;
  font-size: 8px;
  letter-spacing: 3px;
  transition: color 0.2s;
}

.remix-link:hover { color: #A9A244; }

/* Responsive */
@media (max-width: 1100px) {
  #main-layout { flex-wrap: wrap; }
  #left-panel, #right-panel { flex: 1 1 100%; flex-direction: row; flex-wrap: wrap; }
  #left-panel > *, #right-panel > * { flex: 1; min-width: 200px; }
  #screen-area { order: -1; flex: 1 1 100%; }
}

@media (max-width: 600px) {
  .title { font-size: 12px; }
  .subtitle { font-size: 6px; }
  #left-panel, #right-panel { flex-direction: column; }
  #crt-bezel { padding: 8px; border-radius: 12px; }
}