/* Общие стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none; /* запрет выделения текста для всех элементов */
}

html {
    height: 100%;
    height: 100dvh;
    height: calc(var(--vh, 1vh) * 100);
    width: 100%;
    overflow: hidden;
    position: fixed;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #000;
    color: white;
    height: 100vh;
    height: 100dvh; /* Динамическая высота viewport для мобильных */
    height: calc(var(--vh, 1vh) * 100); /* Фиксированная высота через CSS переменную */
    width: 100vw;
    width: 100dvw;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none; /* запрет копирования/выделения */
    -webkit-touch-callout: none; /* iOS запрет контекстного меню */
    touch-action: manipulation; /* снижение двойного тап-зума */
}

body.bg-black {
    background-color: #000 !important;
    transition: background-color 0.5s ease;
}

body.bg-green {
    background-color: #043004 !important; /* тёмный токсичный зелёный */
    transition: background-color 0.5s ease;
}

.game-container {
    height: 100vh;
    height: 100dvh; /* Динамическая высота для мобильных */
    height: calc(var(--vh, 1vh) * 100); /* Фиксированная высота */
    width: 100vw;
    width: 100dvw;
    display: flex;
    flex-direction: column;
    background-color: #000;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
}

/* Верхняя панель */
.top-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    height: 60px;
    background-color: rgba(0, 0, 0, 0.8);
    position: relative; /* для центрирования жизней */
}

.timer {
    font-size: 24px;
    font-weight: bold;
    color: #00ff00;
    font-family: 'Courier New', monospace;
}

.balance {
    font-size: 20px;
    font-weight: bold;
    color: #ffff00;
}

.lives-top {
    font-size: 18px;
    font-weight: bold;
    color: #ff6666;
    pointer-events: none;
}

.rank-display {
    font-size: 18px;
    font-weight: bold;
    color: white;
    pointer-events: none;
    transition: color 0.3s ease;
}

.pause-btn {
    width: 40px;
    height: 40px;
    background-color: #666;
    border: 2px solid #999;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    transition: all 0.3s ease;
}

.pause-btn:hover {
    background-color: #777;
}

.pause-btn:active {
    background-color: #555;
}

.lives {
    font-size: 18px;
    font-weight: bold;
    color: #ff6666;
}

/* Игровое поле */
.game-field {
    flex: 1;
    position: relative;
    background-color: #000;
    z-index: 10; /* поле выше панели апгрейдов */
}

/* Звезда (hai.tgs) на фоне */
.hai-animation {
    position: fixed;
    width: 90px;
    height: 90px;
    opacity: 0.1;
    z-index: 15;
    pointer-events: none; /* не реагирует на клики */
}

