/* Common Game Elements */
.game-item {
    position: absolute;
    cursor: crosshair;
}

.game-area {
    position: absolute;
    inset: 0;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.game-bird,
.game-dove,
.game-eagle,
.game-duck,
.game-knight,
.game-predator,
.game-bee {
    position: absolute;
    top: var(--target-lane, 45%);
    left: 0;
    z-index: 6;
    min-width: 44px;
    min-height: 44px;
    padding: 6px;
    line-height: 1;
    text-align: center;
    user-select: none;
    touch-action: manipulation;
    animation-duration: var(--target-duration, 16s);
    animation-delay: var(--target-delay, 0s);
}

.game-bird-fast,
.game-duck-quick,
.game-eagle-high,
.game-dove-low,
.game-bee-bonus {
    z-index: 7;
}

/* Ducks - disappear when shot, move slowly */
.game-duck {
    font-size: 2.5rem;
    animation: moveDuckRightToLeft 20s linear infinite;
}
.game-duck::before {
    content: "🦆";
}
.game-duck-slow {
    animation-duration: 33s;
}

/* Knight and Predator - disappear when shot, normal speed */
.game-knight, .game-predator {
    font-size: 3rem;
    animation: moveRightToLeft 21s linear infinite;
}
.game-knight::before {
    content: "🤺";
}
.game-predator::before {
    content: "🐺";
}

/* Birds - additional bird, dove, and eagle with specific styling */
.game-bird, .game-dove, .game-eagle {
    font-size: 2.5rem;
    animation: moveRightToLeft 16s linear infinite;
    cursor: crosshair;
}
.game-bird::before {
    content: "🐦"; /* Generic bird */
}
.game-dove::before {
    content: "🕊️"; /* Dove */
}
.game-eagle::before {
    content: "🦅"; /* Eagle */
    font-size: 3.3rem; /* Eagle appears larger */
    animation-duration: 13s; /* Faster movement for eagle */
}

.game-bee {
    font-size: 1.7rem;
    animation: moveBeeLeftToRight 9.5s linear infinite;
    cursor: crosshair;
    display: inline-block;
    transform-origin: center;
}

.game-bee::before {
    content: "🐝"; /* Generic bee */
}

.game-bird,
.game-dove,
.game-eagle,
.game-duck,
.game-knight,
.game-predator,
.game-bee {
    animation-duration: var(--target-duration, 16s);
    animation-delay: var(--target-delay, 0s);
}

/* Clouds - deduct points, float slowly */
.game-cloud {
    background-color: #fff;
    border-radius: 50%;
    opacity: 0.8;
    position: absolute;
    cursor: pointer;
    animation: moveLeftToRight 80s linear infinite;
    z-index: 4;
}
.game-cloud1 { width: 70px; height: 40px; top: 10%; left: 5%; animation-duration: 60s; }
.game-cloud2 { width: 90px; height: 55px; top: 15%; left: 85%; animation-duration: 70s; }
.game-cloud3 { width: 75px; height: 45px; top: 20%; left: 35%; animation-duration: 65s; }
.game-cloud4 { width: 85px; height: 50px; top: 25%; left: 55%; animation-duration: 75s; }
.game-cloud5 { width: 100px; height: 60px; top: 30%; left: 10%; animation-duration: 80s; }

.hit-feedback {
    position: absolute;
    z-index: 30;
    transform: translate(-50%, -50%);
    color: #fff8dc;
    font-size: 1.1rem;
    font-weight: bold;
    line-height: 1;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.55);
    pointer-events: none;
    animation: hit-pop 0.8s ease-out forwards;
}

/* Tree - stationary, deducts points when shot */
.game-tree {
    width: 50px;
    height: 80px;
    background-color: #8B4513;
    position: absolute;
    right: 15%;
    bottom: 10%;
    cursor: pointer;
    z-index: 5;
}
.game-tree::before {
    content: '';
    background: #388E3C;
    border: 1px solid black;
    border-radius: 50%;
    height: 80px;
    width: 140px;
    position: absolute;
    bottom: 80px;
    left: -50px;
}

