/* ============================================================
   ОБЩИЙ СБРОС И BODY
   Центрирует всё на экране, убирает отступы по умолчанию.
   overflow:hidden — скрывает полосы прокрутки, когда враги
   появляются у самого края окна.
============================================================ */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

/* ============================================================
   КАРТОЧКА МЕНЮ
   Общий стиль для главного меню, экрана сложности и паузы.
   Все три выглядят одинаково — JS просто показывает нужный.
============================================================ */
.menu {
    position: absolute;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 50px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 300px;
    z-index: 200; /* поверх игры и HUD */
}

.menu h1 {
    margin-bottom: 30px;
    font-size: 2em;
}

/* ============================================================
   КНОПКИ
   Используются везде: меню, пауза, экран окончания игры.
============================================================ */
button {
    padding: 15px;
    margin: 10px;
    font-size: 1.2em;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    width: 220px;
}

button:hover {
    background-color: #0056b3;
}

/* ============================================================
   ИГРОВОЙ КОНТЕЙНЕР
   Полноэкранная область игры. Скрыт до старта.
   Все игровые объекты (игрок, враги, пули) позиционируются
   абсолютно внутри этого div.
============================================================ */
.game-container {
    width: 100%;
    height: 100%;
    background-color: #2d2d2d;
    position: fixed;
    display: none;
}

/* ============================================================
   ИГРОК
   Синий квадрат 20×20px. Пушка и полоска HP — дочерние
   элементы, поэтому они двигаются вместе с игроком.
============================================================ */
.player {
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: blue;
    z-index: 2;
}

/* Красная точка внутри игрока, поворачивается в сторону врага */
.gun {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background-color: red;
    transition: all 0.1s ease-in-out;
}



/* ============================================================
   ВРАГ
   Тёмно-красный квадрат 20×20px. Появляется на случайном
   краю экрана и движется к игроку каждый кадр.
============================================================ */
.enemy {
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: darkred;
    z-index: 1;
    box-sizing: border-box;
}

/* Элитный враг — крупнее, фиолетовое свечение */
.enemy--elite {
    background: radial-gradient(circle at 30% 30%, #e8b4ff, #6b2d8a 55%, #3d1450);
    border: 1px solid rgba(255, 200, 255, 0.5);
    box-shadow: 0 0 12px rgba(180, 100, 255, 0.75), inset 0 0 6px rgba(255, 255, 255, 0.15);
}

/* Танк — медленный, тёмно-коричневый */
.enemy--brute {
    background: linear-gradient(145deg, #5c3d3d, #2a1818);
    border: 1px solid rgba(80, 50, 50, 0.6);
}

/* Рывок — ярко-красный, чуть агрессивнее вид */
.enemy--rusher {
    background: linear-gradient(145deg, #e74c3c, #922b21);
    box-shadow: 0 0 6px rgba(231, 76, 60, 0.45);
}

/* Орбитёр — холодный синеватый (держит дистанцию) */
.enemy--orbiter {
    background: linear-gradient(145deg, #5d6d7e, #2c3e50);
    border: 1px solid rgba(150, 170, 200, 0.35);
}

/* ============================================================
   ПУЛЯ
   Маленький чёрный квадрат 5×5px, летит в ближайшего врага.
   Удаляется из DOM при выходе за экран или попадании.
============================================================ */
.bullet {
    position: absolute;
    width: 5px;
    height: 5px;
    background-color: black;
    z-index: 3;
}

/* ============================================================
   ЭЛЕМЕНТЫ HUD
   Небольшие панели, закреплённые по углам экрана.
   Видны только во время игры (переключаются через JS).
============================================================ */

/* Верхний правый угол: оставшиеся патроны */
#ammo-indicator {
    font-size: 18px;
    color: white;
    padding: 10px 15px;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.7);
    position: fixed;
    right: 10px;
    top: 10px;
    z-index: 50;
    border-radius: 5px;
}

/* Верхний левый угол: номер текущей волны */
#wave-indicator {
    font-size: 18px;
    color: white;
    padding: 10px 15px;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.7);
    position: fixed;
    left: 10px;
    top: 10px;
    z-index: 50;
    border-radius: 5px;
}

