* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
}

body {
    background: #000000;
    font-family: 'Courier New', monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    overflow: hidden; /* убираем прокрутку страницы */
}

.game-container {
    background: #000000;
    border: 2px solid #404040;
    padding: 60px 20px 20px 20px;  /* увеличен верхний отступ для кнопок языка */
    text-align: center;
    max-width: 95vw;
    max-height: 95vh;
    overflow-y: auto;
    position: relative;
}

h1, h2 {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    letter-spacing: 2px;
    color: #ffff00;
    margin-bottom: 20px;      /* увеличен */
    font-size: 2rem;          /* увеличен */
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;                /* увеличен промежуток */
    align-items: center;
    margin: 20px 0;           /* увеличен отступ */
}

button, .small-btn {
    background: #202020;
    color: #ffffff;
    border: 1px solid #808080;
    padding: 12px 30px;       /* увеличен паддинг */
    font-family: 'Courier New', monospace;
    font-size: 1rem;          /* увеличен шрифт */
    font-weight: bold;
    cursor: pointer;
    min-width: 200px;         /* увеличен */
}

button:hover, .small-btn:hover {
    background: #404040;
    border-color: #ffff00;
}

.small-btn {
    padding: 8px 20px;
    min-width: 160px;
    margin-top: 10px;
}

.records {
    margin-top: 25px;
    font-family: 'Courier New', monospace;
    font-size: 1rem;          /* увеличен */
    color: #00cc44;
    background: #101010;
    display: inline-block;
    padding: 12px 30px;       /* увеличен */
    border: 1px solid #808080;
}

.rules-text {
    text-align: left;
    background: #101010;
    padding: 15px;
    border: 1px solid #808080;
    margin: 15px auto;
    max-width: 600px;
    max-height: 50vh;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: #dddddd;
}

.rules-text ul {
    margin-left: 25px;
    margin-top: 8px;
}
.rules-text li { margin: 6px 0; }

/* Кнопка кика — компактный стиль */
.kick-btn {
    font-size: 11px !important;
    padding: 2px 8px !important;
    min-width: unset !important;
    background: #441111 !important;
    border-color: #883333 !important;
    color: #ff8888 !important;
}
.kick-btn:hover {
    background: #662222 !important;
    border-color: #ff4444 !important;
}
kbd {
    background: #222;
    border: 1px solid #aaa;
    padding: 2px 6px;
    font-family: monospace;
    font-weight: bold;
    color: #ffff00;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    background: #101010;
    padding: 8px 15px;
    border: 1px solid #404040;
}

.header-item {
    color: #ffff00;
    font-weight: bold;
}
.header-item span {
    color: #00cc44;
}
.message {
    color: #ffaa66;
}

canvas {
    background: #000000;
    display: block;
    margin: 0 auto;
    border: 2px solid #404040;
    max-width: 100%;
    height: auto;
    width: auto;
    max-height: 60vh;
}

.game-controls {
    margin-top: 10px;
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.popup-message {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.95);
    font-size: 48px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    padding: 20px 40px;
    border-width: 3px;
    border-style: solid;
    z-index: 1000;
    text-align: center;
    white-space: nowrap;
    color: #ffffff;
}
.popup-message.success {
    color: #00ff00;
    border-color: #00ff00;
}
.popup-message.error {
    color: #ff3333;
    border-color: #ff3333;
}
.popup-message.gameover {
    color: #ffff00;
    border-color: #ffff00;
}