/* Scoreboard */
.game-scoreboard {
    background: #FFD700;
    border: 2px solid #FFC107;
    border-radius: 5px;
    color: #3E2723;
    font-size: 1.5rem;
    font-weight: bold;
    margin: 10px 0;
    padding: 10px;
    text-align: center;
    width: 150px;
    transition: background-color 0.3s ease;
}
.game-scoreboard.increase { background-color: #C8E6C9; } /* Light green for increase */
.game-scoreboard.decrease { background-color: #FFCDD2; } /* Light red for decrease */

/* Game Area Container */
.container-game-castle {
    background: #4CAF50;
    border-radius: 10px;
    height: 80vh;
    margin-bottom: 20px;
    overflow: hidden;
    position: relative;
    width: 100%;
}

/* Animations */
@keyframes moveDuckRightToLeft {
    0% { transform: translateX(100vw); }
    100% { transform: translateX(-100vw); }
}

@keyframes moveRightToLeft {
    0% { transform: translateX(100vw); }
    100% { transform: translateX(-100vw); }
}

@keyframes moveLeftToRight {
    0% { transform: translateX(-100vw); }
    100% { transform: translateX(100vw); }
}

@keyframes hit-pop {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.85);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -120%) scale(1.25);
    }
}

/* Animation for bee movement and flip */
@keyframes moveBeeLeftToRight {
    0% {
        transform: translateX(-100vw) scaleX(1); /* Facing right */
    }
    49.9% {
        transform: translateX(0vw) scaleX(1); /* Moving right */
    }
    50% {
        transform: translateX(0vw) scaleX(-1); /* Flip to face left */
    }
    100% {
        transform: translateX(100vw) scaleX(-1); /* Moving left */
    }
}

/* Position the Reset Button */
.reset-button {
    background: radial-gradient(circle, #FFD700 40%, #FFA500);
    color: #FFFFFF;
    font-size: 1.1rem;
    font-weight: bold;
    padding: 20px;
    border: none;
    border-radius: 50%;
    width: 70px;
    height: 70px;
    cursor: pointer;
    position: absolute;
    top: 5%;
    right: 2%;
    transition: transform 0.3s;
    box-shadow: 0 0 15px rgba(255, 165, 0, 0.5), 0 0 30px rgba(255, 223, 0, 0.7);
    text-align: center;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    z-index: 10; /* Ensures it stays above other game elements */
}

.reset-button:hover {
    transform: scale(1.1); /* Slightly enlarge on hover */
    box-shadow: 0 0 20px rgba(255, 223, 0, 0.7), 0 0 40px rgba(255, 223, 0, 0.9);
}

/* Sun rays */
.reset-button::before,
.reset-button::after {
    content: '';
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 223, 0, 0.3), transparent);
    top: -15px;
    left: -15px;
    z-index: -1;
    transform: rotate(45deg);
    animation: rotate 6s linear infinite; /* Slow rotation for a glowing effect */
}

.reset-button::after {
    animation-direction: reverse; /* Reverse rotation for a dynamic effect */
}

/* Rotate animation */
@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
/* Centered Timer Styling */
.timer {
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff8dc; /* Light yellow background */
    border: 2px solid #FFD700;
    border-radius: 10px;
    font-size: 1.5rem;
    font-weight: bold;
    color: #3E2723;
    padding: 15px 30px;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    z-index: 10; /* Keep it above other elements */
}

/* Flower Decoration */
.timer::before,
.timer::after {
    content: "🌸";
    font-size: 1.5rem;
    color: #FF69B4;
}

/* Flowers around the timer */
.timer .flower-left,
.timer .flower-right {
    position: absolute;
    font-size: 1.2rem;
}

/* Left Flower */
.timer .flower-left {
    left: -30px;
    top: -20px;
    animation: floatFlower 4s ease-in-out infinite;
}

/* Right Flower */
.timer .flower-right {
    right: -30px;
    bottom: -20px;
    animation: floatFlower 4s ease-in-out infinite reverse;
}

/* Floating Animation for Flowers */
@keyframes floatFlower {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.level-win-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(90vw, 440px);
    padding: 22px 26px;
    border: 3px solid #8B4513;
    border-radius: 12px;
    background: #fff8dc;
    color: #3E2723;
    font-size: 1.35rem;
    font-weight: bold;
    line-height: 1.35;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
    z-index: 9998;
}

