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;
}

#btn-start {
    display: block;
    /* Was hidden or none */
    width: 300px;
    /* Fixed width */
    color: #fca048;
    border-color: #fca048;
    margin-top: 30px !important;
    background: rgba(0, 0, 0, 0.8);
}

#btn-start:hover {
    background: #fca048;
    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 {
    display: none;
    /* Hide for simple Denddy-like flow */
    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 70px 70px 40px 40px;
    gap: 8px;
    /* Чуть меньше отступ, чтобы всё влезло */
    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-indicator {
    padding: 6px 10px;
    font-size: 10px;
    color: black;
    font-weight: bold;
    text-align: center;
    width: 100%;
    margin-right: 10px;
}

.team-indicator.yellow {
    background-color: #e6c629;
    box-shadow: 0 0 5px #e6c629;
}

.team-indicator.green {
    background-color: #63db44;
    box-shadow: 0 0 5px #63db44;
}

/* Кнопка удаления (крестик) */
.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: transparent;
    color: white;
    border: none;
    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;
}

/* Скрываем кнопку доната в мобильном режиме */
body.mobile-mode .donate-btn {
    display: none !important;
}

/* Также можно скрыть футер (ссылки), если они мешают */
body.mobile-mode .menu-footer {
    display: none !important;
}

@keyframes heartbeat {
    0% {
        transform: scale(1);
    }

    10% {
        transform: scale(1.1);
    }

    20% {
        transform: scale(1);
    }

    100% {
        transform: scale(1);
    }
}

/* Модальное окно (фон) */
#donate-modal {
    position: fixed;
    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;
}

#touch-toggle-btn {
    position: fixed;
    top: 10px;
    right: 60px;
    /* Справа, рядом с фуллскрином */
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10000;
    /* Поверх всего */
    user-select: none;
    transition: transform 0.1s, text-shadow 0.2s;
}

#touch-toggle-btn:hover {
    /* Легкое свечение */
    text-shadow: 0 0 10px white;
}

#touch-toggle-btn:active {
    /* Эффект нажатия */
    transform: scale(0.9);
}

/* Спец-стиль для кнопки зрителя, чтобы выровнять эмодзи */
.team-btn-gray {
    border-color: #777;
    color: #777;
    font-family: sans-serif;
    /* ВАЖНО: Используем системный шрифт для эмодзи, он ровнее */
    font-size: 14px;
    /* Для эмодзи можно чуть крупнее */
}

/* Остальные стили gray (hover/active) остаются те же, что мы добавили ранее */
.team-btn-gray:hover {
    border-color: #aaa;
    color: #fff;
    background: #333;
}

.team-btn-gray.active {
    border-color: #aaa;
    background-color: #aaa;
    color: black;
    box-shadow: 0 0 5px #aaa;
}

#menu-nickname {
    background: transparent;
    /* Прозрачный фон */
    border: none;
    /* Убираем рамку */
    border-bottom: 4px solid #555;
    /* Только нижняя черта (темно-серая) */
    color: white;
    font-family: 'Press Start 2P', cursive;
    font-size: 20px;
    /* Шрифт покрупнее */
    padding: 10px;
    text-align: center;
    width: 240px;
    text-transform: uppercase;
    outline: none;
    transition: all 0.2s;
    margin-bottom: 20px;
    /* Отступ от кнопок побольше */
}

/* Также давай покрасим LABEL (надпись CALLSIGN), чтобы она выделялась */

/* === NEW MENU STYLES (Cards) === */

