/* =========================================================================
   СВОБОДНО ЛИЦЕНЗИРУЕМЫЕ ШРИФТЫ: GOOGLE SANS FLEX (100..1000) + GOOGLE SANS
   1. Google Sans Flex — вариативный шрифт для латиницы и цифр с весом до 1000.
   2. Google Sans — геометрический гротеск с поддержкой кириллицы.
   ========================================================================= */
@font-face {
    font-family: 'Google Sans Flex';
    src: url('fonts/google_sans_flex_latin.woff2') format('woff2');
    font-weight: 100 1000;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Google Sans';
    src: url('fonts/google_sans_cyrillic.woff2') format('woff2');
    font-weight: 700 1000;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
    font-family: 'Google Sans';
    src: url('fonts/google_sans_latin.woff2') format('woff2');
    font-weight: 700 1000;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Google Sans Flex', 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 700;
    background-color: #EAD2B8;
    color: #ffffff;
    touch-action: none;
}

button {
    font-family: inherit;
    font-weight: 700;
    border: none;
    background: none;
    cursor: pointer;
    outline: none;
}

.hidden {
    display: none !important;
}

/* ЖИВОЙ АНИМИРОВАННЫЙ ФОН И СЛОЙ 3D ЧАСТИЦ */
#bg-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

#fx-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 30;
    pointer-events: none;
}

/* ЭКРАНЫ С УЧЁТОМ ВЫРЕЗА КАМЕРЫ И НИЖНЕЙ ПОЛОСЫ НАВИГАЦИИ ANDROID */
.screen {
    position: fixed;
    inset: 0;
    z-index: 2;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding-top: max(12px, var(--safe-top));
    padding-bottom: max(14px, var(--safe-bottom));
    padding-left: max(12px, var(--safe-left));
    padding-right: max(12px, var(--safe-right));
}

/* На игровом экране убираем внутренние отступы-обрезания: поле занимает весь экран целиком! */
#game-screen {
    padding: 0;
    overflow: visible;
}

