* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    background: #000;
    /* Fallback */
}

#game-logo {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 180px;
    height: auto;
    z-index: 100;
    pointer-events: none;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

#ui-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}

/* The Base Screen - Visible and Active */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    /* Keep this! We manage visibility differently now */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    text-align: center;

    /* The Magic Transition State */
    opacity: 1;
    visibility: visible;
    transform: scale(1);

    /* Smooth transition for fading and scaling */
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        visibility 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* The Hidden Screen - Ghosted and Shrunk */
.screen.hidden {
    opacity: 0 !important;
    visibility: hidden !important;
    transform: scale(0.95) !important;
    /* Shrinks slightly into the background */
    pointer-events: none !important;
    /* DO NOT add display: none here! */
}

@keyframes screen-fade-in {
    0% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

#start-screen {
    background: url('Assets/images/Start-bg.webp') no-repeat center center / cover;
}

#result-screen {
    background: url('Assets/images/result-bg.webp') no-repeat center center / cover;
}


.hidden {
    display: none !important;
}

button {
    font-size: 1.05rem;
    padding: 12px 18px;
    margin: 10px;
    cursor: pointer;
    border: none;
    border-radius: 14px;
    background: #ff9800;
    color: #fff;
    font-weight: 700;
    box-shadow: 0 8px 18px rgba(255, 152, 0, 0.24);
    animation: breathing 2.5s infinite ease-in-out alternate;
}

button:hover {
    background: #e68a00;
    transform: scale(1.05);
    animation-play-state: paused;
}

#start-button {
    margin-top: 20px;
    padding: 0;
    background: transparent;
    box-shadow: none;
    border: none;
    transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#start-button img {
    width: 320px;
    display: block;
    height: auto;
    transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    animation: start-pulse-glow 2s infinite alternate ease-in-out;
}

#start-button:hover img {
    transform: scale(1.1);
}

#start-button:hover {
    background: transparent;
}

#game-title {
    width: 650px;
    max-width: 90vw;
    height: auto;
    object-fit: contain;
    margin-bottom: -200px;
    animation: float-title 3.5s infinite ease-in-out alternate;
}

#start-subtitle {
    margin-top: 10px;
    color: #3b3b3b;
    font-size: 1.2rem;
    font-weight: 600;
}

.character-select {
    margin-top: 18px;
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    justify-content: center;
}

.character-select button {
    background: transparent;
    box-shadow: none;
    padding: 8px;
    border-radius: 18px;
    margin: 6px;
    transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.character-select button img {
    width: 250px;
    height: auto;
    display: block;
    transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    animation: char-wiggle-btn 3.5s infinite alternate ease-in-out;
}

.character-select button:hover img {
    transform: scale(1.1);
}

.character-select button:hover {
    background: transparent;
}

.side-character {
    position: absolute;
    top: 0;
    bottom: 0;
    margin: auto;
    height: 75vh;
    max-height: 650px;
    object-fit: contain;
    z-index: 10;
    pointer-events: none;
}

#left-character,
#instruction-character-left {
    left: 4%;
    animation: sway-left 4s infinite ease-in-out alternate;
}

#right-character,
#instruction-character-right {
    right: 4%;
    animation: sway-right 3.6s infinite ease-in-out alternate;
    /* Slightly offset time for organic feel */
}

#instruction-screen {
    background: url('Assets/images/game-bg.webp') no-repeat center center / cover;
}

.instruction-text {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 45%;
    max-width: 600px;
    height: auto;
    object-fit: contain;
    z-index: 15;
    animation: text-float 4.5s infinite alternate ease-in-out;
}

#instruction-text-left {
    left: 8%;
}

#instruction-text-right {
    right: 8%;
}

.continue-btn {
    position: absolute;
    bottom: 0%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0;
    margin: 0;
    background: transparent;
    box-shadow: none;
    z-index: 20;
    border: none;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    animation: continue-slide-bob 2.8s infinite alternate ease-in-out;
}

.continue-btn img {
    width: 320px;
    height: auto;
    display: block;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.3));
    transition: transform 0.2s ease;
}

.continue-btn:hover {
    background: transparent;
    transform: translateX(-50%) scale(1.1);
    animation-play-state: paused;
}






