/* Shared mobile refinements loaded after page-specific styles. */
@media (max-width: 768px) {
    /* Keep all four match sections visible and easy to tap. */
    .match-detail-tabs { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:4px; overflow:visible; }
    .match-detail-tabs .match-detail-tab { display:flex; flex-direction:column; justify-content:center; gap:6px; width:100%; min-width:0; min-height:62px; padding:9px 2px; white-space:normal; text-align:center; font-size:11px; line-height:1.2; border-radius:10px 10px 0 0; }
    .match-detail-tab>i { font-size:16px; }
    .match-detail-tabs .match-detail-tab>span { display:none; }
    .match-detail-tab.active { background:rgba(16,185,129,.08); }
    .match-detail-heading { align-items:flex-start; flex-wrap:wrap; gap:10px; }
    .match-detail-heading>small a { display:inline-flex; align-items:center; gap:6px; min-height:44px; }

    /* Put the rating entirely above the photo, outside the player's face. */
    .lineup-board { width:100%; min-width:0; padding:11px; }
    .lineup-board-heading { flex-wrap:wrap; gap:7px; }
    .lineup-board-heading small { font-size:10px; }
    .lineup-pitch { min-height:calc(var(--pitch-lines) * 88px + 40px); }
    .lineup-footballer { gap:6px; -webkit-tap-highlight-color:transparent; }
    .lineup-footballer .lineup-portrait { width:34px; height:34px; flex-basis:34px; font-size:16px; }
    .lineup-footballer .lineup-player-rating { top:-21px; right:-5px; min-width:27px; height:19px; padding:0 3px; border-width:1px; border-radius:6px; font-size:10px; line-height:1; pointer-events:none; }
    .lineup-footballer .lineup-player-name { font-size:10px; line-height:1.25; padding:3px; }
    .lineup-pitch-empty { font-size:12px; }
    .lineup-pitch-empty small { font-size:11px; line-height:1.5; }

    .match-event-copy>small { font-size:10px; }
    .match-event-type { font-size:10px; }
    .match-event-player-line>a { font-size:12px; line-height:1.4; }
    .match-event-play { position:relative; width:36px; height:36px; flex-basis:36px; font-size:12px; }
    .match-event-play::before { content:""; position:absolute; inset:-4px; }
    .match-event-minute { font-size:11px; }
    .match-recent-team li { display:grid; grid-template-columns:28px minmax(0,1fr); gap:8px; }
    .match-recent-team li time { grid-column:2; text-align:center; font-size:11px; }
    .match-recent-opponent { display:grid; grid-template-columns:minmax(0,1fr) auto minmax(0,1fr); gap:6px; font-size:11px; line-height:1.5; overflow-wrap:anywhere; }
    .match-recent-opponent b { font-size:14px; }
    input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size:16px; }
}
@media (hover:none) {
    .lineup-footballer:hover .lineup-portrait { transform:none; }
}
@media (max-width:380px) {
    .match-details-section .match-clips-grid { grid-template-columns:minmax(0,1fr) !important; }
    .match-detail-tabs .match-detail-tab { font-size:10px; }
}
@media (max-width: 768px) {
    html { overflow-x: clip; }
    body { min-width: 0; overflow-x: clip; }
    .container { width: 100%; max-width: 100%; padding-right: 16px !important; padding-left: 16px !important; }
    img, video, iframe { max-width: 100%; }

    .header-top { display: none; }
    /* Search suggestions must extend below the sticky header. */
    .header > .container { overflow: visible; }
    .player-search--header .player-search-field input { font-size: 16px; }
    .header-main {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) 48px !important;
        grid-template-rows: auto auto;
        gap: 10px 12px;
        padding: 10px 0 !important;
    }
    .header-main > .logo { grid-column: 1 !important; grid-row: 1 !important; min-width: 0; max-width: 100%; }
    .header-main > .header-actions { grid-column: 2 !important; grid-row: 1 !important; width: 48px !important; min-width: 48px; display: flex !important; align-items: center; justify-content: flex-end; }
    .header-main > .header-actions .mobile-menu-btn { display: inline-flex !important; flex: 0 0 44px; width: 44px; height: 44px; visibility: visible !important; }
    .header-main > .mobile-info-bar { display: none !important; }
    .header-main > .player-search--header {
        grid-column: 1 / -1 !important;
        grid-row: 2 !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
    }
    .player-search--header .player-search-field { min-height: 44px; }
    .player-search--header .player-search-results { max-height: min(60vh, 360px); overflow-y: auto; }
    .mobile-menu-btn, .header-actions button, .header-actions a { min-width: 44px; min-height: 44px; }

    .section, .featured-match-section { padding-top: 36px; padding-bottom: 40px; }
    .hero-content, .hero-text, .hero-standings-card { width: 100%; min-width: 0; max-width: 100%; }
    .hero-text p { width: 100%; min-width: 0; white-space: normal !important; overflow-wrap: anywhere; }
    .hero-content { display: grid !important; grid-template-columns: minmax(0, 1fr) !important; width: 100%; min-width: 0; gap: 24px; }
    .hero-actions { display: flex !important; flex-direction: column !important; align-items: stretch; width: 100%; min-width: 0; gap: 10px; }
    .hero-actions .btn { width: 100%; min-width: 0; white-space: normal; }
    .hero-text, .hero-text * { min-width: 0; max-width: 100%; }
    .section-header, .section-heading, .page-header, .league-hero-inner {
        max-width: 100%;
        min-width: 0;
    }
    .section-header h1, .section-header h2, .page-header h1, .league-hero h1 { overflow-wrap: anywhere; }
    .section-title { font-size: clamp(20px, 5vw, 27px); }

    .stats-grid, .teams-grid, .matches-grid, .video-grid, .kings-grid,
    .dashboard-grid, .availability-grid, .form-grid {
        grid-template-columns: minmax(0, 1fr) !important;
        min-width: 0;
        gap: 14px;
    }
    .card, .stat-card, .match-card, .team-card, .player-card, .video-card,
    .league-section, .availability-card { min-width: 0; max-width: 100%; }

    .page-header, .section-heading, .league-section-heading {
        align-items: flex-start !important;
        flex-wrap: wrap;
        gap: 12px;
    }
    .page-header p, .section-header h2, .section-header .count { width: 100%; max-width: 100%; white-space: normal !important; overflow-wrap: anywhere; }
    .league-hero-inner > div { width: 100%; min-width: 0; max-width: 100%; }
    .matches-page, .matches-section, .matches-grid, .page-header { width: 100%; min-width: 0; max-width: 100%; }
    .section-header { flex-wrap: wrap; }
    .page-header p, .hero p, .section-description { white-space: normal !important; overflow-wrap: anywhere; }
    .league-hero { padding: 35px 0 30px; }
    .league-hero-inner { flex-direction: column; align-items: flex-start; }
    .league-hero-meta { gap: 10px 14px; flex-wrap: wrap; }
    .league-picker { align-items: stretch; flex-direction: column; }
    .league-picker select { width: 100%; min-width: 0; min-height: 44px; }
    .league-section { padding: 16px; }

    .table-scroll, .table-container, .players-table-container,
    .matches-table-container, .table-responsive, .table-wrapper {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto !important;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
    }
    .standings-table { min-width: 780px; }
    .players-table { min-width: 640px; }
    .team-roster-section .players-table { min-width: 0; max-width: 100%; }
    .team-roster-section .players-table tbody { width: 100%; min-width: 0; }
    .team-roster-section .players-table tr { width: 100%; min-width: 0; gap: 6px; padding: 12px 10px; }
    .team-roster-section .players-table .stat-cell { padding: 8px 1px; font-size: 16px; }
    .team-roster-section .stat-cell::before {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 28px;
        max-width: 100%;
        font-size: 10px;
        line-height: 1.3;
        white-space: normal;
        text-align: center;
        overflow-wrap: anywhere;
    }
    .matches-table { min-width: 560px; }

    .fixture-card { min-width: 0; }
    .featured-match-section .live-match-card { max-width: 100%; }
    .featured-match-section .countdown-timer { max-width: 100%; flex-wrap: wrap; justify-content: center; }
    .featured-match-section .match-voting-container { min-width: 0; }
    .match-main, .match-teams { min-width: 0; }
    .timeline-content { min-width: 0; overflow-wrap: anywhere; }

    .matches-page .matches-grid { grid-template-columns: minmax(0, 1fr) !important; }
    .matches-page .match-card { width: 100%; min-width: 0; }
    .matches-page .match-card-body { gap: 6px; padding: 14px 10px; }
    .matches-page .match-team { flex: 1 1 0; min-width: 0; gap: 7px; }
    .matches-page .match-team.home { align-items: center; text-align: center; }
    .matches-page .match-team.away { align-items: center; text-align: center; }
    .matches-page .team-logo { flex: 0 0 42px; width: 42px; height: 42px; font-size: 14px; }
    .matches-page .team-name { width: 100%; max-width: 100%; overflow-wrap: anywhere; font-size: 12px; line-height: 1.25; }
    .matches-page .match-score { gap: 3px; padding: 8px 5px; }
    .matches-page .match-score span { min-width: 19px; font-size: 21px; }
    .matches-page .match-score .divider { min-width: 8px; font-size: 16px; }
    .matches-page .match-time-display { flex: 0 0 auto; padding: 7px 4px; }
    .matches-page .match-time-display .time { font-size: 19px; }
    .matches-page .match-card-header { gap: 6px; padding: 10px 11px; }
    .matches-page .match-date { min-width: 0; font-size: 11px; }
    .matches-page .match-status { padding: 4px 7px; font-size: 9px; }

    .match-page-header .container, .match-main { width: 100%; max-width: 100%; min-width: 0; }
    .match-main { justify-content: space-between; gap: 5px !important; }
    .match-main .match-team-box { flex: 1 1 0; width: 0; min-width: 0; padding: 6px 2px; }
    .match-main .match-score-box { flex: 0 0 76px; width: 76px; min-width: 0; }
    .match-main .match-team-box h2 { max-width: 100%; white-space: normal; overflow-wrap: anywhere; line-height: 1.2; }
    .match-main .team-label { overflow-wrap: anywhere; }

    .match-content { width: 100%; min-width: 0; gap: 5px; padding: 14px 10px; }
    .match-content .match-team { flex: 1 1 0; min-width: 0; gap: 5px; }
    .match-content .match-team .team-logo { flex: 0 0 36px; width: 36px; height: 36px; border-radius: 10px; }
    .match-content .match-team .team-name { min-width: 0; font-size: 11px; line-height: 1.2; overflow-wrap: anywhere; }
    .match-content .match-score-center { flex: 0 0 64px; min-width: 0; }
    .match-content .match-score-center .score { gap: 3px; font-size: 21px; }
    .match-content .match-time-display .time { font-size: 17px; }

    /* Keep profile and match detail layouts readable without page-level clipping. */
    .player-header-content, .player-header-content > *, .player-info,
    .team-header-content, .team-header-content > *, .team-info,
    .match-page-header, .match-page-header > *, .match-details-section,
    .match-detail-panel, .match-squad-team, .match-recent-team { width: 100%; max-width: 100%; min-width: 0; }
    .player-header-content, .team-header-content, .match-page-header .container,
    .match-page-header .match-main { flex-wrap: wrap; }
    .player-info h1, .team-info h1, .match-page-header h2 { overflow-wrap: anywhere; }
    .match-recent-teams, .match-availability-columns { grid-template-columns: minmax(0, 1fr) !important; }
    .match-detail-tabs { max-width: 100%; overflow-x: auto; }
    .match-detail-tab { flex: 0 0 auto; min-height: 44px; white-space: nowrap; }
    .match-clips-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    .match-squad-team > *, .match-recent-team > * { min-width: 0; max-width: 100%; }
    .player-statistics-heading { align-items: flex-start; flex-wrap: wrap; gap: 8px; }
    .player-statistics-heading > * { max-width: 100%; min-width: 0; }
    .team-stats-row { display: grid !important; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
    .team-stat { min-width: 0; }

    .player-header-content.player-profile-hero {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 14px !important;
        text-align: left !important;
    }
    .player-profile-hero > .player-avatar { flex: 0 0 76px; width: 76px !important; height: 76px !important; min-width: 76px !important; min-height: 76px !important; margin: 0 !important; }
    .player-profile-hero > .player-avatar { overflow: visible; }
    .player-profile-hero > .player-avatar > .jersey-number {
        top: auto;
        bottom: -30px;
        right: 50%;
        transform: translateX(50%);
        width: 32px;
        height: 24px;
        border-radius: 8px;
        font-size: 12px;
        line-height: 1;
        border-width: 2px;
    }
    .player-profile-hero > .player-profile-details { flex: 1 1 auto; width: auto !important; align-items: flex-start !important; margin: 0 !important; }
    .player-profile-details h1 { width: 100%; font-size: clamp(19px, 5.4vw, 25px) !important; text-align: left !important; overflow-wrap: anywhere; }
    .player-profile-details .player-meta { justify-content: flex-start !important; gap: 6px; }
    .player-profile-details .player-season { text-align: left; }

    /* Compact one-row player statistics on phones and tablets. */
    .player-statistics .stats-grid { grid-template-columns: repeat(6,minmax(0,1fr)) !important; gap: 7px !important; }
    .player-statistics .stat-card { display:flex; min-width:0; min-height:82px !important; flex-direction:column; align-items:center; justify-content:center; gap:3px; padding:7px 2px !important; text-align:center !important; border-radius:11px; }
    .player-statistics .stat-icon { position:static !important; display:grid; flex:0 0 20px; width:20px !important; height:20px !important; margin:0 !important; transform:none !important; border-radius:6px; font-size:10px !important; }
    .player-statistics .stat-value { margin:0 !important; font-size:16px !important; line-height:1.05; }
    .player-statistics .stat-label { margin:0 !important; font-size:8px !important; line-height:1.1; overflow-wrap:anywhere; }
    .player-statistics-heading { flex-direction:row !important; align-items:flex-end !important; justify-content:space-between; }
    .player-statistics-heading p { max-width:48%; text-align:right; font-size:11px !important; }

    .fixtures-grid { grid-template-columns: minmax(0, 1fr) !important; min-width: 0; }
    .fixtures-grid > .fixture-card { width: 100%; min-width: 0; padding: 14px; }
    .fixture-teams { min-width: 0; gap: 4px; }
    .fixture-team { flex: 1 1 0; min-width: 0; gap: 6px; }
    .fixture-team.away { flex-direction: row-reverse; }
    .fixture-team-logo { flex: 0 0 34px; width: 34px; height: 34px; font-size: 11px; }
    .fixture-team-info { min-width: 0; }
    .fixture-team-info h4 { max-width: 100%; font-size: 11px; overflow-wrap: anywhere; }
    .fixture-score { flex: 0 0 auto; gap: 3px; padding: 0 4px; }
    .fixture-score span { font-size: 19px; }
    .fixture-score .divider { font-size: 15px; }

    .player-tabs, .tabs-nav, .tab-navigation {
        display: flex !important;
        flex-direction: row !important;
        justify-content: flex-start;
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    .player-tab-button, .tab-btn { flex: 0 0 auto; min-width: max-content; min-height: 44px; }

    .hero-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: center; }
    .hero-metric { flex-direction: column; justify-content: center; gap: 4px; min-width: 0; text-align: center; }
    .hero-metric > span:last-child { justify-items: center; min-width: 0; text-align: center; }
    .hero-metric-divider { display: none; }
    .hero-metric small { white-space: normal; text-align: center; }

    input, select, textarea, button, .btn, .tab-btn, .player-tab-button {
        max-width: 100%;
        touch-action: manipulation;
    }
    input, select, textarea { font-size: 16px !important; }
    button, .btn, .nav a, .footer a { -webkit-tap-highlight-color: transparent; }
    .btn { min-height: 44px; }

    .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 22px 16px; }
    .footer-brand { grid-column: 1 / -1; }
    .footer-content { flex-direction: column; gap: 20px; }
}

