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

html, body {
  background: #000;
  overflow: hidden;
}

/* Cards section */
.cards-section {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
}

/* Cards container */
.cards-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 40px;
  z-index: 2;
  position: relative;
}

/* Individual card */
.card {
  width: 220px;
  height: 300px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 24px;
  transition: transform 0.3s ease;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  /* Fix Safari border-radius clipping during transforms */
  -webkit-mask-image: -webkit-radial-gradient(white, black);
  mask-image: radial-gradient(white, black);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transform: translateZ(0);
  box-shadow: 0 3px 0 0 rgba(0,0,0,1);
}

.card:hover {
  transform: translateY(-12px) scale(1.02);
}

.card:hover .card-image {
  transform: scale(1.08);
}

/* Card background image */
.card-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  transition: transform 0.4s ease;
  z-index: 0;
}

/* Shader canvas - replaces card image */
.shader-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
}

/* ASCII text overlay on shader */
.ascii-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  margin: 0;
  padding: 4px;
  font-family: 'Courier New', monospace;
  font-size: 5.5px;
  line-height: 1.0;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.25);
  pointer-events: none;
  overflow: hidden;
  white-space: pre;
  mix-blend-mode: screen;
}

/* Card gradient overlay */
.card-gradient {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60%;
  z-index: 1;
  pointer-events: none;
}

/* Disable transitions during GSAP animations */
.card.no-transition {
  transition: none !important;
}

/* Dark overlay on images */
.card-image::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.35);
}

/* Active glow overlay - lights up card from bottom when playing */
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  mix-blend-mode: soft-light;
}

.card.active-glow::before {
  opacity: 1;
}

.card-green::before {
  background: none;
}

.card-yellow::before {
  background: none;
}

.card-red::before {
  background: linear-gradient(to top, rgba(255, 255, 255, 0.9) 0%, rgba(255, 107, 107, 0.5) 25%, transparent 55%);
}

/* Card colors - gradient overlays */
.card-green .card-gradient {
  background: none;
}

.card-yellow .card-gradient {
  background: none;
}

.card-red .card-gradient {
  background: linear-gradient(to top, rgba(255, 107, 107, 0.7) 0%, rgba(255, 107, 107, 0.5) 10%, transparent 60%);
}

