* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(to bottom, #0f1525, #1a1f33);
    color: #fff;
    overflow-x: hidden;
    padding: 10px 10px 20px 10px;
    touch-action: manipulation;
    width: 100%;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    gap: 15px;
    margin-bottom: 10px;
    flex: 1;
}

.header {
    text-align: center;
    padding: 10px 0;
    width: 100%;
    border-bottom: 3px solid #e94560;
    margin-bottom: 10px;
    background: rgba(15, 20, 40, 0.8);
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

h1 {
    font-size: 2.2rem;
    color: #0fccce;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

h1 i {
    color: #e94560;
}

.subtitle {
    font-size: 1rem;
    color: #aaa;
    margin-top: 5px;
    font-weight: 300;
}

.game-wrapper {
    position: relative;
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-height: 0;
}

#gameCanvas {
    background-color: #0a0e1a;
    border: 4px solid #e94560;
    border-radius: 8px;
    width: 100%;
    max-width: 800px;
    height: auto;
    aspect-ratio: 1 / 1;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
    display: block;
}

.game-info {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 800px;
    padding: 12px;
    background: rgba(15, 20, 40, 0.9);
    border-radius: 10px;
    margin-top: 10px;
    font-size: 1rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.info-label {
    font-size: 0.85rem;
    color: #0fccce;
    display: flex;
    align-items: center;
    gap: 5px;
}

.info-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #fff;
    margin-top: 5px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* Мобильные кнопки - ИСПРАВЛЕНО */
.mobile-controls {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: linear-gradient(to top, rgba(10, 15, 30, 0.95), rgba(15, 20, 40, 0.9));
    padding: 12px 10px;
    border-top: 3px solid #e94560;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.7);
    width: 100%;
    max-width: 100%;
    height: auto;
}

.mobile-controls.visible {
    display: block;
}

.mobile-controls-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 800px;
    margin: 0 auto;
    gap: 20px;
}

.d-pad-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 6px;
    width: 130px;
    height: 130px;
    position: relative;
    margin-bottom: 5px;
}

.d-pad-center {
    grid-column: 2;
    grid-row: 2;
    background-color: rgba(45, 48, 71, 0.8);
    border-radius: 50%;
}

.d-pad-label {
    font-size: 0.8rem;
    color: #0fccce;
    font-weight: 600;
    text-align: center;
}

.action-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    max-width: 160px;
}

