:root {
  --bg: #0b0e17;
  --panel: rgba(16, 20, 33, 0.82);
  --panel-border: rgba(255, 255, 255, 0.09);
  --text: #eef1f8;
  --muted: #9aa3b8;
  --accent: #ffc861;
  --accent-2: #7dd3fc;
  --trombone: #ffb347;
  --accordion: #f472b6;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

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

#stage {
  position: fixed;
  inset: 0;
  touch-action: none;
  background:
    radial-gradient(1200px 700px at 70% -10%, #1c2440 0%, transparent 60%),
    radial-gradient(900px 600px at 10% 110%, #241a35 0%, transparent 55%),
    var(--bg);
}

/* Camera + overlay: both fill the stage identically so drawings line up with the video */
#video, #overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#video { transform: scaleX(-1); } /* selfie mirror */
#video.active.fx { filter: saturate(0.9) contrast(1.03) brightness(0.92); }

/* ---------- top bar ---------- */
#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: linear-gradient(rgba(5, 8, 15, 0.75), transparent);
  z-index: 5;
}
.brand {
  font-weight: 800;
  letter-spacing: 0.02em;
  font-size: 17px;
  white-space: nowrap;
}
.brand span { color: var(--accent); }

.switch {
  display: flex;
  gap: 4px;
  margin: 0 auto;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  backdrop-filter: blur(12px);
}
.switch-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}
.switch-btn kbd {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  color: var(--muted);
}
.switch-btn.active[data-instrument="trombone"] {
  background: linear-gradient(135deg, rgba(255, 179, 71, 0.25), rgba(255, 179, 71, 0.08));
  color: var(--trombone);
  box-shadow: inset 0 0 0 1px rgba(255, 179, 71, 0.4);
}
.switch-btn.active[data-instrument="accordion"] {
  background: linear-gradient(135deg, rgba(244, 114, 182, 0.25), rgba(244, 114, 182, 0.08));
  color: var(--accordion);
  box-shadow: inset 0 0 0 1px rgba(244, 114, 182, 0.4);
}
.switch-btn.active[data-instrument="maracas"] {
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.25), rgba(52, 211, 153, 0.08));
  color: #34d399;
  box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.4);
}
.switch-btn.active[data-instrument="drums"] {
  background: linear-gradient(135deg, rgba(248, 113, 113, 0.25), rgba(248, 113, 113, 0.08));
  color: #f87171;
  box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.4);
}
.switch-btn.active[data-instrument="harp"] {
  background: linear-gradient(135deg, rgba(192, 132, 252, 0.25), rgba(192, 132, 252, 0.08));
  color: #c084fc;
  box-shadow: inset 0 0 0 1px rgba(192, 132, 252, 0.4);
}
.switch-btn.active[data-instrument="bass"] {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.25), rgba(34, 211, 238, 0.08));
  color: #22d3ee;
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.4);
}
.switch-btn.active kbd { color: inherit; }

.top-right { display: flex; align-items: center; gap: 10px; }

.pill {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--muted);
  white-space: nowrap;
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(12px);
  transition: color 0.2s;
}
.pill.ok { color: #86efac; border-color: rgba(134, 239, 172, 0.35); }
.pill.warn { color: #fca5a5; border-color: rgba(252, 165, 165, 0.35); }
.pill.busy { color: var(--accent-2); border-color: rgba(125, 211, 252, 0.35); }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  backdrop-filter: blur(12px);
}
.icon-btn:hover { border-color: rgba(255,255,255,0.25); }

/* ---------- hints / fps ---------- */
#hint {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 4;
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  max-width: min(88vw, 640px);
  pointer-events: none;
  animation: fadeUp 0.35s ease;
}
#hint em { color: var(--accent); font-style: normal; }
@keyframes fadeUp { from { opacity: 0; transform: translate(-50%, 8px); } }

#fps {
  position: absolute;
  right: 12px;
  bottom: 10px;
  z-index: 4;
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* ---------- start panel ---------- */
.panel {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 32px 20px;
  text-align: center;
  background: radial-gradient(1000px 600px at 50% 0%, rgba(28, 36, 64, 0.6), transparent 70%);
}
.panel h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 46px);
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -0.01em;
}

button.primary {
  margin-top: 8px;
  padding: 15px 34px;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  color: #241a05;
  background: linear-gradient(135deg, #ffd983, #ffb347);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(255, 179, 71, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
button.primary:hover { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(255, 179, 71, 0.45); }

button.ghost {
  padding: 10px 22px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  cursor: pointer;
}
button.ghost:hover { color: var(--text); border-color: rgba(255,255,255,0.3); }

.notice {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  max-width: 560px;
  line-height: 1.5;
}

.fineprint { color: rgba(154, 163, 184, 0.7); font-size: 12px; margin: 4px 0 0; }

.hidden { display: none !important; }

@media (max-width: 720px) {
  .brand span { display: none; }
  .switch-btn kbd { display: none; }
  .switch-btn { padding: 8px 12px; }
  #fps { display: none; }
}
