/**
 * Boxing the Beat — KID-FRIENDLY Visual Design
 *
 * Aesthetic: TOY BOX — bright, bubbly, tactile, fun
 * Audience: Ages 6-12
 * Typography: Lilita One (display), Nunito (body), JetBrains Mono (readouts)
 * Theme: Light/bright with saturated candy colors
 */

/* ─── CSS Custom Properties ─────────────────────────────────────── */

:root {
  /* Bright base palette */
  --bg-cream: #FFF3E0;
  --bg-sky: #E3F2FD;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --border-fun: rgba(0, 0, 0, 0.08);
  --shadow-toy: 0 6px 0 rgba(0,0,0,0.08), 0 12px 24px rgba(0,0,0,0.06);
  --shadow-toy-hover: 0 8px 0 rgba(0,0,0,0.1), 0 16px 32px rgba(0,0,0,0.1);
  --shadow-toy-active: 0 2px 0 rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.06);
  --text-primary: #2D3436;
  --text-secondary: #636E72;
  --text-light: #ffffff;

  /* Candy category colors — SATURATED */
  --color-beats: #FF3B6F;
  --color-bass: #00C853;
  --color-melody: #2979FF;
  --color-vocals: #FFB300;
  --color-effects: #AA00FF;

  /* Sizing — fit all 10 characters on one row */
  --char-size: min(120px, calc((100vw - 200px) / 10));
  --char-gap: min(16px, 1vw);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-round: 50%;

  /* Fun transitions */
  --ease-bounce: cubic-bezier(0.34, 1.8, 0.64, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-squish: cubic-bezier(0.68, -0.55, 0.265, 1.55);

  /* Beat-sync timing — updated by JS when BPM changes (default = 120 BPM) */
  --beat-dur: 0.5s;
}

/* ─── Reset & Base ──────────────────────────────────────────────── */

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

html {
  height: 100%;
  overflow: hidden;
}

body {
  height: 100%;
  overflow: hidden;
  margin: 0;
}

body {
  font-family: 'Nunito', system-ui, sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  cursor: default;

  /* Fun polka-dot background */
  background-color: var(--bg-cream);
  background-image:
    radial-gradient(circle at 20px 20px, rgba(255,59,111,0.06) 8px, transparent 8px),
    radial-gradient(circle at 60px 60px, rgba(41,121,255,0.06) 6px, transparent 6px),
    radial-gradient(circle at 100px 30px, rgba(170,0,255,0.05) 5px, transparent 5px);
  background-size: 120px 80px;
}

/* ─── Screen Management ─────────────────────────────────────────── */

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-bounce);
  transform: scale(0.92);
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

/* ─── Screen 1: Project Selector ────────────────────────────────── */

#project-selector {
  align-items: center;
  justify-content: flex-start;
  padding: 32px 24px;
  overflow-y: auto;
  background: linear-gradient(160deg, #E8F5E9 0%, #E3F2FD 35%, #F3E5F5 70%, #FFF3E0 100%);
}

.selector-header {
  text-align: center;
  margin-bottom: 36px;
}

.selector-header h1 {
  font-family: 'Lilita One', cursive;
  font-size: clamp(2.5rem, 7vw, 5rem);
  letter-spacing: 0.04em;
  color: var(--color-beats);
  text-shadow:
    3px 3px 0 var(--color-vocals),
    6px 6px 0 rgba(0,0,0,0.08);
  animation: titleBounce 2s var(--ease-bounce) infinite;
}

@keyframes titleBounce {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-8px) rotate(1deg); }
}

.selector-header .dedication {
  font-family: 'Nunito', sans-serif;
  font-weight: 600;
  font-style: italic;
  color: var(--color-beats);
  font-size: 1rem;
  margin-top: 12px;
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}

.selector-header p {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  color: var(--text-secondary);
  font-size: 1.2rem;
  letter-spacing: 0.05em;
  margin-top: 8px;
}

#project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 24px;
  max-width: 100%;
  width: 100%;
  padding: 0 24px;
}

/* ─── Project Cards — TOY BUTTONS ───────────────────────────────── */

.project-card {
  background: var(--bg-card);
  border: 4px solid var(--accent, #ddd);
  border-radius: var(--radius-xl);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s var(--ease-bounce);
  position: relative;
  box-shadow: var(--shadow-toy);
  overflow: hidden;
}

.project-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--accent);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.project-card:hover {
  transform: translateY(-8px) scale(1.03);
  box-shadow: var(--shadow-toy-hover);
  border-color: var(--accent);
}

.project-card:active {
  transform: translateY(-2px) scale(0.97);
  box-shadow: var(--shadow-toy-active);
}

/* Project Avatar (concentric rings) */
.project-avatar {
  width: 90px;
  height: 90px;
  margin: 0 auto 16px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-core {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-round);
  background: var(--accent);
  box-shadow: 0 0 16px var(--accent);
  z-index: 2;
  animation: corePulse 1.5s ease-in-out infinite;
}

@keyframes corePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.avatar-ring {
  position: absolute;
  width: var(--ring-size);
  height: var(--ring-size);
  border-radius: var(--radius-round);
  border: 3px solid var(--ring-color);
  opacity: 0.4;
  animation: ringPulse 2s ease-in-out infinite;
  animation-delay: var(--ring-delay);
}

.project-card:hover .avatar-ring {
  opacity: 0.8;
  animation-duration: 1s;
}

@keyframes ringPulse {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50% { transform: scale(1.1); opacity: 0.6; }
}

.project-name {
  font-family: 'Lilita One', cursive;
  font-size: 1.4rem;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.project-genre {
  display: block;
  font-weight: 800;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.project-bpm {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-light);
  background: var(--accent);
  padding: 4px 14px;
  border-radius: 20px;
}

/* ─── Screen 2: Mixer ───────────────────────────────────────────── */

#mixer {
  display: grid;
  /* toolbar | stage (stretches) | beat-grid | palette (shrinks to fit) */
  grid-template-rows: auto 1fr auto minmax(0, auto);
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height — accounts for mobile browser chrome */
  overflow: hidden;
  background: linear-gradient(180deg, #E3F2FD 0%, #F3E5F5 50%, #FFF3E0 100%);
}

/* ─── Mixer Toolbar — CHUNKY & CLEAR ────────────────────────────── */

.mixer-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  position: relative; /* Contain the absolute-positioned dedication */
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 3px solid rgba(0,0,0,0.06);
  z-index: 10;
  position: relative;
}

.toolbar-dedication {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Lilita One', cursive;
  font-size: 1.25rem;
  letter-spacing: 0.03em;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  z-index: -1; /* Behind toolbar content so it never blocks clicks or overlaps */
  opacity: 0.3; /* Subtle background decoration, not a competing element */
  max-width: 40%; /* Never take more than 40% of toolbar width */
  overflow: hidden;
  text-overflow: ellipsis;

  /* Flowing candy rainbow — cycles through the game's own palette */
  background: linear-gradient(90deg,
    var(--color-beats)   0%,
    var(--color-vocals)  20%,
    var(--color-melody)  40%,
    var(--color-bass)    60%,
    var(--color-effects) 80%,
    var(--color-beats)   100%
  );
  background-size: 250% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;

  animation:
    dedication-shimmer 5s linear infinite,
    dedication-float   3s ease-in-out infinite;
}

@keyframes dedication-shimmer {
  0%   { background-position: 0%   center; }
  100% { background-position: 250% center; }
}

@keyframes dedication-float {
  0%, 100% { transform: translateX(-50%) translateY(0px);   }
  50%       { transform: translateX(-50%) translateY(-2px);  }
}

#back-btn {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  border: 3px solid rgba(0,0,0,0.1);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.2s var(--ease-bounce);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 0 rgba(0,0,0,0.06);
}

#back-btn:hover {
  transform: scale(1.1);
  background: #FFF3E0;
}

#back-btn:active {
  transform: scale(0.95);
  box-shadow: 0 1px 0 rgba(0,0,0,0.06);
}

#project-title {
  font-family: 'Lilita One', cursive;
  font-size: 1.3rem;
  margin-right: 8px;
  white-space: nowrap;
  flex-shrink: 0;
  color: var(--color-beats);
}

/* Category Tabs — PILL BUTTONS */
.category-tabs {
  display: flex;
  gap: 6px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar { display: none; }

.category-tab {
  padding: 8px 18px;
  border-radius: 24px;
  border: 3px solid transparent;
  background: rgba(0,0,0,0.04);
  color: var(--text-secondary);
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.25s var(--ease-bounce);
}

.category-tab:hover {
  background: rgba(0,0,0,0.08);
  transform: scale(1.05);
}

.category-tab.active {
  background: var(--tab-color);
  border-color: var(--tab-color);
  color: white;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--tab-color) 40%, transparent);
  transform: scale(1.05);
}

/* Transport Controls — BIG & BOLD */
.transport-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.bpm-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bpm-control label {
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  text-transform: uppercase;
}

#bpm-slider {
  width: 110px;
  height: 10px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(0,0,0,0.08);
  border-radius: 5px;
  outline: none;
}

#bpm-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-round);
  background: var(--color-melody);
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(41,121,255,0.4);
  border: 3px solid white;
  transition: transform 0.2s var(--ease-bounce);
}

#bpm-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

#bpm-slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-round);
  background: var(--color-melody);
  cursor: pointer;
  border: 3px solid white;
  box-shadow: 0 3px 8px rgba(41,121,255,0.4);
}

#bpm-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-melody);
  min-width: 36px;
  text-align: right;
}

/* PLAY/PAUSE — THE BIG BUTTON */
#play-pause-btn {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-round);
  border: 4px solid #00C853;
  background: #00E676;
  color: white;
  font-size: 1.3rem;
  cursor: pointer;
  transition: all 0.2s var(--ease-bounce);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 #00A843, 0 6px 16px rgba(0,200,83,0.3);
}

#play-pause-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 0 #00A843, 0 10px 24px rgba(0,200,83,0.4);
}

#play-pause-btn:active {
  transform: scale(0.95) translateY(2px);
  box-shadow: 0 2px 0 #00A843, 0 3px 8px rgba(0,200,83,0.3);
}

#play-pause-btn.playing {
  background: #FF5252;
  border-color: #D32F2F;
  box-shadow: 0 4px 0 #B71C1C, 0 6px 16px rgba(255,82,82,0.3);
}

#play-pause-btn.playing:hover {
  box-shadow: 0 6px 0 #B71C1C, 0 10px 24px rgba(255,82,82,0.4);
}

/* ─── Beat Grid Visualizer — 4x4 STEP DISPLAY ──────────────────── */

.beat-grid-container {
  display: flex;
  justify-content: center;
  padding: 8px 20px;
  background: rgba(255, 255, 255, 0.6);
}

#beat-grid {
  display: flex;
  gap: 12px;
}

.beat-group {
  display: flex;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.03);
}

.beat-step {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.05);
  border: 2px solid rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Nunito', sans-serif;
  font-size: 0.75rem;
  font-weight: 900;
  color: rgba(0, 0, 0, 0.2);
  transition: all 0.08s ease-out;
}

