@media (max-width: 599px) and (pointer: coarse) {
    .level-card {
        margin-top: clamp(0px, calc(60vh - 432px), 76px);
    }
}

@media (max-height: 820px) and (pointer: coarse) {
    .screen {
        padding-top: calc(var(--platform-safe-area-top, env(safe-area-inset-top, 0px)) + var(--main-screen-inset));
    }

    .back-btn {
        top: calc(var(--platform-safe-area-top, env(safe-area-inset-top, 0px)) + 14px);
        left: calc(var(--platform-safe-area-left, env(safe-area-inset-left, 0px)) + 14px);
        width: 58px;
        height: 58px;
        font-size: 38px;
    }

    .wood-title {
        margin-top: 42px;
        min-height: 64px;
        width: min(calc(100% - 120px), 280px);
        font-size: clamp(27px, 8vw, 42px);
    }

    .cream-panel {
        margin-top: 26px;
        padding: 15px;
        border-width: 7px;
    }

    .profile-avatar-wrap {
        width: 112px;
        height: 112px;
    }

    .profile-stat-card {
        min-height: 72px;
        grid-template-columns: 50px 1fr;
        gap: 7px;
        padding: 9px;
    }

    .profile-stat-icon {
        width: 46px;
        height: 46px;
        padding: 6px;
    }

    .settings-panel {
        margin-top: 48px;
        min-height: 390px;
        padding: 54px 20px 38px;
    }

    .levels-tabs {
        margin-top: 12px;
        gap: 7px;
    }

    .levels-tab {
        min-height: 44px;
        padding: 0 8px;
        font-size: 13px;
    }

    .levels-filter-stars img {
        width: 20px;
        height: 20px;
    }

    .levels-panel {
        margin-top: 12px;
        padding: 13px;
    }

    .levels-head {
        grid-template-columns: 90px 1fr;
        gap: 14px;
    }

    .levels-main-thumb {
        width: 90px;
        height: 66px;
    }

    .levels-opened {
        min-height: 38px;
        margin-top: 8px;
    }

    .levels-grid {
        gap: 8px;
    }

    .levels-card {
        min-height: 0;
    }

    .levels-card.small {
        min-height: 0;
    }

    .levels-card-img {
        inset: 7px;
    }

    .levels-play-btn {
        margin-top: 14px;
    }

    .how-to-play-panel {
        margin-top: 26px;
        padding: 13px;
    }

    .how-step {
        min-height: 76px;
        grid-template-columns: 38px 76px 1fr;
        gap: 8px;
        padding: 8px 10px;
    }

    .how-step-icon {
        width: 70px;
        height: 54px;
        font-size: 30px;
    }

    .how-tip {
        min-height: 68px;
        grid-template-columns: 54px 1fr;
    }

    .how-tip-icon {
        width: 50px;
        height: 50px;
    }
}

