/* הגדרות בסיס ופונטים */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Varela Round', sans-serif;
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
    background: #fdfafd;
}

/* ===== ANIMATED MESH GRADIENT BACKGROUND ===== */
.mesh-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -2;
    overflow: hidden;
    background: #fdfafd;
}

.blob {
    position: absolute;
    width: 80vmax;
    height: 80vmax;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.8;
}

.blob1 {
    background: radial-gradient(circle, rgba(230, 230, 250, 0.9) 0%, rgba(230, 230, 250, 0) 60%);
    top: -10%;
    left: -10%;
    animation: blobMove1 28s ease-in-out infinite;
}

.blob2 {
    background: radial-gradient(circle, rgba(255, 182, 193, 0.9) 0%, rgba(255, 182, 193, 0) 60%);
    bottom: -10%;
    right: -10%;
    animation: blobMove2 25s ease-in-out infinite;
}

.blob3 {
    background: radial-gradient(circle, rgba(135, 206, 250, 0.7) 0%, rgba(135, 206, 250, 0) 60%);
    top: 30%;
    left: 40%;
    animation: blobMove3 22s ease-in-out infinite;
}

.blob4 {
    background: radial-gradient(circle, rgba(255, 218, 185, 0.8) 0%, rgba(255, 218, 185, 0) 60%);
    bottom: 20%;
    left: -15%;
    animation: blobMove4 30s ease-in-out infinite;
}

@keyframes blobMove1 {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(20%, 30%);
    }
}

@keyframes blobMove2 {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(-30%, -20%);
    }
}

@keyframes blobMove3 {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(-10%, -30%);
    }
}

@keyframes blobMove4 {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(40%, -10%);
    }
}

h1,
h2,
p,
.station-label {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* עיצוב התפריט העליון */
#navbar {
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 99999 !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    /* CRITICAL: Force navbar to be clickable above ALL overlays */
    pointer-events: auto !important;
}

#navbar ul {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 15px;
}

#navbar li {
    cursor: pointer;
    font-weight: bold;
    color: #6a4c93;
    transition: color 0.3s;
    /* CRITICAL: Ensure list items are always clickable */
    pointer-events: auto !important;
}

#navbar li:hover {
    color: #ff6b6b;
}

/* הגדרות לעמודים */
main {
    position: fixed;
    top: 80px;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: calc(100vh - 80px);
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 100;
}

.page {
    position: fixed;
    top: 80px;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: calc(100vh - 80px);
    display: none !important;
    visibility: hidden;
    pointer-events: none;
    z-index: 1;
    animation: fadeIn 0.5s ease-in-out;
    background: transparent !important;
}

.page,
#home-page,
#game-page,
#hints-page {
    background: rgba(255, 255, 255, 0.2) !important;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.page.active {
    display: flex !important;
    visibility: visible;
    pointer-events: auto;
    z-index: 10;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

/* Clues Page Vertical Layout */
#clues-page.page.active {
    justify-content: flex-start;
    padding-top: 15vh;
}

#clues-page .standard-title {
    margin-bottom: 80px;
}

/* Standard Title Styles (used in all pages except home) */
.standard-title {
    color: #6a4c93;
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 40px;
    text-shadow: 0 4px 8px rgba(255, 182, 193, 0.5);
}

/* Home Page Layout */
#home-page.page.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: calc(100vh - 80px);
    overflow: hidden;
    padding: 20px;
    box-sizing: border-box;
    gap: 0;
}

/* Home Page Curved SVG Title — overlaps image transparent area at top */
.home-rainbow-title {
    display: block;
    width: 95%;
    max-width: 720px;
    height: auto;
    margin: 0 auto -25px auto;
    text-rendering: optimizeLegibility;
    flex-shrink: 0;
    z-index: 20;
    position: relative;
}

.home-rainbow-title text {
    font-weight: bold;
    pointer-events: none;
}

/* Responsive home page sizes */
@media (max-width: 768px) {
    .standard-title {
        font-size: 2rem;
        margin-bottom: 30px;
    }

    .home-rainbow-title {
        max-width: 95%;
        margin: 0 auto -20px auto;
    }

    .home-flowers-img {
        max-height: 52vh;
    }

    .next-btn {
        padding: 14px 40px;
        font-size: 1.4rem;
        margin-top: -20px;
    }
}

@media (max-width: 480px) {
    .standard-title {
        font-size: 1.5rem;
        margin-bottom: 25px;
    }

    .home-rainbow-title {
        max-width: 100%;
        margin: 0 auto -15px auto;
    }

    .home-flowers-img {
        max-height: 46vh;
    }

    .next-btn {
        padding: 12px 35px;
        font-size: 1.2rem;
        margin-top: -15px;
    }
}



.next-btn {
    background: #4b0082;
    color: #ffd700;
    border: 2px solid #ffd700;
    padding: 15px 40px;
    font-size: 1.5rem;
    font-family: inherit;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(75, 0, 130, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
    margin-top: -25px;
    margin-bottom: 0;
    position: relative;
    z-index: 20;
}

.next-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 20px rgba(75, 0, 130, 0.6);
}

/* Home Page Flowers Image — prominent centerpiece */
.home-flowers-img {
    display: block;
    max-height: 60vh;
    width: auto;
    max-width: 90%;
    margin: -20px auto 0;
    border-radius: 20px;
    object-fit: contain;
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.1));
    animation: gentleFloat 4s ease-in-out infinite;
    flex-shrink: 1;
    z-index: 10;
}

@keyframes gentleFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

/* אנימציות */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* ===== 3D CAROUSEL STYLES ===== */

#gallery-page {
    perspective: 1000px;
    width: 100%;
    height: 100%;
    /* Isolate gallery repaints from rest of the page */
    contain: layout style;
}

/* Graceful gallery entrance: fade-in over 0.5s hides layout-calculation stutter */
#gallery-page.page.active .carousel-container {
    animation: galleryEntrance 0.5s ease-out both;
}

@keyframes galleryEntrance {
    from {
        opacity: 0;
        transform: scale(0.97);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

#gallery-page h2 {
    font-size: 2.5rem;
    color: #4a4e69;
    margin-bottom: 60px;
    text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.5);
}

/* ===== GALLERY LOADING CURTAIN ("Developing Memories") ===== */
.gallery-loader {
    position: absolute;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(253, 250, 253, 0.97) 0%, rgba(230, 230, 250, 0.98) 60%, rgba(255, 218, 235, 0.95) 100%);
    backdrop-filter: blur(12px);
    /* Cinematic reveal transition */
    opacity: 1;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
}

.gallery-loader.revealed {
    opacity: 0;
    pointer-events: none;
}

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}