/* Each beat group has its own color palette */
.beat-group:nth-child(1) { --beat-color: #FF3B6F; --beat-glow: rgba(255,59,111,0.4); } /* Pink/Red */
.beat-group:nth-child(2) { --beat-color: #FFB300; --beat-glow: rgba(255,179,0,0.4); }   /* Gold */
.beat-group:nth-child(3) { --beat-color: #00C853; --beat-glow: rgba(0,200,83,0.4); }    /* Green */
.beat-group:nth-child(4) { --beat-color: #2979FF; --beat-glow: rgba(41,121,255,0.4); }  /* Blue */

/* Active step — uses group color */
.beat-step.active {
  background: var(--beat-color);
  border-color: var(--beat-color);
  color: white;
  transform: scaleY(1.3) scaleX(1.05);
  box-shadow: 0 2px 12px var(--beat-glow);
}

/* Downbeat steps (1, 2, 3, 4) bigger pop */
.beat-step.active.downbeat {
  transform: scaleY(1.6) scaleX(1.15);
  box-shadow: 0 4px 20px var(--beat-glow);
}

/* Recently played step — faded group color */
.beat-step.trail {
  background: color-mix(in srgb, var(--beat-color) 25%, white);
  border-color: color-mix(in srgb, var(--beat-color) 15%, transparent);
}

/* ─── Stage (Character Area) — THE PLAYGROUND ───────────────────── */

.stage-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 12px;
  overflow: visible;
  position: relative;
  min-height: 0; /* Allow grid row to shrink below content height */
}

#stage {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: var(--char-gap);
  flex-wrap: wrap;
  width: 100%;
  max-width: 100%;
  padding: 20px 12px;
  position: relative;
}

/* ─── Characters — BIG BOUNCY FRIENDS ───────────────────────────── */

.character {
  width: var(--char-size);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: default;
  transition: all 0.4s var(--ease-bounce);
  position: relative;
  animation: charEntrance 0.5s var(--ease-bounce) backwards;
}

/* Staggered entrance */
.character:nth-child(1) { animation-delay: 0s; }
.character:nth-child(2) { animation-delay: 0.06s; }
.character:nth-child(3) { animation-delay: 0.12s; }
.character:nth-child(4) { animation-delay: 0.18s; }
.character:nth-child(5) { animation-delay: 0.24s; }
.character:nth-child(6) { animation-delay: 0.30s; }
.character:nth-child(7) { animation-delay: 0.36s; }
.character:nth-child(8) { animation-delay: 0.42s; }
.character:nth-child(9) { animation-delay: 0.48s; }
.character:nth-child(10) { animation-delay: 0.54s; }

@keyframes charEntrance {
  0% { transform: translateY(40px) scale(0.5); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* Drop target highlight */
.character.drop-target::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: var(--radius-xl);
  border: 4px dashed rgba(0, 0, 0, 0.15);
  animation: dashPulse 0.8s ease-in-out infinite;
}

.character.drag-over {
  transform: scale(1.15);
}

.character.drag-over::after {
  border-color: var(--color-melody);
  border-style: solid;
  background: rgba(41, 121, 255, 0.08);
}

@keyframes dashPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* Character Image Wrapper */
.char-img-wrapper {
  width: 130px;
  height: 130px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.char-img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  position: relative;
  z-index: 1;
  transition: all 0.4s var(--ease-bounce);
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15));
}

/* Idle: desaturated with spotlight circle */
.character.idle .char-img {
  filter: grayscale(0.8) brightness(0.7) drop-shadow(0 4px 8px rgba(0,0,0,0.1));
  opacity: 0.5;
}

.character.idle::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -40%);
  width: 100px;
  height: 30px;
  background: radial-gradient(ellipse, rgba(0,0,0,0.08), transparent 70%);
  border-radius: var(--radius-round);
  z-index: 0;
}

.character.idle:hover .char-img {
  filter: grayscale(0.3) brightness(0.85) drop-shadow(0 4px 8px rgba(0,0,0,0.15));
  opacity: 0.75;
  /* Stop breathing animation on hover so the scale transform can apply */
  animation: none !important;
  transform: scale(1.08);
}

/* ─── Active: per-category animations synced to --beat-dur ─────────────
 * data-category is set by renderStage() on each .character.active element.
 * --beat-dur is updated by JS whenever BPM changes so all animations
 * breathe at the correct musical tempo automatically.
 * ─────────────────────────────────────────────────────────────────────── */

/* Base: colored drop shadow for all active characters */
.character.active .char-img {
  filter: drop-shadow(0 6px 16px color-mix(in srgb, var(--char-color) 40%, transparent));
}

/* ── BEATS: punchy squish on every quarter note ── */
.character.active[data-category="beats"] .char-img {
  animation: beatsDance var(--beat-dur) var(--ease-squish) infinite;
}
@keyframes beatsDance {
  0%   { transform: translateY(0)     scaleY(1)    scaleX(1); }
  8%   { transform: translateY(-14px) scaleY(1.1)  scaleX(0.91); }
  20%  { transform: translateY(3px)   scaleY(0.92) scaleX(1.08); }
  35%  { transform: translateY(-7px)  scaleY(1.04) scaleX(0.96); }
  50%  { transform: translateY(1px)   scaleY(0.97) scaleX(1.03); }
  100% { transform: translateY(0)     scaleY(1)    scaleX(1); }
}

/* ── BASS: slow deep groove over 2 beats ── */
.character.active[data-category="bass"] .char-img {
  animation: bassDance calc(var(--beat-dur) * 2) ease-in-out infinite;
}
@keyframes bassDance {
  0%,100% { transform: translateY(0)    rotate(0deg); }
  18%     { transform: translateY(-11px) rotate(-4deg); }
  50%     { transform: translateY(6px)   rotate(3.5deg); }
  72%     { transform: translateY(-4px)  rotate(-2deg); }
}

/* ── MELODY: smooth waltz sway over 2 beats ── */
.character.active[data-category="melody"] .char-img {
  animation: melodyDance calc(var(--beat-dur) * 2) ease-in-out infinite;
}
@keyframes melodyDance {
  0%,100% { transform: translateX(0)    rotate(0deg)  scaleY(1); }
  25%     { transform: translateX(-9px) rotate(-6deg) scaleY(1.02); }
  50%     { transform: translateX(0)    rotate(0deg)  scaleY(1); }
  75%     { transform: translateX(9px)  rotate(6deg)  scaleY(1.02); }
}

/* ── VOCALS: energetic head-bob sing on every beat ── */
.character.active[data-category="vocals"] .char-img {
  animation: vocalsDance var(--beat-dur) ease-in-out infinite;
}
@keyframes vocalsDance {
  0%,100% { transform: translateY(0)    rotate(0deg); }
  12%     { transform: translateY(-13px) rotate(-3deg); }
  28%     { transform: translateY(-2px)  rotate(2.5deg); }
  55%     { transform: translateY(-9px)  rotate(-2deg); }
  78%     { transform: translateY(-1px)  rotate(1deg); }
}

/* ── EFFECTS: shimmer-throb over 2 beats ── */
.character.active[data-category="effects"] .char-img {
  animation: effectsDance calc(var(--beat-dur) * 2) ease-in-out infinite;
}
@keyframes effectsDance {
  0%,100% { transform: scale(1)    rotate(0deg); }
  20%     { transform: scale(1.07) rotate(2.5deg); }
  50%     { transform: scale(0.96) rotate(-1.5deg); }
  75%     { transform: scale(1.04) rotate(1deg); }
}

/* Fallback for any unknown/missing/invalid category value */
.character.active:not([data-category]) .char-img,
.character.active[data-category=""] .char-img,
.character.active[data-category="null"] .char-img,
.character.active[data-category="undefined"] .char-img {
  animation: beatsDance var(--beat-dur) var(--ease-squish) infinite;
}

/* ── Floating music notes — vocals characters ── */
.char-notes {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  overflow: visible;
}
.char-note {
  position: absolute;
  font-size: 15px;
  color: var(--char-color, var(--color-vocals));
  opacity: 0;
  animation: floatNote calc(var(--beat-dur) * 2) ease-out infinite;
  text-shadow: 0 1px 4px rgba(0,0,0,0.25);
  user-select: none;
}
.char-note:nth-child(1) { left: 18%; bottom: 55%; animation-delay: 0s; }
.char-note:nth-child(2) { left: 62%; bottom: 55%; animation-delay: calc(var(--beat-dur) * 0.67); }
.char-note:nth-child(3) { left: 40%; bottom: 55%; animation-delay: calc(var(--beat-dur) * 1.33); }

@keyframes floatNote {
  0%   { transform: translateY(0)    rotate(-8deg)  scale(0.7); opacity: 0; }
  15%  { opacity: 1; }
  60%  { opacity: 0.75; }
  100% { transform: translateY(-52px) rotate(12deg) scale(1.1); opacity: 0; }
}

/* Glow behind character */
.char-glow {
  position: absolute;
  inset: -20px;
  border-radius: var(--radius-round);
  background: radial-gradient(
    circle,
    color-mix(in srgb, var(--char-color) 25%, transparent),
    transparent 60%
  );
  opacity: 0;
  transition: opacity 0.4s var(--ease-out);
  z-index: 0;
}

.character.active .char-glow {
  opacity: 1;
  animation: glowPulse calc(var(--beat-dur) * 2) ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* Instrument overlay — bottom-right badge */
.char-instrument {
  position: absolute;
  bottom: 0;
  right: 0;
  z-index: 3;
  font-size: 1.5rem;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-round);
  background: white;
  border: 3px solid var(--inst-color);
  box-shadow: 0 3px 8px color-mix(in srgb, var(--inst-color) 30%, transparent);
  animation: instrumentPop 0.4s var(--ease-bounce);
}

@keyframes instrumentPop {
  0% { transform: scale(0) rotate(-20deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* Character Label Area */
.char-label {
  width: 100%;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.char-name {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-secondary);
  text-align: center;
}

.char-drop-hint {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--color-melody);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0;
  transition: opacity 0.3s;
}

.character.drop-target .char-drop-hint,
.character.drag-over .char-drop-hint {
  opacity: 1;
  animation: hintBounce 0.6s var(--ease-bounce) infinite;
}

@keyframes hintBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.char-sound-name {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--char-color);
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Active character = clickable to remove */
.character.active {
  cursor: pointer;
}

.character.active:hover {
  transform: scale(0.92);
}

/* Waveform visualization — COLORFUL BARS */
.char-waveform {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 24px;
}

.wave-bar {
  width: 5px;
  border-radius: 3px;
  background: var(--char-color);
  animation: waveBar calc(var(--beat-dur) * 0.75) ease-in-out infinite;
}

.wave-bar:nth-child(1) { height: 40%; animation-delay: 0s; }
.wave-bar:nth-child(2) { height: 70%; animation-delay: 0.08s; }
.wave-bar:nth-child(3) { height: 100%; animation-delay: 0.16s; }
.wave-bar:nth-child(4) { height: 55%; animation-delay: 0.24s; }
.wave-bar:nth-child(5) { height: 35%; animation-delay: 0.12s; }

@keyframes waveBar {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.3); }
}