/* Горизонтальная пунктирная линия */
.horizontal-line {
    position: absolute;
    bottom: 60px; /* Было 120px, теперь в два раза ближе */
    left: 0;
    right: 0;
    height: 3px;
    background-image: linear-gradient(to right, #00aa00 50%, transparent 50%);
    background-size: 20px 3px;
    background-repeat: repeat-x;
    opacity: 0.35; /* в два раза прозрачнее */
    z-index: 1500; /* пунктир над спрайтом игрока */
}

/* Дорожки */
.tracks {
    display: flex;
    height: 100%;
}

.track {
    flex: 1;
    /* делаем линию более прозрачной через цвет границы,
       чтобы не влиять на потомков (персонажи/пули остаются непрозрачными) */
    border-right: 2px solid rgba(0, 170, 0, 0.3);
    position: relative; /* чтобы абсолютные персонажи позиционировались внутри дорожки */
}

/* Персонажи (контейнер анимации) */
.character {
    position: absolute;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 100%; /* вписаться по ширине дорожки */
    max-width: 100%;
    height: 90px; /* базовая высота; при необходимости можно подправить */
    pointer-events: none; /* чтобы клики проходили сквозь */
}

/* Бочка (спец-объект) визуально ведёт себя как персонаж */
.barrel {
    position: absolute;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 100%;
    max-width: 100%;
    height: 90px;
    pointer-events: none;
}

/* Ящик-буст (crate) */
.crate {
    position: absolute;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 100%;
    max-width: 100%;
    height: 90px;
    pointer-events: none;
}

/* Пчела */
.bee {
    position: absolute;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 100%;
    max-width: 100%;
    height: 90px;
    pointer-events: none;
}

/* Сердце (добавляет жизнь) */
.heart-item {
    position: absolute;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 100%;
    max-width: 100%;
    height: 80px;
    pointer-events: none;
}

/* Босс */
.boss {
    position: absolute;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 100%;
    max-width: 100%;
    height: 110px; /* немного крупнее */
    pointer-events: none;
}

.devil {
    position: absolute;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 100%;
    max-width: 100%;
    height: 110px;
    pointer-events: none;
}

.devil .hp {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: -20px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    line-height: 1;
    color: #e0e0e0;
    pointer-events: none;
    white-space: nowrap;
    opacity: 0.5; /* 50% прозрачность */
}

.devil .hp .heart {
    color: #e53935;
}

.pxp-mult {
    position: absolute;
    color: #00e5ff;
    font-weight: bold;
    text-shadow: 0 0 6px rgba(0,229,255,0.7);
    pointer-events: none;
    transform: translate(-50%, 0);
    animation: pxpUp 1.1s ease-out forwards;
    z-index: 2000;
}

.character .hp {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: -18px; /* под персонажем */
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    line-height: 1;
    color: #e0e0e0;
    pointer-events: none;
    white-space: nowrap;
    opacity: 0.5; /* 50% прозрачность */
}

.boss .hp {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: -20px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    line-height: 1;
    color: #e0e0e0;
    pointer-events: none;
    white-space: nowrap;
    opacity: 0.5; /* 50% прозрачность */
}

.character .hp .heart {
    color: #e53935;
}

/* Туториал по управлению */
.tutorial-container {
    display: flex;
    align-items: stretch;
    justify-content: center;
    width: 100%;
    max-width: 500px;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    gap: 0;
}

.tutorial-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px 10px;
}

.tutorial-left {
    text-align: center;
}

.tutorial-right {
    text-align: center;
}

.tutorial-divider {
    width: 2px;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        #fff 10%,
        #fff 90%,
        transparent 100%
    );
    margin: 0 10px;
    min-height: 100px;
}

.tutorial-icon {
    font-size: 48px;
    margin-bottom: 10px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.7;
    }
}

.tutorial-text {
    font-size: 14px;
    line-height: 1.5;
    color: #e0e0e0;
    font-weight: 500;
}

.start-popup {
    max-width: 600px;
    width: 90%;
}

/* Поп‑ап кнопка рестарта */
#restart-btn {
    padding: 12px 24px;
    font-size: 18px;
    background-color: #c62828;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

#restart-btn:hover {
    background-color: #b71c1c;
}

/* Overlay поп‑ап */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2500;
}

.popup {
    background: #111;
    border: 2px solid #fff;
    border-radius: 12px;
    padding: 24px 28px;
    text-align: center;
    box-shadow: 0 0 20px rgba(255,255,255,0.5);
}

/* Кнопка выбора языка */
.lang-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 8px 16px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.lang-btn:active {
    transform: scale(0.95);
}

.popup {
    position: relative;
}

.popup-title {
    font-size: 22px;
    margin-bottom: 12px;
}

.popup-time {
    font-size: 18px;
    color: #ffff00;
    margin-bottom: 16px;
    font-family: 'Courier New', monospace;
}

.popup-dev {
    display: inline-block;
    margin-top: 12px;
    color: #66bbff;
    text-decoration: none;
    font-size: 14px;
}

.popup-dev:hover {
    text-decoration: underline;
}

.pause-continue-btn,
.pause-restart-btn {
    padding: 12px 24px;
    font-size: 18px;
    background-color: #2e7d32;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin: 8px;
    display: inline-block;
}

.pause-continue-btn:hover {
    background-color: #1b5e20;
}

.pause-restart-btn {
    background-color: #c62828;
}

.pause-restart-btn:hover {
    background-color: #b71c1c;
}

/* Всплывающее начисление PXP */
.pxp-float {
    position: absolute;
    left: 0;
    top: 0;
    color: #ffd800;
    font-weight: bold;
    font-size: 14px;
    text-shadow: 0 0 6px rgba(255, 216, 0, 0.6);
    pointer-events: none;
    transform: translate(-50%, 0);
    animation: pxpUp 1s ease-out forwards;
    z-index: 2000;
}

@keyframes pxpUp {
    0% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, -40px); }
}