.control-btn {
    width: 100%;
    height: 100%;
    min-height: 40px;
    background: linear-gradient(to bottom, #3a3e5c, #2d3047);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    transition: all 0.1s;
    box-shadow: 0 5px 0 rgba(0, 0, 0, 0.4);
    touch-action: manipulation;
    font-weight: 600;
    padding: 5px;
}

.control-btn:active {
    transform: translateY(5px);
    box-shadow: 0 0 0 rgba(0, 0, 0, 0.4);
}

.control-btn.up {
    grid-column: 2;
    grid-row: 1;
    background: linear-gradient(to bottom, #4a4e7c, #3a3e5c);
}

.control-btn.down {
    grid-column: 2;
    grid-row: 3;
    background: linear-gradient(to bottom, #4a4e7c, #3a3e5c);
}

.control-btn.left {
    grid-column: 1;
    grid-row: 2;
    background: linear-gradient(to bottom, #4a4e7c, #3a3e5c);
}

.control-btn.right {
    grid-column: 3;
    grid-row: 2;
    background: linear-gradient(to bottom, #4a4e7c, #3a3e5c);
}

.fire-btn {
    background: linear-gradient(to bottom, #e94560, #b3364a);
    height: 60px;
    font-size: 1rem;
}

.fire-btn:active {
    background: linear-gradient(to bottom, #b3364a, #8c2a3a);
}

.pause-btn {
    background: linear-gradient(to bottom, #0fccce, #0c9a9c);
    height: 60px;
    font-size: 1rem;
}

.pause-btn:active {
    background: linear-gradient(to bottom, #0c9a9c, #087a7c);
}

.legend {
    max-width: 800px;
    background: rgba(15, 20, 40, 0.9);
    border-radius: 10px;
    padding: 15px;
    margin-top: 15px;
    width: 100%;
    flex-shrink: 0;
}

.legend h3 {
    color: #0fccce;
    margin-bottom: 15px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.2rem;
}

.legend-items {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.tank-icon, .icon {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    flex-shrink: 0;
}

.tank-icon.player {
    background-color: #0fccce;
    position: relative;
}

.tank-icon.player:after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 10px;
    background-color: white;
    border-radius: 2px;
}

.tank-icon.enemy {
    background-color: #e94560;
    position: relative;
}

.tank-icon.enemy:after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 10px;
    background-color: white;
    border-radius: 2px;
}

.tank-icon.boss {
    background-color: #ffcc00;
    position: relative;
}

.tank-icon.boss:after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 12px;
    background-color: white;
    border-radius: 2px;
}

.icon.base {
    background-color: #ffcc00;
    position: relative;
}

.icon.base:after {
    content: "★";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #000;
    font-size: 10px;
    font-weight: bold;
}

.icon.brick {
    background-color: #8b4513;
}

.icon.steel {
    background-color: #666;
}

.icon.water {
    background-color: #1a5f9c;
}

.icon.bonus-life {
    background-color: #e94560;
    position: relative;
}

.icon.bonus-life:after {
    content: "❤";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 10px;
}

.icon.bonus-speed {
    background-color: #0fccce;
    position: relative;
}

.icon.bonus-speed:after {
    content: "⚡";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 10px;
}

.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 15, 30, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 8px;
    text-align: center;
    padding: 20px;
}

.overlay-title {
    font-size: 2.5rem;
    color: #0fccce;
    margin-bottom: 20px;
    text-shadow: 3px 3px 5px rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.overlay-message {
    font-size: 1.2rem;
    margin-bottom: 25px;
    max-width: 90%;
    line-height: 1.6;
    color: #ddd;
}

.final-score {
    font-size: 3.5rem;
    font-weight: bold;
    color: #ffcc00;
    margin: 20px 0;
    text-shadow: 3px 3px 5px rgba(0, 0, 0, 0.7);
}

.btn {
    border: none;
    border-radius: 10px;
    color: white;
    padding: 14px 28px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s;
    margin: 5px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 180px;
}

.btn-primary {
    background: linear-gradient(to bottom, #0fccce, #0c9a9c);
    box-shadow: 0 5px 0 rgba(12, 154, 156, 0.5);
}

.btn-primary:hover, .btn-primary:active {
    background: linear-gradient(to bottom, #0c9a9c, #087a7c);
    transform: translateY(2px);
    box-shadow: 0 3px 0 rgba(12, 154, 156, 0.5);
}

.btn-secondary {
    background: linear-gradient(to bottom, #3a3e5c, #2d3047);
    box-shadow: 0 5px 0 rgba(45, 48, 71, 0.5);
}

.btn-secondary:hover, .btn-secondary:active {
    background: linear-gradient(to bottom, #2d3047, #1a1c2e);
    transform: translateY(2px);
    box-shadow: 0 3px 0 rgba(45, 48, 71, 0.5);
}

.menu-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
}

#saveScoreForm {
    background: rgba(15, 20, 40, 0.9);
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    width: 90%;
    max-width: 400px;
}

#saveScoreForm h3 {
    color: #ffcc00;
    margin-bottom: 10px;
}

#saveScoreForm p {
    margin-bottom: 15px;
    color: #ddd;
}

#playerName {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 2px solid #0fccce;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.1rem;
    margin-bottom: 15px;
    text-align: center;
}

#playerName:focus {
    outline: none;
    border-color: #ffcc00;
}

/* ========== ТАБЛИЦА ЛИДЕРОВ - УВЕЛИЧЕНА ВЫСОТА КОНТЕЙНЕРА ========== */
.leaderboard-container {
    width: 90%;
    max-width: 750px;
    background: rgba(15, 20, 40, 0.95);
    border-radius: 15px;
    padding: 25px;
    margin: 25px 0;
    /* УВЕЛИЧЕНА МАКСИМАЛЬНАЯ ВЫСОТА ДЛЯ ПОКАЗА БОЛЬШЕ СТРОК */
    max-height: 70vh; /* Вместо фиксированного значения используем проценты от высоты экрана */
    min-height: 400px; /* Минимальная высота для небольших экранов */
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    border: 3px solid #0fccce;
    display: flex;
    flex-direction: column;
}

/* Стили для скроллбара в таблице лидеров */
.leaderboard-container::-webkit-scrollbar {
    width: 12px;
}

.leaderboard-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.leaderboard-container::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #0fccce, #0c9a9c);
    border-radius: 10px;
    border: 3px solid rgba(15, 20, 40, 0.95);
}

.leaderboard-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #0c9a9c, #087a7c);
}

#leaderboardTable {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 10px;
    color: white;
    table-layout: fixed; /* Фиксированная ширина столбцов */
}

#leaderboardTable th {
    background: linear-gradient(to bottom, #0fccce, #0c9a9c);
    color: #000;
    padding: 20px 15px;
    text-align: left;
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 3px solid rgba(0, 0, 0, 0.3);
}

#leaderboardTable th:first-child {
    border-radius: 10px 0 0 0;
    width: 15%;
}

#leaderboardTable th:nth-child(2) {
    width: 25%;
}

