/* =========================================================
   Minecraft Creeper Defense
   style.css
   ========================================================= */

/* =========================
   RESET
========================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --green: #4caf50;
    --green-dark: #2f7d32;
    --green-light: #73d677;

    --grass: #5f9f3f;
    --grass-dark: #3f6f2c;

    --stone: #59636b;
    --stone-dark: #353c42;
    --stone-light: #7c8992;

    --dirt: #76523b;
    --dirt-dark: #513726;

    --gold: #f7c843;
    --red: #e34b4b;
    --orange: #f28a30;
    --blue: #5db9ff;

    --panel: rgba(24, 29, 31, 0.96);
    --panel-light: rgba(46, 55, 59, 0.96);

    --text: #ffffff;
    --muted: #c7d0d4;

    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

html {
    width: 100%;
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    font-family: Arial, Helvetica, sans-serif;
    background: #101719;
    color: var(--text);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

button {
    font: inherit;
}

button,
.tower-card,
.build-spot {
    touch-action: manipulation;
}

/* =========================
   COMMON
========================= */

.hidden {
    display: none !important;
}

.screen {
    position: relative;
    z-index: 2;
    width: 100%;
    min-height: 100vh;
}

.active-screen {
    display: flex;
}

#gameBackground {
    position: fixed;
    inset: 0;
    z-index: 0;

    background:
        linear-gradient(
            rgba(9, 19, 14, 0.32),
            rgba(7, 12, 10, 0.72)
        ),
        repeating-linear-gradient(
            0deg,
            rgba(255, 255, 255, 0.02) 0,
            rgba(255, 255, 255, 0.02) 2px,
            transparent 2px,
            transparent 32px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.02) 0,
            rgba(255, 255, 255, 0.02) 2px,
            transparent 2px,
            transparent 32px
        ),
        linear-gradient(
            180deg,
            #315d3b 0%,
            #244c31 35%,
            #152b20 100%
        );
}

.minecraft-btn {
    border: 3px solid #151b16;
    border-bottom-width: 6px;
    border-radius: 7px;

    background: linear-gradient(
        180deg,
        #6a7670,
        #46514c
    );

    color: white;

    padding: 13px 20px;

    font-weight: 800;
    font-size: 15px;

    cursor: pointer;

    box-shadow:
        inset 0 2px rgba(255, 255, 255, 0.18),
        var(--shadow);

    transition:
        transform 0.15s ease,
        filter 0.15s ease,
        border-bottom-width 0.15s ease;
}

.minecraft-btn:hover {
    filter: brightness(1.12);
    transform: translateY(-2px);
}

.minecraft-btn:active {
    transform: translateY(2px);
    border-bottom-width: 3px;
}

.primary-btn {
    background: linear-gradient(
        180deg,
        #64c94d,
        #318d32
    );
}

.danger-btn {
    border: 2px solid #8e2525;
    border-radius: 6px;

    background: #b93232;
    color: white;

    padding: 10px 16px;

    font-weight: bold;
    cursor: pointer;
}

.danger-btn:hover {
    background: #d33b3b;
}

/* =========================
   MAIN MENU
========================= */

#mainMenu {
    align-items: center;
    justify-content: center;

    padding: 28px 18px;
}

.menu-card {
    width: min(620px, 100%);

    text-align: center;

    padding: 40px 34px;

    background:
        linear-gradient(
            rgba(37, 46, 43, 0.96),
            rgba(20, 27, 25, 0.98)
        );

    border: 4px solid #17201b;
    border-radius: 14px;

    box-shadow:
        inset 0 0 0 2px rgba(255, 255, 255, 0.05),
        0 18px 60px rgba(0, 0, 0, 0.5);
}

.title-icon {
    font-size: 58px;
    margin-bottom: 12px;
    animation: titleFloat 2.4s ease-in-out infinite;
}

@keyframes titleFloat {
    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-7px);
    }
}

.menu-card h1 {
    font-size: clamp(32px, 6vw, 58px);

    line-height: 1.03;

    text-shadow:
        3px 3px 0 #1a321b,
        6px 6px 0 rgba(0, 0, 0, 0.25);

    margin-bottom: 10px;
}

.game-subtitle {
    color: var(--green-light);

    font-size: 18px;
    font-weight: 800;

    margin-bottom: 18px;
}

.story-text {
    max-width: 480px;

    margin: 0 auto 27px;

    line-height: 1.65;
    color: var(--muted);
}

