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

:root {
  --c64-black: #000000;
  --c64-white: #FFFFFF;
  --c64-red: #B03A48;
  --c64-cyan: #7ABFC7;
  --c64-purple: #6F3D86;
  --c64-green: #75CE64;
  --c64-blue: #40318D;
  --c64-yellow: #EDF171;
  --c64-orange: #A4643B;
  --c64-brown: #6C5EB5;
  --c64-light-red: #EA9E8E;
  --c64-dark-grey: #4A4A4A;
  --c64-mid-grey: #7B7B7B;
  --c64-light-green: #A0FF9C;
  --c64-light-blue: #A0A0FF;
  --c64-light-grey: #B2B2B2;
  --c64-border: #7869C4;
  --c64-bg: #40318D;
  --c64-text: #A0A0FF;
}

body {
  background: var(--c64-border);
  font-family: 'Press Start 2P', monospace;
  overflow-x: hidden;
  min-height: 100vh;
}

#root {
  min-height: 100vh;
}

.crt-overlay {
  pointer-events: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1000;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.07) 0px,
    rgba(0, 0, 0, 0.07) 1px,
    transparent 1px,
    transparent 3px
  );
}

.crt-glow {
  text-shadow: 0 0 4px rgba(160, 160, 255, 0.4), 0 0 8px rgba(160, 160, 255, 0.2);
}

.boot-screen {
  background: var(--c64-bg);
  color: var(--c64-text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  border: 24px solid var(--c64-border);
  cursor: pointer;
}

.boot-text {
  font-size: 10px;
  line-height: 2;
  max-width: 600px;
  width: 100%;
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.cursor-blink {
  animation: blink 0.8s step-end infinite;
}

.app-border {
  border: 24px solid var(--c64-border);
  min-height: 100vh;
  background: var(--c64-bg);
  color: var(--c64-text);
}

@media (max-width: 768px) {
  .app-border { border-width: 10px; }
  .boot-screen { border-width: 10px; padding: 20px; }
  .boot-text { font-size: 8px; }
}

.app-inner {
  padding: 16px;
  max-width: 1200px;
  margin: 0 auto;
}

.header-title {
  font-size: 20px;
  color: var(--c64-white);
  margin-bottom: 4px;
}

@media (max-width: 500px) {
  .header-title { font-size: 14px; }
}

.header-subtitle {
  font-size: 7px;
  color: var(--c64-light-blue);
  margin-bottom: 6px;
}

.silicon-badge {
  display: inline-block;
  font-size: 7px;
  color: var(--c64-black);
  background: var(--c64-yellow);
  border: 2px solid var(--c64-white);
  padding: 5px 8px;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
  line-height: 1.6;
  animation: silicon-pulse 2.5s ease-in-out infinite;
}

@media (max-width: 500px) {
  .silicon-badge { font-size: 6px; padding: 4px 6px; }
}

@keyframes silicon-pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(237, 241, 113, 0); }
  50% { box-shadow: 0 0 12px rgba(237, 241, 113, 0.7); }
}

.header-note {
  font-size: 6px;
  color: var(--c64-border);
  margin-bottom: 16px;
}

.upload-zone {
  border: 3px dashed var(--c64-light-blue);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 16px;
}

.upload-zone:hover, .upload-zone.drag-over {
  background: rgba(160, 160, 255, 0.1);
  border-color: var(--c64-white);
}

.upload-zone-text {
  font-size: 10px;
  color: var(--c64-text);
  margin-bottom: 12px;
}

.c64-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  padding: 8px 14px;
  background: var(--c64-border);
  color: var(--c64-white);
  border: 2px solid var(--c64-light-blue);
  cursor: pointer;
  transition: all 0.1s;
  text-transform: uppercase;
  margin: 2px;
  min-height: 36px;
}

.c64-btn:hover {
  background: var(--c64-light-blue);
  color: var(--c64-bg);
}

.c64-btn:active {
  transform: scale(0.95);
}

.c64-btn.active {
  background: var(--c64-green);
  color: var(--c64-black);
  border-color: var(--c64-green);
}

.c64-btn.danger {
  border-color: var(--c64-red);
  color: var(--c64-red);
}

.c64-btn.danger:hover {
  background: var(--c64-red);
  color: var(--c64-white);
}

.transport-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin-bottom: 12px;
}

.transport-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c64-border);
  color: var(--c64-white);
  border: 3px solid var(--c64-light-blue);
  cursor: pointer;
  transition: all 0.1s;
}

.transport-btn:hover {
  background: var(--c64-light-blue);
  color: var(--c64-bg);
}

.transport-btn.playing {
  background: var(--c64-green);
  color: var(--c64-black);
  border-color: var(--c64-green);
}

.volume-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 160px;
  max-width: 55vw;
  height: 12px;
  background: var(--c64-bg);
  border: 2px solid var(--c64-light-blue);
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 20px;
  background: var(--c64-cyan);
  border: 2px solid var(--c64-white);
  cursor: pointer;
}

.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 20px;
  background: var(--c64-cyan);
  border: 2px solid var(--c64-white);
  cursor: pointer;
}

