/* Mobile UX 2.0 — final responsive polish layered after page/component CSS. */
:root {
    --fs-mobile-edge: 10px;
    --fs-mobile-dock-gap: 8px;
    --fs-mobile-control-h: 44px;
}

@media (max-width: 767.98px) {
    html {
        scroll-padding-top: 76px;
        -webkit-text-size-adjust: 100%;
    }

    body {
        overscroll-behavior-x: none;
    }

    body > .page {
        padding-bottom: calc(116px + env(safe-area-inset-bottom));
    }

    /* Header: keep it compact, tappable and stable on narrow screens. */
    .fs-main-navbar .container-xl {
        flex-wrap: nowrap;
        min-width: 0;
        gap: 4px;
    }

    .fs-main-navbar .navbar-toggler,
    .fs-header-control {
        min-width: 40px;
        width: 40px;
        min-height: 40px;
        height: 40px;
        padding: 0 !important;
        align-items: center;
        justify-content: center;
    }

    .fs-header-actions {
        flex: 0 0 auto;
        gap: 1px !important;
    }

    .fs-auth-chip {
        width: auto;
        min-width: 40px;
    }

    .fs-auth-avatar {
        margin: 0 !important;
    }

    /* Mobile navigation behaves like a proper menu rather than a compressed desktop nav. */
    .fs-secondary-navbar .navbar-collapse {
        max-height: calc(100dvh - 60px);
        overflow-y: auto;
        overscroll-behavior: contain;
        background: var(--tblr-bg-surface);
        border-top: 1px solid var(--tblr-border-color);
        box-shadow: 0 12px 28px rgba(15, 23, 42, .10);
    }

    .fs-secondary-navbar .navbar,
    .fs-secondary-navbar .container-xl,
    .fs-secondary-navbar .navbar-nav {
        width: 100%;
    }

    .fs-secondary-navbar .navbar-nav {
        padding: 6px 8px calc(10px + env(safe-area-inset-bottom));
    }

    .fs-secondary-navbar .nav-link,
    .fs-ticket-nav-button {
        min-height: var(--fs-mobile-control-h);
        display: flex;
        align-items: center;
        width: 100%;
        border-radius: 9px;
        padding: 9px 10px !important;
    }

    .fs-secondary-navbar .nav-link-icon {
        width: 28px;
        min-width: 28px;
        margin-right: 8px !important;
    }

    .fs-secondary-navbar .dropdown-menu {
        position: static !important;
        inset: auto !important;
        transform: none !important;
        float: none;
        width: 100%;
        min-width: 0;
        margin: 2px 0 6px;
        padding: 4px;
        border-radius: 9px;
        box-shadow: none;
    }

    .fs-secondary-navbar .dropdown-item {
        min-height: 42px;
        display: flex;
        align-items: center;
        border-radius: 7px;
        white-space: normal;
    }

    /* Search was desktop-only before this step. */
    .fs-mobile-nav-search {
        padding: 4px 2px 8px;
    }

    .fs-mobile-search-form,
    .fs-mobile-search-form .input-icon {
        width: 100%;
    }

    .fs-mobile-search-form .form-control {
        min-height: 44px;
        border-radius: 10px;
        font-size: 16px; /* prevents iOS zoom on focus */
    }

    .fs-mobile-search-form .fs-search-suggestions {
        left: 0;
        right: 0;
        width: 100%;
        max-height: min(54dvh, 430px);
    }

    /* General reading/touch comfort. */
    .page-body > .container-xl {
        padding-left: 8px;
        padding-right: 8px;
    }

    .card-header {
        gap: 8px;
    }

    .card-header > .btn,
    .card-header > a.btn,
    .card-footer .btn,
    .fs-ticket-actions .btn,
    .fs-home-actions .btn {
        min-height: 40px;
    }

    .btn-sm {
        min-height: 36px;
    }

    .form-control,
    .form-select {
        font-size: 16px;
    }

    .breadcrumb,
    .nav-tabs,
    .fs-date-nav,
    .fs-ticket-filter {
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
    }

    .breadcrumb > *,
    .nav-tabs .nav-link,
    .fs-date-nav .btn,
    .fs-ticket-filter > * {
        scroll-snap-align: start;
    }

    .nav-tabs {
        gap: 2px;
        padding-bottom: 2px;
    }

    .nav-tabs .nav-link {
        min-height: 42px;
        display: inline-flex;
        align-items: center;
    }

    .table-responsive,
    .fs-responsive-scroll {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }

    /* Match page: names remain readable without making the score column collapse. */
    .fs-match-hero .card-body {
        padding-left: .7rem;
        padding-right: .7rem;
    }

    .fs-match-hero .fs-team-logo-lg {
        width: 58px;
        height: 58px;
    }

    .fs-match-hero .fs-team-block .h3 {
        font-size: .98rem;
        line-height: 1.2;
        white-space: normal !important;
        overflow-wrap: anywhere;
    }

    .fs-match-hero .fs-match-score {
        font-size: 1.65rem;
    }

    .fs-stat-row {
        grid-template-columns: minmax(0, 1fr) 96px minmax(0, 1fr);
        gap: .4rem;
    }

    .fs-stat-home,
    .fs-stat-away {
        font-size: .9rem;
        overflow-wrap: anywhere;
    }

    .fs-stat-name {
        font-size: .75rem;
        line-height: 1.15;
    }

    /* VIP / Izdvojeno: actions are easier to hit and no longer squeeze into tiny rows. */
    .fs-user-pick {
        padding: .85rem !important;
    }

    .fs-user-pick .fs-ticket-add,
    .fs-user-pick .fs-ai-pick-explain,
    .fs-vip-tip .fs-ticket-add,
    .fs-vip-tip .fs-ai-pick-explain {
        min-height: 40px;
    }

    .fs-user-pick-details summary {
        min-height: 40px;
        display: flex;
        align-items: center;
    }

    /* Restore the mobile score block even if the legacy site.css rule contains a malformed prefix. */
    .fs-vip-mobile-score {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        flex-wrap: wrap;
        margin: 10px 0 14px;
        padding: 9px 12px;
        border: 1px solid var(--tblr-border-color, #dce1e7);
        border-radius: 10px;
        background: color-mix(in srgb, var(--tblr-primary) 5%, transparent);
        text-align: center;
    }

    .fs-vip-mobile-score-ht {
        width: 100%;
    }

    /* Homepage: primary CTAs are easier to scan with one thumb. */
    .fs-home-actions {
        gap: 7px;
    }

    .fs-home-match {
        min-height: 72px;
    }

    .fs-home-quick-grid a,
    .fs-home-league,
    .fs-home-personal-stat,
    .fs-home-kpi {
        min-height: 64px;
    }

    /* Personal area / notifications. */
    .fs-notification-item,
    .fs-personal-feed-item,
    .fs-ticket-list-item,
    .fs-ticket-leg {
        scroll-margin-top: 80px;
    }

    /* Floating controls: three different controls must never occupy the same spot. */
    .fs-back-to-top {
        left: max(10px, env(safe-area-inset-left));
        right: auto;
        bottom: max(12px, env(safe-area-inset-bottom));
        width: 42px;
        height: 42px;
    }

    .fs-ai {
        right: max(10px, env(safe-area-inset-right));
        bottom: max(12px, env(safe-area-inset-bottom));
    }

    .fs-ai-launch {
        min-height: 44px;
        max-width: calc(100vw - 72px);
        padding-left: 13px;
        padding-right: 13px;
    }

    .fs-ticket-builder {
        right: max(10px, env(safe-area-inset-right));
        bottom: calc(64px + env(safe-area-inset-bottom));
    }

    .fs-ticket-builder-toggle {
        min-height: 44px;
        padding-left: 13px;
        padding-right: 13px;
    }

    /* Panels sit above both floating launch buttons, not behind them. */
    .fs-ai-panel {
        position: fixed;
        left: 8px;
        right: 8px;
        bottom: calc(116px + env(safe-area-inset-bottom));
        width: auto;
        height: min(72dvh, 620px);
        max-height: calc(100dvh - 188px - env(safe-area-inset-top));
        border-radius: 14px;
    }

    .fs-ai-panel.is-minimized {
        left: auto;
        right: max(8px, env(safe-area-inset-right));
        bottom: calc(116px + env(safe-area-inset-bottom));
        width: min(340px, calc(100vw - 16px));
        height: 58px;
    }

    .fs-ai-header {
        min-height: 56px;
    }

    .fs-ai-messages {
        padding-bottom: 16px;
    }

    .fs-ai-form {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }

    .fs-ticket-builder-panel {
        position: fixed;
        left: 8px;
        right: 8px;
        bottom: calc(116px + env(safe-area-inset-bottom));
        width: auto;
        height: min(68dvh, 560px);
        max-height: calc(100dvh - 188px - env(safe-area-inset-top));
        border-radius: 14px;
    }

    .fs-ticket-builder-panel.is-open {
        display: flex;
    }

    .fs-ticket-builder-panel .card-body {
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .fs-ticket-builder-list {
        max-height: none;
    }

    .fs-ticket-builder-panel .card-footer {
        flex: 0 0 auto;
        padding-bottom: calc(.75rem + env(safe-area-inset-bottom));
    }
}

@media (max-width: 479.98px) {
    .fs-main-navbar .container-xl {
        padding-left: 5px;
        padding-right: 5px;
    }

    .fs-main-navbar .navbar-toggler,
    .fs-header-control {
        min-width: 36px;
        width: 36px;
        min-height: 38px;
        height: 38px;
    }

    .fs-brand-logo-wrap {
        width: 34px;
        height: 34px;
        flex-basis: 34px;
    }

    .fs-header-actions {
        gap: 0 !important;
    }

    .fs-match-hero .fs-team-logo-lg {
        width: 48px;
        height: 48px;
    }

    .fs-match-hero .fs-team-block .h3 {
        font-size: .88rem;
    }

    .fs-match-hero .fs-kickoff {
        font-size: .95rem;
    }

    .fs-stat-row {
        grid-template-columns: minmax(0, 1fr) 82px minmax(0, 1fr);
    }

    .fs-home-actions .btn {
        flex: 1 1 100%;
        justify-content: center;
    }

    .fs-user-pick .fs-ticket-add,
    .fs-user-pick .fs-ai-pick-explain,
    .fs-vip-tip .fs-ticket-add,
    .fs-vip-tip .fs-ai-pick-explain {
        flex: 1 1 100%;
        justify-content: center;
    }

    .fs-ai-panel,
    .fs-ticket-builder-panel {
        left: 5px;
        right: 5px;
        border-radius: 12px;
    }

    .fs-ai-page-actions {
        padding: 10px;
    }
}