.level-gameover-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(90vw, 460px);
    padding: 22px 26px;
    border: 3px solid #5d2f12;
    border-radius: 12px;
    background: #fff3d6;
    color: #3E2723;
    font-size: 1.25rem;
    font-weight: bold;
    line-height: 1.35;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
    z-index: 9998;
}

.level-win-celebration {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 9999;
    animation: win-burst 0.6s ease-out;
}

.level-win-celebration span {
    position: absolute;
    top: -24px;
    left: var(--x);
    width: 12px;
    height: 18px;
    border-radius: 2px;
    background: linear-gradient(145deg, #ffdf5d, #ff6f91);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.9);
    animation: win-confetti var(--duration) ease-in var(--delay) forwards;
}

.level-win-celebration span:nth-child(3n) {
    background: linear-gradient(145deg, #7bdff2, #00b894);
}

.level-win-celebration span:nth-child(4n) {
    background: linear-gradient(145deg, #fff1a8, #f39c12);
}

@keyframes win-confetti {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(105vh) rotate(720deg);
        opacity: 0;
    }
}

@keyframes win-burst {
    0% {
        background: rgba(255, 245, 180, 0.55);
    }
    100% {
        background: transparent;
    }
}

@media only screen and (max-width:700px) {
    .container {
        display: block;
    }

    .nav,
    .main,
    .right {
        float: none;
        width: 100%;
        min-width: 100%;
        box-sizing: border-box;
    }

    .main {
        padding: 8px;
    }

    .main h2 {
        margin: 8px 0 4px;
        font-size: 1.35rem;
    }

    .main > p {
        margin: 0 0 8px;
        padding: 0 8px;
        font-size: 0.95rem;
        line-height: 1.35;
    }

    .container-game-castle {
        height: min(70vh, 560px);
        min-height: 420px;
        margin: 8px 0 16px;
        border-radius: 8px;
    }

    .game-scoreboard {
        position: absolute;
        top: 8px;
        left: 8px;
        width: auto;
        margin: 0;
        padding: 7px 10px;
        font-size: 1rem;
        z-index: 20;
    }

    .timer {
        top: auto;
        right: 8px;
        bottom: 8px;
        left: auto;
        transform: none;
        width: auto;
        max-width: none;
        padding: 4px 7px;
        gap: 0;
        font-size: 0.78rem;
        line-height: 1.1;
        white-space: nowrap;
        pointer-events: none;
        z-index: 8;
    }

    .timer::before,
    .timer::after {
        display: none;
    }

    .timer .flower-left,
    .timer .flower-right {
        display: none;
    }

    .reset-button {
        top: 8px;
        right: 8px;
        width: 54px;
        height: 54px;
        padding: 6px;
        font-size: 0.72rem;
        line-height: 1.1;
        z-index: 21;
    }

    .reset-button::before,
    .reset-button::after {
        width: 70px;
        height: 70px;
        top: -8px;
        left: -8px;
    }

    .game-bird,
    .game-dove,
    .game-duck,
    .game-knight,
    .game-predator {
        min-width: 48px;
        min-height: 48px;
        padding: 8px;
        font-size: 2.1rem;
    }

    .game-eagle {
        min-width: 54px;
        min-height: 54px;
        padding: 8px;
        font-size: 2.35rem;
    }

    .game-eagle::before {
        font-size: 2.7rem;
    }

    .game-bee {
        min-width: 44px;
        min-height: 44px;
        padding: 8px;
        font-size: 1.75rem;
    }

    .game-cloud1,
    .game-cloud2,
    .game-cloud3,
    .game-cloud4,
    .game-cloud5 {
        transform: scale(0.78);
        transform-origin: center;
    }

    .game-tree {
        right: 7%;
        bottom: 7%;
        transform: scale(0.72);
        transform-origin: bottom right;
    }

    .level-win-message,
    .level-gameover-message {
        width: min(86vw, 360px);
        padding: 18px 20px;
        font-size: 1.1rem;
    }
}

@media only screen and (max-width:420px) {
    .container-game-castle {
        height: 68vh;
        min-height: 390px;
    }

    .timer {
        right: 6px;
        bottom: 6px;
        padding: 3px 6px;
        font-size: 0.72rem;
    }

    .game-scoreboard {
        padding: 6px 8px;
        font-size: 0.9rem;
    }
}
