body {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #222; /* Dark background */
    color: #fff;
    font-family: 'Arial', sans-serif;
}

.game-container {
    text-align: center;
    background-color: #333;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
}

h1 {
    color: #FFD700; /* Gold */
    margin-bottom: 15px;
}

#canvas-wrapper {
    position: relative; /* Needed for absolute positioning of overlays */
    display: inline-block; /* Fit content size */
}

canvas {
    border: 2px solid #FFD700; /* Gold border */
    background-color: #000; /* Black play area */
    display: block;
}

#score {
    font-size: 1.2em;
    margin-bottom: 10px;
}

#message {
    color: #ff6347; /* Tomato */
    font-weight: bold;
    min-height: 1.5em; /* Reserve space */
    margin-bottom: 10px;
}

button, .home-button {
    background-color: #B8860B; /* DarkGoldenrod */
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    border: 1px solid #F0E68C; /* Khaki */
    font-size: 1em;
    cursor: pointer;
    transition: background-color 0.2s ease;
    text-decoration: none;
    display: inline-block;
    margin-top: 10px;
}

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

#upgrade-selection-overlay, #opponent-upgrade-log {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85); /* Darker overlay */
    color: #FFD700; /* Gold text */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 10;
    padding: 20px;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}

#upgrade-selection-overlay.hidden,
#opponent-upgrade-log.hidden,
#boss-message-overlay.hidden { 
    display: none;
}

#upgrade-title {
    margin-bottom: 20px;
    font-size: 1.8em;
    text-shadow: 1px 1px 2px #B8860B;
}

#opponent-upgrade-log h3 {
    margin-bottom: 15px;
    color: #ff4500; /* OrangeRed for wasp theme */
    font-size: 1.5em;
}

#upgrade-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 80%;
    max-width: 400px;
}

.upgrade-button-pong {
    background-color: #B8860B; /* DarkGoldenrod */
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    border: 2px solid #F0E68C; /* Khaki */
    font-size: 1em;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.upgrade-button-pong:hover {
    background-color: #DAA520; /* Goldenrod */
    transform: scale(1.03);
}

.upgrade-button-pong strong {
    display: block;
    font-size: 1.1em;
    margin-bottom: 5px;
}

.upgrade-button-pong span {
    font-size: 0.9em;
    color: #eee;
}

#opponent-upgrades-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: #ff6347; /* Tomato */
}

#opponent-upgrades-list li {
    background-color: rgba(255, 99, 71, 0.2); /* Light Tomato background */
    padding: 8px 12px; /* Slightly more padding */
    border-radius: 5px;
    border: 1px solid #ff4500;
    transition: background-color 0.3s ease, opacity 0.3s ease, transform 0.3s ease; /* Add transitions */
    margin-bottom: 8px; /* Add margin between items */
}

#opponent-upgrades-list li.chosen-opponent-upgrade {
    background-color: rgba(255, 69, 0, 0.6); /* Brighter OrangeRed background */
    color: #fff; /* White text */
    border-color: #fff; /* White border */
    transform: scale(1.05); /* Slightly larger */
    box-shadow: 0 0 8px rgba(255, 69, 0, 0.7);
}

#opponent-upgrades-list li.not-chosen-opponent-upgrade {
    opacity: 0.5; /* Fade out */
    background-color: rgba(100, 100, 100, 0.3); /* Dim background */
    border-color: #888; /* Dim border */
    transform: scale(0.95); /* Slightly shrink */
}

#boss-message-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    max-width: 500px;
    background-color: rgba(50, 0, 0, 0.9); /* Dark red tint */
    color: #ffcccc; /* Light red text */
    border: 3px solid red;
    border-radius: 10px;
    padding: 30px;
    text-align: center;
}

#boss-hp-container {
    position: absolute;
    top: 10px; /* Position below the top border */
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    max-width: 400px;
    background-color: rgba(50, 50, 50, 0.7); /* Dark semi-transparent background */
    border: 2px solid #ff4500; /* OrangeRed border */
    border-radius: 5px;
    padding: 5px;
    box-sizing: border-box;
    z-index: 5; /* Below overlays, above canvas content visually */
    text-align: center;
    box-shadow: 0 0 15px rgba(255, 69, 0, 0.7);
    transition: box-shadow 0.3s ease;
}

#boss-hp-container.danger {
    box-shadow: 0 0 25px rgba(255, 0, 0, 0.8);
}

#boss-hp-container.hidden {
    display: none;
}

#boss-hp-text {
    color: #ffcccc; /* Light red text */
    font-size: 0.9em;
    font-weight: bold;
    margin-bottom: 4px;
}

#boss-hp-bar-outer {
    height: 15px;
    background-color: #444; /* Dark grey background for the bar */
    border-radius: 3px;
    overflow: hidden; /* Keep inner bar contained */
}

