@font-face {
    font-family: 'PixeloidMono';
    src: url('../assets/tekst/pixeloid_mono/PixeloidMono.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

body {
    font-family: 'PixeloidMono', monospace;
    background: #000;
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    transition: background-color 0.5s ease;
    
    /* УБРАН display: flex; align-items: center; 
       Именно он смещал меню "Уровни" на середину экрана! */
}

body.game-active {
    background: transparent;
}

.hidden {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* УБРАНЫ жесткие width: 100% и height: 100% */
/* Благодаря этому картинка в WebGL перестанет двоиться и разрываться! */
#game canvas {
    max-width: 100%;
    max-height: 100%;
    display: block;
    margin: 0 auto;
}


.game-controls {
    align-items: center;
    bottom: 0;
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    position: fixed;
    width: 100%;
    z-index: 100; /* .game-controls — контроллеры игры */
}

.control-group {
    align-items: center;
    display: flex;
    gap: 0.5rem;
}

.control-btn {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #fff;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    font-size: 1.5rem;
    height: 50px;
    width: 50px;
}

@media (max-width: 480px) {
    .control-btn {
        font-size: 1.2rem;
        height: 40px;
        width: 40px;
    }
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    overflow-x: hidden !important;
    width: 100%;
    max-width: 100%;
}

#vn-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 19990; /* vn-dialog-overlay — оверлей диалога */
}

/* === GLITCH OVERLAY === */
body::before,
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 19999; /* глитч-оверлей body::before/after */
    opacity: 0;
}

body::before {
    background: repeating-linear-gradient(
        0deg,
        rgba(255, 0, 0, 0.05) 0px,
        rgba(255, 0, 0, 0.05) 1px,
        transparent 1px,
        transparent 3px
    );
    animation: glitch-red 3s infinite steps(2);
}

body::after {
    background: repeating-linear-gradient(
        90deg,
        rgba(0, 150, 255, 0.04) 0px,
        rgba(0, 150, 255, 0.04) 1px,
        transparent 1px,
        transparent 4px
    );
    animation: glitch-blue 2.5s infinite steps(2);
}

body.game-active::before,
body.game-active::after {
    opacity: 1;
}

@keyframes glitch-red {
    0%   { transform: translate(0); }
    20%  { transform: translate(-2px, 1px); }
    40%  { transform: translate(2px, -1px); }
    60%  { transform: translate(-1px, 2px); }
    80%  { transform: translate(1px, -2px); }
    100% { transform: translate(0); }
}

@keyframes glitch-blue {
    0%   { transform: translate(0); }
    25%  { transform: translate(2px, 0); }
    50%  { transform: translate(-2px, 1px); }
    75%  { transform: translate(1px, -1px); }
    100% { transform: translate(0); }
}

/* ========================================================== */
/* МАСТЕР-ЛЕЙАУТ: ЦЕНТРИРОВАНИЕ ВСЕХ ЭКРАНОВ (MAX 400PX)      */
/* ========================================================== */

/* Все меню и игра фиксируются по центру. 
   Убраны все transform: translateX, которые уводили меню влево */
#game, 
#mainMenu, #pvpLobby, #pvpResult, 
#levelMenu, #settingsMenu, #lobbyMenu, 
#winScreen, #gameOverScreen, #pauseMenu {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    margin: 0 auto !important;
    width: 100vw !important;
    max-width: 400px !important; /* На ПК будет ширина 400px, на телефоне 100% экрана */
    height: 100vh !important;
    height: 100dvh !important;
    transform: none !important;
    z-index: 1000; /* все меню и интерфейсы */
    overflow-y: auto; /* Скролл только внутри меню */
    overflow-x: hidden;
}

/* #game определен в game.css */

/* HUD элементы, кнопки и счётчики определены в game.css */

/* === ОБЩАЯ КНОПКА "НАЗАД" ДЛЯ ВСЕХ ЭКРАНОВ === */
.back-to-main-menu-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 10;
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    color: #fff;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: all 0.2s;
}

.back-to-main-menu-btn:hover {
    background: rgba(255, 34, 68, 0.3);
    border-color: var(--color-red, #ff2244);
    transform: scale(1.1);
}
