/* The first menu tap must not wait for images or the theme's window.load hook. */
@media (max-width: 767px) {
  body.td-menu-mob-open-menu #td-mobile-nav,
  body.td-menu-mob-open-menu #td-mobile-nav .td-mobile-container,
  body.td-menu-mob-open-menu .td-menu-background {
    visibility: visible !important;
  }
  #td-mobile-nav .td-mobile-content .sub-menu,
  body.td-menu-mob-open-menu #td-mobile-nav .td-mobile-container {
    transition: none !important;
  }
}

@media (max-width: 1023px) {
  /* Navigation stays entirely visible, including season and date selectors. */
  body :is(nav[aria-label="Разделы главных новостей"],.ss-hp-v1__tabs,.ss-hockey-v1__tabs,.ss-rpl-v1__tabs,.ss-ucl-v1__tabs,
    .ss-league-sections-v1__section-nav,.ss-league-sections-v1__seasons,.ss-sports-desk__leagues,
    .ss-live-center-v1__filters,.ss-tools__tabs,.ss-pg__nav,.ss-world-cup-v1__tabs,
    .ss-authors-directory-v1__filters,.ss-bookmakers-v1__sort-tabs,.ss-hockey-transfer-preview-v1__leaders) {
    display:flex !important;
    flex-wrap:wrap !important;
    overflow:visible !important;
    white-space:normal !important;
    height:auto !important;
    max-height:none !important;
    min-width:0 !important;
    max-width:100% !important;
    gap:6px !important;
  }
  body :is(nav[aria-label="Разделы главных новостей"],.ss-hp-v1__tabs,.ss-hockey-v1__tabs,.ss-rpl-v1__tabs,.ss-ucl-v1__tabs,
    .ss-league-sections-v1__section-nav,.ss-league-sections-v1__seasons,.ss-sports-desk__leagues,
    .ss-live-center-v1__filters,.ss-tools__tabs,.ss-pg__nav,.ss-world-cup-v1__tabs,
    .ss-authors-directory-v1__filters,.ss-bookmakers-v1__sort-tabs) > :is(a,button,span) {
    min-width:0 !important;
    max-width:100% !important;
    white-space:normal !important;
    overflow-wrap:anywhere;
    flex:0 1 auto !important;
    line-height:1.4 !important;
    padding:8px 10px !important;
  }
  /* Reflow editorial rails rather than clipping cards or hiding scrollbars. */
  body :is(.ss-entity-news__grid,.ss-sports-desk__rail,.ss-ucl-v1__news-track,
    .ss-hockey-v1__news-track,.ss-live-center-v1__track,.td-big-grid-scroll,
    .td-big-grid-flex-scroll-holder) {
    display:grid !important;
    grid-auto-flow:row !important;
    grid-template-columns:repeat(auto-fit,minmax(min(100%,240px),1fr)) !important;
    grid-auto-columns:auto !important;
    overflow:visible !important;
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    height:auto !important;
    gap:12px !important;
    transform:none !important;
  }
  body :is(.ss-entity-news__grid,.ss-sports-desk__rail,.ss-ucl-v1__news-track,
    .ss-hockey-v1__news-track,.ss-live-center-v1__track,.td-big-grid-scroll,
    .td-big-grid-flex-scroll-holder) > * {
    width:auto !important;
    min-width:0 !important;
    max-width:100% !important;
    grid-column:auto !important;
  }
  body [data-ss-mobile-table-wrap] {
    overflow:visible !important;
    min-width:0 !important;
    max-width:100% !important;
  }
  body table[data-ss-mobile-table] {
    display:block !important;
    width:100% !important;
    min-width:0 !important;
    max-width:100% !important;
  }
  body table[data-ss-mobile-table] > thead {
    position:absolute !important;
    width:1px !important;
    height:1px !important;
    overflow:hidden !important;
    clip-path:inset(50%);
  }
  body table[data-ss-mobile-table] > :is(tbody,tfoot) {
    display:block !important;
    width:100% !important;
  }
  body table[data-ss-mobile-table] > :is(tbody,tfoot) > tr {
    display:grid !important;
    grid-template-columns:repeat(2,minmax(0,1fr)) !important;
    gap:10px 16px !important;
    width:100% !important;
    padding:14px 10px !important;
    border-bottom:1px solid #dfe5df !important;
    box-sizing:border-box;
  }
  body table[data-ss-mobile-table] > :is(tbody,tfoot) > tr > :is(td,th) {
    display:flex !important;
    flex-direction:column;
    align-items:flex-start !important;
    gap:4px;
    position:static !important;
    width:auto !important;
    min-width:0 !important;
    max-width:100% !important;
    height:auto !important;
    padding:0 !important;
    border:0 !important;
    white-space:normal !important;
    overflow:visible !important;
    overflow-wrap:anywhere;
    font-size:13px !important;
    line-height:1.45 !important;
    text-align:left !important;
  }
  body table[data-ss-mobile-table] [data-ss-cell-label]::before {
    content:attr(data-ss-cell-label);
    color:#556055;
    font-size:11px;
    font-weight:600;
    line-height:1.4;
  }
  body table[data-ss-mobile-table] [data-ss-cell-main] { grid-column:1 / -1 !important; }
  body table[data-ss-mobile-table] :is(td,th) :is(a,span,strong) {
    min-width:0;
    max-width:100%;
    white-space:normal !important;
    overflow-wrap:anywhere;
  }
  /* Preserve application filters instead of overriding their hidden state. */
  body table[data-ss-mobile-table] > :is(tbody,tfoot) > tr[hidden],
  body table[data-ss-mobile-table] > :is(tbody,tfoot) > tr[style*="display: none"],
  body table[data-ss-mobile-table] > :is(tbody,tfoot) > tr[style*="display:none"],
  body table[data-ss-mobile-table] > :is(tbody,tfoot) > tr > [hidden] {
    display:none !important;
  }
}