@font-face {
  font-family: 'GeistPixelSquare';
  src: url('assets/GeistPixel-Square.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

.card-label {
  position: absolute;
  top: 14px;
  left: 16px;
  font-family: 'GeistPixelSquare', monospace;
  font-size: 14px;
  font-weight: normal;
  color: rgba(255, 255, 255, 0.95);
  z-index: 2;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Slot container - top position set by JS for responsiveness */
.slot-container {
  opacity: 0;
  position: fixed;
  top: 100%;
  left: 0;
  width: 100%;
  height: 0;
  overflow: visible;
}

/* Single slot bar - fully rounded */
.slot-bar {
  width: 240px;
  height: 8px;
  position: absolute;
  left: 50%;
  margin-left: -120px;
  top: 0;
  background: #0a0a0a;
  border-radius: 4px;
  z-index: 6;
}

/* Gradient slot bar - always visible */
.slot-bar-gradient {
  width: 240px;
  height: 8px;
  position: absolute;
  left: 50%;
  margin-left: -120px;
  top: 0;
  background: linear-gradient(to right, #aaa 0%, #d9d9d9 3.4%, #d9d9d9 50%, #d9d9d9 98%, #aaa 100%);
  border-radius: 4px;
  z-index: 7;
}

/* Glow emanating from slot - behind card, beam shape with progressive blur */
.slot-glow {
  position: fixed;
  width: 343px;
  height: 119px;
  left: 50%;
  margin-left: -171.5px;
  top: 0; /* Set dynamically by JS */
  opacity: 0;
  pointer-events: none;
  z-index: 1; /* Behind everything except white background */
  visibility: hidden;
  --glow-opacity: 1;
  color: var(--glow-color, #a8e6cf);
}

/* Base glow layer styles - SVG */
.glow-layer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: auto;
  overflow: visible;
}

/* Bottom layer - heavy blur (50px), visible at bottom */
.glow-layer-blur {
  filter: blur(40px);
  opacity: calc(1 * var(--glow-opacity, 1));
  -webkit-mask-image: linear-gradient(to top, white 0%, white 50%, transparent 80%);
  mask-image: linear-gradient(to top, white 0%, white 50%, transparent 80%);
}

/* Middle layer - medium blur (25px), visible in middle */
.glow-layer-mid {
  filter: blur(20px);
  opacity: calc(0.8 * var(--glow-opacity, 1));
  -webkit-mask-image: linear-gradient(to top, transparent 10%, white 30%, white 70%, transparent 90%);
  mask-image: linear-gradient(to top, transparent 10%, white 30%, white 70%, transparent 90%);
}

/* Top layer - light blur (8px), fades out at top */
.glow-layer-sharp {
  filter: blur(8px);
  opacity: calc(0.5 * var(--glow-opacity, 1));
  -webkit-mask-image: linear-gradient(to top, transparent 30%, white 50%, transparent 85%);
  mask-image: linear-gradient(to top, transparent 30%, white 50%, transparent 85%);
}

.slot-glow.visible {
  opacity: 1;
  visibility: visible;
  display: none; /* TEMP: hidden for testing */
}

/* Glow colors */
.slot-glow.glow-green {
  --glow-color: #4ade80;
}

.slot-glow.glow-yellow {
  --glow-color: #facc15;
}

.slot-glow.glow-red {
  --glow-color: #f87171;
}

/* The void below - full width white mask, top position set by JS */
.slot-void {
  width: 100vw;
  height: 100vh;
  background: #fff;
  position: fixed;
  top: 100%;
  left: 0;
  z-index: 4;
}

/* Card when inserting - fixed position to escape stacking context */
.card.inserting {
  position: fixed;
  z-index: 3;
  /* Reinforce border-radius during animation on Safari/iOS */
  -webkit-mask-image: -webkit-radial-gradient(white, black);
  mask-image: radial-gradient(white, black);
  will-change: transform, top, left;
}

/* Card with no shadow when inserted */
.card.inserting {
  box-shadow: none !important;
}

/* Card at top position after insertion - raise above void */
.card.inserted {
  z-index: 7;
}

/* Anime speed lines - top position set by JS */
.speed-lines {
  position: fixed;
  top: 100%;
  left: 50%;
  margin-left: -120px;
  width: 240px;
  height: 4px;
  z-index: 7;
  pointer-events: none;
}

.speed-line {
  position: absolute;
  top: 0;
  width: 80px;
  height: 3px;
  background: transparent;
  overflow: hidden;
}

.speed-line.left {
  right: 100%;
  margin-right: 2px;
}

.speed-line.left.top {
  transform: rotate(-12deg);
  transform-origin: right center;
}

.speed-line.left.bottom {
  transform: rotate(12deg);
  transform-origin: right center;
}

.speed-line.right {
  left: 100%;
  margin-left: 2px;
}

.speed-line.right.top {
  transform: rotate(12deg);
  transform-origin: left center;
}

.speed-line.right.bottom {
  transform: rotate(-12deg);
  transform-origin: left center;
}

/* The moving segment inside the line */
.speed-line::after {
  content: '';
  position: absolute;
  top: 0;
  height: 100%;
  width: 25px;
  border-radius: 2px;
}

.speed-line.left::after {
  right: -25px;
  background: linear-gradient(to left, transparent 0%, #0a0a0a 40%, #0a0a0a 60%, transparent 100%);
}

.speed-line.right::after {
  left: -25px;
  background: linear-gradient(to right, transparent 0%, #0a0a0a 40%, #0a0a0a 60%, transparent 100%);
}

/* Animation - segment shoots outward */
@keyframes speedLineTravelLeft {
  0% {
    right: -25px;
    opacity: 1;
  }
  100% {
    right: 80px;
    opacity: 0;
  }
}

@keyframes speedLineTravelRight {
  0% {
    left: -25px;
    opacity: 1;
  }
  100% {
    left: 80px;
    opacity: 0;
  }
}

.speed-lines.active .speed-line.left::after {
  animation: speedLineTravelLeft 0.25s ease-out forwards;
}

.speed-lines.active .speed-line.right::after {
  animation: speedLineTravelRight 0.25s ease-out forwards;
}

/* Back button */
.back-button {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 20;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 10px;
  font-size: 24px;
  color: #333;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: background 0.2s ease, opacity 0.3s ease, visibility 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.back-button:hover {
  background: rgba(0, 0, 0, 0.08);
}

.back-button.visible {
  opacity: 1;
  visibility: visible;
}

/* Mute button */
.mute-button {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 20;
  height: 40px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 10px;
  opacity: 0;
  visibility: hidden;
  transition: background 0.2s ease, opacity 0.3s ease, visibility 0.3s ease, width 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
  width: 40px;
  -webkit-tap-highlight-color: transparent;
}

.mute-button:hover {
  background: rgba(0, 0, 0, 0.08);
}

.mute-button.visible {
  opacity: 1;
  visibility: visible;
}

/* Mute toggle button inside container */
.mute-toggle {
  width: 100%;
  height: 100%;
  min-width: 40px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 10px;
  font-size: 24px;
  color: #333 !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.mute-toggle:hover {
  background: transparent;
}

.mute-toggle i {
  color: inherit;
}

.mute-button .mute-icon-off {
  display: none;
}

.mute-button.muted .mute-icon-on {
  display: none;
}

.mute-button.muted .mute-icon-off {
  display: block;
}

.mute-button.muted .mute-toggle {
  color: #e53935;
}

/* Volume slider */
.volume-slider {
  --volume: 100;
  width: 0;
  height: 4px;
  margin: 0 8px 0 0;
  opacity: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(
    to right,
    #333 0%,
    #333 calc(var(--volume) * 1%),
    rgba(0, 0, 0, 0.15) calc(var(--volume) * 1%),
    rgba(0, 0, 0, 0.15) 100%
  );
  border-radius: 2px;
  transition: width 0.25s ease, opacity 0.25s ease;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: #333;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #333;
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

.volume-slider::-moz-range-track {
  height: 4px;
  background: linear-gradient(
    to right,
    #333 0%,
    #333 calc(var(--volume) * 1%),
    rgba(0, 0, 0, 0.15) calc(var(--volume) * 1%),
    rgba(0, 0, 0, 0.15) 100%
  );
  border-radius: 2px;
}

/* Desktop hover: expand to show slider */
@media (hover: hover) and (pointer: fine) {
  .mute-button:hover {
    width: 140px;
  }
  
  .mute-button:hover .volume-slider {
    width: 80px;
    opacity: 1;
  }
}

/* Music visualizer - positioned inside the selected card */
.visualizer {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.visualizer.visible {
  opacity: 1;
  visibility: visible;
}

.visualizer-bar {
  width: 3px;
  height: 16px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 1.5px;
  transform-origin: center;
  transition: transform 0.05s ease-out, background 0.2s ease;
}

.visualizer.muted .visualizer-bar {
  background: rgba(239, 68, 68, 0.9);
}

/* Game content area */
.game-content {
  position: fixed;
  top: 100px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  background: #89CFF0;
  overflow: hidden;
  cursor: grab;
}
.game-content:active {
  cursor: grabbing;
}

.game-content.visible {
  opacity: 1;
  visibility: visible;
}

/* Game canvas fills the game content area */
#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

/* Touch-friendly active states (fallback for hover) */
@media (hover: none) {
  .card:active {
    transform: translateY(-6px) scale(1.01);
  }

  .card:hover {
    transform: none;
  }

  .back-button:active {
    background: #e8e8e8;
  }
}

/* Tablet and below */
@media (max-width: 768px) {
  .cards-container {
    gap: 24px;
  }

  .card {
    width: 200px;
    height: 270px;
  }

  .slot-bar,
  .slot-bar-gradient {
    width: 210px;
    margin-left: -105px;
  }

  .speed-lines {
    width: 210px;
    margin-left: -105px;
  }




  .card-label {
    font-size: 12px;
    top: 12px;
    left: 14px;
  }

  .back-button {
    padding: 12px 20px;
    font-size: 16px;
  }
}

/* Mobile phones */
@media (max-width: 600px) {
  .cards-container {
    flex-direction: row;
    gap: 16px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 20px 40px;
    width: 100%;
    justify-content: flex-start;
  }

  /* Hide scrollbar but keep functionality */
  .cards-container::-webkit-scrollbar {
    display: none;
  }
  .cards-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }

  /* When inserting, allow card to escape container clipping */
  .cards-container.card-inserting {
    overflow: visible;
  }

  .card {
    flex-shrink: 0;
    scroll-snap-align: center;
    width: 195px;
    height: 260px;
  }




  .card-label {
    font-size: 12px;
  }

  .card {
    padding-bottom: 20px;
  }

  /* Narrower slot for mobile */
  .slot-bar,
  .slot-bar-gradient {
    width: 210px;
    margin-left: -105px;
  }

  .speed-lines {
    width: 210px;
    margin-left: -105px;
  }

  .back-button {
    top: 12px;
    left: 12px;
    width: 44px;
    height: 44px;
  }

  .mute-button {
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    justify-content: center;
    transition: width 0.25s ease, background 0.2s ease;
  }

  .mute-button.expanded {
    width: 160px;
    justify-content: flex-start;
    background: rgba(255, 255, 255, 0.85);
  }

  .mute-toggle {
    min-width: 44px;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
  }

  .volume-slider {
    width: 0;
    opacity: 0;
    margin: 0;
    pointer-events: none;
    transition: width 0.25s ease, opacity 0.25s ease, margin 0.25s ease;
  }

  .mute-button.expanded .volume-slider {
    width: 90px;
    opacity: 1;
    margin: 0 12px 0 0;
    pointer-events: auto;
  }

  .game-content {
    top: 80px;
  }
}

/* Small phones */
@media (max-width: 380px) {
  .cards-container {
    padding: 20px 30px;
    gap: 12px;
  }

  .card {
    width: 175px;
    height: 230px;
    padding-bottom: 18px;
  }

  .slot-bar,
  .slot-bar-gradient {
    width: 190px;
    margin-left: -95px;
  }

  .speed-lines {
    width: 190px;
    margin-left: -95px;
  }




  .card-label {
    font-size: 11px;
    top: 10px;
    left: 12px;
  }
}

/* Landscape phone orientation */
@media (max-height: 500px) and (orientation: landscape) {
  .cards-container {
    gap: 16px;
    padding: 10px 40px;
  }

  .card {
    width: 140px;
    height: 180px;
    padding-bottom: 14px;
  }

  .slot-bar,
  .slot-bar-gradient {
    width: 160px;
    margin-left: -80px;
  }

  .speed-lines {
    width: 160px;
    margin-left: -80px;
  }




  .card-label {
    font-size: 10px;
    top: 8px;
    left: 10px;
  }

  .game-content {
    top: 60px;
  }
}

/* ============================================
   PIANO ROLL / MIDI EDITOR
   ============================================ */

.piano-roll {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, #0f0f1a 0%, #1a1a2e 100%);
  z-index: 100;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.piano-roll.visible {
  display: flex;
}

/* Top 1/3 - 3D visualizer */
.piano-roll-visualizer {
  flex: 0 0 30%;
  min-height: 150px;
  position: relative;
  background: radial-gradient(ellipse at center, rgba(255, 107, 107, 0.15) 0%, rgba(255, 80, 80, 0.05) 40%, transparent 70%);
}

.piano-roll-visualizer::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(255, 107, 107, 0.3) 0%, transparent 70%);
  pointer-events: none;
  animation: visualizerGlow 2s ease-in-out infinite;
}

@keyframes visualizerGlow {
  0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.8; transform: translate(-50%, -50%) scale(1.1); }
}

#piano-roll-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Bottom 2/3 - editor */
.piano-roll-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 24px 24px 0 0;
  margin-top: -20px;
  position: relative;
  z-index: 1;
}

.piano-roll-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: transparent;
  flex-shrink: 0;
}

.piano-roll-title {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: white;
  letter-spacing: -0.3px;
}

.piano-roll-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.piano-roll-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

/* Piano roll controls bar - Apple-style clean toolbar */
.piano-roll-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: transparent;
  flex-shrink: 0;
}

/* Transport controls (play, etc) - centered pill */
.transport-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 4px;
}

.piano-roll-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 16px;
  padding: 10px 14px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
}