/* Keep the mobile drawer outside the sticky header's containing block. */
@media (max-width: 992px) {
    .nav {
        position: fixed !important;
        inset: 0 auto 0 0 !important;
        width: min(82vw, 320px) !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;
        padding: calc(76px + env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom)) !important;
        z-index: 1101 !important;
        transform: translateX(-105%);
        transition: transform .28s ease;
        -webkit-overflow-scrolling: touch;
    }

    .nav.active {
        left: 0 !important;
        transform: translateX(0);
        display: flex !important;
    }

    .nav-overlay {
        position: fixed !important;
        inset: 0 !important;
        width: auto !important;
        height: auto !important;
        z-index: 1100 !important;
    }

    .nav-close { z-index: 1; }
}

@media (max-width: 480px) {
    .container { padding-right: 13px !important; padding-left: 13px !important; }
    .header-main { gap: 8px 10px; }
    .header-main > .header-actions { width: 44px !important; min-width: 44px; }
    .logo { gap: 8px; }
    .logo-icon { flex: 0 0 38px; width: 38px; height: 38px; }
    .logo-text span:first-child { font-size: 14px; }

    .hero { padding-top: 32px; padding-bottom: 32px; }
    .hero .hero-text h1 { font-size: clamp(35px, 10vw, 46px); }
    .hero-metrics { gap: 6px; }
    .hero-metric { gap: 5px; }
    .hero-metric small { white-space: normal; line-height: 1.1; }
    .hero-scorer-showcase { margin-top: 14px; padding: 14px 13px 10px; border-radius: 15px; }
    .hero-scorer-heading h2 { font-size: 15px; }
    .hero-scorer-row { min-height: 50px; gap: 8px; padding: 6px 4px; }
    .hero-scorer-avatar { flex-basis: 32px; width: 32px; height: 32px; }
    .hero-scorer-info strong { font-size: 11px; }
    .hero-scorer-goals { min-width: 38px; padding: 4px 6px; }
    .hero-metric-icon { width: 29px; height: 29px; flex-basis: 29px; }
    .hero-metric strong { font-size: 15px; }
    .hero-metric small { max-width: 100%; font-size: 8px; overflow-wrap: anywhere; }
    .match-main .match-score-box { flex-basis: 66px; width: 66px; }
    .match-main .match-team-box .team-logo { width: 46px; height: 46px; }
    .match-content .match-team .team-logo { flex-basis: 30px; width: 30px; height: 30px; font-size: 10px; }
    .match-content .match-score-center { flex-basis: 56px; }
    .fixtures-grid > .fixture-card { padding: 12px 10px; }
    .fixture-team { gap: 4px; }
    .fixture-team-logo { flex-basis: 30px; width: 30px; height: 30px; font-size: 10px; }
    .fixture-team-info h4 { font-size: 10px; }
    .fixture-score { gap: 2px; padding: 0 2px; }
    .fixture-score span { font-size: 17px; }
    .teams-page .team-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .teams-page .team-stat-item { min-width: 0; }
    .teams-page .team-stat-item .stat-value { font-size: 18px; }
    .teams-page .team-stat-item .stat-label { font-size: 9px; overflow-wrap: anywhere; }

    .league-section { padding: 13px; border-radius: 14px; }
    .fixture-card { border-radius: 10px; }
    .footer-grid { grid-template-columns: minmax(0, 1fr) !important; }
    .footer-brand { grid-column: auto; }

    .match-card-body { gap: 5px; }
    .match-tabs .tab-btn, .match-tab-nav .tab-btn { padding: 10px 12px; font-size: 13px; }
    .profile-tabs, .team-tabs { max-width: 100%; overflow-x: auto; }
    .match-clips-grid { grid-template-columns: minmax(0, 1fr) !important; }
    .team-stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .player-profile-hero > .player-avatar { flex-basis: 68px; width: 68px !important; height: 68px !important; min-width: 68px !important; min-height: 68px !important; }
    .player-profile-details h1 { font-size: 19px !important; }
    .player-statistics .stats-grid { gap: 4px !important; }
    .player-statistics .stat-card { min-height: 74px !important; padding: 5px 1px !important; }
    .player-statistics .stat-value { font-size: 14px !important; }
    .player-statistics .stat-label { font-size: 7px !important; }

    .video-modal { padding: 10px; }
    .video-modal-content { max-height: calc(100dvh - 20px); overflow-y: auto; }
    .video-modal-player iframe { width: 100%; aspect-ratio: 16 / 9; }
}

