/* ========================================== */
/* === БАЗОВЫЕ НАСТРОЙКИ И ЦВЕТОВАЯ ПАЛИТРА === */
/* ========================================== */
:root {
    --bg: #000;         /* Фон игры */
    --gold: #ffd700;    /* Цвет энергии/денег */
    --alert: #ff3333;   /* Цвет опасности/урона */
    --heal: #33ff77;    /* Цвет здоровья/лечения */
}

/* Сброс стандартных отступов браузера и запрет выделения текста (чтобы не мешало играть) */
* {
    margin: 0; 
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Настройка главного окна (запрет скролла и зума на мобилках) */
html, body {
    height: 100%;       
    background: var(--bg); 
    font-family: system-ui, sans-serif; 
    color: #fff;        
    overflow: hidden;   
    touch-action: none; 
    overscroll-behavior: none; 
}

/* ========================================== */
/* === ЭКРАНЫ И МЕНЮ (SPA Архитектура) ====== */
/* ========================================== */
/* Базовый класс для всех экранов. По умолчанию они скрыты (opacity: 0) */
.screen {
    position: fixed; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    opacity: 0; visibility: hidden;
    transition: opacity 0.2s;
    z-index: 10; /* Базовый слой меню */
    padding: 18px;
    background: #000; 
}

/* Класс, который делает экран видимым */
.screen.active {
    opacity: 1; 
    visibility: visible;
    pointer-events: auto;
}

/* Экран самой аркады должен быть выше остальных меню */
.screen#screen-arcade.active {
    z-index: 150;
}

#screen-location {
    justify-content: flex-start;
    padding-top: 30px;
}