.menu-buttons {
    display: grid;
    gap: 12px;

    max-width: 390px;
    margin: 0 auto;
}

.menu-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;

    margin-top: 26px;
}

.menu-stat {
    padding: 14px;

    border: 2px solid #35433d;
    border-radius: 8px;

    background: rgba(255, 255, 255, 0.04);
}

.menu-stat-label {
    display: block;

    color: var(--muted);

    font-size: 12px;
    font-weight: bold;

    text-transform: uppercase;
    letter-spacing: 1px;

    margin-bottom: 5px;
}

.menu-stat strong {
    color: var(--gold);
    font-size: 25px;
}

/* =========================
   POPUP PANELS
========================= */

.popup-panel {
    position: fixed;
    inset: 0;
    z-index: 50;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;

    background: rgba(5, 8, 7, 0.78);
    backdrop-filter: blur(5px);
}

.popup-content {
    position: relative;

    width: min(600px, 100%);
    max-height: 88vh;

    overflow-y: auto;

    padding: 31px;

    border: 4px solid #1b241f;
    border-radius: 12px;

    background: var(--panel);

    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.55);
}

.popup-content h2 {
    font-size: 28px;
    margin-bottom: 22px;
}

.close-btn,
.small-close-btn {
    border: none;
    color: white;
    background: transparent;

    cursor: pointer;

    font-weight: bold;
}

.close-btn {
    position: absolute;

    top: 14px;
    right: 16px;

    width: 38px;
    height: 38px;

    border-radius: 5px;

    background: #9d3030;
}

.close-btn:hover {
    background: #c33939;
}

.instructions-list {
    display: grid;
    gap: 11px;
}

.instruction-item {
    display: flex;
    align-items: center;
    gap: 13px;

    padding: 12px;

    border-radius: 8px;

    background: rgba(255, 255, 255, 0.05);
}

.instruction-item span {
    flex-shrink: 0;

    display: grid;
    place-items: center;

    width: 34px;
    height: 34px;

    border-radius: 5px;

    background: var(--green-dark);

    font-weight: bold;
}

.instruction-item p {
    color: #e3e8e5;
    line-height: 1.5;
}

.settings-content {
    max-width: 550px;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 25px;

    padding: 18px 0;

    border-bottom: 1px solid #404b46;
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-row h3 {
    margin-bottom: 5px;
}

.setting-row p {
    color: var(--muted);
    font-size: 13px;
}

.setting-toggle {
    min-width: 90px;

    padding: 10px 12px;

    border: 2px solid #283129;
    border-radius: 6px;

    background: #4e5551;
    color: white;

    font-weight: 800;

    cursor: pointer;
}

.setting-toggle.enabled {
    background: var(--green-dark);
}

/* =========================
   GAME SCREEN
========================= */

#gameScreen {
    padding-top: 78px;

    background:
        linear-gradient(
            rgba(10, 20, 15, 0.2),
            rgba(5, 10, 8, 0.6)
        );
}

/* =========================
   HUD
========================= */

#gameHud {
    position: fixed;

    top: 0;
    left: 0;
    right: 0;

    z-index: 25;

    min-height: 66px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;

    padding: 8px 14px;

    border-bottom: 3px solid #181f1b;

    background: rgba(24, 30, 28, 0.97);

    box-shadow: 0 5px 16px rgba(0, 0, 0, 0.3);
}

.hud-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 8px;

    min-width: 104px;

    padding: 7px 10px;

    border: 2px solid #3f4d46;
    border-radius: 6px;

    background: #303a36;
}

.hud-item small {
    display: block;

    color: #b9c4be;

    font-size: 10px;
    font-weight: bold;

    text-transform: uppercase;
}

.hud-item strong {
    font-size: 17px;
}

.hud-icon {
    font-size: 23px;
}

.coins-hud strong {
    color: var(--gold);
}

.health-hud strong {
    color: #ff7777;
}

.hud-actions {
    display: flex;
    gap: 7px;
}

.icon-btn {
    width: 42px;
    height: 42px;

    border: 2px solid #222b26;
    border-radius: 6px;

    background: #48534e;
    color: white;

    font-size: 20px;

    cursor: pointer;
}

.icon-btn:hover {
    background: #5a6861;
}

/* =========================
   WAVE CONTROLS
========================= */

#waveControls {
    width: calc(100% - 30px);
    max-width: 1400px;

    margin: 0 auto 13px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;

    padding: 12px 15px;

    border: 2px solid #344139;
    border-radius: 8px;

    background: rgba(32, 39, 36, 0.94);
}

