/* --- Arena --- */
#game-arena {
    width: 1000px;
    height: 550px;
    border: 5px solid #2E5016;
    position: relative;
    overflow: hidden;
    cursor: crosshair;
    background: linear-gradient(to bottom, #87CEEB 0%, #B0E0E6 30%, #E0F6FF 100%);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3), inset 0 0 20px rgba(255, 255, 255, 0.1);
}

/* === Tło === */
.background-zone {
    position: absolute;
    top: 0;
    height: 100%;
    z-index: 1;
}

#left-grass {
    left: 0;
    width: 460px;
    background: linear-gradient(135deg, #558B2F 0%, #689F38 50%, #7CB342 100%);
    background-image:
        linear-gradient(135deg, #558B2F 0%, #689F38 50%, #7CB342 100%),
        repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255, 255, 255, .05) 10px, rgba(255, 255, 255, .05) 20px);
    box-shadow: inset -5px 0 15px rgba(0, 0, 0, 0.2);
}

#river {
    left: 460px;
    width: 80px;
    background: linear-gradient(to bottom, #0D47A1 0%, #1565C0 25%, #1976D2 50%, #42A5F5 75%, #64B5F6 100%);
    box-shadow:
        inset 0 0 20px rgba(0, 0, 0, 0.3),
        inset 5px 0 10px rgba(0, 0, 0, 0.2),
        inset -5px 0 10px rgba(0, 0, 0, 0.2);
    animation: river-flow 8s linear infinite;
    background-size: 100% 200%;
}

@keyframes river-flow {
    0% {
        background-position: 0% 0%;
    }

    100% {
        background-position: 0% 100%;
    }
}

#right-grass {
    left: 540px;
    width: 460px;
    background: linear-gradient(135deg, #7CB342 0%, #689F38 50%, #558B2F 100%);
    background-image:
        linear-gradient(135deg, #7CB342 0%, #689F38 50%, #558B2F 100%),
        repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255, 255, 255, .05) 10px, rgba(255, 255, 255, .05) 20px);
    box-shadow: inset 5px 0 15px rgba(0, 0, 0, 0.2);
}

/* === Spawn Zone === */
#player-spawn-zone {
    position: absolute;
    left: 0;
    top: 0;
    width: 500px;
    height: 100%;
    background-color: rgba(144, 202, 249, 0.1);
    border-right: 2px dashed #90CAF9;
    box-sizing: border-box;
    z-index: 6;
}

/* Wieże */
.castle {
    width: 80px;
    height: 100px;
    border: 3px solid #424242;
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 10px;
    box-sizing: border-box;
    pointer-events: none;
    z-index: 10;
    border-radius: 8px 8px 4px 4px;
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.2),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2);
    transition: filter 0.15s ease, box-shadow 0.15s ease;
}

.main-castle {
    width: 100px;
    height: 120px;
    box-shadow:
        0 6px 12px rgba(0, 0, 0, 0.5),
        inset 0 2px 6px rgba(255, 255, 255, 0.3),
        inset 0 -2px 6px rgba(0, 0, 0, 0.3);
}

.player-castle {
    background: linear-gradient(to bottom, #BBDEFB 0%, #90CAF9 50%, #64B5F6 100%);
    left: 40px;
    border-color: #1976D2;
}

.enemy-castle {
    background: linear-gradient(to bottom, #FFCDD2 0%, #EF9A9A 50%, #E57373 100%);
    right: 40px;
    border-color: #C62828;
}

#player-tower-top,
#enemy-tower-top {
    top: 50px;
}

#player-tower-mid,
#enemy-tower-mid {
    top: 215px;
}

#player-tower-bottom,
#enemy-tower-bottom {
    bottom: 50px;
}

.hp-display {
    font-weight: bold;
    font-size: 11px;
    color: #FFFFFF;
    background: linear-gradient(to bottom, rgba(211, 47, 47, 0.9), rgba(183, 28, 28, 0.95));
    padding: 3px 6px;
    border-radius: 4px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Jednostki */
.unit {
    position: absolute;
    pointer-events: none;
    z-index: 11;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4));
    transition: filter 0.2s ease;
    /* Optymalizacja: informuje przeglądarkę, że te właściwości będą często zmieniane */
    will-change: transform;
}