/* Окошки внутри экранов (менюшки) */
.panel {
    width: min(440px, 94vw); 
    display: flex; flex-direction: column;
    gap: 12px; position: relative; padding: 15px;
    background: rgba(10, 10, 10, 0.95); 
    border: 1px solid #333;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

#screen-location .panel { margin-top: 0; }

h1, h2 {
    color: var(--gold);
    text-transform: uppercase; letter-spacing: 0.14em;
    margin: 8px 0 12px; text-align: center;
}

/* ========================================== */
/* === ЭКРАНЫ-ШЛЮЗЫ (Анимации переходов) ==== */
/* ========================================== */
/* Шлюзы перекрывают всё (z-index: 200) для плавного перехода между локациями */
.gate {
    position: fixed; inset: 0; z-index: 200;
    display: flex; align-items: flex-end; justify-content: center;
    padding-bottom: 15vh;
    background-color: #000;
    background-size: 120% auto; 
    background-repeat: no-repeat; 
    background-position: center;
    transition: opacity 0.4s ease-in-out;
}

/* Фоны для разных шлюзов */
#gate-intro { background-image: linear-gradient(rgba(0,0,0,0.3), rgba(0,0,0,0.8)), url('start.jpg?v=3'); }
#gate-to-arena { background-image: linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.9)), url('start10.jpg?v=3'); background-position: top center; background-size: 120% auto;}
#gate-to-base { background-image: linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.9)), url('start20.jpg?v=3'); background-position: top center; background-size: 130% auto;}
#screen-menu { background-image: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.95)), url('start30.jpg?v=3'); background-position: top center; background-size: 100% auto;}
#screen-menu .panel { background: transparent; border: none; box-shadow: none; }

.gate.active-gate { opacity: 1; visibility: visible; pointer-events: auto; }
.gate.hidden-gate { opacity: 0; visibility: hidden; pointer-events: none; }

/* Пульсирующий текст на загрузочных экранах */
.gate-text {
    font-size: 18px; padding: 22px 14px;
    color: var(--gold); text-transform: uppercase;
    letter-spacing: 0.16em; text-align: center;
    text-shadow: 0 0 10px #000;
    animation: pulse 1.5s infinite;
}

@keyframes pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

/* Полоса загрузки */
.loading-bar {
    display: block; width: 200px; height: 4px;
    background: #333; margin: 10px auto 0; border-radius: 2px;
    position: relative; overflow: hidden;
}
.loading-bar::after {
    content: ''; position: absolute; top: 0; left: 0; height: 100%;
    width: 0%; background: currentColor;
    animation: loadingAnim 2s ease-in-out forwards;
}
@keyframes loadingAnim { to { width: 100%; } }

/* ========================================== */
/* === КНОПКИ === */
/* ========================================== */
.btn {
    padding: 13px; border: 2px solid var(--gold); border-radius: 22px;
    background: #111; color: var(--gold); font-size: 15px;
    font-weight: 700; text-transform: uppercase; cursor: pointer;
    transition: 0.1s;
}
.btn:active { transform: scale(0.95); } /* Эффект нажатия */
.btn:disabled { opacity: 0.5; filter: grayscale(1); pointer-events: none; }

.btn-alert { border-color: var(--alert); color: var(--alert); } 
.btn-safe { border-color: #555; color: #aaa; }                  
.btn-big { padding: 17px; font-size: 17px; border-width: 3px; } 

.btn-claim {
    width: 100%; margin-top: 15px; padding: 12px; font-size: 15px; font-weight: bold;
    text-transform: uppercase; background: var(--alert); color: #fff;
    border: none; border-radius: 8px; cursor: pointer; box-shadow: 0 0 10px rgba(255, 51, 51, 0.5);
}
.btn-claim:active { transform: scale(0.95); background: #cc0000; }
.nav-top { width: 100%; display: flex; justify-content: flex-start; margin-bottom: 4px; }

/* ========================================== */
/* === ИНТЕРФЕЙС МЕНЮ (HUD, ЛОГИ, СТАТЫ) ==== */
/* ========================================== */
.hud {
    position: fixed; top: 4px; left: 8px; right: 8px;
    display: flex; justify-content: space-between; 
    font-size: 13px; font-weight: 700; z-index: 90; text-shadow: 0 0 3px #000;
}
.hud span { color: var(--gold); }

/* Блоки со статистикой танка в гараже */
.stats-box {
    display: flex; flex-wrap: wrap; justify-content: space-between;
    padding: 14px; border: 1px solid #333; border-radius: 12px; background: #0a0a0a;
}
.stat-item { width: 48%; font-size: 0.83em; color: #aaa; text-transform: uppercase; margin-bottom: 6px; }
.stat-val { display: block; color: var(--gold); font-weight: 700; font-size: 1.25em; margin-top: 2px; }
.stat-val.hp { color: var(--heal); }

/* Всплывающие сообщения системы */
#log-container {
    position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
    display: flex; flex-direction: column; gap: 4px; z-index: 299; width: min(420px, 92vw); pointer-events: none;
}
.log-msg {
    background: rgba(0, 0, 0, 0.9); border: 1px solid var(--gold);
    padding: 5px 10px; border-radius: 8px; font-size: 12px; text-align: center; transition: opacity 0.3s;
}

/* Точки пути на экране выбора миссии */
.level-path { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; margin: 6px 0 10px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #222; border: 1px solid #444; }
.dot.active { background: var(--gold); border-color: var(--gold); } 
.dot.current { box-shadow: 0 0 6px var(--gold); transform: scale(1.25); } 

.lore-text-box {
    background: rgba(0, 255, 255, 0.05); border: 1px solid rgba(0, 255, 255, 0.2);
    padding: 15px; border-radius: 8px; color: #ccc; font-size: 14px; line-height: 1.5;
}
.lore-text-box p { margin-bottom: 10px; }

/* ========================================== */
/* === БОЕВОЙ ИНТЕРФЕЙС (ВО ВРЕМЯ ИГРЫ) ===== */
/* ========================================== */
.battle-hud {
    position: absolute; top: 0; left: 0; right: 0;
    background: rgba(6, 6, 6, 0.96); border-bottom: 3px solid #333;
    padding: 12px 16px; z-index: 120; display: flex; flex-direction: column; gap: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.8);
}
.hud-top-row { display: flex; justify-content: space-between; align-items: center; font-size: 18px; font-weight: 900; font-family: monospace; }
.hud-currency-container {
    font-size: 28px; color: #fff; font-weight: 900;
    text-shadow: 0 0 10px var(--gold), 0 0 20px var(--gold);
    background: rgba(255,215,0,0.1); padding: 2px 16px; border-radius: 12px;
    border: 1px solid rgba(255,215,0,0.3);
}
.hud-bottom-row { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.weapon-stats { font-size: 14px; font-weight: bold; color: #bbb; letter-spacing: 1px; }
.color-gold { color: var(--gold); } .color-heal { color: var(--heal); }

.btn-abort {
    padding: 8px 16px; border: 2px solid var(--alert); border-radius: 8px;
    background: #111; color: var(--alert); font-size: 13px; font-weight: bold; text-transform: uppercase; cursor: pointer;
}
.btn-settings { background: transparent; border: none; font-size: 24px; cursor: pointer; filter: drop-shadow(0 0 4px #000); }

/* Кнопки использования расходников в бою */
.battle-inventory-panel {
    position: absolute; bottom: 20px; left: 16px; right: 16px;
    display: flex; gap: 12px; z-index: 130; pointer-events: auto;
}
.battle-inv-btn {
    flex: 1; padding: 16px 8px; font-size: 13px; font-weight: 900;
    background: rgba(5,5,5,0.95); border-radius: 10px; cursor: pointer;
    text-transform: uppercase; text-align: center; box-shadow: 0 6px 15px rgba(0,0,0,0.7);
    letter-spacing: 1px;
}
.battle-inv-btn:disabled { opacity: 0.2; pointer-events: none; border-color: #333 !important; color: #555 !important; }
.shield-btn { border: 2px solid #0ff; color: #0ff; text-shadow: 0 0 5px #0ff; }
.rocket-btn { border: 2px solid #f80; color: #f80; text-shadow: 0 0 5px #f80; }

/* Модальные окна (настройки, итоги боя) */
.modal {
    position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.8); backdrop-filter: blur(2px);
}
.modal.hidden { display: none; }
.modal-content {
    background: #0a0a0a; border: 2px solid var(--gold); border-radius: 12px;
    padding: 20px; width: 280px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 0 20px rgba(0,0,0,0.8);
}
.setting-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: bold; color: #ccc; border-bottom: 1px solid #222; padding-bottom: 8px; }

/* Текст обратного отсчета (3.. 2.. 1..) */
.countdown-text {
    position: fixed; inset: 0; z-index: 150; display: none; 
    flex-direction: column; align-items: center; justify-content: center;
    font-size: 90px; font-weight: bold; color: var(--gold); text-shadow: 0 0 20px #ff3333;
    pointer-events: none; animation: popScale 0.8s infinite; text-align: center;
}
.countdown-subtext {
    font-size: 20px; font-family: monospace; color: #fff;
    text-transform: uppercase; letter-spacing: 2px; margin-top: 15px;
    text-shadow: 0 2px 4px #000, 0 0 8px var(--gold);
}
@keyframes popScale { 0% { transform: scale(0.5); opacity: 0; } 30% { transform: scale(1.1); opacity: 1; } 80% { transform: scale(1); opacity: 1; } 100% { transform: scale(0.8); opacity: 0; } }

/* Холст, где рисуется сама игра */
#gameCanvas {
    position: absolute; inset: 0; width: 100vw; height: 100vh;
    background: #050505; image-rendering: pixelated; touch-action: none;
    z-index: 5;
}

/* ========================================== */
/* === АНГАР: ПРЕВЬЮ ТАНКА И ТАБЫ =========== */
/* ========================================== */
.tank-scanner {
    background: radial-gradient(circle, #1a2a3a 0%, #050505 80%); border: 1px solid #335577; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; padding: 10px; box-shadow: inset 0 0 20px rgba(0, 255, 255, 0.1); position: relative; overflow: hidden;
}
.tank-scanner::after {
    content: ''; position: absolute; inset: 0; background: linear-gradient(rgba(0, 255, 255, 0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(0, 255, 255, 0.05) 1px, transparent 1px); background-size: 10px 10px; pointer-events: none;
}
.cheat-btn { background: rgba(255, 0, 255, 0.05) !important; border-color: #f0f !important; color: #f0f !important; }

/* Вкладки гаража (База, Оружие, Защита) */
.garage-tabs { display: flex; gap: 4px; margin-top: 10px; border-bottom: 2px solid #333; }
.garage-tab {
    flex: 1; padding: 8px 6px; background: transparent; border: none; color: #888;
    font-size: 14px; font-weight: bold; text-transform: uppercase; cursor: pointer;
    transition: 0.2s; border-bottom: 2px solid transparent;
}
.garage-tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.garage-tab-content { display: none; padding-top: 8px; }
.garage-tab-content.active { display: block; }