/* Верхний центр: счётчик убийств */
#kill-counter {
    font-size: 18px;
    color: white;
    padding: 10px 15px;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.7);
    position: fixed;
    left: 50%;
    top: 10px;
    transform: translateX(-50%);
    z-index: 50;
    border-radius: 5px;
    min-width: 120px;
}

/* ============================================================
   БАННЕР ОБЪЯВЛЕНИЯ ВОЛНЫ
   Ненадолго появляется в центре экрана в начале каждой волны.
   pointer-events:none — клики проходят сквозь него.
============================================================ */
#wave-announce {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 36px;
    color: white;
    background-color: rgba(0, 0, 0, 0.75);
    padding: 20px 40px;
    border-radius: 10px;
    z-index: 60;
    pointer-events: none;
    text-align: center;
    white-space: pre-line; /* учитывает \n в тексте */
}

/* ============================================================
   ЭКРАН ОКОНЧАНИЯ ИГРЫ
   Центрированный оверлей при смерти игрока.
   Показывает итоговую статистику и кнопку возврата в меню.
============================================================ */
#game-over-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 280px;
    padding: 30px;
    text-align: center;
    color: white;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 100;
    border-radius: 10px;
    gap: 15px;
    white-space: pre-line;
}

#game-over-text {
    font-size: 22px;
    font-weight: bold;
    line-height: 1.6;
}

/* ============================================================
   ПОЛОСКИ HUD (HP и опыт) — внизу по центру
============================================================ */
#player-healthbar-wrap,
#experience-bar-wrap {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    background: linear-gradient(180deg, rgba(15, 15, 25, 0.92), rgba(25, 25, 40, 0.88));
    border: 2px solid rgba(255, 215, 0, 0.45);
    border-radius: 10px;
    padding: 10px 18px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

#player-healthbar-wrap {
    bottom: 72px;
    display: flex;
    align-items: center;
    gap: 10px;
}

#experience-bar-wrap {
    bottom: 16px;
    min-width: 320px;
    display: flex;
    align-items: center;
    gap: 10px;
}

#player-hp-label {
    color: #eee;
    font-size: 13px;
    font-weight: bold;
    min-width: 30px;
}

#player-hp-value {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    min-width: 70px;
    text-align: right;
}

#level-indicator {
    color: #87ceeb;
    font-size: 13px;
    font-weight: bold;
    min-width: 100px;
    text-shadow: 0 0 8px rgba(135, 206, 235, 0.5);
}

#player-healthbar-bg {
    width: min(52vw, 200px);
    height: 18px;
    background: linear-gradient(180deg, #1a1a1a, #0d0d0d);
    border-radius: 9px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.6);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5);
}

#player-healthbar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(180deg, #3ddc6f, #27ae60);
    border-radius: 8px;
    transition: width 0.12s linear, background 0.25s ease, filter 0.25s ease;
    box-shadow: 0 0 12px rgba(46, 204, 113, 0.35);
}

#experience-bar-bg {
    width: min(52vw, 200px);
    height: 14px;
    background: linear-gradient(180deg, #1a1a1a, #0d0d0d);
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.6);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5);
}

#exp-indicator {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4169e1, #87ceeb);
    border-radius: 6px;
    box-shadow: 0 0 10px rgba(65, 105, 225, 0.5);
    transition: width 0.15s ease-out;
}

/* Сообщение о повышении уровня */
#level-up-message {
    position: fixed;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 32px;
    color: #ffd700;
    background: linear-gradient(180deg, rgba(30, 30, 50, 0.95), rgba(20, 20, 40, 0.9));
    padding: 20px 40px;
    border-radius: 12px;
    z-index: 70;
    text-align: center;
    border: 2px solid #ffd700;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
    animation: levelUpPulse 0.5s ease-out;
}

@keyframes levelUpPulse {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.1); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* Кристалл опыта (выпадает с врага) */
.exp-gem {
    position: absolute;
    width: 14px;
    height: 14px;
    z-index: 4;
    pointer-events: none;
    background: linear-gradient(135deg, #7ec8ff, #4169e1);
    transform: rotate(45deg);
    box-shadow:
        0 0 8px rgba(65, 105, 225, 0.9),
        inset 0 0 4px rgba(255, 255, 255, 0.35);
    border: 1px solid rgba(200, 220, 255, 0.5);
}

