* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@keyframes psychedelicFlow {
    0% {
        background-position: 0% 0%;
    }

    25% {
        background-position: 100% 50%;
    }

    50% {
        background-position: 100% 100%;
    }

    75% {
        background-position: 0% 50%;
    }

    100% {
        background-position: 0% 0%;
    }
}

@keyframes breathe {

    0%,
    100% {
        transform: scale(1) translateZ(0);
    }

    50% {
        transform: scale(1.03) translateZ(0);
    }
}

/*
 * float composes its drift with live custom properties:
 *   --ox / --oy  static offset (orb3 uses them to stay centered)
 *   --px / --py  audio/parallax offset driven from JS
 *   --s          audio-reactive scale driven from JS
 * Defaults keep the animation identical when the vars are unset
 * (e.g. body::before), but let JS reactivity actually render —
 * inline transforms are overridden by running animations, vars are not.
 */
@keyframes float {

    0%,
    100% {
        transform: translate(calc(var(--ox, 0px) + var(--px, 0px)), calc(var(--oy, 0px) + var(--py, 0px))) rotate(0deg) scale(var(--s, 1));
    }

    33% {
        transform: translate(calc(var(--ox, 0px) + var(--px, 0px) + 20px), calc(var(--oy, 0px) + var(--py, 0px) - 30px)) rotate(120deg) scale(calc(var(--s, 1) * 1.1));
    }

    66% {
        transform: translate(calc(var(--ox, 0px) + var(--px, 0px) - 20px), calc(var(--oy, 0px) + var(--py, 0px) + 20px)) rotate(240deg) scale(calc(var(--s, 1) * 0.95));
    }
}

@keyframes shimmer {
    0% {
        opacity: 0;
        transform: translate(-30%, -40%) scale(0.8);
    }

    40% {
        opacity: 0.6;
        transform: translate(0%, -10%) scale(1.1);
    }

    70% {
        opacity: 0.4;
        transform: translate(20%, 10%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(30%, 40%) scale(0.8);
    }
}

@keyframes morphOrb {

    0%,
    100% {
        border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    }

    50% {
        border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
    }
}

@keyframes geometricPulse {

    0%,
    100% {
        transform: rotate(0deg) scale(1);
        opacity: 0.03;
    }

    50% {
        transform: rotate(180deg) scale(1.2);
        opacity: 0.08;
    }
}

@keyframes grainDrift {

    0%,
    100% {
        transform: translate(0, 0);
    }

    10% {
        transform: translate(-2%, -3%);
    }

    20% {
        transform: translate(3%, 1%);
    }

    30% {
        transform: translate(-1%, 3%);
    }

    40% {
        transform: translate(2%, -2%);
    }

    50% {
        transform: translate(-3%, 1%);
    }

    60% {
        transform: translate(1%, -1%);
    }

    70% {
        transform: translate(-2%, 2%);
    }

    80% {
        transform: translate(3%, -3%);
    }

    90% {
        transform: translate(-1%, -2%);
    }
}

@keyframes revealText {
    0% {
        opacity: 0;
        letter-spacing: 0.5em;
        filter: blur(12px);
    }

    50% {
        opacity: 0.8;
        letter-spacing: 0.15em;
        filter: blur(0px);
    }

    85% {
        opacity: 0.5;
        filter: blur(0px);
    }

    100% {
        opacity: 0;
        filter: blur(6px);
    }
}

@keyframes planckDefocus {

    0%,
    100% {
        filter: blur(6px);
    }

    40% {
        filter: blur(3px);
    }

    60% {
        filter: blur(8px);
    }
}

@keyframes rotate {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

body {
    min-height: 100vh;
    min-height: -webkit-fill-available;
    min-height: 100dvh;
    background:
        radial-gradient(ellipse at 20% 30%, rgba(255, 20, 147, 0.4), transparent 40%),
        radial-gradient(ellipse at 80% 70%, rgba(0, 255, 255, 0.3), transparent 40%),
        radial-gradient(ellipse at 50% 50%, rgba(138, 43, 226, 0.3), transparent 50%),
        radial-gradient(ellipse at top left, rgba(254, 168, 55, 0.5), transparent 40%),
        radial-gradient(ellipse at bottom right, rgba(89, 62, 103, 0.5), transparent 40%),
        linear-gradient(135deg,
            #FF1493,
            #FF6B35,
            #FEA837,
            #00CED1,
            #8A2BE2,
            #FF1493,
            #00FA9A,
            #FFD700,
            #FF1493);
    background-size: 400% 400%;
    animation:
        psychedelicFlow 30s cubic-bezier(0.4, 0, 0.6, 1) infinite,
        breathe 6s ease-in-out infinite;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: crosshair;
    overflow: hidden;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    transition: filter 0.8s ease;
}

body.playing {
    animation-duration: 15s, 4s;
}

/* Film grain overlay */
.grain {
    position: fixed;
    inset: -60%;
    width: 220%;
    height: 220%;
    pointer-events: none;
    z-index: 50;
    opacity: 0.035;
    mix-blend-mode: overlay;
    animation: grainDrift 0.8s steps(1) infinite;
    -webkit-mask-image: radial-gradient(ellipse at center, black 40%, transparent 72%);
    mask-image: radial-gradient(ellipse at center, black 40%, transparent 72%);
}

body.playing .grain {
    opacity: 0.05;
}

.geometric-overlay {
    position: absolute;
    inset: -20%;
    pointer-events: none;
    opacity: 0.06;
    mix-blend-mode: overlay;
    animation: geometricPulse 10s ease-in-out infinite;
    background-image:
        radial-gradient(circle 2px at 25% 25%, rgba(255, 255, 255, 0.08) 0%, transparent 100%),
        radial-gradient(circle 3px at 75% 20%, rgba(255, 255, 255, 0.06) 0%, transparent 100%),
        radial-gradient(circle 2px at 50% 60%, rgba(255, 255, 255, 0.07) 0%, transparent 100%),
        radial-gradient(circle 4px at 15% 80%, rgba(255, 255, 255, 0.05) 0%, transparent 100%),
        radial-gradient(circle 2px at 85% 70%, rgba(255, 255, 255, 0.06) 0%, transparent 100%),
        radial-gradient(circle 3px at 40% 90%, rgba(255, 255, 255, 0.04) 0%, transparent 100%),
        radial-gradient(circle 2px at 60% 35%, rgba(255, 255, 255, 0.07) 0%, transparent 100%);
}

body::before {
    content: '';
    position: absolute;
    inset: -50%;
    background:
        radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(255, 20, 147, 0.03) 0%, transparent 50%);
    animation: float 25s ease-in-out infinite;
    pointer-events: none;
}

body::after {
    content: '';
    position: absolute;
    inset: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 50% 50%, rgba(255, 255, 255, 0.18), transparent 60%);
    animation: shimmer 8s ease-in-out infinite;
    pointer-events: none;
    mix-blend-mode: overlay;
    border-radius: 50%;
}

.orbs-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    filter: blur(40px);
    opacity: 0.5;
    transition: filter 1s ease, opacity 1s ease;
}

