/* styles.css */

:root {
    --bg-color-center: #4c2a4c;
    --bg-color-outer: #1c0f1f;
    --player-aura-color: #fadf7f;
    --enemy-color: #1a1a1a;
    --enemy-accent-color: #ff3333;
    --projectile-color: #ffffff;
    --xp-orb-color: #87ceeb;
    --damage-text-color: #ffffff;
    --hud-bg: rgba(0, 0, 0, 0.4);
    --hud-text: #ffffff;
    --hp-bar: #f44336;
    --xp-bar: #4caf50;
    --modal-bg: #2a2d42;
    --modal-border: #7b84a3;
    --card-bg: #3a3f5e;
    --card-hover-bg: #4e547b;
    --bones-color: rgba(90, 120, 90, 0.3);
    --cracks-color: rgba(120, 50, 180, 0.4);
    --lightning-color: #9dffff;
    --volcano-color: #ff8c00;
    --safe-house-fill: rgba(161, 232, 232, 0.15);
    --safe-house-stroke: rgba(209, 250, 250, 0.5);
    /* NEW: Modal specific colors/shadows */
    --modal-shadow: rgba(0,0,0,0.9);
    --card-shadow: rgba(0,0,0,0.5);
    --bulletstorm-color: #00e0ff; /* Bright neon blue for bulletstorm projectiles */
    --xp-orb-color: #87ceeb; /* Existing light blue */
    --highlight-xp-orb-color: #ffd700; /* NEW: A bright gold/yellow for emphasis */

    /* NEW: Boss specific color */
    --boss-hp-color: #ff0000; /* Red for boss health bar */
}
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
html, body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: radial-gradient(circle, var(--bg-color-center) 0%, var(--bg-color-outer) 80%);
    color: var(--hud-text);
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
}

/* Ensure main-menu starts visible and game-container starts hidden by default CSS */
#main-menu {
    display: flex; /* Or block, based on its internal layout */
    /* Other styles for main menu - if you have more, keep them here */
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    visibility: hidden; /* Hidden by default, controlled by JS */
}
canvas {
    background: transparent;
    image-rendering: auto;
    width: 100%;
    height: 100%;
    cursor: default;
}
.hud {
    position: absolute;
    display: flex;
    align-items: center;
    padding: 5px 15px;
    background: var(--hud-bg);
    border-radius: 5px;
    z-index: 10;
}
#hud-top-left {
    top: 20px;
    left: 20px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px; /* Original gap between elements */
    padding: 10px 15px; /* Slightly more padding for the whole top-left HUD */
}

/* NEW: Styles for Stage and Wave text */
#stage-wave-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px; /* Small gap between Stage and Wave lines */
    margin-bottom: 5px; /* Space above HP bar */
}

#stage-text, #wave-text {
    font-family: 'Press Start 2P', cursive; /* Retro font for stage/wave */
    font-size: 16px;
    color: var(--player-aura-color); /* Highlight color */
    text-shadow: 2px 2px #000;
}


/* NEW: Styles for the upgrade stats list */
#upgrade-stats-list {
    margin-top: 15px; /* Space between HP bar and upgrade list */
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px; /* Tight spacing between individual stat lines */
    max-height: 200px; /* Limit height to prevent it from growing too big */
    overflow-y: auto; /* Add scrollbar if content exceeds max-height */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: var(--player-aura-color) transparent; /* Firefox */
    padding-right: 5px; /* Space for potential scrollbar */
}

/* For Webkit browsers (Chrome, Safari) */
#upgrade-stats-list::-webkit-scrollbar {
    width: 6px;
}
#upgrade-stats-list::-webkit-scrollbar-track {
    background: transparent;
}
#upgrade-stats-list::-webkit-scrollbar-thumb {
    background-color: var(--player-aura-color);
    border-radius: 3px;
}


.upgrade-stat-item {
    font-family: 'Roboto', sans-serif; /* Readable font for stats */
    font-size: 14px; /* Clear but not too large */
    color: #b0c4de; /* Slightly muted color to differentiate from main HUD text */
    white-space: nowrap; /* Prevent text wrapping within a stat line */
}