/* ─── Palette Container — THE TOY BOX ───────────────────────────── */

.palette-container {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 3px solid rgba(0,0,0,0.06);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0; /* Allow grid to shrink this row */
}

.palette-container::-webkit-scrollbar {
  width: 8px;
}

.palette-container::-webkit-scrollbar-track {
  background: transparent;
}

.palette-container::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

/* Sound Palette — HORIZONTAL LAYOUT, all visible at once */
#sound-palette {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 10px;
  justify-content: flex-start;
  overflow-x: auto;
  padding: 4px 16px 4px 16px;  /* horizontal padding so edge items aren't clipped */
  -webkit-overflow-scrolling: touch;
}

.palette-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--group-color, #ccc) 6%, white);
  border: 2px solid color-mix(in srgb, var(--group-color, #ccc) 15%, white);
}

.palette-group-label {
  font-family: 'Lilita One', cursive;
  font-size: 1rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.palette-icons {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
}

/* Sound Icons — BIG ROUNDED TOY BUTTONS */
.sound-icon {
  width: 105px;
  height: 105px;
  border-radius: var(--radius-lg);
  border: 3px solid color-mix(in srgb, var(--sound-color) 50%, white);
  background: color-mix(in srgb, var(--sound-color) 8%, white);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: grab;
  transition: all 0.25s var(--ease-bounce);
  user-select: none;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--sound-color) 20%, transparent);
  animation: iconWiggle 3s ease-in-out infinite;
  animation-delay: calc(var(--wiggle-seed, 0) * 0.3s);
}

/* Subtle idle wiggle to invite interaction */
@keyframes iconWiggle {
  0%, 90%, 100% { transform: rotate(0deg); }
  93% { transform: rotate(-3deg); }
  96% { transform: rotate(3deg); }
}

.sound-icon:nth-child(1) { --wiggle-seed: 0; }
.sound-icon:nth-child(2) { --wiggle-seed: 1; }
.sound-icon:nth-child(3) { --wiggle-seed: 2; }
.sound-icon:nth-child(4) { --wiggle-seed: 3; }

.sound-icon:hover:not(.assigned) {
  transform: translateY(-6px) scale(1.08);
  border-color: var(--sound-color);
  background: color-mix(in srgb, var(--sound-color) 15%, white);
  box-shadow: 0 8px 0 color-mix(in srgb, var(--sound-color) 15%, transparent),
              0 12px 24px color-mix(in srgb, var(--sound-color) 15%, transparent);
}

.sound-icon:active:not(.assigned) {
  cursor: grabbing;
  transform: scale(0.93) translateY(2px);
  box-shadow: 0 2px 0 color-mix(in srgb, var(--sound-color) 15%, transparent);
}

.sound-icon.assigned {
  opacity: 0.25;
  cursor: not-allowed;
  border-style: dashed;
  animation: none;
}

.sound-icon.dragging {
  opacity: 0.4;
  transform: scale(0.85) rotate(-5deg);
}

.sound-icon-symbol {
  font-size: 2.4rem;
  color: var(--sound-color);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}

.sound-icon-name {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-secondary);
  text-align: center;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Palette Action Buttons */
.palette-actions {
  display: flex;
  gap: 10px;
}

.palette-actions button {
  padding: 10px 20px;
  border-radius: var(--radius-lg);
  border: 3px solid rgba(0,0,0,0.08);
  background: white;
  color: var(--text-secondary);
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s var(--ease-bounce);
  box-shadow: 0 3px 0 rgba(0,0,0,0.04);
}

.palette-actions button:hover {
  transform: translateY(-2px) scale(1.03);
  background: #E3F2FD;
  border-color: var(--color-melody);
  color: var(--color-melody);
  box-shadow: 0 5px 0 rgba(0,0,0,0.06);
}

.palette-actions button:active {
  transform: translateY(1px) scale(0.97);
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}

/* ─── Sparkle Effect (CSS-only, added via JS class) ─────────────── */

@keyframes sparkle {
  0% { transform: scale(0) rotate(0deg); opacity: 1; }
  50% { opacity: 1; }
  100% { transform: scale(1.5) rotate(180deg); opacity: 0; }
}

.sparkle-burst::after {
  content: '✨';
  position: absolute;
  top: 10%;
  left: 50%;
  font-size: 2rem;
  z-index: 10;
  animation: sparkle 0.6s var(--ease-out) forwards;
  pointer-events: none;
}

/* ─── Responsive ────────────────────────────────────────────────── */

/* ─── MEDIUM SCREENS (max 900px) ───────────────────────────────── */

@media (max-width: 900px) {
  .toolbar-dedication { display: none !important; }
}

/* ─── TABLET (max 768px) ───────────────────────────────────────── */

@media (max-width: 768px) {
  :root {
    --char-size: 100px;
    --char-gap: 10px;
  }

  /* Toolbar: compact, wrap transport to second row */
  .mixer-toolbar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 10px;
  }

  #project-title {
    font-size: 1rem;
  }

  .toolbar-dedication { display: none; }

  .category-tabs {
    order: 10;
    width: 100%;
    gap: 3px;
  }

  .category-tab {
    padding: 5px 12px;
    font-size: 0.75rem;
  }

  #bpm-slider { width: 70px; }
  #play-pause-btn { width: 44px; height: 44px; font-size: 1rem; }
  #back-btn { width: 40px; height: 40px; font-size: 1.2rem; }

  .transport-controls { gap: 8px; }
  .bpm-control label { display: none; }

  /* Stage: smaller characters */
  .stage-container { padding: 10px 8px; }

  .char-img-wrapper { width: 80px; height: 80px; }
  .char-img { width: 72px; height: 72px; }
  .char-instrument { width: 28px; height: 28px; font-size: 1.1rem; }
  .char-label { min-height: 32px; }
  .char-name { font-size: 0.6rem; }
  .char-sound-name { font-size: 0.6rem; }

  /* Beat grid: smaller */
  .beat-grid-container { padding: 4px 8px; }
  .beat-step { width: 28px; height: 28px; font-size: 0.65rem; }
  .beat-group { gap: 3px; padding: 3px 5px; }
  #beat-grid { gap: 8px; }

  /* Palette: smaller icons, horizontal scroll */
  .palette-container {
    padding: 8px 8px;
    max-height: 35vh;
    gap: 6px;
  }

  .sound-icon {
    width: 64px;
    height: 64px;
    border-radius: 14px;
  }

  .sound-icon-symbol { font-size: 1.5rem; }
  .sound-icon-name { font-size: 0.55rem; max-width: 56px; }

  .palette-group { padding: 4px 6px; }
  .palette-group-label { font-size: 0.8rem; }
  .palette-icons { gap: 5px; }

  .palette-actions button {
    padding: 6px 12px;
    font-size: 0.75rem;
  }

  /* Project selector */
  #project-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
  }

  .selector-header h1 { font-size: 2.2rem; }
  .selector-header .dedication { font-size: 0.85rem; }
  .project-card { padding: 20px 14px; }
  .project-name { font-size: 1.15rem; }
}

/* ─── PHONE (max 520px — covers all Android phones up to 412px + some tablets) */

@media (max-width: 520px) {
  :root {
    --char-size: 72px;
    --char-gap: 6px;
  }

  /* Toolbar: minimal, two rows — controls top, tabs bottom */
  .mixer-toolbar {
    padding: 4px 6px;
    gap: 3px;
    flex-wrap: wrap;
  }

  #project-title { font-size: 0.8rem; max-width: 80px; overflow: hidden; text-overflow: ellipsis; }
  #back-btn { width: 32px; height: 32px; font-size: 0.9rem; border-width: 2px; padding: 0; }
  #play-pause-btn { width: 36px; height: 36px; font-size: 0.85rem; border-width: 3px; }

  .category-tabs {
    order: 10;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
  .category-tab { padding: 4px 10px; font-size: 0.65rem; flex-shrink: 0; }
  .transport-controls { gap: 4px; }
  #bpm-slider { width: 50px; height: 6px; }
  #bpm-display { font-size: 0.75rem; min-width: 24px; }
  .bpm-control label { display: none; }

  /* Hide non-essential toolbar buttons on small screens */
  .record-btn,
  #record-btn,
  #mixes-btn,
  #share-btn,
  #tap-tempo-btn,
  #seq-btn,
  .volume-control { display: none !important; }

  /* Stage: wrap to 2 rows so all 7 characters are visible without horizontal scroll */
  .stage-container {
    padding: 4px 4px;
    flex: none;               /* Override flex:1 — only take content height */
    overflow-x: hidden;
    overflow-y: visible;
    justify-content: center;
  }
  #stage {
    padding: 4px 4px;
    gap: var(--char-gap);
    flex-wrap: wrap;          /* 2-row wrap — all 7 chars visible on screen */
    justify-content: center;
    min-width: unset;
  }

  /* Mixer grid: stage+beat auto-size, palette fills remaining space */
  #mixer {
    grid-template-rows: auto auto auto 1fr !important;
  }

  /* Palette fills bottom, scrollable if lots of sounds */
  .palette-container {
    align-content: flex-start;
    overflow-y: auto;
    max-height: none;         /* Override 35vh cap from 768px query — fill the 1fr row */
  }

  .char-img-wrapper { width: 60px; height: 60px; }
  .char-img { width: 54px; height: 54px; }
  .char-glow { inset: -8px; }
  .char-instrument { width: 22px; height: 22px; font-size: 0.85rem; border-width: 2px; }
  .char-label { min-height: 24px; gap: 2px; }
  .char-name { font-size: 0.5rem; }
  .char-sound-name { font-size: 0.5rem; }
  .char-drop-hint { font-size: 0.5rem; }
  .char-waveform { height: 16px; gap: 2px; }
  .wave-bar { width: 3px; }

  /* Beat grid: compact */
  .beat-grid-container { padding: 3px 4px; }
  .beat-step { width: 20px; height: 20px; font-size: 0.55rem; border-radius: 6px; }
  .beat-group { gap: 2px; padding: 2px 3px; border-radius: 8px; }
  #beat-grid { gap: 5px; }

  /* Palette: small icons, takes remaining screen space */
  .palette-container {
    padding: 6px 4px;
    gap: 4px;
    min-height: 0;
  }

  /* Sound groups: stack vertically so all categories visible without horizontal scroll */
  #sound-palette {
    flex-direction: column;
    flex-wrap: nowrap;
    overflow-x: hidden;
    justify-content: flex-start;
    align-items: stretch;
    gap: 6px;
  }

  /* Each group: full width, sounds wrap within it */
  .palette-group {
    width: 100%;
    box-sizing: border-box;
    padding: 3px 4px;
    border-width: 1px;
    border-radius: 10px;
  }

  .palette-group-label { font-size: 0.65rem; }

  /* Sounds wrap within each group row */
  .palette-icons {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 3px;
  }

  .sound-icon {
    width: 52px;
    height: 52px;
    border-width: 2px;
    border-radius: 12px;
  }

  .sound-icon-symbol { font-size: 1.2rem; }
  .sound-icon-name { font-size: 0.5rem; max-width: 46px; }

  .palette-actions { gap: 6px; }
  .palette-actions button {
    padding: 5px 10px;
    font-size: 0.7rem;
    border-width: 2px;
  }

  /* Project selector */
  #project-selector { padding: 20px 12px; }
  .selector-header h1 { font-size: 1.7rem; }
  .selector-header .dedication { font-size: 0.75rem; }
  .selector-header p { font-size: 0.9rem; }

  #project-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
  }

  .project-card { padding: 16px 10px; border-radius: 20px; border-width: 3px; }
  .project-avatar { width: 60px; height: 60px; margin-bottom: 10px; }
  .avatar-core { width: 18px; height: 18px; }
  .project-name { font-size: 1rem; }
  .project-genre { font-size: 0.75rem; }
  .project-bpm { font-size: 0.65rem; padding: 2px 8px; }

  .search-bar { padding: 0 8px; margin-bottom: 10px; }
  .project-search { font-size: 0.85rem; padding: 8px 12px; }
}