.viz-canvas {
  width: 100%;
  border: 2px solid var(--c64-light-blue);
  background: var(--c64-black);
  image-rendering: pixelated;
  display: block;
}

.panel {
  border: 2px solid var(--c64-light-blue);
  padding: 12px;
  margin-bottom: 12px;
  background: rgba(0, 0, 0, 0.2);
}

.panel-title {
  font-size: 9px;
  color: var(--c64-cyan);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--c64-border);
  line-height: 1.6;
}

.panel-text {
  font-size: 8px;
  line-height: 2;
  color: var(--c64-text);
  white-space: pre-wrap;
  word-break: break-word;
}

.voice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

@media (max-width: 768px) {
  .voice-grid { grid-template-columns: 1fr; }
}

.voice-box {
  border: 2px solid var(--c64-border);
  padding: 8px;
  font-size: 7px;
  line-height: 2;
  word-break: break-word;
}

.voice-box.v1 { border-color: var(--c64-cyan); }
.voice-box.v2 { border-color: var(--c64-green); }
.voice-box.v3 { border-color: #EA9E8E; }

.reg-dump {
  font-size: 8px;
  line-height: 1.8;
  color: var(--c64-light-blue);
  white-space: pre;
  overflow-x: auto;
}

.main-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
}

@media (max-width: 900px) {
  .main-layout { grid-template-columns: 1fr; }
}

.recent-item {
  font-size: 7px;
  line-height: 2;
  padding: 4px 8px;
  cursor: pointer;
  border-bottom: 1px solid rgba(120, 105, 196, 0.3);
  transition: background 0.1s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.recent-item:hover {
  background: rgba(160, 160, 255, 0.1);
}

.time-display {
  font-size: 11px;
  color: var(--c64-green);
  padding: 4px 8px;
  letter-spacing: 1px;
}

.tune-selector {
  font-size: 9px;
  color: var(--c64-yellow);
  display: flex;
  align-items: center;
  gap: 4px;
}

.footer {
  font-size: 7px;
  color: var(--c64-border);
  text-align: center;
  padding: 16px;
  margin-top: 24px;
  border-top: 1px solid var(--c64-border);
  line-height: 1.8;
}

.footer a {
  color: var(--c64-cyan);
  text-decoration: none;
}

.footer a:hover {
  color: var(--c64-white);
}

.error-msg {
  color: var(--c64-red);
  font-size: 9px;
  padding: 12px;
  border: 2px solid var(--c64-red);
  margin: 8px 0;
}

.preset-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.model-toggle {
  display: flex;
  gap: 2px;
}

.model-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  padding: 6px 8px;
  background: transparent;
  color: var(--c64-text);
  border: 2px solid var(--c64-border);
  cursor: pointer;
  min-height: 30px;
}

.model-btn.active {
  background: var(--c64-cyan);
  color: var(--c64-black);
  border-color: var(--c64-cyan);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--c64-bg); }
::-webkit-scrollbar-thumb { background: var(--c64-border); }

@keyframes sprite-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.c64-sprite {
  display: inline-block;
  animation: sprite-bounce 2s ease-in-out infinite;
}

.sys-input {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  background: transparent;
  border: none;
  color: var(--c64-text);
  outline: none;
  width: 120px;
  caret-color: var(--c64-text);
}

.filter-display {
  font-size: 7px;
  line-height: 2;
  padding: 6px;
  border: 1px solid var(--c64-border);
  margin-top: 4px;
  word-break: break-word;
}

.filter-canvas {
  width: 100%;
  height: 60px;
  border: 1px solid var(--c64-border);
  background: #000;
  display: block;
  margin-top: 4px;
}

.digi-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 7px;
  padding: 2px 6px;
  border: 1px solid var(--c64-border);
}

.digi-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #333;
  border: 1px solid #555;
  transition: background 0.1s;
}

.digi-led.on {
  background: var(--c64-red);
  box-shadow: 0 0 4px var(--c64-red), 0 0 8px var(--c64-red);
}

.dc-bias-bar {
  width: 60px;
  height: 6px;
  border: 1px solid var(--c64-border);
  background: #000;
  display: inline-block;
  vertical-align: middle;
  margin-left: 4px;
}

.dc-bias-fill {
  height: 100%;
  background: var(--c64-orange);
  transition: width 100ms;
}

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

.voice-led {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.voice-led.on {
  box-shadow: 0 0 3px currentColor;
  animation: led-pulse 1s ease-in-out infinite;
}

.voice-led.off {
  opacity: 0.3;
}

.env-stage-indicator {
  display: inline-block;
  padding: 1px 4px;
  font-size: 6px;
  border: 1px solid;
}

.env-stage-indicator.attack { border-color: var(--c64-green); color: var(--c64-green); }
.env-stage-indicator.decay { border-color: var(--c64-yellow); color: var(--c64-yellow); }
.env-stage-indicator.sustain { border-color: var(--c64-cyan); color: var(--c64-cyan); }
.env-stage-indicator.release { border-color: var(--c64-light-red); color: var(--c64-light-red); }