body {
    margin: 0;
    overflow: hidden;
    height: 100vh;
    background-color: #87CEEB; /* Sky blue */
    position: relative; /* Needed for absolute positioning of bees */
    font-family: sans-serif; /* Add a default font */
}

/* New cloud styles */
.cloud {
    position: absolute;
    background-color: rgba(255, 255, 255, 0.5); /* Semi-transparent white */
    border-radius: 50%; /* Rounded shape */
    pointer-events: none; /* Clouds shouldn't interfere with clicks */
}

/* Different cloud sizes */
.cloud-sm {
    width: 50px;
    height: 30px;
}

.cloud-md {
    width: 80px;
    height: 40px;
}

.cloud-lg {
    width: 120px;
    height: 60px;
}

.cloud-xl {
    width: 180px;
    height: 80px;
}

#bee-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* pointer-events: none;  Removed to allow clicking specific bees */
}

.bee-wrapper {
    position: absolute;
    display: flex; /* Use flexbox for image and bubble */
    align-items: center; /* Vertically align image and bubble */
    will-change: transform; /* Optimize animation */
    transition: transform 0.1s linear; /* Smooth out visual updates */
    /* Set height explicitly to avoid layout shifts if image loads slow */
    height: 50px;
    cursor: default; /* Default cursor */
    pointer-events: none; /* Bees are not clickable by default */
}

.home-bee {
    cursor: pointer; /* Make home bee clickable */
    pointer-events: auto !important; /* Override container setting */
}

.game-bee {
    cursor: pointer; /* Make game bee clickable */
    pointer-events: auto !important; /* Override container setting */
}

.music-bee {
    cursor: pointer; /* Make music bee clickable */
    pointer-events: auto !important; /* Override container setting */
}

.rps-bee {
    cursor: pointer; /* Make rps bee clickable */
    pointer-events: auto !important; /* Override container setting */
}

.shop-keeper-bee {
    cursor: pointer;
    pointer-events: auto !important;
}

/* New King Bee style */
.king-bee {
    cursor: pointer;
    pointer-events: auto !important;
    z-index: 10; /* Higher z-index to be visible above other bees */
}

/* Style for the bee image */
.bee-image {
    width: 50px; /* Match beeSize in JS */
    height: auto; /* Maintain aspect ratio */
    display: block; /* Remove extra space below image */
    /* Add a slight filter for effect if desired, e.g., drop-shadow */
    /* Ensure image flipping doesn't affect layout badly */
    transform-origin: center center;
}

/* King Bee image specifically */
.king-bee .bee-image {
    width: 100px; /* Make king bee larger */
    height: auto;
    filter: drop-shadow(0 0 10px gold); /* Add a golden glow */
}

.speech-bubble {
    /* Adjust margin to appear next to the image */
    margin-left: 5px; /* Default margin for right-facing bee */
    margin-right: 0;
    background: white;
    padding: 5px 10px;
    border-radius: 10px;
    border: 1px solid black;
    font-size: 12px;
    font-family: sans-serif;
    white-space: nowrap;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
    /* Ensure it doesn't shrink */
    flex-shrink: 0;
    /* Transform origin for scaling/flipping */
    transform-origin: center left; /* Default origin for right-facing bee */
    /* Add transition for smoother scale changes if needed */
    /* transition: transform 0.1s linear; */
}

/* Style for the King Bee speech bubble */
.king-bee .speech-bubble {
    background-color: #FFD700; /* Gold background */
    color: #8B4513; /* Brown text */
    border: 2px solid #8B4513; /* Brown border */
    font-weight: bold;
}

/* Highlighted bee style */
.highlighted-bee {
    animation: pulse-highlight 2s infinite alternate;
    z-index: 50; /* Make sure it appears above other bees */
}

.highlighted-bee .bee-image {
    filter: drop-shadow(0 0 8px gold); /* Add gold glow to the image */
}

.highlighted-bee .speech-bubble {
    background-color: #FFD700; /* Gold background */
    color: #8B4513; /* Brown text */
    font-weight: bold;
    border: 2px solid #8B4513; /* Thicker border */
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.7); /* Golden glow */
}