/* Polaroid frame with glowing pulse */
.polaroid-frame {
    width: 100px;
    height: 120px;
    background: #fff;
    border-radius: 6px;
    box-shadow:
        0 8px 32px rgba(106, 76, 147, 0.25),
        0 0 60px rgba(255, 215, 0, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 8px 24px 8px;
    animation: polaroidFloat 2.5s ease-in-out infinite;
}

.polaroid-inner {
    width: 100%;
    flex: 1;
    border-radius: 3px;
    background: linear-gradient(135deg, rgba(186, 85, 211, 0.2) 0%, rgba(135, 206, 235, 0.25) 50%, rgba(255, 182, 193, 0.2) 100%);
    position: relative;
    overflow: hidden;
}

/* Shimmer sweep across the polaroid */
.polaroid-shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg,
            transparent 30%,
            rgba(255, 255, 255, 0.6) 45%,
            rgba(255, 215, 0, 0.25) 50%,
            rgba(255, 255, 255, 0.6) 55%,
            transparent 70%);
    transform: translateX(-100%);
    animation: shimmerSweep 2s ease-in-out infinite;
}

.polaroid-strip {
    width: 50%;
    height: 6px;
    margin-top: 8px;
    border-radius: 3px;
    background: linear-gradient(90deg, rgba(186, 85, 211, 0.3), rgba(255, 182, 193, 0.4), rgba(255, 215, 0, 0.3));
}

.loader-text {
    font-family: 'Varela Round', sans-serif;
    font-size: 1.15rem;
    color: #6a4c93;
    letter-spacing: 1px;
    animation: textPulse 2s ease-in-out infinite;
}

@keyframes polaroidFloat {

    0%,
    100% {
        transform: translateY(0) rotate(-2deg);
    }

    50% {
        transform: translateY(-12px) rotate(2deg);
    }
}

@keyframes shimmerSweep {
    0% {
        transform: translateX(-100%);
    }

    60% {
        transform: translateX(100%);
    }

    100% {
        transform: translateX(100%);
    }
}

@keyframes textPulse {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

.carousel-container {
    perspective: 1000px;
    width: 100%;
    max-width: 600px;
    height: 500px;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Contain layout/paint so carousel never triggers full-page recalc */
    contain: layout paint;
}

.carousel-stage {
    position: relative;
    width: 400px;
    height: 400px;
    transform-style: preserve-3d;
    animation: rotate3D 20s linear infinite;
    transition: animation-play-state 0.3s ease;
    /* GPU: promote to compositor layer */
    will-change: transform;
    transform: translateZ(0);
}

.carousel-stage.paused {
    animation-play-state: paused;
}

/* Freeze carousel whenever ANY grid image is hovered (via CSS :has() - bulletproof) */
.carousel-stage:has(.grid-image-wrapper:hover) {
    animation-play-state: paused !important;
}

/* CRITICAL: Also freeze carousel when the lightbox overlay is active (solves mouse-left issue) */
.carousel-stage:has(~.image-lightbox-overlay.active),
main:has(.image-lightbox-overlay.active) .carousel-stage {
    animation-play-state: paused !important;
}

/* 8 items positioned in a 3D circle */
.carousel-item {
    position: absolute;
    width: 180px;
    height: 180px;
    left: 50%;
    top: 50%;
    margin-left: -90px;
    margin-top: -90px;
    transform-style: preserve-3d;
    perspective: 1200px;
    cursor: pointer;
    transition: z-index 0.1s ease;
    /* CRITICAL: Allow images to overflow and break out of the panel */
    overflow: visible;
    z-index: 1;
    /* GPU: own compositor layer + skip rendering backside */
    will-change: transform;
    backface-visibility: hidden;
    /* Contain internal layout/paint to this element */
    contain: layout paint;
}

/* When any image inside is hovered, bring the entire panel to the front */
.carousel-item:has(.grid-image-wrapper:hover) {
    z-index: 999;
}

/* Position each panel at 45 degrees (360/8 = 45) */
.carousel-item:nth-child(1) {
    transform: rotateY(0deg) translateZ(250px);
}

.carousel-item:nth-child(2) {
    transform: rotateY(45deg) translateZ(250px);
}

.carousel-item:nth-child(3) {
    transform: rotateY(90deg) translateZ(250px);
}

.carousel-item:nth-child(4) {
    transform: rotateY(135deg) translateZ(250px);
}

.carousel-item:nth-child(5) {
    transform: rotateY(180deg) translateZ(250px);
}

.carousel-item:nth-child(6) {
    transform: rotateY(225deg) translateZ(250px);
}

.carousel-item:nth-child(7) {
    transform: rotateY(270deg) translateZ(250px);
}

.carousel-item:nth-child(8) {
    transform: rotateY(315deg) translateZ(250px);
}

/* 3x2 Grid Layout - 6 images per panel */
.image-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    width: 100%;
    height: 100%;
    gap: 4px;
    padding: 4px;
    box-sizing: border-box;
    transform-style: preserve-3d;
    perspective: 1200px;
    /* GPU: force hardware-accelerated compositing */
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
    contain: layout paint;
}

/* Individual image wrapper with proper overflow and z-index handling */
.grid-image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    /* Ensure visible placeholder even if image is broken */
    min-height: 60px;
    /* Allow the image to scale on hover */
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    /* Default z-index for grid images */
    z-index: 1;
    /* Elegant gradient fallback background */
    background: linear-gradient(135deg, rgba(186, 85, 211, 0.3) 0%, rgba(135, 206, 235, 0.3) 100%);
    border-radius: 8px;
    /* CRITICAL: Preserve 3D context for child transforms */
    transform-style: preserve-3d;
    perspective: 1200px;
    /* Enable pointer events at this level */
    pointer-events: auto;
    /* Subtle transition for visual feedback */
    transition: background 0.3s ease, box-shadow 0.3s ease;
    /* GPU: own layer + skip backface rendering */
    will-change: transform;
    backface-visibility: hidden;
    contain: layout paint;
}

.grid-image-wrapper:hover {
    background: linear-gradient(135deg, rgba(186, 85, 211, 0.5) 0%, rgba(135, 206, 235, 0.5) 100%);
    /* Subtle glow on hover */
    box-shadow: inset 0 0 12px rgba(186, 85, 211, 0.4);
}

.grid-image-wrapper img {
    width: 100%;
    height: 100%;
    min-height: 60px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    /* Subtle hover scale */
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.3s ease, opacity 0.4s ease;
    filter: brightness(1);
    /* Gradient-first: images start transparent and fade in once decoded */
    opacity: 0;
    transform: scale(1);
    backface-visibility: hidden;
    will-change: transform;
    /* Hide broken image icons and text */
    color: transparent;
    font-size: 0;
    /* Ensure visible placeholder background shows through */
    background: linear-gradient(135deg, rgba(186, 85, 211, 0.4) 0%, rgba(135, 206, 235, 0.4) 100%);
    /* Enable 3D transforms on the image */
    transform-style: preserve-3d;
    /* Set scale origin to center for proper pop-out effect */
    transform-origin: center center;
    /* Allow the image to interact with user input */
    pointer-events: auto;
}

