/* ===== BeatBox Lab · premium stage ===== */
@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@500;600;700;800&display=swap");

.beatboxlab {
  --bb-bg0: #06051a;
  --bb-bg1: #120a2c;
  --bb-cyan: #3df0ff;
  --bb-pink: #ff4d9a;
  --bb-yel: #ffd24a;
  --bb-pur: #8b5cff;
  --bb-ink: #f4f0ff;
  --bb-slot-h: clamp(120px, 28vw, 168px);
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: min(78vh, 720px);
  max-height: min(78vh, 100%);
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  border-radius: 20px;
  overflow: hidden;
  font-family: "Outfit", Fredoka, Nunito, system-ui, sans-serif;
  color: var(--bb-ink);
  background:
    radial-gradient(90% 55% at 50% -8%, rgba(255, 77, 154, 0.28), transparent 55%),
    radial-gradient(50% 40% at 10% 60%, rgba(61, 240, 255, 0.12), transparent 60%),
    radial-gradient(45% 35% at 90% 30%, rgba(139, 92, 255, 0.16), transparent 60%),
    linear-gradient(180deg, #1a0d3a 0%, var(--bb-bg1) 45%, var(--bb-bg0) 100%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  isolation: isolate;
  container-type: inline-size;
}
.beatboxlab *, .beatboxlab *::before, .beatboxlab *::after { box-sizing: border-box; }

.beatboxlab__sky {
  position: absolute; inset: 0 0 38% 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 55% 40% at 50% 0%, rgba(61, 240, 255, 0.14), transparent 65%);
}
.beatboxlab__stars {
  position: absolute; inset: 0; opacity: 0.45;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff, transparent),
    radial-gradient(1px 1px at 48% 12%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 72% 28%, #fff, transparent),
    radial-gradient(1px 1px at 88% 16%, #d8c7ff, transparent);
}
.beatboxlab__city {
  position: absolute; left: -2%; right: -2%; bottom: 0; height: 22%;
  background: linear-gradient(90deg, transparent 0 5%, #1a1238 5% 8%, transparent 8% 14%, #22174a 14% 18%, transparent 18% 26%, #18103a 26% 32%, transparent 32% 40%, #241852 40% 46%, transparent 46% 55%, #1a1238 55% 61%, transparent 61% 70%, #22174a 70% 76%, transparent 76% 85%, #18103a 85% 91%, transparent 91%);
  opacity: 0.75; mask-image: linear-gradient(180deg, transparent, #000 40%);
}

/* ---- top bars ---- */
.beatboxlab__top {
  position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px 4px; flex-wrap: nowrap; min-width: 0;
}
.beatboxlab__brand { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; }
.beatboxlab__logo {
  width: 36px; height: 36px; object-fit: contain; flex: 0 0 auto;
  filter: drop-shadow(0 0 8px rgba(61, 240, 255, 0.5));
}
.beatboxlab__title {
  margin: 0; font-size: clamp(0.95rem, 2.8vw, 1.2rem); font-weight: 800;
  background: linear-gradient(90deg, #fff, var(--bb-cyan));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.beatboxlab__sub { display: none; }

.beatboxlab__actions {
  display: flex; align-items: center; gap: 6px; flex: 0 0 auto; flex-wrap: nowrap;
}
.beatboxlab__btn {
  appearance: none; border: 0; border-radius: 999px;
  padding: 0.48rem 0.85rem; font: inherit; font-weight: 800; font-size: 0.78rem;
  cursor: pointer; color: #081018; white-space: nowrap;
  background: linear-gradient(180deg, #7bfff3, var(--bb-cyan));
  box-shadow: 0 0 0 1px rgba(255,255,255,.2) inset, 0 4px 0 #1498a8;
}
.beatboxlab__btn:active { transform: translateY(2px); box-shadow: 0 0 0 1px rgba(255,255,255,.2) inset, 0 2px 0 #1498a8; }
.beatboxlab__btn--stop {
  color: #fff; background: linear-gradient(180deg, #ff7eb8, var(--bb-pink));
  box-shadow: 0 0 0 1px rgba(255,255,255,.2) inset, 0 4px 0 #b0185f;
}
.beatboxlab__btn--exit {
  color: #1a0a08; background: linear-gradient(180deg, #ffe27a, var(--bb-yel));
  box-shadow: 0 0 0 1px rgba(255,255,255,.25) inset, 0 4px 0 #b8860b;
  animation: bbExitPulse 1.1s ease-in-out infinite;
}
@keyframes bbExitPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.12); }
}
.beatboxlab__btn--ghost {
  color: var(--bb-ink); background: rgba(255,255,255,.08);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16);
  padding: 0.48rem 0.7rem;
}

/* Master tempo bar — always visible */
.beatboxlab__bar {
  position: relative; z-index: 5;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 12px; padding: 8px 12px;
  border-radius: 14px;
  background: rgba(8, 6, 28, 0.72);
  border: 1px solid rgba(61, 240, 255, 0.28);
  backdrop-filter: blur(10px);
}
.beatboxlab__eq { display: flex; align-items: flex-end; gap: 3px; height: 18px; opacity: 0.4; }
.beatboxlab.is-playing .beatboxlab__eq { opacity: 1; }
.beatboxlab__eq span {
  width: 3px; height: 5px; border-radius: 2px; background: var(--bb-cyan);
}
.beatboxlab.is-playing .beatboxlab__eq span { animation: bbEq 0.55s ease-in-out infinite alternate; }
.beatboxlab.is-playing .beatboxlab__eq span:nth-child(2) { animation-delay: .08s; background: var(--bb-pink); }
.beatboxlab.is-playing .beatboxlab__eq span:nth-child(3) { animation-delay: .16s; }
@keyframes bbEq { from { height: 4px; } to { height: 16px; } }

.beatboxlab__tempo {
  display: flex; align-items: center; gap: 8px; flex: 1 1 180px; min-width: 0;
  font-size: 0.75rem; font-weight: 700;
}
.beatboxlab__tempo span:first-child { color: rgba(244,240,255,.7); flex: 0 0 auto; }
.beatboxlab__tempo input[type="range"] {
  flex: 1 1 auto; min-width: 80px; accent-color: var(--bb-cyan); height: 6px;
}
.beatboxlab__tempo-val {
  flex: 0 0 auto; min-width: 58px; color: var(--bb-cyan); font-variant-numeric: tabular-nums;
}

.beatboxlab__mission {
  position: relative; z-index: 5;
  margin: 6px 12px 0; padding: 7px 12px; border-radius: 12px;
  background: rgba(12, 10, 32, 0.55); border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.78rem; font-weight: 600; line-height: 1.3;
}
.beatboxlab__mission strong { color: var(--bb-cyan); }
.beatboxlab__progress { display: none; }

/* ---- stage ---- */
.beatboxlab__stage-wrap {
  position: relative; z-index: 2;
  min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 8px 6px 0;
}
.beatboxlab__floor {
  position: absolute; left: -8%; right: -8%; bottom: 0; height: 34%; z-index: 1;
  background:
    radial-gradient(ellipse 55% 45% at 50% 0%, rgba(61, 240, 255, 0.18), transparent 70%),
    linear-gradient(180deg, #2a1760 0%, #120a30 50%, #08061a 100%);
  border-top-left-radius: 50% 30%; border-top-right-radius: 50% 30%;
}
.beatboxlab__stage {
  position: relative; z-index: 3;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: clamp(2px, 0.8vw, 6px);
  align-items: end;
  width: 100%;
  max-width: 100%;
  padding: 0 clamp(2px, 1vw, 8px) 10px;
  min-height: var(--bb-slot-h);
  overflow: hidden;
}

.beatboxlab__slot {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: var(--bb-slot-h);
  min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  border-radius: 14px;
  overflow: hidden;
  transition: background .15s, box-shadow .15s;
}
.beatboxlab__slot.is-over {
  background: rgba(61, 240, 255, 0.12);
  box-shadow: inset 0 0 0 2px rgba(61, 240, 255, 0.5);
}
.beatboxlab__slot:not(.is-filled)::after {
  content: "+";
  position: absolute; bottom: 52px; left: 50%; transform: translateX(-50%);
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: 14px; font-weight: 800; color: rgba(255,255,255,.22);
  border: 1.5px dashed rgba(255,255,255,.18); pointer-events: none;
}
.beatboxlab__pole {
  position: absolute; bottom: 6px; left: 50%; width: 8px; height: 36px;
  transform: translateX(-50%); border-radius: 5px;
  background: linear-gradient(180deg, #9aa3b8, #4a5166);
  opacity: .3; z-index: 1;
}
.beatboxlab__slot.is-filled .beatboxlab__pole { opacity: .85; height: 40px; }

.bb-char {
  position: relative; z-index: 2; width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  cursor: grab; user-select: none; touch-action: none;
  max-height: 100%;
}
.bb-char:active { cursor: grabbing; }
.bb-char__figure {
  position: relative; width: 100%; max-width: 64px; height: 96px;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,.4));
}
.bb-char__figure--sprite {
  display: flex; align-items: flex-end; justify-content: center;
  width: 100%; max-width: 64px; height: 96px;
}
.bb-char__figure--sprite .bb-sprite {
  width: 100%; max-width: 58px; height: 90px;
  object-fit: contain; object-position: bottom center;
  pointer-events: none; user-select: none;
}
.bb-char__shadow {
  position: absolute; left: 50%; bottom: 0; width: 28px; height: 6px;
  transform: translateX(-50%); border-radius: 50%; background: rgba(0,0,0,.35); filter: blur(2px);
}
.bb-char__label {
  font-size: 0.58rem; font-weight: 700; text-align: center;
  text-shadow: 0 2px 6px rgba(0,0,0,.85); max-width: 100%;
  line-height: 1.05; padding: 0 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bb-badge {
  position: absolute; top: -2px; right: 0; z-index: 5; font-size: 11px;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.5));
}
.bb-glow {
  position: absolute; inset: auto 6px 12px; height: 28px; border-radius: 50%;
  filter: blur(8px); opacity: .4; z-index: 0; background: var(--bb-cyan);
}
.bb-char.is-playing .bb-char__figure { animation: bbBob .45s ease-in-out infinite; }
.bb-char.is-playing .bb-glow { opacity: .8; }
@keyframes bbBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* per-slot tempo */
.bb-slot-tempo {
  position: relative; z-index: 4;
  width: calc(100% - 4px); max-width: 72px;
  margin: 0 auto 2px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  pointer-events: auto;
}
.bb-slot-tempo input[type="range"] {
  width: 100%; height: 4px; accent-color: var(--bb-yel); cursor: pointer;
}
.bb-slot-tempo__val {
  font-size: 0.52rem; font-weight: 700; color: var(--bb-yel);
  font-variant-numeric: tabular-nums; line-height: 1;
  text-shadow: 0 1px 4px rgba(0,0,0,.8);
}

/* tints */
.bb-tint--kick .bb-sprite { filter: drop-shadow(0 6px 8px rgba(0,0,0,.35)); }
.bb-tint--snare .bb-sprite { filter: drop-shadow(0 6px 8px rgba(0,0,0,.35)) hue-rotate(20deg); }
.bb-tint--hat .bb-sprite { filter: drop-shadow(0 6px 8px rgba(0,0,0,.35)) hue-rotate(-15deg); }
.bb-tint--bass .bb-sprite { filter: drop-shadow(0 6px 8px rgba(0,0,0,.35)) hue-rotate(250deg); }
.bb-tint--arp .bb-sprite { filter: drop-shadow(0 6px 8px rgba(0,0,0,.35)) hue-rotate(140deg); }
.bb-tint--lead .bb-sprite { filter: drop-shadow(0 6px 8px rgba(0,0,0,.35)) hue-rotate(180deg); }
.bb-tint--loop .bb-sprite { filter: drop-shadow(0 6px 8px rgba(0,0,0,.35)) hue-rotate(30deg); }
.bb-tint--hiphop .bb-sprite { filter: drop-shadow(0 6px 8px rgba(0,0,0,.35)) hue-rotate(300deg); }
.bb-tint--melody .bb-sprite { filter: drop-shadow(0 6px 8px rgba(0,0,0,.35)) hue-rotate(160deg); }
.bb-tint--voice .bb-sprite { filter: drop-shadow(0 6px 8px rgba(0,0,0,.35)) hue-rotate(320deg); }
.bb-tint--fx .bb-sprite { filter: drop-shadow(0 6px 8px rgba(0,0,0,.35)) hue-rotate(50deg); }
.bb-tint--game .bb-sprite { filter: drop-shadow(0 6px 8px rgba(0,0,0,.35)) hue-rotate(85deg) saturate(1.3); }

/* ---- palette rail + visual EQ ---- */
.beatboxlab__rail {
  position: relative; z-index: 6;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
  padding: 8px 10px 10px;
  background: linear-gradient(180deg, rgba(8,6,24,.15), rgba(6,5,20,.96));
  border-top: 1px solid rgba(255,255,255,.08);
  min-height: 0;
  min-width: 0;
}
.beatboxlab__rail-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.beatboxlab__tabs {
  display: flex; gap: 6px; overflow-x: auto;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
  max-width: 100%;
}
.beatboxlab__tabs::-webkit-scrollbar { display: none; }
.beatboxlab__tab {
  appearance: none; border: 0; border-radius: 999px;
  padding: 0.35rem 0.75rem; font: inherit; font-size: clamp(0.62rem, 2.2vw, 0.7rem); font-weight: 800;
  cursor: pointer; white-space: nowrap; flex: 0 0 auto;
  color: rgba(244,240,255,.7); background: rgba(255,255,255,.06);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.1);
}
.beatboxlab__tab.is-on {
  color: #081018; background: linear-gradient(180deg, #7bfff3, var(--bb-cyan));
  box-shadow: 0 0 12px rgba(61,240,255,.35);
}
.beatboxlab__tab--game.is-on {
  background: linear-gradient(180deg, #ffe27a, var(--bb-yel));
}

.beatboxlab__palette {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 4px;
  -webkit-overflow-scrolling: touch; scrollbar-width: thin;
  align-items: flex-end; max-width: 100%;
}
.beatboxlab__chip {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 5px 5px; border-radius: 14px;
  min-width: clamp(58px, 16vw, 70px); flex: 0 0 auto;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1);
}
.beatboxlab__chip--game {
  background: linear-gradient(180deg, rgba(255, 210, 74, 0.16), rgba(255, 77, 154, 0.1));
  border-color: rgba(255, 210, 74, 0.5);
}
.beatboxlab__chip .bb-char { width: 100%; max-width: 62px; }
.beatboxlab__chip .bb-char__figure--sprite { max-width: 56px; height: clamp(64px, 18vw, 86px); }
.beatboxlab__chip .bb-sprite { max-width: 52px !important; height: clamp(58px, 16vw, 80px) !important; }
.beatboxlab__chip .bb-char__label { font-size: clamp(0.55rem, 2vw, 0.62rem); max-width: 66px; }

.bb-prev {
  width: 28px; height: 28px; border-radius: 50%; border: 0;
  background: rgba(61,240,255,.16); color: var(--bb-cyan);
  font-size: .78rem; font-weight: 800; cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(61,240,255,.35);
}
.bb-prev.is-on {
  background: var(--bb-pink); color: #fff;
  box-shadow: 0 0 12px rgba(255,77,154,.45);
}

/* Visual-only equalizer (right side) */
.beatboxlab__viz {
  flex: 0 0 auto;
  width: clamp(88px, 22vw, 140px);
  min-height: 96px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  gap: 6px;
  padding: 8px 10px 10px;
  border-radius: 16px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 100%, rgba(61, 240, 255, 0.12), transparent 70%),
    rgba(255,255,255,.04);
  border: 1px solid rgba(61, 240, 255, 0.22);
  box-shadow: inset 0 0 20px rgba(139, 92, 255, 0.08);
}
.beatboxlab__viz-label {
  font-size: 0.58rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase;
  color: rgba(244,240,255,.45); margin: 0;
}
.beatboxlab__viz-bars {
  display: flex; align-items: flex-end; justify-content: center;
  gap: clamp(3px, 1vw, 5px);
  height: clamp(56px, 12vw, 78px);
  width: 100%;
}
.beatboxlab__viz-bars i {
  display: block;
  flex: 1 1 0;
  min-width: 4px;
  max-width: 10px;
  height: 12%;
  border-radius: 3px 3px 1px 1px;
  background: linear-gradient(180deg, var(--bb-cyan), var(--bb-pur) 55%, var(--bb-pink));
  opacity: 0.35;
  transform-origin: bottom;
  transition: height .12s ease, opacity .2s;
}
.beatboxlab.is-playing .beatboxlab__viz {
  border-color: rgba(255, 77, 154, 0.4);
  box-shadow: 0 0 18px rgba(61, 240, 255, 0.18), inset 0 0 20px rgba(255, 77, 154, 0.08);
}
.beatboxlab.is-playing .beatboxlab__viz-label { color: var(--bb-cyan); }
.beatboxlab.is-playing .beatboxlab__viz-bars i {
  opacity: 1;
  animation: bbVizDance 0.55s ease-in-out infinite alternate;
}
.beatboxlab.is-playing .beatboxlab__viz-bars i:nth-child(1) { animation-duration: .42s; animation-delay: 0s; }
.beatboxlab.is-playing .beatboxlab__viz-bars i:nth-child(2) { animation-duration: .58s; animation-delay: .05s; background: linear-gradient(180deg, var(--bb-yel), var(--bb-pink)); }
.beatboxlab.is-playing .beatboxlab__viz-bars i:nth-child(3) { animation-duration: .48s; animation-delay: .1s; }
.beatboxlab.is-playing .beatboxlab__viz-bars i:nth-child(4) { animation-duration: .62s; animation-delay: .02s; background: linear-gradient(180deg, var(--bb-pink), var(--bb-pur)); }
.beatboxlab.is-playing .beatboxlab__viz-bars i:nth-child(5) { animation-duration: .5s; animation-delay: .08s; }
.beatboxlab.is-playing .beatboxlab__viz-bars i:nth-child(6) { animation-duration: .68s; animation-delay: .04s; background: linear-gradient(180deg, var(--bb-yel), var(--bb-cyan)); }
.beatboxlab.is-playing .beatboxlab__viz-bars i:nth-child(7) { animation-duration: .44s; animation-delay: .12s; }
.beatboxlab.is-playing .beatboxlab__viz-bars i:nth-child(8) { animation-duration: .56s; animation-delay: .06s; }
.beatboxlab.is-playing .beatboxlab__viz-bars i:nth-child(9) { animation-duration: .52s; animation-delay: .09s; }
.beatboxlab.is-playing .beatboxlab__viz-bars i:nth-child(10) { animation-duration: .6s; animation-delay: .03s; background: linear-gradient(180deg, #fff, var(--bb-cyan)); }
@keyframes bbVizDance {
  0% { height: 14%; }
  100% { height: 92%; }
}

.beatboxlab__hint { display: none; }

/* ---- responsive ---- */
@media (max-width: 720px) {
  .beatboxlab { height: min(84vh, 780px); --bb-slot-h: 148px; }
  .beatboxlab__viz { width: clamp(72px, 20vw, 110px); min-height: 84px; padding: 6px 8px 8px; }
  .beatboxlab__viz-bars { height: 52px; }
}
@media (max-width: 560px) {
  .beatboxlab {
    height: min(86vh, 820px);
    --bb-slot-h: 136px;
    border-radius: 14px;
  }
  .beatboxlab__top { padding: 8px 8px 2px; gap: 6px; }
  .beatboxlab__logo { width: 30px; height: 30px; }
  .beatboxlab__btn { padding: 0.42rem 0.7rem; font-size: 0.72rem; }
  .beatboxlab__btn--ghost { display: none; }
  .beatboxlab__bar { margin: 0 8px; padding: 6px 10px; gap: 8px; }
  .beatboxlab__tempo { flex: 1 1 140px; font-size: 0.68rem; }
  .beatboxlab__mission { margin: 4px 8px 0; font-size: 0.72rem; padding: 6px 10px; }
  .beatboxlab__stage { gap: 2px; padding: 0 2px 8px; }
  .beatboxlab__slot { height: var(--bb-slot-h); }
  .bb-char__figure--sprite { height: 72px; max-width: 42px; }
  .bb-sprite { max-width: 40px !important; height: 68px !important; }
  .bb-slot-tempo { max-width: 48px; }
  .bb-slot-tempo__val { font-size: 0.48rem; }
  .beatboxlab__rail {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px; padding: 6px 8px 8px;
  }
  .beatboxlab__chip { min-width: 54px; padding: 4px 3px; }
  .beatboxlab__chip .bb-char__figure--sprite { height: 64px; }
  .beatboxlab__chip .bb-sprite { height: 58px !important; max-width: 44px !important; }
}
@media (max-width: 400px) {
  .beatboxlab { --bb-slot-h: 120px; }
  .beatboxlab__viz { width: 64px; min-height: 72px; }
  .beatboxlab__viz-label { font-size: 0.5rem; }
  .beatboxlab__viz-bars { height: 44px; gap: 2px; }
  .beatboxlab__title { font-size: 0.88rem; }
}

@media (prefers-reduced-motion: reduce) {
  .bb-char.is-playing .bb-char__figure,
  .beatboxlab.is-playing .beatboxlab__eq span,
  .beatboxlab.is-playing .beatboxlab__viz-bars i,
  .beatboxlab__btn--exit { animation: none !important; }
  .beatboxlab.is-playing .beatboxlab__viz-bars i { height: 55%; opacity: 0.85; }
}