#leaderboardTable th:nth-child(3) {
    width: 20%;
    text-align: center;
}

#leaderboardTable th:nth-child(4) {
    width: 15%;
    text-align: center;
}

#leaderboardTable th:nth-child(5) {
    width: 25%;
    text-align: center;
    border-radius: 0 10px 0 0;
}

#leaderboardTable td {
    padding: 18px 15px;
    background-color: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1.1rem;
    transition: all 0.3s ease;
    vertical-align: middle;
    line-height: 1.4;
}

#leaderboardTable tr {
    transition: all 0.3s ease;
}

#leaderboardTable tr:nth-child(even) td {
    background-color: rgba(255, 255, 255, 0.1);
}

#leaderboardTable tr:hover td {
    background-color: rgba(15, 204, 206, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* Стили для первых трех мест */
#leaderboardTable tr:first-child td {
    background: linear-gradient(to right, rgba(255, 215, 0, 0.15), rgba(255, 215, 0, 0.08));
    border-left: 4px solid gold;
    border-right: 4px solid gold;
}

#leaderboardTable tr:nth-child(2) td {
    background: linear-gradient(to right, rgba(192, 192, 192, 0.15), rgba(192, 192, 192, 0.08));
    border-left: 4px solid silver;
    border-right: 4px solid silver;
}

#leaderboardTable tr:nth-child(3) td {
    background: linear-gradient(to right, rgba(205, 127, 50, 0.15), rgba(205, 127, 50, 0.08));
    border-left: 4px solid #cd7f32;
    border-right: 4px solid #cd7f32;
}

/* Иконки медалей */
.medal-gold {
    color: gold;
    text-shadow: 0 0 6px rgba(255, 215, 0, 0.5);
}

.medal-silver {
    color: silver;
    text-shadow: 0 0 6px rgba(192, 192, 192, 0.5);
}

.medal-bronze {
    color: #cd7f32;
    text-shadow: 0 0 6px rgba(205, 127, 50, 0.5);
}

/* Стиль для ячеек с медалями */
#leaderboardTable td:first-child {
    font-weight: bold;
    font-size: 1.2rem;
    text-align: center;
}

#leaderboardTable td:nth-child(2) {
    font-weight: 600;
}

#leaderboardTable td:nth-child(3) {
    color: #ffcc00;
    font-weight: bold;
    font-size: 1.2rem;
    text-align: center;
}

#leaderboardTable td:nth-child(4) {
    color: #0fccce;
    font-weight: 600;
    text-align: center;
}

#leaderboardTable td:nth-child(5) {
    color: #aaa;
    font-size: 0.95rem;
    text-align: center;
}

/* Пустая таблица */
#leaderboardTable td[colspan] {
    text-align: center;
    padding: 50px 30px;
    font-size: 1.3rem;
    color: #aaa;
    background-color: rgba(255, 255, 255, 0.03);
    border: 2px dashed #0fccce;
    border-radius: 10px;
}
/* ========== КОНЕЦ ТАБЛИЦЫ ЛИДЕРОВ ========== */

.instructions-content {
    width: 90%;
    max-width: 700px;
    background: rgba(15, 20, 40, 0.9);
    border-radius: 10px;
    padding: 20px;
    margin: 20px 0;
    max-height: 400px;
    overflow-y: auto;
    text-align: left;
}

.instructions-section {
    margin-bottom: 25px;
}

