:root {
  color-scheme: dark;
  --hold-angle: 0deg;
  --glass: rgba(255, 255, 255, 0.1);
  --glass-line: rgba(255, 255, 255, 0.24);
  --ink: rgba(255, 255, 255, 0.92);
  --quiet-ink: rgba(13, 18, 25, 0.72);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #030409;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
  user-select: none;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.experience {
  position: fixed;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
}

.environment-canvas,
.atmosphere,
.product-stage {
  position: absolute;
  inset: 0;
}

.environment-canvas {
  z-index: 0;
  width: 100%;
  height: 100%;
  transition:
    filter 1s cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 1s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.atmosphere {
  z-index: 1;
  pointer-events: none;
}

.off-layer,
.calm-layer,
.switch-wash {
  position: absolute;
  inset: -18%;
  transition:
    opacity 1s cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 1s cubic-bezier(0.2, 0.8, 0.2, 1),
    filter 1s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform, opacity, filter;
}

.rgb-smear {
  opacity: 0.66;
  background:
    linear-gradient(105deg, transparent 0 19%, rgba(0, 214, 255, 0.44) 29%, transparent 45%),
    linear-gradient(250deg, transparent 8%, rgba(255, 32, 105, 0.4) 28%, transparent 47%),
    linear-gradient(20deg, rgba(123, 255, 94, 0.22), transparent 43% 67%, rgba(70, 82, 255, 0.34)),
    #030409;
  filter: blur(26px) saturate(1.9) contrast(1.16);
  mix-blend-mode: screen;
  animation: rgbSmear 8.2s ease-in-out infinite alternate;
}

.turbulence {
  opacity: 0.62;
  background:
    repeating-linear-gradient(
      103deg,
      rgba(255, 255, 255, 0.02) 0 2px,
      rgba(0, 255, 255, 0.08) 3px 9px,
      transparent 10px 34px
    ),
    repeating-linear-gradient(
      -32deg,
      transparent 0 14px,
      rgba(255, 36, 104, 0.09) 15px 26px,
      transparent 27px 54px
    );
  filter: blur(34px) saturate(2.2);
  mix-blend-mode: color-dodge;
  animation: turbulence 5.4s cubic-bezier(0.45, 0, 0.55, 1) infinite alternate;
}

.refracted-lines {
  inset: -5%;
  opacity: 0.48;
  background:
    linear-gradient(92deg, transparent 0 22%, rgba(255, 255, 255, 0.08) 25%, transparent 28%),
    linear-gradient(114deg, transparent 0 42%, rgba(0, 235, 255, 0.12) 46%, transparent 52%),
    linear-gradient(76deg, transparent 0 60%, rgba(255, 58, 92, 0.1) 65%, transparent 70%);
  filter: blur(14px);
  mix-blend-mode: screen;
  animation: refract 3.8s ease-in-out infinite alternate;
}

.calm-layer {
  opacity: 0;
}

.calm-wash {
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(243, 247, 250, 0.94)),
    linear-gradient(65deg, rgba(202, 220, 235, 0.38), transparent 52%),
    linear-gradient(160deg, transparent 28%, rgba(237, 239, 228, 0.42) 88%);
}

.calm-breath {
  inset: -24%;
  background:
    linear-gradient(115deg, transparent 8%, rgba(199, 222, 235, 0.38) 35%, transparent 62%),
    linear-gradient(250deg, transparent 16%, rgba(230, 231, 218, 0.32) 48%, transparent 78%);
  filter: blur(58px);
  animation: calmBreath 12s ease-in-out infinite alternate;
}

.switch-wash {
  inset: 0;
  opacity: 0;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.94), transparent),
    rgba(255, 255, 255, 0.22);
  transform: scaleX(0.18);
  transform-origin: center;
  z-index: 5;
}

.noise-on {
  background: #f8faf9;
  color-scheme: light;
}

.noise-on .environment-canvas {
  filter: blur(2px) saturate(0.72);
}

.noise-on .off-layer {
  opacity: 0;
  filter: blur(76px) saturate(0.05) brightness(1.65);
  transform: scale(1.18);
}

.noise-on .calm-layer {
  opacity: 1;
}

.is-switching .switch-wash {
  animation: switchWash 1s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.product-stage {
  z-index: 3;
  display: grid;
  place-items: center;
  pointer-events: none;
}

#productCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.music-button {
  position: fixed;
  z-index: 6;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  min-width: 154px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 0 22px;
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(8, 10, 16, 0.36);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 18px 42px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(22px) saturate(1.3);
  transform: translateX(-50%);
  transition:
    background 0.35s ease,
    color 0.35s ease,
    border-color 0.35s ease,
    transform 0.35s ease,
    opacity 0.35s ease;
}

.music-button:active {
  transform: translateX(-50%) translateY(2px) scale(0.98);
}