/* ─── VERY SMALL PHONE (max 360px) ─────────────────────────────── */

@media (max-width: 360px) {
  :root {
    --char-size: 60px;
    --char-gap: 4px;
  }

  .char-img-wrapper { width: 50px; height: 50px; }
  .char-img { width: 46px; height: 46px; }
  .char-instrument { display: none; }
  .char-name { display: none; }

  .sound-icon { width: 44px; height: 44px; }
  .sound-icon-symbol { font-size: 1rem; }
  .sound-icon-name { display: none; }

  .beat-step { width: 16px; height: 16px; font-size: 0; }
  #beat-grid { gap: 3px; }
  .beat-group { gap: 1px; padding: 2px; }

  .selector-header h1 { font-size: 1.4rem; }
}

/* ─── Utility ───────────────────────────────────────────────────── */

::selection {
  background: rgba(41, 121, 255, 0.2);
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--color-melody);
  outline-offset: 3px;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
}

/* ═══════════════════════════════════════════════════════════════════
   PHASE 1 ADDITIONS
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Project Search Bar ────────────────────────────────────────── */

.search-bar {
  width: 100%;
  max-width: 420px;
  margin-bottom: 20px;
}

.project-search {
  width: 100%;
  padding: 12px 22px;
  border-radius: var(--radius-xl);
  border: 3px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.85);
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  outline: none;
  transition: all 0.25s var(--ease-bounce);
  box-shadow: var(--shadow-toy);
}

.project-search:focus {
  border-color: var(--color-melody);
  background: white;
  box-shadow: var(--shadow-toy-hover);
  transform: scale(1.01);
}

.project-search::placeholder {
  color: #b0b8c1;
  font-weight: 700;
}

/* ─── Project Card — Phase 1.1 Enhancements ─────────────────────── */

/* Entrance animation for cards */
@keyframes cardEntrance {
  0%   { transform: translateY(28px) scale(0.88); opacity: 0; }
  100% { transform: translateY(0)    scale(1);    opacity: 1; }
}

.project-card {
  animation: cardEntrance 0.45s var(--ease-bounce) backwards;
}

/* Category dot row */
.project-category-dots {
  display: flex;
  gap: 5px;
  justify-content: center;
  margin: 10px 0 4px;
  flex-wrap: wrap;
}

.category-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  opacity: 0.85;
}

.project-sound-count {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-secondary);
  margin-top: 2px;
  letter-spacing: 0.04em;
}

/* ── Local-only pack badge (shown on GitHub Pages) ── */
.local-only-pack {
  opacity: 0.55;
  cursor: default;
}
.local-only-pack:hover {
  transform: none;
  box-shadow: var(--shadow-toy);
}
.local-only-pack:active {
  transform: none;
  box-shadow: var(--shadow-toy);
}
.local-only-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* ── Offline pack controls ───────────────────────────────────────── */

.offline-btn-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
}

.offline-dl-btn {
  font-family: 'Nunito', sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1.5px solid rgba(0,0,0,0.13);
  background: rgba(255,255,255,0.75);
  color: #2979FF;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.04em;
  transition: background 0.15s, transform 0.1s;
}
.offline-dl-btn:hover   { background: #e8f0fe; }
.offline-dl-btn:active  { transform: scale(0.96); }
.offline-dl-btn:disabled { opacity: 0.6; cursor: default; }

.offline-badge {
  display: inline-block;
  font-family: 'Nunito', sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: 0.04em;
  cursor: default;
}
.offline-badge--ready {
  background: rgba(0, 200, 83, 0.15);
  border: 1.5px solid rgba(0, 200, 83, 0.4);
  color: #00873a;
}
.offline-badge--partial {
  background: rgba(255,179,0,0.15);
  border: 1.5px solid rgba(255,179,0,0.5);
  color: #b37a00;
  cursor: pointer;
}
.offline-badge--partial:hover { background: rgba(255,179,0,0.25); }

.offline-pin-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 2px 4px;
  border-radius: 6px;
  opacity: 0.55;
  transition: opacity 0.15s, transform 0.1s;
}
.offline-pin-btn:hover   { opacity: 1; transform: scale(1.1); }
.offline-pin-btn:active  { transform: scale(0.92); }
.offline-pin-btn:disabled { opacity: 0.3; cursor: default; }

.offline-remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 2px 4px;
  border-radius: 6px;
  opacity: 0.4;
  transition: opacity 0.15s, transform 0.1s, color 0.15s;
}
.offline-remove-btn:hover   { opacity: 1; color: #FF3B6F; transform: scale(1.1); }
.offline-remove-btn:active  { transform: scale(0.92); }
.offline-remove-btn:disabled { opacity: 0.2; cursor: default; }

.offline-network-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: #FF6B35;
  color: #fff;
  text-align: center;
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 8px 16px;
  letter-spacing: 0.03em;
  transform: translateY(-100%);
  transition: transform 0.3s var(--ease-bounce);
}
.offline-network-banner:not(.hidden) {
  transform: translateY(0);
}

/* "New Project" card */
.project-card.new-project-card {
  border-style: dashed;
  border-color: rgba(0,0,0,0.15);
  background: rgba(255,255,255,0.5);
}

.project-card.new-project-card:hover {
  border-color: var(--color-melody);
  background: rgba(41,121,255,0.04);
}

.new-project-plus {
  font-size: 2.5rem;
  color: rgba(0,0,0,0.15);
  line-height: 1;
  margin-bottom: 8px;
  transition: color 0.2s;
}

.project-card.new-project-card:hover .new-project-plus {
  color: var(--color-melody);
}

/* No results message */
.no-results {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 700;
  grid-column: 1 / -1;
}

.no-results span {
  font-size: 2rem;
  display: block;
  margin-bottom: 8px;
}

/* ─── Tap Tempo Button ───────────────────────────────────────────── */

#tap-tempo-btn {
  padding: 8px 13px;
  border-radius: var(--radius-md);
  border: 3px solid var(--color-vocals);
  background: white;
  color: var(--color-vocals);
  font-family: 'Lilita One', cursive;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.1s var(--ease-bounce);
  box-shadow: 0 3px 0 rgba(255,179,0,0.3);
  flex-shrink: 0;
  letter-spacing: 0.04em;
}

#tap-tempo-btn:active,
#tap-tempo-btn.tapped {
  transform: scale(0.92) translateY(2px);
  box-shadow: 0 1px 0 rgba(255,179,0,0.3);
  background: var(--color-vocals);
  color: white;
}

/* ─── Master Volume ──────────────────────────────────────────────── */

.volume-control {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.volume-icon {
  font-size: 1rem;
  line-height: 1;
}

#volume-slider {
  width: 72px;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(0,0,0,0.08);
  border-radius: 4px;
  outline: none;
}

#volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-round);
  background: var(--color-bass);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0,200,83,0.4);
  transition: transform 0.15s var(--ease-bounce);
}

#volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

#volume-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-round);
  background: var(--color-bass);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0,200,83,0.4);
}

/* ─── Loading Overlay ────────────────────────────────────────────── */

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(255, 243, 224, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.35s;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.loading-spinner {
  width: 64px;
  height: 64px;
  border: 6px solid rgba(0,0,0,0.08);
  border-top-color: var(--color-beats);
  border-right-color: var(--color-melody);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-title {
  font-family: 'Lilita One', cursive;
  font-size: 1.8rem;
  color: var(--color-beats);
}

.loading-bar-wrap {
  width: 300px;
  height: 18px;
  background: rgba(0,0,0,0.07);
  border-radius: 9px;
  overflow: hidden;
  border: 2px solid rgba(0,0,0,0.05);
}

.loading-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-beats), var(--color-melody));
  border-radius: 9px;
  transition: width 0.35s var(--ease-out);
}

.loading-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
}

/* ─── Tutorial Overlay ───────────────────────────────────────────── */

.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s;
}

.tutorial-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.tutorial-content {
  background: white;
  border-radius: var(--radius-xl);
  padding: 36px 40px 40px;
  max-width: 440px;
  width: 92%;
  text-align: center;
  box-shadow: var(--shadow-toy-hover);
  position: relative;
  animation: tutorialPop 0.45s var(--ease-bounce);
}

@keyframes tutorialPop {
  0%   { transform: scale(0.65); opacity: 0; }
  100% { transform: scale(1);    opacity: 1; }
}

.tutorial-close {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-secondary);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-round);
  border: none;
  background: transparent;
  transition: background 0.15s;
}

.tutorial-close:hover {
  background: rgba(0,0,0,0.06);
}

.tutorial-emoji {
  font-size: 3rem;
  margin-bottom: 4px;
}

.tutorial-content h2 {
  font-family: 'Lilita One', cursive;
  font-size: 1.9rem;
  color: var(--color-beats);
  margin-bottom: 22px;
}

.tutorial-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 28px;
  text-align: left;
}

.tutorial-step {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(0,0,0,0.03);
  border-radius: var(--radius-md);
  padding: 9px 14px;
}

.tutorial-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.tutorial-step span:last-child {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.tutorial-ok-btn {
  background: var(--color-bass);
  color: white;
  border: none;
  border-radius: var(--radius-xl);
  padding: 14px 40px;
  font-family: 'Lilita One', cursive;
  font-size: 1.15rem;
  cursor: pointer;
  transition: all 0.2s var(--ease-bounce);
  box-shadow: 0 5px 0 #00a843;
}

.tutorial-ok-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 0 #00a843;
}

.tutorial-ok-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #00a843;
}

/* ─── Undo Toast ─────────────────────────────────────────────────── */

.undo-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: rgba(30, 30, 40, 0.88);
  color: white;
  padding: 10px 22px;
  border-radius: var(--radius-lg);
  font-family: 'Nunito', sans-serif;
  font-size: 0.88rem;
  font-weight: 800;
  transition: transform 0.35s var(--ease-bounce);
  z-index: 300;
  pointer-events: none;
  letter-spacing: 0.03em;
}

.undo-toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ─── Character Idle Breathing ───────────────────────────────────── */

@keyframes idleBreathe {
  0%, 100% { transform: scale(1)    translateY(0px);  }
  50%       { transform: scale(1.04) translateY(-4px); }
}

.character.idle .char-img {
  animation: idleBreathe 3.5s ease-in-out infinite !important;
}

