:root {
    --primary-yellow: #feca57;
    --primary-blue: #48dbfb;
    --dark-blue: #222f3e;
    --health-red: #ff6b6b;
    --health-green: #1dd1a1;
    --ui-bg: rgba(255, 255, 255, 0.9);
    --cat-white: #f5f6fa;
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Open Sans', sans-serif;
    background-color: #87ceeb;
}

#game-container {
    width: 200%;
    /* Wider than screen for horizontal scrolling if needed, but we'll stick to 100% for now */
    height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Background Layers */
.sky {
    position: absolute;
    width: 100%;
    height: 60%;
    background: linear-gradient(to bottom, #4facfe 0%, #00f2fe 100%);
    z-index: 1;
}

.ground {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 40%;
    background: linear-gradient(to top, #2ecc71, #27ae60);
    z-index: 2;
    border-top: 4px solid #145a32;
}

/* Battlefield */
#battlefield {
    position: absolute;
    width: 2000px;
    /* Long battlefield */
    height: 100%;
    z-index: 5;
    left: 0;
    transition: transform 0.1s ease-out;
}

.base {
    position: absolute;
    bottom: 30%;
    width: 120px;
    height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#player-base {
    left: 50px;
}

#enemy-base {
    right: 50px;
}

#cannon-beam {
    position: absolute;
    top: 50px;
    left: 100px;
    width: 0px;
    height: 100px;
    background: linear-gradient(to bottom, rgba(72, 219, 251, 0.2), rgba(72, 219, 251, 1), rgba(72, 219, 251, 0.2));
    z-index: 4;
    pointer-events: none;
    transition: width 0.1s;
    box-shadow: 0 0 50px var(--primary-blue);
    border-radius: 50px;
}

#cannon-beam.firing {
    width: 1800px;
    animation: beam-flicker 0.4s ease-out forwards;
}

@keyframes beam-flicker {
    0% {
        transform: scaleY(0.1);
        opacity: 1;
    }

    50% {
        transform: scaleY(1.5);
        opacity: 1;
    }

    100% {
        transform: scaleY(0);
        opacity: 0;
    }
}

.base-model {
    font-size: 100px;
    filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.3));
}

.hp-bar {
    width: 100px;
    height: 12px;
    background: #555;
    border: 2px solid white;
    border-radius: 6px;
    margin-bottom: 10px;
    overflow: hidden;
}

.hp-fill {
    width: 100%;
    height: 100%;
    background: var(--health-green);
    transition: width 0.3s;
}

/* Units */
.unit {
    position: absolute;
    bottom: 30%;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 40px;
    transition: transform 0.1s linear;
    filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.2));
}

.unit.enemy {
    transform: scaleX(-1);
}

.unit-hp {
    position: absolute;
    top: -15px;
    width: 30px;
    height: 4px;
    background: red;
}

/* HUD Top */
#top-hud {
    position: fixed;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    z-index: 100;
    pointer-events: none;
}

.money-container {
    background: var(--ui-bg);
    padding: 10px 30px;
    border-radius: 50px;
    font-family: 'Fredoka One', cursive;
    font-size: 1.5rem;
    color: var(--dark-blue);
    border: 4px solid var(--primary-yellow);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
}

.cannon-container {
    pointer-events: auto;
}

#fire-cannon-btn {
    width: 200px;
    height: 50px;
    background: #576574;
    border: 4px solid #ced6e0;
    border-radius: 10px;
    color: white;
    font-family: 'Fredoka One', cursive;
    position: relative;
    overflow: hidden;
    cursor: not-allowed;
}

#fire-cannon-btn.ready {
    background: var(--primary-blue);
    border-color: #fff;
    cursor: pointer;
    box-shadow: 0 0 15px var(--primary-blue);
}

#cannon-charge-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0%;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
}

.worker-level {
    pointer-events: auto;
}

#upgrade-worker-btn {
    background: #ff9f43;
    color: white;
    border: 4px solid #ee5253;
    padding: 10px 20px;
    border-radius: 15px;
    font-family: 'Fredoka One', cursive;
    cursor: pointer;
    transition: 0.2s;
}

#upgrade-worker-btn:hover {
    transform: scale(1.05);
}

#upgrade-worker-btn:active {
    transform: scale(0.95);
}

/* HUD Bottom */
#bottom-hud {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
}

.unit-slots {
    display: flex;
    gap: 15px;
    background: rgba(0, 0, 0, 0.5);
    padding: 15px;
    border-radius: 20px;
    backdrop-filter: blur(5px);
}

.unit-slot {
    width: 100px;
    height: 120px;
    background: white;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: 0.2s;
    border: 4px solid #ddd;
}

.unit-slot:hover {
    transform: translateY(-5px);
    border-color: var(--primary-blue);
}

.unit-slot.disabled {
    opacity: 0.6;
    filter: grayscale(0.8);
    cursor: not-allowed;
}

.unit-icon {
    font-size: 40px;
}

.unit-name {
    font-size: 0.7rem;
    font-weight: bold;
    text-align: center;
}

.unit-cost {
    font-family: 'Fredoka One', cursive;
    color: #ee5253;
}

.cooldown-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: rgba(0, 0, 0, 0.4);
}

/* Overlays */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.menu-card {
    background: white;
    padding: 50px;
    border-radius: 30px;
    text-align: center;
    border: 10px solid var(--primary-yellow);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.game-title {
    font-family: 'Fredoka One', cursive;
    font-size: 4rem;
    color: var(--dark-blue);
    margin: 0;
}

.subtitle {
    letter-spacing: 5px;
    color: #555;
}

button#start-btn,
.menu-card button {
    margin-top: 30px;
    padding: 20px 60px;
    font-family: 'Fredoka One', cursive;
    font-size: 2rem;
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 10px 0 #2980b9;
    transition: 0.2s;
}

button#start-btn:active {
    transform: translateY(10px);
    box-shadow: 0 0 0 #2980b9;
}

.hidden {
    display: none !important;
}

/* Combat Effects */
.hit-particle {
    position: absolute;
    font-size: 20px;
    color: red;
    font-weight: bold;
    pointer-events: none;
    animation: float-up 0.5s ease-out forwards;
}

@keyframes float-up {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateY(-50px);
        opacity: 0;
    }
}