body.playing .orbs-container {
    filter: blur(30px);
    opacity: 0.6;
}

.orb {
    position: absolute;
    mix-blend-mode: screen;
    animation: morphOrb 8s ease-in-out infinite;
}

.orb1 {
    width: min(600px, 80vw);
    height: min(600px, 80vw);
    background: radial-gradient(circle, rgba(255, 20, 147, 0.8), rgba(254, 168, 55, 0.4), transparent);
    top: -20%;
    left: -20%;
    animation: float 20s ease-in-out infinite, morphOrb 8s ease-in-out infinite;
}

.orb2 {
    width: min(400px, 60vw);
    height: min(400px, 60vw);
    background: radial-gradient(circle, rgba(0, 255, 255, 0.8), rgba(138, 43, 226, 0.4), transparent);
    bottom: -15%;
    right: -15%;
    animation: float 25s ease-in-out infinite reverse, morphOrb 10s ease-in-out infinite reverse;
}

.orb3 {
    /* Centering lives in the animation vars so the delayed float
       animation no longer makes the orb jump off-center at 3s. */
    --ox: -50%;
    --oy: -50%;
    width: min(350px, 50vw);
    height: min(350px, 50vw);
    background: radial-gradient(circle, rgba(138, 43, 226, 0.6), rgba(0, 255, 127, 0.3), transparent);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: float 18s ease-in-out 3s infinite backwards, morphOrb 7s ease-in-out infinite;
}