.piano-roll-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.piano-roll-btn:active {
  transform: scale(0.95);
}

.piano-roll-btn.primary {
  background: #ff6b6b;
  color: white;
}

.piano-roll-btn.primary:hover {
  background: #ff8080;
}

/* Tempo control - minimal */
.piano-roll-tempo-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 8px 14px;
}

.piano-roll-label {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  font-weight: 500;
}

.piano-roll-tempo-val {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: white;
  min-width: 32px;
}

#piano-roll-tempo {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  cursor: pointer;
}

#piano-roll-tempo::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

#piano-roll-tempo::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

#piano-roll-tempo::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* Length controls - pill style */
.piano-roll-length-wrap {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 4px;
}

.piano-roll-length-val {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: white;
  min-width: 28px;
  text-align: center;
  padding: 0 4px;
}

.piano-roll-btn-sm {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 18px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.piano-roll-btn-sm:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.piano-roll-secondary {
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
}

.piano-roll-secondary:hover {
  color: rgba(255, 255, 255, 0.9);
}

.piano-roll-clear {
  color: #ff6b6b;
  font-size: 13px;
  font-weight: 500;
}

.piano-roll-grid {
  display: grid;
  gap: 2px;
  padding: 0 12px 12px;
  overflow-y: auto;
  flex: 1;
}

/* Step number header row - minimal */
.step-number {
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 8px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.25);
  user-select: none;
}