#scrolling-bg-container {
    position: absolute;
    inset: 0;
    width: 200vw;
    /* Double width so we always have a tile ready off-screen */
    background: url('Assets/images/game-bg.webp') repeat-x left center;
    background-size: 50% 100%;
    /* Each tile = 100vw, 2 tiles fill the 200vw container */
    z-index: 1;
    will-change: transform;
    /* JS sets transform directly via RAF */
}

/* .game-moving-bg + @keyframes scroll-bg removed — RAF loop in script.js handles scroll */

#hud {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    font-size: 1.2rem;
    font-weight: 700;
    color: #2c2c2c;
    pointer-events: none;
}

#stats-display,
#wave-display,
#lane-tip {
    margin-top: 8px;
    background: rgba(255, 255, 255, 0.82);
    padding: 8px 16px;
    border-radius: 999px;
}

#wave-display,
#lane-tip {
    font-size: 0.95rem;
    font-weight: 600;
}

#progress-container {
    width: min(64%, 900px);
    height: 26px;
    background: #e3e3e3;
    border-radius: 999px;
    border: 3px solid #ffffff;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08) inset;
}

#progress-bar {
    width: 0%;
    height: 100%;
    background: #4caf50;
    transition: width 0.3s ease;
}

#countdown {
    margin-top: 12px;
    font-size: 4rem;
    line-height: 1;
    color: #ff7043;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

#feedback {
    margin-top: 12px;
    font-size: 2rem;
    font-weight: 800;
    padding: 10px 18px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.9);
    color: #28405a;
}

#result-title {
    animation: result-shimmer 2.2s infinite alternate ease-in-out;
}

#result-message {
    animation: result-fade-pulse 3.3s infinite alternate ease-in-out;
}

#result-images-container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: flex-end;
    gap: -80px;
    width: 100vw;
    max-width: 2000px;
    margin-top: 10vh;
    padding-bottom: 5vh;
}

#result-img-final,
#mooshak-img-final {
    width: 35%;
    max-height: 60vh;
    object-fit: contain;
    animation: result-popper 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, result-triumph-bounce 1.8s infinite ease-in-out alternate 0.8s;
    opacity: 0;
}

#mooshak-img-final {
    margin-left: -100px;
    /* Additional tuck-in for Mooshak */
}

@keyframes result-popper {
    0% {
        transform: scale(0.2);
        opacity: 0;
    }

    80% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

#tutorial-overlay {
    background: url('Assets/images/game-bg.webp') no-repeat center center / cover;
}

.tutorial-images {
    display: flex;
    flex-direction: row;
    gap: 60px;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transform: translateY(-20px);
    /* Move images slightly higher */
}

.tutorial-images img {
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.4));
    animation: tutorial-jump 3s infinite alternate ease-in-out;
}

#tutorial-img-1 {
    width: 38vw;
    max-width: 600px;
}

#tutorial-img-2 {
    width: 38vw;
    max-width: 550px;
    animation-delay: 0.5s;
    /* Offset animation for organic feel */
}

#game {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: #87CEEB;
    /* Fallback sky color */
}

.lanes {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 70vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 3;
}



.power-up {
    animation: hero-glow 1s ease-out;
}

@keyframes hero-glow {
    0% {
        transform: scale(1);
        filter: brightness(1.2);
        /* optimized hover */
    }

    50% {
        transform: scale(1.3);
        filter: drop-shadow(0 0 30px #4caf50) brightness(1.5);
    }

    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 0px #4caf50) brightness(1);
    }
}

.slow-down-blur {
    animation: world-blur 1.5s ease-out;
}

@keyframes world-blur {
    0% {
        filter: blur(0px) grayscale(0%);
    }

    20% {
        filter: blur(5px) grayscale(80%);
    }

    100% {
        filter: blur(0px) grayscale(0%);
    }
}

.spin-penalty {
    animation: dizzy-spin 1s ease-in-out;
}

@keyframes dizzy-spin {
    0% {
        transform: rotate(0deg) scale(1);
    }

    50% {
        transform: rotate(-360deg) scale(0.6);
        filter: hue-rotate(90deg) brightness(0.7);
    }

    100% {
        transform: rotate(-360deg) scale(1);
        filter: hue-rotate(0deg) brightness(1);
    }
}

#game-layout {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80vw;
    height: 60vh;
    display: flex;
    flex-direction: row;
    z-index: 5;
    pointer-events: none;
}

#player-zone {
    flex: 2;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    pointer-events: auto;
}

#layout-gap {
    flex: 1;
}

