* {
  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 Scanline overlay */
.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.08) 0px,
    rgba(0, 0, 0, 0.08) 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 */
.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;
}

/* Main app */
.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: 12px;
  }
  .boot-screen {
    border-width: 12px;
    padding: 20px;
  }
  .boot-text {
    font-size: 8px;
  }
}

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

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

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

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

.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;
}

/* Buttons */
.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;
}

.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);
}

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

.c64-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Transport controls */
.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 slider */
.volume-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 160px;
  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;
}

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

/* Panels */
.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);
}

.panel-text {
  font-size: 8px;
  line-height: 2;
  color: var(--c64-text);
}

/* Voice info */
.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;
}

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

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

.reg-changed {
  color: var(--c64-yellow);
}

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

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

/* Recent files */
.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 */
.time-display {
  font-size: 11px;
  color: var(--c64-green);
  padding: 4px 8px;
  letter-spacing: 1px;
}

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

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

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

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

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

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

/* Voice mute toggles */
.voice-toggles {
  display: flex;
  gap: 4px;
  align-items: center;
}

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

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

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

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--c64-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--c64-border);
}

/* Pixel art C64 icon */
@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;
}

/* Speed control */
.speed-control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 7px;
}

.speed-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 8px;
  background: var(--c64-bg);
  border: 2px solid var(--c64-border);
  outline: none;
  cursor: pointer;
}

.speed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 16px;
  background: var(--c64-yellow);
  border: 2px solid var(--c64-white);
  cursor: pointer;
}

/* SYS 64738 easter egg */
.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);
}

/* Loading animation */
@keyframes loading-dots {
  0% { content: '.'; }
  33% { content: '..'; }
  66% { content: '...'; }
}

.loading-text::after {
  content: '...';
  animation: loading-dots 1.5s step-end infinite;
}

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