/* ─── Character Beat Pulse ───────────────────────────────────────── */

@keyframes beatPulse {
  0%   { transform: scale(1);    }
  35%  { transform: scale(1.14); }
  70%  { transform: scale(0.97); }
  100% { transform: scale(1);    }
}

.character.beat-pulse .char-img {
  animation: beatPulse 0.25s var(--ease-bounce) forwards !important;
}

/* ─── Character Mute State ───────────────────────────────────────── */

.character.muted .char-img {
  filter: grayscale(0.7) brightness(0.75) drop-shadow(0 4px 8px rgba(0,0,0,0.1)) !important;
  opacity: 0.55 !important;
}

.character.muted .char-glow {
  opacity: 0 !important;
  animation: none !important;
}

.character.muted .char-waveform .wave-bar {
  animation: none !important;
  opacity: 0.3;
}

/* ─── Transport-paused: freeze active character animations ───────── */
/* #stage gains .is-playing when Transport runs; loses it on pause/stop.
   Idle characters keep their breathe animation — only active dancers freeze. */
#stage:not(.is-playing) .character.active .char-img,
#stage:not(.is-playing) .character.active .char-glow,
#stage:not(.is-playing) .character.active .wave-bar,
#stage:not(.is-playing) .character.active .char-note {
  animation-play-state: paused !important;
}

/* Mute button — appears on hover over active characters */
.char-mute-btn {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-round);
  background: rgba(0, 0, 0, 0.65);
  color: white;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.2s, background 0.15s, transform 0.15s;
  border: 2px solid rgba(255,255,255,0.25);
  user-select: none;
}

.character.active:hover .char-mute-btn {
  opacity: 1;
}

.character.muted .char-mute-btn {
  opacity: 1;
  background: rgba(255, 82, 82, 0.85);
}

.char-mute-btn:hover {
  transform: scale(1.15);
  background: rgba(255, 82, 82, 0.9) !important;
}

/* On touch/non-hover devices (phones, tablets) the :hover state never fires,
   so character overlay buttons would be permanently invisible. Always show them
   on devices where hover is not the primary input mechanism. */
@media (hover: none) {
  .character.active .char-mute-btn,
  .character.active .char-fx-btn {
    opacity: 1;
  }
}

/* ─── FX Button (per-character effects) ─────────────────────────── */

.char-fx-btn {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-round);
  background: rgba(0, 0, 0, 0.65);
  color: white;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.2s, background 0.15s, transform 0.15s;
  border: 2px solid rgba(255,255,255,0.25);
  user-select: none;
}

.character.active:hover .char-fx-btn {
  opacity: 1;
}

.char-fx-btn:hover {
  transform: scale(1.15);
  background: rgba(80, 120, 255, 0.9) !important;
}

/* ─── FX Popover ─────────────────────────────────────────────────── */

.fx-popover {
  position: fixed;
  z-index: 2000;
  background: #1a1a2e;
  border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 12px 14px 10px;
  width: 220px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.55), 0 0 0 1px rgba(80,120,255,0.25);
  animation: fx-popover-in 0.18s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes fx-popover-in {
  from { opacity: 0; transform: scale(0.88) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.fx-popover-header {
  font-family: 'Lilita One', sans-serif;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.fx-popover-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.35);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s;
}
.fx-popover-close:hover { color: rgba(255,255,255,0.8); }

/* Each effect row */
.fx-row {
  margin-bottom: 8px;
}

.fx-row-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: rgba(255,255,255,0.6);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.fx-locked .fx-row-label {
  color: rgba(255,255,255,0.25);
}

.fx-locked-hint {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.25);
  font-style: italic;
  padding: 2px 0 4px;
}

.fx-slider-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fx-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.15);
  outline: none;
  cursor: pointer;
}

.fx-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #5078ff;
  cursor: pointer;
  box-shadow: 0 0 4px rgba(80,120,255,0.6);
  transition: transform 0.1s;
}

.fx-slider::-webkit-slider-thumb:hover {
  transform: scale(1.25);
}

/* Firefox */
.fx-slider::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.15);
  border: none;
}

.fx-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #5078ff;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 4px rgba(80,120,255,0.6);
}

.fx-value {
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(255,255,255,0.5);
  min-width: 36px;
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
}

/* Reset row */
.fx-reset-row {
  margin-top: 10px;
  text-align: center;
}

.fx-reset-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  color: rgba(255,255,255,0.35);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.fx-reset-btn:hover {
  color: rgba(255,255,255,0.7);
  border-color: rgba(255,255,255,0.4);
}

/* ─── Sound Tooltip ──────────────────────────────────────────────── */

.sound-icon {
  position: relative; /* ensure stacking context for tooltip */
}

.sound-tooltip {
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 20, 32, 0.88);
  color: white;
  font-family: 'Nunito', sans-serif;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 5px 10px;
  border-radius: var(--radius-md);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 50;
}

.sound-icon:hover .sound-tooltip {
  opacity: 1;
}

.sound-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(20, 20, 32, 0.88);
}

/* Click-to-preview ripple */
@keyframes previewRipple {
  0%   { box-shadow: 0 0 0 0px color-mix(in srgb, var(--sound-color) 60%, transparent); }
  100% { box-shadow: 0 0 0 14px color-mix(in srgb, var(--sound-color) 0%, transparent); }
}

.sound-icon.previewing {
  animation: previewRipple 0.4s var(--ease-out) forwards !important;
  border-color: var(--sound-color) !important;
  background: color-mix(in srgb, var(--sound-color) 18%, white) !important;
}

/* ─── Drag Ghost Element ─────────────────────────────────────────── */

#drag-ghost {
  position: fixed;
  top: -200px;
  left: -200px;
  width: 80px;
  height: 80px;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  pointer-events: none;
  z-index: 9999;
  border: 3px solid;
  box-shadow: 0 8px 20px rgba(0,0,0,0.25);
  opacity: 0.95;
}

#drag-ghost .ghost-symbol {
  font-size: 2rem;
}

#drag-ghost .ghost-name {
  font-family: 'Nunito', sans-serif;
  font-size: 0.65rem;
  font-weight: 800;
  text-align: center;
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Responsive — Phase 1 additions ────────────────────────────── */

@media (max-width: 768px) {
  .toolbar-dedication { display: none; }
  #tap-tempo-btn { padding: 6px 10px; font-size: 0.72rem; }
  .volume-control { display: none; }
  .search-bar { max-width: 100%; padding: 0 8px; }
}

/* ─── Phase 2: Transport action buttons (Record, Mixes, Share) ───── */

#record-btn,
#mixes-btn,
#share-btn {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 3px solid rgba(0,0,0,0.12);
  background: white;
  color: var(--text-primary);
  font-family: 'Nunito', sans-serif;
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.12s var(--ease-bounce), box-shadow 0.12s;
  box-shadow: 0 3px 0 rgba(0,0,0,0.1);
  line-height: 1;
}

#record-btn:hover,
#mixes-btn:hover,
#share-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 5px 0 rgba(0,0,0,0.12);
}

#record-btn:active,
#mixes-btn:active,
#share-btn:active {
  transform: scale(0.93) translateY(2px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.1);
}

/* Record button — idle has red tint */
#record-btn {
  border-color: #FF5252;
  color: #FF5252;
}

/* Record button — actively recording */
#record-btn.recording {
  background: #FF5252;
  border-color: #D32F2F;
  color: white;
  box-shadow: 0 3px 0 #B71C1C, 0 0 0 0 rgba(255,82,82,0.4);
  animation: recordPulse 1.2s ease-in-out infinite;
  font-size: 0.78rem;
  padding: 8px 10px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.03em;
}

@keyframes recordPulse {
  0%, 100% { box-shadow: 0 3px 0 #B71C1C, 0 0 0 0 rgba(255,82,82,0.5); }
  50%       { box-shadow: 0 3px 0 #B71C1C, 0 0 0 8px rgba(255,82,82,0); }
}

#mixes-btn { border-color: #2979FF; color: #2979FF; }
#share-btn { border-color: #AA00FF; color: #AA00FF; }

/* Hide transport action buttons on phones — MUST come after base styles above */
@media (max-width: 520px) {
  #record-btn,
  #mixes-btn,
  #share-btn,
  #tap-tempo-btn { display: none !important; }
}

/* ─── Phase 2: Recording countdown overlay ──────────────────────── */

.record-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(20, 10, 30, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.record-overlay.hidden {
  display: none;
}

.record-countdown {
  font-family: 'Lilita One', cursive;
  font-size: 12rem;
  color: white;
  text-shadow: 0 0 60px rgba(255,82,82,0.9), 0 8px 0 rgba(0,0,0,0.3);
  line-height: 1;
  user-select: none;
}

@keyframes countdownBounce {
  0%   { transform: scale(0.4); opacity: 0; }
  55%  { transform: scale(1.15); opacity: 1; }
  75%  { transform: scale(0.95); }
  100% { transform: scale(1); opacity: 1; }
}

.record-countdown.countdown-bounce {
  animation: countdownBounce 0.45s var(--ease-bounce) forwards;
}

/* ─── Phase 2: General toast ─────────────────────────────────────── */

.share-toast {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30, 20, 50, 0.92);
  color: white;
  font-family: 'Nunito', sans-serif;
  font-size: 0.88rem;
  font-weight: 800;
  padding: 10px 22px;
  border-radius: var(--radius-xl);
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  z-index: 400;
  transition: opacity 0.25s, transform 0.25s var(--ease-bounce);
  white-space: nowrap;
}

.share-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Phase 2: Mixes modal ────────────────────────────────────────── */

.mixes-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(20, 15, 35, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  padding: 20px;
}

.mixes-modal.hidden {
  display: none;
}

.mixes-content {
  background: white;
  border-radius: var(--radius-xl);
  padding: 32px 36px 28px;
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35), 0 6px 0 rgba(0,0,0,0.08);
  animation: modalPop 0.3s var(--ease-bounce) forwards;
}

@keyframes modalPop {
  0%   { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1);    opacity: 1; }
}

.mixes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mixes-header h2 {
  font-family: 'Lilita One', cursive;
  font-size: 1.6rem;
  color: #2979FF;
}

.mixes-close {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-round);
  border: 2px solid var(--border-fun);
  background: #f5f5f5;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
}

.mixes-close:hover {
  background: #ffe0e0;
  color: #FF3B6F;
  transform: scale(1.12);
}

.mixes-save-row {
  display: flex;
  gap: 10px;
}

.mixes-save-row input {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 3px solid #e0e0e0;
  font-family: 'Nunito', sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  outline: none;
  transition: border-color 0.15s;
}

.mixes-save-row input:focus {
  border-color: #2979FF;
}

.mixes-save-row input::placeholder {
  color: #bbb;
  font-weight: 600;
}

#mix-save-btn {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: 3px solid #1A56C4;
  background: #2979FF;
  color: white;
  font-family: 'Nunito', sans-serif;
  font-size: 0.9rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.12s var(--ease-bounce), box-shadow 0.12s;
  box-shadow: 0 3px 0 #1A56C4;
}

#mix-save-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 5px 0 #1A56C4;
}

