:root {
  --magenta: #ff2bd6;
  --cyan: #00f0ff;
  --bg: #050008;
}

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

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: white;
  font-family: -apple-system, "Inter", "Helvetica Neue", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#stage {
  position: fixed;
  inset: 0;
  background: #000;
}

#cam {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  left: -9999px;
}

#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  filter: saturate(1.3) contrast(1.1);
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#hud .left {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
#hud .right {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 60%;
}

#bpm {
  font-size: 14px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--magenta);
  color: var(--magenta);
  border-radius: 999px;
  text-shadow: 0 0 8px var(--magenta);
  backdrop-filter: blur(6px);
}

#hands {
  font-size: 11px;
  letter-spacing: 0.22em;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.85);
  border-radius: 999px;
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  gap: 6px;
}
#hands .dot {
  width: 8px; height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.2);
  display: inline-block;
}
#hands .dot.on { background: #fff200; box-shadow: 0 0 12px #fff200; }
#hands .dot.lead.on { background: #ff2bd6; box-shadow: 0 0 12px #ff2bd6; }
#hands .sep { opacity: 0.4; }

#extras {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 9px;
  letter-spacing: 0.2em;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.7);
  border-radius: 12px;
  backdrop-filter: blur(6px);
}
#extras .row {
  display: flex;
  align-items: center;
  gap: 8px;
}
#extras .lbl { width: 48px; }
#extras .bar {
  width: 90px;
  height: 5px;
  background: rgba(255,255,255,0.12);
  border-radius: 3px;
  overflow: hidden;
}
#extras .bar > span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--c1, white);
  transition: width 0.15s ease;
  box-shadow: 0 0 8px var(--c1, white);
}
#extras .row:nth-child(1) { --c1: #ff2bd6; }
#extras .row:nth-child(2) { --c1: #fff200; }
#extras input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 92px;
  height: 5px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  outline: none;
  pointer-events: auto;
  cursor: pointer;
}
#extras input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #00f0ff;
  border: none;
  cursor: pointer;
  box-shadow: 0 0 6px #00f0ff;
}
#extras input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #00f0ff;
  border: none;
  cursor: pointer;
  box-shadow: 0 0 6px #00f0ff;
}

#note {
  font-size: 64px;
  font-weight: 900;
  color: var(--cyan);
  text-shadow:
    0 0 12px var(--cyan),
    0 0 32px rgba(0, 240, 255, 0.5),
    2px 0 0 var(--magenta),
    -2px 0 0 #fff200;
  font-variant-numeric: tabular-nums;
}

#rec {
  pointer-events: auto;
  font-family: inherit;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 0.12em;
  padding: 10px 16px;
  background: var(--magenta);
  color: black;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 0 18px var(--magenta);
}
#rec.recording {
  background: #ff003c;
  box-shadow: 0 0 28px #ff003c;
  animation: pulse 0.8s infinite alternate;
}
@keyframes pulse {
  to { transform: scale(1.05); box-shadow: 0 0 40px #ff003c; }
}

#recDuration, #maskSelect {
  pointer-events: auto;
  font-family: inherit;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.12em;
  padding: 8px 12px;
  background: transparent;
  color: white;
  border: 1px solid rgba(255,255,255,0.45);
  border-radius: 999px;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'><path fill='white' d='M0 0l4 5 4-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 26px;
  backdrop-filter: blur(6px);
}
#recDuration:hover, #maskSelect:hover { border-color: white; }
#recDuration option, #maskSelect option { background: #0e0014; color: white; }

#vibe, #beat, #lang {
  pointer-events: auto;
  font-family: inherit;
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 0.16em;
  padding: 8px 12px;
  background: transparent;
  color: white;
  border: 1px solid rgba(255,255,255,0.45);
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
#vibe:hover, #beat:hover, #lang:hover { border-color: white; }
#beat.muted {
  background: rgba(255, 0, 60, 0.15);
  border-color: #ff003c;
  color: #ff003c;
  text-decoration: line-through;
}

/* ---------- SPLASH ---------- */
#splash {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  text-align: center;
  gap: 14px;
  background: radial-gradient(ellipse at center, #1a0024 0%, #050008 70%);
  z-index: 10;
  padding: max(56px, calc(env(safe-area-inset-top, 0px) + 32px)) 24px max(24px, env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
}

#splash h1 {
  font-size: clamp(38px, 9vw, 100px);
  font-weight: 900;
  letter-spacing: -0.03em;
  white-space: nowrap;
  background: linear-gradient(90deg, var(--magenta), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 24px rgba(255, 43, 214, 0.6));
}

#splash .claim {
  font-size: clamp(14px, 2.4vw, 18px);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.75);
}

#splash .pickHint {
  font-size: clamp(11px, 1.6vw, 14px);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.6);
  margin-top: 6px;
}

#splash .hint {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 6px;
}

.voiceSubPanel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.voiceSubPanel.hidden { display: none; }

.picker {
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
  padding: 10px 16px;
  background: rgba(255,255,255,0.06);
  color: white;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 999px;
  cursor: pointer;
  outline: none;
  backdrop-filter: blur(6px);
  min-width: 280px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='white' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 32px;
}
.picker:hover { border-color: rgba(255,255,255,0.55); }
.picker option, .picker optgroup {
  background: #0e0014;
  color: white;
}

