/* Основные стили */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
    overflow-x: hidden;
    touch-action: manipulation;
}

body {
    font-family: 'Roboto', 'Arial', sans-serif;
    line-height: 1.6;
    color: #333;
    margin: 0;
    padding: 10px;
    min-height: 100vh;
    max-height: 100vh;
    background-color: #f0f8ff;
    background-image: url('../images/back.avif');
    background-size: cover;
    background-attachment: fixed;
    background-position: center;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: pan-y;
}

.container {
    background-color: rgba(255, 255, 255, 0.9);
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

h1 {
    color: #2c3e50;
    text-align: center;
    margin-bottom: 20px;
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    position: relative;
    padding-bottom: 10px;
    word-break: break-word;
    line-height: 1.3;
}

h1::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: min(80px, 80%);
    height: 3px;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    border-radius: 2px;
}

/* Обновленные стили для меню */
.menu {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 15px;
    margin-top: 15px;
    position: relative;
    width: 100%;
    overflow-y: auto;
    flex: 1;
    padding-bottom: 15px;
}

.menu h2 {
    grid-column: 1 / -1;
    text-align: center;
    color: #2c3e50;
    font-size: clamp(1.4rem, 4vw, 1.8rem);
    margin-bottom: 10px;
    position: relative;
    word-break: break-word;
    line-height: 1.3;
}

.menu h2::before,
.menu h2::after {
    content: '✻';
    color: #3498db;
    margin: 0 10px;
    font-size: clamp(0.9rem, 2vw, 1.2rem);
}

/* Общий стиль для всех кнопок главного меню */
.region-btn,
.leaderboard-btn,
.other-games-btn,
.reference-btn {
    position: relative;
    padding: 15px 10px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: clamp(1rem, 3vw, 1.2rem);
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    overflow: hidden;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 70px;
    text-align: center;
    background-size: cover;
    background-position: center;
    word-break: break-word;
    line-height: 1.3;
    width: 100%;
    text-align: center;
    white-space: normal;
    line-height: 1.3;
}

.reference-btn {
    grid-column: 1 / -1;
    justify-self: center;
    width: min(100%, 1200px);
    margin-top: 5px;
    background-image: url('../images/backSprav.png');
    background-size: cover;
    background-position: center;
}

/* Затемнение фона */
.region-btn::before,
.leaderboard-btn::before,
.other-games-btn::before,
.reference-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: -1;
    transition: background 0.3s ease;
}

/* Эффекты при наведении */
.region-btn:hover::before,
.leaderboard-btn:hover::before,
.other-games-btn:hover::before,
.reference-btn:hover::before {
    background: rgba(0, 0, 0, 0.2);
}

.region-btn:hover,
.leaderboard-btn:hover,
.other-games-btn:hover,
.reference-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* Стиль для кнопки "Все страны" */
.region-btn[data-region="map"] {
    grid-column: 1 / -1;
    justify-self: center;
    width: min(100%, 1200px);
    margin-top: 5px;
}

/* Индивидуальные фоны для кнопок */
.region-btn[data-region="europe"] {
    background-image: url('../images/europe.png');
}

.region-btn[data-region="asia"] {
    background-image: url('../images/asia.png');
}

.region-btn[data-region="africa"] {
    background-image: url('../images/africa.png');
}

.region-btn[data-region="north-america"] {
    background-image: url('../images/north-america.png');
}

.region-btn[data-region="south-america"] {
    background-image: url('../images/south-america.png');
}

.region-btn[data-region="oceania"] {
    background-image: url('../images/oceania.jpg');
}

.region-btn[data-region="map"] {
    background-image: url('../images/map.png');
}

.leaderboard-btn {
    background-image: url('../images/lead.png');
}

.other-games-btn {
    background-image: url('../images/test.jpg');
}

.reference-btn {
    background-image: url('../images/backSprav.png');
}

/* Убедимся, что скрытые элементы действительно не видны */
.hidden {
    display: none !important;
}

/* Контейнер для двух кнопок в одной строке */
.double-buttons-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    width: min(100%, 1200px);
    margin-top: 5px;
    grid-column: 1 / -1;
}

/* === Стили для переключателя режимов (внутри .menu) === */

.menu .mode-switcher {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    /* Уменьшено с 20px */
    overflow-x: auto;
    padding: 0 10px;
    -webkit-overflow-scrolling: touch;
}

.menu .mode-switcher::-webkit-scrollbar {
    height: 6px;
}

.menu .mode-switcher::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.mode-btn {
    padding: 10px 20px;
    font-size: 1rem;
    border: 2px solid #4CAF50;
    background-color: white;
    color: #4CAF50;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
    text-align: center;
    white-space: nowrap;
    box-sizing: border-box;
    min-width: 130px;
    font-weight: 500;
    margin: 0;
    /* Убедитесь, что нет отступов */
}

.mode-btn:hover {
    background-color: #f0f0f0;
}

.mode-btn.active {
    background-color: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

@media (max-width: 600px) {
    .mode-btn {
        padding: 8px 12px;
        font-size: 14px;
        min-width: 110px;
    }

    .mode-switcher {
        gap: 8px;
        padding: 6px 8px;
    }
}

/* Адаптивность */
@media (max-width: 768px) {
    body {
        padding: 8px;
    }

    .container {
        padding: 12px;
        max-height: calc(100vh - 16px);
    }

    .menu {
        grid-template-columns: 1fr;
        gap: 8px;
        margin-top: 15px;
        padding-bottom: 25vh;
    }

    .region-btn,
    .leaderboard-btn,
    .other-games-btn,
    .reference-btn {
        min-height: 50px;
        padding: 10px 8px;
        font-size: 0.95rem;
    }

    .menu h2 {
        margin-bottom: 8px;
    }

    .double-buttons-container {
        grid-template-columns: 1fr;
    }

    .other-games-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
    }

    .container {
        padding: 10px;
        max-height: calc(100vh - 10px);
    }

    .menu {
        gap: 6px;
        padding-bottom: 20vh;
    }

    .menu h2::before,
    .menu h2::after {
        margin: 0 3px;
    }

    .region-btn,
    .leaderboard-btn,
    .other-games-btn,
    .reference-btn {
        min-height: 45px;
        font-size: 0.9rem;
        padding: 8px 6px;
    }

    h1 {
        font-size: 1.5rem;
        margin-bottom: 12px;
    }
}

@media (max-height: 700px) and (orientation: landscape) {
    body {
        padding: 5px;
    }

    .container {
        padding: 8px;
    }

    .menu {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        padding-bottom: 15vh;
    }

    .region-btn,
    .leaderboard-btn,
    .other-games-btn,
    .reference-btn {
        min-height: 40px;
        padding: 6px 4px;
        font-size: 0.85rem;
    }

    h1 {
        font-size: 1.3rem;
        margin-bottom: 8px;
    }
}

/* Запрет масштабирования на мобильных устройствах */
@viewport {
    width: device-width;
    zoom: 1;
    min-zoom: 1;
    max-zoom: 1;
    user-zoom: fixed;
}

/* Для Safari и других браузеров */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 9999;
}

.loading-spinner {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.hidden {
    display: none !important;
}

.best-score {
    margin-top: 15px;
    padding: 10px;
    background-color: #f8f8f8;
    border-radius: 5px;
    font-weight: bold;
    text-align: center;
}