* {
    box-sizing: border-box;
    padding: 0;
    margin: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    background: #0b0b0b;
    height: 100%;
    min-height: -webkit-fill-available;
}

body {
    margin: 0;
    background: #0b0b0b;
    height: 100%;
    min-height: -webkit-fill-available;
    overflow: hidden;
    touch-action: none;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
    font-family: Helvetica, sans-serif;
    opacity: 0;
    animation: fadeIn 6s ease-in-out forwards;
    font-weight: 100;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
        padding-top: max(0px, env(safe-area-inset-top));
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
}

#bg-ps2 {
    position: fixed;
    left: 0;
    top: 0;
    z-index: -1000;
    width: 100vw;
    height: 100vh;
    height: -webkit-fill-available;
    background: radial-gradient(ellipse at center, #0b0b0b 0%, #000 100%);
    pointer-events: none;
    filter: brightness(0.9) contrast(1.2);
    opacity: .66;
    animation: zoomOut 3.75s ease-in-out forwards;
    transition: filter 0.5s ease-in-out;
}

@keyframes zoomOut {
    from {
        transform: scale(5);
        transform-origin: bottom;
    }
    to {
        transform: scale(1);
        transform-origin: bottom;
    }
}

@keyframes opacityPulse {
    0%, 100% {
        opacity: 0.42;
    }
    50% {
        opacity: 0.57;
    }
}

#bg-particle-effect {
    position: fixed;
    top: 0; /* Ensure top is 0 */
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -999; /* Between the uppermost and bottom-most wave layers */
    pointer-events: none;
    opacity: 0; /* Start fully transparent */
    transition: opacity 4s ease-in-out; /* Smooth fade-in effect with 4 seconds duration */
}

model-viewer {
    min-width: 50vw;
    min-height: 50vh;
    max-width: 100vw;
    max-height: 100vh;
    width: 100%;
    height: 100%;
    background-color: #00000000;
    margin: 0;
    display: block;
    z-index: 2147483641;
    opacity: 0;
    overflow: hidden;
    animation: fadeIn 2.6s ease-in-out forwards;
    animation-delay: 4s;
    top: 0; /* Ensure top is 0 */
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#bg-particles {
    position: fixed;
    top: 0; /* Ensure top is 0 */
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0; /* Behind everything */
    pointer-events: none;
    overflow: hidden;
    opacity: .375; /* Start fully visible */
    transition: opacity 4s ease-in-out; /* Smooth fade-in effect with 4 seconds duration */
    transition-delay: 4s;
    filter: invert(1);
}

#bg-particles canvas {
    width: 100vw;
    height: 100vh;
    display: block;
    overflow: hidden;
    filter: blur(0.5px) brightness(0.9) contrast(1.2);
    opacity: .5;
    transition: opacity 4s ease-in-out; /* Smooth fade-in effect with 4 seconds duration */
    transition-delay: 4s;
}

.logo {
    display: block;
    width: 100%;
    height: auto;
    max-width: 25%;
    z-index: 2147483645; /* Maximum possible z-index value */
    position: absolute;
    top: 0;
    left: 3rem;
    right: 0;
    bottom: 0;
    transform: translateY(50%);
    transition: opacity 0.5s ease, blur 1s ease, 5s ease;
    user-select: none;
    opacity: 0;
    animation: fadeIn 1ms ease-in-out forwards;
    animation-delay: 0s;
    /* fill: white; */
}


.sc-player, .widget, .single-sound, .sound-container {
    display: none !important;
}

.mog {
    display: block !important;
    position: absolute;
    z-index: 2147483647; /* Ensure mog is above the cards */
    width: 30px;
    height: auto;
    max-width: 25%;
    transform: translateY(0);
    transition: opacity 0.5s ease, blur 1s ease, transform 0.5s ease;
    user-select: none;
    transform: scaleX(-1);
    bottom: calc(20px + 34px); /* 20px (play button bottom) + 10px margin + mog height approximation */
    left: calc(20px + 0px - 15px + 4px); /* 20px (play button left) + half of play button width (22px / 2) - half of mog width (30px / 2) */
    opacity: 0;
    animation: fadeIn 3s ease-in-out forwards;
    animation-delay: 7.5s; /* Delay the animation to start changing opacity from 33% onward */
}

.soft-wave {
    display: block;
    width: 100%;
    height: auto;
    max-width: 18%;
    position: fixed;
    top: 73%;
    left: 75%;
    z-index: 2147483645;
    user-select: none;
    touch-action: none !important;
    -webkit-user-drag: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out, filter 0.5s ease-in-out;
    opacity: 0;
    animation: fadeIn 1ms ease-in-out forwards;
    animation-delay: 0s;
}

@media (max-width: 1500px) {
    .soft-wave {
        transform: translateY(50px);
        transition: transform 0.5s ease-in-out;
    }
}