#boss-hp-bar-inner {
    height: 100%;
    width: 100%; /* Start full */
    background: linear-gradient(to right, #FF4500, #FF0000);
    border-radius: 3px;
    transition: width 0.3s ease-out; /* Smooth HP loss animation */
    box-shadow: 0 0 5px rgba(255, 0, 0, 0.5);
}

/* D-pad Styles */
#dpad {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100; /* Ensure it's above the canvas */
}

#dpad button {
    background-color: #B8860B; /* DarkGoldenrod */
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.2s ease;
    width: 60px; /* Consistent button size */
    text-align: center;
}

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

/* Hide D-pad on larger screens */
@media (min-width: 769px) {
    #dpad {
        display: none;
    }
}

/* Make Game Screen Smaller for Mobile */
@media (max-width: 768px) {
    .game-container {
        width: 95%; /* Take up almost the full width */
        padding: 10px; /* Reduce padding */
    }

    canvas {
        max-width: 100%; /* Make canvas responsive */
        height: auto; /* Maintain aspect ratio */
    }

    #boss-message-overlay {
        width: 90%; /* Wider overlay on small screens */
        padding: 20px; /* Reduce padding */
    }
}

/* Pong Game Entrance Animation */
.pong-entrance {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    overflow: hidden;
    animation: fade-out 1.5s ease-out forwards;
    animation-delay: 2s;
    pointer-events: none;
}

.pong-title {
    color: #FFD700;
    font-size: 3em;
    text-shadow: 0 0 15px rgba(218, 165, 32, 0.7);
    margin-bottom: 40px;
    opacity: 0;
    animation: pong-title-in 1s forwards;
    animation-delay: 0.5s;
}

.pong-field {
    position: relative;
    width: 400px;
    height: 200px;
    border: 2px solid #FFD700;
}

.pong-paddle {
    position: absolute;
    width: 10px;
    height: 60px;
    background-color: #FFF;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    animation: paddle-grow 0.5s forwards;
}

.pong-paddle.left {
    left: 10px;
    animation-delay: 0.2s;
}

.pong-paddle.right {
    right: 10px;
    animation-delay: 0.3s;
}

.pong-ball {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #FFF;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    animation: ball-appear 0.3s forwards, ball-move 1.5s infinite alternate;
    animation-delay: 0.8s, 1.1s;
}

.pong-wasp {
    position: absolute;
    width: 30px;
    height: 30px;
    background-color: #FF0000;
    border-radius: 50%;
    right: 20px;
    top: 20px;
    opacity: 0;
    animation: wasp-appear 0.5s forwards;
    animation-delay: 1.5s;
}

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

@keyframes pong-title-in {
    0% { opacity: 0; transform: translateY(-30px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes paddle-grow {
    0% { transform: translateY(-50%) scaleY(0); }
    100% { transform: translateY(-50%) scaleY(1); }
}

@keyframes ball-appear {
    0% { transform: translate(-50%, -50%) scale(0); }
    100% { transform: translate(-50%, -50%) scale(1); }
}

@keyframes ball-move {
    0% { transform: translate(-50%, -50%); }
    25% { transform: translate(-150px, -30px); }
    50% { transform: translate(0, 40px); }
    75% { transform: translate(150px, -20px); }
    100% { transform: translate(-80px, 30px); }
}

@keyframes wasp-appear {
    0% { opacity: 0; transform: scale(0) rotate(0deg); }
    100% { opacity: 1; transform: scale(1) rotate(360deg); }
}

/* Music Controls */
.music-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

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

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

#music-volume {
    accent-color: #FFD700; /* Gold */
    width: 100px;
}

/* Boss Fight Effects */
@keyframes screen-shake {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    10%, 30%, 50%, 70%, 90% { transform: translate(-2px, 1px) rotate(-0.5deg); }
    20%, 40%, 60%, 80% { transform: translate(2px, -1px) rotate(0.5deg); }
}

.screen-shake {
    animation: screen-shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

/* Boss Phase elements */
.boss-warning {
    color: #FF4500; /* OrangeRed */
    font-weight: bold;
    font-size: 1.2em;
    text-shadow: 0 0 10px rgba(255, 69, 0, 0.7);
}

.boss-message-text {
    color: #FF6347; /* Tomato */
    font-size: 1.2em;
    line-height: 1.4;
    margin-bottom: 20px;
}

/* Custom Ability Indicators */
.warning-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 0, 0, 0.2);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.warning-flash.active {
    opacity: 1;
}

/* Projectile enhancements */
.player-projectile {
    box-shadow: 0 0 5px rgba(255, 255, 0, 0.7);
}

.player-special-projectile {
    box-shadow: 0 0 10px rgba(0, 191, 255, 0.9);
}

/* Boss abilities visual indicators */
.ability-indicator {
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 0.9em;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.7);
    pointer-events: none;
}