:root {
    --bg: #0f1218;
    --panel: #1a1f2b;
    --text: #e8eaef;
    --muted: #8b93a7;
    --accent: #f4a261;
    --found: #2a9d8f;
    --miss: #e76f51;
    /* Указатель ~как лапка по масштабу (высота ≈12, ширина ≈12) + лапка */
    --cursor-paw: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg fill='%23f4a261' stroke='%231a1208' stroke-width='0.9' stroke-linejoin='round' stroke-linecap='round'%3E%3Cpath d='M2 2L2 14.25L14 6.9Z'/%3E%3Ccircle cx='11' cy='13.7' r='2.22'/%3E%3Ccircle cx='14.15' cy='12' r='2.32'/%3E%3Ccircle cx='17.85' cy='12' r='2.32'/%3E%3Ccircle cx='21' cy='13.7' r='2.22'/%3E%3Cellipse cx='16' cy='23.85' rx='6.45' ry='4.95'/%3E%3C/g%3E%3C/svg%3E")
        2 2,
        pointer;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
}

* {
    box-sizing: border-box;
}

/* Скрытая view в SPA (меню/игра) — приоритетнее display у .app/.app--play */
[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overscroll-behavior: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: "Segoe UI", system-ui, sans-serif;
    background-color: var(--bg);
    background-image: url("../images/foon.jpg");
    background-repeat: repeat;
    background-size: auto;
    color: var(--text);
    overflow-x: clip;
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
    overscroll-behavior: none;
    touch-action: manipulation;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

html:not(.page-game) {
    overflow: hidden;
    height: 100%;
    max-height: 100%;
    position: fixed;
    inset: 0;
    width: 100%;
    overscroll-behavior: none;
    touch-action: pan-y;
}

html:not(.page-game) body {
    overflow: hidden;
    height: 100%;
    max-height: 100%;
    position: fixed;
    inset: 0;
    width: 100%;
    overscroll-behavior: none;
    touch-action: pan-y;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html:not(.page-game) body > .app {
    height: 100%;
    max-height: 100%;
    min-height: 0;
}

/* Страница игры: жёстко фиксируем viewport — отключает iOS swipe-to-refresh */
html.page-game {
    overflow: hidden;
    height: 100%;
    max-height: 100%;
    position: fixed;
    inset: 0;
    width: 100%;
    overscroll-behavior: none;
    touch-action: none;
}

html.page-game body {
    overflow: hidden;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    position: fixed;
    inset: 0;
    width: 100%;
    padding-left: 0;
    padding-right: 0;
    touch-action: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
}

html.page-game * {
    -webkit-tap-highlight-color: transparent;
}

html.page-game .app {
    padding: max(clamp(0.28rem, 1.1vw, 0.58rem), var(--safe-top))
        max(clamp(0.3rem, 1.2vw, 0.62rem), var(--safe-right))
        max(clamp(0.32rem, 1.3vw, 0.66rem), var(--safe-bottom))
        max(clamp(0.3rem, 1.2vw, 0.62rem), var(--safe-left));
    height: 100%;
    max-height: 100%;
    min-height: 0;
}

.app {
    width: 100%;
    max-width: min(1200px, 100%);
    margin: 0 auto;
    padding: clamp(0.5rem, 2.5vw, 1.25rem);
    padding-bottom: max(clamp(0.5rem, 2.5vw, 1.25rem), var(--safe-bottom));
}

/* Игровой экран: колонка на всю высоту окна, сцена подстраивается под оставшееся место */
.app--play {
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

/* В WebView Яндекса 100vh может быть выше видимой области — внутри фиксированного body только 100% */
html.page-game .app--play {
    min-height: 0;
    height: 100%;
    max-height: 100%;
}

.app--play .bar {
    flex-shrink: 0;
    width: var(--bar-width, 100%);
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 0;
    border-radius: 12px 12px 0 0;
    border-bottom: none;
    box-sizing: border-box;
    min-width: 0;
}

.app--play .stage-wrap {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    overflow: hidden;
}

/* Ширина сцены — на всю полосу контента; --bar-width только у шапки, иначе при ресайзе
   clientWidth сцены оставался бы старым и картинка не росла */
.app--play .stage {
    width: 100%;
    max-width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    max-height: var(--stage-max-h, calc(100svh - 7rem - var(--safe-top) - var(--safe-bottom)));
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
    margin-top: 0;
    overflow: hidden;
}

.app--play .scene-stack {
    width: 100%;
    max-width: 100%;
    max-height: var(--stage-max-h, 100%);
}

.app--play #scene {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
}

.bar {
    background: var(--panel);
    border-radius: 12px;
    padding: clamp(0.75rem, 3vw, 1.25rem);
    margin-bottom: clamp(0.5rem, 2vw, 1rem);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.title {
    margin: 0 0 0.25rem;
    font-size: clamp(1.15rem, 4.2vw, 1.5rem);
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.subtitle {
    margin: 0 0 0.75rem;
    color: var(--muted);
    font-size: clamp(0.8rem, 2.8vw, 0.95rem);
    line-height: 1.45;
}

.stats {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: clamp(0.5rem, 2vw, 1rem);
    font-size: clamp(0.85rem, 2.5vw, 0.95rem);
    margin-bottom: 0.75rem;
}

.bar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.btn {
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    padding: 0.5rem 1rem;
    min-height: 2.75rem;
    border-radius: 8px;
    font-size: clamp(0.85rem, 2.5vw, 0.9rem);
    touch-action: manipulation;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn.primary {
    background: var(--accent);
    color: #1a1208;
    border-color: transparent;
    font-weight: 600;
}

.stage-wrap {
    position: relative;
    touch-action: none;
}

.stage {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    border: none;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
    background: #000;
    line-height: 0;
    cursor: var(--cursor-paw);
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

/* Высота задаётся aspect-ratio из JS по ч/б растру — цвет и canvas совпадают пиксель-в-пиксель */
.scene-stack {
    position: relative;
    width: 100%;
    line-height: 0;
}

.scene-stack .color-bg,
.scene-stack .bw-canvas {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: block;
    user-select: none;
}

.scene-stack .color-bg {
    pointer-events: auto;
}

.scene-stack .bw-canvas {
    pointer-events: none;
}

#scene {
    width: 100%;
    height: auto;
    display: block;
    vertical-align: middle;
    user-select: none;
    pointer-events: auto;
    cursor: var(--cursor-paw);
    -webkit-user-drag: none;
}

.stage canvas,
.stage svg,
.stage img {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.is-hidden {
    display: none !important;
}

.overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.overlay circle {
    fill: none;
    stroke: var(--found);
    stroke-width: 3;
    opacity: 0.95;
    filter: drop-shadow(0 0 6px rgba(42, 157, 143, 0.7));
}

.toast {
    position: absolute;
    left: 50%;
    bottom: max(0.5rem, env(safe-area-inset-bottom, 0));
    transform: translateX(-50%);
    max-width: calc(100% - 1.5rem);
    margin: 0;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    background: rgba(0, 0, 0, 0.75);
}

.toast.show {
    opacity: 1;
}

.toast.miss {
    color: #ffb4a2;
}

.toast.ok {
    color: #b5ead7;
}

.win-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: max(0.75rem, env(safe-area-inset-top))
        max(0.75rem, env(safe-area-inset-right))
        max(0.75rem, env(safe-area-inset-bottom))
        max(0.75rem, env(safe-area-inset-left));
}

.win-modal:not([hidden]) {
    display: flex;
}

.win-modal[hidden] {
    display: none !important;
}

.win-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 12, 18, 0.72);
    cursor: pointer;
}

.win-modal__panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    padding: 1.5rem 1.5rem 1.35rem;
    border-radius: 14px;
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
    text-align: center;
}

.win-modal__title {
    margin: 0 0 0.75rem;
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.02em;
}

.win-modal__message {
    margin: 0 0 1.35rem;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text);
}

.win-modal__actions {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    justify-content: center;
    align-items: center;
}

.win-modal__actions .btn {
    min-width: 10rem;
}

/* ——— главное меню ——— */
/* Меню прокручивается, если контент не помещается (узкие/альбомные экраны),
   чтобы названия уровней не обрезались (п. 1.10.1) */
.menu-page {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
}

.menu-page .level-grid {
    flex: 0 0 auto;
    min-height: 0;
}

.bar-actions--toolbar {
    align-items: center;
}

.app-dock__btn {
    font: inherit;
    font-size: 0.88rem;
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.25rem;
    transition: background 0.15s, border-color 0.15s;
    touch-action: manipulation;
}

.app-dock__btn:hover {
    background: rgba(244, 162, 97, 0.12);
    border-color: rgba(244, 162, 97, 0.35);
}

.app-dock__btn--ghost {
    background: transparent;
}

.app-dock__lang {
    display: inline-flex;
    gap: 0.35rem;
    padding: 0.2rem;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
}

.app-dock__pill {
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.35rem 0.65rem;
    min-width: 2.75rem;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.app-dock__pill.is-active {
    background: rgba(244, 162, 97, 0.2);
    border-color: rgba(244, 162, 97, 0.45);
    color: var(--accent);
}

.app-dock__pill:not(.is-active):hover {
    color: var(--text);
}

/* Достаточные зоны нажатия для меню на сенсорных устройствах (п. 1.8) */
@media (pointer: coarse) {
    .menu-bar__right .app-dock__btn {
        min-height: 2.6rem;
        padding: 0.5rem 0.85rem;
    }

    .menu-bar__right .app-dock__pill {
        min-height: 2.6rem;
        min-width: 3rem;
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
}

.menu-header {
    text-align: center;
}

.menu-bar {
    padding: clamp(0.55rem, 1.7vw, 0.85rem);
}

/* Контролы (язык/музыка) — отдельной строкой над заголовком, чтобы текст
   заголовка никогда не наезжал на кнопки (п. 1.10.3) */
.menu-bar__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    align-items: center;
    gap: 0.4rem;
}

.menu-bar__title {
    margin: 0;
    grid-column: 1;
    grid-row: 2;
    text-align: center;
}

.menu-bar__subtitle {
    margin: 0.1rem auto 0;
    grid-column: 1;
    grid-row: 3;
    text-align: center;
    max-width: min(56ch, 100%);
}

.menu-bar__right {
    display: flex;
    gap: 0.45rem;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    grid-column: 1;
    grid-row: 1;
    justify-self: end;
}

.menu-lead {
    max-width: 36rem;
    margin-left: auto;
    margin-right: auto;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: clamp(0.55rem, 1.5vw, 0.95rem);
    margin-top: 0.4rem;
}

.menu-page .level-grid {
    --menu-cols: 4;
    grid-template-columns: repeat(var(--menu-cols), minmax(0, 1fr));
    grid-auto-rows: auto;
    align-items: stretch;
    align-content: start;
    padding-bottom: 0.4rem;
}

@media (max-width: 72rem) {
    .menu-page .level-grid {
        --menu-cols: 4;
    }
}

@media (max-width: 40rem) {
    .menu-page .level-grid {
        --menu-cols: 3;
    }

    .game-bar {
        padding: 0.4rem;
    }

    .game-bar__left,
    .game-bar__right {
        gap: 0.3rem;
    }

    .game-bar__left .btn,
    .game-bar__right .app-dock__btn,
    .game-bar__right .app-dock__pill {
        min-height: 2.15rem;
        padding: 0.35rem 0.65rem;
    }

    .game-bar__title {
        white-space: normal;
        font-size: clamp(0.95rem, 3.2vw, 1.15rem);
    }
}

@media (max-height: 520px) and (orientation: landscape) {
    html.page-game .app {
        padding-top: max(0.18rem, var(--safe-top));
        padding-bottom: max(0.18rem, var(--safe-bottom));
    }

    .game-bar {
        padding: 0.24rem 0.32rem;
    }

    /* Компактная шапка: меню | заголовок | язык-музыка в одну строку,
       чтобы сцена и котики были крупнее на телефоне (п. 1.8) */
    .app--play .game-bar__row {
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-rows: auto;
        align-items: center;
        gap: 0.24rem 0.4rem;
    }

    .app--play .game-bar__title {
        grid-column: 2;
        grid-row: 1;
        -webkit-line-clamp: 2;
    }

    .app--play .game-bar__left {
        grid-column: 1;
        grid-row: 1;
        justify-self: start;
        width: auto;
        max-width: none;
        justify-content: flex-start;
        flex-wrap: nowrap;
    }

    .app--play .game-bar__right {
        grid-column: 3;
        grid-row: 1;
        justify-self: end;
        width: auto;
        max-width: none;
        justify-content: flex-end;
        flex-wrap: nowrap;
    }

    .app--play .game-bar__stats {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .game-bar__left,
    .game-bar__right {
        gap: 0.22rem;
    }

    .app--play .game-bar .btn,
    .app--play .game-bar .btn-link,
    .app--play .game-bar .app-dock__btn {
        min-height: 2rem;
        padding: 0.3rem 0.55rem;
        font-size: 0.76rem;
    }

    .app--play .game-bar .app-dock__pill {
        min-height: 2rem;
        min-width: 2.4rem;
        padding: 0.28rem 0.5rem;
        font-size: 0.74rem;
    }

    .app--play .game-bar__title {
        font-size: clamp(0.78rem, 2vw, 0.98rem);
        line-height: 1.1;
    }

    .stats {
        margin-bottom: 0.18rem;
    }

    .game-bar__stats {
        margin-top: 0.16rem;
        font-size: 0.7rem;
        gap: 0.35rem;
    }

    .app--play .stage {
        max-height: var(--stage-max-h, calc(100dvh - 4.4rem - var(--safe-top) - var(--safe-bottom)));
    }
}

@media (max-width: 360px) {
    .menu-bar {
        padding: 0.4rem;
    }

    .menu-bar__right {
        gap: 0.25rem;
    }

    .menu-bar__right .app-dock__btn,
    .menu-bar__right .app-dock__pill {
        min-height: 2rem;
        padding: 0.28rem 0.55rem;
        font-size: 0.74rem;
    }

    .menu-bar__title {
        font-size: clamp(0.92rem, 4.2vw, 1.1rem);
    }

    .menu-bar__subtitle {
        font-size: clamp(0.68rem, 3.25vw, 0.82rem);
    }
}

.level-tile {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    overflow: hidden;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(35, 42, 58, 0.95), rgba(22, 27, 39, 0.96));
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.2s, border-color 0.2s, transform 0.14s, box-shadow 0.2s, filter 0.2s;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

.menu-page .level-tile {
    height: auto;
    min-height: 0;
}

.level-tile:hover {
    background: linear-gradient(180deg, rgba(43, 51, 70, 0.98), rgba(25, 31, 45, 0.98));
    border-color: rgba(244, 162, 97, 0.5);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.36), 0 0 0 1px rgba(244, 162, 97, 0.2) inset;
    transform: translateY(-2px);
}

.level-tile:active {
    transform: translateY(0) scale(0.985);
}

.level-tile__img {
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    object-fit: cover;
    display: block;
    background: #0a0c10;
    transition: filter 0.2s ease, transform 0.25s ease;
}

.menu-page .level-tile__img {
    height: auto;
    aspect-ratio: 16 / 9;
}

.level-tile:hover .level-tile__img {
    filter: brightness(1.08) saturate(1.18) hue-rotate(-5deg);
    transform: scale(1.03);
}

.level-tile__body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.62rem 0.5rem 0.78rem;
    background: linear-gradient(180deg, rgba(15, 19, 28, 0.05), rgba(8, 11, 18, 0.35));
}

.menu-page .level-tile__body {
    flex: 0 0 auto;
    min-height: 0;
    padding: 0.5rem 0.45rem 0.6rem;
}

.level-tile__n {
    font-size: 1.35rem;
    font-weight: 700;
    color: #ffd29b;
    line-height: 1;
    text-shadow: 0 1px 8px rgba(244, 162, 97, 0.35);
}

.menu-page .level-tile__n {
    font-size: clamp(0.95rem, 1.8vw, 1.25rem);
}

.level-tile__t {
    text-align: center;
    line-height: 1.25;
    color: #c7cfdf;
    font-size: 0.8rem;
    min-height: 2.2em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Полное название уровня без обрезки (п. 1.10.1) */
.menu-page .level-tile__t {
    font-size: clamp(0.68rem, 1.2vw, 0.82rem);
    min-height: 0;
    -webkit-line-clamp: unset;
    display: block;
    overflow: visible;
    overflow-wrap: anywhere;
}

.level-tile:hover .level-tile__t {
    color: #eef2fb;
}

.btn-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.game-bar {
    padding: clamp(0.45rem, 1.5vw, 0.75rem);
}

/* Две строки: заголовок на всю ширину, кнопки слева/справа — без наложения на iOS */
.game-bar__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 0.38rem 0.55rem;
}

.game-bar__title {
    grid-column: 1 / -1;
    grid-row: 1;
}

.game-bar__left {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
}

.game-bar__right {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
}

.game-bar__left,
.game-bar__right {
    display: flex;
    gap: 0.45rem;
    align-items: center;
    flex-wrap: wrap;
    min-width: 0;
}

.game-bar__right {
    justify-content: flex-end;
}

.game-bar__title {
    margin: 0;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.15;
    font-size: clamp(0.88rem, 2.2vw, 1.28rem);
    max-width: 100%;
}

.game-bar__subtitle {
    margin: 0.1rem 0 0;
    text-align: center;
    max-width: min(52ch, 100%);
}

.game-bar__stats {
    margin: 0.35rem 0 0;
    justify-content: center;
    text-align: center;
    gap: clamp(0.3rem, 1.2vw, 0.7rem);
    font-size: clamp(0.72rem, 1.9vw, 0.92rem);
    flex-wrap: wrap;
    row-gap: 0.25rem;
    max-width: 100%;
}

/* iOS / узкий экран: шапка на всю ширину, кнопки в столбец — без наложений (п. 1.10.3) */
@media (max-width: 52rem), (pointer: coarse) {
    .app--play .bar {
        width: 100% !important;
        max-width: 100% !important;
    }

    .game-bar__row {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 0.32rem;
    }

    .game-bar__title {
        grid-column: 1;
        grid-row: 1;
        font-size: clamp(0.82rem, 3.6vw, 1.05rem);
        line-height: 1.2;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .game-bar__left {
        grid-column: 1;
        grid-row: 2;
        justify-self: stretch;
        justify-content: space-between;
        width: 100%;
        max-width: 100%;
    }

    .game-bar__right {
        grid-column: 1;
        grid-row: 3;
        justify-self: stretch;
        justify-content: center;
        width: 100%;
        max-width: 100%;
    }

    /* Комфортные зоны нажатия на сенсорных экранах (п. 1.8) */
    .game-bar .btn,
    .game-bar .btn-link,
    .game-bar .app-dock__btn {
        min-height: 2.6rem;
        padding: 0.45rem 0.7rem;
        font-size: clamp(0.74rem, 2.9vw, 0.88rem);
    }

    .game-bar .app-dock__pill {
        min-height: 2.6rem;
        min-width: 3rem;
        padding: 0.45rem 0.7rem;
    }

    .game-bar__stats {
        flex-direction: column;
        align-items: center;
        gap: 0.2rem;
        font-size: clamp(0.68rem, 2.6vw, 0.82rem);
    }

    .game-bar__stats span {
        display: block;
        max-width: 100%;
        overflow-wrap: anywhere;
    }
}

.game-bar .btn,
.game-bar .btn-link,
.game-bar .app-dock__btn,
.game-bar .app-dock__pill {
    min-height: 2.15rem;
    padding: 0.34rem 0.66rem;
    font-size: clamp(0.74rem, 1.7vw, 0.9rem);
}

.game-bar .app-dock__lang {
    gap: 0.24rem;
    padding: 0.16rem;
}

.help-modal {
    position: fixed;
    inset: 0;
    z-index: 980;
    align-items: center;
    justify-content: center;
    padding: max(0.75rem, env(safe-area-inset-top))
        max(0.75rem, env(safe-area-inset-right))
        max(0.75rem, env(safe-area-inset-bottom))
        max(0.75rem, env(safe-area-inset-left));
}

.help-modal:not([hidden]) {
    display: flex;
}

.help-modal[hidden] {
    display: none !important;
}

.help-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 12, 18, 0.66);
    cursor: pointer;
}