#mix-save-btn:active {
  transform: scale(0.95) translateY(2px);
  box-shadow: 0 1px 0 #1A56C4;
}

/* Saved mixes list */
.mixes-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 280px;
  padding-right: 4px;
}

.mixes-list::-webkit-scrollbar { width: 6px; }
.mixes-list::-webkit-scrollbar-track { background: #f5f5f5; border-radius: 3px; }
.mixes-list::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }

.mixes-empty {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.88rem;
  padding: 24px 16px;
  line-height: 1.5;
}

.mix-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #f9f9fc;
  border-radius: var(--radius-md);
  border: 2px solid #eeeeee;
  transition: border-color 0.15s;
}

.mix-item:hover {
  border-color: #2979FF;
}

.mix-item-meta {
  flex: 1;
  min-width: 0;
}

.mix-item-name {
  font-size: 0.95rem;
  font-weight: 900;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mix-item-details {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mix-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.mix-load-btn,
.mix-share-btn,
.mix-delete-btn {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-family: 'Nunito', sans-serif;
  font-size: 0.78rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
  border: 2px solid;
}

.mix-load-btn   { background: #00C853; border-color: #00A843; color: white; }
.mix-share-btn  { background: white;   border-color: #AA00FF; color: #AA00FF; }
.mix-delete-btn { background: white;   border-color: #e0e0e0; color: #aaa; }

.mix-load-btn:hover   { transform: scale(1.08); }
.mix-share-btn:hover  { background: #f3e8ff; transform: scale(1.08); }
.mix-delete-btn:hover { border-color: #FF3B6F; color: #FF3B6F; transform: scale(1.08); }

.mix-load-btn:disabled,
.shared-mix-load-btn:disabled {
  background: #e0e0e0;
  border-color: #ccc;
  color: #999;
  cursor: not-allowed;
  transform: none;
  opacity: 0.7;
}

/* Mixes footer (export / import / screenshot) */
.mixes-footer {
  display: flex;
  gap: 8px;
  padding-top: 4px;
  border-top: 2px solid #f0f0f0;
}

.mixes-io-btn {
  flex: 1;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  border: 2px solid #e0e0e0;
  background: white;
  color: var(--text-secondary);
  font-family: 'Nunito', sans-serif;
  font-size: 0.78rem;
  font-weight: 900;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, color 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mixes-io-btn:hover {
  border-color: #2979FF;
  color: #2979FF;
  transform: scale(1.04);
}

/* ─── Phase 2: Shared mix banner on project selector ─────────────── */

.shared-mix-banner {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #f3e8ff 0%, #e8f0ff 100%);
  border-radius: var(--radius-lg);
  border: 3px solid #AA00FF;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.shared-mix-title {
  font-size: 1rem;
  font-weight: 900;
  color: #AA00FF;
  flex: 1;
}

.shared-mix-sub {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  width: 100%;
  margin-top: -8px;
}

.shared-mix-load-btn {
  padding: 9px 18px;
  border-radius: var(--radius-md);
  border: 3px solid #00A843;
  background: #00C853;
  color: white;
  font-family: 'Nunito', sans-serif;
  font-size: 0.88rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.12s var(--ease-bounce);
  box-shadow: 0 3px 0 #00A843;
}

.shared-mix-load-btn:hover { transform: scale(1.07); }

.shared-mix-dismiss {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-round);
  border: 2px solid #e0e0e0;
  background: white;
  color: #aaa;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
}

.shared-mix-dismiss:hover { color: #FF3B6F; border-color: #FF3B6F; }

/* ─── Responsive — Phase 2 ──────────────────────────────────────── */

@media (max-width: 768px) {
  #record-btn, #mixes-btn, #share-btn { padding: 6px 9px; font-size: 0.95rem; }
  .record-countdown { font-size: 8rem; }
  .mixes-content { padding: 24px 20px 20px; }
  .mixes-footer { flex-direction: column; }
}

/* ═══════════════════════════════════════════════════════════════════
   PHASE 5: PACK BUILDER (Screen 3)
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Screen 3 Layout ───────────────────────────────────────────── */

#pack-builder {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(160deg, #E8F5E9 0%, #E3F2FD 35%, #F3E5F5 70%, #FFF3E0 100%);
}

/* ─── Pack Builder Toolbar ──────────────────────────────────────── */

.pb-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 3px solid rgba(0,0,0,0.06);
  z-index: 10;
  flex-shrink: 0;
}

.pb-toolbar-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.pb-toolbar-title {
  font-family: 'Lilita One', cursive;
  font-size: 1.3rem;
  color: #AA00FF;
  letter-spacing: 0.03em;
}

.pb-by {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.pb-back {
  padding: 9px 16px;
  border-radius: var(--radius-lg);
  border: 3px solid rgba(0,0,0,0.1);
  background: white;
  color: var(--text-primary);
  font-family: 'Nunito', sans-serif;
  font-size: 0.88rem;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.2s var(--ease-bounce);
  box-shadow: 0 3px 0 rgba(0,0,0,0.06);
  flex-shrink: 0;
}

.pb-back:hover {
  transform: translateY(-2px) scale(1.04);
  background: #FFF3E0;
  border-color: var(--color-vocals);
}

.pb-back:active {
  transform: translateY(1px) scale(0.97);
}

.pb-save-top-btn {
  padding: 9px 16px;
  border-radius: var(--radius-lg);
  border: 3px solid #7B00CC;
  background: #AA00FF;
  color: white;
  font-family: 'Nunito', sans-serif;
  font-size: 0.88rem;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.2s var(--ease-bounce);
  box-shadow: 0 3px 0 #7B00CC;
  flex-shrink: 0;
}

.pb-save-top-btn:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 5px 0 #7B00CC;
}

.pb-save-top-btn:active {
  transform: translateY(1px) scale(0.97);
  box-shadow: 0 1px 0 #7B00CC;
}

/* ─── 3-Column Layout ───────────────────────────────────────────── */

.pb-layout {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ─── Panels ────────────────────────────────────────────────────── */

.pb-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  min-height: 0;
}

.pb-panel-browse {
  background: #ffffff;
  border-right: 2px solid rgba(0,0,0,0.07);
}

.pb-panel-canvas {
  background: var(--bg-cream);
  background-image:
    radial-gradient(circle at 20px 20px, rgba(170,0,255,0.05) 4px, transparent 4px),
    radial-gradient(circle at 60px 60px, rgba(41,121,255,0.04) 3px, transparent 3px);
  background-size: 80px 80px;
  border-right: 2px solid rgba(0,0,0,0.07);
}

.pb-panel-settings {
  background: #ffffff;
  overflow-y: auto;
  padding: 20px 18px 28px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.1) transparent;
}

.pb-panel-settings::-webkit-scrollbar { width: 6px; }
.pb-panel-settings::-webkit-scrollbar-track { background: transparent; }
.pb-panel-settings::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 3px; }

/* ─── Panel Headers ─────────────────────────────────────────────── */

.pb-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 2px solid rgba(0,0,0,0.05);
  background: rgba(255,255,255,0.9);
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 6px;
}

.pb-panel-title {
  font-family: 'Lilita One', cursive;
  font-size: 1.1rem;
  color: var(--text-primary);
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

/* ─── Category Tabs (browse panel) ─────────────────────────────── */

.pb-category-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.pb-cat-tab {
  padding: 5px 11px;
  border-radius: 20px;
  border: 2px solid transparent;
  background: rgba(0,0,0,0.04);
  color: var(--text-secondary);
  font-family: 'Nunito', sans-serif;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s var(--ease-bounce);
}

.pb-cat-tab:hover {
  background: rgba(0,0,0,0.08);
  transform: scale(1.05);
}

.pb-cat-tab.active {
  background: var(--tab-col);
  border-color: var(--tab-col);
  color: white;
  box-shadow: 0 3px 8px color-mix(in srgb, var(--tab-col) 40%, transparent);
  transform: scale(1.05);
}

/* ─── Search Input ──────────────────────────────────────────────── */

.pb-search {
  margin: 8px 10px;
  padding: 9px 14px;
  border-radius: var(--radius-lg);
  border: 2px solid rgba(0,0,0,0.08);
  background: rgba(0,0,0,0.02);
  font-family: 'Nunito', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s;
  flex-shrink: 0;
}

.pb-search:focus {
  border-color: #AA00FF;
  background: white;
  box-shadow: 0 0 0 3px rgba(170,0,255,0.1);
}

.pb-search::placeholder {
  color: #c0c8d0;
  font-weight: 600;
}

/* ─── Sound List ────────────────────────────────────────────────── */

.pb-sound-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.1) transparent;
}

.pb-sound-list::-webkit-scrollbar { width: 5px; }
.pb-sound-list::-webkit-scrollbar-track { background: transparent; }
.pb-sound-list::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 3px; }

.pb-browser-empty {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  padding: 24px 12px;
  font-weight: 700;
}

/* ─── Sound List Items ──────────────────────────────────────────── */

.pb-sound-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 2px solid rgba(0,0,0,0.05);
  background: white;
  cursor: pointer;
  transition: all 0.2s var(--ease-bounce);
  min-height: 52px;
}