/* Images fade in once loaded/decoded — gradient placeholder shows first */
.grid-image-wrapper img[src]:not([src=""]) {
    opacity: 1;
}

/* Subtle hover effect on grid images */
.grid-image-wrapper:hover img {
    transform: scale(1.08);
    filter: brightness(1.1);
}

/* ===== CINEMATIC LIGHTBOX OVERLAY SYSTEM (Decoupled Architecture) =====
   The lightbox is now a stable, fixed-position overlay completely separate from the 3D carousel.
   This eliminates hit-box collision issues entirely. The overlay is hidden by default and
   becomes visible (with smooth fade) when a grid image is hovered. */

.image-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Hidden by default - CRITICAL: Both visibility AND pointer-events must be disabled */
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    /* Smooth fade in/out */
    transition: opacity 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* When active: fully visible and interactive */
.image-lightbox-overlay.active {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

/* Dimming background */
.lightbox-dim {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    /* Smooth fade for the dim */
    transition: background 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    /* Allow clicking through dim to close */
    cursor: pointer;
}

/* Dim becomes visible when overlay is active */
.image-lightbox-overlay.active .lightbox-dim {
    background: rgba(0, 0, 0, 0.75);
}

/* Image wrapper - centered in the viewport */
.lightbox-image-wrapper {
    position: relative;
    z-index: 10000;
    /* CRITICAL: pointer-events must be none by default to avoid blocking clicks */
    pointer-events: none;
    margin: auto;
    /* Scale up smoothly when overlay becomes active */
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    /* Subtle scale: starts slightly smaller, grows to normal */
    transform: scale(0.9);
}

/* When overlay is active, image becomes interactive and scales to normal */
.image-lightbox-overlay.active .lightbox-image-wrapper {
    pointer-events: auto;
    transform: scale(1);
}

.lightbox-image-wrapper img {
    display: block;
    max-width: 70vw;
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 16px;
    box-shadow:
        0 30px 100px rgba(0, 0, 0, 0.8),
        0 0 80px rgba(255, 215, 0, 0.3),
        inset 0 1px 0px rgba(255, 255, 255, 0.1);
    /* Prevent flickering */
    backface-visibility: hidden;
    will-change: transform;
    /* Hide broken image icons */
    color: transparent;
    font-size: 0;
}

/* 3D Rotation animation */
@keyframes rotate3D {
    from {
        transform: rotateY(0deg);
    }

    to {
        transform: rotateY(360deg);
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .carousel-container {
        max-width: 400px;
        height: 400px;
    }

    .carousel-stage {
        width: 280px;
        height: 280px;
    }

    .carousel-item {
        width: 140px;
        height: 140px;
        margin-left: -70px;
        margin-top: -70px;
    }

    .carousel-item:nth-child(1) {
        transform: rotateY(0deg) translateZ(180px);
    }

    .carousel-item:nth-child(2) {
        transform: rotateY(45deg) translateZ(180px);
    }

    .carousel-item:nth-child(3) {
        transform: rotateY(90deg) translateZ(180px);
    }

    .carousel-item:nth-child(4) {
        transform: rotateY(135deg) translateZ(180px);
    }

    .carousel-item:nth-child(5) {
        transform: rotateY(180deg) translateZ(180px);
    }

    .carousel-item:nth-child(6) {
        transform: rotateY(225deg) translateZ(180px);
    }

    .carousel-item:nth-child(7) {
        transform: rotateY(270deg) translateZ(180px);
    }

    .carousel-item:nth-child(8) {
        transform: rotateY(315deg) translateZ(180px);
    }

    /* Adjust grid gap for smaller screens */
    .image-grid {
        gap: 3px;
        padding: 3px;
    }

    .grid-image-wrapper img {
        border-radius: 6px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }

    .grid-image-wrapper:hover img {
        transform: scale(1.5) translateZ(60px);
        box-shadow: 0 15px 45px rgba(255, 215, 0, 0.5), 0 6px 20px rgba(255, 100, 150, 0.3);
        border: 2px solid #ffd700;
    }

    #gallery-page h2 {
        font-size: 2rem;
        margin-bottom: 40px;
    }
}

@media (max-width: 480px) {
    .carousel-container {
        max-width: 300px;
        height: 300px;
    }

    .carousel-stage {
        width: 220px;
        height: 220px;
    }

    .carousel-item {
        width: 110px;
        height: 110px;
        margin-left: -55px;
        margin-top: -55px;
    }

    .carousel-item:nth-child(1) {
        transform: rotateY(0deg) translateZ(140px);
    }

    .carousel-item:nth-child(2) {
        transform: rotateY(45deg) translateZ(140px);
    }

    .carousel-item:nth-child(3) {
        transform: rotateY(90deg) translateZ(140px);
    }

    .carousel-item:nth-child(4) {
        transform: rotateY(135deg) translateZ(140px);
    }

    .carousel-item:nth-child(5) {
        transform: rotateY(180deg) translateZ(140px);
    }

    .carousel-item:nth-child(6) {
        transform: rotateY(225deg) translateZ(140px);
    }

    .carousel-item:nth-child(7) {
        transform: rotateY(270deg) translateZ(140px);
    }

    .carousel-item:nth-child(8) {
        transform: rotateY(315deg) translateZ(140px);
    }

    /* Smaller grid for mobile */
    .image-grid {
        gap: 2px;
        padding: 2px;
    }

    .grid-image-wrapper img {
        border-radius: 4px;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    }

    .grid-image-wrapper:hover img {
        transform: scale(1.4) translateZ(50px);
        box-shadow: 0 10px 30px rgba(255, 215, 0, 0.4), 0 4px 15px rgba(255, 100, 150, 0.25);
        border: 2px solid #ffd700;
    }

    #gallery-page h2 {
        font-size: 1.5rem;
        margin-bottom: 30px;
    }
}

/* ===== GAME PAGE STYLES ===== */

.map-container {
    position: relative;
    width: 100%;
    max-width: 900px;
    height: 60vh;
    min-height: 400px;
    margin: 80px auto 150px auto;
}

#game-page {
    padding-top: 80px;
    padding-bottom: 120px;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
}

.map-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.station {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #4a3623;
    border: 3px solid #d4af37;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    cursor: pointer;
    z-index: 2;
    font-size: 1.2rem;
    transform: translate(-50%, -50%);
    transition: transform 0.2s, box-shadow 0.2s;
}

.station:hover {
    transform: translate(-50%, -50%) scale(1.2);
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.7);
}

.station.locked {
    filter: grayscale(1);
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: auto;
}

.station.locked:hover {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: none;
}

.station.locked::after {
    content: '🔒';
    position: absolute;
    top: -15px;
    right: -10px;
    font-size: 1rem;
}

.station[data-station="1"] {
    top: 5%;
    left: 15%;
}

.station[data-station="2"] {
    top: 10%;
    left: 50%;
}

.station[data-station="3"] {
    top: 20%;
    left: 85%;
}