.menu-overlay {
    background: rgba(16, 16, 16, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    z-index: 50;
    padding: 20px;
}

.game-title {
    font-size: 60px;
    text-shadow: 4px 4px #880000;
    margin-bottom: 40px;
    text-align: center;
    line-height: 1.2;
}

.game-title .subtitle {
    font-size: 0.4em;
    color: #a42020;
    letter-spacing: 4px;
}

.menu-intro {
    margin-bottom: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.nickname-label {
    color: #fca048;
    font-size: 10px;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.nickname-input {
    background: transparent;
    border: none;
    border-bottom: 4px solid #555;
    color: white;
    font-family: 'Press Start 2P', cursive;
    font-size: 20px;
    padding: 10px;
    text-align: center;
    width: 240px;
    text-transform: uppercase;
    outline: none;
    transition: border-color 0.2s;
}

.nickname-input:focus {
    border-color: #63db44;
}

.mode-selection {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.game-card {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid #444;
    border-radius: 8px;
    padding: 30px;
    width: 280px;
    text-align: center;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.game-card:hover {
    transform: translateY(-5px);
    border-color: #fca048;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
}

.card-icon {
    font-size: 40px;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.2));
}

.game-card h3 {
    margin: 0;
    color: #fca048;
    font-size: 16px;
    line-height: 1.5;
}

.game-card p {
    font-size: 10px;
    color: #aaa;
    line-height: 1.6;
    margin: 0;
    flex-grow: 1;
    /* Push buttons down */
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.primary-button,
.secondary-button {
    font-family: 'Press Start 2P', cursive;
    padding: 12px 20px;
    font-size: 12px;
    cursor: pointer;
    border-radius: 4px;
    text-transform: uppercase;
    width: 100%;
    margin: 0;
    /* Override default button margin */
    transition: all 0.2s;
}

.primary-button {
    background: #63db44;
    color: #000;
    border: 2px solid #63db44;
}

.primary-button:hover {
    background: #7aff55;
    border-color: #7aff55;
    transform: scale(1.05);
}

/* Highlight (Quick Play) */
.primary-button.highlight {
    background: #fca048;
    border-color: #fca048;
}

.primary-button.highlight:hover {
    background: #ffb86c;
    border-color: #ffb86c;
}

.secondary-button {
    background: transparent;
    border: 2px solid #666;
    color: #ccc;
}

.secondary-button:hover {
    border-color: #fff;
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* --- DENDY D-PAD STYLES --- */
.dpad-container {
    position: relative;
    width: 150px;
    height: 150px;
}

.dpad-horizontal,
.dpad-vertical {
    position: absolute;
    background-color: #222;
    border: 3px solid #555;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
}

.dpad-horizontal {
    top: 50px;
    left: 0;
    width: 150px;
    height: 50px;
    z-index: 1;
}

.dpad-vertical {
    top: 0;
    left: 50px;
    width: 50px;
    height: 150px;
    z-index: 1;
}

/* Center filler to cover borders */
.dpad-center-fill {
    position: absolute;
    top: 53px;
    left: 53px;
    width: 44px;
    height: 44px;
    background-color: #222;
    z-index: 2;
}

/* Decor: Central Circle */
.dpad-center-circle {
    position: absolute;
    top: 60px;
    left: 60px;
    width: 30px;
    height: 30px;
    background: radial-gradient(circle at 30% 30%, #444, #111);
    border-radius: 50%;
    z-index: 3;
    opacity: 0.8;
}

.dpad-btn {
    position: absolute;
    width: 50px;
    height: 50px;
    z-index: 10;
    /* Transparent but clickable */
    background: transparent;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
}

/* Texture/lines on buttons */
.dpad-texture {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    pointer-events: none;
}

/* Arrows */
.dpad-arrow {
    width: 0;
    height: 0;
    border-style: solid;
    opacity: 0.7;
    pointer-events: none;
    z-index: 4;
}

.dpad-up {
    top: 0;
    left: 50px;
}

.dpad-down {
    top: 100px;
    left: 50px;
}

.dpad-left {
    top: 50px;
    left: 0;
}

.dpad-right {
    top: 50px;
    left: 100px;
}

/* Arrow Shapes */
.dpad-up .dpad-arrow {
    border-width: 0 8px 12px 8px;
    border-color: transparent transparent #000 transparent;
}

.dpad-down .dpad-arrow {
    border-width: 12px 8px 0 8px;
    border-color: #000 transparent transparent transparent;
}

.dpad-left .dpad-arrow {
    border-width: 8px 12px 8px 0;
    border-color: transparent #000 transparent transparent;
}

.dpad-right .dpad-arrow {
    border-width: 8px 0 8px 12px;
    border-color: transparent transparent transparent #000;
}

/* Active State Visuals */
.dpad-btn:active .dpad-arrow {
    opacity: 1;
    border-bottom-color: #fca048;
    /* Orange highlight for Up (approx) */
}

/* Specific overrides for active colors if needed */
.dpad-up:active .dpad-arrow {
    border-bottom-color: #fca048;
}

.dpad-down:active .dpad-arrow {
    border-top-color: #fca048;
}

.dpad-left:active .dpad-arrow {
    border-right-color: #fca048;
}

.dpad-right:active .dpad-arrow {
    border-left-color: #fca048;
}

/* Pressed Effect on the button area itself to simulated depth */
.dpad-btn:active {
    background: rgba(255, 255, 255, 0.05);
}

/* --- TOP CONTROLS (Sound + Touch) --- */
#top-controls {
    position: fixed;
    top: 10px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 10000;
}

#sound-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.6);
    padding: 5px 10px;
    border-radius: 20px;
    border: 1px solid #444;
}

#mute-btn {
    font-size: 20px;
    cursor: pointer;
    user-select: none;
    line-height: 1;
}

/* Custom Range Slider */
#volume-slider {
    -webkit-appearance: none;
    width: 80px;
    height: 4px;
    background: #555;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: #fca048;
    /* Orange */
    border-radius: 50%;
    cursor: pointer;
}

#volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Touch Toggle Btn - update style to be relative inside flex */
#touch-toggle-btn {
    position: static !important;
    /* Override previous fixed pos */
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #444;
    color: white;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: transform 0.1s, text-shadow 0.2s;
}

#touch-toggle-btn:hover {
    text-shadow: 0 0 10px white;
    background: rgba(255, 255, 255, 0.1);
}