#waveStatus {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

#waveMessage {
    font-weight: bold;
}

#waveCountdown {
    color: var(--gold);
    font-size: 13px;
}

.wave-btn {
    white-space: nowrap;
}

/* =========================
   MAIN GAME LAYOUT
========================= */

#gameLayout {
    width: calc(100% - 30px);
    max-width: 1400px;

    margin: auto;

    display: grid;
    grid-template-columns: 255px minmax(0, 1fr);
    gap: 14px;

    padding-bottom: 20px;
}

/* =========================
   TOWER SHOP
========================= */

#towerShop {
    align-self: start;

    padding: 14px;

    border: 3px solid #202823;
    border-radius: 10px;

    background: var(--panel);

    box-shadow: var(--shadow);
}

.panel-title {
    padding-bottom: 12px;
    margin-bottom: 12px;

    border-bottom: 1px solid #445149;
}

.panel-title h2 {
    font-size: 21px;
    margin-bottom: 6px;
}

.panel-title p {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.4;
}

.tower-card {
    position: relative;

    width: 100%;

    display: grid;
    grid-template-columns: 42px 1fr;
    gap: 10px;

    text-align: left;

    margin-bottom: 9px;
    padding: 10px;

    border: 2px solid #4a5951;
    border-radius: 7px;

    background: #35413b;
    color: white;

    cursor: pointer;

    transition:
        transform 0.15s ease,
        border-color 0.15s ease,
        background 0.15s ease;
}

.tower-card:hover {
    transform: translateX(3px);
    border-color: var(--green-light);
    background: #3c4c44;
}

.tower-card.selected {
    border-color: var(--gold);

    background:
        linear-gradient(
            90deg,
            rgba(247, 200, 67, 0.17),
            #3b4942
        );

    box-shadow: 0 0 0 2px rgba(247, 200, 67, 0.15);
}

.tower-card.locked {
    opacity: 0.52;
    cursor: not-allowed;
}

.tower-icon {
    display: grid;
    place-items: center;

    width: 42px;
    height: 42px;

    border-radius: 5px;

    background: rgba(255, 255, 255, 0.08);

    font-size: 25px;
}

.tower-info {
    min-width: 0;
}

.tower-info strong {
    display: block;

    margin-bottom: 2px;

    font-size: 13px;
}

.tower-info > span {
    display: block;

    color: #bbc6c0;

    font-size: 10px;
    line-height: 1.25;

    margin-right: 5px;
}

.tower-card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;

    margin-top: 6px;
}

.tower-card-stats small {
    padding: 3px 5px;

    border-radius: 4px;

    background: #27322d;

    color: #d8e0dc;

    font-size: 8px;
}

.tower-price {
    grid-column: 1 / -1;

    color: var(--gold);

    font-size: 12px;
    font-weight: bold;

    margin-top: 1px;
}

.cancel-placement-btn {
    width: 100%;

    padding: 10px;

    border: 2px solid #922d2d;
    border-radius: 6px;

    background: #b13838;
    color: white;

    font-weight: bold;

    cursor: pointer;
}

/* =========================
   BATTLEFIELD CONTAINER
========================= */

#battlefieldContainer {
    position: relative;

    min-width: 0;
}

#battlefield {
    position: relative;

    width: 100%;
    height: 650px;

    overflow: hidden;

    border: 5px solid #1a241b;
    border-radius: 10px;

    background:
        linear-gradient(
            rgba(255, 255, 255, 0.02),
            rgba(0, 0, 0, 0.08)
        ),
        repeating-linear-gradient(
            0deg,
            transparent 0,
            transparent 47px,
            rgba(44, 89, 37, 0.25) 48px,
            rgba(44, 89, 37, 0.25) 49px
        ),
        repeating-linear-gradient(
            90deg,
            transparent 0,
            transparent 47px,
            rgba(44, 89, 37, 0.25) 48px,
            rgba(44, 89, 37, 0.25) 49px
        ),
        #679947;

    box-shadow:
        inset 0 0 40px rgba(0, 0, 0, 0.2),
        var(--shadow);
}

/* =========================
   MAP DECORATIONS
========================= */

.map-decoration {
    position: absolute;
    z-index: 2;

    pointer-events: none;

    filter: drop-shadow(3px 4px 2px rgba(0, 0, 0, 0.25));
}

.tree {
    font-size: 42px;
}

.rock {
    font-size: 31px;
}

.tree-1 {
    top: 4%;
    left: 5%;
}

