:root {
  --bg: #0a0a0f;
  --fg: #f4f2ee;
  --muted: #9aa0ad;
  --accent: #7c9cff;
  --accent-2: #ff7cc3;
  --panel: rgba(18, 18, 26, 0.72);
  --border: rgba(255, 255, 255, 0.12);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
}

#stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 20%, #16161f 0%, #0a0a0f 70%);
}

/* Video is hidden; we draw it (mirrored) onto the canvas ourselves. */
#video {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

#canvas {
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

/* ---------- Overlay ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(6, 6, 10, 0.86);
  backdrop-filter: blur(10px);
  z-index: 20;
  transition: opacity 0.4s ease;
}
.overlay.hidden { opacity: 0; pointer-events: none; }

.overlay-card {
  text-align: center;
  max-width: 420px;
  padding: 40px 32px;
}
.overlay-card h1 {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 14px;
}
.overlay-card h1 span,
.brand span { color: var(--accent); }
.overlay-card p { color: var(--muted); line-height: 1.5; margin-bottom: 22px; }
.overlay-card .fine { font-size: 0.8rem; opacity: 0.7; margin-top: 18px; margin-bottom: 0; }

#start-btn {
  font: inherit;
  font-weight: 600;
  color: #0a0a0f;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  border: 0;
  border-radius: 999px;
  padding: 14px 28px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#start-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(124, 156, 255, 0.35); }
#start-btn:disabled { opacity: 0.6; cursor: wait; transform: none; box-shadow: none; }

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  z-index: 10;
  pointer-events: none;
}
.hud.hidden { display: none; }
.hud > * { pointer-events: auto; }

.brand { font-weight: 800; font-size: 1.2rem; letter-spacing: -0.02em; }

.modes { display: flex; gap: 6px; background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 5px; backdrop-filter: blur(8px); }
.mode-btn {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease;
}
.mode-btn:hover { color: var(--fg); }
.mode-btn.active { color: #0a0a0f; background: linear-gradient(120deg, var(--accent), var(--accent-2)); }

.hud-right { display: flex; gap: 8px; }
.ghost {
  font: inherit;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.ghost:hover { color: var(--fg); border-color: rgba(255, 255, 255, 0.28); }

/* ---------- Effects menu (left dropdown) ---------- */
.fx-menu-btn {
  position: absolute;
  top: 68px; left: 16px;
  z-index: 12;
}
.fx-menu-btn.hidden { display: none; }

.fx-menu {
  position: absolute;
  top: 108px; left: 16px;
  width: 210px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  backdrop-filter: blur(10px);
  z-index: 12;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.fx-menu.hidden { display: none; }
.fx-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.fx-menu-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.fx-x {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}
.fx-x:hover { color: var(--fg); background: rgba(255, 255, 255, 0.08); }
.fx-menu ul { list-style: none; }
.fx-row {
  display: flex;
  align-items: center;
  border-radius: 8px;
  transition: background 0.12s ease;
}
.fx-row:hover { background: rgba(255, 255, 255, 0.06); }
.fx-row.current { background: rgba(124, 156, 255, 0.18); }
.fx-jump {
  flex: 1;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--fg);
  font: inherit;
  font-size: 0.9rem;
  padding: 8px 8px;
  cursor: pointer;
  border-radius: 8px;
}
.fx-row.current .fx-jump { color: var(--accent); font-weight: 600; }
.fx-row input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0 8px; cursor: pointer; }
.fx-menu-note {
  margin-top: 10px;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}

/* ---------- Chords key/scale picker ---------- */
.chord-controls {
  position: absolute;
  top: 64px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  backdrop-filter: blur(8px);
  z-index: 11;
}
.chord-controls.hidden { display: none; }
.chord-controls label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.chord-controls select {
  font: inherit;
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg);
  background: rgba(10, 10, 16, 0.9);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  cursor: pointer;
}
.chord-controls select:focus { outline: none; border-color: var(--accent); }
.chord-controls input[type="range"] {
  width: 90px;
  accent-color: var(--accent);
  cursor: pointer;
}
.chord-edit-btn {
  font: inherit;
  font-size: 0.78rem;
  color: var(--fg);
  background: rgba(124, 156, 255, 0.18);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}
.chord-edit-btn:hover { border-color: var(--accent); }

/* Chords reassign editor */
.chord-editor {
  position: absolute;
  top: 112px; left: 50%;
  transform: translateX(-50%);
  width: 280px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  z-index: 13;
}
.chord-editor.hidden { display: none; }
.chord-editor-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.chord-editor-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.chord-preset-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
  margin-bottom: 10px;
}
.chord-editor ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.chord-slot-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chord-slot-label { font-size: 0.85rem; color: var(--fg); }
.chord-editor select {
  font: inherit; font-size: 0.85rem; color: var(--fg);
  background: rgba(10, 10, 16, 0.9);
  border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px; cursor: pointer;
}
.chord-editor select:focus { outline: none; border-color: var(--accent); }
.chord-preset-row select { flex: 1; }
.chord-editor-note { margin-top: 10px; font-size: 0.72rem; color: var(--muted); line-height: 1.35; }

/* ---------- Hint + FPS ---------- */
.hint {
  position: absolute;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 0.85rem;
  color: var(--fg);
  backdrop-filter: blur(8px);
  z-index: 10;
  text-align: center;
  max-width: 90vw;
}
.hint.hidden { display: none; }

.fps {
  position: absolute;
  bottom: 24px; right: 24px;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  z-index: 10;
}
.fps.hidden { display: none; }

@media (max-width: 640px) {
  .mode-btn { padding: 8px 10px; font-size: 0.78rem; }
  .brand, .hud-right { display: none; }
}