.pb-sound-item:hover {
  transform: scale(1.02) translateX(2px);
  border-color: var(--item-color, #AA00FF);
  background: color-mix(in srgb, var(--item-color, #AA00FF) 5%, white);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--item-color, #AA00FF) 20%, transparent);
}

.pb-sound-item:active {
  transform: scale(0.98);
}

.pb-sound-item.in-pack {
  background: color-mix(in srgb, var(--item-color, #AA00FF) 8%, white);
  border-color: var(--item-color, #AA00FF);
  border-style: solid;
}

.pb-sound-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
}

.pb-sound-info {
  flex: 1;
  min-width: 0;
}

.pb-sound-name {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pb-sound-proj {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pb-sound-badge {
  font-size: 0.62rem;
  font-weight: 900;
  color: white;
  padding: 2px 7px;
  border-radius: 12px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}

.pb-sound-action-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-round);
  border: 2px solid var(--item-color, #AA00FF);
  background: white;
  color: var(--item-color, #AA00FF);
  font-size: 1.1rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s var(--ease-bounce);
  flex-shrink: 0;
}

.pb-sound-action-btn:hover {
  background: var(--item-color, #AA00FF);
  color: white;
  transform: scale(1.15);
}

/* ─── Upload Zone ───────────────────────────────────────────────── */

.pb-upload-zone {
  padding: 10px 10px 12px;
  border-top: 2px solid rgba(0,0,0,0.05);
  flex-shrink: 0;
}

.pb-upload-btn {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  border: 3px dashed rgba(170,0,255,0.35);
  background: rgba(170,0,255,0.04);
  color: #AA00FF;
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.2s var(--ease-bounce);
}

.pb-upload-btn:hover {
  border-color: #AA00FF;
  background: rgba(170,0,255,0.09);
  transform: translateY(-1px);
}

.pb-upload-btn:active {
  transform: translateY(1px);
}

/* ─── Pack Canvas Grid ──────────────────────────────────────────── */

.pb-canvas-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  align-content: start;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.1) transparent;
}

.pb-canvas-grid::-webkit-scrollbar { width: 5px; }
.pb-canvas-grid::-webkit-scrollbar-track { background: transparent; }
.pb-canvas-grid::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 3px; }

/* ─── Canvas Sound Cards ────────────────────────────────────────── */

.pb-canvas-sound {
  background: white;
  border: 3px solid color-mix(in srgb, var(--card-color, #AA00FF) 40%, white);
  border-radius: var(--radius-lg);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  position: relative;
  cursor: default;
  transition: all 0.2s var(--ease-bounce);
  animation: pbCardIn 0.35s var(--ease-bounce) backwards;
  box-shadow: 0 3px 0 color-mix(in srgb, var(--card-color, #AA00FF) 20%, transparent);
  min-height: 88px;
}

@keyframes pbCardIn {
  0%   { transform: scale(0.7) rotate(-5deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg);    opacity: 1; }
}

.pb-canvas-sound:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 6px 0 color-mix(in srgb, var(--card-color, #AA00FF) 15%, transparent),
              0 8px 20px color-mix(in srgb, var(--card-color, #AA00FF) 15%, transparent);
  border-color: var(--card-color, #AA00FF);
}

.pb-canvas-sound-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.pb-canvas-sound-name {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-primary);
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.pb-canvas-sound-cat {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pb-canvas-remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-round);
  border: none;
  background: rgba(255,59,111,0.12);
  color: #FF3B6F;
  font-size: 0.65rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, transform 0.15s;
}

.pb-canvas-sound:hover .pb-canvas-remove-btn {
  opacity: 1;
}

.pb-canvas-remove-btn:hover {
  background: #FF3B6F;
  color: white;
  transform: scale(1.2);
}

/* ─── Canvas Empty State ────────────────────────────────────────── */

.pb-canvas-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 12px;
  padding: 40px 20px;
  pointer-events: none;
}

.pb-empty-icon {
  font-size: 3.5rem;
  animation: pbEmptyBounce 2.5s ease-in-out infinite;
}

@keyframes pbEmptyBounce {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50%       { transform: translateY(-12px) rotate(5deg); }
}

.pb-empty-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: center;
  max-width: 260px;
  line-height: 1.4;
}

/* ─── Count Badge ───────────────────────────────────────────────── */

.pb-count-badge {
  background: #AA00FF;
  color: white;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  flex-shrink: 0;
}

/* ─── Settings Panel styles ─────────────────────────────────────── */

.pb-setting-group {
  margin-bottom: 22px;
}

.pb-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.pb-char-hint {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  color: #b0b8c1;
}

/* Pack Name Input */
.pb-name-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  border: 3px solid rgba(0,0,0,0.08);
  background: rgba(0,0,0,0.02);
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s;
}

.pb-name-input:focus {
  border-color: #AA00FF;
  background: white;
  box-shadow: 0 0 0 3px rgba(170,0,255,0.12);
}

.pb-name-input::placeholder {
  color: #c0c8d0;
  font-weight: 600;
}

.pb-name-input.pb-input-error {
  border-color: #FF3B6F;
  animation: pbShake 0.35s var(--ease-bounce);
}

@keyframes pbShake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-6px); }
  75%       { transform: translateX(6px); }
}

/* BPM Slider */
.pb-bpm-slider {
  width: 100%;
  height: 10px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(0,0,0,0.08);
  border-radius: 5px;
  outline: none;
}

.pb-bpm-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-round);
  background: #AA00FF;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(170,0,255,0.4);
  border: 3px solid white;
  transition: transform 0.15s var(--ease-bounce);
}

.pb-bpm-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.pb-bpm-slider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-round);
  background: #AA00FF;
  cursor: pointer;
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(170,0,255,0.4);
}

/* ─── Color Palette Swatches ────────────────────────────────────── */

.pb-palettes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.pb-palette-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  background: var(--swatch-color, #ccc);
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s var(--ease-bounce);
  box-shadow: 0 3px 0 color-mix(in srgb, var(--swatch-color, #ccc) 50%, black);
}

.pb-palette-swatch:hover {
  transform: translateY(-3px) scale(1.1);
  box-shadow: 0 6px 0 color-mix(in srgb, var(--swatch-color, #ccc) 50%, black),
              0 8px 16px color-mix(in srgb, var(--swatch-color, #ccc) 30%, transparent);
}

.pb-palette-swatch:active {
  transform: translateY(1px) scale(0.95);
}

.pb-palette-swatch.selected {
  border-color: white;
  outline: 3px solid var(--swatch-color, #ccc);
  outline-offset: 2px;
  transform: translateY(-2px) scale(1.08);
}

/* ─── Character Grid ────────────────────────────────────────────── */

.pb-char-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.pb-char-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  border-radius: var(--radius-md);
  border: 2px solid rgba(0,0,0,0.07);
  cursor: pointer;
  transition: all 0.2s var(--ease-bounce);
  filter: grayscale(0.8) opacity(0.45);
  background: rgba(0,0,0,0.02);
}

.pb-char-item.active {
  filter: none;
  border-color: #AA00FF;
  background: rgba(170,0,255,0.06);
  box-shadow: 0 2px 8px rgba(170,0,255,0.15);
}

.pb-char-item:hover {
  transform: scale(1.08) translateY(-2px);
  filter: grayscale(0.3) opacity(0.75);
}

.pb-char-item.active:hover {
  filter: none;
  transform: scale(1.08) translateY(-2px);
}

.pb-char-item img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  display: block;
}

.pb-char-name {
  font-size: 0.58rem;
  font-weight: 800;
  color: var(--text-secondary);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
}

/* ─── Save bottom button ────────────────────────────────────────── */

.pb-save-bottom-btn {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 3px solid #7B00CC;
  background: #AA00FF;
  color: white;
  font-family: 'Lilita One', cursive;
  font-size: 1.1rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.2s var(--ease-bounce);
  box-shadow: 0 5px 0 #7B00CC;
  margin-top: 8px;
}

.pb-save-bottom-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 0 #7B00CC;
}

.pb-save-bottom-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #7B00CC;
}

/* ─── Custom Pack Cards on Project Selector ─────────────────────── */

.custom-pack-card {
  position: relative;
  text-align: left;
  padding: 20px 18px 16px;
}

.custom-pack-header {
  margin-bottom: 14px;
}

.custom-pack-name {
  font-family: 'Lilita One', cursive;
  font-size: 1.2rem;
  color: var(--text-primary);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.custom-pack-by {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.custom-pack-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  color: white;
  background: var(--accent, #AA00FF);
  padding: 3px 10px;
  border-radius: 12px;
  display: inline-block;
}

.custom-pack-actions {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.2s;
}

.custom-pack-card:hover .custom-pack-actions {
  opacity: 1;
}

.custom-pack-play-btn,
.custom-pack-edit-btn,
.custom-pack-delete-btn {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-family: 'Nunito', sans-serif;
  font-size: 0.78rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.12s var(--ease-bounce), opacity 0.12s;
  border: 2px solid;
}

.custom-pack-play-btn   { background: #00C853; border-color: #00A843; color: white; }
.custom-pack-edit-btn   { background: white; border-color: #2979FF; color: #2979FF; }
.custom-pack-delete-btn { background: white; border-color: #e0e0e0; color: #aaa; }

.custom-pack-play-btn:hover   { transform: scale(1.08); }
.custom-pack-edit-btn:hover   { background: #e8f0ff; transform: scale(1.08); }
.custom-pack-delete-btn:hover { border-color: #FF3B6F; color: #FF3B6F; transform: scale(1.08); }

/* ─── "New Pack" card on Project Selector ───────────────────────── */

.new-pack-card {
  border-style: dashed;
  border-color: rgba(170,0,255,0.35);
  background: rgba(170,0,255,0.03);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
}

.new-pack-card:hover {
  border-color: #AA00FF;
  background: rgba(170,0,255,0.07);
}

.new-pack-icon {
  font-size: 2.5rem;
  animation: iconWiggle 3s ease-in-out infinite;
}

.new-pack-title {
  font-family: 'Lilita One', cursive;
  font-size: 1.2rem;
  color: #AA00FF;
}

.new-pack-sub {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
}

/* ─── Profile Modal ─────────────────────────────────────────────── */

.profile-modal {
  position: fixed;
  inset: 0;
  z-index: 350;
  background: rgba(20, 15, 35, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.3s;
}

.profile-modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.profile-content {
  background: white;
  border-radius: var(--radius-xl);
  padding: 36px 40px 40px;
  max-width: 400px;
  width: 92%;
  text-align: center;
  box-shadow: var(--shadow-toy-hover);
  animation: modalPop 0.4s var(--ease-bounce);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.profile-emoji {
  font-size: 3rem;
  line-height: 1;
}

.profile-content h2 {
  font-family: 'Lilita One', cursive;
  font-size: 1.8rem;
  color: #AA00FF;
}

.profile-content p {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-top: -4px;
}

.profile-name-input {
  width: 100%;
  padding: 13px 18px;
  border-radius: var(--radius-lg);
  border: 3px solid rgba(0,0,0,0.1);
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
  outline: none;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.profile-name-input:focus {
  border-color: #AA00FF;
  box-shadow: 0 0 0 3px rgba(170,0,255,0.15);
}

.profile-name-input::placeholder {
  color: #c0c8d0;
  font-weight: 600;
}

.profile-save-btn {
  width: 100%;
  padding: 13px 20px;
  border-radius: var(--radius-lg);
  border: 3px solid #7B00CC;
  background: #AA00FF;
  color: white;
  font-family: 'Lilita One', cursive;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s var(--ease-bounce);
  box-shadow: 0 5px 0 #7B00CC;
}

.profile-save-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 0 #7B00CC;
}

.profile-save-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #7B00CC;
}

.profile-skip-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.15s;
}

.profile-skip-btn:hover {
  color: #AA00FF;
}

/* ─── Responsive — Pack Builder ─────────────────────────────────── */

@media (max-width: 900px) {
  .pb-layout {
    grid-template-columns: 240px 1fr 260px;
  }
}

@media (max-width: 768px) {
  .pb-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    overflow-y: auto;
  }

  .pb-panel {
    height: auto;
    min-height: 300px;
  }

  .pb-panel-browse {
    border-right: none;
    border-bottom: 2px solid rgba(0,0,0,0.07);
  }

  .pb-panel-canvas {
    border-right: none;
    border-bottom: 2px solid rgba(0,0,0,0.07);
  }

  .pb-char-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .pb-palettes {
    grid-template-columns: repeat(4, 1fr);
  }

  .pb-toolbar-title { font-size: 1.1rem; }
  .pb-back          { padding: 7px 12px; font-size: 0.82rem; }
  .pb-save-top-btn  { padding: 7px 12px; font-size: 0.82rem; }
}

/* ════════════════════════════════════════════════════════════════════
   Phase 4: Progression System
   ════════════════════════════════════════════════════════════════════ */

/* ── Locked Feature State ─────────────────────────────────────────── */

.feature-btn {
  position: relative;
  transition: opacity 0.2s, filter 0.2s;
  cursor: pointer;
}

.feature-btn.locked {
  opacity: 0.45;
  filter: grayscale(0.8);
  cursor: not-allowed;
}

.feature-btn.locked::after {
  content: '🔒';
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 0.75rem;
  line-height: 1;
  pointer-events: none;
}

/* ── Combo Burst — active characters explode on combo discover ─────── */

@keyframes combo-burst {
  0%   { transform: scale(1);    filter: brightness(1);   }
  20%  { transform: scale(1.18); filter: brightness(2.5) saturate(2); }
  50%  { transform: scale(0.94); filter: brightness(1.8); }
  75%  { transform: scale(1.10); filter: brightness(2) saturate(1.5); }
  100% { transform: scale(1);    filter: brightness(1);   }
}

.character.combo-burst {
  animation: combo-burst 1s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* ── Combo Celebration Modal ──────────────────────────────────────── */

.combo-celebration {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.combo-celebration.hidden {
  display: none;
}

.combo-celebration.active {
  opacity: 1;
  pointer-events: auto;
}

.combo-celebration-card {
  --combo-accent: #00e5ff;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 48px 36px;
  max-width: 420px;
  width: calc(100% - 48px);
  background: linear-gradient(160deg, #0f0f1a 0%, #1a1230 60%, #0f0f1a 100%);
  border: 2px solid var(--combo-accent);
  border-radius: 24px;
  box-shadow:
    0 0 40px var(--combo-accent),
    0 0 80px color-mix(in srgb, var(--combo-accent) 40%, transparent),
    0 24px 64px rgba(0, 0, 0, 0.8);
  text-align: center;
  /* Card entrance animation */
  animation: combo-card-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes combo-card-in {
  from { transform: scale(0.7) translateY(30px); opacity: 0; }
  to   { transform: scale(1)   translateY(0);    opacity: 1; }
}

.combo-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  color: var(--combo-accent);
  text-transform: uppercase;
  border: 1px solid var(--combo-accent);
  border-radius: 100px;
  padding: 4px 16px;
  animation: combo-badge-pulse 1.8s ease-in-out infinite;
}

@keyframes combo-badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--combo-accent) 50%, transparent); }
  50%       { box-shadow: 0 0 0 8px transparent; }
}

.combo-emoji {
  font-size: 4.5rem;
  line-height: 1;
  animation: combo-emoji-bounce 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.5));
}

@keyframes combo-emoji-bounce {
  from { transform: scale(0) rotate(-20deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg);   opacity: 1; }
}

.combo-name {
  font-family: 'Lilita One', cursive;
  font-size: 2rem;
  line-height: 1.1;
  color: #fff;
  text-shadow:
    0 0 20px var(--combo-accent),
    0 2px 4px rgba(0, 0, 0, 0.8);
  animation: combo-name-slide 0.4s ease 0.2s both;
}

@keyframes combo-name-slide {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.combo-description {
  font-family: 'Nunito', sans-serif;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.7);
  max-width: 300px;
  line-height: 1.5;
  animation: combo-name-slide 0.4s ease 0.3s both;
}

/* Unlock banner — shown when a tier is just triggered */
.combo-unlock-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 14px 20px;
  background: linear-gradient(135deg,
    rgba(255, 215, 0, 0.15) 0%,
    rgba(255, 165, 0, 0.1) 100%);
  border: 1px solid rgba(255, 215, 0, 0.5);
  border-radius: 12px;
  width: 100%;
  animation: combo-name-slide 0.4s ease 0.35s both;
}

.combo-unlock-wrap.hidden {
  display: none;
}

.combo-unlock-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: #ffd700;
  text-transform: uppercase;
}

.combo-unlock-names {
  font-family: 'Nunito', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
}

.combo-dismiss-btn {
  margin-top: 8px;
  padding: 14px 36px;
  font-family: 'Lilita One', cursive;
  font-size: 1.1rem;
  color: #0f0f1a;
  background: var(--combo-accent);
  border: none;
  border-radius: 100px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow:
    0 4px 16px color-mix(in srgb, var(--combo-accent) 60%, transparent),
    0 0 0 0 var(--combo-accent);
  animation:
    combo-name-slide 0.4s ease 0.4s both,
    combo-dismiss-pulse 2s ease-in-out 1s infinite;
}

@keyframes combo-dismiss-pulse {
  0%, 100% { box-shadow: 0 4px 16px color-mix(in srgb, var(--combo-accent) 60%, transparent), 0 0 0 0 color-mix(in srgb, var(--combo-accent) 50%, transparent); }
  50%       { box-shadow: 0 4px 16px color-mix(in srgb, var(--combo-accent) 60%, transparent), 0 0 0 10px transparent; }
}

.combo-dismiss-btn:hover {
  transform: scale(1.04);
  box-shadow: 0 6px 24px color-mix(in srgb, var(--combo-accent) 80%, transparent);
}

.combo-dismiss-btn:active {
  transform: scale(0.97);
}

/* ═══════════════════════════════════════════════════════════════════
   STEP SEQUENCER — Phase 4.3
   ═══════════════════════════════════════════════════════════════════ */

/* ─── SEQ toolbar button ─────────────────────────────────────────── */

#seq-btn {
  padding: 8px 11px;
  border-radius: var(--radius-md);
  border: 3px solid var(--color-melody);
  background: white;
  color: var(--color-melody);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.12s var(--ease-bounce);
  box-shadow: 0 3px 0 rgba(0,150,136,0.25);
  flex-shrink: 0;
}

#seq-btn:hover {
  background: color-mix(in srgb, var(--color-melody) 10%, white);
}

#seq-btn.active {
  background: var(--color-melody);
  color: white;
  box-shadow: 0 1px 0 rgba(0,150,136,0.4), 0 0 0 3px color-mix(in srgb, var(--color-melody) 30%, transparent);
}

#seq-btn:active {
  transform: scale(0.93) translateY(2px);
  box-shadow: 0 1px 0 rgba(0,150,136,0.25);
}

/* ─── Panel container ────────────────────────────────────────────── */

.sequencer-panel {
  width: 100%;
  background: rgba(20, 20, 36, 0.97);
  border-top: 2px solid rgba(0,150,136,0.4);
  border-bottom: 2px solid rgba(0,0,0,0.2);
  padding: 0 0 10px 0;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: hidden;
  /* Animation */
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              opacity    0.25s ease,
              padding    0.3s ease;
}

.seq-hidden {
  display: none;
}

.seq-visible {
  display: block;
}

/* ─── Header row ─────────────────────────────────────────────────── */

.seq-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px 4px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.seq-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--color-melody);
  text-transform: uppercase;
  opacity: 0.9;
}