.tree-2 {
    bottom: 8%;
    left: 42%;
}

.tree-3 {
    top: 8%;
    right: 8%;
}

.rock-1 {
    bottom: 5%;
    left: 10%;
}

.rock-2 {
    top: 42%;
    right: 5%;
}

/* =========================
   ENEMY ENTRANCE
========================= */

#enemyEntrance {
    position: absolute;

    left: 0;
    top: 48%;

    z-index: 7;

    transform: translateY(-50%);

    display: flex;
    flex-direction: column;
    align-items: center;

    padding: 7px 9px;

    border: 3px solid #432a21;
    border-left: none;
    border-radius: 0 7px 7px 0;

    background: #66412e;

    box-shadow: 3px 5px 8px rgba(0, 0, 0, 0.25);
}

#enemyEntrance span {
    color: var(--gold);
    font-size: 21px;
}

#enemyEntrance small {
    font-size: 8px;
    font-weight: bold;
}

/* =========================
   PATH
========================= */

#enemyPath {
    position: absolute;
    inset: 0;

    z-index: 1;

    pointer-events: none;
}

.path-segment {
    position: absolute;

    background:
        repeating-linear-gradient(
            45deg,
            #b29a70 0,
            #b29a70 9px,
            #aa9269 9px,
            #aa9269 18px
        );

    border: 2px solid rgba(94, 69, 45, 0.38);

    box-shadow:
        inset 0 0 10px rgba(0, 0, 0, 0.08),
        0 3px 7px rgba(0, 0, 0, 0.1);
}

/*
   S-shaped enemy road
*/

.path-1 {
    left: 0;
    top: 43%;

    width: 25%;
    height: 72px;
}

.path-2 {
    left: 22%;
    top: 23%;

    width: 72px;
    height: 26%;
}

.path-3 {
    left: 22%;
    top: 23%;

    width: 33%;
    height: 72px;
}

.path-4 {
    left: 50%;
    top: 23%;

    width: 72px;
    height: 42%;
}

.path-5 {
    left: 50%;
    top: 55%;

    width: 31%;
    height: 72px;
}

.path-6 {
    left: 76%;
    top: 55%;

    width: 24%;
    height: 72px;
}

/* =========================
   BUILD SPOTS
========================= */

.build-spot {
    position: absolute;
    z-index: 10;

    width: 58px;
    height: 58px;

    display: grid;
    place-items: center;

    transform: translate(-50%, -50%);

    border: 3px dashed rgba(255, 255, 255, 0.65);
    border-radius: 50%;

    background: rgba(33, 91, 45, 0.66);
    color: rgba(255, 255, 255, 0.85);

    font-size: 28px;
    font-weight: bold;

    cursor: pointer;

    box-shadow:
        inset 0 0 12px rgba(0, 0, 0, 0.15),
        0 4px 9px rgba(0, 0, 0, 0.15);

    transition:
        transform 0.15s ease,
        background 0.15s ease,
        border-color 0.15s ease;
}

.build-spot:hover {
    transform: translate(-50%, -50%) scale(1.1);

    background: rgba(51, 132, 65, 0.82);
    border-color: white;
}

.build-spot.valid-placement {
    background: rgba(75, 190, 84, 0.8);

    border-color: #d7ffd9;

    animation: buildPulse 1s infinite;
}

.build-spot.invalid-placement {
    background: rgba(185, 53, 53, 0.72);

    border-color: #ff9999;
}

.build-spot.occupied {
    border: 2px solid rgba(25, 40, 29, 0.8);
    background: rgba(31, 55, 37, 0.25);
    color: transparent;
}

@keyframes buildPulse {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(93, 255, 109, 0.45);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(93, 255, 109, 0);
    }
}

/*
    Build spot positions
*/

.build-spot[data-spot="1"] {
    left: 12%;
    top: 29%;
}

.build-spot[data-spot="2"] {
    left: 14%;
    top: 66%;
}

.build-spot[data-spot="3"] {
    left: 31%;
    top: 12%;
}

.build-spot[data-spot="4"] {
    left: 38%;
    top: 42%;
}

.build-spot[data-spot="5"] {
    left: 43%;
    top: 76%;
}

.build-spot[data-spot="6"] {
    left: 59%;
    top: 12%;
}

.build-spot[data-spot="7"] {
    left: 64%;
    top: 43%;
}

.build-spot[data-spot="8"] {
    left: 65%;
    top: 76%;
}

.build-spot[data-spot="9"] {
    left: 79%;
    top: 31%;
}

