.mobile-channel-grid,
.mobile-channel-home {
  display: none;
}

@media (max-width: 1000px) {
  body {
    overflow-x: clip;
    margin: 0;
    padding: 0 clamp(10px, 3vw, 22px) 20px;
    font: 16px/1.45 Arial, sans-serif;
    overflow-wrap: anywhere;
  }

  .tv-layout {
    display: block;
    min-width: 0;
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
  }

  .tv-layout > tbody,
  .tv-layout > tbody > tr,
  .tv-layout > tbody > tr > td,
  .tv-columns > tbody,
  .tv-columns > tbody > tr,
  .tv-columns > tbody > tr > td {
    display: block;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .tv-layout table {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
  }
  .tv-layout img { max-width: 100%; height: auto; }
  .tv-layout iframe, .tv-layout video, .tv-layout object { max-width: 100% !important; }

  .tv-layout > tbody > tr:first-child table:first-child > tbody > tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    column-gap: 12px;
    padding-top: 6px;
  }

  .tv-layout > tbody > tr:first-child table:first-child > tbody > tr > td {
    width: auto;
    text-align: center;
  }

  .tv-layout > tbody > tr:first-child table:first-child td:has(h1) {
    flex: 1 0 100%;
    order: 1;
  }

  .tv-layout h1 {
    margin: 4px 0 6px;
    font-size: clamp(22px, 5vw, 30px);
    line-height: 1.2;
  }

  .tv-columns > tbody > tr.tv-content-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .tv-columns > tbody > .tv-content-row > td:nth-child(2) { order: -2; }
  .tv-columns > tbody > .tv-content-row > td:nth-child(3) { order: -1; }
  .tv-home .tv-columns > tbody > tr:first-child > td:not(:nth-child(2)) { display: none; }

  .tv-player {
    display: block;
    width: min(100%, var(--player-width)) !important;
    height: auto !important;
    aspect-ratio: var(--player-ratio);
    margin: 0 auto;
    border: 0;
    background: #000;
  }

  .tv-layout #channel-epg { width: 100%; }

  .tv-layout .media-wrapper,
  .tv-layout .mejs__container,
  .tv-layout .mejs__layer,
  .tv-layout .mejs__mediaelement video {
    max-width: 100%;
  }

  .tv-layout .mejs__container {
    width: min(100%, 480px) !important;
    height: auto !important;
    aspect-ratio: 480 / 310;
    margin: 0 auto;
  }

  .tv-layout .mejs__inner,
  .tv-layout .mejs__layers,
  .tv-layout .mejs__layer,
  .tv-layout .mejs__mediaelement video {
    width: 100% !important;
    height: 100% !important;
  }

  .mobile-channel-home {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 14px;
    color: #153a70;
    font-weight: bold;
  }

  .tv-layout .link_img {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    margin: 6px 0;
  }

  .tv-layout .link_img a {
    display: inline-flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
  }

  .tv-desktop-directory { display: none; }

  .mobile-channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
    gap: 8px;
    margin: 8px 0 14px;
    text-align: left;
  }

  .mobile-channel-grid a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    box-sizing: border-box;
    min-height: 50px;
    border: 1px solid #bcd6e3;
    border-radius: 8px;
    background: #fff;
    color: #173759;
    font-weight: bold;
    line-height: 1.25;
    text-decoration: none;
  }

  .mobile-channel-grid img {
    width: 30px;
    height: 24px;
    object-fit: contain;
    flex: none;
  }

  .mobile-channel-grid a:focus-visible,
  .mobile-channel-home:focus-visible {
    outline: 2px solid #145c98;
    outline-offset: 2px;
  }

  .tv-layout table[width="95%"] > tbody > tr > td[width="20%"] {
    display: inline-block;
    width: auto;
    min-width: 90px;
    margin: 4px;
  }
}