.seq-close-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}

.seq-close-btn:hover {
  color: white;
  background: rgba(255,255,255,0.1);
}

/* ─── Beat column markers (1 2 3 4) ─────────────────────────────── */

.seq-col-markers {
  display: flex;
  align-items: center;
  /* left: seq-rows padding (16px) + label width (82px) + gap (6px)
     right: seq-rows padding (16px) + reset btn (26px) + gap (6px) = 48px */
  padding: 3px 48px 1px calc(16px + 82px + 6px);
  gap: 0;
  pointer-events: none;
  min-width: 540px; /* must match .seq-rows so markers stay aligned when panel scrolls horizontally */
}

.seq-col-marker {
  flex: 1; /* each beat spans equal width */
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.55rem;
  color: rgba(255,255,255,0.25);
  letter-spacing: 0.1em;
  user-select: none;
  padding-left: 2px;
}

/* ─── Rows container ─────────────────────────────────────────────── */

.seq-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 16px 0 16px;
  min-width: 540px; /* prevent squishing on small screens */
}

.seq-empty {
  color: rgba(255,255,255,0.3);
  font-size: 0.8rem;
  font-family: 'Nunito', sans-serif;
  padding: 12px 4px;
  text-align: center;
}

/* ─── Individual row ─────────────────────────────────────────────── */

.seq-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
}

.seq-row-muted {
  opacity: 0.4;
}

/* ─── Row label ──────────────────────────────────────────────────── */

.seq-row-label {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 82px;
  min-width: 0;
  overflow: hidden;
}

.seq-row-icon {
  font-size: 1rem;
  flex-shrink: 0;
  line-height: 1;
}

.seq-row-name {
  font-family: 'Nunito', sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ─── Sample badge (non-pattern sounds) ─────────────────────────── */

.seq-row-sample-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: rgba(255,255,255,0.2);
  text-transform: uppercase;
  padding: 2px 8px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 100px;
  flex-shrink: 0;
}

/* ─── Steps area ─────────────────────────────────────────────────── */

.seq-steps {
  display: flex;
  gap: 2px;
  flex: 1;
}

/* ─── Individual step buttons ────────────────────────────────────── */

.seq-step {
  flex: 1;
  height: 28px;
  min-width: 0;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: background 0.08s ease, border-color 0.08s ease, transform 0.06s ease;
  padding: 0;
  position: relative;
}

.seq-step:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

.seq-step:active {
  transform: scale(0.88);
}

/* Downbeat divider: slightly brighter left border every 4 steps */
.seq-step.seq-step-downbeat {
  border-left-color: rgba(255, 255, 255, 0.22);
  margin-left: 3px; /* visual gap between beat groups */
}

.seq-step.seq-step-downbeat:first-child {
  margin-left: 0;
}

/* ON: step is active — use melody color */
.seq-step.seq-step-on {
  background: var(--color-melody);
  border-color: color-mix(in srgb, var(--color-melody) 80%, white);
  box-shadow: 0 0 6px color-mix(in srgb, var(--color-melody) 50%, transparent);
}

.seq-step.seq-step-on:hover {
  background: color-mix(in srgb, var(--color-melody) 80%, white);
}

/* Modified: differs from original project pattern — show accent dot */
.seq-step.seq-step-modified::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--color-vocals);
  opacity: 0.9;
}

/* Playing: current transport step highlight */
.seq-step.seq-step-playing {
  border-color: rgba(255, 255, 255, 0.7) !important;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}

.seq-step.seq-step-on.seq-step-playing {
  background: color-mix(in srgb, var(--color-melody) 60%, white) !important;
  border-color: white !important;
  box-shadow: 0 0 12px white, 0 0 6px var(--color-melody);
}

/* ─── Reset button ───────────────────────────────────────────────── */

.seq-row-reset {
  background: none;
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  color: rgba(255,255,255,0.35);
  font-size: 0.9rem;
  width: 26px;
  height: 26px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.seq-row-reset:hover {
  color: var(--color-vocals);
  border-color: var(--color-vocals);
  background: rgba(255,179,0,0.1);
}

.seq-row-reset:active {
  transform: scale(0.88);
}

/* ─── Responsive tweaks ──────────────────────────────────────────── */

@media (max-width: 600px) {
  .seq-rows { min-width: 480px; }
  .seq-col-markers { min-width: 480px; padding-left: calc(16px + 64px + 6px); }
  .seq-step { height: 24px; }
  .seq-row-label { flex: 0 0 64px; }
  .seq-row-icon { font-size: 0.85rem; }
}

/* Hide SEQ button on very narrow screens where transport is already hidden */
@media (max-width: 400px) {
  #seq-btn { display: none !important; }
}
