:root {
  --bg: #05050f;
  --fg: #ececf6;
  --muted: #9090ad;
  --pitch: #5ee7ff;
  --volume: #ff5ec8;
  --panel: rgba(14, 14, 30, 0.72);
  --border: rgba(255, 255, 255, 0.12);
}

* { box-sizing: border-box; }

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

#video { display: none; }

canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#fx { touch-action: none; cursor: crosshair; }

/* ---------- Top bar ---------- */
.top {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  pointer-events: none;
}

.brand h1 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--pitch), var(--volume));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#status { margin: 4px 0 0; font-size: 0.85rem; color: var(--muted); }

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

.controls label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.controls select {
  background: #15152a;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
  font: inherit;
}

.controls button,
.tutorial button {
  font: inherit;
  font-size: 0.8rem;
  color: var(--fg);
  background: #15152a;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
}

.controls button:disabled { opacity: 0.4; cursor: default; }

/* ---------- Tutorial card ---------- */
.tutorial {
  position: fixed;
  left: 50%;
  bottom: 130px;
  transform: translateX(-50%);
  width: min(420px, calc(100% - 32px));
  padding: 16px 18px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  backdrop-filter: blur(8px);
  text-align: center;
  z-index: 5;
}

.tutorial.hidden { display: none; }

.tut-step {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.tut-title { margin-top: 4px; font-size: 1.25rem; font-weight: 700; }
.tutorial[data-zone="pitch"] .tut-title { color: var(--pitch); }
.tutorial[data-zone="volume"] .tut-title { color: var(--volume); }
.tutorial[data-zone="done"] .tut-title { color: #7dffa8; }

.tut-text { margin-top: 6px; font-size: 0.9rem; color: var(--muted); line-height: 1.4; }

.tut-progress {
  height: 4px;
  margin: 12px 0 10px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

#tutBar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--pitch), var(--volume));
  transition: width 80ms linear;
}

/* ---------- Volume meter ---------- */
.meter {
  position: fixed;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 40vh;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  pointer-events: none;
}

#meterFill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 0%;
  background: linear-gradient(to top, var(--volume), #ffd25e);
  transition: height 60ms linear;
}

.meter span {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: var(--muted);
}

/* ---------- Note readout ---------- */
.readout {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
}

#note {
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

#freq {
  margin-top: 4px;
  font-size: 0.9rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Intro overlay ---------- */
.intro {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(circle at center, rgba(30, 20, 60, 0.85), rgba(5, 5, 15, 0.96));
  z-index: 10;
}

.intro.hidden { display: none; }

.card {
  max-width: 440px;
  width: 100%;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  text-align: center;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 2rem;
  background: linear-gradient(90deg, var(--pitch), var(--volume));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.card p { color: var(--muted); margin: 0 0 16px; }

.card ul {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  text-align: left;
  line-height: 1.9;
}

.card li b:first-child { color: var(--pitch); }
.card li:nth-child(2) b:first-child,
.card li:nth-child(4) b:first-child { color: var(--volume); }

#start {
  font: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 12px 36px;
  border: none;
  border-radius: 999px;
  color: #05050f;
  background: linear-gradient(90deg, var(--pitch), var(--volume));
  cursor: pointer;
}

#start:disabled { opacity: 0.5; cursor: wait; }

.hint { margin-top: 16px !important; font-size: 0.8rem; }
.error { color: #ff7a7a !important; font-size: 0.85rem; margin: 0 !important; }

@media (max-width: 600px) {
  .top { flex-direction: column; }
  .controls { justify-content: flex-start; }
}