.build-spot[data-spot="10"] {
    left: 83%;
    top: 76%;
}

.build-spot[data-spot="11"] {
    left: 91%;
    top: 42%;
}

.build-spot[data-spot="12"] {
    left: 91%;
    top: 87%;
}

/* =========================
   VILLAGE
========================= */

#village {
    position: absolute;

    right: 1.4%;
    top: 55%;

    z-index: 8;

    transform: translateY(-50%);

    display: flex;
    flex-direction: column;
    align-items: center;

    min-width: 105px;

    padding: 10px 8px;

    border: 4px solid #49301d;
    border-radius: 8px;

    background:
        linear-gradient(
            #a67b47,
            #7d5832
        );

    box-shadow:
        0 8px 15px rgba(0, 0, 0, 0.28),
        inset 0 2px rgba(255, 255, 255, 0.15);
}

.village-house {
    font-size: 43px;
    line-height: 1;
}

.villagers {
    font-size: 15px;
    margin-top: 3px;
}

#village > span {
    margin-top: 4px;

    font-size: 9px;
    font-weight: bold;
}

/* =========================
   RANGE PREVIEW
========================= */

#towerRangePreview {
    position: absolute;

    z-index: 6;

    width: 220px;
    height: 220px;

    transform: translate(-50%, -50%);

    border: 2px dashed rgba(255, 255, 255, 0.75);
    border-radius: 50%;

    background: rgba(92, 210, 107, 0.11);

    pointer-events: none;
}

/* =========================
   DYNAMIC GAME LAYERS
========================= */

#towerLayer,
#enemyLayer,
#projectileLayer,
#effectLayer {
    position: absolute;
    inset: 0;

    pointer-events: none;
}

#towerLayer {
    z-index: 11;
}

#enemyLayer {
    z-index: 13;
}

#projectileLayer {
    z-index: 15;
}

#effectLayer {
    z-index: 18;
}

/* =========================
   TOWER VISUALS
========================= */

.game-tower {
    position: absolute;

    width: 55px;
    height: 55px;

    transform: translate(-50%, -50%);

    display: grid;
    place-items: center;

    border: 3px solid #28342b;
    border-radius: 8px;

    background: #596b5e;

    box-shadow:
        0 6px 8px rgba(0, 0, 0, 0.3),
        inset 0 2px rgba(255, 255, 255, 0.16);

    font-size: 30px;

    pointer-events: auto;
    cursor: pointer;

    transition:
        transform 0.16s ease,
        filter 0.16s ease;
}

.game-tower:hover {
    transform: translate(-50%, -50%) scale(1.08);
    filter: brightness(1.08);
}

.game-tower.selected {
    outline: 3px solid var(--gold);
    outline-offset: 3px;
}

.game-tower.level-2::after,
.game-tower.level-3::after {
    content: "";

    position: absolute;

    right: -5px;
    top: -7px;

    width: 18px;
    height: 18px;

    display: grid;
    place-items: center;

    border-radius: 50%;

    background: var(--gold);
    color: #3b2c00;

    font-size: 10px;
    font-weight: 900;
}

.game-tower.level-2::after {
    content: "2";
}

.game-tower.level-3::after {
    content: "3";
}

/* =========================
   ENEMY VISUALS
========================= */

.enemy {
    position: absolute;

    width: 46px;
    min-height: 50px;

    transform: translate(-50%, -50%);

    display: flex;
    flex-direction: column;
    align-items: center;

    pointer-events: none;
}

.enemy-character {
    position: relative;

    z-index: 2;

    font-size: 30px;

    filter: drop-shadow(2px 3px 2px rgba(0, 0, 0, 0.3));
}

.enemy-name {
    display: none;
}

.enemy-health-bar {
    width: 42px;
    height: 6px;

    overflow: hidden;

    margin-bottom: 3px;

    border: 1px solid #141414;
    border-radius: 2px;

    background: #3b1515;
}

.enemy-health-fill {
    width: 100%;
    height: 100%;

    background: #55d35e;

    transform-origin: left center;
}

.enemy.boss .enemy-character {
    font-size: 43px;

    animation: bossFloat 1.1s ease-in-out infinite;
}

.enemy.boss::after {
    content: "BOSS";

    padding: 2px 5px;

    border-radius: 3px;

    background: #932626;

    font-size: 8px;
    font-weight: 900;
}

