* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: sans-serif;
}

body {
  height: 100vh;
  background: radial-gradient(circle at top, #7f00ff, #12002f);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Background icons */
.bg-icons span {
  position: absolute;
  font-size: 20px;
  color: rgba(255,255,255,0.4);
  animation: float 10s linear infinite;
}

@keyframes float {
  from {
    transform: translateY(100vh) rotate(0deg);
  }
  to {
    transform: translateY(-120vh) rotate(360deg);
  }
}

/* Piano */
.piano {
  display: flex;
  gap: 6px;
  padding: 12px;
  background: transparent;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  position: relative;
  --w: 72px; /* white key width */
  --gap: 6px; /* gap between keys */
  --blackW: 46px; /* black key width */
}

/* Frame and controls */
.piano-frame {
  background: linear-gradient(180deg,#1b1b1b 0%, #0f0f0f 100%);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), inset 0 2px 6px rgba(255,255,255,0.02);
  max-width: 95vw;
  width: min(1200px, 95vw);
}

.frame-top {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 8px 12px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  margin-bottom: 12px;
}

.controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.control-group {
  display: flex;
  gap: 6px;
}

.btn {
  background: #2a2a2a;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.04);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.6);
}

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

.btn.play { font-weight: 600; }

.piano-wrap {
  background: linear-gradient(180deg,#111 0%, #0b0b0b 100%);
  padding: 12px;
  border-radius: 8px;
  box-shadow: inset 0 -6px 16px rgba(0,0,0,0.6);
  position: relative;
  overflow: hidden;
}

/* Floating Note Stream overlay */
.floating-notes {
  position: absolute;
  inset: 0; /* cover the piano-wrap area */
  pointer-events: none;
  overflow: visible;
  z-index: 1000;
}

/* Global top overlay for floating notes above the piano */
.floating-notes-top {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 9999;
}

.floating-note {
  position: absolute;
  left: 50%;
  top: 28px; /* default start a bit below top */
  transform: translateX(-50%) translateY(0);
  font-size: 56px; /* large/gig font */
  line-height: 1;
  color: rgba(230, 220, 255, 0.98);
  mix-blend-mode: screen;
  filter: drop-shadow(0 8px 20px rgba(0,0,0,0.55));
  opacity: 1;
  white-space: nowrap;
  transition: opacity 0.2s ease;
  will-change: transform, opacity;
  text-shadow: 0 0 12px rgba(170,140,255,0.18);
  pointer-events: none;
}

@keyframes float-note {
  0% {
    transform: translateX(-50%) translateY(0) scale(1);
    opacity: 1;
    filter: blur(0px);
  }
  100% {
    transform: translateX(-50%) translateY(-96px) scale(0.98);
    opacity: 0;
    filter: blur(1px);
  }
}

.floating-note.animate {
  animation: float-note 1400ms cubic-bezier(.2,.7,.2,1) forwards;
}

.key {
  width: var(--w);
  height: 140px;
  background: linear-gradient(180deg, #ffffff 0%, #f3f3f3 60%, #e8e8e8 100%);
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  box-shadow: 0 6px 10px rgba(10,10,10,0.12), inset 0 -6px 12px rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.06);
  overflow: visible;
}

/* Black keys container positioned over white keys */
.black-keys {
  position: absolute;
  top: 12px; /* match .piano padding */
  left: 12px;
  right: 12px;
  height: 140px;
  pointer-events: none; /* allow individual black keys to handle events */
}

.black-keys .key {
  position: absolute;
  top: 0;
  width: var(--blackW);
  height: 96px;
  background: linear-gradient(180deg, #1b1b1b 0%, #0f0f0f 100%);
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.5), inset 0 -6px 12px rgba(255,255,255,0.02);
  z-index: 5;
  pointer-events: auto;
  border: 1px solid rgba(255,255,255,0.03);
}

/* hide white-key separators on black keys */
.key.black::after { display: none; }

/* place the 5 black keys between white keys: C#, D#,   F#, G#, A#  */
.black-keys .key:nth-child(1) { left: calc(var(--w) * 0 + var(--w) - (var(--blackW) / 2)); }
.black-keys .key:nth-child(2) { left: calc(var(--w) * 1 + var(--gap) * 1 + var(--w) - (var(--blackW) / 2)); }
.black-keys .key:nth-child(3) { left: calc(var(--w) * 3 + var(--gap) * 3 + var(--w) - (var(--blackW) / 2)); }
.black-keys .key:nth-child(4) { left: calc(var(--w) * 4 + var(--gap) * 4 + var(--w) - (var(--blackW) / 2)); }
.black-keys .key:nth-child(5) { left: calc(var(--w) * 5 + var(--gap) * 5 + var(--w) - (var(--blackW) / 2)); }

/* small rounding for black-key active indicator (optional) */
.key.black.active::before {
  content: "";
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: linear-gradient(180deg,#ff6b6b,#c92a2a);
  box-shadow: 0 0 6px rgba(201,42,42,0.7);
}

.key:active {
  transform: translateY(2px) scale(0.995);
  box-shadow: 0 3px 6px rgba(10,10,10,0.08), inset 0 -4px 8px rgba(0,0,0,0.08);
}

/* thin vertical separators between white keys */
.key::after {
  content: "";
  position: absolute;
  right: -3px;
  top: 8%;
  height: 84%;
  width: 6px;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.06) 40%, rgba(255,255,255,0.8) 60%, rgba(0,0,0,0.04) 100%);
  border-radius: 2px;
  transform: translateX(2px);
}

/* Flying particles */
.particle {
  position: absolute;
  font-size: 18px;
  pointer-events: none;
  animation: fly 1.2s ease-out forwards;
}

/* small red indicator dot for active key */
.key.active::before {
  content: "";
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ff6b6b, #c92a2a);
  box-shadow: 0 0 10px rgba(201, 42, 42, 0.7);
  pointer-events: none;
}

@keyframes fly {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--x), var(--y)) scale(0.2);
  }
}