/* Стили для онлайн дуэли */
.online-container { text-align: center; }
.tab-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 15px 0;
    flex-wrap: wrap;
}
.tab-btn {
    background: #202020;
    color: #ffffff;
    border: 1px solid #808080;
    padding: 8px 25px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    cursor: pointer;
}
.tab-btn.active {
    background: #404040;
    border-color: #ffff00;
    color: #ffff00;
}
.tab-content { display: none; }
.tab-content.active { display: block; }
.room-panel {
    background: #101010;
    border: 1px solid #404040;
    padding: 15px;
    margin: 15px auto;
    max-width: 500px;
}
.room-code {
    font-size: 28px;
    font-family: monospace;
    background: #000;
    padding: 8px;
    letter-spacing: 3px;
    border: 1px solid #ffd966;
    color: #ffd966;
}
.flex-players {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 15px;
    flex-wrap: wrap;
}
.player-card {
    background: #101010;
    border: 1px solid #404040;
    padding: 10px;
    transition: background-color 0.3s;
}
.online-canvas { border: 2px solid #808080; transition: box-shadow 0.1s; }
.status { margin-top: 15px; font-size: 1rem; font-weight: bold; color: #ffff00; }
.copy-btn { background: #2a2a2a; padding: 4px 12px; font-size: 0.8rem; }
.lives { font-size: 1rem; font-family: monospace; margin-top: 5px; color: #ff6666; }
.countdown { font-size: 40px; font-weight: bold; color: #ffff00; text-align: center; margin: 15px; }
.nickname { font-size: 0.9rem; color: #ffd966; margin-bottom: 8px; }
.waiting-players {
    margin-top: 15px;
    text-align: left;
    font-family: monospace;
    font-size: 1rem;
    background: #000;
    padding: 8px;
    border: 1px solid #808080;
    color: #ffffff;
}
.waiting-players div { margin: 6px 0; color: #ffffaa; }
.waiting-players span { color: #ffd966; font-weight: bold; }
.popup-error {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.95);
    color: #ff3333;
    font-size: 40px;
    font-family: monospace;
    font-weight: bold;
    padding: 20px 40px;
    border: 3px solid #ff3333;
    z-index: 1000;
    white-space: nowrap;
}
.lobby-list {
    background: #000;
    border: 1px solid #808080;
    padding: 8px;
    max-height: 250px;
    overflow-y: auto;
    text-align: left;
}
.lobby-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px;
    border-bottom: 1px solid #404040;
}
.lobby-name { color: #ffd966; font-weight: bold; }
.lobby-creator { color: #aaaaaa; font-size: 0.8rem; }
.join-lobby-btn { padding: 3px 10px; margin: 0; }
.refresh-btn { margin-top: 8px; }
.info-text {
    font-size: 0.8rem;
    color: #aaaaaa;
    margin: 4px 0;
}
.numbers-toggle {
    margin-left: 15px;
    background: #2a2a2a;
}
.waiting-numbers-btn {
    margin-top: 8px;
    background: #2a2a2a;
}

/* Стили для эстафеты */
.mode-selector {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
    background: #101010;
    padding: 8px;
    border: 1px solid #404040;
}
.mode-selector label {
    font-family: 'Courier New', monospace;
    color: #ffffaa;
    cursor: pointer;
}
.mode-selector input {
    margin-right: 4px;
}
.relay-players-list {
    background: #000;
    border: 1px solid #808080;
    padding: 8px;
    max-height: 180px;
    overflow-y: auto;
    text-align: left;
    margin: 8px 0;
}
.relay-player-item {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    border-bottom: 1px solid #404040;
    padding: 4px;
    font-family: monospace;
    color: #ffffff;
}
.relay-player-item .nick { color: #ffd966; font-weight: bold; }
.relay-player-item .status { color: #aaa; }
.relay-player-item .steps { color: #88ff88; font-size: 0.75rem; }
.relay-my-steps {
    background: #101010;
    border: 1px solid #808080;
    padding: 8px;
    margin: 8px 0;
    text-align: left;
    color: #ffffff;
}
.relay-afk-warning {
    position: fixed;
    bottom: 15px;
    right: 15px;
    background: rgba(0,0,0,0.9);
    border: 2px solid #ffaa00;
    padding: 8px 15px;
    font-family: monospace;
    font-weight: bold;
    color: #ffaa00;
    z-index: 1000;
    display: none;
}
.relay-countdown {
    font-size: 40px;
    font-weight: bold;
    color: #ffff00;
    text-align: center;
    margin: 15px;
}
.relay-game-over-msg {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.95);
    border: 3px solid #ffff00;
    padding: 20px 40px;
    font-size: 36px;
    font-family: monospace;
    font-weight: bold;
    color: #ffff00;
    z-index: 1001;
    display: none;
    text-align: center;
    white-space: nowrap;
}
.current-step-hint {
    font-size: 28px;
    margin: 8px 0;
    font-family: monospace;
    background: #000;
    display: inline-block;
    padding: 4px 15px;
    border: 2px solid #ffd966;
    color: #ffffff;
}

/* Дополнительные стили для FFA */
.ffa-container { max-width: 1400px; margin: 0 auto; position: relative; }
.players-grid { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 15px 0; }
.player-mini-card { width: 140px; background: #000; border: 1px solid #404040; border-radius: 8px; padding: 8px; text-align: center; }
.player-mini-card .nick { font-weight: bold; color: #ffd966; margin-bottom: 6px; font-size: 0.85rem; word-break: break-word; }
.player-mini-card .mini-field { width: 100%; height: 80px; background: rgba(0,0,0,0.8); border: 1px solid #808080; position: relative; margin-bottom: 6px; display: flex; align-items: center; justify-content: center; }
.player-mini-card .icon { font-size: 40px; }
.player-mini-card .stats { font-size: 0.65rem; color: #aaa; }
.ranking-table { margin-top: 15px; background: #000; border: 1px solid #808080; padding: 8px; text-align: left; color: #ffffff; }
.ranking-table table { width: 100%; border-collapse: collapse; color: #fff; }
.ranking-table th, .ranking-table td { padding: 6px; border-bottom: 1px solid #404040; }
.ranking-table th { color: #ffd966; }
.current-level-info { margin: 8px 0; font-size: 1rem; color: #ffffff; }
.countdown-big { font-size: 40px; color: #ffff00; text-align: center; margin: 15px; }
.game-canvas { border: 2px solid #808080; background: #000; }
.ffa-game-panel { text-align: center; }

/* Адаптация под маленькие экраны */
@media (max-width: 800px) {
    .game-container { padding: 50px 10px 10px 10px; }
    h1 { font-size: 1.5rem; }
    button { padding: 8px 20px; font-size: 0.85rem; min-width: 160px; }
    .player-card { padding: 5px; }
    .flex-players { gap: 15px; }
    .popup-message, .popup-error, .relay-game-over-msg { font-size: 28px; padding: 15px 30px; white-space: normal; text-align: center; }
}

/* Цвет текста на канвасе (номера) теперь белый, но это задаётся в JS, поэтому в CSS не нужно, но для прочих текстов */
body, .game-container, .player-card, .waiting-players, .relay-my-steps, .ranking-table, .current-level-info {
    color: #ffffff;
}

/* Переключатель языка – в правом верхнем углу, маленькие кнопки */
.language-switch {
    position: absolute;
    top: 10px;
    right: 20px;
    z-index: 100;
    display: flex;
    gap: 6px;
}

.lang-btn {
    background: #202020;
    color: #ffffff;
    border: 1px solid #808080;
    padding: 2px 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.65rem;
    font-weight: bold;
    cursor: pointer;
    min-width: auto;
}

.lang-btn:hover {
    background: #404040;
    border-color: #ffff00;
}

/* Градиент для подписи "Made by ..." */
.credits {
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    font-weight: bold;
    margin: 5px 0 15px 0;
    letter-spacing: 1px;
    background: linear-gradient(90deg, #ff8800, #ffdd55);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 0 2px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
}

.credits:hover {
    background: linear-gradient(90deg, #ffaa33, #ffee88);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    transform: scale(1.02);
}

/* Для пост-игровой панели FFA */
#postGamePanel {
    width: 95vw;
    max-width: 1200px;
    margin: 20px auto;
    overflow-x: auto;
}
#postGamePanel .ranking-table {
    width: 100%;
    overflow-x: auto;
}
#postGamePanel table {
    min-width: 400px;
}
#postGamePlayersList {
    max-height: 150px;
    overflow-y: auto;
}
.relay-player-item {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    border-bottom: 1px solid #404040;
    padding: 4px;
    font-family: monospace;
    color: #ffffff;
}
.relay-player-item .nick {
    color: #ffd966;
    font-weight: bold;
}
.relay-player-item .status {
    color: #aaa;
}

.game-container {
    max-height: 98vh;  /* было 95vh */
    overflow-y: auto;  /* оставляем, чтобы контейнер скроллился, но теперь больше места */
}

#postGamePanel {
    width: 95vw;
    max-width: 1200px;
    margin: 20px auto;
    overflow-x: auto;   /* горизонтальная прокрутка только для таблицы, если не влезает */
}

#postGamePanel .ranking-table {
    overflow-x: auto;
    max-height: none;   /* убираем ограничение высоты */
}

.room-panel {
    padding: 10px;  /* было 15px, можно уменьшить */
}

.afk-warning {
    position: fixed;
    bottom: 15px;
    right: 15px;
    background: rgba(0,0,0,0.9);
    border: 2px solid #ffaa00;
    padding: 8px 15px;
    font-family: monospace;
    font-weight: bold;
    color: #ffaa00;
    z-index: 1000;
    display: none;
}

.feedback-button button {
    transition: background 0.2s;
}
.feedback-button button:hover {
    background: #404040;
    border-color: #ffff00;
}
#feedbackModal a, #feedbackModal button {
    font-family: 'Courier New', monospace;
}

/* ============ СЕЛЕКТОР УСТРОЙСТВА ============ */
.device-selector {
    margin: 15px auto;
    padding: 15px;
    border: 2px solid #ffff00;
    background: #101010;
    max-width: 400px;
}
.device-selector-title {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 12px;
    color: #ffff00;
}
.device-selector-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}
.device-btn {
    flex: 1;
    background: #202020;
    border: 2px solid #808080;
    color: #fff;
    padding: 15px 10px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}
.device-btn:hover {
    background: #404040;
    border-color: #ffff00;
}
.device-btn.selected {
    background: #ffff00;
    color: #000;
    border-color: #ffff00;
}
.device-change-bar {
    margin-top: 15px;
    font-size: 0.85rem;
    color: #aaa;
}
.global-nickname-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 12px 0 18px 0;
    font-size: 14px;
}
.global-nickname-bar label {
    color: #aaa;
    white-space: nowrap;
}
.global-nickname-bar input {
    background: #111;
    border: 1px solid #444;
    color: #ffd966;
    padding: 6px 12px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    border-radius: 4px;
    width: 200px;
    text-align: center;
}
.global-nickname-bar input:focus {
    outline: none;
    border-color: #ffd966;
}
.device-change-btn {
    background: #202020;
    border: 1px solid #808080;
    color: #fff;
    padding: 5px 12px;
    margin-left: 8px;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    border-radius: 5px;
    font-size: 0.8rem;
}
.device-change-btn:hover {
    background: #404040;
    border-color: #ffff00;
}
.device-selector.hidden {
    display: none;
}

/* ============ ON-SCREEN СТРЕЛКИ (МОБИЛЬНЫЕ) ============ */
.dpad-container {
    display: none;
    margin: 8px auto;
    width: 144px;
    height: 144px;
    position: relative;
}
.dpad-container.visible {
    display: grid;
    grid-template-columns: 48px 48px 48px;
    grid-template-rows: 48px 48px 48px;
    gap: 0;
    justify-content: center;
    align-items: center;
    border: 3px solid #606060;
    border-radius: 12px;
    background: #1a1a1a;
    box-shadow: 0 3px 8px rgba(0,0,0,0.5);
    overflow: hidden;
}
.dpad-btn {
    background: #2a2a2a;
    border: 1px solid #444;
    color: #ffcc00;
    font-size: 24px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    transition: background 0.12s;
    padding: 0;
    margin: 0;
    min-width: 0;
    width: 100%;
    height: 100%;
    align-self: stretch;
    justify-self: stretch;
}
.dpad-btn:active {
    background: #ffcc00;
    color: #000;
}
/* Единый блок: скругления только по внешнему краю */
.dpad-up    { grid-column: 2; grid-row: 1; }
.dpad-left  { grid-column: 1; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down  { grid-column: 2; grid-row: 3; }
/* Убираем двойные рамки между кнопками */
.dpad-up, .dpad-down { border-left: none; border-right: none; }
.dpad-left { border-top: none; border-bottom: none; border-right: none; }
.dpad-right { border-top: none; border-bottom: none; border-left: none; }
.dpad-up { border-bottom: none; }
.dpad-down { border-top: none; }

/* Для онлайн-дуэли: стрелки между полями */
.duel-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.duel-fields {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}
.duel-dpad-wrapper {
    display: none;
    justify-content: center;
}
body.device-mobile .duel-dpad-wrapper {
    display: flex;
}
@media (max-width: 768px) {
    body:not(.device-pc) .duel-dpad-wrapper {
        display: flex;
    }
    body:not(.device-pc) .flex-players {
        flex-direction: column;
        align-items: center;
    }
}

/* Мобильные: уменьшаем поле, всё влезает в 1 экран */
body.device-mobile .game-container {
    padding: 8px 8px 8px 8px;
    max-width: 100vw;
    min-height: 100dvh;
    max-height: 100dvh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}
body.device-mobile canvas {
    max-width: 94vw;
    max-height: 26vh;
    width: auto;
    height: auto;
    object-fit: contain;
}
body.device-mobile .menu-buttons button {
    font-size: 0.85rem;
    padding: 8px 14px;
}
/* Компактное главное меню на телефоне */
body.device-mobile h1 {
    font-size: 1.4rem;
    margin-bottom: 10px;
    letter-spacing: 1px;
}
body.device-mobile .menu-buttons {
    gap: 8px;
    margin: 10px 0;
}
body.device-mobile .device-selector {
    margin: 6px auto;
    padding: 8px;
    max-width: 94vw;
}
body.device-mobile .device-selector-title {
    font-size: 0.9rem;
    margin-bottom: 6px;
}
body.device-mobile .device-selector .device-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
}
body.device-mobile .device-change-bar {
    margin: 6px 0;
    font-size: 0.8rem;
}
body.device-mobile .records {
    margin: 4px 0;
    font-size: 0.8rem;
}
/* Компактный игровой экран на телефоне */
body.device-mobile .game-header {
    font-size: 0.75rem;
    padding: 5px 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
    gap: 4px;
}
body.device-mobile .header-item {
    font-size: 0.75rem;
}
body.device-mobile .game-controls {
    margin-top: 6px;
    gap: 6px;
    flex-wrap: wrap;
}
body.device-mobile .game-controls button {
    padding: 6px 10px;
    font-size: 0.75rem;
}
body.device-mobile .game-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-height: 100dvh;
    overflow: hidden;
}
body.device-mobile .language-switch {
    top: 4px;
    right: 6px;
}
body.device-mobile .language-switch button {
    padding: 4px 8px;
    font-size: 0.75rem;
}
@media (max-width: 768px) {
    body:not(.device-pc) .dpad-container {
        display: grid;
    }
}

/* ============ КНОПКА КИКА ============ */
.kick-btn {
    background: #662222;
    color: #ff8888;
    border: 1px solid #aa3333;
    padding: 2px 8px;
    font-size: 11px;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    border-radius: 3px;
    margin-left: 6px;
}
.kick-btn:hover {
    background: #993333;
    border-color: #ff4444;
}

/* ============ БЕЙДЖ ЖАЛОБ ============ */
.complaint-badge {
    display: inline-block;
    background: #cc3333;
    color: #fff;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 5px;
    font-weight: bold;
}