.instructions-section h3 {
    color: #0fccce;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.instructions-section p {
    color: #ddd;
    line-height: 1.6;
    margin-bottom: 10px;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 15px 0;
}

.control-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.control-item .key {
    background-color: #2d3047;
    color: #0fccce;
    padding: 10px 15px;
    border-radius: 8px;
    font-weight: bold;
    min-width: 60px;
    text-align: center;
    font-size: 1.1rem;
}

.mobile-note {
    color: #ffcc00;
    font-style: italic;
    margin-top: 15px;
}

.points-list {
    list-style-type: none;
    padding-left: 20px;
}

.points-list li {
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
}

.points {
    background-color: #ffcc00;
    color: #000;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9rem;
}

.version-info {
    margin-top: 20px;
    color: #aaa;
    font-size: 0.9rem;
    font-style: italic;
}

.hidden {
    display: none;
}

.level-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3.5rem;
    font-weight: bold;
    color: #0fccce;
    text-shadow: 3px 3px 5px rgba(0, 0, 0, 0.7);
    z-index: 5;
    animation: pulse 1.5s ease-in-out;
    background: rgba(0, 0, 0, 0.7);
    padding: 20px 40px;
    border-radius: 15px;
    border: 3px solid #e94560;
}

@keyframes pulse {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

footer {
    margin-top: 20px;
    text-align: center;
    font-size: 0.85rem;
    color: #7a7a9e;
    padding: 15px;
    width: 100%;
    border-top: 1px solid #2d3047;
    flex-shrink: 0;
}

.footer-note {
    font-size: 0.75rem;
    color: #5a5a7e;
    margin-top: 5px;
}

/* Адаптация для мобильных устройств */
@media (max-width: 768px) {
    body {
        padding: 8px 8px 140px 8px;
        justify-content: flex-start;
        min-height: auto;
    }
    
    .container {
        gap: 10px;
        margin-bottom: 0;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
    
    .game-info {
        padding: 8px;
        font-size: 0.9rem;
        margin-top: 5px;
    }
    
    .info-item {
        flex: 0 0 calc(50% - 10px);
        margin-bottom: 5px;
    }
    
    .info-value {
        font-size: 1.3rem;
    }
    
    /* Мобильные кнопки - адаптация */
    .mobile-controls {
        padding: 10px 8px;
    }
    
    .mobile-controls-content {
        gap: 15px;
    }
    
    .d-pad {
        width: 110px;
        height: 110px;
        gap: 5px;
    }
    
    .d-pad-label {
        font-size: 0.75rem;
    }
    
    .action-section {
        max-width: 140px;
        gap: 10px;
    }
    
    .control-btn {
        font-size: 1rem;
        min-height: 35px;
    }
    
    .fire-btn, .pause-btn {
        height: 55px;
        font-size: 0.95rem;
    }
    
    /* Легенда - адаптация */
    .legend {
        display: none; /* Скрываем на мобильных для экономии места */
    }
    
    .overlay-title {
        font-size: 2rem;
    }
    
    .final-score {
        font-size: 2.8rem;
    }
    
    .btn {
        min-width: 150px;
        padding: 12px 20px;
        font-size: 1rem;
    }
    
    .controls-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Адаптация таблицы лидеров для мобильных */
    .leaderboard-container {
        padding: 20px 15px;
        max-height: 65vh; /* Увеличена высота для мобильных */
        min-height: 350px;
        border-radius: 12px;
        margin: 15px 0;
    }
    
    #leaderboardTable {
        font-size: 0.95rem;
        border-spacing: 0 8px;
    }
    
    #leaderboardTable th {
        padding: 16px 10px;
        font-size: 1rem;
    }
    
    #leaderboardTable td {
        padding: 14px 10px;
        font-size: 0.95rem;
        line-height: 1.3;
    }
    
    #leaderboardTable td:first-child {
        font-size: 1rem;
        padding: 14px 5px;
    }
    
    #leaderboardTable td:nth-child(3) {
        font-size: 1rem;
    }
    
    #leaderboardTable td[colspan] {
        padding: 40px 20px;
        font-size: 1.1rem;
    }
    
    .leaderboard-container::-webkit-scrollbar {
        width: 8px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 6px 6px 130px 6px;
    }
    
    h1 {
        font-size: 1.5rem;
        gap: 10px;
    }
    
    .subtitle {
        font-size: 0.8rem;
    }
    
    .game-info {
        padding: 6px;
        flex-wrap: wrap;
    }
    
    .info-item {
        flex: 0 0 50%;
        margin-bottom: 5px;
    }
    
    .info-value {
        font-size: 1.2rem;
    }
    
    /* Компактные мобильные кнопки для маленьких экранов */
    .mobile-controls {
        padding: 8px 6px;
    }
    
    .mobile-controls-content {
        gap: 10px;
    }
    
    .d-pad {
        width: 100px;
        height: 100px;
    }
    
    .action-section {
        max-width: 130px;
    }
    
    .control-btn {
        font-size: 0.9rem;
        min-height: 30px;
    }
    
    .fire-btn, .pause-btn {
        height: 50px;
        font-size: 0.9rem;
    }
    
    .menu-buttons {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .btn {
        width: 100%;
        max-width: 250px;
        padding: 10px 16px;
        font-size: 0.95rem;
    }
    
    .controls-grid {
        grid-template-columns: 1fr;
    }
    
    .overlay-title {
        font-size: 1.7rem;
    }
    
    .overlay-message {
        font-size: 1rem;
    }
    
    .final-score {
        font-size: 2.5rem;
    }
    
    /* Таблица лидеров для очень маленьких экранов */
    .leaderboard-container {
        padding: 15px 12px;
        max-height: 60vh; /* Еще больше для очень маленьких экранов */
        min-height: 300px;
    }
    
    #leaderboardTable {
        font-size: 0.9rem;
        border-spacing: 0 6px;
    }
    
    #leaderboardTable th {
        padding: 14px 8px;
        font-size: 0.95rem;
    }
    
    #leaderboardTable td {
        padding: 12px 8px;
        font-size: 0.9rem;
    }
    
    #leaderboardTable td:first-child {
        font-size: 0.95rem;
        padding: 12px 4px;
    }
    
    #leaderboardTable td:nth-child(3) {
        font-size: 0.95rem;
    }
    
    /* На очень маленьких экранах скрываем столбец с датой */
    #leaderboardTable th:nth-child(5),
    #leaderboardTable td:nth-child(5) {
        display: none;
    }
    
    #leaderboardTable td[colspan] {
        padding: 30px 15px;
        font-size: 1rem;
    }
    
    /* На очень маленьких экранах также уменьшаем отступы в заголовках */
    #leaderboardTable th:nth-child(1) {
        width: 20%;
    }
    
    #leaderboardTable th:nth-child(2) {
        width: 40%;
    }
    
    #leaderboardTable th:nth-child(3) {
        width: 20%;
    }
    
    #leaderboardTable th:nth-child(4) {
        width: 20%;
    }
}