@keyframes bossFloat {
    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

/* =========================
   PROJECTILES
========================= */

.projectile {
    position: absolute;

    z-index: 15;

    transform: translate(-50%, -50%);

    pointer-events: none;
}

.projectile.arrow {
    width: 17px;
    height: 4px;

    border-radius: 4px;

    background: #f4d39c;

    box-shadow: 0 0 7px rgba(255, 233, 184, 0.8);
}

.projectile.snowball {
    width: 11px;
    height: 11px;

    border-radius: 50%;

    background: white;

    box-shadow: 0 0 9px rgba(207, 244, 255, 0.9);
}

.projectile.fireball {
    width: 15px;
    height: 15px;

    border-radius: 50%;

    background: #ff8c27;

    box-shadow:
        0 0 5px #ffe46d,
        0 0 12px #ff5a23;
}

.projectile.cannonball {
    width: 15px;
    height: 15px;

    border-radius: 50%;

    background: #2c2f31;

    box-shadow: 0 0 7px rgba(255, 70, 35, 0.45);
}

/* =========================
   EFFECTS
========================= */

.damage-number {
    position: absolute;

    z-index: 20;

    transform: translate(-50%, -50%);

    color: #fff2aa;

    font-weight: 900;
    font-size: 15px;

    text-shadow: 1px 2px #4a2918;

    pointer-events: none;

    animation: damageFloat 0.7s ease-out forwards;
}

@keyframes damageFloat {
    from {
        opacity: 1;
        transform: translate(-50%, -20%);
    }

    to {
        opacity: 0;
        transform: translate(-50%, -90%);
    }
}

.coin-effect {
    position: absolute;

    z-index: 20;

    font-size: 18px;

    pointer-events: none;

    animation: coinFly 0.9s ease-out forwards;
}

@keyframes coinFly {
    0% {
        opacity: 0;
        transform: translate(-50%, -20%) scale(0.7);
    }

    30% {
        opacity: 1;
        transform: translate(-50%, -60%) scale(1.2);
    }

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

.explosion-effect {
    position: absolute;

    width: 60px;
    height: 60px;

    transform: translate(-50%, -50%);

    border-radius: 50%;

    background:
        radial-gradient(
            circle,
            #fff5a2 0%,
            #ff9f2e 32%,
            #e24626 55%,
            rgba(226, 70, 38, 0) 72%
        );

    pointer-events: none;

    animation: explosion 0.45s ease-out forwards;
}

@keyframes explosion {
    from {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.25);
    }

    to {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.6);
    }
}

.upgrade-effect {
    position: absolute;

    width: 72px;
    height: 72px;

    transform: translate(-50%, -50%);

    border: 3px solid var(--gold);
    border-radius: 50%;

    pointer-events: none;

    animation: towerUpgradeEffect 0.7s ease-out forwards;
}

@keyframes towerUpgradeEffect {
    from {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.3);
    }

    to {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.7);
    }
}

/* =========================
   SELECTED TOWER PANEL
========================= */

#selectedTowerPanel {
    width: 100%;

    margin-top: 10px;
    padding: 13px;

    border: 3px solid #202823;
    border-radius: 9px;

    background: var(--panel);

    box-shadow: var(--shadow);
}

.selected-tower-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;

    margin-bottom: 12px;
}

.selected-tower-header small {
    display: block;

    color: var(--muted);

    font-size: 10px;

    text-transform: uppercase;
}

.selected-tower-header h3 {
    margin-top: 2px;
}

.small-close-btn {
    width: 32px;
    height: 32px;

    border-radius: 5px;

    background: #833131;
}

.selected-tower-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.selected-tower-stats > div {
    padding: 8px;

    text-align: center;

    border: 1px solid #48534d;
    border-radius: 5px;

    background: #303a35;
}

.selected-tower-stats small {
    display: block;

    margin-bottom: 3px;

    color: var(--muted);

    font-size: 9px;
}

.tower-action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;

    margin-top: 10px;
}

.upgrade-btn,
.sell-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;

    padding: 10px;

    border-radius: 6px;

    color: white;

    font-weight: bold;

    cursor: pointer;
}

.upgrade-btn {
    border: 2px solid #996f16;

    background: #b8871d;
}

.upgrade-btn:hover {
    background: #d09b25;
}

.upgrade-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.sell-btn {
    border: 2px solid #32623b;

    background: #3e7e49;
}

.sell-btn:hover {
    background: #4a9557;
}

/* =========================
   MOBILE SHOP BUTTON
========================= */