.step-number.beat-start {
  color: rgba(255, 255, 255, 0.5);
}

.header-spacer {
  height: 16px;
  background: transparent;
}

/* Piano key labels on left - cleaner */
.piano-roll-row {
  display: contents;
}

.piano-key {
  width: 36px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 9px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.4);
  background: transparent;
  border-radius: 6px 0 0 6px;
  transition: all 0.15s ease;
  user-select: none;
  cursor: pointer;
}

.piano-key:hover {
  color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.05);
}

.piano-key:active {
  background: rgba(255, 107, 107, 0.2);
}

.piano-key.sharp {
  color: rgba(255, 255, 255, 0.3);
}

.piano-key.sharp:hover {
  color: rgba(255, 255, 255, 0.7);
}

/* Note cells - tight */
.note-cell {
  height: 20px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.note-cell:hover {
  background: rgba(255, 255, 255, 0.08);
}

.note-cell.active {
  background: linear-gradient(135deg, #ff6b6b 0%, #e85d5d 100%);
  box-shadow: 0 1px 8px rgba(255, 107, 107, 0.4);
  border-radius: 3px;
  animation: notePopIn 0.15s ease-out;
}

.note-cell.active:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(255, 107, 107, 0.5);
}

@keyframes notePopIn {
  0% { transform: scale(0.8); opacity: 0.5; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* Slide/bend indicator - glowing curve */
.note-cell.active.slide {
  position: relative;
  overflow: visible;
}

.note-cell.active.slide::after {
  content: '';
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background: linear-gradient(135deg, transparent 40%, currentColor 50%, transparent 60%);
  border-radius: 0 50% 50% 0;
  opacity: 0.9;
  z-index: 10;
  animation: slidePulse 0.8s ease-in-out infinite;
}

.note-cell.active.slide::before {
  content: '~';
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  font-weight: bold;
  color: white;
  text-shadow: 0 0 8px currentColor;
  z-index: 11;
}

@keyframes slidePulse {
  0%, 100% { opacity: 0.7; transform: translateY(-50%) scale(1); }
  50% { opacity: 1; transform: translateY(-50%) scale(1.2); }
}

/* Playhead indicator - animated glow */
.note-cell.playhead {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5);
  animation: playheadPulse 0.3s ease-out;
}

.note-cell.playhead.active {
  box-shadow: 0 0 20px rgba(255, 107, 107, 0.7);
  transform: scale(1.1);
  animation: playheadActive 0.15s ease-out;
}

@keyframes playheadPulse {
  0% { box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.8); }
  100% { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5); }
}