#player {
    position: relative;
    width: 300px;
    height: 300px;
    z-index: 5;
    /* Animation moved to sprite to prevent transform conflicts */
}

#player-sprite {
    width: 100%;
    height: 100%;
    object-fit: contain;
    animation: dash-bounce 1s infinite ease-in-out;
}

#swish-effect {
    position: absolute;
    right: 50%;
    top: 50%;
    margin-top: -40px;
    width: 250px;
    height: 80px;
    background: linear-gradient(to left, rgba(255, 255, 255, 0.9), transparent);
    border-radius: 40px;
    filter: blur(8px);
    z-index: 4;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

#swish-effect.active {
    opacity: 1;
}

/* Swish effect defined here... */



@keyframes food-pulse-idle {
    0% {
        transform: scale(1);
    }

    100% {
        transform: scale(1.1);
    }
}

#food-container {
    flex: 2;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    align-items: center;
    pointer-events: auto;
}

.food {
    position: relative;
    width: 160px;
    height: 160px;
    z-index: 10;
    transition: transform 0.2s ease, opacity 0.35s ease, filter 0.35s ease;
    object-fit: contain;
    cursor: pointer;
    animation: food-pulse-idle 1.2s infinite ease-in-out alternate;
}

.food:hover {
    animation-play-state: paused;
    filter: brightness(1.2) drop-shadow(0 0 15px rgba(255, 255, 255, 0.8));
    transform: scale(1.2);
}

.food.variant-warm {
    filter: hue-rotate(-12deg) saturate(1.1);
}

.food.variant-cool {
    filter: hue-rotate(16deg) saturate(1.08);
}

.food.variant-contrast {
    filter: contrast(1.18) saturate(1.06);
}

.food.variant-soft {
    filter: brightness(1.05) saturate(0.95);
}

.food.variant-sharp {
    filter: contrast(1.12) brightness(0.98);
}

.food.dimmed {
    filter: brightness(0.5);
    transform: scale(0.6);
}

.food.expand-fade {
    animation: food-expand-fade 0.5s ease forwards;
    pointer-events: none;
}

@keyframes food-expand-fade {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(1.8);
        opacity: 0;
        filter: brightness(1.5);
    }
}

.food.consumed {
    opacity: 0;
    transform: scale(1.25);
}

@keyframes breathing {
    0% {
        transform: translateY(-5px);
    }

    100% {
        transform: translateY(5px);
    }
}

@keyframes float-title {
    0% {
        transform: translateY(-8px) scale(0.98);
    }

    100% {
        transform: translateY(8px) scale(1.02);
    }
}

@keyframes sway-left {
    0% {
        transform: translateY(-10px) rotate(-2deg);
    }

    100% {
        transform: translateY(10px) rotate(1deg);
    }
}

@keyframes sway-right {
    0% {
        transform: scaleX(-1) translateY(-10px) rotate(-2deg);
    }

    100% {
        transform: scaleX(-1) translateY(10px) rotate(1deg);
    }
}

@keyframes food-wobble {
    0% {
        transform: translateY(-6px) rotate(-4deg);
    }

    100% {
        transform: translateY(6px) rotate(4deg);
    }
}

@keyframes dash-bounce {
    0% {
        transform: translateY(0) scaleY(1);
    }

    50% {
        transform: translateY(-4px) scaleY(1.02);
    }

    100% {
        transform: translateY(0) scaleY(0.98);
    }
}

@keyframes start-pulse-glow {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 0 5px rgba(255, 165, 0, 0.4));
    }

    100% {
        transform: scale(1.05);
        filter: drop-shadow(0 0 25px rgba(255, 165, 0, 0.9));
    }
}

@keyframes char-wiggle-btn {

    0%,
    100% {
        transform: rotate(-4deg) translateY(0);
    }

    50% {
        transform: rotate(4deg) translateY(-8px);
    }
}

@keyframes text-float {
    0% {
        transform: translateY(calc(-50% - 10px)) translateX(-5px);
    }

    100% {
        transform: translateY(calc(-50% + 10px)) translateX(5px);
    }
}

@keyframes continue-slide-bob {
    0% {
        transform: translateX(-50%) translateY(0) scale(1);
    }

    100% {
        transform: translateX(-50%) translateY(-10px) scale(1.02);
    }
}

@keyframes result-shimmer {
    0% {
        opacity: 0.8;
        transform: scale(0.98);
        text-shadow: 0 0 5px rgba(255, 255, 255, 0.4);
    }

    100% {
        opacity: 1;
        transform: scale(1.03);
        text-shadow: 0 0 15px rgba(255, 255, 255, 0.9);
    }
}