.station[data-station="4"] {
    top: 35%;
    left: 75%;
}

.station[data-station="5"] {
    top: 40%;
    left: 45%;
}

.station[data-station="6"] {
    top: 45%;
    left: 15%;
}

.station[data-station="7"] {
    top: 60%;
    left: 20%;
}

.station[data-station="8"] {
    top: 65%;
    left: 55%;
}

.station[data-station="9"] {
    top: 75%;
    left: 85%;
}

.station[data-station="10"] {
    top: 88%;
    left: 50%;
}

.station-label {
    position: absolute;
    font-weight: bold;
    color: #4a3623;
    font-size: 1.2rem;
    white-space: nowrap;
    z-index: 5;
}

.start-label {
    position: absolute;
    top: -60px;
    left: 15%;
    transform: translateX(-50%);
    z-index: 5;
    font-size: 1.4rem;
    font-weight: bold;
    width: max-content;
}

.end-label {
    position: absolute;
    top: 95%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    font-size: 1.4rem;
    font-weight: bold;
    width: max-content;
    margin-top: 0;
}

.noya-car {
    position: absolute;
    width: 100px;
    z-index: 10;
    left: 5%;
    /* Default: start-node position, far left of Station 1 */
    top: 10%;
    /* Default: start-node position, clearly separated from Station 1 */
    transition: left 0.8s ease-in-out, top 0.8s ease-in-out;
    transform: translate(-50%, -50%) scaleX(-1);
    pointer-events: none !important;
    /* CRITICAL: Car must not steal clicks from stations */
}

/* Car faces RIGHT (scaleX is -1 to flip from source facing LEFT) */
.noya-car.facing-right {
    transform: translate(-50%, -50%) scaleX(-1);
}

/* Car faces LEFT (scaleX is 1, original source orientation) */
.noya-car.facing-left {
    transform: translate(-50%, -50%) scaleX(1);
}

/* Start Node - Invisible anchor, sits at the visual start of the SVG dashed path */
#start-node {
    position: absolute;
    left: 15%;
    top: 15%;
    width: 20px;
    height: 20px;
    opacity: 0;
    pointer-events: none;
}

.undo-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    background: #6a4c93;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 20;
}

.undo-btn:hover {
    background: #5a3c83;
}

/* ===== CLUES PAGE STYLES ===== */

.chests-grid {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    flex-wrap: nowrap;
    width: 100%;
    margin-top: 40px;
}

.chest-item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 15px;
    box-shadow: none;
}

.chest-item.locked {
    opacity: 0.5;
    filter: grayscale(1);
    cursor: not-allowed;
    pointer-events: none;
}

.chest-item.locked .chest-img {
    filter: blur(3px);
}

.chest-item.locked h3 {
    filter: blur(2px);
}

.chest-item.unlocked {
    opacity: 1;
    filter: grayscale(0);
    cursor: pointer !important;
    pointer-events: auto !important;
}

/* Smooth transition when unlocking */
@keyframes unlockChest {
    from {
        opacity: 0.5;
        filter: grayscale(1);
    }

    to {
        opacity: 1;
        filter: grayscale(0);
    }
}

.chest-item.unlocking {
    animation: unlockChest 0.6s ease-out forwards;
}

.lock-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    opacity: 1;
    transition: opacity 0.4s ease;
    z-index: 10;
}

.chest-item.unlocked .lock-icon {
    opacity: 0;
    pointer-events: none;
}

.chest-item.unlocked .chest-img {
    filter: blur(0px);
}

.chest-item.unlocked h3 {
    filter: blur(0px);
}

/* ===== OPENED CHEST STATE ===== */
.chest-item.opened {
    background: rgba(212, 175, 55, 0.15);
    border-color: rgba(212, 175, 55, 0.5);
}

.chest-item.opened::before {
    content: '✓';
    position: absolute;
    top: 5px;
    right: 8px;
    font-size: 1.5rem;
    color: #d4af37;
    font-weight: bold;
    text-shadow: 0 0 8px rgba(212, 175, 55, 0.8);
}

/* ===== MAGICAL UNLOCK ANIMATION ===== */
@keyframes magicalUnlock {
    0% {
        opacity: 0.5;
        filter: grayscale(1);
        transform: scale(1);
        box-shadow: none;
    }

    30% {
        transform: scale(0.95);
        filter: grayscale(0.8);
    }

    50% {
        transform: scale(1.15);
        filter: grayscale(0);
        box-shadow: 0 0 30px 10px rgba(255, 215, 0, 0.8),
            0 0 50px 20px rgba(255, 215, 0, 0.4);
        opacity: 1;
    }

    60% {
        transform: scale(1.12) rotate(-2deg);
    }

    70% {
        transform: scale(1.13) rotate(2deg);
    }

    85% {
        transform: scale(1.08) rotate(-1deg);
    }

    100% {
        opacity: 1;
        filter: grayscale(0);
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
    }
}

.chest-item.unlock-anim {
    animation: magicalUnlock 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.chest-img {
    width: 150px;
    height: auto;
    cursor: pointer;
    transition: transform 0.2s;
    margin-bottom: 10px;
}

.chest-img:hover {
    transform: scale(1.1);
}

.chest-item h3 {
    font-weight: bold;
    color: #6a4c93;
    font-size: 1rem;
    margin: 0;
    padding: 0;
}

/* ===== CLUE MODAL (SCROLL) STYLES ===== */

.clue-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    display: none !important;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
    pointer-events: none !important;
    visibility: hidden !important;
}

.clue-modal-overlay.active {
    display: flex !important;
    pointer-events: auto !important;
    visibility: visible !important;
}

.scroll-container {
    width: 600px;
    height: 750px;
    background-image: url('assets/scroll.png');
    background-size: 100% 100% !important;
    background-color: transparent !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    border: none !important;
    box-shadow: none !important;
    position: relative;
    animation: slideIn 0.4s ease;
}

.scroll-close-btn {
    position: absolute;
    right: 180px;
    top: 165px;
    background: transparent;
    border: none;
    color: #4a3623;
    font-size: 1.6rem;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
    font-weight: bold;
}

.scroll-close-btn:hover {
    color: #d32f2f;
    opacity: 0.8;
}

.scroll-content-area {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 260px;
    top: 160px;
    bottom: 140px;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    align-items: center;
    text-align: center;
}

.clue-text {
    font-family: 'Times New Roman', serif;
    font-size: 1.1rem;
    color: #4a3623;
    font-weight: bold;
    line-height: 1.5;
    margin: 0;
    padding: 0 10px;
    word-wrap: break-word;
}

.scroll-btn {
    background: linear-gradient(135deg, #d4af37 0%, #c9a227 100%);
    color: #4a3623;
    border: none;
    padding: 12px 28px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

.scroll-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 18px rgba(212, 175, 55, 0.5);
}

/* ===== HINT SELECTION MODAL ===== */
.hint-selection-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2500;
    display: none !important;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
    pointer-events: none !important;
    visibility: hidden !important;
}