@keyframes pulse-highlight {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(1.05);
    }
}

#game-overlay {
    position: fixed; /* Fixed position to stay centered */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent background */
    display: flex; /* Use flex for centering */
    justify-content: center;
    align-items: center;
    z-index: 101; /* Ensure score is above overlay */
}

#game-overlay.hidden {
    display: none; /* Hide the overlay initially */
}

/* New container for game content */
#game-content {
    display: flex; /* Arrange bee and sidebar */
    align-items: center; /* Vertically align */
    gap: 30px; /* Space between bee and sidebar */
    background-color: rgba(0, 0, 0, 0.3); /* Optional: Slight background for the content area */
    padding: 20px;
    border-radius: 10px;
    position: relative; /* Needed for absolute positioning of the minigame bee container */
    /* Ensure clicks go through to elements behind if needed, though children have higher z-index */
    /* pointer-events: none; */ /* Removed as children need events */
    z-index: 0; /* Establish stacking context */
}

#minigame-bee-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Bees inside shouldn't be clickable */
    overflow: hidden; /* Keep bees contained */
    z-index: 1; /* Behind clickable bee and sidebar, but above game-content background */
}

.minigame-bee {
    position: absolute;
    width: 25px; /* Smaller bees for the minigame */
    height: auto;
    display: block;
    will-change: transform;
    /* No pointer events needed */
    transform-origin: center center; /* For potential flipping */
}

#clickable-bee {
    width: 150px; /* Larger bee */
    height: auto;
    cursor: pointer;
    border: 3px solid gold;
    border-radius: 50%;
    transition: transform 0.1s ease-out; /* Add a little bounce effect */
    flex-shrink: 0; /* Prevent bee from shrinking */
    position: relative; /* Ensure it stays above the minigame bees */
    z-index: 2; /* Above minigame bees */
}

#clickable-bee:active {
    transform: scale(0.95); /* Shrink slightly when clicked */
}

/* Sidebar styles */
#upgrade-sidebar {
    width: 220px; /* Slightly wider */
    background-color: #8B4513; /* SaddleBrown */
    color: #F0E68C; /* Khaki */
    border: 3px solid #DAA520; /* Goldenrod */
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px; /* Space between elements */
    font-family: 'Arial', sans-serif;
    position: relative; /* Ensure it stays above the minigame bees */
    z-index: 2; /* Above minigame bees */
    max-height: 80vh; /* Prevent excessive height */
    overflow-y: auto; /* Allow scrolling if needed */
}

#upgrade-sidebar h3 {
    margin: 0 0 10px 0;
    text-align: center;
    color: #FFD700; /* Gold */
    border-bottom: 1px solid #DAA520; /* Goldenrod */
    padding-bottom: 5px;
    flex-shrink: 0; /* Prevent shrinking */
}

/* Container for stats */
#stats-display {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 8px;
    border-radius: 4px;
    margin-bottom: 10px; /* Space below stats */
    flex-shrink: 0; /* Prevent shrinking */
}

#ppc-display, #pps-display {
    text-align: center;
    font-size: 0.9em;
    font-weight: bold;
    margin-top: 5px;
}

.upgrade-button { /* General class for all upgrade buttons */
    background-color: #B8860B; /* DarkGoldenrod */
    color: white;
    border: 1px solid #F0E68C; /* Khaki */
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s ease;
    flex-shrink: 0; /* Prevent shrinking */
    text-align: center; /* Center text */
    min-height: 40px; /* Ensure consistent height */
    display: flex; /* Center span vertically */
    align-items: center;
    justify-content: center;
}

.upgrade-button:hover:not(:disabled) {
    background-color: #DAA520; /* Goldenrod */
}

.upgrade-button:disabled {
    background-color: #A0522D; /* Sienna */
    color: #cccccc;
    cursor: not-allowed;
    opacity: 0.7;
}

.upgrade-button span {
    display: inline-block; /* Allows text wrapping if needed, though unlikely here */
}

/* Rebirth locked style */
.rebirth-locked {
    opacity: 0.5; /* Dim the button */
    /* Add maybe a border color or text color change */
    border-color: grey;
    color: #ccc;
}