@keyframes playheadActive {
  0% { transform: scale(1.2); box-shadow: 0 0 30px rgba(255, 107, 107, 0.9); }
  100% { transform: scale(1.1); box-shadow: 0 0 20px rgba(255, 107, 107, 0.7); }
}

/* Beat markers (every 4th column) */
.note-cell.beat-start {
  border-left: 1px solid rgba(255, 255, 255, 0.15);
}

/* Footer with mutes - pill toggles */
.piano-roll-footer {
  padding: 16px 20px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.piano-roll-mutes {
  display: flex;
  gap: 8px;
}

.piano-roll .mute-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8) !important;
  user-select: none;
  background: rgba(255, 255, 255, 0.08);
  padding: 8px 14px;
  border-radius: 20px;
  transition: all 0.2s ease;
  width: auto;
  height: auto;
  min-width: unset;
  border: none;
}

.piano-roll .mute-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
}

.piano-roll .mute-toggle input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  background: rgba(255, 255, 255, 0.2);
  transition: all 0.15s ease;
}

.piano-roll .mute-toggle input[type="checkbox"]:checked {
  background: #ff6b6b;
}

.piano-roll .mute-toggle.bass-toggle input[type="checkbox"]:checked {
  background: #a855f7;
}

/* Instrument selector dropdowns */
.instrument-select {
  appearance: none;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 12px;
  padding: 6px 12px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: all 0.2s ease;
}

.instrument-select:hover {
  background: rgba(255, 255, 255, 0.12);
}

.instrument-select:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.4);
}

.instrument-select option {
  background: #1a1a2e;
  color: white;
}

.instrument-select.bass-select:focus {
  box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.4);
}

.piano-roll .mute-toggle input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: 1px;
  left: 4px;
  font-size: 12px;
  color: white;
  font-weight: bold;
}