.mobile-shop-btn {
    display: none;

    position: fixed;

    right: 15px;
    bottom: 15px;

    z-index: 30;

    padding: 11px 15px;

    border: 3px solid #162019;
    border-radius: 7px;

    background: #397e3d;
    color: white;

    font-weight: bold;

    box-shadow: var(--shadow);

    cursor: pointer;
}

/* =========================
   OVERLAYS
========================= */

.game-overlay {
    position: fixed;
    inset: 0;

    z-index: 80;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;

    background: rgba(5, 8, 7, 0.82);
    backdrop-filter: blur(4px);
}

.overlay-card {
    width: min(500px, 100%);

    padding: 32px 25px;

    text-align: center;

    border: 4px solid #1f2822;
    border-radius: 12px;

    background: #252d29;

    box-shadow:
        0 20px 70px rgba(0, 0, 0, 0.55),
        inset 0 2px rgba(255, 255, 255, 0.05);
}

.overlay-icon {
    font-size: 55px;
    margin-bottom: 9px;
}

.overlay-card h2 {
    font-size: 34px;
    margin-bottom: 9px;
}

.overlay-card p {
    color: var(--muted);
    line-height: 1.5;

    margin-bottom: 20px;
}

.game-over-card {
    border-color: #5d2929;
}

.game-over-card h2 {
    color: #ff7474;
}

.victory-card {
    border-color: #a88731;
}

.victory-card h2 {
    color: #ffd75b;
}

.victory-stars {
    color: var(--gold);

    margin-bottom: 5px;

    font-size: 20px;

    animation: victoryStars 1s ease-in-out infinite alternate;
}

@keyframes victoryStars {
    from {
        transform: scale(0.95);
    }

    to {
        transform: scale(1.08);
    }
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;

    margin-bottom: 18px;
}

.result-stats > div {
    padding: 10px;

    border-radius: 6px;

    background: #313b36;
}

.result-stats small {
    display: block;

    color: var(--muted);

    font-size: 9px;

    margin-bottom: 4px;
}

.result-stats strong {
    color: var(--gold);
    font-size: 21px;
}

.result-buttons {
    display: grid;
    gap: 9px;
}

/* =========================
   BOSS WARNING
========================= */

.boss-warning {
    position: fixed;

    left: 50%;
    top: 105px;

    z-index: 65;

    transform: translateX(-50%);

    width: min(520px, calc(100% - 30px));

    display: flex;
    align-items: center;
    gap: 15px;

    padding: 14px 18px;

    border: 3px solid #7f2424;
    border-radius: 8px;

    background:
        linear-gradient(
            90deg,
            rgba(112, 21, 21, 0.97),
            rgba(54, 17, 17, 0.97)
        );

    box-shadow:
        0 0 28px rgba(255, 46, 46, 0.4),
        var(--shadow);

    animation: bossWarningPulse 0.7s ease-in-out infinite alternate;
}

.boss-warning-icon {
    font-size: 38px;
}

.boss-warning strong {
    display: block;

    color: #ffd04e;

    font-size: 22px;
}

.boss-warning span {
    color: #f2dddd;

    font-size: 12px;
}

@keyframes bossWarningPulse {
    from {
        transform: translateX(-50%) scale(1);
    }

    to {
        transform: translateX(-50%) scale(1.025);
    }
}

/* =========================
   GAME NOTIFICATION
========================= */

.game-notification {
    position: fixed;

    left: 50%;
    bottom: 25px;

    z-index: 100;

    transform: translateX(-50%);

    max-width: calc(100% - 30px);

    padding: 11px 18px;

    border: 2px solid #43554a;
    border-radius: 7px;

    background: rgba(25, 34, 29, 0.96);

    box-shadow: var(--shadow);

    font-size: 13px;
    font-weight: bold;

    text-align: center;
}

/* =========================
   LOW HEALTH EFFECT
========================= */

.low-health #battlefield {
    animation: dangerFlash 0.9s ease-in-out infinite alternate;
}

@keyframes dangerFlash {
    from {
        box-shadow:
            inset 0 0 20px rgba(255, 0, 0, 0.08),
            var(--shadow);
    }

    to {
        box-shadow:
            inset 0 0 45px rgba(255, 0, 0, 0.26),
            var(--shadow);
    }
}

/* =========================
   SCREEN SHAKE
========================= */

.screen-shake {
    animation: screenShake 0.25s linear;
}