/* Keep each squad member and all five statistics on a single compact row. */
@media (max-width: 992px) {
    .team-roster-section .players-table tbody { gap: 6px; }
    .team-roster-section .players-table tr {
        grid-template-columns: 20px minmax(0, 1fr) repeat(5, minmax(0, 26px));
        align-items: center;
        gap: 3px;
        padding: 8px;
        border-radius: 10px;
    }
    .team-roster-section .players-table td { gap: 3px; padding: 2px 0; border-radius: 0; background: transparent; }
    .team-roster-section .players-table .jersey-cell,
    .team-roster-section .players-table .player-cell { grid-column: auto; padding: 0; }
    .team-roster-section .players-table .player-cell { align-items: stretch; }
    .team-roster-section .jersey-number { width: 22px; height: 24px; font-size: 10px; }
    .team-roster-section .team-roster-avatar { display: grid; flex: 0 0 26px; width: 26px; height: 26px; font-size: 9px; }
    .team-roster-section .team-roster-person { gap: 5px; }
    .team-roster-section .team-roster-name { font-size: 11px; gap: 3px; line-height: 1.3; }
    .team-roster-section .team-roster-mobile-position { font-size: 9px; margin-top: 3px; }
    .team-roster-section .captain-badge { padding: 1px 3px; font-size: 8px; }
    .team-roster-section .players-table .stat-cell { padding: 2px 0; font-size: 14px; }
    .team-roster-section .stat-cell::before { min-height: 22px; font-size: 8px; line-height: 1.2; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
