body {
    background-color: #202020;
    display: flex;
    justify-content: center;
    align-items: center;
    height: auto;
    margin: 0;
    min-height: 100vh;
    font-family: 'Press Start 2P', cursive; /* Пиксельный шрифт */
    overflow: auto;
    text-align: center;
    padding: 20px;
}

#game-container {
    position: relative;
    margin: 0 auto; /* Центр */
}

canvas {
    display: block;
}

/* Добавь ID селектор для фона */
#gameCanvas {
    background-color: #636363; /* Фон игры */
    image-rendering: pixelated;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

#uiCanvas {
    position: absolute;
    top: 0; left: 0;
    pointer-events: none;
    /* Фон прозрачный по умолчанию */
}

#gameCanvas, #uiCanvas {
    width: 864px; /* 288 * 3 */
    height: 816px; /* 272 * 3 */
}

/* Оверлей меню */
#menu-screen, #lobby-screen {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    z-index: 10;
}

.title {
    font-size: 60px;
    text-shadow: 4px 4px #880000;
    margin-bottom: 60px;
    text-align: center;
    line-height: 1.5;
}

.menu-section {
    margin-bottom: 40px;
    text-align: center;
}

.toggle-btn {
    display: inline-block;
    padding: 15px 20px;
    margin: 10px;
    border: 4px solid #fff;
    cursor: pointer;
    opacity: 0.5;
}
.toggle-btn.selected {
    opacity: 1;
    background-color: #fff;
    color: #000;
}

button {
    font-family: 'Press Start 2P', cursive;
    background: transparent;
    color: white;
    border: 4px solid white;
    padding: 15px 30px;
    font-size: 16px;
    cursor: pointer;
    margin: 10px;
}
button:hover {
    background: white;
    color: black;
}

input {
    font-family: 'Press Start 2P', cursive;
    padding: 15px;
    font-size: 16px;
    width: 120px;
    text-transform: uppercase;
}

.join-row {
    display: flex;
    align-items: center;
    justify-content: center;
}

#player-list li {
    margin: 10px;
    color: #ccc;
}

/* Стили для блока настроек в лобби */
.lobby-settings {
    margin: 20px 0;
    padding: 20px;
    border: 4px solid #63db44; /* Зеленая рамка как у танчиков */
    background: rgba(0, 50, 0, 0.8);
    text-align: left;
    width: 400px; /* Чтобы ширина совпадала с шириной списка игроков */
}

.lobby-settings label {
    display: block;
    margin: 10px 0;
    font-size: 14px;
    cursor: pointer;
    /* Выравнивание текста и инпута */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.lobby-settings input[type="number"] {
    width: 60px;
    padding: 5px;
    font-family: 'Press Start 2P', cursive;
    text-align: center;
    border: 2px solid white;
    background: black;
    color: white;
}

.lobby-settings input[type="checkbox"] {
    /* Кастомный чекбокс сложноват, оставим стандартный, но увеличим */
    transform: scale(1.5);
    cursor: pointer;
}

/* Стили для disabled инпутов (для не-хоста) */
.lobby-settings input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #888;
    color: #888;
}


/* Список игроков */
#lobby-players {
    width: 500px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.lobby-player-row {
    display: grid;
    /* Сетка: Имя (растягивается) | Кнопка | Кнопка | Крестик */
    grid-template-columns: 1fr 80px 80px 40px; 
    gap: 10px;
    align-items: center;
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #333;
}

/* Инпут имени внутри строки */
.lobby-name-input {
    width: 100%;
    padding: 8px;
    font-size: 12px;
    background: transparent;
    border: none;
    border-bottom: 2px solid #555;
    color: white;
    font-family: 'Press Start 2P', cursive;
}
.lobby-name-input:focus {
    outline: none;
    border-color: #fff;
}

/* Текст имени (чужой) */
.lobby-name-text {
    font-size: 12px;
    padding-left: 5px;
}

/* Кнопки команд */
.team-btn {
    padding: 8px 0;
    font-size: 10px;
    margin: 0;
    cursor: pointer;
    border: 2px solid #555;
    background: transparent;
    color: #555;
    transition: all 0.2s;
}

/* YELLOW */
.team-btn-yellow.active {
    border-color: #e6c629;
    background-color: #e6c629;
    color: black;
    box-shadow: 0 0 8px #e6c629;
}

/* GREEN */
.team-btn-green.active {
    border-color: #63db44;
    background-color: #63db44;
    color: black;
}