/* Mobile navigation uses shared icon centers rather than font baselines. */
@media (max-width: 767px) {
  body #td-top-mobile-toggle a,
  body .header-search-wrap #td-header-search-button-mob {
    display:flex !important;
    align-items:center;
    justify-content:center;
    height:54px !important;
  }
  body #td-top-mobile-toggle a { width:64px !important; }
  body .header-search-wrap #td-header-search-button-mob { width:56px !important; }
  body #td-top-mobile-toggle i,
  body .header-search-wrap :is(.td-icon-search,.td-icon-search-mobile) {
    display:flex !important;
    align-items:center;
    justify-content:center;
    position:static !important;
    width:24px !important;
    height:24px !important;
    padding:0 !important;
    margin:0 !important;
    font-size:24px !important;
    line-height:24px !important;
    transform:none !important;
  }
  body #td-top-mobile-toggle i::before,
  body .header-search-wrap :is(.td-icon-search,.td-icon-search-mobile)::before {
    display:block;
    width:24px;
    height:24px;
    line-height:24px;
  }
  body #td-mobile-nav .td-mobile-close {
    display:flex;
    align-items:center;
    justify-content:center;
    top:18px !important;
    right:20px !important;
    width:44px !important;
    height:44px !important;
  }
  body #td-mobile-nav .td-mobile-close > span {
    display:flex;
    align-items:center;
    justify-content:center;
    width:44px;
    height:44px;
  }
  body #td-mobile-nav .td-mobile-close i {
    position:static !important;
    top:auto !important;
    display:block;
    width:19px !important;
    height:19px !important;
    margin:0 !important;
    font-size:19px !important;
    line-height:19px !important;
  }
  body #td-mobile-nav .td-mobile-close i::before {
    display:block;
    width:19px;
    height:19px;
    line-height:19px;
  }
  body #td-mobile-nav .td-mobile-main-menu > li.ss-other-header-nav-v2 > a {
    padding:12px 30px 12px 12px !important;
    margin:0 !important;
    text-align:left !important;
  }
}