.screen.active {
    display: flex;
    animation: screenEnter 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes screenEnter {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

/* =========================================================================
   ГЛАВНОЕ МЕНЮ (АДАПТИВНЫЙ ТЕКСТОВЫЙ 3D-ЛОГОТИП C ЖИРНОСТЬЮ 1000)
   ========================================================================= */
.menu-top-bar {
    width: 100%;
    max-width: 100%;
    display: flex;
    justify-content: flex-end;
    padding: 4px 6px 0;
    flex-shrink: 0;
}

.menu-container {
    width: 100%;
    max-width: 440px;
    flex: 1;
    padding: 6px clamp(6px, 2.5vw, 12px) 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-evenly;
    gap: clamp(8px, 1.8vh, 14px);
    overflow-y: auto;
}

.logo-card {
    max-width: 100%;
    background: linear-gradient(180deg, #FFFFFF 0%, #F7F2EC 100%);
    border-radius: 42px;
    padding: clamp(11px, 2.2vh, 15px) clamp(22px, 6.5vw, 42px) clamp(12px, 2.4vh, 17px);
    border: 2.5px solid #FFFFFF;
    box-shadow:
        0 8px 0 #D8C7B6,
        0 18px 32px rgba(93, 68, 48, 0.16),
        inset 0 2px 0 #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Надпись "Сапёр" / "Minesweeper" с жирностью 1000 и плавным масштабированием под ширину экрана */
.logo-text {
    font-size: clamp(32px, 9.5vw, 46px);
    font-weight: 1000;
    font-variation-settings: 'wght' 1000, 'GRAD' 150;
    -webkit-text-stroke: 1.3px #6488E5;
    line-height: 1.05;
    letter-spacing: -0.5px;
    color: #6B8EEB;
    white-space: nowrap;
    text-shadow:
        0 3px 0 rgba(87, 115, 194, 0.24),
        0 6px 14px rgba(87, 115, 194, 0.15);
}

/* Для длинного английского заголовка "Minesweeper" (11 букв) адаптируем размер на узких экранах */
body.lang-en .logo-text {
    font-size: clamp(24px, 7.4vw, 40px);
    -webkit-text-stroke: 1.1px #6488E5;
}

.glass-card {
    width: 100%;
    background: rgba(255, 255, 255, 0.56);
    border: 3px solid rgba(255, 255, 255, 0.82);
    border-radius: clamp(28px, 6vw, 36px);
    padding: clamp(14px, 2.8vh, 20px) clamp(14px, 4vw, 18px);
    box-shadow:
        0 9px 0 rgba(164, 134, 108, 0.25),
        0 20px 38px rgba(85, 62, 43, 0.14),
        inset 0 2px 0 rgba(255, 255, 255, 0.85);
}

.menu-title {
    font-size: clamp(20px, 5.6vw, 25px);
    color: #5C4435;
    margin: 0 0 clamp(10px, 2vh, 14px) 8px;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.diff-buttons {
    display: flex;
    flex-direction: column;
    gap: clamp(9px, 1.8vh, 12px);
}

.diff-btn {
    position: relative;
    width: 100%;
    height: clamp(50px, 7.4vh, 58px);
    background: linear-gradient(180deg, #8DA9F4 0%, #7491E2 100%);
    border: 2px solid rgba(255, 255, 255, 0.92);
    border-radius: 24px;
    padding: 0 clamp(14px, 4vw, 20px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: #ffffff;
    box-shadow:
        0 6px 0 #5773C2,
        0 10px 18px rgba(74, 102, 176, 0.24),
        inset 0 2px 0 rgba(255, 255, 255, 0.45);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.diff-btn:hover {
    transform: translateY(-2px);
    box-shadow:
        0 8px 0 #5773C2,
        0 14px 22px rgba(74, 102, 176, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.55);
}

.diff-btn:active {
    transform: translateY(4px);
    box-shadow:
        0 2px 0 #5773C2,
        0 4px 8px rgba(74, 102, 176, 0.2);
}

.diff-name {
    font-size: clamp(18px, 4.8vw, 22px);
    text-shadow: 0 2px 4px rgba(45, 68, 128, 0.25);
    white-space: nowrap;
}

.diff-meta {
    font-size: clamp(11px, 3.2vw, 13px);
    background: rgba(255, 255, 255, 0.24);
    padding: 5px clamp(8px, 2.5vw, 12px);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    white-space: nowrap;
    flex-shrink: 0;
}

/* РУЧНОЙ РЕЖИМ (КАСТОМНЫЙ) */
.custom-card {
    width: 100%;
    background: linear-gradient(180deg, #F6ECE2 0%, #EADAC9 100%);
    border: 3px solid #FFFFFF;
    border-radius: clamp(26px, 6vw, 34px);
    padding: clamp(14px, 2.8vh, 20px);
    box-shadow:
        0 10px 0 #CBB5A0,
        0 20px 38px rgba(80, 56, 38, 0.22),
        inset 0 2px 0 #FFFFFF;
    color: #5C4435;
}

.custom-title {
    font-size: clamp(20px, 5.6vw, 25px);
    text-align: center;
    color: #5C4435;
    margin-bottom: clamp(12px, 2vh, 16px);
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: clamp(8px, 1.6vh, 12px);
}

.setting-label {
    font-size: clamp(17px, 4.6vw, 20px);
    color: #5C4435;
}

.setting-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-value {
    width: clamp(68px, 18vw, 80px);
    height: clamp(44px, 6.8vh, 50px);
    background: #FFFFFF;
    border: 2px solid #D9C6B5;
    border-radius: 15px;
    box-shadow: inset 0 3px 6px rgba(130, 102, 78, 0.12), 0 2px 0 #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(19px, 5vw, 22px);
    font-weight: 1000;
    font-variation-settings: 'wght' 1000;
    color: #463429;
}

.setting-steppers {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.step-btn {
    width: 36px;
    height: 26px;
    background: linear-gradient(180deg, #FFFFFF 0%, #F4EAE0 100%);
    border: 1.5px solid #D5C0AE;
    border-radius: 9px;
    box-shadow: 0 3px 0 #C4AD99;
    font-size: 18px;
    color: #5C4435;
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #C4AD99;
}

.custom-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: clamp(14px, 2.4vh, 20px);
}

.close-custom-btn {
    width: clamp(50px, 7.4vh, 58px);
    height: clamp(50px, 7.4vh, 58px);
    background: linear-gradient(180deg, #FFFFFF 0%, #F4EAE0 100%);
    border: 2px solid #D5C0AE;
    border-radius: 20px;
    box-shadow: 0 6px 0 #C4AD99, 0 10px 20px rgba(92, 68, 53, 0.15);
    font-size: 22px;
    color: #5C4435;
    flex-shrink: 0;
}

.close-custom-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #C4AD99;
}

.play-custom-btn {
    flex: 1;
    height: clamp(50px, 7.4vh, 58px);
    background: linear-gradient(180deg, #8DA9F4 0%, #7491E2 100%);
    border: 2px solid #FFFFFF;
    border-radius: 20px;
    box-shadow: 0 6px 0 #5773C2, 0 12px 24px rgba(87, 115, 194, 0.32);
    font-size: clamp(19px, 5vw, 22px);
    color: #ffffff;
}

.play-custom-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #5773C2;
}

/* =========================================================================
   ПАРЯЩАЯ ВЕРХНЯЯ ПАНЕЛЬ В ИГРЕ (НЕ ОБРЕЗАЕТ ПОЛЕ ПРИ УВЕЛИЧЕНИИ!)
   ========================================================================= */
.control-panel {
    position: fixed;
    top: max(12px, var(--safe-top));
    left: max(12px, var(--safe-left));
    right: max(12px, var(--safe-right));
    max-width: 100%;
    padding: 4px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    z-index: 20;
    pointer-events: none;
}

.control-panel > * {
    pointer-events: auto;
}

.control-panel > :first-child {
    justify-self: start;
}

.control-panel > .top-actions {
    justify-self: center;
}

.control-panel > :last-child {
    justify-self: end;
}

.stat-pill {
    min-width: clamp(78px, 22vw, 94px);
    height: clamp(44px, 6.5vh, 48px);
    padding: 0 clamp(11px, 3vw, 15px);
    background: linear-gradient(180deg, #FFFFFF 0%, #F5EFEA 100%);
    border: 2px solid #FFFFFF;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #46382E;
    font-size: clamp(17px, 4.5vw, 20px);
    font-weight: 1000;
    font-variation-settings: 'wght' 1000;
    font-variant-numeric: tabular-nums;
    box-shadow:
        0 5px 0 #D5C5B5,
        0 10px 18px rgba(70, 52, 38, 0.16),
        inset 0 2px 0 #FFFFFF;
}

.flag-header-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: clamp(8px, 2.2vw, 10px);
}

.icon-btn {
    position: relative;
    width: clamp(44px, 6.5vh, 48px);
    height: clamp(44px, 6.5vh, 48px);
    background: linear-gradient(180deg, #7DA3D1 0%, #6389B8 100%);
    border: 2px solid rgba(255, 255, 255, 0.88);
    color: #ffffff;
    border-radius: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 5px 0 #4B6E99,
        0 10px 16px rgba(55, 82, 118, 0.22),
        inset 0 2px 0 rgba(255, 255, 255, 0.4);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.icon-btn:active {
    transform: translateY(4px);
    box-shadow: 0 1px 0 #4B6E99;
}

.icon-svg {
    width: 22px;
    height: 22px;
    transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* =========================================================================
   ПОЛНОЭКРАННОЕ ИГРОВОЕ ПОЛЕ (БЕЗ РАМОК ОБРЕЗКИ ПРИ ЗУМЕ И ПЕРЕМЕЩЕНИИ)
   ========================================================================= */
.board-viewport {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    z-index: 5;
}

.board-viewport.dragging {
    cursor: grabbing;
}

.board-transform {
    transform-origin: center center;
    will-change: transform;
    display: flex;
    align-items: center;
    justify-content: center;
}

.island-3d {
    position: relative;
}

/* 3D-платформа острова */
.island-deck {
    position: relative;
    padding: 15px;
    border-radius: 28px;
    background: linear-gradient(180deg, #F2E8DD 0%, #E2D4C4 100%);
    border: 3px solid #FAF5F0;
    box-shadow:
        inset 0 2px 0 #FFFFFF,
        inset 0 -3px 6px rgba(135, 110, 88, 0.2),
        0 5px 0 #D8C6B4,
        0 10px 0 #CBB7A2,
        0 15px 0 #BFA993,
        0 19px 0 #F390C8,
        0 25px 0 #9E8A78,
        0 34px 48px rgba(68, 48, 34, 0.34);
}

.island-neon-strip {
    position: absolute;
    bottom: -17px;
    left: 50%;
    transform: translateX(-50%);
    width: 40%;
    max-width: 160px;
    height: 7px;
    border-radius: 6px;
    background: linear-gradient(90deg, #FF85B3 0%, #B388FF 50%, #7CE0FF 100%);
    pointer-events: none;
    opacity: 0.95;
}

.minefield-grid {
    display: grid;
    gap: 5px;
    padding: 8px;
    border-radius: 20px;
    background: #D5C5B5;
    box-shadow:
        inset 0 4px 8px rgba(92, 71, 53, 0.24),
        0 1px 0 rgba(255, 255, 255, 0.7);
}

/* =========================================================================
   3D-ЯЧЕЙКИ ПОЛЯ (ОПТИМИЗИРОВАНЫ БЕЗ ДОРОГИХ ФИЛЬТРОВ + ЖИРНОСТЬ ЦИФР 1000)
   ========================================================================= */
.cell {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    font-weight: 1000;
    font-variation-settings: 'wght' 1000, 'GRAD' 120;
    cursor: pointer;
    contain: layout style paint;
}

/* Закрытая 3D-плитка */
.cell.unrevealed {
    background-image: url('img/block.png');
    background-size: cover;
    background-position: center;
    transform: translateY(-3px);
    box-shadow:
        0 4.5px 0 #C0A387,
        0 6px 7px rgba(78, 56, 38, 0.22),
        inset 0 2px 0 rgba(255, 255, 255, 0.78),
        inset 0 -2px 0 rgba(158, 125, 96, 0.25);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

@media (hover: hover) and (pointer: fine) {
    .cell.unrevealed:hover {
        transform: translateY(-4.5px) scale(1.03);
        z-index: 3;
    }
    .cell.revealed.has-number:hover {
        background: #FAF7F2;
    }
}

.cell.pressing {
    transform: translateY(1px) scale(0.95) !important;
    box-shadow:
        0 1px 0 #C0A387,
        inset 0 2px 3px rgba(0, 0, 0, 0.1) !important;
}

/* Открытая ячейка: GPU-ускоренная анимация только через transform и opacity */
.cell.revealed {
    background: #F4EFEA;
    transform: translateY(0px);
    box-shadow:
        inset 0 2px 4px rgba(110, 90, 72, 0.16),
        0 1px 0 rgba(255, 255, 255, 0.65);
    cursor: default;
    animation: cellRevealPop 0.18s cubic-bezier(0.25, 1, 0.5, 1);
}

.cell.revealed.revealed-fast {
    animation: none;
}

.cell.revealed.has-number {
    cursor: pointer;
    background: #F8F4F0;
}

.cell.revealed.empty {
    background: #E8DDD1;
    box-shadow: inset 0 2px 3px rgba(115, 94, 75, 0.12);
}

.cell.revealed.mine {
    background: #F2E4DC;
}

.cell.revealed.mine-exploded {
    background: linear-gradient(135deg, #E8837E 0%, #D96B66 100%) !important;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.4) !important;
    animation: explodeBounce 0.4s ease;
    z-index: 4;
}

.cell.wrong-flag::after,
.cell.wrong-flag::before {
    content: '';
    position: absolute;
    width: 76%;
    height: 3px;
    background: #D46A6A;
    border-radius: 2px;
    z-index: 3;
}
.cell.wrong-flag::after { transform: rotate(45deg); }
.cell.wrong-flag::before { transform: rotate(-45deg); }

.cell.hint-flash {
    outline: 3px solid #6389B8;
    outline-offset: 2px;
}

@keyframes cellRevealPop {
    0% { transform: scale(0.84); opacity: 0.65; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes explodeBounce {
    0% { transform: scale(0.85); }
    40% { transform: scale(1.16); }
    100% { transform: scale(1); }
}

.cell-svg {
    width: 23px;
    height: 23px;
    pointer-events: none;
}

.flag-anim {
    animation: flagPlant3D 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: bottom center;
}

@keyframes flagPlant3D {
    0% { transform: translateY(-12px) scale(0.4); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* СПОКОЙНАЯ ПРИРОДНАЯ ПАЛИТРА ЦИФР С ЖИРНОСТЬЮ 1000 */
.num-1 { color: #547EA8; -webkit-text-stroke: 0.5px #547EA8; text-shadow: 0 1px 0 #FFFFFF; }
.num-2 { color: #52876E; -webkit-text-stroke: 0.5px #52876E; text-shadow: 0 1px 0 #FFFFFF; }
.num-3 { color: #B36453; -webkit-text-stroke: 0.5px #B36453; text-shadow: 0 1px 0 #FFFFFF; }
.num-4 { color: #736894; -webkit-text-stroke: 0.5px #736894; text-shadow: 0 1px 0 #FFFFFF; }
.num-5 { color: #966441; -webkit-text-stroke: 0.5px #966441; text-shadow: 0 1px 0 #FFFFFF; }
.num-6 { color: #47838E; -webkit-text-stroke: 0.5px #47838E; text-shadow: 0 1px 0 #FFFFFF; }
.num-7 { color: #544B46; -webkit-text-stroke: 0.5px #544B46; text-shadow: 0 1px 0 #FFFFFF; }
.num-8 { color: #736860; -webkit-text-stroke: 0.5px #736860; text-shadow: 0 1px 0 #FFFFFF; }

/* =========================================================================
   ПАРЯЩАЯ НИЖНЯЯ ПАНЕЛЬ (ДОК: [⚙️ НАСТРОЙКИ]  [ФЛАГ | ЛОПАТА]  [💡 ПОДСКАЗКА])
   ========================================================================= */
.bottom-bar {
    position: fixed;
    bottom: max(14px, var(--safe-bottom));
    left: max(12px, var(--safe-left));
    right: max(12px, var(--safe-right));
    max-width: 100%;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 15;
    pointer-events: none;
}

.bottom-bar > * {
    pointer-events: auto;
}

.bottom-center-dock {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(10px, 3vw, 14px);
    justify-self: center;
}

.dock-action-btn {
    position: relative;
    width: 56px;
    height: 56px;
    background: linear-gradient(180deg, #FFFFFF 0%, #F5EFEA 100%);
    border: 2px solid #FFFFFF;
    color: #5C4435;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 6px 0 #D5C5B5,
        0 12px 22px rgba(70, 52, 38, 0.18),
        inset 0 2px 0 #FFFFFF;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.dock-action-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #D5C5B5;
}

.badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    background: linear-gradient(180deg, #FF8E72 0%, #E86A4D 100%);
    color: #ffffff;
    font-size: 12px;
    font-weight: 1000;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Переключатель режима с ИДЕАЛЬНО КВАДРАТНЫМИ селекторами .mode-option (52x52px) */
.mode-switcher {
    position: relative;
    width: 120px;
    height: 68px;
    background: linear-gradient(180deg, #FFFFFF 0%, #F5EFEA 100%);
    border: 2px solid #FFFFFF;
    border-radius: 22px;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow:
        0 6px 0 #D5C5B5,
        0 14px 26px rgba(70, 52, 38, 0.2),
        inset 0 2px 0 #FFFFFF;
}

.mode-track {
    position: absolute;
    inset: 5px;
    background: #E9E1D8;
    border-radius: 16px;
    box-shadow: inset 0 2px 4px rgba(105, 85, 65, 0.15);
    pointer-events: none;
}

.mode-thumb {
    position: absolute;
    top: 6px;
    left: 5px;
    width: 52px;
    height: 52px;
    background: linear-gradient(180deg, #7DA3D1 0%, #6389B8 100%);
    border-radius: 15px;
    box-shadow:
        0 3px 0 #4B6E99,
        0 5px 10px rgba(75, 110, 153, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.45);
    transition: transform 0.26s cubic-bezier(0.34, 1.45, 0.64, 1);
    pointer-events: none;
}

.mode-thumb.shovel-active {
    transform: translateX(54px);
}

/* Квадратный селектор 52x52px */
.mode-option {
    position: relative;
    z-index: 2;
    width: 52px;
    height: 52px;
    aspect-ratio: 1 / 1;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #879FB8;
    transition: color 0.2s ease, transform 0.15s ease;
}

.mode-option.active {
    color: #ffffff;
    transform: scale(1.04);
}

.mode-icon {
    width: 24px;
    height: 24px;
}

/* Парящая нижняя панель при осмотре поля после игры ("Начать с начала") */
.inspect-bar {
    position: fixed;
    bottom: max(16px, var(--safe-bottom));
    left: max(16px, var(--safe-left));
    right: max(16px, var(--safe-right));
    max-width: 400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15;
    pointer-events: none;
}

.inspect-restart-btn {
    pointer-events: auto;
    width: 100%;
    height: clamp(52px, 7.5vh, 58px);
    background: linear-gradient(180deg, #8DA9F4 0%, #7491E2 100%);
    border: 2.5px solid #FFFFFF;
    border-radius: 24px;
    color: #FFFFFF;
    font-size: clamp(18px, 4.8vw, 21px);
    box-shadow:
        0 6px 0 #5773C2,
        0 14px 26px rgba(74, 102, 176, 0.34),
        inset 0 2px 0 rgba(255, 255, 255, 0.45);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.inspect-restart-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #5773C2;
}

/* Элементы для ПК: трёхколоночная сетка 1fr auto 1fr гарантирует, что .bottom-center-dock всегда строго по центру экрана */
.pc-only {
    display: none;
}

@media (min-width: 760px) {
    .pc-only {
        display: flex;
    }
    .bottom-bar {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
    }
    .zoom-controls {
        justify-self: start;
    }
    .bottom-center-dock {
        justify-self: center;
    }
    .pc-hint {
        justify-self: end;
    }
}

.zoom-controls {
    align-items: center;
    background: linear-gradient(180deg, #FFFFFF 0%, #F5EFEA 100%);
    border: 2px solid #FFFFFF;
    border-radius: 20px;
    padding: 4px;
    gap: 4px;
    box-shadow: 0 5px 0 #D5C5B5, 0 10px 20px rgba(70, 52, 38, 0.14);
}

.zoom-btn {
    min-width: 38px;
    height: 38px;
    padding: 0 8px;
    border-radius: 13px;
    color: #5C4435;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-btn:hover {
    background: rgba(125, 163, 209, 0.18);
}

.zoom-label {
    font-size: 15px;
    min-width: 58px;
}

.pc-hint {
    flex-direction: column;
    gap: 3px;
    font-size: 13px;
    color: #5C4435;
    background: rgba(255, 255, 255, 0.78);
    border: 1.5px solid rgba(255, 255, 255, 0.92);
    padding: 8px 14px;
    border-radius: 16px;
}

/* =========================================================================
   МОДАЛЬНОЕ ОКНО НАСТРОЕК (ЗВУК, ВИБРАЦИЯ, ЯЗЫК)
   ========================================================================= */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(45, 32, 22, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeInModal 0.18s ease;
}

@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

.settings-dialog {
    width: 100%;
    max-width: 390px;
    background: linear-gradient(180deg, #FBF6F0 0%, #EFE3D6 100%);
    border: 3px solid #FFFFFF;
    border-radius: clamp(26px, 6vw, 34px);
    padding: clamp(18px, 4vw, 22px) clamp(16px, 4vw, 20px) clamp(20px, 4.5vw, 24px);
    box-shadow:
        0 10px 0 #CBB5A0,
        0 24px 48px rgba(45, 30, 18, 0.3),
        inset 0 2px 0 #FFFFFF;
    color: #4A372B;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 0 4px;
}

.settings-title {
    font-size: clamp(21px, 5.6vw, 25px);
    color: #4A372B;
}

.settings-close-btn {
    width: 42px;
    height: 42px;
    border-radius: 15px;
    background: #FFFFFF;
    border: 1.5px solid #D9C6B5;
    box-shadow: 0 4px 0 #C9B4A1;
    color: #5C4435;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.settings-close-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #C9B4A1;
}

.settings-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.settings-item {
    background: rgba(255, 255, 255, 0.78);
    border: 1.5px solid #FFFFFF;
    border-radius: 22px;
    padding: 12px clamp(12px, 3.5vw, 16px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.settings-item-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: clamp(15px, 4.2vw, 18px);
    color: #4A372B;
}

.settings-emoji {
    font-size: 19px;
    flex-shrink: 0;
}

.pill-switch {
    position: relative;
    width: 58px;
    height: 34px;
    border-radius: 18px;
    background: #D7C8B9;
    box-shadow: inset 0 2px 5px rgba(80, 60, 42, 0.22);
    padding: 3px;
    transition: background-color 0.22s ease;
    flex-shrink: 0;
}

.pill-switch.active {
    background: #6EA1D4;
}

.pill-switch-knob {
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 14px;
    background: #FFFFFF;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.22);
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pill-switch.active .pill-switch-knob {
    transform: translateX(24px);
}

.lang-segmented {
    display: flex;
    background: #E5D8CA;
    padding: 3px;
    border-radius: 15px;
    gap: 4px;
    flex-shrink: 0;
}

.lang-btn {
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 14px;
    color: #6E5849;
}

.lang-btn.active {
    background: #FFFFFF;
    color: #4A372B;
    box-shadow: 0 2px 6px rgba(70, 52, 38, 0.16);
}

/* =========================================================================
   ОВЕРЛЕЙ ПОБЕДЫ / ПОРАЖЕНИЯ (БЕЗ ВЕРХНЕЙ ПАНЕЛИ, СО СТРЕЛКОЙ ВОЗВРАТА НА ПОЛЕ)
   ========================================================================= */
.result-overlay {
    position: fixed;
    inset: 0;
    z-index: 25;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding-top: max(16px, var(--safe-top));
    padding-bottom: max(24px, var(--safe-bottom));
    padding-left: max(16px, var(--safe-left));
    padding-right: max(16px, var(--safe-right));
    animation: fadeInOverlay 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes fadeInOverlay {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.result-top-bar {
    width: 100%;
    max-width: 100%;
    display: flex;
    justify-content: flex-end;
    padding-top: 4px;
}

/* Кнопка-стрелочка возврата на поле в правом верхнем углу */
.inspect-arrow-btn {
    width: 52px;
    height: 52px;
    background: linear-gradient(180deg, #FFFFFF 0%, #F2ECE6 100%);
    color: #46382E;
    border: 2px solid #FFFFFF;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 5px 0 #C9B9AA,
        0 12px 24px rgba(0, 0, 0, 0.16);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.inspect-arrow-btn:active {
    transform: translateY(4px);
    box-shadow: 0 1px 0 #C9B9AA;
}

.result-content {
    width: 100%;
    max-width: 420px;
    margin: auto 0;
    background: rgba(255, 255, 255, 0.26);
    border: 3px solid rgba(255, 255, 255, 0.68);
    border-radius: clamp(26px, 6vw, 34px);
    padding: clamp(20px, 4vw, 26px) clamp(18px, 4vw, 22px);
    box-shadow: 0 20px 46px rgba(0, 0, 0, 0.18), inset 0 2px 0 rgba(255, 255, 255, 0.6);
    display: flex;
    flex-direction: column;
    gap: clamp(18px, 3vh, 24px);
}

.result-headings {
    padding-left: 4px;
}

.result-subtitle {
    font-size: clamp(17px, 4.5vw, 20px);
    color: #ffffff;
    opacity: 0.95;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.result-title {
    font-size: clamp(26px, 7.2vw, 33px);
    color: #ffffff;
    margin-top: 4px;
    text-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.result-stats {
    margin-top: 10px;
    font-size: clamp(14px, 3.8vw, 16px);
    color: rgba(255, 255, 255, 0.95);
    background: rgba(0, 0, 0, 0.15);
    display: inline-block;
    padding: 6px 14px;
    border-radius: 14px;
}

.result-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-btn {
    width: 100%;
    height: clamp(50px, 7.4vh, 58px);
    border-radius: 20px;
    font-size: clamp(17px, 4.6vw, 20px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.result-btn:hover {
    transform: translateY(-2px);
}

.result-btn:active {
    transform: translateY(4px);
}

.primary-result-btn {
    background: linear-gradient(180deg, #FFFFFF 0%, #F4EFEA 100%);
    color: #3E3229;
    border: 2px solid #FFFFFF;
    box-shadow: 0 6px 0 #CFC2B6, 0 12px 24px rgba(0, 0, 0, 0.16);
}

.primary-result-btn:active {
    box-shadow: 0 2px 0 #CFC2B6;
}

.outline-result-btn {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    border: 2.5px solid #ffffff;
    box-shadow: 0 5px 0 rgba(255, 255, 255, 0.35);
}

.outline-result-btn:active {
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.revive-btn {
    background: linear-gradient(180deg, #FFE082 0%, #FFCA28 100%);
    color: #4A3520;
    border: 2px solid #FFF8E1;
    font-size: clamp(17px, 4.6vw, 20px);
    box-shadow: 0 6px 0 #D9A414, 0 12px 24px rgba(217, 164, 20, 0.35);
}

.revive-btn:active {
    box-shadow: 0 2px 0 #D9A414;
}

/* Адаптация под горизонтальную ориентацию экрана смартфона */
@media (max-height: 520px) and (orientation: landscape) {
    .menu-container {
        flex-direction: row;
        flex-wrap: wrap;
        max-width: 780px;
        justify-content: center;
        gap: 14px;
    }
    .logo-card {
        padding: 8px 24px;
    }
    .logo-text,
    body.lang-en .logo-text {
        font-size: 28px;
    }
    .glass-card, .custom-card {
        max-width: 420px;
        padding: 12px 16px;
    }
    .diff-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .diff-btn {
        height: 46px;
        padding: 0 12px;
    }
    .diff-name {
        font-size: 16px;
    }
}
