/* Compact phone layout. Keep the tap button and navigation in separate rows. */
@media (max-width: 699px), (pointer: coarse) and (max-height: 520px) {
    .app {
        --top-inset: 8px;
        --top-inset: max(8px, env(safe-area-inset-top));
        --side-inset: 10px;
        --side-inset: max(10px, env(safe-area-inset-left), env(safe-area-inset-right));
        --bottom-inset: 6px;
        --bottom-inset: max(6px, env(safe-area-inset-bottom));
        --hud-height: 72px;
        --menu-size: 32px;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        padding: var(--top-inset) var(--side-inset) var(--bottom-inset);
        align-items: center;
    }

    .topbar {
        width: 100%;
        height: var(--hud-height);
    }

    .site-icon {
        position: absolute;
        top: calc(var(--top-inset) + 4px);
        left: var(--side-inset);
        width: 86px;
        width: clamp(68px, 23vw, 100px);
        height: auto;
    }

    .area-counter {
        position: absolute;
        top: auto;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        white-space: nowrap;
    }

    .balance-group {
        flex-direction: row;
        align-items: center;
        gap: 4px;
    }

    .balance-group .currency,
    .gram-balance {
        width: 60px;
        width: clamp(46px, 16vw, 72px);
        height: 25px;
    }

    .currency {
        padding: 0 5px;
        gap: 2px;
    }

    .currency-icon {
        width: 16px;
        height: 16px;
    }

    #currencyCount {
        font-size: 11px;
    }

    .world-rank {
        position: absolute;
        top: 28px;
        right: 2px;
        width: 96px;
        height: 23px;
    }

    .rank-icon {
        width: 26px;
        height: 26px;
        margin-right: -12px;
    }

    .rank-bar {
        height: 13px;
    }

    #rankCounter {
        font-size: 8px;
        letter-spacing: 0.5px;
    }

    .world-container {
        flex: 0 1 auto;
        width: calc(100% - 64px);
        max-width: 390px;
        height: 37vh;
        height: clamp(80px, 37dvh, 310px);
        margin: 6px auto 0;
    }

    .tools {
        position: fixed;
        top: calc(var(--top-inset) + var(--hud-height) + 6px);
        right: var(--side-inset);
        bottom: auto;
        z-index: 10;
    }

    .menu-container {
        width: var(--menu-size);
        height: var(--menu-size);
    }

    .menu-container.open {
        height: 85px;
    }

    .tap-controls {
        width: 100%;
        height: auto;
        margin: auto 0;
        padding-top: 6px;
        gap: 3px;
    }

    .tap-button {
        width: 72px;
        height: 72px;
    }

    .tap-label {
        font-size: 8px;
    }

    .bottom-panel,
    body.market-screen .app > .bottom-panel,
    body.cart-screen .app > .bottom-panel {
        position: relative;
        left: auto;
        bottom: auto;
        transform: none;
        width: auto;
        margin: auto 0 0;
        padding-top: 6px;
        gap: 5px;
        z-index: 20;
    }

    body:not(.cart-screen):not(.market-screen) .bottom-panel {
        margin-top: 0;
    }

    .glass-menu {
        width: 150px;
        height: 46px;
        padding: 0 3px;
    }

    .round-button {
        width: 44px;
        height: 44px;
        padding: 5px;
        touch-action: manipulation;
    }

    .glass-circle {
        width: 34px;
        height: 34px;
        flex-basis: 34px;
    }

    body.cart-screen .play-screen-button {
        bottom: 68px;
        bottom: calc(62px + var(--bottom-inset));
    }

    body.cart-screen .play-screen-button img {
        width: clamp(96px, 34vw, 140px);
    }

    .play-menu::backdrop {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .play-menu {
        width: min(325px, calc(100vw - 28px));
        padding: 14px 16px 10px;
    }

    .game-modes {
        max-width: 244px;
        margin: 0 auto;
        gap: 8px 12px;
    }

    .play-menu-description {
        margin-bottom: 10px;
    }

    .game-mode-status {
        margin-top: 10px;
    }

    #skipTurnButton,
    #drawCardButton {
        width: clamp(64px, 22vw, 82px);
        height: 44px;
        bottom: 12px;
        bottom: max(12px, env(safe-area-inset-bottom));
    }

    .card-game-window .exit-game-button {
        width: 40px;
        height: 40px;
    }

    .dealt-card {
        will-change: auto;
    }
}

@media (max-height: 520px) and (orientation: landscape) {
    .app {
        --hud-height: 42px;
    }

    .world-rank {
        top: 24px;
    }

    .tap-controls {
        padding-top: 3px;
    }

    .tap-button {
        width: 56px;
        height: 56px;
    }

    .game-modes {
        max-width: 320px;
    }
}