.hint-selection-overlay.active {
    display: flex !important;
    pointer-events: auto !important;
    visibility: visible !important;
}

.hint-selection-popup {
    background: linear-gradient(135deg, rgba(75, 0, 130, 0.95) 0%, rgba(138, 43, 226, 0.95) 100%);
    border: 2px solid #d4af37;
    border-radius: 20px;
    padding: 40px 50px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
}

.selection-title {
    font-family: 'Varela Round', sans-serif;
    font-size: 1.8rem;
    color: #ffd700;
    margin: 0 0 20px 0;
    font-weight: bold;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
}

.selection-subtitle {
    font-family: 'Varela Round', sans-serif;
    font-size: 1.1rem;
    color: #e0c3fc;
    margin: 0 0 30px 0;
    font-weight: normal;
}

.stage-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 15px;
    margin-bottom: 10px;
}

.stage-btn {
    background: linear-gradient(135deg, #ffc0cb 0%, #ff69b4 100%);
    color: #fff;
    border: 2px solid #ff1493;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(255, 105, 180, 0.3);
    font-family: 'Varela Round', sans-serif;
}

.stage-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(255, 105, 180, 0.5);
    background: linear-gradient(135deg, #ff69b4 0%, #ff1493 100%);
}

.stage-btn:active {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(255, 105, 180, 0.4);
}

/* ===== SCROLL BACKGROUND STYLING ===== */
.scroll-background {
    width: 100%;
    height: 100%;
    background-size: 100% 100% !important;
    background-color: transparent !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    border: none !important;
    box-shadow: none !important;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* ===== ANIMATIONS ===== */
@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.cyber-trigger-btn {
    background: linear-gradient(135deg, #2d6a2d 0%, #1e4d1e 100%);
    color: #00ff88;
    border: 2px solid #00ff88;
    padding: 12px 28px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 255, 136, 0.25);
    margin-top: 10px;
}

.cyber-trigger-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 255, 136, 0.5);
    background: linear-gradient(135deg, #3a8a3a 0%, #2d6a2d 100%);
}

/* Cyber Modal */
.cyber-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    z-index: 3000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
    /* CRITICAL: Prevent pointer events when hidden */
    pointer-events: none;
    visibility: hidden;
}

.cyber-modal.active {
    display: flex;
    pointer-events: auto;
    visibility: visible;
}

.cyber-modal .cyber-content {
    background: #0a0e27;
    border: 3px solid #ff00ff;
    border-radius: 10px;
    padding: 40px;
    max-width: 450px;
    width: 90%;
    position: relative;
    box-shadow: 0 0 30px rgba(255, 0, 255, 0.5), inset 0 0 30px rgba(255, 0, 255, 0.1);
    animation: slideIn 0.4s ease;
}

.cyber-content::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    background: linear-gradient(45deg, #ff00ff, #00ffff, #ff00ff);
    border-radius: 10px;
    z-index: -1;
    animation: glow 2s infinite;
}

.cyber-title {
    color: #00ffff;
    font-family: 'Courier New', monospace;
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 30px;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.7);
    font-weight: bold;
}

.cyber-input {
    width: 100%;
    padding: 12px;
    background: #1a1f3a;
    border: 2px solid #00ffff;
    color: #00ffff;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    border-radius: 5px;
    margin: 15px 0;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.cyber-input:focus {
    outline: none;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.7);
}

.cyber-input::placeholder {
    color: #00ffff;
    opacity: 0.5;
}

.cyber-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #ff00ff 0%, #00ffff 100%);
    border: none;
    color: #0a0e27;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(255, 0, 255, 0.5);
}

.cyber-btn:hover {
    box-shadow: 0 0 25px rgba(255, 0, 255, 0.8);
    transform: scaleX(1.05);
}

.cyber-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: 2px solid #ff00ff;
    color: #ff00ff;
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cyber-close-btn:hover {
    background: #ff00ff;
    color: #0a0e27;
}

/* Cyber Window - Station Password Input - SAFE DISPLAY TOGGLING */
.cyber-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: none !important;
    align-items: center;
    justify-content: center;
    /* CRITICAL: Prevent pointer events when hidden */
    pointer-events: none;
    visibility: hidden;
}

.cyber-overlay.active {
    display: flex !important;
    pointer-events: auto;
    visibility: visible;
}

.cyber-content-window {
    border: 2px solid #0f0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    color: #0f0;
    font-family: 'Courier New', monospace;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 0 20px #0f0, inset 0 0 20px rgba(0, 255, 0, 0.1);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.cyber-content-window h3 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    text-shadow: 0 0 10px #0f0;
}

.cyber-content-window p {
    font-size: 1rem;
    margin: 10px 0;
}

.cyber-content-window input {
    background: #111;
    color: #0f0;
    border: 1px solid #0f0;
    padding: 10px 15px;
    margin: 15px 0;
    margin-bottom: 20px;
    font-size: 1.2rem;
    width: 100%;
    box-sizing: border-box;
    font-family: 'Courier New', monospace;
    text-align: center;
}

.cyber-content-window input:focus {
    outline: none;
    box-shadow: 0 0 10px #0f0;
}

.cyber-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.cyber-buttons button {
    position: relative;
    background: #0f0;
    color: #000;
    border: none;
    padding: 12px 30px;
    font-weight: bold;
    cursor: pointer;
    margin: 5px;
    font-size: 1.1rem;
    border-radius: 5px;
    min-width: 120px;
    transition: all 0.2s ease;
}

/* Invisible hitbox expansion — 15px larger than visual button in all directions */
.cyber-buttons button::after {
    content: '';
    position: absolute;
    top: -15px;
    bottom: -15px;
    left: -15px;
    right: -15px;
}

.cyber-buttons button:active {
    transform: scale(0.95);
}

.cyber-buttons button:hover {
    background: #00ff00;
    box-shadow: 0 0 10px #0f0;
}

.error-msg {
    color: #ff0000;
    font-weight: bold;
    margin-top: 15px;
    text-shadow: 0 0 5px #ff0000;
}

/* Modal Pointer Events automatically handled by CSS above (no inline style hacks needed) */

/* Toast Notification */
.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 107, 107, 0.95);
    color: white;
    padding: 20px 30px;
    border-radius: 10px;
    font-weight: bold;
    z-index: 3000;
    display: flex;
    align-items: center;
    gap: 15px;
    animation-duration: 0.3s;
    animation-timing-function: ease;
    max-width: 400px;
    box-shadow: 0 8px 24px rgba(255, 107, 107, 0.4);
}

.toast.show {
    animation: slideUp 0.3s ease forwards;
}

.toast img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}

/* Toast Notification Styling */
#toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #6a4c93;
    /* Purple theme color */
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    font-weight: bold;
    z-index: 1000000 !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: opacity 0.5s ease, transform 0.5s ease;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    max-width: 90%;
    word-wrap: break-word;
}

