:root {
  --bg-color: #0a0a0f;
  --accent-primary: #7000ff;
  --accent-secondary: #00d4ff;
  --text-main: #ffffff;
  --text-muted: #a0a0b0;
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glow-color: rgba(112, 0, 255, 0.5);
  --font-family: 'Outfit', sans-serif;

  /* Responsive Dimensions */
  --stage-max-width: 1500px;
  --wheel-size: 330px;
  --keyboard-width: 580px;
  --keyboard-height: 360px;
}


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

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-family);
  overflow: hidden;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, #1a1a2e 0%, #0a0a0f 100%);
}

#app {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0.8rem;
  max-width: 1700px;
  overflow-y: auto;
}

header {
  text-align: center;
  margin-bottom: 0.5rem;
}

.logo {
  font-size: 1.8rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo span {
  font-weight: 300;
  -webkit-text-fill-color: var(--text-main);
}

.instrument-controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
  width: 100%;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.control-group {
  background: var(--glass-bg);
  padding: 0.6rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-width: 180px;
  flex: 1;
}

.control-group label {
  color: var(--accent-secondary);
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

.mixer-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
}

select {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--glass-border);
  color: white;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  font-size: 0.8rem;
  flex: 1;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 60px;
  height: 4px;
  background: var(--glass-border);
  border-radius: 2px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: var(--accent-secondary);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 5px var(--accent-secondary);
}

.interaction-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.experience-stage {
  position: relative;
  width: 100%;
  max-width: 1500px;
  aspect-ratio: 16/9;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.5), 0 0 20px var(--glow-color);
  background: #000;
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform: scaleX(-1);
}

.wheel-container {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: var(--wheel-size);
  height: var(--wheel-size);
  z-index: 5;
  touch-action: none;
}

.wheel-container.left {
  left: 20px;
}

.wheel-container.right {
  right: 20px;
}

@media (max-width: 900px) {
  .wheel-container.left {
    left: 10px;
  }

  .wheel-container.right {
    right: 10px;
  }
}

.keyboard-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: var(--keyboard-width);
  height: var(--keyboard-height);
  z-index: 5;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 15px;
  border: 1px solid var(--glass-border);
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  touch-action: none;
  aspect-ratio: 580 / 360; /* Critical for coordinate mapping */
}

.key {
  fill: rgba(255, 255, 255, 0.1);
  stroke: var(--glass-border);
  transition: all 0.15s;
}

.key.black {
  fill: rgba(0, 0, 0, 0.6);
}

.key.active {
  fill: var(--accent-secondary);
  stroke: white;
  filter: drop-shadow(0 0 15px var(--accent-secondary));
}

.divider-line {
  fill: none;
  stroke: var(--accent-secondary);
  stroke-width: 2;
  stroke-opacity: 0.15;
  filter: blur(1px);
}

.chord-segment {
  fill: var(--glass-bg);
  stroke: var(--glass-border);
  stroke-width: 1;
  transition: all 0.2s;
}

#fullscreen-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 40px;
  height: 40px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  backdrop-filter: blur(5px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0.5;
}

#fullscreen-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.1);
  border-color: var(--accent-secondary);
  box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}

#fullscreen-btn svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s;
}

#fullscreen-btn:active {
  transform: scale(0.9);
}

.chord-segment.active {
  fill: rgba(112, 0, 255, 0.5);
  stroke: var(--accent-primary);
  filter: drop-shadow(0 0 10px var(--accent-primary));
}

.chord-segment.minor {
  fill: rgba(255, 255, 255, 0.02);
}

.chord-label {
  fill: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

.chord-segment.active+.chord-label {
  fill: white;
  font-size: 13px;
}

#loading-overlay,
#start-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 15, 0.98);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.loader {
  width: 40px;
  height: 40px;
  border: 3px solid var(--glass-border);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#start-btn {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border: none;
  padding: 1rem 3rem;
  color: white;
  font-size: 1.3rem;
  font-weight: 600;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(112, 0, 255, 0.3);
}

#start-btn:hover {
  transform: scale(1.05);
}

footer {
  margin-top: 0.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Responsive Overrides */
@media (max-width: 1200px) {
  :root {
    --wheel-size: 250px;
    --keyboard-width: 450px;
    --keyboard-height: 280px;
  }
}

@media (max-width: 1000px) {
  :root {
    --wheel-size: 35vw;
    --keyboard-width: 58vw;
    --keyboard-height: 240px;
  }

  .wheel-container.right {
    display: none !important;
  }

  .wheel-container.left {
    left: 2% !important;
  }

  .keyboard-container {
    left: unset !important;
    right: 2vw !important;
    transform: translateY(-50%) !important;
    width: var(--keyboard-width) !important;
    height: auto !important;
    padding: 0 !important;
  }
}

@media (max-width: 600px) {
  :root {
    --keyboard-height: 180px;
  }
}