.audio-control {
    position: fixed;
    bottom: max(env(safe-area-inset-bottom), 20px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(40px) saturate(200%);
    -webkit-backdrop-filter: blur(40px) saturate(200%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50px;
    padding: clamp(12px, 3vw, 15px) clamp(20px, 5vw, 30px);
    display: flex;
    align-items: center;
    gap: clamp(10px, 2vw, 15px);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    box-shadow:
        0 8px 32px rgba(138, 43, 226, 0.15),
        0 0 80px rgba(255, 20, 147, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    touch-action: manipulation;
    min-width: 120px;
    justify-content: center;
}

.audio-control:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(-50%) translateY(-3px) scale(1.05);
    box-shadow:
        0 12px 48px rgba(138, 43, 226, 0.25),
        0 0 120px rgba(255, 20, 147, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.audio-control:active {
    transform: translateX(-50%) scale(0.98);
}

.audio-control:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.75);
    outline-offset: 4px;
}

.play-icon {
    position: absolute;
    inset: 0;
    margin: auto;
    width: clamp(18px, 4.5vw, 22px);
    height: clamp(18px, 4.5vw, 22px);
    fill: white;
    filter: drop-shadow(0 0 3px rgba(255, 20, 147, 0.5));
    z-index: 2;
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

body.playing .play-icon {
    opacity: 0;
    transform: scale(0.8);
}

.visualizer {
    display: flex;
    gap: 3px;
    height: 24px;
    align-items: center;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.3s ease, transform 0.3s ease;
    width: 0;
    overflow: hidden;
}

body.playing .visualizer {
    opacity: 1;
    transform: scale(1);
    width: auto;
}

.bar {
    width: 2.5px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 3px;
    transition: height 0.08s ease-out;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.3);
    will-change: height;
}

.bar1 {
    height: 4px;
}

.bar2 {
    height: 6px;
}

.bar3 {
    height: 4px;
}

.bar4 {
    height: 8px;
}

.bar5 {
    height: 5px;
}

.bar6 {
    height: 3px;
}

.bar7 {
    height: 7px;
}

.cursor-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 20, 147, 0.08), rgba(0, 255, 255, 0.04), transparent 40%);
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -50%);
    transition: opacity 0.3s ease;
    z-index: 5;
    mix-blend-mode: screen;
    filter: blur(2px);
    will-change: transform;
}

.hint {
    position: fixed;
    top: max(env(safe-area-inset-top), 20px);
    left: 50%;
    transform: translateX(-50%);
    font-size: clamp(11px, 2.5vw, 13px);
    text-transform: uppercase;
    letter-spacing: 0.3em;
    opacity: 0;
    animation: revealText 10s ease-in-out 1.5s;
    pointer-events: none;
    text-shadow:
        0 0 30px rgba(255, 20, 147, 0.4),
        0 2px 10px rgba(0, 0, 0, 0.3);
    padding: 0 20px;
    text-align: center;
    font-weight: 300;
}

.kaleidoscope {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 3s ease;
    mix-blend-mode: multiply;
}

body.playing .kaleidoscope {
    opacity: 0.03;
}

.kaleidoscope::before,
.kaleidoscope::after {
    content: '';
    position: absolute;
    inset: -50%;
    background: conic-gradient(from 0deg,
            transparent,
            rgba(255, 20, 147, 0.1),
            transparent,
            rgba(0, 255, 255, 0.1),
            transparent,
            rgba(138, 43, 226, 0.1),
            transparent);
    animation: rotate 60s linear infinite;
}

.kaleidoscope::after {
    animation-direction: reverse;
    animation-duration: 45s;
}

/* Central ℏ symbol */
.planck {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    pointer-events: none;
    z-index: 3;
    font-size: clamp(140px, 28vw, 320px);
    font-weight: 200;
    font-family: 'Times New Roman', 'Georgia', serif;
    color: rgba(255, 255, 255, 0);
    text-shadow: none;
    transition: color 1.5s ease, text-shadow 1.5s ease, transform 1.5s ease, filter 1.5s ease, opacity 1.5s ease;
    user-select: none;
    -webkit-user-select: none;
    line-height: 1;
    will-change: transform, filter, opacity;
    opacity: 0;
    filter: blur(8px);
}

body.playing .planck {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    color: rgba(255, 255, 255, 0.35);
    filter: blur(5px);
    text-shadow:
        0 0 30px rgba(255, 255, 255, 0.12),
        0 0 80px rgba(255, 20, 147, 0.2),
        0 0 160px rgba(138, 43, 226, 0.12),
        0 0 300px rgba(0, 255, 255, 0.05);
    animation: planckDefocus 12s ease-in-out infinite;
    /* Only opacity keeps its long fade while playing, so the
       per-frame audio reactivity from JS stays crisp instead of
       being smeared by 1.5s transitions. */
    transition: opacity 1.5s ease;
}

@media (max-width: 768px) {
    body {
        cursor: default;
        animation-duration: 35s, 12s;
    }

    .cursor-glow {
        display: none;
    }

    .geometric-overlay {
        opacity: 0.03;
    }

    .kaleidoscope {
        display: none;
    }

    .planck {
        font-size: clamp(120px, 35vw, 240px);
    }
}

@media (prefers-reduced-motion: reduce) {
    body {
        animation: none;
        background-size: 100% 100%;
    }

    body::before,
    body::after,
    .orb,
    .kaleidoscope::before,
    .kaleidoscope::after,
    .geometric-overlay,
    .grain {
        animation: none;
    }

    body.playing .planck {
        animation: none;
    }

    /* Show the name statically instead of the animated reveal. */
    .hint {
        animation: none;
        opacity: 0.5;
    }
}