@keyframes result-fade-pulse {
    0% {
        opacity: 0.6;
        transform: translateY(5px);
    }

    100% {
        opacity: 1;
        transform: translateY(-5px);
    }
}

@keyframes result-triumph-bounce {

    0%,
    100% {
        transform: translateY(0) scale(1);
        filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
    }

    50% {
        transform: translateY(-20px) scale(1.05);
        filter: drop-shadow(0 15px 12px rgba(0, 0, 0, 0.5));
    }
}

@keyframes tutorial-jump {
    0% {
        transform: translateY(0) scale(1);
        filter: drop-shadow(0 4px 6px rgba(255, 255, 255, 0.2));
    }

    100% {
        transform: translateY(-15px) scale(1.05);
        filter: drop-shadow(0 15px 12px rgba(255, 255, 255, 0.4));
    }
}

@keyframes tutorial-fade {
    0% {
        opacity: 0.7;
        transform: scale(0.98);
    }

    100% {
        opacity: 1;
        transform: scale(1.02);
    }
}

/* ===================================================
   SPEECH BUBBLE
=================================================== */
#speech-bubble {
    position: absolute;
    bottom: calc(100% + -10px);
    /* Lowered position: sits closer to the character */
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 12px 20px;
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    min-width: 160px;
    text-align: center;
    z-index: 50;
    font-weight: 800;
    color: #2d3436;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease;
}

#speech-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 12px;
    border-style: solid;
    border-color: white transparent transparent transparent;
}

#speech-bubble.hidden {
    opacity: 0 !important;
    display: block !important;
    pointer-events: none;
    visibility: hidden;
}

#speech-bubble.bubble-healthy {
    background: #e8fff0 !important;
    border: 4px solid #4CAF50;
    color: #1b5e20 !important;
    box-shadow: 0 4px 18px rgba(50, 200, 100, 0.25) !important;
}

#speech-bubble.bubble-healthy::after {
    border-top-color: #e8fff0 !important;
}

#speech-bubble.bubble-junk {
    background: #fff0f0 !important;
    border: 4px solid #F44336;
    color: #b71c1c !important;
    box-shadow: 0 4px 18px rgba(200, 50, 50, 0.25) !important;
}

#speech-bubble.bubble-junk::after {
    border-top-color: #fff0f0 !important;
}

/* ===================================================
   SCREEN FLASH (BORDER GLOW)
=================================================== */
#screen-flash {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 999;
    border-radius: 0;
    opacity: 0;
}

#screen-flash.flash-healthy {
    animation: flash-green 1s ease forwards;
}

#screen-flash.flash-junk {
    animation: flash-red 0.8s ease forwards;
}

#screen-flash.flash-timeout {
    animation: flash-timeout-red 0.6s ease forwards;
}

@keyframes flash-green {
    0% {
        opacity: 1;
        box-shadow: inset 0 0 0 12px rgba(50, 220, 100, 0.8);
    }

    50% {
        opacity: 1;
        box-shadow: inset 0 0 0 20px rgba(50, 255, 120, 0.4);
    }

    100% {
        opacity: 0;
        box-shadow: inset 0 0 0 8px rgba(50, 220, 100, 0);
    }
}

@keyframes flash-red {
    0% {
        opacity: 1;
        box-shadow: inset 0 0 0 12px rgba(220, 30, 30, 0.9);
    }

    30% {
        opacity: 0.5;
        box-shadow: inset 0 0 0 8px rgba(150, 0, 0, 0.6);
    }

    60% {
        opacity: 1;
        box-shadow: inset 0 0 0 12px rgba(220, 30, 30, 0.9);
    }

    100% {
        opacity: 0;
        box-shadow: inset 0 0 0 8px rgba(220, 30, 30, 0);
    }
}

@keyframes flash-timeout-red {
    0% {
        opacity: 1;
        box-shadow: inset 0 0 0 15px rgba(255, 0, 0, 0.7);
    }

    100% {
        opacity: 0;
        box-shadow: inset 0 0 0 8px rgba(255, 0, 0, 0);
    }
}