.startBtn {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  padding: 18px 32px;
  margin-top: 10px;
  min-width: 220px;
  font-family: inherit;
  text-transform: uppercase;
  cursor: pointer;
  border: none;
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.25);
  color: white;
  transition: transform 0.1s ease, background 0.2s ease, border-color 0.2s ease;
  backdrop-filter: blur(6px);
}
.startBtn:hover { background: rgba(255,255,255,0.08); border-color: white; }
.startBtn:active { transform: scale(0.97); }
.startBtn .ptitle {
  font-weight: 900;
  font-size: 28px;
  letter-spacing: 0.06em;
  background: linear-gradient(90deg, var(--magenta), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 14px var(--magenta));
}
.startBtn .psub {
  font-size: 11px;
  letter-spacing: 0.18em;
  color: rgba(255,255,255,0.65);
}

/* ---------- INFO OVERLAY ---------- */
#infoBtn {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: white;
  font-family: inherit;
  font-weight: 900;
  font-size: 16px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  pointer-events: auto;
}
#infoBtn:hover { border-color: white; background: rgba(0, 0, 0, 0.75); }

#info {
  position: fixed;
  inset: 0;
  background: rgba(5, 0, 8, 0.92);
  backdrop-filter: blur(12px);
  z-index: 20;
  padding: max(24px, calc(env(safe-area-inset-top, 0px) + 16px)) 24px max(24px, env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#info .infoCard {
  position: relative;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 18px;
  padding: 32px 36px;
  font-family: inherit;
  color: rgba(255, 255, 255, 0.92);
  line-height: 1.55;
  backdrop-filter: blur(8px);
}

#info h2 {
  font-size: clamp(20px, 3vw, 28px);
  font-weight: 900;
  letter-spacing: -0.01em;
  margin-top: 18px;
  margin-bottom: 12px;
  background: linear-gradient(90deg, var(--magenta), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#info h2:first-of-type { margin-top: 0; }

#info h3 {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-top: 18px;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.7);
}

#info p {
  font-size: 14px;
  margin-bottom: 10px;
  color: rgba(255, 255, 255, 0.85);
}
#info p.lead { font-size: 15px; color: white; }
#info p.credit {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.18);
  font-size: 13px;
  color: rgba(255,255,255,0.65);
}
#info p.credit a {
  color: #ff2bd6;
  text-decoration: none;
  border-bottom: 1px solid rgba(255,43,214,0.4);
}
#info p.credit a:hover { color: #00f0ff; border-bottom-color: rgba(0,240,255,0.5); }

#splashCredit {
  margin-top: 14px;
  font-size: 11px;
  letter-spacing: 0.10em;
  color: rgba(255,255,255,0.55);
  text-align: center;
}
#splashCredit a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.30);
  padding-bottom: 1px;
}
#splashCredit a:hover { color: #ff2bd6; border-bottom-color: #ff2bd6; }

#info ul {
  list-style: none;
  padding-left: 0;
  margin-bottom: 6px;
}
#info li {
  font-size: 14px;
  padding: 4px 0;
  color: rgba(255, 255, 255, 0.85);
}
#info li strong {
  color: white;
  font-weight: 800;
}

#infoClose {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: white;
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}
#infoClose:hover { background: rgba(255, 255, 255, 0.16); }

/* ---------- DEBUG ---------- */
#debug {
  position: fixed;
  top: 56px;
  left: 12px;
  right: 12px;
  z-index: 99;
  display: none;
  background: rgba(15, 15, 20, 0.92);
  color: rgba(255, 255, 255, 0.85);
  font-family: ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.4;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  word-break: break-word;
  white-space: pre-wrap;
  max-height: 50vh;
  overflow-y: auto;
}
#debug.on { display: block; }
#debug.error {
  background: rgba(255, 0, 60, 0.92);
  border-color: #ff003c;
  color: white;
}

#dropFlash {
  position: absolute;
  inset: 0;
  background: white;
  pointer-events: none;
  z-index: 6;
  animation: dropflash 0.6s ease-out forwards;
}
@keyframes dropflash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

.hidden { display: none !important; }

/* ---------- portrait mobile ---------- */
@media (orientation: portrait) and (max-width: 900px) {
  #hud {
    inset: 8px;
    font-size: 11px;
  }
  #note { font-size: 40px; }
  #bpm { font-size: 11px; padding: 6px 10px; }
  #hands, #extras { font-size: 10px; padding: 5px 8px; }
  #extras .bar { width: 60px; }
  #vibe, #beat, #lang, #rec, #recDuration, #maskSelect { font-size: 10px; padding: 6px 10px; }
  #recDuration, #maskSelect { padding-right: 22px; }
  #infoBtn { top: 8px; width: 30px; height: 30px; font-size: 14px; }
  .picker { min-width: 220px; font-size: 12px; padding: 8px 12px; }
  .startBtn { min-width: 200px; padding: 14px 24px; }
  .startBtn .ptitle { font-size: 22px; }
  #splash h1 { font-size: clamp(32px, 9.5vw, 56px); }
  #splash .claim { font-size: 12px; }
}
