/* ===== ОБЩИЕ СТИЛИ И КАНВАС ===== */
body {
    margin: 0;
    background: #05050f;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    font-family: Arial, sans-serif;
    overflow: hidden;
    touch-action: none;
}

canvas {
    background: radial-gradient(circle at 50% 0%, #1a1a4a 0%, #0a0a1a 70%);
    border: 2px solid #00ffff;
    box-shadow: 0 0 80px #00ffff66, inset 0 0 60px #00ffff22;
    border-radius: 15px;
    max-width: 100vw;
    max-height: 100vh;
    position: relative;
    z-index: 1;
}

/* ===== ЭКРАН ЗАГРУЗКИ ===== */
#loadingScreen {
    position: absolute;
    width: 500px;
    height: 700px;
    background: #05050f;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    color: #00ffff;
    transition: opacity 0.5s ease;
    border-radius: 15px;
    border: 2px solid #00ffff;
    box-sizing: border-box;
}

.glitch-text {
    font-size: 50px;
    margin: 0 0 20px 0;
    text-shadow: 0 0 10px #00ffff, 0 0 20px #ff00ff;
}

.loader-bar {
    width: 250px;
    height: 20px;
    border: 2px solid #00ffff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 15px #00ffff;
    margin-bottom: 10px;
}

.loader-fill {
    width: 0%;
    height: 100%;
    background: #00ffff;
    animation: loadAnim 1s forwards;
    box-shadow: 0 0 20px #00ffff inset;
}

@keyframes loadAnim {
    0% { width: 0%; }
    100% { width: 100%; }
}

/* ===== ИГРОВОЙ HUD (В ИГРЕ) ===== */
#gameHud {
    position: absolute;
    top: 35px;
    /* Центрируем сам контейнер строго по центру канваса */
    left: 50%;
    transform: translateX(-50%);
    width: 460px;
    display: none;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 10;
    pointer-events: none;
}

/* Пауза слева */
#pauseBtn {
    pointer-events: auto;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.2) 0%, rgba(0, 0, 0, 0.7) 100%);
    border: 2px solid #00ffff;
    width: 45px;
    height: 45px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: inset 2px 2px 5px rgba(255, 255, 255, 0.4), 0 4px 10px rgba(0, 0, 0, 0.8), 0 0 15px rgba(0, 255, 255, 0.3);
    transition: 0.2s;
}

#pauseBtn span {
    display: block;
    width: 6px;
    height: 20px;
    background-color: #00ffff;
    border-radius: 2px;
    box-shadow: 0 0 5px #00ffff;
}

/* Очки по центру */
.hud-score {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 0;

    font-size: 36px;
    font-weight: 900;
    color: #ffffff;
    background: rgba(10, 10, 20, 0.4);
    padding: 4px 30px;
    border-radius: 12px;
    border: 2px solid rgba(0, 255, 255, 0.4);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4), 0 0 15px rgba(0, 255, 255, 0.2);
    text-shadow: 0 0 8px rgba(0, 255, 255, 0.8), 0 2px 4px rgba(0, 0, 0, 0.8);
    letter-spacing: 1px;
}

/* Монеты справа */
.hud-coins {
    background: rgba(80, 50, 0, 0.85);
    border: 2px solid #ffcc00;
    border-radius: 20px;
    padding: 8px 20px;
    font-size: 24px;
    font-weight: bold;
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6), 0 0 20px rgba(255, 204, 0, 0.4);
    text-shadow: 0 0 5px #ffcc00, 0 2px 2px #000;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== ГЛАВНОЕ МЕНЮ ===== */
#mainMenu {
    position: absolute;
    width: 500px;
    height: 700px;
    background: radial-gradient(circle at 50% 50%, #2a2a5a 0%, #111122 100%);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 40px 0;
    box-sizing: border-box;
    z-index: 10;
    border-radius: 15px;
}

/* Сетка верхней панели */
.top-hud-container {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 20;
}