#touch-toggle-btn:active {
    transform: scale(0.9);
}

#btn-pause-toggle {
    /* Same style as touch toggle */
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #444;
    color: white;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: transform 0.1s, text-shadow 0.2s;
}

#btn-pause-toggle:hover {
    text-shadow: 0 0 10px white;
    background: rgba(255, 255, 255, 0.1);
}

#btn-pause-toggle:active {
    transform: scale(0.9);
}

#game-controls-top {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* === VOICE CHAT CONTROLS === */
#voice-controls-top {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-right: 20px;
    background: rgba(0, 0, 0, 0.5);
    padding: 5px 10px;
    border-radius: 20px;
    border: 1px solid #444;
}

#btn-mic-toggle {
    cursor: pointer;
    font-size: 20px;
    opacity: 0.5;
    transition: all 0.2s;
}

#opponent-voice-indicator {
    font-size: 20px;
    opacity: 0.3;
}

/* === MOBILE ADAPTATION === */
@media (max-width: 900px) {

    /* Shrink Back Button */
    .back-to-menu {
        top: 5px;
        left: 5px;
        padding: 6px 10px;
        font-size: 8px;
    }

    /* Adjust Top Controls Container - Stack Vertically */
    #top-controls {
        top: 5px;
        right: 5px;
        gap: 10px;
        max-width: none;
        flex-direction: column;
        align-items: flex-end;
    }

    /* Reorder: Gamepad(0), Voice(1), Sound(2) */
    #touch-toggle-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
        /* Custom order removed, relies on wrapper */
    }

    #btn-pause-toggle {
        width: 32px;
        height: 32px;
        font-size: 16px;
        /* Custom order removed, relies on wrapper */
    }

    #game-controls-top {
        order: -1;
        /* Place the group at the top */
        gap: 10px;
        /* Smaller gap on mobile */
    }

    #voice-controls-top {
        gap: 8px;
        margin-right: 0;
        padding: 4px 6px;
        order: 1;
    }

    #sound-controls {
        padding: 4px 6px;
        gap: 5px;
        order: 2;
        /* Make background darker/distinct if needed */
        background: rgba(0, 0, 0, 0.7);
    }

    #btn-mic-toggle,
    #opponent-voice-indicator,
    #mute-btn {
        font-size: 16px;
    }

    #volume-slider {
        width: 50px;
    }
}