/* --- styles.css --- */
        :root {
            --bg-color: #2e242a;
            --ui-bg: #1a1a1a;
            --text-color: #eee;
            --accent: #b4202a; /* Blood red */
            --upgrade-card: #3a3a4a;
        }

        body {
            margin: 0;
            padding: 0;
            background-color: #111;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            overflow: hidden;
            font-family: 'Courier New', Courier, monospace;
            color: var(--text-color);
            user-select: none;
        }

        /* Fill the entire viewport so the gameplay area is full-page.
           UI overlays are children of this container so they move with it. */
        #game-container {
            position: relative;
            width: 100vw;
            height: 100vh;
            background-color: var(--bg-color);
            background-image: url("../assets/img/parkinglot3.png");
            background-position: center center;
            background-size: cover;
            background-repeat: no-repeat;
            box-shadow: 0 0 20px rgba(0,0,0,0.5);
            overflow: hidden;
        }

        canvas {
            display: block;
            width: 100%;
            height: 100%;
            image-rendering: pixelated;
        }

        /* UI Overlays */
        .ui-layer {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            padding: 20px;
            box-sizing: border-box;
        }

        /* HUD */
        #hud {
            display: flex;
            justify-content: space-between;
            font-size: 24px;
            font-weight: bold;
            text-shadow: 2px 2px 0 #000;
            align-items: flex-start;
        }

        .bar-container {
            width: 200px;
            height: 20px;
            background: #444;
            border: 2px solid #000;
            margin-top: 5px;
            position: relative;
        }

        #hp-bar {
            width: 100%;
            height: 100%;
            background: #b4202a;
            transition: width 0.1s;
        }
        
        #lunge-bar {
            width: 100%;
            height: 100%;
            background: #4a90e2;
            transition: width 0.1s;
        }

        #infect-bar {
            width: 100%;
            height: 100%;
            background: #aaff2e;
            transition: width 0.1s;
        }

        .hud-section {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        /* Top-center HUD for Wave / Enemies / Minions */
        #top-center-hud {
            position: absolute;
            top: 12px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
            pointer-events: none;
            z-index: 15;
            padding: 6px 12px;
            background: rgba(0,0,0,0.18);
            border-radius: 8px;
            backdrop-filter: blur(2px);
        }

        #top-center-hud #wave-text {
            font-size: 1.1rem;
            font-weight: 800;
            color: #fff;
            letter-spacing: 1px;
            text-shadow: 2px 2px 0 #000;
        }

        #top-center-hud #enemies-text {
            font-size: 0.85rem;
            color: #ccc;
        }

        #top-center-hud #minion-text {
            font-size: 0.85rem;
            color: #aaff2e;
        }

        /* Bottom-center meters (Lunge / Infect) */
        #bottom-center-meters {
            position: absolute;
            bottom: 12px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            flex-direction: row; /* HP + meters column on left, mutations sidebar on right */
            gap: 16px;
            align-items: flex-end;
            pointer-events: none;
            z-index: 15;
            padding: 8px 12px;
            background: rgba(0,0,0,0.12);
            border-radius: 8px;
            min-width: 680px;
        }


        #bottom-center-meters .meter {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 6px;
            min-width: 160px;
        }

        #bottom-center-meters .meter-label {
            font-size: 0.85rem;
            color: #fff;
            text-shadow: 1px 1px 0 #000;
        }

        /* HP meter styling placed above the other meters */
        #hp-meter {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 6px;
            min-width: 260px;
        }

        /* Container holding HP above the meters */
        #hp-and-meters {
            display: flex;
            flex-direction: column;
            gap: 8px;
            align-items: center;
            min-width: 320px;
        }

        #hp-meter .hp-label {
            font-size: 0.95rem;
            color: #fff;
            text-shadow: 1px 1px 0 #000;
        }

        .hp-bar-wrap {
            width: 100%;
        }

        #hp-bar {
            width: 100%;
            height: 18px;
            background: #b4202a;
        }

        #meters-row {
            display: flex;
            flex-direction: row;
            gap: 12px;
            align-items: center;
            justify-content: center;
        }

        #meters-and-sidebar {
            display: flex;
            flex-direction: row;
            align-items: flex-end;
            gap: 12px;
        }


        #mutations-sidebar {
            width: 260px;
            max-width: 260px;
            background: rgba(0,0,0,0.08);
            padding: 10px 12px;
            border-radius: 8px;
            box-shadow: 0 8px 18px rgba(0,0,0,0.28);
        }

        /* Minions box sits to the right of the mutations sidebar at the bottom HUD area */
        #minions-box {
            display: flex;
            align-items: center;
            justify-content: center;
            align-self: flex-end;
            padding: 8px 12px;
            margin-left: 6px;
            background: rgba(0,0,0,0.04);
            border-radius: 8px;
            min-width: 140px;
            pointer-events: none;
            color: #aaff2e;
        }

        #minions-box #minion-text {
            font-size: 0.85rem;
            color: #aaff2e;
            font-weight: 700;
            text-align: center;
        }

        .mut-title {
            font-size: 1rem;
            font-weight: 800;
            color: #88bd26;
            margin-bottom: 8px;
            text-align: center;
        }

        #mutations-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
            max-height: 320px; /* larger so fewer/ no scrolls on most screens */
            overflow: auto;
        }

        .mut-item {
            display: flex;
            justify-content: space-between;
            font-size: 0.85rem;
            color: #eee;
            padding: 4px 6px;
            border-radius: 6px;
            background: rgba(255,255,255,0.02);
        }

        .mut-item .mut-lvl {
            color: #aaff2e;
            font-weight: 700;
        }

        /* Menus (Start, Upgrade, GameOver) */
        .menu-overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.85);
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            pointer-events: auto;
            z-index: 10;
        }

        .hidden {
            display: none !important;
        }

        h1 {
            font-size: 4rem;
            color: #88bd26;
            text-shadow: 4px 4px 0 #2a2a2a;
            margin: 0 0 20px 0;
        }

        h2 {
            font-size: 2rem;
            margin-bottom: 30px;
        }

        button {
            background: #88bd26;
            color: #1a1a1a;
            border: 4px solid #000;
            padding: 15px 30px;
            font-size: 1.5rem;
            font-family: inherit;
            cursor: pointer;
            margin: 10px;
            transition: transform 0.1s;
        }

        button:hover {
            transform: scale(1.05);
            background: #aaff2e;
        }

        /* Enable audio button on start screen */
        #enable-audio-btn {
            background: #88bd26;
            color: #111;
            border: 3px solid #000;
            padding: 10px 18px;
            font-size: 1rem;
            cursor: pointer;
            border-radius: 8px;
        }

        /* Pause Button */
        #pause-btn {
            position: absolute;
            top: 20px;
            right: 20px;
            width: 50px;
            height: 50px;
            background: transparent;
            border: 3px solid #fff;
            color: #fff;
            font-size: 24px;
            font-weight: bold;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            opacity: 0.3;
            transition: opacity 0.2s, transform 0.1s;
            z-index: 20;
            pointer-events: auto;
            border-radius: 8px;
        }

        #pause-btn:hover {
            opacity: 1;
            background: rgba(255,255,255,0.1);
        }

        /* Screenshot button (to the left of pause) */
        #screenshot-btn {
            position: absolute;
            top: 20px;
            right: 86px; /* placed left of pause button */
            width: 50px;
            height: 50px;
            background: transparent;
            border: 3px solid #fff;
            color: #fff;
            font-size: 20px;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            opacity: 0.3;
            transition: opacity 0.2s, transform 0.1s;
            z-index: 20;
            pointer-events: auto;
            border-radius: 8px;
        }

        #screenshot-btn:hover { opacity: 1; background: rgba(255,255,255,0.06); }

        /* Volume sliders inside pause screen */
        #volume-controls input[type="range"] {
            width: 100%;
        }
        #volume-controls label { font-size: 0.95rem; }

        /* Upgrade Cards Grid */
        #upgrade-grid {
            display: flex;
            gap: 20px;
            flex-wrap: wrap;
            justify-content: center;
        }

        .upgrade-card {
            background: var(--upgrade-card);
            border: 3px solid #666;
            padding: 20px;
            width: 320px; /* increased width to accommodate artwork */
            text-align: center;
            cursor: pointer;
            transition: all 0.2s;
            position: relative;
            overflow: hidden;
        }

        .upgrade-card:hover {
            border-color: #fff;
            background: #4a4a5a;
            transform: translateY(-5px);
        }

        /* Visual for currently selected upgrade when navigating */
        .upgrade-card.selected {
            border-color: #88bd26;
            box-shadow: 0 6px 18px rgba(136,189,38,0.15), 0 0 0 4px rgba(136,189,38,0.06) inset;
            transform: translateY(-6px) scale(1.02);
        }

        .upgrade-title {
            color: #88bd26;
            font-size: 1.2rem;
            margin-bottom: 10px;
            font-weight: bold;
        }

        .upgrade-desc {
            font-size: 0.9rem;
            color: #ccc;
        }
        
        .stat-label {
            font-size: 0.8rem;
            color: #888;
            margin-top: 5px;
        }

        /* Upgrade artwork */
        .upgrade-art {
            width: 96px;
            height: 96px;
            object-fit: contain;
            display: block;
            margin: 0 auto 10px auto;
        }

        /* When card has artwork, make it fill and overlay text at bottom */
        .upgrade-card.has-art {
            /* Use contain so the whole artwork fits without cropping */
            background-size: contain;
            background-position: center center;
            background-repeat: no-repeat;
            color: #fff;
            min-height: 380px; /* taller to fit artwork aspect ratios */
            padding: 0; /* overlay handles padding */
            border: none; /* remove visible box border so art replaces the card */
            box-shadow: none;
            border-radius: 12px;
            background-color: transparent;
        }

        .upgrade-card .upgrade-overlay {
            position: absolute;
            left: 0;
            right: 0;
            bottom: 0;
            padding: 16px 18px;
            background: rgba(0,0,0,0.62);
            box-sizing: border-box;
            text-align: center;
        }

        /* Hover/selected visuals when artwork is used */
        .upgrade-card.has-art:hover {
            transform: translateY(-6px) scale(1.01);
            filter: brightness(1.02);
        }

        .upgrade-card.has-art.selected {
            box-shadow: 0 8px 26px rgba(0,0,0,0.45);
            /* Slight zoom of the artwork to make it look bigger when selected */
            background-size: 120%;
            transform: translateY(-6px) scale(1.02);
        }

        /* Smaller inner highlight frame for selection */
        .upgrade-card.has-art::after {
            content: '';
            position: absolute;
            left: 10px; /* revert to previous horizontal inset */
            right: 10px;
            top: 20px; /* raise top to shorten highlight height */
            bottom: 10px; /* keep a small bottom inset */
            border-radius: 10px;
            pointer-events: none;
            box-shadow: inset 0 0 0 0 rgba(136,189,38,0); /* hidden by default */
            transition: box-shadow 120ms ease, opacity 120ms ease;
            opacity: 0;
        }

        .upgrade-card.has-art.selected::after {
            box-shadow: inset 0 0 0 4px rgba(136,189,38,0.14); /* revert to thicker inset */
            opacity: 1;
        }
        /* Hide overlay text entirely when artwork used (artwork contains description) */
        .upgrade-card.has-art .upgrade-overlay { display: none; }

        /* Fallback state when art file missing */
        .upgrade-card.art-missing {
            background: var(--upgrade-card);
            color: inherit;
            padding: 20px;
            min-height: auto;
        }

    