@media (max-width: 480px) {
    .soft-wave {
        max-width: 25%;
        top: 4%;
        left: 66.5%;
        transform: none;
    }
}

.logo:active, .soft-wave:active, .mog:active {
    opacity: 0.75;
    filter: blur(.125px);
}

.logo:hover, .soft-wave:hover, .mog:hover {
    opacity: 0.825;
}

.hero {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.userInput {
    overflow: hidden;
    max-width: 100vw;
    max-height: 100vh;
}
iframe {
    display: none;
}
.music-player {
    position: fixed;
    bottom: -100px; /* Start off-screen */
    left: 0;
    width: 100%;
    z-index: 2147483645; /* Ensure music player is above the cards */
    display: flex;
    align-items: center;
    background: linear-gradient(to top, rgba(47, 47, 47, 0.135), rgba(47, 47, 47, 0));
    padding: 10px;
    box-sizing: border-box;
    backdrop-filter: blur(5px) brightness(0.9) contrast(1.1);
    border-top: 1px solid rgba(42, 42, 42, 0.05);
    opacity: 0; /* Start fully transparent */
    animation: slideInFromBottom 3s ease-in-out forwards;
    animation-delay: 7s; /* Delay animation by 7 seconds */
}

@keyframes slideInFromBottom {
    from {
        bottom: -100px; /* Off-screen */
        opacity: 0;
    }
    75% {
        bottom: 0; /* Fully moved into position */
        opacity: 0.5; /* Partially faded in */
    }
    to {
        bottom: 0; /* Fully visible */
        opacity: 1;
    }
}

#playBtn {
    background: none;
    border: none;
    font-size: 22px;
    color: white;
    cursor: pointer;
    margin-right: 10px;
    margin-left: 20px;
}

#tracklistBtn {
    background: none;
    border: none;
    font-size: 22px;
    color: white;
    cursor: pointer;
    margin-left: auto; /* Align to the right */
    margin-right: 20px;
    padding-top: 4px;
}

#tracklistBtn:hover, svg:hover {
    color: #ECB7DD;
    transition: color 0.3s ease;
    filter: drop-shadow(0 0 2px rgba(236, 183, 221, 0.2));
    fill: #ECB7DD;
}

#tracklistBtn:active {
    transform: scale(0.95);
}

#seekBar {
    flex: 1;
    height: 5px;
    appearance: none;
    background: #55555569;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

#seekBar::-webkit-slider-thumb {
    appearance: none;
    width: 10px;
    height: 10px;
    background: #ECB7DD;
    border-radius: 50%;
    cursor: pointer;
}

#seekBar::-moz-range-thumb {
    width: 10px;
    height: 10px;
    background: #ECB7DD;
    border-radius: 50%;
    cursor: pointer;
}

#playBtn:hover {
    color: #ECB7DD;
}

#playBtn:active {
    transform: scale(0.95);
}

#playBtn:focus {
    outline: none;
}

#playBtn:focus-visible {
    outline: 2px solid #ECB7DD;
    outline-offset: 2px;
}

#track-popup {
    position: fixed;
    background: rgba(0, 0, 0, 0.778);
    color: white;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-family: "Tiny5", sans-serif;
    letter-spacing: 1px;
    text-align: center;
    opacity: 0;
    transition: all 0.5s ease;
    pointer-events: none;
    transform: translateY(0); /* Removed fixed bottom positioning */
    z-index: 2147483647; /* Set to the highest possible z-index value */
    white-space: nowrap; /* Ensure text stays on one line */
    overflow: visible; /* Allow the full text to display */
    text-overflow: unset; /* Disable truncation */
}

#track-popup.show {
    opacity: 1;
    transform: translateY(0);
}

#loading-screen {
    position: fixed;
    z-index: 0;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1; /* Ensure it starts fully visible */
    transition: opacity 0.2s ease; /* Faster fade-out */
    pointer-events: none; /* Prevent blocking interactions during fade-out */
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.166);
    border-top: 4px solid #EFBAE1;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 0.8s linear infinite;
    z-index: 1000; /* Ensure spinner is above everything */
    position: absolute;
    top: 50%;
    left: 50%;
    opacity: .5; /* Ensure spinner is fully visible */
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.selected-fx {
    animation: flicker 1s infinite, glow 1s infinite ease-out;
    filter: drop-shadow(0 0 2px rgba(236, 183, 221, 0.2));
    z-index: 2147483646; /* Highest possible z-index - 1 */
}

@keyframes flicker {
    0%, 100% {
        opacity: 1;
        filter: grayscale(0%);
    }
    50% {
        opacity: 0.55;
        filter: grayscale(100%);
    }
}

body {
    background-color: transparent;
}

#bg-particle-container {
    z-index: -500; /* Background cards appear behind most elements but in front of PS2 waves */
    pointer-events: none; /* Prevent interaction with the cards */
}