.rebirth-locked:hover {
    /* Prevent hover effect when locked */
    background-color: #A0522D;
    cursor: not-allowed;
}

#score-display {
    position: fixed;
    top: 10px;
    left: 10px;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 1.2em;
    font-weight: bold;
    z-index: 200; /* Above the music menu */
}

/*home button*/
.home-button {
    position: fixed;
    top: 50px;
    left: 10px;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 1.2em;
    font-weight: bold;
    z-index: 200; /* Above the music menu */
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.home-button:hover {
    background-color: #DAA520; /* Goldenrod */
}

/* Gambling Button Styles */
.gamble-button {
    position: fixed;
    top: 10px;
    right: 10px;
    background-color: rgba(0, 128, 0, 0.8); /* Green with transparency */
    color: white;
    padding: 15px 20px; /* Bigger button */
    border-radius: 8px; /* More rounded */
    font-size: 1.3em; /* Larger text */
    font-weight: bold;
    z-index: 200; /* Above everything */
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.gamble-button:hover {
    background-color: rgba(0, 150, 0, 0.9); /* Darker green on hover */
}

/* Play Button Styles */
.play-button {
    position: fixed;
    top: 65px; /* Position between gamble and shop buttons */
    right: 10px;
    background-color: #00A86B; /* Bright green */
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    font-size: 1.3em;
    font-weight: bold;
    z-index: 200; /* Above everything */
    border: 2px solid #FFFFFF;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.play-button:hover {
    background-color: #00C985; /* Lighter green on hover */
    transform: scale(1.05);
}

/* Music Menu Styles */
#music-menu {
    position: fixed;
    top: 10px;
    right: 10px;
    background-color: rgba(139, 69, 19, 0.85); /* SaddleBrown semi-transparent */
    color: #FFD700; /* Gold */
    padding: 15px;
    border: 3px solid #DAA520; /* Goldenrod */
    border-radius: 8px;
    z-index: 200; /* Above everything else */
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-family: 'Arial', sans-serif;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

#music-menu.hidden {
    display: none;
}

#music-menu h3 {
    margin: 0 0 10px 0;
    text-align: center;
    font-size: 1.1em;
    border-bottom: 1px solid #DAA520;
    padding-bottom: 5px;
}

.music-button {
    background-color: #B8860B; /* DarkGoldenrod */
    color: white;
    border: 1px solid #F0E68C; /* Khaki */
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s ease;
}

.music-button:hover {
    background-color: #DAA520; /* Goldenrod */
}

.music-button.active {
    background-color: #DAA520; /* Goldenrod */
    border: 2px solid #FFD700; /* Gold */
}

.close-button { /* Style for modal close buttons */
    position: absolute;
    top: 5px;
    right: 5px;
    background: #8B4513;
    color: #FFD700;
    border: 1px solid #DAA520;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    padding: 0;
    font-size: 1em;
    line-height: 20px; /* Center the 'X' */
    text-align: center;
    cursor: pointer;
}

.close-button:hover {
    background: #A0522D;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 5px;
}

.volume-control label {
    font-size: 0.9em;
}

#volume-slider {
    flex-grow: 1;
    cursor: pointer;
    height: 8px; /* Make slider a bit thicker */
    accent-color: #FFD700; /* Style the slider thumb/track */
}

/* Music controls visible now */
.music-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.music-controls-hidden {
    display: none;
}

#music-broken-message.hidden {
    display: none;
}

/* --- Rebirth Modal Styles --- */
#rebirth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); /* Semi-transparent dark background */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1500; /* Ensure it's above everything else */
}

#rebirth-modal.hidden {
    display: none;
}

#rebirth-modal .modal-content {
    background-color: #5a3a29; /* Darker SaddleBrown */
    color: #F0E68C; /* Khaki */
    border: 5px solid #FFD700; /* Gold border */
    border-radius: 10px;
    padding: 30px;
    max-width: 400px; /* Set a max width */
    width: 90%; /* Responsive width */
    max-height: 90vh; /* Limit height */
    overflow-y: auto; /* Add scroll if content overflows */
    text-align: center;
    position: relative; /* Needed for close button absolute positioning */
    display: flex; /* Flex container for layout */
    flex-direction: column;
    gap: 15px; /* Space between sections/buttons */
}