/* Для устройств с очень маленькой высотой экрана */
@media (max-height: 700px) and (max-width: 768px) {
    body {
        padding-bottom: 120px;
    }
    
    .header {
        padding: 5px 0;
    }
    
    h1 {
        font-size: 1.4rem;
        margin-bottom: 0;
    }
    
    .subtitle {
        font-size: 0.75rem;
        margin-top: 2px;
    }
    
    .game-info {
        padding: 5px;
        margin-top: 3px;
    }
    
    .info-label {
        font-size: 0.75rem;
    }
    
    .info-value {
        font-size: 1.1rem;
    }
    
    /* Еще более компактные кнопки */
    .mobile-controls {
        padding: 6px 5px;
    }
    
    .d-pad {
        width: 90px;
        height: 90px;
    }
    
    .action-section {
        max-width: 120px;
    }
    
    .control-btn {
        min-height: 25px;
        font-size: 0.85rem;
    }
    
    .fire-btn, .pause-btn {
        height: 45px;
        font-size: 0.85rem;
    }
    
    /* Таблица лидеров для очень низких экранов */
    .leaderboard-container {
        max-height: 55vh; /* Увеличиваем процент для низких экранов */
        min-height: 250px;
        padding: 12px 10px;
    }
    
    #leaderboardTable th {
        padding: 12px 6px;
        font-size: 0.9rem;
    }
    
    #leaderboardTable td {
        padding: 10px 6px;
        font-size: 0.85rem;
    }
    
    #leaderboardTable td:first-child {
        font-size: 0.9rem;
    }
}

