:root {
  --mx: 50%;
  --my: 46%;
  --bg-top: #4c3f79;
  --bg-mid: #746a99;
  --bg-bottom: #a09abc;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  background: var(--bg-top);
}

body {
  color: white;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.scene {
  position: relative;
  width: 100vw;
  height: 100svh;
  overflow: hidden;
  isolation: isolate;
  user-select: none;
  touch-action: none;
  background:
    radial-gradient(circle at var(--mx) var(--my), rgba(242, 221, 255, 0.18), transparent 26%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 52%, var(--bg-bottom) 100%);
}

.scene::before {
  content: "";
  position: absolute;
  inset: -12%;
  z-index: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent 28%, rgba(55, 38, 93, 0.14) 66%, transparent),
    linear-gradient(180deg, rgba(235, 210, 255, 0.12), transparent 32%, rgba(80, 63, 121, 0.14));
  transform: translate3d(0, 0, 0);
  opacity: 0.72;
  pointer-events: none;
}

.reveal-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: block;
  cursor: default;
  touch-action: none;
}

.noise-fill {
  position: absolute;
  inset: -18%;
  z-index: 3;
  pointer-events: none;
  opacity: 0.22;
  mix-blend-mode: overlay;
  background-image:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.32) 0 0.7px, transparent 1.1px),
    radial-gradient(circle at 42% 72%, rgba(47, 34, 89, 0.34) 0 0.8px, transparent 1.2px),
    radial-gradient(circle at 78% 36%, rgba(236, 216, 255, 0.28) 0 0.6px, transparent 1px);
  background-size: 22px 22px, 27px 27px, 34px 34px;
  animation: noise-drift 12s linear infinite;
}

.glass-vignette {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(33, 23, 60, 0.24), transparent 22%, transparent 74%, rgba(41, 31, 70, 0.2)),
    linear-gradient(90deg, rgba(40, 30, 73, 0.2), transparent 22%, transparent 78%, rgba(49, 36, 82, 0.18));
}

.fx-panel {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 8;
  width: min(300px, calc(100vw - 36px));
  padding: 12px;
  color: rgba(255, 255, 255, 0.86);
  background: rgba(42, 33, 72, 0.46);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 54px rgba(20, 14, 38, 0.22);
  pointer-events: auto;
  touch-action: auto;
  user-select: none;
}

.fx-toggle {
  display: none;
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 9;
  width: 52px;
  height: 52px;
  padding: 0;
  color: rgba(255, 255, 255, 0.92);
  font: inherit;
  background: rgba(26, 20, 46, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  backdrop-filter: blur(18px);
  box-shadow: 0 14px 42px rgba(20, 14, 38, 0.24);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.fx-toggle__line {
  position: absolute;
  left: 15px;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 999px;
  transform-origin: center;
  transition:
    opacity 140ms ease,
    transform 160ms ease;
}

.fx-toggle__line:nth-child(1) {
  transform: translateY(-7px);
}

.fx-toggle__line:nth-child(3) {
  transform: translateY(7px);
}

.fx-toggle[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.18);
}

.fx-toggle[aria-expanded="true"] .fx-toggle__line:nth-child(1) {
  transform: rotate(45deg);
}

.fx-toggle[aria-expanded="true"] .fx-toggle__line:nth-child(2) {
  opacity: 0;
}

.fx-toggle[aria-expanded="true"] .fx-toggle__line:nth-child(3) {
  transform: rotate(-45deg);
}

.fx-panel__head,
.fx-control span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.fx-panel__head {
  margin-bottom: 9px;
  font-size: 12px;
  font-weight: 650;
}

.fx-panel__button {
  min-height: 28px;
  padding: 0 10px;
  color: rgba(255, 255, 255, 0.86);
  font: inherit;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  cursor: pointer;
}

.fx-panel__button:hover {
  background: rgba(255, 255, 255, 0.16);
}

.fx-control {
  display: block;
  margin-top: 8px;
  font-size: 11px;
}

.fx-control output {
  min-width: 42px;
  color: rgba(255, 255, 255, 0.68);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.fx-control input {
  width: 100%;
  height: 18px;
  margin: 3px 0 0;
  accent-color: #f2dcff;
  cursor: ew-resize;
  touch-action: pan-x;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes noise-drift {
  0% {
    transform: translate3d(0, 0, 0) scale(0.94);
  }

  50% {
    transform: translate3d(-2.5%, 1.8%, 0) scale(0.98);
  }

  100% {
    transform: translate3d(0, 0, 0) scale(0.94);
  }
}

@media (max-width: 720px) {
  .scene {
    background:
      radial-gradient(circle at var(--mx) var(--my), rgba(242, 221, 255, 0.14), transparent 34%),
      linear-gradient(180deg, #493b72 0%, #716895 56%, #9892b3 100%);
  }

  .fx-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    right: max(14px, env(safe-area-inset-right));
    top: max(16px, env(safe-area-inset-top));
    bottom: auto;
  }

  .fx-panel {
    left: auto;
    right: max(14px, env(safe-area-inset-right));
    top: max(76px, calc(env(safe-area-inset-top) + 76px));
    bottom: auto;
    width: min(360px, calc(100vw - 28px));
    max-height: min(54svh, 420px);
    padding: 12px;
    overflow-y: auto;
    border-radius: 14px;
    opacity: 0;
    pointer-events: none;
    transform: translate3d(0, -10px, 0) scale(0.98);
    transform-origin: top right;
    transition:
      opacity 160ms ease,
      transform 180ms ease;
  }

  .fx-panel.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translate3d(0, 0, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .noise-fill {
    animation: none;
  }
}