.piano-roll .mute-toggle:has(input:not(:checked)) {
  opacity: 0.5;
}

.piano-roll .mute-toggle:has(input:not(:checked)) span {
  text-decoration: line-through;
}

.piano-roll-hint {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.3);
}

/* Scale highlighting - dim out-of-scale notes */
.note-cell.out-of-scale {
  opacity: 0.4;
  background: rgba(255, 255, 255, 0.02);
}

.note-cell.out-of-scale:hover {
  opacity: 0.7;
}

/* Octave color coding - subtle tints */
.piano-key.octave-4 {
  color: rgba(96, 165, 250, 0.8);
}

.piano-key.octave-5 {
  color: rgba(251, 191, 36, 0.8);
}

.note-cell.octave-4.active {
  background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
}

.note-cell.octave-5.active {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
}

/* Track divider - minimal */
.track-divider {
  grid-column: 1;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 10px 6px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.track-divider-cell {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 12px 0 6px;
  border-radius: 1px;
}

/* Drum track styling - cleaner */
.drum-key {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
  background: transparent;
  height: 28px;
}

.drum-cell {
  height: 28px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.drum-cell:hover {
  background: rgba(255, 255, 255, 0.06);
}

.drum-cell.active {
  background: var(--drum-color, #ff6b6b);
  border-radius: 6px;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--drum-color, #ff6b6b) 40%, transparent);
  animation: notePopIn 0.15s ease-out;
}

.drum-cell.active:hover {
  transform: scale(1.05);
}

.drum-cell.beat-start {
  border-left: none;
}

/* Playhead for drums */
.drum-cell.playhead {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6);
}

/* Bass track styling - purple theme */
.bass-key {
  font-size: 10px;
  color: rgba(168, 85, 247, 0.8);
  background: transparent;
  height: 28px;
}

.bass-cell {
  height: 28px;
  background: rgba(168, 85, 247, 0.03);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.bass-cell:hover {
  background: rgba(168, 85, 247, 0.1);
}

.bass-cell.active {
  background: linear-gradient(135deg, #a855f7 0%, #9333ea 100%);
  border-radius: 6px;
  box-shadow: 0 2px 12px rgba(168, 85, 247, 0.4);
  animation: notePopIn 0.15s ease-out;
}

.bass-cell.active:hover {
  transform: scale(1.05);
}

.bass-cell.playhead {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6);
}

/* Mobile responsive styles */
@media (max-width: 768px) {
  .piano-roll-visualizer {
    flex: 0 0 25%;
    min-height: 120px;
  }
  
  .piano-roll-editor {
    border-radius: 16px 16px 0 0;
  }
  
  .piano-roll-header {
    padding: 12px 16px;
  }
  
  .piano-roll-title {
    font-size: 16px;
  }
  
  .piano-roll-controls {
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .transport-controls {
    padding: 4px;
    gap: 2px;
  }
  
  #piano-roll-play {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }
  
  #piano-roll-random {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
  
  .piano-roll-tempo input[type="range"] {
    width: 60px;
  }
  
  .piano-roll-grid {
    padding: 8px;
    gap: 3px;
  }
  
  .note-cell, .drum-cell, .bass-cell {
    height: 24px;
  }
  
  .piano-key {
    width: 32px;
    font-size: 9px;
    padding-right: 6px;
  }
  
  .step-number {
    font-size: 8px;
    height: 18px;
  }
  
  .piano-roll-footer {
    padding: 10px 12px;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
  
  .piano-roll-mutes {
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .mute-toggle {
    padding: 6px 10px;
    font-size: 11px;
  }
  
  .piano-roll-hint {
    font-size: 10px;
  }
}

@media (max-width: 480px) {
  .piano-roll-visualizer {
    flex: 0 0 20%;
    min-height: 100px;
  }
  
  .note-cell, .drum-cell, .bass-cell {
    height: 20px;
    border-radius: 4px;
  }
  
  .piano-key {
    width: 28px;
    font-size: 8px;
  }
  
  .track-divider {
    font-size: 8px;
    padding: 8px 6px 4px;
  }
}

/* Hidden build number - shows on hover over bottom-left corner */
.build-hover-area {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 60px;
  height: 60px;
  z-index: 9999;
}

.build-number {
  position: absolute;
  bottom: 8px;
  left: 8px;
  font-size: 10px;
  color: #888;
  opacity: 0;
  transition: opacity 0.2s;
  user-select: none;
}

.build-hover-area:hover .build-number {
  opacity: 0.5;
}
