:root {
  --backdrop-base: hsl(230 30% 10%);
  --blob-1: hsl(260 60% 50% / 0.55);
  --blob-2: hsl(190 60% 45% / 0.55);
  --blob-3: hsl(330 60% 50% / 0.55);
  --blob-4: hsl(45 70% 55% / 0.45);
  --bg: #0f1216;
  --fg: #e9edf2;
  --muted: #b8c0cc;
  --panel: rgba(16, 19, 24, 0.72);
  --border: rgba(255, 255, 255, 0.16);
  --accent: #ffd23f;
  --accent-ink: #1a1500;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--backdrop-base);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

/* --- Animated backdrop: four soft blobs that drift and breathe. Colours come from backdrop.js --- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: var(--backdrop-base);
}

.backdrop span {
  position: absolute;
  width: 62vmax;
  height: 62vmax;
  border-radius: 50%;
  filter: blur(70px);
  will-change: transform;
  animation: drift 26s ease-in-out infinite alternate;
}

.backdrop span:nth-child(1) {
  background: var(--blob-1);
  top: -22%;
  left: -14%;
}

.backdrop span:nth-child(2) {
  background: var(--blob-2);
  bottom: -26%;
  right: -12%;
  animation-duration: 32s;
  animation-delay: -8s;
}

.backdrop span:nth-child(3) {
  background: var(--blob-3);
  top: 18%;
  right: 8%;
  width: 48vmax;
  height: 48vmax;
  animation-duration: 22s;
  animation-delay: -4s;
}

.backdrop span:nth-child(4) {
  background: var(--blob-4);
  bottom: 4%;
  left: 26%;
  width: 40vmax;
  height: 40vmax;
  animation-duration: 38s;
  animation-delay: -15s;
}

@keyframes drift {
  from {
    transform: translate(0, 0) scale(1);
  }
  to {
    transform: translate(12vw, -8vh) scale(1.18);
  }
}

@media (prefers-reduced-motion: reduce) {
  .backdrop span,
  .logo {
    animation: none;
  }
}

/* --- Logo: elegant script with a slow light sweep and a glow to stand out from the backdrop --- */

.logo {
  position: fixed;
  top: 10px;
  left: 20px;
  z-index: 2;
  margin: 0;
  font-family: "Great Vibes", "Brush Script MT", cursive;
  font-weight: 400;
  font-size: clamp(2.8rem, 7vw, 5rem);
  line-height: 1.1;
  padding-right: 0.1em;
  /* The colour pattern repeats every half of the image, so the sweep loops without a jump. */
  background: linear-gradient(
    110deg,
    #ffffff 0%,
    #fff1c4 12.5%,
    #ffc6ef 25%,
    #c9f4ff 37.5%,
    #ffffff 50%,
    #fff1c4 62.5%,
    #ffc6ef 75%,
    #c9f4ff 87.5%,
    #ffffff 100%
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.55)) drop-shadow(0 0 20px rgba(255, 255, 255, 0.45));
  animation: sweep 9s linear infinite;
  pointer-events: none;
}

@keyframes sweep {
  from {
    background-position: 0% center;
  }
  to {
    background-position: 100% center;
  }
}

/* --- Mute / unmute icon, top right --- */

.music-toggle {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 5;
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--fg);
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.music-toggle[hidden] {
  display: none;
}

.music-toggle:hover,
.music-toggle:focus-visible {
  border-color: var(--accent);
}

.music-toggle svg {
  width: 22px;
  height: 22px;
}

.music-toggle .icon-off {
  display: none;
}

.music-toggle.muted .icon-on {
  display: none;
}

.music-toggle.muted .icon-off {
  display: block;
}

#cube-view {
  position: fixed;
  inset: 0;
}

#cube-view canvas {
  display: block;
  touch-action: none;
  cursor: grab;
}

.panel {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 2;
  width: min(320px, calc(100vw - 32px));
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  display: grid;
  gap: 10px;
}

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

.row label {
  color: var(--muted);
  font-size: 0.9rem;
  min-width: 48px;
}

select,
button {
  font: inherit;
  color: inherit;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 8px 12px;
  background: transparent;
}

select {
  flex: 1;
  background: var(--bg);
}

.buttons button {
  flex: 1;
  cursor: pointer;
  font-weight: 600;
}

.buttons button:first-child {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

.buttons button.stop {
  background: #ff6b6b;
  color: #1a0000;
  border-color: transparent;
}

.status {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  min-height: 1.2em;
  overflow-wrap: anywhere;
}

.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 96px;
  overflow-y: auto;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.85rem;
}

.steps span {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--border);
}

.steps span.done {
  opacity: 0.5;
}

.steps span.current {
  background: var(--accent);
  color: var(--accent-ink);
}

#fireworks {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.congrats {
  position: fixed;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: clamp(1rem, 3vw, 1.4rem);
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .logo {
    font-size: clamp(2.4rem, 14vw, 3.4rem);
  }
  .panel {
    left: 16px;
    right: 16px;
    width: auto;
  }
}
