/* =====================================================================
   SUDOKA — стили игры «Сапёр»
   Самодостаточный файл: подключается только на странице игры.
   ===================================================================== */

.msw-page { max-width: 640px; margin-inline: auto; }

.msw-head { text-align: center; margin-bottom: 1rem; }
.msw-head h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); }
.msw-head p { color: var(--ink-muted); max-width: 46ch; margin: .35rem auto 0; }

/* ---------- Панель управления ---------- */
.msw-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: .75rem; margin-bottom: .9rem;
}
.msw-diff-group {
    display: inline-flex; background: var(--bg-alt); border-radius: 999px; padding: .25rem; gap: .15rem;
}
.msw-diff {
    border: 0; background: transparent; color: var(--ink-muted); font-weight: 800; font-size: .9rem;
    padding: .4rem .85rem; border-radius: 999px; transition: background .15s, color .15s;
}
.msw-diff:hover { color: var(--terracotta-d); }
.msw-diff.active { background: var(--terracotta); color: #fff; box-shadow: var(--shadow-sm); }
.msw-actions { display: inline-flex; gap: .5rem; align-items: center; }

/* Кнопка «режим флажков» — для тача и трекпада */
.msw-flag-mode {
    border: 2px solid var(--border); background: var(--card); color: var(--ink-muted);
    font-weight: 800; font-size: .9rem; padding: .38rem .8rem; border-radius: 999px;
    display: inline-flex; align-items: center; gap: .35rem; transition: all .15s;
}
.msw-flag-mode:hover { color: var(--terracotta-d); border-color: var(--terracotta-l); }
.msw-flag-mode.active { background: var(--terracotta); border-color: var(--terracotta); color: #fff; box-shadow: var(--shadow-sm); }

/* ---------- Статистика ---------- */
.msw-stats {
    display: flex; justify-content: center; gap: 1.5rem; flex-wrap: wrap;
    color: var(--ink-muted); font-weight: 700; font-size: .95rem; margin-bottom: .75rem;
}
.msw-stats b { color: var(--ink); }
.msw-stats .num {
    display: inline-block; min-width: 2.6ch; text-align: center;
    font-variant-numeric: tabular-nums; color: var(--terracotta-d);
}

/* ---------- Игровое поле ---------- */
.msw-wrap { position: relative; }

.msw-grid {
    width: 100%;
    max-width: 560px;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(var(--msw-cols, 10), 1fr);
    grid-template-rows: repeat(var(--msw-cols, 10), 1fr);
    gap: 2px;
    background: var(--border);
    border: 3px solid var(--ink);
    border-radius: 12px;
    overflow: hidden;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.msw-tile {
    background: var(--card);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-weight: 800;
    line-height: 1;
    font-size: clamp(.65rem, 2.4vw, 1.15rem);
    position: relative;
    transition: background .1s;
}
.msw-tile:hover { background: var(--terracotta-l); }
.msw-tile.checked {
    background: var(--bg-alt);
    cursor: default;
}
.msw-tile.checked:hover { background: var(--bg-alt); }
.msw-tile svg { width: 62%; height: 62%; pointer-events: none; }
.msw-tile.exploded { background: var(--danger); }
.msw-tile.revealed-bomb { background: var(--danger-l); }

/* ---------- Подсказка ---------- */
.msw-help {
    text-align: center; color: var(--ink-muted); font-size: .9rem; margin-top: .9rem;
}
.msw-help kbd {
    background: var(--bg-alt); border: 1px solid var(--border); border-bottom-width: 2px;
    border-radius: 5px; padding: .05rem .4rem; font-size: .8rem; font-family: var(--font);
}

/* ---------- Финальное окно ---------- */
.msw-modal {
    position: fixed; inset: 0;
    background: rgba(58, 46, 42, .45);
    display: flex; align-items: center; justify-content: center;
    z-index: 999; visibility: hidden; opacity: 0; pointer-events: none;
    transition: opacity .3s, visibility .3s;
    padding: 1rem;
}
.msw-modal.show { visibility: visible; opacity: 1; pointer-events: auto; }

.msw-result {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem 2.5rem;
    text-align: center;
    max-width: 92vw;
}
.msw-result-msg { font-size: 1.8rem; line-height: 1.15; margin-bottom: .4rem; }
.msw-result-msg.msw-win { color: var(--sage-d); }
.msw-result-msg.msw-lose { color: var(--danger); }
.msw-result-time { color: var(--ink-muted); margin-bottom: 1.25rem; font-weight: 700; }
.msw-result .btn { margin-top: .25rem; }

/* ---------- Тряска при взрыве ---------- */
.msw-grid.shake {
    animation: msw-shake .55s cubic-bezier(.36, .07, .19, .97) both;
}
@keyframes msw-shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}