/* Горизонтальная ориентация на мобильных */
@media (max-width: 768px) and (orientation: landscape) {
    body {
        padding: 5px 5px 100px 5px;
        flex-direction: row;
        align-items: flex-start;
        justify-content: center;
    }
    
    .container {
        flex-direction: row;
        flex-wrap: wrap;
        max-width: 100%;
        align-items: flex-start;
        padding-bottom: 0;
    }
    
    .header {
        flex: 0 0 100%;
        margin-bottom: 5px;
        padding: 5px 0;
    }
    
    h1 {
        font-size: 1.3rem;
    }
    
    .game-wrapper {
        flex: 1;
        min-width: 0;
        max-width: calc(100vh - 150px);
    }
    
    .game-info {
        flex: 0 0 auto;
        flex-direction: column;
        width: auto;
        max-width: 120px;
        margin-left: 5px;
        margin-top: 0;
    }
    
    .info-item {
        flex: 0 0 auto;
        margin-bottom: 10px;
    }
    
    .legend {
        display: none;
    }
    
    footer {
        flex: 0 0 100%;
        margin-top: 5px;
        padding: 8px;
        font-size: 0.75rem;
    }
    
    .mobile-controls {
        height: 90px;
        padding: 8px 5px;
    }
    
    .mobile-controls-content {
        height: 100%;
        align-items: center;
    }
    
    .d-pad {
        width: 90px;
        height: 90px;
    }
    
    .action-section {
        flex-direction: row;
        max-width: 180px;
        gap: 10px;
    }
    
    .fire-btn, .pause-btn {
        flex: 1;
        height: 70px;
    }
    
    /* Таблица лидеров в ландшафтном режиме */
    .leaderboard-container {
        max-height: 70vh; /* Увеличиваем высоту в ландшафтном режиме */
        min-height: 200px;
    }
    
    #leaderboardTable th:nth-child(5),
    #leaderboardTable td:nth-child(5) {
        display: table-cell;
    }
    
    /* В ландшафтном режиме уменьшаем размеры для экономии места */
    #leaderboardTable th {
        padding: 14px 8px;
        font-size: 0.9rem;
    }
    
    #leaderboardTable td {
        padding: 12px 8px;
        font-size: 0.9rem;
    }
}

/* Адаптация для планшетов */
@media (min-width: 769px) and (max-width: 1024px) {
    .mobile-controls {
        max-width: 800px;
        left: 50%;
        transform: translateX(-50%);
        padding: 15px;
    }
    
    .d-pad {
        width: 150px;
        height: 150px;
    }
    
    .action-section {
        max-width: 180px;
    }
    
    .fire-btn, .pause-btn {
        height: 70px;
        font-size: 1.1rem;
    }
    
    /* Таблица лидеров на планшетах */
    .leaderboard-container {
        max-width: 90%;
        max-height: 65vh; /* Увеличиваем высоту для планшетов */
        min-height: 450px;
    }
}

/* Специальные стили для очень узких экранов */
@media (max-width: 350px) {
    .mobile-controls-content {
        flex-direction: column;
        gap: 10px;
    }
    
    .d-pad-section, .action-section {
        width: 100%;
        max-width: 100%;
    }
    
    .d-pad {
        width: 120px;
        height: 120px;
        margin: 0 auto;
    }
    
    .action-section {
        flex-direction: row;
    }
    
    .fire-btn, .pause-btn {
        flex: 1;
    }
    
    /* Таблица лидеров для очень узких экранов */
    #leaderboardTable th:nth-child(4),
    #leaderboardTable td:nth-child(4) {
        display: none;
    }
    
    #leaderboardTable th:nth-child(5),
    #leaderboardTable td:nth-child(5) {
        display: none;
    }
    
    #leaderboardTable td:first-child {
        width: 20%;
    }
    
    #leaderboardTable td:nth-child(2) {
        width: 50%;
    }
    
    #leaderboardTable td:nth-child(3) {
        width: 30%;
    }
    
    /* Увеличиваем контейнер для очень узких экранов */
    .leaderboard-container {
        max-height: 55vh;
        min-height: 250px;
    }
}

/* Специальные стили для очень высоких экранов */
@media (min-height: 900px) {
    .leaderboard-container {
        max-height: 75vh; /* Увеличиваем для очень высоких экранов */
    }
}