/* Кнопка удаления (крестик) */
.btn-remove {
    padding: 5px;
    font-size: 14px;
    color: #d43333;
    border: none;
    background: transparent;
}
.btn-remove:hover {
    color: red;
    background: transparent;
    transform: scale(1.2);
}

.btn-placeholder {
    width: 40px; /* Чтобы P1 занимал столько же места, сколько P2 */
}

/* Кнопка добавления */
.lobby-add-row {
    text-align: left;
    padding-left: 10px;
}
.lobby-add-row button {
    font-size: 10px;
    padding: 10px;
    border: 1px dashed #666;
    color: #888;
}
.lobby-add-row button:hover {
    border-color: white;
    color: white;
}

/* Кнопка Старт - делаем её большой и заметной */
#btn-start {
    font-size: 20px;
    padding: 20px 40px;
    border-color: #fca048; /* Оранжевый */
    color: #fca048;
    animation: pulse 2s infinite; /* Пульсация */
}

#btn-start:hover {
    background: #fca048;
    color: black;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Добавь это */
.lobby-settings select {
    width: 120px;
    padding: 5px;
    font-family: 'Press Start 2P', cursive;
    font-size: 16px;
    border: 2px solid white;
    background: black;
    color: white;
    cursor: pointer;
    /* Убираем стандартную стрелку браузера (для красоты) */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    text-align: center;
}

.lobby-settings select:hover {
    background: #222;
}

.lobby-settings select:focus {
    outline: none;
    border-color: #63db44;
}

/* Крестик в углу */
.lobby-close {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 40px;
    color: #d43333;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.2s;
}

.lobby-close:hover {
    transform: scale(1.2) rotate(90deg);
    color: red;
}


#main-layout {
    /* Игра по центру */
    display: inline-block;
    justify-content: center;
    align-items: center;
    height: auto; /* Растягивается контентом */
    min-height: 100vh;
    padding: 20px;
    box-sizing: border-box;
    vertical-align: top;
}

#chat-container {
    position: fixed; /* Поверх всего */
    left: 0;
    top: 0;
    height: 100%;
    width: 300px;
    
    background: rgba(0, 0, 0, 0.9);
    border-right: 4px solid #444;
    
    transform: translateX(-100%); /* Спрятан влево */
    transition: transform 0.3s ease-in-out;
    
    z-index: 200;
    display: none; /* Скрыт до входа в лобби */
}

#chat-window {
    flex: 1;
    background: #111;
    border: 4px solid #444;
    display: flex;
    flex-direction: column;
}

#chat-container.open {
    transform: translateX(0); /* Выехал */
}

/* Ярлычок (Кнопка) */
#chat-toggle-btn {
    position: absolute;
    right: -40px; /* Торчит справа от чата */
    top: 50%;
    width: 40px;
    height: 80px;
    
    background: #444;
    color: white;
    cursor: pointer;
    
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl; /* Текст вертикально */
    text-orientation: upright;
    
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    font-family: 'Press Start 2P', cursive;
    font-size: 9px;
    line-height: 1.5;
}

#chat-input {
    background: #222;
    border: none;
    border-top: 2px solid #444;
    color: white;
    padding: 15px;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    outline: none;
    resize: none; /* Запрет ручного ресайза */
    overflow: hidden; /* Скрываем скроллбар */
    box-sizing: border-box; /* Важно! */
    height: 45px; /* Начальная высота (примерно 15px pad + 10px text + 15px pad = ~45-50) */
    max-height: 270px; /* Максимум (дальше скролл) */
    line-height: 1.5;
}

.lobby-header {
    display: flex;
    align-items: center;
    gap: 15px; /* Отступ между текстом и кнопкой */
    margin-bottom: 20px;
}

.copy-btn {
    background: none;
    border: none; /* Без рамки */
    color: #666; /* Серый */
    font-size: 18px;
    cursor: pointer;
    padding: 0px;
    transition: color 0.2s;
}

.copy-btn:hover {
    background: transparent !important; /* Принудительно убираем фон */
    color: #fff;       /* Иконка становится белой */
    border-color: #666; /* Рамка остается серой (или transparent, если хочешь без рамки) */
    transform: scale(1.2);
}

/* Состояние "Скопировано" */
.copy-btn.copied {
    color: #63db44;
    background: transparent !important;
    border-color: #63db44;
}

