/*==================================================
    Phones
    Loaded last, so it settles the phone layout. The Pond tab fits the
    screen: a compact top bar, the pond taking whatever height is left,
    then Cast and the tackle. Nothing scrolls sideways; menus and long
    lists still scroll up and down inside their own panels.
==================================================*/

@media (max-width: 760px) {
    html,
    body {
        overflow-x: hidden;
        overscroll-behavior: none;
    }

    .fish-room-active .game.ff-shell {
        gap: 6px;
        padding: 6px 6px calc(68px + env(safe-area-inset-bottom));
        overflow: hidden;
    }

    /* Top bar: weather, Season Pass and level on top, coins and Pearls
       under them, the zone picker across the bottom. */
    .ff-shell .ff-topbar {
        display: grid;
        grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr) auto;
        grid-template-areas:
            "weather season level"
            "coins pearls level"
            "zone zone zone";
        align-items: stretch;
        gap: 5px;
        min-width: 0;
        padding: 5px;
    }

    .ff-shell .ff-topbar > * {
        min-width: 0;
        margin: 0;
    }

    .ff-shell .ff-weather-chip {
        grid-area: weather;
        min-height: 36px;
        padding: 3px 8px;
    }

    .ff-shell .ff-weather-chip .ff-weather-icon {
        width: 24px;
        height: 24px;
        flex: 0 0 auto;
    }

    .ff-shell .ff-weather-chip strong,
    .ff-shell .ff-season-chip strong {
        overflow: hidden;
        font-size: 0.82rem;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .ff-shell .ff-weather-chip small,
    .ff-shell .ff-season-chip small {
        overflow: hidden;
        font-size: 0.7rem;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .ff-shell .ff-weather-chip span,
    .ff-shell .ff-season-chip span {
        min-width: 0;
    }

    .ff-shell .ff-season-chip {
        grid-area: season;
        min-height: 36px;
        padding: 3px 8px;
    }

    .ff-shell .ff-season-chip-icon {
        width: 22px;
        height: 22px;
        flex: 0 0 auto;
    }

    .ff-shell .ff-angler-badge {
        grid-area: level;
        min-height: 0;
        padding: 3px;
    }

    .ff-shell .ff-angler-level {
        height: 100%;
        min-width: 48px;
    }

    .ff-shell .ff-wallet.wallet {
        grid-area: coins;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 5px;
        min-height: 34px;
        padding: 2px 6px;
    }

    .ff-shell .ff-wallet span::before {
        width: 17px;
        height: 17px;
    }

    .ff-shell .ff-wallet strong {
        overflow: hidden;
        font-size: 0.92rem;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .ff-shell .hb-pearl-wallet {
        grid-area: pearls;
        justify-content: center;
        min-height: 34px;
        padding: 2px 8px;
    }

    .ff-shell .hb-pearl-wallet strong {
        font-size: 0.95rem;
    }

    .ff-shell .ff-topbar .zone-bar {
        grid-area: zone;
        height: 36px;
        min-height: 0;
    }

    .ff-shell .ff-topbar .zone-name {
        font-size: 0.95rem;
        line-height: 1.1;
    }

    .ff-shell .ff-topbar .zone-progress {
        font-size: 0.68rem;
        line-height: 1.1;
    }

    /* The stage never scrolls sideways. On the Pond tab it shouldn't need
       to scroll at all; up and down stays as a fallback for tiny screens. */
    .ff-stage.pond-column {
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .ff-stage .fishing-area-view {
        gap: 6px;
    }

    .ff-shell .pond-scene,
    .ff-stage #pondScene {
        flex: 1 1 0;
        height: auto;
        min-height: 170px;
    }

    /* Pond overlays: smaller, so they leave the water visible. */
    .ff-shell .pond-scene .ff-pond-hud-left {
        transform: scale(0.74);
        transform-origin: top left;
    }

    .ff-shell .pond-scene .pond-streak-display {
        transform: scale(0.8);
        transform-origin: top right;
    }

    /* Cast row and tackle. */
    .ff-dock {
        gap: 6px;
    }

    .ff-dock .cast-control-row {
        gap: 6px;
        padding: 6px;
    }

    .ff-dock .cast-button,
    .ff-dock .storage-access-button {
        min-height: 54px;
    }

    .ff-dock .storage-access-button {
        font-size: 0.78rem;
        line-height: 1.1;
    }

    .ff-dock .cast-button .cast-button-label {
        white-space: nowrap;
    }

    /* The AUTO switch sits in the corner, clear of "Cast Line". */
    .ff-dock .cast-button .auto-recast-toggle {
        top: 3px;
        right: 4px;
        padding: 1px 6px 1px 4px;
        font-size: 0.55rem;
    }

    .ff-dock .cast-button:has(.auto-recast-toggle:not([hidden])) .cast-button-label {
        margin-top: 14px;
    }

    .ff-dock-tackle {
        grid-template-areas:
            "bait lure"
            "buy buy"
            "gear gear";
        gap: 5px 8px;
        padding: 6px 8px;
    }

    .ff-dock-tackle .gear-control-title {
        display: none;
    }

    .ff-dock-tackle .gear-picker-button,
    .ff-dock-tackle select {
        min-height: 40px;
    }

    /* Quick Buy and the bulk amounts on one line. */
    .ff-dock-tackle .quick-buy-group {
        grid-template-columns: minmax(0, 1fr) repeat(3, auto);
    }

    .ff-dock-tackle .quick-buy-group #quickBuyBaitButton {
        grid-column: auto;
        font-size: 0.72rem;
    }

    .ff-dock-tackle .quick-buy-group .quick-buy-bait {
        min-height: 30px;
    }

    .ff-dock-tackle .quick-buy-group .quick-buy-multi {
        padding: 0 5px;
        font-size: 0.68rem;
    }

    .ff-dock-tackle .ff-gear-row .sidebar-section-title {
        display: none;
    }

    .ff-dock-tackle .ff-gear-row .gear-summary div {
        min-height: 30px;
        padding: 2px 4px;
        font-size: 0.7rem;
    }

    .ff-dock-tackle .ff-gear-row .gear-summary div::before {
        width: 18px;
        height: 18px;
    }

    /* Panels opened from the Menu fill the stage and scroll inside. */
    .ff-stage .center-view-panel {
        max-width: 100%;
        overflow-x: hidden;
    }
}

/* Short phones (an iPhone SE, or a phone with its browser bars showing). */
@media (max-width: 760px) and (max-height: 700px) {
    .ff-dock .cast-button,
    .ff-dock .storage-access-button {
        min-height: 46px;
    }

    .ff-dock-tackle .ff-gear-row {
        display: none;
    }

    .ff-dock-tackle {
        grid-template-areas:
            "bait lure"
            "buy buy";
    }

    .ff-shell .pond-scene,
    .ff-stage #pondScene {
        min-height: 150px;
    }

    /* The zone's card leaves room for the fisher; the Zones menu has it. */
    .ff-shell .pond-scene .ff-zone-card {
        display: none;
    }
}

/*==================================================
    Keep Net and Aquarium on phones: the header and
    toolbar keep their full height instead of being
    squeezed over the list, the whole window scrolls,
    and the page buttons stay at the bottom.
==================================================*/

@media (max-width: 760px) {
    .hb-storage {
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior: contain;
    }

    .hb-storage > * {
        flex-shrink: 0;
    }

    .hb-storage .storage-modal-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: start;
        gap: 8px;
        height: auto;
    }

    .hb-storage .storage-modal-header > .hb-storage-stats {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .hb-storage .storage-toolbar {
        max-height: none;
    }

    .hb-storage .storage-grid,
    .hb-storage .aquarium-list {
        flex: 0 0 auto;
        min-height: auto;
        overflow: visible;
    }

    .hb-storage .storage-pagination {
        position: sticky;
        bottom: 0;
        z-index: 3;
        margin-top: auto;
        padding-block: 8px;
        /* The window's own solid color, so cards don't show through. */
        background: none;
        background-color: inherit;
        box-shadow: 0 -10px 14px -6px rgba(0, 0, 0, 0.45);
    }
}