.music-button:disabled {
  cursor: default;
  opacity: 0.78;
}

.music-icon {
  position: relative;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1px solid currentColor;
  opacity: 0.88;
}

.music-icon::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 56%;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid currentColor;
  transform: translate(-40%, -50%);
}

.music-label {
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.noise-button {
  position: fixed;
  z-index: 6;
  top: 50%;
  right: clamp(20px, 4.5vw, 58px);
  width: clamp(76px, 9vw, 92px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.04)),
    rgba(8, 10, 16, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.23);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -18px 30px rgba(0, 0, 0, 0.18),
    0 22px 62px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(28px) saturate(1.35);
  transform: translateY(-50%);
  touch-action: none;
  transition:
    color 0.35s ease,
    background 0.35s ease,
    border-color 0.35s ease,
    box-shadow 0.35s ease,
    transform 0.2s ease;
}

.noise-button-ring {
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  background: conic-gradient(
    from -90deg,
    rgba(255, 255, 255, 0.98) var(--hold-angle),
    rgba(255, 255, 255, 0.16) 0
  );
  -webkit-mask:
    radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  mask:
    radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  opacity: 0.84;
  transition: opacity 0.2s ease;
}

.noise-mark {
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
}

.noise-state {
  position: absolute;
  bottom: 21%;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  opacity: 0.52;
}

.noise-button.is-holding {
  background:
    linear-gradient(145deg, rgba(0, 0, 0, 0.34), rgba(255, 255, 255, 0.04)),
    rgba(0, 0, 0, 0.5);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -24px 46px rgba(0, 0, 0, 0.36),
    0 14px 44px rgba(0, 0, 0, 0.42);
  transform: translateY(-50%) scale(0.96);
}

.noise-button.is-holding .noise-button-ring {
  opacity: 1;
}

.noise-on .music-button {
  color: var(--quiet-ink);
  background: rgba(255, 255, 255, 0.55);
  border-color: rgba(26, 35, 45, 0.14);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.82),
    0 22px 60px rgba(90, 105, 120, 0.18);
}

.noise-on .noise-button {
  color: var(--quiet-ink);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(227, 232, 236, 0.72)),
    rgba(255, 255, 255, 0.7);
  border-color: rgba(26, 35, 45, 0.13);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -20px 36px rgba(121, 135, 148, 0.1),
    0 26px 70px rgba(97, 112, 126, 0.2);
}

.noise-on .noise-button-ring {
  background: conic-gradient(
    from -90deg,
    rgba(20, 29, 38, 0.74) var(--hold-angle),
    rgba(20, 29, 38, 0.12) 0
  );
}

.noise-on .noise-button.is-holding {
  background:
    linear-gradient(145deg, rgba(217, 224, 230, 0.98), rgba(247, 249, 250, 0.84)),
    rgba(255, 255, 255, 0.82);
}

@keyframes rgbSmear {
  0% {
    transform: translate3d(-3%, 2%, 0) rotate(-4deg) scale(1.12);
  }

  45% {
    transform: translate3d(4%, -2%, 0) rotate(3deg) scale(1.2);
  }

  100% {
    transform: translate3d(-1%, -5%, 0) rotate(8deg) scale(1.15);
  }
}

@keyframes turbulence {
  0% {
    transform: translate3d(-6%, 3%, 0) skewX(-8deg) scale(1.1);
  }

  100% {
    transform: translate3d(4%, -4%, 0) skewX(7deg) scale(1.2);
  }
}

@keyframes refract {
  0% {
    transform: translate3d(-2%, 0, 0) rotate(-1deg);
    opacity: 0.24;
  }

  100% {
    transform: translate3d(2%, -1%, 0) rotate(2deg);
    opacity: 0.44;
  }
}

@keyframes calmBreath {
  0% {
    transform: translate3d(-1%, 0, 0) scale(1.02);
    filter: blur(62px);
  }

  100% {
    transform: translate3d(1%, -2%, 0) scale(1.08);
    filter: blur(72px);
  }
}

@keyframes switchWash {
  0% {
    opacity: 0;
    transform: scaleX(0.12);
    filter: blur(18px);
  }

  18% {
    opacity: 0.92;
  }

  100% {
    opacity: 0;
    transform: scaleX(1.8);
    filter: blur(52px);
  }
}

@media (max-width: 720px) {
  .music-button {
    bottom: max(22px, env(safe-area-inset-bottom));
    min-width: 142px;
    height: 46px;
    padding: 0 18px;
  }

  .noise-button {
    top: 50%;
    right: max(16px, env(safe-area-inset-right));
    bottom: auto;
    width: 72px;
    transform: translateY(-50%);
  }

  .noise-button.is-holding {
    transform: translateY(-50%) scale(0.96);
  }

  .music-label {
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .off-layer,
  .calm-layer {
    animation-duration: 20s;
  }
}