#toast img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 50%;
    flex-shrink: 0;
}

.toast-hidden {
    opacity: 0;
    transform: translate(-50%, 20px) !important;
    visibility: hidden;
}

.toast-visible {
    opacity: 1;
    transform: translate(-50%, 0) !important;
    visibility: visible;
}

/* Toast Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideUp {
    from {
        bottom: -100px;
        opacity: 0;
    }

    to {
        bottom: 30px;
        opacity: 1;
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

@keyframes glow {

    0%,
    100% {
        box-shadow: 0 0 10px rgba(255, 0, 255, 0.5);
    }

    50% {
        box-shadow: 0 0 30px rgba(255, 0, 255, 1);
    }
}

/* --- Custom Auto-Hide Scrollbar --- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 10px;
}

/* Show scrollbar thumb when hovering over the body or game page */
body:hover ::-webkit-scrollbar-thumb,
#game-page:hover ::-webkit-scrollbar-thumb {
    background: rgba(106, 76, 147, 0.4);
    /* Light purple */
}

/* Darker color when explicitly hovering over the scrollbar thumb */
::-webkit-scrollbar-thumb:hover {
    background: rgba(106, 76, 147, 0.9);
    /* Solid purple */
}

/* ===== BLESSING ANIMATION OVERLAY ===== */
#blessing-anim {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(106, 76, 147, 0.9);
    z-index: 99999;
}

.blessing-hidden {
    display: none !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none !important;
    z-index: -1;
}

.blessing-visible {
    display: flex !important;
    opacity: 1;
    visibility: visible;
    pointer-events: auto !important;
    z-index: 99999;
}

.blessing-text {
    color: #fff;
    font-family: 'Varela Round', sans-serif;
    font-size: clamp(2rem, 8vw, 5rem);
    text-align: center;
    animation: popIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* The Confetti must be the absolute top layer */
#confetti-canvas,
.celebration-overlay {
    z-index: 999999 !important;
    pointer-events: none !important;
}

/* ===== CELEBRATION OVERLAY ===== */
.celebration-overlay {
    position: absolute;
    inset: 0;
    z-index: 5000;
    pointer-events: none;
    border-radius: inherit;
    animation: celebFadeOut 0.6s ease forwards;
    animation-delay: 2.2s;
}

@keyframes celebFadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* Pulsing glow on all stations during celebration */
.station.celebrating {
    animation: stationGlow 0.6s ease-in-out infinite alternate;
}

@keyframes stationGlow {
    from {
        box-shadow: 0 0 6px 2px rgba(212, 175, 55, 0.5);
        transform: translate(-50%, -50%) scale(1);
    }

    to {
        box-shadow: 0 0 22px 8px rgba(212, 175, 55, 0.95), 0 0 40px 12px rgba(156, 39, 176, 0.5);
        transform: translate(-50%, -50%) scale(1.18);
    }
}

/* ===== PARTICLE DUST — golden-lavender sparkles from car & stations ===== */
.particle-dust {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 15;
    animation: particleFloat 1.6s ease-out forwards;
}

.particle-dust.gold {
    background: radial-gradient(circle, #ffd700 30%, rgba(212, 175, 55, 0) 100%);
    box-shadow: 0 0 6px 2px rgba(255, 215, 0, 0.5);
}

.particle-dust.lavender {
    background: radial-gradient(circle, #c8a0e8 30%, rgba(200, 160, 232, 0) 100%);
    box-shadow: 0 0 6px 2px rgba(200, 160, 232, 0.4);
}

.particle-dust.white {
    background: radial-gradient(circle, #fff 30%, rgba(255, 255, 255, 0) 100%);
    box-shadow: 0 0 4px 1px rgba(255, 255, 255, 0.5);
}

@keyframes particleFloat {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }

    60% {
        opacity: 0.7;
    }

    100% {
        opacity: 0;
        transform: translate(var(--dx), var(--dy)) scale(0.2);
    }
}

/* ===== PRIZE OVERLAY DISMISS BUTTON ===== */
.prize-dismiss-btn {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 3rem;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    border: 1.5px solid rgba(212, 175, 55, 0.5);
    color: #ffd700;
    font-family: 'Varela Round', sans-serif;
    font-size: 1rem;
    font-weight: bold;
    padding: 10px 28px;
    border-radius: 30px;
    cursor: pointer;
    z-index: 20005;
    opacity: 0;
    transition: opacity 0.6s ease 2.5s, background 0.2s;
    pointer-events: none;
}

.prize-dismiss-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

.prize-dismiss-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ===== PRIZE REWARD OVERLAY ===== */
#prize-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(45, 0, 77, 0.4);
    backdrop-filter: blur(15px);
    z-index: 20000;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    transition: opacity 0.5s;
    /* CRITICAL: pointer-events: none when NOT active */
    pointer-events: none;
    visibility: hidden;
    padding-bottom: 12vh;
}

#prize-overlay.hidden {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

/* When showing prize, enable pointer events */
#prize-overlay.active {
    pointer-events: auto;
    visibility: visible;
}

.prize-wrapper {
    position: relative;
    text-align: center;
}

.gift-img {
    width: min(350px, 50vw);
    max-height: 42vh;
    height: auto;
    transition: transform 0.3s, opacity 0.3s;
    cursor: pointer;
    object-fit: contain;
}

.gift-img.hidden {
    display: none !important;
}

/* --- Prize Reward Animations --- */

/* Drop-Down Animation */
@keyframes giftDrop {
    0% {
        transform: translateY(-100%) scale(0.5);
        opacity: 0;
    }

    80% {
        transform: translateY(10%) scale(1.1);
    }

    100% {
        transform: translateY(0%) scale(1);
        opacity: 1;
    }
}

.animation-close-envelope {
    animation: giftDrop 1.2s ease-out forwards;
}

/* Shake Animation */
@keyframes giftShake {

    0%,
    100% {
        transform: rotate(0deg);
    }

    20% {
        transform: rotate(5deg);
    }

    40% {
        transform: rotate(-5deg);
    }

    60% {
        transform: rotate(3deg);
    }

    80% {
        transform: rotate(-3deg);
    }
}

.animation-shake {
    animation: giftShake 0.6s ease-in-out forwards;
}

/* Premium Golden-Lavender Light Rays — massive diffused radiant bloom */
.light-rays {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-radius: 50%;
    background:
        radial-gradient(circle, rgba(255, 255, 255, 0.5) 0%, transparent 40%),
        radial-gradient(circle, rgba(255, 215, 0, 0.22) 0%, rgba(255, 255, 255, 0.08) 35%, transparent 60%),
        radial-gradient(circle, rgba(200, 170, 240, 0.25) 0%, rgba(180, 160, 220, 0.08) 40%, transparent 65%),
        radial-gradient(ellipse at 30% 40%, rgba(255, 215, 0, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 60%, rgba(200, 160, 230, 0.12) 0%, transparent 50%);
    box-shadow:
        0 0 60px 30px rgba(255, 215, 0, 0.25),
        0 0 120px 60px rgba(200, 160, 230, 0.15),
        0 0 200px 100px rgba(255, 215, 0, 0.08),
        0 0 300px 150px rgba(180, 140, 220, 0.06);
    opacity: 0;
    transition: width 1.4s ease-out, height 1.4s ease-out, opacity 1.2s ease-out;
    pointer-events: none;
    z-index: 20001;
    animation: raysBreath 3s ease-in-out infinite paused;
}

.light-rays.reveal-light {
    width: 700px;
    height: 700px;
    opacity: 1;
    animation-play-state: running;
}

@keyframes raysBreath {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.08);
        opacity: 0.85;
    }
}