.left-column {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.right-column {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

/* Профиль */
.hud-profile {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.profile-avatar {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #4a148c, #7b1fa2);
    border: 2px solid #e040fb;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    z-index: 2;
    box-shadow: 0 4px 8px rgba(0,0,0,0.5);
}

.profile-info {
    background: rgba(20, 20, 30, 0.9);
    border: 2px solid #e040fb;
    border-left: none;
    border-radius: 0 12px 12px 0;
    padding: 5px 10px 5px 15px;
    margin-left: -8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 1;
    width: 90px;
}

.lvl-badge {
    background: #e040fb;
    color: white;
    font-size: 10px;
    font-weight: bold;
    text-align: center;
    border-radius: 5px;
    width: 20px;
    height: 15px;
    line-height: 15px;
}

.lvl-bar {
    width: 100%;
    height: 6px;
    background: #333;
    border-radius: 3px;
    overflow: hidden;
}

.lvl-fill {
    height: 100%;
    background: #00ff00;
}

/* Ресурсы */
.hud-resources {
    display: flex;
    align-items: center;
    gap: 8px;
}

.res-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    font-weight: bold;
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
    padding: 5px 10px;
    border-radius: 12px;
    border: 2px solid;
}

.res-item.diamond { border-color: #00ffff; }
.res-item.coin { border-color: #ffcc00; }

.settings-btn {
    font-size: 18px;
    cursor: pointer;
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    border: 2px solid #888;
    transition: 0.2s;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 10px #fff;
}

/* Рекорд */
.hud-record-bar {
    background: rgba(20, 20, 30, 0.9);
    border: 2px solid #ffcc00;
    border-radius: 10px;
    padding: 4px 15px;
    color: #ffcc00;
    font-size: 13px;
    font-weight: bold;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hud-record-bar span {
    color: #fff;
    font-size: 16px;
    margin-left: 10px;
    text-shadow: 0 0 5px #fff;
}

/* Боевой пропуск */
.battle-pass-box {
    background: linear-gradient(135deg, #ff9800, #ff5722);
    border: 2px solid #ffeb3b;
    border-radius: 10px;
    padding: 5px 10px;
    width: 120px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.bp-text {
    font-size: 10px;
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 0 #000;
    margin-bottom: 4px;
}

.bp-progress {
    width: 100%;
    height: 8px;
    background: rgba(0,0,0,0.5);
    border-radius: 4px;
    overflow: hidden;
}

.bp-fill {
    height: 100%;
    background: #fff;
}

/* Кнопка ЗАБЕГ */
.menu-center {
    position: absolute;
    bottom: 110px;
    width: 100%;
    display: flex;
    justify-content: center;
    z-index: 20;
}

.play-button {
    width: 85%;
    padding: 18px;
    font-size: 28px;
    font-weight: 900;
    background: linear-gradient(to bottom, #ffeb3b, #f57c00);
    border: none;
    border-radius: 20px;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 0 #b26500, 0 15px 25px rgba(0,0,0,0.6);
    text-shadow: 2px 2px 0 rgba(0,0,0,0.3);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s;
}

.play-button:hover {
    transform: scale(1.05) translateY(-5px);
    box-shadow: 0 12px 0 #b26500, 0 20px 30px rgba(0,0,0,0.7);
    filter: brightness(1.1);
}

.play-button:active {
    transform: translateY(6px) scale(0.98);
    box-shadow: 0 2px 0 #b26500;
}

/* ===== НИЖНЯЯ ПАНЕЛЬ (ТАБ-БАР) ===== */
.bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 85px;
    background: rgba(20, 20, 40, 0.95);
    border-top: 2px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 40; /* ВЫШЕ ЗАГЛУШКИ */
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 15px;
    padding: 0 5px;
    box-sizing: border-box;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    width: 19%;
    height: 70px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: #ccc;
}

.nav-item .icon-wrap {
    width: 28px;
    height: 28px;
    margin-bottom: 2px;
    color: #ccc;
    transition: 0.2s;
}

.nav-item .icon-wrap svg { width: 100%; height: 100%; fill: currentColor; }
.nav-item .label { font-size: 10px; font-weight: bold; text-transform: uppercase; }

.nav-item.active {
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
}

.nav-item.active .icon-wrap {
    color: #00ffff;
    transform: translateY(-2px);
}

/* ===== ЗАГЛУШКИ ЭКРАНОВ ===== */
.sub-screen {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at 50% 50%, #2a2a5a 0%, #111122 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 30;
    border-radius: 15px;
    padding-bottom: 85px;
    box-sizing: border-box;
}

.sub-screen h2 {
    font-size: 36px;
    color: #00ffff;
    text-shadow: 0 0 20px #00ffff;
    margin-bottom: 10px;
}

.sub-screen p {
    font-size: 20px;
    color: #ff00ff;
    text-shadow: 0 0 10px #ff00ff;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Кнопка НАЗАД */
.back-btn {
    position: absolute;
    bottom: 25px;
    left: 20px;
    width: 60px;
    height: 60px;
    background: rgba(20, 20, 40, 0.95);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32px;
    color: #00ffff;
    cursor: pointer;
    text-shadow: 0 0 15px #00ffff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    transition: 0.2s;
    z-index: 50;
}

.back-btn:hover {
    background: rgba(0, 255, 255, 0.2);
    transform: scale(1.05) translateX(-5px);
}

/* ===== ЭКРАН ПАУЗЫ ===== */
#pauseScreen {
    position: absolute;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 26, 0.9);
    backdrop-filter: blur(5px);
    border: 2px solid #00ffff;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 0 50px #00ffff88;
    color: white;
    z-index: 40;
    width: 80%;
    max-width: 400px;
    box-sizing: border-box;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#pauseScreen h1 {
    color: #00ffff;
    text-shadow: 0 0 20px #00ffff;
    font-size: 40px;
    margin-bottom: 30px;
}

/* ===== ЭКРАН GAME OVER ===== */
#gameOver {
    position: absolute;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 26, 0.95);
    border: 3px solid #ff00ff;
    border-radius: 20px;
    padding: 30px 50px;
    box-shadow: 0 0 80px #ff00ff88;
    color: white;
    text-align: center;
    z-index: 40;
    width: 350px;
    box-sizing: border-box;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#gameOver h1 {
    font-size: 40px;
    margin: 0 0 15px 0;
    color: #ff00ff;
    text-shadow: 0 0 30px #ff00ff;
}

#gameOver p { font-size: 20px; margin: 5px 0; }
#gameOver .record { color: #ffff00; font-size: 24px; }

#gameOver button {
    width: 100%;
    margin-top: 15px;
    margin-bottom: 5px;
}

/* ===== ОБЩИЕ СТИЛИ ДЛЯ КНОПОК ДЕЙСТВИЙ ===== */
.action-btn {
    width: 100%;
    padding: 15px;
    margin-bottom: 15px;
    font-size: 20px;
    font-weight: bold;
    color: #fff;
    background: #00ddff;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 5px 0 #0088aa;
    transition: all 0.2s ease-in-out;
}

.action-btn:hover {
    background: #ff00ff;
    color: #fff;
    transform: scale(1.05);
    box-shadow: 0 8px 0 #aa00aa, 0 15px 30px rgba(255, 0, 255, 0.5);
    text-shadow: 0 0 10px #fff;
}

.action-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 0 #aa00aa;
}

.action-btn.secondary {
    background: transparent;
    border: 2px solid #ff00ff;
    color: #ff00ff;
    box-shadow: none;
}

.action-btn.secondary:hover {
    background: #00ffff;
    border-color: #00ffff;
    color: #000;
    box-shadow: 0 8px 0 #0088aa, 0 15px 30px rgba(0, 255, 255, 0.5);
}