/* Optional: Make current values stand out a bit more */
.upgrade-stat-item strong {
    color: var(--player-aura-color);
}
.hud-main-stats {
    display: flex;
    align-items: center;
    gap: 15px;
}
#hud-top-right {
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}
#timer-text {
    font-size: 22px;
}
#kill-counter {
    font-size: 16px;
}
#hp-bar-container {
    width: 200px;
    height: 15px;
    background: rgba(0,0,0,0.5);
    border-radius: 5px;
    border: 1px solid #fff;
    overflow: hidden;
}
#hp-bar-fill {
    width: 100%;
    height: 100%;
    background: var(--hp-bar);
    transition: width 0.2s linear;
}
#hp-text, #level-text {
    font-size: 16px;
}
#xp-bar-bottom-container {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    max-width: 60%;
    height: 10px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #fff;
    border-radius: 5px;
    overflow: hidden;
    z-index: 10;
}
#xp-bar-bottom-fill {
    width: 0%;
    height: 100%;
    background: var(--xp-bar);
    transition: width 0.2s linear;
}

/* Positioning for Auto Mode and Hyper Beam buttons */
#auto-mode-button, #hyperBeamButton {
    position: absolute;
    bottom: 20px; /* Aligns with the bottom HUD bar */
    background-color: #6c757d;
    border: 1px solid #fff;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    font-size: 14px;
    z-index: 15; /* Above XP bar */
}

#auto-mode-button {
    left: 20px;
}

#hyperBeamButton {
    right: 20px;
    /* Styles for visibility handled by JS */
}

#auto-mode-button.auto-on {
    background-color: var(--player-aura-color);
    color: #000;
}

/* NEW: Next Wave Incoming message */
#next-wave-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Press Start 2P', cursive;
    font-size: 48px;
    color: var(--player-aura-color);
    text-shadow: 6px 6px 0 #000;
    z-index: 1000; /* Ensure it's on top of everything */
    white-space: nowrap;
    display: none; /* Hidden by default, controlled by JS */
}

/* NEW: Boss Health Bar */
#boss-health-bar-container {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 500px; /* Wider for boss */
    max-width: 80%; /* Responsive width */
    height: 25px; /* Taller */
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid var(--modal-border);
    border-radius: 10px;
    overflow: hidden;
    z-index: 100; /* Above regular HUD, below modals */
    display: none; /* Hidden by default, controlled by JS */
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.5); /* Red glow for boss HP */
}

#boss-health-bar-fill {
    width: 100%;
    height: 100%;
    background: var(--boss-hp-color);
    transition: width 0.2s linear;
    border-radius: 8px; /* Slightly less rounded than container */
}


/* MODAL / LEVEL-UP WINDOW ENHANCEMENTS */
.modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: var(--modal-bg);
    border: 3px solid var(--modal-border);
    border-radius: 15px;
    padding: 30px; /* Increased padding */
    text-align: center;
    box-shadow: 0 10px 30px var(--modal-shadow); /* Stronger, darker shadow */
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    width: 95%; /* Make it slightly wider on smaller screens */
    max-width: 900px; /* Increased max-width for more cards */
    font-family: 'Press Start 2P', cursive;
}
.modal.visible {
    opacity: 1;
    pointer-events: all;
    transform: translate(-50%, -50%) scale(1);
}
.modal h2 {
    margin-bottom: 25px;
    font-size: 32px; /* Increased title font size */
    color: var(--player-aura-color);
    text-shadow: 4px 4px #000; /* Stronger text shadow */
}

/* NEW: Style for the level-up timer display */
#level-up-timer-display {
    font-family: 'Press Start 2P', cursive; /* Match modal title font */
    font-size: 40px; /* Large and prominent */
    color: var(--player-aura-color); /* Matches title color, stands out */
    text-shadow: 4px 4px #000; /* Strong shadow for readability */
    margin-bottom: 20px; /* Space between timer and upgrade cards */
    display: block; /* Ensure it takes full width and centers text */
    width: 100%;
    text-align: center;
    /* Optional: Add a subtle pulse animation */
    animation: pulseTimer 1s infinite alternate;
}