/* Сообщения */
.msg-system { color: #fca048; font-style: italic; }
.msg-player-1 { color: #e6c629; } /* Yellow */
.msg-player-2 { color: #63db44; } /* Green */
.msg-text { color: #eee; }



#instructions {
    display: flex;
    gap: 40px;
    background: #111;
    border: 4px solid #444;
    padding: 20px;
    margin-top: 20px;
    width: 912px; /* Ширина игры */
    box-sizing: border-box;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    color: #ccc;
    justify-content: space-around;
}

.instr-col h3 {
    color: #fca048; /* Оранжевый */
    margin-bottom: 15px;
    text-align: center;
}

.instr-col p {
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 5px;
}

.key {
    display: inline-block;
    background: #333;
    border: 2px solid #666;
    border-radius: 4px;
    padding: 5px 8px;
    color: white;
    font-weight: bold;
    box-shadow: 0 2px 0 #000;
}

.key.wide {
    padding: 5px 15px;
}



/* По умолчанию мобильный UI скрыт */
#mobile-ui {
    display: none;
}

/* Стили для мобильного режима */
body.mobile-mode {
    background: #000;
    flex-direction: column;
    justify-content: flex-start;
    overflow: hidden; /* Запрет скролла */
}

body.mobile-mode #chat-container,
body.mobile-mode #instructions {
    display: none !important; /* Скрываем лишнее */
}

body.mobile-mode #mobile-ui {
    display: flex;
    position: fixed;
    bottom: 20px;
    left: 0;
    width: 100%;
    height: 150px;
    z-index: 999;
    pointer-events: none; /* Чтобы клики сквозь пустоту проходили, если надо */
}

/* Зоны управления (включаем pointer-events обратно) */
#zone_joystick {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 150px;
    height: 150px;
    pointer-events: auto;
    /* background: rgba(255, 255, 255, 0.1); Debug */
}

#btn_fire {
    position: absolute;
    bottom: 30px;
    right: 30px;
    width: 80px;
    height: 80px;
    background: rgba(255, 0, 0, 0.5);
    border: 4px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    color: white;
    font-size: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    pointer-events: auto;
    cursor: pointer;
}

#btn_fire.pressed {
    background: rgba(255, 0, 0, 0.8);
    transform: scale(0.95);
}

#btn_fullscreen {
    position: fixed;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.5);
    color: white;
    border: 1px solid white;
    pointer-events: auto;
    z-index: 1000;
    font-size: 24px;
}



/* Кнопка в меню */
.donate-btn {
    border-color: #fca048; /* Оранжевый */
    color: #fca048;
    font-size: 12px;
    padding: 10px 20px;
    animation: heartbeat 1.5s infinite;
}

@keyframes heartbeat {
    0% { transform: scale(1); }
    10% { transform: scale(1.1); }
    20% { transform: scale(1); }
    100% { transform: scale(1); }
}

/* Модальное окно (фон) */
#donate-modal {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

/* Окно */
.modal-content {
    background: #000;
    border: 4px solid #fff;
    width: 300px;
    font-family: 'Press Start 2P', cursive;
    color: white;
    text-align: center;
    box-shadow: 10px 10px 0 #222;
}

.modal-header {
    background: #63db44; /* Зеленый заголовок */
    color: black;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-btn {
    background: none;
    border: none;
    color: black;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    margin: 0;
}

.modal-body {
    padding: 20px;
}

.modal-body p {
    font-size: 10px;
    line-height: 1.5;
    margin-bottom: 20px;
    color: #ccc;
}

.qr-placeholder {
    width: 150px;
    height: 150px;
    background: white;
    margin: 0 auto 20px auto;
    padding: 5px; /* Белая рамка */
}

/* Ссылка-кнопка */
.pay-link {
    display: inline-block;
    background: #fca048;
    color: black;
    text-decoration: none;
    padding: 10px 20px;
    border: 2px solid white;
    font-size: 12px;
}
.pay-link:hover {
    background: white;
    color: #fca048;
}




.menu-footer {
    margin-top: 60px; /* Отступ от кнопок */
    font-size: 10px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 15px;
}

.footer-link {
    color: #888;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.2s;
}

.footer-link:hover {
    color: white;
    text-decoration: underline;
}

.footer-link .icon {
    width: 16px;
    height: 16px;
    image-rendering: pixelated;
    opacity: 0.7;
}

.footer-link:hover .icon {
    opacity: 1;
}

.separator {
    color: #444;
}