@media (max-height: 720px) and (pointer: coarse) {
    .screen {
        padding-left: calc(var(--platform-safe-area-left, env(safe-area-inset-left, 0px)) + var(--main-screen-inset));
        padding-right: calc(var(--platform-safe-area-right, env(safe-area-inset-right, 0px)) + var(--main-screen-inset));
    }

    .settings-screen,
    .how-to-play-screen,
    .regular-game-setup-screen,
    .profile-screen,
    .shop-screen,
    .leaderboard-screen,
    .levels-screen {
        padding-left: calc(var(--platform-safe-area-left, env(safe-area-inset-left, 0px)) + var(--main-screen-inset));
        padding-right: calc(var(--platform-safe-area-right, env(safe-area-inset-right, 0px)) + var(--main-screen-inset));
    }

    .back-btn {
        width: 50px;
        height: 50px;
        font-size: 32px;
        top: calc(var(--platform-safe-area-top, env(safe-area-inset-top, 0px)) + 10px);
        left: calc(var(--platform-safe-area-left, env(safe-area-inset-left, 0px)) + 10px);
    }

    .wood-title {
        margin-top: 36px;
        min-height: 56px;
        width: min(calc(100% - 118px), 250px);
        font-size: clamp(24px, 7.5vw, 38px);
    }

    .cream-panel {
        width: min(calc(100% - 20px), 372px);
        margin-top: 20px;
        padding: 12px;
        border-width: 6px;
        border-radius: 20px;
    }

    .setup-preview-image {
        aspect-ratio: 1.45 / 1;
    }

    .setup-action-btn {
        min-height: 44px;
        margin-top: 12px;
        font-size: 16px;
    }

    .field-size-title {
        margin-top: 14px;
        font-size: 17px;
    }

    .field-size-buttons {
        margin-top: 10px;
        gap: 7px;
    }

    .size-btn {
        min-height: 44px;
        font-size: 22px;
    }

    .green-big-btn {
        min-height: 54px;
        margin-top: 14px;
        font-size: 32px;
    }

    .profile-review-btn {
        min-height: 50px;
        font-size: 22px;
    }

    .profile-avatar-wrap {
        width: 92px;
        height: 92px;
        margin-bottom: 10px;
    }

    .profile-name {
        font-size: 28px;
    }

    .profile-progress-card {
        padding: 10px;
    }

    .profile-progress-bar {
        height: 28px;
    }

    .profile-stats-title {
        margin-top: 12px;
    }

    .profile-stats-grid {
        gap: 7px;
    }

    .profile-stat-card {
        min-height: 62px;
        grid-template-columns: 44px 1fr;
        padding: 7px;
    }

    .profile-stat-icon {
        width: 40px;
        height: 40px;
        padding: 5px;
    }

    .profile-stat-label {
        font-size: 12px;
    }

    .profile-stat-value {
        font-size: 25px;
    }

    .settings-panel {
        min-height: 350px;
        margin-top: 42px;
        padding: 44px 16px 30px;
    }

    .settings-decor {
        margin-bottom: 34px;
    }

    .settings-row {
        min-height: 78px;
        grid-template-columns: 64px 1fr 78px;
        gap: 10px;
        padding: 12px;
    }

    .settings-row + .settings-row {
        margin-top: 22px;
    }

    .settings-option-icon {
        width: 56px;
        height: 56px;
        padding: 7px;
    }

    .settings-option-title {
        font-size: clamp(22px, 7vw, 32px);
    }

    .toggle-btn {
        width: 76px;
        height: 40px;
    }

    .toggle-knob {
        width: 32px;
        height: 32px;
    }

    .levels-tabs {
        width: min(calc(100% - 12px), 372px);
        margin-top: 10px;
        gap: 6px;
    }

    .levels-tab {
        min-height: 40px;
        border-radius: 12px;
        padding: 0 6px;
        flex-direction: column;
        font-size: 10px;
        line-height: 1.05;
        gap: 1px;
    }

    .levels-filter-stars img {
        width: 16px;
        height: 16px;
    }

    .levels-panel {
        margin-top: 10px;
        padding: 10px;
    }

    .levels-head {
        grid-template-columns: 76px 1fr;
        gap: 11px;
    }

    .levels-main-thumb {
        width: 76px;
        height: 56px;
        border-radius: 10px;
    }

    .levels-name {
        font-size: 30px;
    }

    .levels-opened {
        min-height: 34px;
        margin-top: 7px;
        padding: 0 10px;
        font-size: 16px;
    }

    .levels-opened-star {
        font-size: 22px;
    }

    .levels-divider {
        margin: 10px 0 8px;
    }

    .levels-subtitle {
        margin-bottom: 8px;
        font-size: 14px;
    }

    .levels-grid {
        gap: 7px;
    }

    .levels-card {
        min-height: 0;
        border-radius: 11px;
    }

    .levels-card.small {
        min-height: 0;
    }

    .levels-card-img {
        inset: 6px;
        border-radius: 8px;
    }

    .levels-card.small .levels-card-img {
        bottom: 6px;
    }

    .levels-check {
        width: 34px;
        height: 34px;
        font-size: 22px;
    }

    .levels-lock {
        width: 31px;
        height: 28px;
        font-size: 17px;
    }

    .levels-level {
        min-width: 0;
        max-width: calc(100% - 6px);
        min-height: 24px;
        padding: 0 4px;
        font-size: 11px;
        border-radius: 7px;
    }

    .levels-card.unlocked .levels-level {
        min-width: 0;
        font-size: 11px;
    }

    .levels-card-stars {
        padding-right: 5px;
        padding-left: 5px;
        gap: 1px;
    }

    .levels-card-star {
        width: 15px;
        height: 15px;
    }

    .levels-play-btn {
        width: min(calc(100% - 120px), 230px);
        margin-top: 12px;
    }

    .game-ui {
        --puzzle-section-gap: 12px;
        --puzzle-action-height: 48px;
    }

    .show-picture-btn {
        font-size: 16px;
    }

    .how-top-info {
        gap: 12px;
        margin-bottom: 10px;
    }

    .how-step {
        min-height: 62px;
        margin-top: 7px;
        grid-template-columns: 34px 60px 1fr;
        gap: 7px;
        padding: 7px;
    }

    .how-step-number {
        width: 30px;
        height: 30px;
        font-size: 19px;
    }

    .how-step-icon {
        width: 56px;
        height: 44px;
        font-size: 25px;
    }

    .how-step-text {
        font-size: 14px;
    }

    .how-tip {
        margin-top: 10px;
        min-height: 58px;
        grid-template-columns: 44px 1fr;
        padding: 9px;
    }

    .how-tip-icon {
        width: 40px;
        height: 40px;
    }

    .how-tip-text {
        font-size: 14px;
    }

}