.card {
    position: relative;
    z-index: 20; /* Default z-index for cards */
    transform-origin: center;
    transform-style: flat; /* Changed from preserve-3d to flat for better performance */
    perspective: none; /* Removed perspective for optimization */
    opacity: 0; /* Ensure cards start invisible */
    transition: opacity 0.5s ease; /* Smooth fade-in and fade-out */
    border-radius: 12px;
}

.card.foreground {
    z-index: 909; /* Higher than most elements but below mog (90000), ripple effect (10002), music player (999), and song popup (999999) */
    transform: scale(1.5); /* Slightly enlarge foreground cards for emphasis */
}

.card-face {
    border-radius: 4px; /* Optional: Add rounded corners */
    box-shadow: none; /* Removed shadow for better rendering performance */
    backface-visibility: hidden; /* Ensure backface is hidden to prevent popping */
}

.card-face.side {
    background-color: #333; /* Simulate card edge color */
}

#foreground-canvas {
    position: fixed;
    top: 0; /* Ensure top is 0 */
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9990099999; /* Ensure it is above everything */
    pointer-events: none;
}

#bg-particle-container .card:last-child,
#bg-particle-container .card:nth-last-child(2) {
    z-index: -1000;
    transform: scale(0);
    opacity: 0; /* Ensure the last and second last cards are fully transparent */
}

.logo:not(.fade-in-done),
.soft-wave:not(.fade-in-done) {
    animation: fadeIn 7s ease-in-out forwards;
    animation-delay: 5s;
}

.jacquard-12-regular {
    font-family: "Jacquard 12", system-ui;
    font-weight: 400;
    font-style: normal;
}

.tracklist {
    background-color: #ffffff41;
    z-index: 2147483647;
    font-family: "Jacquard 12", system-ui;
    font-weight: 400;
    font-style: normal;
    font-size: 23px;
    position: fixed;
    top: 57.7%;
    transform: translateY(-50%) translateZ(0);
    padding: rem;
    backdrop-filter: blur(2px);
    -webkit-user-drag: none; /* Disable Safari drag ghosting */
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    touch-action: none !important;
    opacity: 0;
    animation: fadeIn 1.5s ease-in-out forwards, floatEffect 4s infinite ease-in-out;
    text-shadow: #ECB7DD 0px 0px 2px, #b5b0b3 0px 0px 2px;
    -webkit-text-stroke: .5px #7a325d;
    margin: 1rem;
    padding-left: 3.5rem;
    border-radius: 2px;
    box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.01); /* Add shadow for floating effect */
    transition: transform .75s ease-in-out, box-shadow 0.3s ease-in-out; /* Smooth hover effect */
}

.close-tracklist {
    -webkit-text-stroke: .5px #7a325d;
    text-shadow: #ECB7DD 0px 0px 2px, #b5b0b3 0px 0px 2px;
    box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.01); /* Add shadow for floating effect */
}

@keyframes floatEffect {
    0%, 100% {
        transform: translateY(-50%) translateZ(0) translateY(-1px);
    }
    50% {
        transform: translateY(-50%) translateZ(0) translateY(1px);
    }
}

.tracklist:hover {
    transform: translateY(-50%) translateZ(0) scale(1.02); /* Slightly enlarge on hover */
    box-shadow: 0px 12px 20px rgba(0, 0, 0, 0.3); /* Enhance shadow on hover */
}

.tracklist ul {
    list-style-type: upper-roman;
    padding-left: 2rem;
    margin: 7px;
}

.russian {
    position: relative;
    top: -2px;
}

.tracklist-items li {
    padding-bottom: .25rem;
}

.tracklist-items li a {
    text-decoration: none;
    color: black;
}

.tracklist-items li a:hover {
    color: #ECB7DD;
    -webkit-text-stroke: .75px;
    transition: color 1s ease, text-shadow 0.5s ease;
    text-shadow: #ECB7DD 0px 0px 2px, #b5b0b3 0px 0px 2px;
}

.card-inner {
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
}

.card-face {
    backface-visibility: hidden;
    background-size: cover;
    position: absolute;
    width: 100%;
    height: 100%;
}

.card-face.back {
    transform: rotateY(180deg);
}

#audio-visualizer {
    position: fixed;
    top: 100px;
    right: 10px;
    width: 200px;
    height: 50px;
    z-index: 2147483645;
    border-radius: 5px;
    cursor: grab;
    touch-action: auto !important;
    pointer-events: auto !important;
    -webkit-user-drag: element !important;
    user-select: none;
}

#audio-visualizer:active {
    cursor: grabbing;
}

#audio-visualizer.fullscreen {
    width: 100%;
    height: 100%;
    top: 0;
    right: 0;
    left: 0;
    border-radius: 0;
    background: transparent;
}
