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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

#stage {
  position: relative;
  width: min(100vw, 100vh);
  height: min(100vw, 100vh);
  background: #000;
  z-index: 1;
  overflow: hidden;
}

.layer {
  position: absolute;
  inset: -10%;
  width: 120%;
  height: 120%;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  opacity: 0;
  will-change: transform, opacity, filter;
}

#layer-front {
  z-index: 2;
}

#layer-back {
  z-index: 1;
}

#overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    radial-gradient(circle at center, transparent var(--vignette-size, 50%), rgba(0,0,0,var(--vignette-darkness, 0.55)) 100%);
}

#scanlines {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255,255,255,0.35) 0px,
      rgba(255,255,255,0.35) 1px,
      transparent 1px,
      transparent 3px
    );
  opacity: 0.3;
  transition: opacity 0.3s ease;
}

#beat-flash {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.05s ease-out;
}

#matrix-rain {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  overflow: hidden;
}

.matrix-char {
  position: absolute;
  font-family: "Courier New", Courier, monospace;
  font-weight: bold;
  color: rgba(255, 255, 255, 0.45);
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.3);
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 1.5s ease-out, transform 1.5s ease-out;
}

#particles {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 6px;
  height: 6px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.5);
}

#waveform {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 100%;
  transform: translateY(-50%);
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#waveform.active {
  opacity: 1;
}

#start-prompt {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  color: rgba(255,255,255,0.85);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: clamp(1.2rem, 4vw, 2rem);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

#start-prompt.hidden {
  opacity: 0;
}

#transport-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 44px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  pointer-events: auto;
  transition: transform 0.4s ease, opacity 0.4s ease;
}

#transport-bar.hidden {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

#btn-play {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.2s ease;
  min-width: 28px;
}

#btn-fullscreen {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.2s ease;
}

#btn-fullscreen:hover {
  color: #fff;
}

#btn-play:hover {
  color: #fff;
}

#time-display {
  color: rgba(255, 255, 255, 0.7);
  font-family: monospace;
  font-size: 13px;
  letter-spacing: 0.05em;
  white-space: nowrap;
  min-width: 140px;
}

#scrubber {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

#scrubber-fill {
  height: 100%;
  width: 0%;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 3px;
  transition: width 0.1s linear;
}