/* Animation for the timer pulse */
@keyframes pulseTimer {
    from {
        transform: scale(1);
        opacity: 1;
    }
    to {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

/* Style for when the timer is low (e.g., last 3 seconds) */
#level-up-timer-display.low-time {
    color: yellow; /* Change to yellow for urgency */
    animation: none; /* Stop the pulse or change it to a faster, more urgent pulse if desired */
}


#upgrade-options {
    display: flex;
    flex-direction: column; /* Default for small screens */
    gap: 20px; /* Increased gap between cards */
    justify-content: center; /* Center items horizontally when wrapped */
    align-items: stretch; /* NEW: Ensures all cards in a row have the same height */
    flex-wrap: wrap; /* Allow upgrade cards to wrap to the next line */
    padding: 10px;
    margin-bottom: 20px; /* Space between cards and XP bar */
}

@media (min-width: 768px) {
    #upgrade-options {
        flex-direction: row; /* Keep row for larger screens */
    }
}

.upgrade-card {
    background: var(--card-bg);
    border: 2px solid var(--modal-border);
    border-radius: 10px; /* Slight roundness */
    padding: 25px; /* Increased internal padding */
    flex: 0 0 calc(33.33% - 20px); /* Adjusting calc for 3 cards per row with 20px gap */
    max-width: 280px; /* Increased max-width for individual cards */
    min-height: 150px; /* Ensure a minimum height for visual consistency */
    box-sizing: border-box;
    cursor: pointer;
    transition: all 0.2s ease, transform 0.1s ease; /* Softer hover transition */
    text-align: left;
    position: relative; /* For inner shadow */
    overflow: hidden; /* Prevent text overflow if too long */

    /* NEW: Subtle inner border/shadow for depth */
    box-shadow: inset 0 0 10px var(--card-shadow), 0 5px 15px var(--card-shadow);
}
.upgrade-card:hover {
    background: var(--card-hover-bg);
    transform: translateY(-8px) scale(1.02); /* More pronounced lift and slight scale */
    border-color: var(--player-aura-color); /* Highlight border on hover */
    box-shadow: inset 0 0 15px rgba(255,255,255,0.1), 0 8px 20px var(--modal-shadow); /* Enhanced shadow */
}

.upgrade-card h3 {
    font-family: 'Press Start 2P', cursive; /* Keep retro font for title */
    font-size: 18px; /* Increased title font size */
    margin-bottom: 12px; /* More space below title */
    color: #fff; /* White title */
    text-shadow: 2px 2px #000; /* Small text shadow for definition */
    line-height: 1.2; /* Better line spacing for titles */
}
.upgrade-card p {
    font-family: 'Roboto', sans-serif; /* NEW: Use Roboto for descriptions for readability */
    font-size: 15px; /* Increased description font size */
    line-height: 1.6; /* Better line spacing for descriptions */
    color: #e0e0e0; /* Slightly lighter color for descriptions */
}

.stat-bar {
    width: 100%;
    height: 10px;
    background: #444;
    border-radius: 5px;
    overflow: hidden;
    margin-top: 15px;
}
#xp-bar-fill {
    height: 100%;
    background: var(--xp-bar);
}
#restart-button {
    font-family: 'Press Start 2P', cursive;
    font-size: 18px;
    padding: 15px 30px;
    background: var(--player-aura-color);
    color: #000;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    text-shadow: none;
    margin-top: 25px; /* Added space */
}

/* Ensure mobile styling for the modal too */
@media (max-width: 767px) {
    .modal {
        padding: 20px;
        width: 95%;
        max-width: 400px; /* Restrict width on very small screens */
    }
    .modal h2 {
        font-size: 24px;
    }
    #level-up-timer-display { /* Adjust timer size for smaller screens */
        font-size: 32px;
    }
    .upgrade-card {
        flex: 1 1 100%; /* Make cards take full width on small screens */
        max-width: none; /* Remove max-width constraint */
        padding: 15px;
        font-size: 16px;
    }
    .upgrade-card h3 {
        font-size: 16px;
    }
    .upgrade-card p {
        font-size: 14px;
    }

    /* Adjust new HUD elements for smaller screens */
    #next-wave-message {
        font-size: 32px; /* Smaller font on mobile */
    }
    #boss-health-bar-container {
        width: 90%; /* Take more width on mobile */
        height: 20px; /* Slightly less tall */
    }
    /* Reposition buttons for mobile */
    #auto-mode-button {
        bottom: 10px; /* Closer to edge */
        left: 10px;
    }
    #hyperBeamButton {
        bottom: 10px;
        right: 10px;
    }
}