/* Dynamic Image Voucher — pops up and scales from the open envelope */
.prize-voucher-img {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%) scale(0.5);
    width: min(420px, 62vw);
    max-height: 55vh;
    height: auto;
    opacity: 0;
    transition: top 1s ease-out 0.8s, transform 1s ease-out 0.8s, opacity 0.8s ease-out 0.6s, width 1s ease-out 0.8s;
    z-index: 20002;
    object-fit: contain;
    pointer-events: none;
    /* Premium golden frame */
    border: 3px solid #d4af37;
    border-radius: 14px;
    box-shadow:
        0 0 0 2px rgba(212, 175, 55, 0.4),
        0 8px 32px rgba(0, 0, 0, 0.35),
        0 0 20px 4px rgba(212, 175, 55, 0.15);
    background: #fffef8;
}

.prize-voucher-img.hidden {
    display: none !important;
}

.prize-voucher-img.voucher-pop-and-scale {
    top: -50%;
    transform: translateX(-50%) scale(1);
    width: min(520px, 78vw);
    opacity: 1;
    box-shadow:
        0 0 0 3px rgba(212, 175, 55, 0.6),
        0 12px 48px rgba(0, 0, 0, 0.4),
        0 0 30px 8px rgba(212, 175, 55, 0.25),
        0 0 60px 16px rgba(200, 180, 230, 0.12);
}

#reveal-effects.hidden {
    display: none !important;
}

/* ===== BLESSING LOCK OVERLAY: IMAGE-BASED HEART LOCK ===== */
.blessing-lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

    /* === HEAVY BLUR BACKDROP + PURPLE TINT === */
    background-color: rgba(100, 30, 120, 0.5);
    backdrop-filter: blur(25px) saturate(110%);
    -webkit-backdrop-filter: blur(25px) saturate(110%);

    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    animation: lockFadeIn 0.8s ease-out;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
        display 0.8s ease-out,
        pointer-events 0.8s ease-out,
        backdrop-filter 1.5s ease-out,
        background-color 1.5s ease-out;
}

.blessing-lock-overlay.unlocked {
    opacity: 0;
    pointer-events: none;
    display: none;
}

.blessing-lock-overlay.disappearing {
    animation: lockDisappear 1.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.lock-container {
    text-align: center;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    z-index: 101;
}

/* === LOCK UNIT: Image and Animations === */
.heart-lock-unit {
    position: relative;
    width: 300px;
    height: 300px;
    animation: lockGentlePulse 3s ease-in-out infinite;
}

.lock-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 20px rgba(212, 175, 55, 0.3));
    transition: transform 0.3s ease, filter 0.3s ease;
    cursor: pointer;
}

/* Hover rattle animation */
.heart-lock-unit:hover .lock-image {
    animation: lockRattle 0.6s ease-in-out;
    filter: drop-shadow(0 0 30px rgba(212, 175, 55, 0.8));
}

/* === LOCK TEXT === */
.lock-text {
    font-family: 'Varela Round', serif;
    font-size: 1.9rem;
    color: #ffffff;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-shadow:
        0 0 20px rgba(157, 78, 221, 0.6),
        0 0 40px rgba(157, 78, 221, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.5);
    animation: textFadeIn 0.9s ease-out 0.3s both;
    margin-top: 10px;
    padding: 15px 25px;
    background: rgba(100, 30, 120, 0.4);
    border-radius: 15px;
    backdrop-filter: blur(8px);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
}

/* ===== ANIMATIONS ===== */
@keyframes lockFadeIn {
    from {
        opacity: 0;
        transform: scale(0.85) translateY(30px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes lockGentlePulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.03);
    }
}

@keyframes lockRattle {

    0%,
    100% {
        transform: translateX(0) rotate(0deg) scale(1.05);
    }

    10% {
        transform: translateX(-5px) rotate(-1deg) scale(1.06);
    }

    20% {
        transform: translateX(5px) rotate(1deg) scale(1.06);
    }

    30% {
        transform: translateX(-3px) rotate(-0.5deg) scale(1.055);
    }

    40% {
        transform: translateX(3px) rotate(0.5deg) scale(1.055);
    }

    50% {
        transform: translateX(0) rotate(0deg) scale(1.05);
    }

    60% {
        transform: translateX(-2px) rotate(-0.3deg) scale(1.052);
    }

    80% {
        transform: translateX(1px) rotate(0.2deg) scale(1.051);
    }
}

@keyframes lockDisappear {
    0% {
        opacity: 1;
        transform: scale(1);
        filter: brightness(1) blur(0px);
        backdrop-filter: blur(25px);
        background-color: rgba(100, 30, 120, 0.5);
    }

    30% {
        opacity: 1;
        transform: scale(1.1);
        filter: brightness(1.1) blur(0px);
        backdrop-filter: blur(25px);
    }

    60% {
        opacity: 0.5;
        transform: scale(0.95);
        filter: brightness(0.9) blur(5px);
        backdrop-filter: blur(15px);
        background-color: rgba(100, 30, 120, 0.35);
    }

    100% {
        opacity: 0;
        transform: scale(0.5);
        filter: brightness(0.5) blur(10px);
        backdrop-filter: blur(0px);
        background-color: rgba(100, 30, 120, 0);
        pointer-events: none;
    }
}

@keyframes textFadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* Particle burst container - PREMIUM */
.particle-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 102;
}

/* Lock unlock particle burst */
.blessing-lock-overlay.disappearing .particle-container {
    animation: particleBurstField 0.8s ease-out forwards;
}

@keyframes particleBurstField {
    0% {
        opacity: 1;
        filter: brightness(1);
    }

    100% {
        opacity: 0;
        filter: brightness(0.5);
    }
}

/* ===== STAGE SELECTION MODAL: DELICATE GLASSMORPHISM ===== */

.stage-selection-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;

    /* Light pastel gradient background */
    background: linear-gradient(135deg, #f0e8fa 0%, #f5f0ff 50%, #ede0f8 100%);

    /* Animation on entry */
    animation: stageOverlayFadeIn 0.3s ease-out;
}

.stage-selection-overlay.hidden {
    display: none !important;
}

