body {
    background-color: #222;
    color: #fff;
    font-family: sans-serif;
    text-align: center;
    margin: 0;
    padding: 10px;
    padding-bottom: 80px;
    overflow: hidden;
    height: 100vh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* ========== ГЛАВНОЕ МЕНЮ ========== */
.main-menu {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: 20px;
}

.menu-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    position: relative;
}

.game-title {
    font-size: 42px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #ffd93d, #ff6b6b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
}

.language-switcher {
    display: flex;
    gap: 8px;
    margin: 10px 0 15px 0;
    background: #2a2a2a;
    padding: 4px;
    border-radius: 20px;
    border: 1px solid #444;
}

.lang-btn {
    padding: 6px 16px;
    border: none;
    border-radius: 16px;
    background: transparent;
    color: #888;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.lang-btn:hover {
    color: #fff;
}

.lang-btn.active {
    background: #444;
    color: #ffd93d;
    box-shadow: 0 2px 8px rgba(255, 217, 61, 0.2);
}

.lang-btn.active:hover {
    background: #555;
}

.game-subtitle {
    font-size: 18px;
    color: #aaa;
    margin-bottom: 40px;
    -webkit-text-fill-color: #aaa;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 300px;
}

.menu-btn {
    padding: 16px 24px;
    font-size: 20px;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    text-align: center;
}

.menu-btn.primary {
    background: linear-gradient(135deg, #2e7d32, #4caf50);
    color: #fff;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.menu-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(76, 175, 80, 0.5);
}

.menu-btn.secondary {
    background: #333;
    color: #fff;
    border: 2px solid #555;
}

.menu-btn.secondary:hover {
    background: #444;
    border-color: #ffd93d;
    transform: translateY(-2px);
}

.menu-footer {
    margin-top: 40px;
    color: #555;
    font-size: 14px;
}

/* ========== ИГРОВОЙ ЭКРАН ========== */
#gameScreen {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: center;
}

#gameScreen.active {
    display: flex;
}

h1 {
    margin-bottom: 4px;
    font-size: 24px;
    margin-top: 2px;
}

.game-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    font-size: 18px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.game-stats span {
    background: #2a2a2a;
    padding: 4px 14px;
    border-radius: 20px;
    border: 1px solid #444;
}

.lives span {
    color: #ff4757;
    font-weight: bold;
    letter-spacing: 2px;
}

.timer span {
    color: #ffd93d;
    font-weight: bold;
}

.game-container {
    position: relative;
    display: inline-block;
    margin-top: 2px;
    max-height: calc(100vh - 170px);
}

canvas {
    background-color: #0f5132;
    border: 4px solid #333;
    border-radius: 8px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    display: block;
    max-height: calc(100vh - 180px);
    touch-action: none;
}

.overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    border-radius: 8px;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.modal {
    background-color: #2c2c2c;
    border: 3px solid #444;
    border-radius: 10px;
    padding: 25px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.8);
    max-width: 320px;
    width: 85%;
}

.modal h2 {
    margin-top: 0;
    font-size: 22px;
    margin-bottom: 12px;
    line-height: 1.4;
}

.modal p {
    margin: 8px 0 16px 0;
    font-size: 16px;
    color: #ccc;
    white-space: pre-line;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-buttons button {
    width: 100%;
    background-color: #444;
    color: #fff;
    border: 2px solid #666;
    padding: 12px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.modal-buttons button:hover {
    background-color: #555;
    border-color: #ffeb3b;
}

.modal-buttons button#btnNextLevel {
    background-color: #2e7d32;
    border-color: #4caf50;
}

.modal-buttons button#btnNextLevel:hover {
    background-color: #388e3c;
    border-color: #81c784;
}

.modal-buttons button#btnRestartFromZero {
    background-color: #c0392b;
    border-color: #e74c3c;
}

.modal-buttons button#btnRestartFromZero:hover {
    background-color: #e74c3c;
    border-color: #ff6b6b;
}

.modal-buttons button#btnPlayAgain {
    background-color: #2980b9;
    border-color: #3498db;
}

.modal-buttons button#btnPlayAgain:hover {
    background-color: #3498db;
    border-color: #5dade2;
}

.controls {
    position: fixed;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 0;
}

.controls.disabled {
    opacity: 0.3;
    pointer-events: none;
}

.icon-btn {
    background-color: #333;
    color: #fff;
    border: 2px solid #555;
    width: 50px;
    height: 50px;
    font-size: 22px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    touch-action: manipulation;
    font-weight: bold;
}

.icon-btn:hover {
    background-color: #444;
    border-color: #ffeb3b;
    transform: translateY(-2px);
}

.icon-btn:active {
    transform: translateY(1px);
}

.icon-btn#btnMenu {
    background-color: #1a237e;
    border-color: #3f51b5;
}

.icon-btn#btnMenu:hover {
    background-color: #283593;
    border-color: #5c6bc0;
}



/* ========== МОДАЛЬНОЕ ОКНО ТАБЛИЦЫ ЛИДЕРОВ ========== */
.modal-overlay {
    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: 1000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: #2c2c2c;
    border-radius: 12px;
    border: 2px solid #444;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 2px solid #444;
    background: #1a1a1a;
    border-radius: 12px 12px 0 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: #ffd93d;
}

.modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    padding: 0 8px;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #fff;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.leaderboard-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.tab-btn {
    background: #333;
    color: #888;
    border: 1px solid #444;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: #444;
    color: #fff;
}

.tab-btn.active {
    background: #2e7d32;
    color: #fff;
    border-color: #4caf50;
}

.tab-btn.active:hover {
    background: #388e3c;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    margin-bottom: 6px;
    background: #222;
    border-radius: 8px;
    border: 1px solid #333;
    transition: background 0.2s;
}

.leaderboard-item:hover {
    background: #2a2a2a;
}

.leaderboard-item.user {
    border-color: #ffd93d;
    background: #2a2a2a;
}

.leaderboard-rank {
    font-weight: bold;
    font-size: 16px;
    width: 40px;
    color: #888;
}

.leaderboard-rank.gold {
    color: #ffd700;
}

.leaderboard-rank.silver {
    color: #c0c0c0;
}

.leaderboard-rank.bronze {
    color: #cd7f32;
}

.leaderboard-name {
    flex: 1;
    font-size: 15px;
    color: #fff;
}

.leaderboard-name .me {
    color: #ffd93d;
    font-size: 12px;
    margin-left: 8px;
}

.leaderboard-time {
    font-size: 15px;
    color: #ffd93d;
    font-weight: bold;
    font-family: monospace;
}

.leaderboard-empty {
    text-align: center;
    color: #666;
    padding: 30px;
    font-size: 16px;
}

.loading {
    text-align: center;
    color: #888;
    padding: 20px;
}


/* ========== ИНДИКАТОР РЕЖИМА ========== */
.mode-indicator {
    position: fixed;
    top: 4px;
    left: 4px;
    color: #555;
    font-size: 10px;
    font-family: monospace;
    z-index: 100;
    pointer-events: none;
    user-select: none;
    opacity: 0.7;
    transition: all 0.3s ease;
}

.mode-indicator.local {
    color: #ffd93d;
    opacity: 0.9;
}

.mode-indicator.yandex {
    color: #ffcc00;
    opacity: 0.9;
}

.mode-indicator.vk {
    color: #4caf50;
    opacity: 0.9;
}