.meerkat {
    width: 70px;
    height: 70px;
    background-image: url('../assets/units/meerkat/meerkat_idle.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: transparent;
    border: none;
    border-radius: 0;
    position: absolute;
    pointer-events: none;
    z-index: 11;
    transition: transform 0.1s, filter 0.2s;
}

.monkey {
    width: 30px;
    height: 30px;
    background: radial-gradient(circle at 30% 30%, #8D6E63, #6D4C41);
    border: 2px solid #4E342E;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.mole {
    width: 30px;
    height: 30px;
    background: radial-gradient(circle at 30% 30%, #8D6E63, #5D4037);
    border: 2px solid #3E2723;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.bat {
    width: 20px;
    height: 20px;
    background: radial-gradient(circle at 30% 30%, #8E24AA, #6A1B9A);
    border: 2px solid #4A148C;
    border-radius: 50%;
    box-shadow: 0 4px 8px rgba(106, 27, 154, 0.6), 0 0 10px rgba(142, 36, 170, 0.4);
    z-index: 12;
}

.antelope {
    width: 35px;
    height: 35px;
    background: linear-gradient(135deg, #EF5350, #E53935);
    border: 2px solid #C62828;
    border-radius: 10px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
}

.hedgehog {
    width: 30px;
    height: 30px;
    background: radial-gradient(circle at 30% 30%, #A1887F, #6D4C41);
    border: 3px dotted #8D6E63;
    border-radius: 50%;
    box-sizing: border-box;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), 0 0 8px rgba(161, 136, 127, 0.3);
}

.elephant {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #90A4AE, #607D8B);
    border: 3px solid #455A64;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
}

.hippo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #26A69A, #00796B);
    border: 3px solid #00695C;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
}

.vulture {
    width: 30px;
    height: 30px;
    background: radial-gradient(circle at 30% 30%, #6D4C41, #4E342E);
    border: 2px solid #3E2723;
    border-radius: 50%;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.6), 0 0 10px rgba(93, 64, 55, 0.4);
    z-index: 12;
}

.badger {
    width: 30px;
    height: 30px;
    background: radial-gradient(circle at 30% 30%, #BDBDBD, #757575);
    border: 2px solid #424242;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.turtle {
    width: 38px;
    height: 38px;
    background: radial-gradient(circle at 30% 30%, #43A047, #2E7D32);
    border: 3px solid #1B5E20;
    border-radius: 50%;
    box-sizing: border-box;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5), inset 0 -2px 4px rgba(0, 0, 0, 0.3);
}

.shell-broken-effect {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    background: #BCAAA4;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: shell-crack 0.5s ease-out forwards;
}

.ant_colony {
    width: 18px;
    height: 18px;
    background: radial-gradient(circle at 30% 30%, #8D6E63, #5D4037);
    border: 2px solid #3E2723;
    border-radius: 50%;
    position: absolute;
    pointer-events: none;
    z-index: 11;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.red_ant_colony {
    width: 18px;
    height: 18px;
    background: radial-gradient(circle at 30% 30%, #D32F2F, #B71C1C);
    border: 2px solid #800000;
    border-radius: 50%;
    position: absolute;
    pointer-events: none;
    z-index: 11;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 0 6px rgba(211, 47, 47, 0.3);
}

@keyframes shell-crack {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(5);
        opacity: 0;
    }
}

.grumpy_llama {
    width: 30px;
    height: 40px;
    background: linear-gradient(135deg, #DEB887, #D2B48C);
    border: 3px solid #8B4513;
    border-radius: 8px;
    box-sizing: border-box;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
}

.wolf_pack {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #607D8B, #546E7A);
    border: 2px solid #CFD8DC;
    border-radius: 20% 50% 20% 50%;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

/* Goryl - nasz Mega Knight */
.gorilla {
    width: 38px;
    height: 38px;
    background-color: #212121;
    /* Czarna sierść */
    border: 3px solid #000000;
    border-radius: 10px;
    /* Lekko kwadratowy, masywny */
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
    /* Cień bestii */
    position: absolute;
    z-index: 11;
    pointer-events: none;
    transition: transform 0.1s linear, box-shadow 0.2s ease-in-out;
}

.gorilla.charging-jump {
    animation: charge-pulse 0.5s infinite;
}

.gorilla.jumping {
    z-index: 12;
    box-shadow: 0 15px 25px rgba(0, 0, 0, 0.6);
}

@keyframes charge-pulse {
    0% {
        box-shadow: 0 0 10px rgba(255, 255, 100, 0.8);
    }

    50% {
        box-shadow: 0 0 20px 10px rgba(255, 200, 50, 0.9);
    }

    100% {
        box-shadow: 0 0 10px rgba(255, 255, 100, 0.8);
    }
}

/* Efekt lądowania po skoku */
.jump-landing-effect {
    position: absolute;
    border: 5px solid #6D4C41;
    border-radius: 50%;
    opacity: 1;
    transform: scale(0.2);
    animation: jump-impact-wave 0.5s ease-out forwards;
    z-index: 9;
    pointer-events: none;
    box-sizing: border-box;
}

@keyframes jump-impact-wave {
    0% {
        transform: scale(0.2);
        opacity: 0.9;
    }

    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* Efekt trzęsienia ekranu */
#game-arena.screen-shake {
    animation: screen-shake 0.2s linear;
}

@keyframes screen-shake {
    0% {
        transform: translate(0, 0);
    }

    25% {
        transform: translate(-3px, 2px);
    }

    50% {
        transform: translate(2px, -3px);
    }

    75% {
        transform: translate(-2px, 3px);
    }

    100% {
        transform: translate(0, 0);
    }
}

/* Efekt uderzenia przy lądowaniu */
.spawn-impact {
    position: absolute;
    border: 4px solid #FFF;
    border-radius: 50%;
    opacity: 1;
    transform: scale(0.5);
    animation: impact-wave 0.4s ease-out forwards;
    z-index: 20;
    pointer-events: none;
}

@keyframes impact-wave {
    0% {
        transform: scale(0.5);
        opacity: 1;
        border-color: #fff;
    }

    100% {
        transform: scale(2.5);
        opacity: 0;
        border-color: #ccc;
    }
}

/* Pociski */
.projectile {
    position: absolute;
    z-index: 15;
    pointer-events: none;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
    /* Optymalizacja: pociski ciągle się poruszają */
    will-change: transform;
}

.tower-shot {
    width: 10px;
    height: 10px;
    background: radial-gradient(circle at 30% 30%, #FFF176, #FFEB3B);
    border: 1px solid #F57F17;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(255, 235, 59, 0.8), 0 0 4px rgba(255, 193, 7, 0.6);
}

.banana {
    width: 15px;
    height: 7px;
    background: linear-gradient(135deg, #FFF59D, #FFF176);
    border: 1px solid #F9A825;
    border-radius: 10px 10px 0 0 / 5px 5px 0 0;
    transform: rotate(-45deg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.llama-spit-ball {
    width: 12px;
    height: 12px;
    background: radial-gradient(circle at 30% 30%, rgba(144, 238, 144, 0.9), rgba(34, 139, 34, 0.8));
    border: 1px solid #006400;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(144, 238, 144, 0.7), 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Efekt Czaru */
.spell-effect-indicator {
    position: absolute;
    border: 3px dashed #FFEB3B;
    border-radius: 50%;
    box-sizing: border-box;
    z-index: 50;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.5s ease-out;
    background-color: rgba(255, 235, 59, 0.1);
}

.spell-effect-indicator.enemy-spell {
    border-color: #F44336;
    background-color: rgba(244, 67, 54, 0.1);
}

/* Mosty */
.bridge {
    position: absolute;
    left: 460px;
    width: 80px;
    height: 100px;
    background: linear-gradient(to bottom, #8D6E63 0%, #A1887F 20%, #BCAAA4 50%, #A1887F 80%, #8D6E63 100%);
    background-image:
        linear-gradient(to bottom, #8D6E63 0%, #A1887F 20%, #BCAAA4 50%, #A1887F 80%, #8D6E63 100%),
        repeating-linear-gradient(90deg, transparent, transparent 8px, rgba(0, 0, 0, .1) 8px, rgba(0, 0, 0, .1) 9px);
    border-top: 5px solid #5D4037;
    border-bottom: 5px solid #5D4037;
    box-sizing: border-box;
    z-index: 5;
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.2),
        inset 0 -2px 4px rgba(0, 0, 0, 0.3);
}

#top-bridge {
    top: 50px;
}

#bottom-bridge {
    bottom: 50px;
}

/* Efekty Sudden Death */
.sd-particle {
    position: absolute;
    pointer-events: none;
    z-index: 1000;
}

.tiebreaker-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, transparent 50%, rgba(244, 67, 54, 0.3) 100%);
    z-index: 50;
    pointer-events: none;
    animation: pulseWarning 2s infinite;
}

@keyframes pulseWarning {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 0.7;
    }
}

/* Efekty Wizualne: Burza Śnieżna */
.snowflake {
    position: absolute;
    background-color: white;
    border-radius: 50%;
    pointer-events: none;
    z-index: 51;
    box-shadow: 0 0 10px rgba(173, 216, 230, 0.8);
}

.unit.frozen,
.castle.frozen {
    box-shadow: 0 0 15px 5px rgba(66, 165, 245, 0.9);
    filter: brightness(1.2) saturate(0.5);
    transition: box-shadow 0.2s ease-in-out, filter 0.2s ease-in-out;
}

/* Deploy Timer */
.deploy-timer {
    position: absolute;
    width: 30px;
    height: 30px;
    z-index: 20;
}

.deploy-spinner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    animation: spin linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- Ikony Kart --- */
/* (Style ikon kart powinny docelowo trafić do ui.css, ale na razie są tutaj) */
.wolf-pack-icon {
    background-color: #455A64;
    border: 2px solid #263238;
}