/* Игрок */
.player {
    position: absolute;
    width: 100%;
    max-width: 100%;
    left: 0;
    right: 0;
    margin: 0 auto;
    height: 90px;
    pointer-events: none;
    z-index: 1400; /* над панелью, ниже пунктира */
}

.player .hp { display: none; }

.player .hp .heart {
    color: #e53935;
}

/* Пули */
.bullet {
    position: absolute;
    width: 7px;  /* было 14px */
    height: 17px; /* было 34px */
    left: 50%;
    transform: translateX(-50%);
    background: #ff4da6; /* розовый */
    border-radius: 6px / 9px; /* пропорционально уменьшено */
    box-shadow: 0 0 6px rgba(255, 77, 166, 0.6);
    pointer-events: none;
}

.track:last-child {
    border-right: none;
}

/* Подписи дорожек */
.track-labels {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%; /* по центру экрана по вертикали */
    transform: translateY(-50%);
    display: flex;
    height: 20px;
    z-index: 1600;
}

.track-labels .track-label {
    flex: 1;
    text-align: center;
    font-size: 12px;
    color: #66ff66;
    font-family: 'Courier New', monospace;
    opacity: 0.45; /* в два раза прозрачнее */
}

/* Панель с кнопками */
.button-panel {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 20px;
    height: 100px;
    background-color: rgba(0, 0, 0, 0.8);
    gap: 20px;
    position: relative;
    z-index: 1; /* ниже игрового поля и игрока */
}

.upgrade-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.auto-buy-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.auto-buy-checkbox {
    width: 40px;
    height: 40px;
    border: 2px solid #999;
    border-radius: 6px;
    background-color: #222;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.auto-buy-checkbox:hover {
    background-color: #333;
    border-color: #aaa;
}

.auto-buy-checkbox.checked {
    background-color: #2e7d32;
    border-color: #4caf50;
}

.checkmark {
    font-size: 28px;
    color: white;
    font-weight: bold;
}

.auto-buy-label {
    font-size: 12px;
    color: #66bb6a;
    text-align: center;
    font-weight: 400;
    margin-bottom: 6px;
}

.upgrade-label {
    color: #66bb6a;
    font-size: 12px;
    margin-bottom: 6px;
    font-family: 'Courier New', monospace;
}

/* Кнопки обновлений */
.upgrade-btn {
    flex: 1;
    max-width: 200px;
    height: 60px;
    background-color: #666;
    border: 2px solid #999;
    border-radius: 8px;
    cursor: not-allowed;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

.upgrade-btn:hover {
    background-color: #777;
}

.upgrade-btn:disabled {
    opacity: 0.6;
}

.upgrade-btn.can-afford {
    background-color: #2e7d32; /* зелёный */
    border-color: #66bb6a;
    opacity: 1;
}

.btn-text {
    font-size: 14px;
    font-weight: bold;
    color: white;
    margin-bottom: 2px;
}

.btn-price {
    font-size: 12px;
    color: #ffff00;
    font-weight: bold;
}

/* Кнопка PLAY */
.play-btn {
    width: 200px;
    height: 80px;
    font-size: 32px;
    font-weight: bold;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 3px solid #ffffff;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
    margin-top: 20px;
}

.play-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 30px rgba(102, 126, 234, 0.6);
}

.play-btn:active {
    transform: scale(0.95);
}

/* Адаптивность */
@media (max-width: 768px) {
    .top-panel {
        padding: 15px;
        height: 50px;
    }

    .timer {
        font-size: 18px;
    }

    .balance {
        font-size: 16px;
    }

    .button-panel {
        padding: 15px;
        height: 80px;
        gap: 10px; /* Убрал flex-direction: column, чтобы сохранить горизонтальное расположение */
    }

    .upgrade-btn {
        max-width: none;
        width: 100%;
        height: 50px;
    }

    .horizontal-line {
        bottom: 50px; /* Было 100px, теперь в два раза ближе */
    }
}

@media (max-width: 480px) {
    .top-panel {
        padding: 10px;
        height: 45px;
    }

    .timer {
        font-size: 16px;
    }

    .balance {
        font-size: 14px;
    }

    .button-panel {
        padding: 10px;
        height: 70px;
    }

    .upgrade-btn {
        height: 45px;
    }

    .btn-text {
        font-size: 12px;
    }

    .btn-price {
        font-size: 10px;
    }
}