@keyframes stageOverlayFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Delicate Glassmorphism Panel */
.stage-selection-panel {
    position: relative;
    background: rgba(250, 245, 255, 0.85);
    backdrop-filter: blur(15px);
    border-radius: 25px;
    border: 1.5px solid rgba(255, 255, 255, 0.6);
    padding: 40px 35px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    animation: stagePanelSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes stagePanelSlideIn {
    from {
        transform: translateY(-25px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.stage-selection-title {
    font-size: 1.8rem;
    font-weight: 600;
    color: #6b4c9a;
    text-align: center;
    margin-bottom: 30px;
    letter-spacing: -0.3px;
}

/* Stage Grid: Clean 5x2 layout */
.stage-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 25px;
}

/* Stage Buttons: Soft Pastel Pink & Purple */
.stage-btn {
    position: relative;
    padding: 16px 12px;
    border-radius: 14px;
    border: 1.5px solid rgba(220, 180, 240, 0.4);
    background: linear-gradient(135deg, rgba(255, 200, 230, 0.5), rgba(220, 190, 240, 0.5));
    color: #6b4c9a;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 6px 15px rgba(200, 120, 200, 0.12);

    /* Hover effect: lift and glow */
    &:hover {
        transform: translateY(-3px);
        background: linear-gradient(135deg, rgba(255, 200, 230, 0.7), rgba(220, 190, 240, 0.7));
        box-shadow: 0 10px 25px rgba(200, 120, 200, 0.2);
        border-color: rgba(220, 180, 240, 0.6);
    }

    /* Active state: press down */
    &:active {
        transform: translateY(-1px);
        box-shadow: 0 4px 10px rgba(200, 120, 200, 0.15);
    }
}

/* Cancel/Close Button */
.stage-close-btn {
    display: block;
    margin: 0 auto;
    padding: 11px 28px;
    border-radius: 18px;
    border: 1.5px solid rgba(200, 150, 220, 0.3);
    background: rgba(220, 200, 240, 0.3);
    color: #6b4c9a;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    min-width: 140px;
    backdrop-filter: blur(8px);
}

.stage-close-btn:hover {
    background: rgba(220, 200, 240, 0.5);
    border-color: rgba(200, 150, 220, 0.5);
    transform: scale(1.03);
}

.stage-close-btn:active {
    transform: scale(0.98);
}

/* Responsive Design */
@media (max-width: 600px) {
    .stage-selection-panel {
        padding: 30px 25px;
        border-radius: 20px;
    }

    .stage-selection-title {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }

    .stage-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 10px;
        margin-bottom: 20px;
    }

    .stage-btn {
        padding: 12px 8px;
        font-size: 0.9rem;
        border-radius: 12px;
    }

    .stage-close-btn {
        padding: 9px 20px;
        font-size: 0.9rem;
    }
}

/* ===== SEQUENTIAL UNLOCKING: Visual States for Hints Room ===== */

/* Locked state: Chest waiting for previous hint to be assigned */
.chest-item.sequence-locked {
    opacity: 0.5;
    filter: grayscale(100%) brightness(0.9);
    transition: all 0.3s ease;
    cursor: not-allowed;
}

.chest-item.sequence-locked .chest-img {
    transform: scale(0.95);
}

/* Unlocked state: Chest is ready for interaction */
.chest-item.sequence-unlocked {
    opacity: 1;
    filter: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.chest-item.sequence-unlocked:hover {
    transform: scale(1.08);
    filter: brightness(1.15) drop-shadow(0 8px 20px rgba(200, 100, 255, 0.3));
}

.chest-item.sequence-unlocked:active {
    transform: scale(1.02);
}

/* ===== PAC-MAN STAGE 10 MODAL ===== */
.pacman-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 25000;
}

.pacman-overlay.hidden {
    display: none !important;
}

.pacman-container {
    background: #08081e;
    border: 3px solid #ffd700;
    border-radius: 14px;
    padding: 16px 20px 16px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    box-shadow: 0 0 50px rgba(255, 215, 0, 0.3), 0 20px 60px rgba(0, 0, 0, 0.9);
    max-width: 98vw;
    max-height: 95vh;
    overflow: auto;
    position: relative;
}

.pacman-header {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}

.pacman-title {
    color: #ffd700;
    font-size: 22px;
    font-family: 'Varela Round', sans-serif;
    margin: 0;
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    grid-column: 2;
}

.pacman-close-btn {
    grid-column: 3;
    justify-self: end;
}

.pacman-title-ghost {
    width: 60px;
    height: auto;
    object-fit: contain;
    flex-shrink: 0;
}

#pacman-game {
    display: block;
    background: #000;
    border: 2px solid #ffd700;
    border-radius: 6px;
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.2), inset 0 0 30px rgba(0, 0, 0, 0.8);
    width: 100%;
    height: auto;
    max-height: 80vh;
    object-fit: contain;
    touch-action: none;
}

.pacman-close-btn {
    background: rgba(220, 50, 50, 0.85);
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pacman-close-btn:hover {
    background: #ff3333;
    transform: scale(1.15);
}

.pacman-hint {
    color: #888;
    font-size: 13px;
    margin: 0;
    text-align: center;
    direction: ltr;
    letter-spacing: 0.4px;
}

/* ── Death animation ── */
@keyframes board-shake {
    0% {
        transform: translate(0, 0);
    }

    10% {
        transform: translate(2px, 1px);
    }

    20% {
        transform: translate(-1px, -2px);
    }

    30% {
        transform: translate(-3px, 1px);
    }

    40% {
        transform: translate(2px, -1px);
    }

    50% {
        transform: translate(-1px, 2px);
    }

    60% {
        transform: translate(3px, 1px);
    }

    70% {
        transform: translate(-2px, -1px);
    }

    80% {
        transform: translate(1px, 3px);
    }

    90% {
        transform: translate(-1px, 1px);
    }

    100% {
        transform: translate(0, 0);
    }
}

.shake-active {
    animation: board-shake 0.15s linear 10;
}

@keyframes light-ray-burst {
    0% {
        transform: scale(0);
        opacity: 1;
    }

    100% {
        transform: scale(3);
        opacity: 0;
    }
}

.light-ray-fx {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(circle, #fff, #ffd700, transparent);
    transform-origin: center;
    pointer-events: none;
    z-index: 100;
    animation: light-ray-burst 1s ease-out forwards;
}

@keyframes emoji-explode {
    0% {
        transform: translate(0, 0) scale(0.5);
        opacity: 1;
    }

    60% {
        transform: translate(var(--dx), var(--dy)) scale(1.4);
        opacity: 0.9;
    }

    100% {
        transform: translate(var(--dx), var(--dy)) scale(0.2);
        opacity: 0;
    }
}

.angry-emoji-fx {
    position: absolute;
    font-size: 28px;
    pointer-events: none;
    z-index: 101;
    animation: emoji-explode 1.2s ease-out forwards;
}