@media (max-width: 360px) {
    .game-ui {
        --main-screen-inset: 16px;
        --main-control-size: clamp(48px, 7vh, 52px);
    }

    .modal-close-btn {
        top: -15px;
        right: -15px;
        width: 34px;
        height: 34px;
        min-height: 34px;
        padding-bottom: 2px;
        border-width: 3px;
        font-size: 30px;
    }

    .wood-title {
        font-size: 28px;
    }

    .cream-panel {
        width: calc(100% - 8px);
    }

    .settings-row {
        grid-template-columns: 58px 1fr 72px;
        gap: 8px;
    }

    .settings-option-icon {
        width: 52px;
        height: 52px;
        padding: 7px;
    }

    .settings-option-title {
        font-size: 23px;
    }

    .toggle-btn {
        width: 70px;
        height: 38px;
    }

    .toggle-knob {
        width: 30px;
        height: 30px;
    }

    .profile-stat-card {
        grid-template-columns: 40px 1fr;
    }

    .profile-stat-icon {
        width: 38px;
        height: 38px;
        padding: 5px;
    }

    .profile-stat-value {
        font-size: 23px;
    }

    .levels-tab {
        min-width: 0;
        padding: 0 2px;
        overflow: hidden;
        flex-direction: column;
        gap: 1px;
        font-size: 9px;
        line-height: 1.05;
    }

    .levels-filter-stars {
        gap: 1px;
    }

    .levels-filter-stars img {
        width: 15px;
        height: 15px;
    }

    .levels-level,
    .levels-card.unlocked .levels-level {
        min-width: 0;
        max-width: calc(100% - 6px);
        min-height: 22px;
        padding: 0 3px;
        font-size: 10px;
    }

    .levels-card-stars {
        padding-right: 4px;
        padding-left: 4px;
        gap: 1px;
    }

    .levels-card-star {
        width: 14px;
        height: 14px;
    }

    .levels-head {
        grid-template-columns: 68px 1fr;
        gap: 9px;
    }

    .levels-main-thumb {
        width: 68px;
        height: 52px;
    }

    .levels-name {
        font-size: 27px;
    }

    .levels-opened {
        font-size: 14px;
    }

    .leaderboard-row {
        grid-template-columns: 35px 36px 1fr 48px;
        padding-left: 9px;
        padding-right: 9px;
    }

    .how-step {
        grid-template-columns: 32px 52px 1fr;
    }

    .how-step-icon {
        width: 50px;
    }
}

@media (max-width: 439px) {
    .shop-products-grid {
        width: min(100%, 300px);
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }
}

@media (min-width: 361px) and (max-width: 599px) and (pointer: coarse) {
    .game-ui {
        --puzzle-control-size: 56px;
        --puzzle-action-height: 56px;
    }

    .level-title {
        font-size: clamp(20px, 6vw, 24px);
        font-weight: 900;
        line-height: 1.08;
    }

    .puzzle-back-btn,
    .puzzle-hint-btn,
    .puzzle-stat-card {
        height: 56px;
    }

    .show-picture-btn {
        height: 56px;
        min-height: 56px;
    }

    html.fullscreen-layout .settings-screen .settings-modal,
    html.fullscreen-layout .how-to-play-screen .how-to-play-modal,
    html.fullscreen-layout .regular-game-setup-screen .regular-setup-modal,
    html.fullscreen-layout .profile-screen .profile-modal,
    html.fullscreen-layout .shop-screen .shop-modal,
    html.fullscreen-layout .leaderboard-screen .leaderboard-modal,
    html.fullscreen-layout .levels-screen .levels-modal {
        height: 100%;
        max-height: 100%;
    }

    html.fullscreen-layout .victory-overlay {
        align-items: center;
        justify-content: center;
        padding:
            calc(var(--platform-safe-area-top, env(safe-area-inset-top, 0px)) + var(--main-screen-inset))
            calc(var(--platform-safe-area-right, env(safe-area-inset-right, 0px)) + var(--main-screen-inset))
            calc(var(--platform-safe-area-bottom, env(safe-area-inset-bottom, 0px)) + var(--main-screen-inset))
            calc(var(--platform-safe-area-left, env(safe-area-inset-left, 0px)) + var(--main-screen-inset));
    }

    html.fullscreen-layout .victory-modal {
        width: 100%;
        height: 100%;
        max-height: 100%;
        margin: 0;
    }
}