@keyframes screenShake {
    0% {
        transform: translate(0, 0);
    }

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

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

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

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

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 1100px) {

    #gameHud {
        align-items: flex-start;
    }

    .hud-item {
        min-width: 90px;
    }

    #gameLayout {
        grid-template-columns: 220px minmax(0, 1fr);
    }

    #towerShop {
        padding: 10px;
    }

    .tower-card {
        grid-template-columns: 35px 1fr;
    }

    .tower-icon {
        width: 35px;
        height: 35px;

        font-size: 21px;
    }

    #battlefield {
        height: 590px;
    }

}

@media (max-width: 850px) {

    #gameScreen {
        padding-top: 125px;
    }

    #gameHud {
        flex-direction: column;

        padding: 8px 10px;
    }

    .hud-group {
        width: 100%;

        display: grid;
        grid-template-columns: repeat(5, 1fr);
    }

    .hud-item {
        min-width: 0;
        padding: 6px;
    }

    .hud-icon {
        display: none;
    }

    .hud-actions {
        position: absolute;

        right: 8px;
        top: 74px;
    }

    #gameLayout {
        grid-template-columns: 1fr;
    }

    #towerShop {
        position: fixed;

        z-index: 40;

        left: 12px;
        bottom: 12px;

        width: min(340px, calc(100% - 24px));
        max-height: 73vh;

        overflow-y: auto;

        transform: translateY(calc(100% + 30px));

        transition: transform 0.25s ease;
    }

    #towerShop.mobile-open {
        transform: translateY(0);
    }

    .mobile-shop-btn {
        display: block;
    }

    #battlefield {
        height: 560px;
    }

    #selectedTowerPanel {
        margin-bottom: 70px;
    }

}

@media (max-width: 650px) {

    #mainMenu {
        padding: 15px;
    }

    .menu-card {
        padding: 30px 18px;
    }

    .menu-card h1 {
        font-size: 36px;
    }

    .title-icon {
        font-size: 46px;
    }

    .menu-stats {
        grid-template-columns: 1fr 1fr;
    }

    .popup-content {
        padding: 26px 17px;
    }

    .setting-row {
        flex-direction: column;
        align-items: flex-start;
    }

    #gameScreen {
        padding-top: 133px;
    }

    #gameHud {
        min-height: 116px;
    }

    .hud-group {
        grid-template-columns: repeat(3, 1fr);
    }

    .hud-item:nth-child(4),
    .hud-item:nth-child(5) {
        grid-column: auto;
    }

    .hud-item small {
        font-size: 8px;
    }

    .hud-item strong {
        font-size: 14px;
    }

    .hud-actions {
        top: auto;
        bottom: 6px;
        right: 8px;
    }

    .icon-btn {
        width: 34px;
        height: 31px;

        font-size: 15px;
    }

    #waveControls {
        width: calc(100% - 18px);

        flex-direction: column;
        align-items: stretch;

        text-align: center;
    }

    .wave-btn {
        width: 100%;
    }

    #gameLayout {
        width: calc(100% - 18px);
    }

    #battlefield {
        height: 520px;
    }

    .build-spot {
        width: 47px;
        height: 47px;

        font-size: 22px;
    }

    #enemyEntrance {
        padding: 5px;
    }

    #enemyEntrance small {
        display: none;
    }

    #village {
        min-width: 77px;
        padding: 7px 4px;
    }

    .village-house {
        font-size: 34px;
    }

    .villagers {
        font-size: 12px;
    }

    #village > span {
        font-size: 7px;
    }

    .selected-tower-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .tower-action-buttons {
        grid-template-columns: 1fr;
    }

    .result-stats {
        grid-template-columns: 1fr;
    }

    .boss-warning {
        top: 145px;
    }

}

@media (max-width: 430px) {

    .menu-card h1 {
        font-size: 31px;
    }

    .game-subtitle {
        font-size: 15px;
    }

    .story-text {
        font-size: 13px;
    }

    #battlefield {
        height: 485px;
    }

    .build-spot {
        width: 41px;
        height: 41px;

        border-width: 2px;

        font-size: 20px;
    }

    .tree {
        font-size: 30px;
    }

    .rock {
        font-size: 24px;
    }

    #village {
        right: 0.3%;
    }

}

/* =========================
   VERY SMALL DEVICES
========================= */

@media (max-width: 360px) {

    .hud-group {
        grid-template-columns: repeat(2, 1fr);
    }

    #gameScreen {
        padding-top: 167px;
    }

    #gameHud {
        min-height: 151px;
    }

    .boss-warning {
        top: 178px;
    }

    #battlefield {
        height: 460px;
    }

}