#rebirth-modal h2 {
    margin-top: 0;
    color: #FFD700; /* Gold */
}

/* New styles for the upgrade containers and help buttons */
.upgrade-container {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    gap: 5px;
}

.help-button {
    background-color: #FFD700; /* Gold */
    color: #8B4513; /* SaddleBrown */
    border: 1px solid #8B4513;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-weight: bold;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color 0.2s ease;
}

.help-button:hover {
    background-color: #FFC125; /* Darker gold */
}

/* Tooltip style */
#upgrade-tooltip {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(139, 69, 19, 0.95); /* SaddleBrown with high opacity */
    color: #F0E68C; /* Khaki */
    padding: 20px;
    border: 3px solid #FFD700; /* Gold */
    border-radius: 10px;
    z-index: 2000; /* Above everything */
    max-width: 400px;
    width: 90%;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
}

#upgrade-tooltip.hidden {
    display: none;
}

#tooltip-content {
    margin-bottom: 15px;
    font-size: 1.1em;
    line-height: 1.4;
}

#tooltip-content h3 {
    color: #FFD700; /* Gold */
    margin-top: 0;
    border-bottom: 1px solid #DAA520;
    padding-bottom: 5px;
    margin-bottom: 10px;
}

#tooltip-content p {
    margin-bottom: 10px;
}

#tooltip-content ul {
    padding-left: 20px;
    margin-bottom: 10px;
}

#close-tooltip {
    background-color: #B8860B; /* DarkGoldenrod */
    color: white;
    border: 1px solid #F0E68C; /* Khaki */
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.2s ease;
    display: block;
    margin: 0 auto;
}

#close-tooltip:hover {
    background-color: #DAA520; /* Goldenrod */
}

/* Enhanced responsive design */
@media (max-width: 768px) {
    .gamble-button, .play-button, .home-button {
        padding: 10px 15px;
        font-size: 1em;
    }
    
    .play-button {
        top: 60px; /* Adjust position for mobile */
    }
    
    /* Stack buttons on narrow screens */
    .gamble-button {
        top: 10px;
    }
    
    .play-button {
        top: 60px;
    }
    
    /* Move shop button down */
    button.gamble-button[style*="top: 120px"] {
        top: 110px !important;
    }
    
    /* Adjust minigame container for smaller screens */
    #minigame-bee-container {
        max-height: 50vh;
    }
    
    #game-content {
        flex-direction: column;
        gap: 15px;
    }
    
    #clickable-bee {
        width: 120px; /* Smaller bee for mobile */
    }
    
    #upgrade-sidebar {
        width: 100%;
        max-height: 40vh;
        overflow-y: auto;
    }
}

/* Game Entrance Animation */
.game-entrance {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, #FFD700, #B8860B);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    animation: fade-out 1.5s ease-out forwards;
    animation-delay: 1.5s;
    pointer-events: none;
}

.entrance-title {
    font-size: 3em;
    font-weight: bold;
    color: white;
    text-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
    margin-bottom: 20px;
    opacity: 0;
    transform: translateY(-50px);
    animation: title-entrance 1s ease-out forwards;
    animation-delay: 0.3s;
}

.entrance-bees-container {
    position: relative;
    width: 300px;
    height: 300px;
}

.entrance-bee {
    position: absolute;
    width: 50px;
    height: 50px;
    background-image: url('/bee-poster.png');
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0;
    animation: bee-fly-in 1.5s forwards;
}

@keyframes fade-out {
    0% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        visibility: hidden;
    }
}

@keyframes title-entrance {
    0% {
        opacity: 0;
        transform: translateY(-50px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bee-fly-in {
    0% {
        opacity: 0;
        transform: translate(var(--start-x), var(--start-y)) scale(0.2);
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 1;
        transform: translate(var(--end-x), var(--end-y)) scale(1);
    }
}