/* ===================================================
   SCREEN SHAKE
=================================================== */
.shake-screen {
    animation: screen-shake 0.3s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes screen-shake {

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

    20%,
    60% {
        transform: translate3d(-4px, 2px, 0);
    }

    40%,
    80% {
        transform: translate3d(4px, -2px, 0);
    }
}

/* ===================================================
   ENERGY BAR
=================================================== */
#energy-bar-container {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

#energy-bar-label {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 800;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

#energy-bar-track {
    width: 320px;
    height: 24px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 14px;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

#energy-bar {
    height: 100%;
    width: 100%;
    /* start at full */
    border-radius: 10px;
    background: linear-gradient(90deg, #56ab2f, #a8e063);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1),
        background 0.5s ease;
    box-shadow: 0 0 8px rgba(100, 220, 60, 0.5);
}

#energy-bar.low {
    background: linear-gradient(90deg, #c0392b, #e74c3c);
    box-shadow: 0 0 8px rgba(220, 60, 60, 0.6);
}

/* ===================================================
   TUTORIAL OVERLAY (STORY SLIDES)
=================================================== */

.story-slide {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    bottom: 1000px;
}

.story-slide.active {
    opacity: 1;
    pointer-events: auto;
}

.story-character {
    height: 55vh;
    max-height: 440px;
    object-fit: contain;
    filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.4));
    animation: story-float 3s infinite ease-in-out alternate;
}

@keyframes story-float {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-14px);
    }
}

.story-text-box {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    border-radius: 24px;
    padding: 24px 40px;
    max-width: 560px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.story-text {
    font-size: 1.45rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    line-height: 1.5;
    margin: 0 0 12px 0;
}

.story-tap-hint {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.65);
    font-weight: 600;
    margin: 0;
    animation: hint-pulse 1.5s infinite ease-in-out alternate;
}

@keyframes hint-pulse {
    from {
        opacity: 0.5;
    }

    to {
        opacity: 1;
    }
}

.peacock-box {
    background: rgba(255, 215, 0, 0.15);
    border-color: rgba(255, 215, 0, 0.4);
}

.peacock-speaker {
    font-size: 1rem;
    font-weight: 800;
    color: #ffe066;
    margin-bottom: 8px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* ===================================================
   KARTIKEYA EXIT ANIMATION
=================================================== */
@keyframes exit-right {
    0% {
        transform: translateX(0) scaleX(1);
        opacity: 1;
    }

    80% {
        transform: translateX(75vw) scaleX(1);
        opacity: 1;
    }

    100% {
        transform: translateX(110vw) scaleX(0.8);
        opacity: 0;
    }
}

#player.exit-right {
    animation: exit-right 1.2s cubic-bezier(0.4, 0, 1, 1) forwards;
    pointer-events: none;
}

/* ===================================================
   VISIBLE TIMER
=================================================== */
#visible-timer {
    position: fixed;
    top: 90px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 3rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 4px 16px rgba(0, 0, 0, 0.8);
    z-index: 40;
    transition: transform 0.2s ease, color 0.3s ease;
}

#visible-timer.warning {
    color: #ff5252;
    transform: translateX(-50%) scale(1.2);
    animation: hint-pulse 0.5s infinite alternate;
}

/* ===================================================
   FOOD MOVEMENT
=================================================== */
.food.clickable {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.food.clickable:hover {
    transform: scale(1.1);
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.6));
}



.food.fading {
    transition: opacity 0.4s ease, transform 0.4s ease;
    opacity: 0;
    transform: scale(0.5);
    pointer-events: none;
}

#speech-bubble:not(.hidden) {
    animation: bubble-pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes bubble-pop {
    0% {
        transform: translateX(-50%) scale(0);
        opacity: 0;
    }

    100% {
        transform: translateX(-50%) scale(1);
        opacity: 1;
    }
}

#speech-bubble-text {
    font-size: 1.1rem;
    white-space: nowrap;
}

/* --- Tap Hint --- */
#tap-hint {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 3px solid #baf872;
    padding: 14px 32px;
    border-radius: 24px;
    color: #baf872;
    font-weight: 800;
    font-size: 1.3rem;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 204, 51, 0.3);
    z-index: 100;
    pointer-events: none;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    animation: hint-float 2.5s infinite ease-in-out alternate;
}

#tap-hint.hidden {
    display: none !important;
}

@keyframes hint-float {
    from {
        transform: translateX(-50%) translateY(0);
        filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
    }

    to {
        transform: translateX(-50%) translateY(-8px);
        filter: drop-shadow(0 12px 20px rgba(0, 0, 0, 0.4));
    }
}