.help-modal__panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 520px;
    padding: 1.3rem 1.35rem 1.2rem;
    border-radius: 14px;
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
    text-align: center;
}

.help-modal__title {
    margin: 0 0 0.55rem;
    font-size: 1.25rem;
    color: var(--accent);
}

.help-modal__message {
    margin: 0;
    color: var(--text);
    line-height: 1.5;
}

.help-modal__actions {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    justify-content: center;
    align-items: center;
}

@media (max-width: 28rem) {
    .stats {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }

    .bar-actions {
        width: 100%;
    }

    .bar-actions .btn,
    .bar-actions .btn-link {
        flex: 1 1 auto;
        min-width: 0;
        justify-content: center;
    }

    .game-bar__row {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }

    .game-bar__title {
        grid-column: 1;
        grid-row: 1;
    }

    .game-bar__left {
        grid-column: 1;
        grid-row: 2;
        justify-self: center;
    }

    .game-bar__right {
        grid-column: 1;
        grid-row: 3;
        justify-self: center;
    }

    .game-bar__subtitle {
        order: -1;
    }

    .menu-bar__row {
        grid-template-columns: 1fr;
    }

    .menu-bar__title,
    .menu-bar__subtitle {
        text-align: center;
    }

    .menu-bar__right {
        justify-self: center;
        justify-content: center;
    }

    .level-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .menu-page .level-grid {
        --menu-cols: 2;
        --menu-rows: 6;
    }
}

