@layer tvoiResponsive {
  /* Use the available viewport, including Split View, instead of device names. */
  html[data-tvoi-pro] .browser-screen .hockey-app > .bottom-navigation {
    box-sizing: border-box !important;
    align-items: center !important;
    gap: 0 !important;
    padding-inline: 4px !important;
  }

  html[data-tvoi-pro] .browser-screen .hockey-app > .bottom-navigation > button {
    flex: 1 1 0% !important;
    min-inline-size: 0 !important;
    min-block-size: 44px !important;
    padding-inline: 2px !important;
  }

  html[data-tvoi-pro] .browser-screen .bottom-navigation > button > span:not(.fh-icon):not(.account-unread-badge) {
    padding-inline: 0 !important;
    text-overflow: ellipsis !important;
  }

  @media (orientation: portrait) and (max-width: 639px) {
    html[data-tvoi-pro] .browser-screen .bottom-navigation > button > span:not(.fh-icon):not(.account-unread-badge) {
      inline-size: 100% !important;
      text-align: center !important;
    }
  }

  @media (max-width: 359px) {
    html[data-tvoi-pro] .browser-screen .hockey-app > .bottom-navigation > button {
      font-size: 10px !important;
      letter-spacing: normal !important;
    }
  }

  @media (min-width: 640px) and (min-height: 601px) {
    html[data-tvoi-pro] .browser-screen .hockey-app.fidelity-mobile {
      --phone-navigation-height: 64px !important;
      --pro-content: 1160px !important;
      --pro-gutter: clamp(20px, 3vw, 40px) !important;
      --tablet-document-width: 1240px;
      --tablet-reading-width: 820px;
    }

    html[data-tvoi-pro] .browser-screen .hockey-app > .match-appbar {
      padding-inline: var(--pro-gutter) !important;
    }

    html[data-tvoi-pro] .browser-screen .hockey-app .match-content {
      box-sizing: border-box !important;
      inline-size: 100% !important;
      max-inline-size: var(--tablet-document-width) !important;
      margin-inline: auto !important;
      padding-inline: var(--pro-gutter) !important;
    }

    html[data-tvoi-pro] .browser-screen .hockey-app .match-content > :is(
      .source-scout-search, .pro-scout-home, .source-scout-home,
      .working-playlists, .source-playlists, .source-account,
      .source-notifications, .source-uploads
    ) {
      box-sizing: border-box !important;
      inline-size: 100% !important;
      max-inline-size: var(--tablet-reading-width) !important;
      margin-inline: auto !important;
    }

    html[data-tvoi-pro] .browser-screen .hockey-app .match-content.is-native-player-page {
      max-inline-size: 1360px !important;
    }

    html[data-tvoi-pro] .browser-screen .hockey-app .home-review > section {
      grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
      gap: 12px !important;
    }

    html[data-tvoi-pro] .browser-screen .hockey-app > .bottom-navigation {
      padding-inline: max(8px, calc((100% - 672px) / 2)) !important;
    }

    html[data-tvoi-pro] .browser-screen .hockey-app > .bottom-navigation > button {
      block-size: 56px !important;
      align-items: center !important;
      justify-content: center !important;
      flex-direction: row !important;
      gap: 8px !important;
      padding: 0 8px !important;
      font-size: 14px !important;
    }

    html[data-tvoi-pro] .browser-screen .hockey-app > .bottom-navigation > button .fh-icon {
      inline-size: 23px !important;
      block-size: 23px !important;
    }

    html[data-tvoi-pro] .browser-screen .bottom-navigation > button > span:not(.fh-icon):not(.account-unread-badge) {
      flex: 0 1 90px !important;
      min-inline-size: 0 !important;
      text-align: start !important;
    }

    html[data-tvoi-pro] .browser-screen .hockey-app > .bottom-navigation > button::before {
      inline-size: calc(100% - 10px) !important;
      block-size: 44px !important;
      margin-top: -22px !important;
    }

    html[data-tvoi-pro] .browser-screen :is(.bottom-sheet, .phone-native-sheet, .phone-map-host-sheet, .phone-map-legend-host-sheet) {
      box-sizing: border-box !important;
      width: min(560px, calc(100% - 32px)) !important;
      max-width: 560px !important;
      left: 0 !important;
      right: 0 !important;
      margin-inline: auto !important;
    }
  }

  @media (min-width: 1100px) and (min-height: 601px) {
    html[data-tvoi-pro] .browser-screen .hockey-app .home-review > section {
      grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
  }

  @media (orientation: landscape) and (min-width: 640px) and (max-height: 600px) {
    html[data-tvoi-pro] .browser-screen .hockey-app > .bottom-navigation {
      padding-inline: max(6px, calc((100% - 640px) / 2)) !important;
    }
  }

  @media (orientation: landscape) and (min-width: 500px) and (max-height: 600px) {
    html[data-tvoi-pro] .browser-screen .bottom-navigation > button > span:not(.fh-icon):not(.account-unread-badge) {
      flex: 0 1 76px !important;
      min-inline-size: 0 !important;
      text-align: start !important;
    }
  }
}

@layer tvoiResponsive {
  .working-player-table .player-comparison-table th[data-column],
  .working-player-table .player-comparison-table tbody tr[data-table-player] > td {
    --actions-column-width: max(154px, calc(var(--player-column-width, 112px) + 24px));
    width: var(--actions-column-width) !important;
    min-width: var(--actions-column-width) !important;
    max-width: var(--actions-column-width) !important;
  }

  .working-player-table .player-comparison-table :is(th[data-column], td).is-short {
    --actions-column-width: 80px;
  }

  .working-player-table .player-comparison-table :is(th[data-column], td).is-time {
    --actions-column-width: max(104px, var(--player-column-width, 96px));
  }

  .working-player-table .player-comparison-table .player-comparison-person {
    width: clamp(142px, 36vw, 215px) !important;
    min-width: clamp(142px, 36vw, 215px) !important;
    max-width: clamp(142px, 36vw, 215px) !important;
  }

  .player-comparison-table thead th[data-column] {
    padding-block: 4px !important;
  }

  .player-comparison-table thead th[data-column] > .player-comparison-sort {
    box-sizing: border-box;
    min-height: calc(5.2em + 15px) !important;
    justify-content: flex-end !important;
    gap: 3px !important;
  }

  .player-comparison-table thead th[data-column] > .player-comparison-sort > span {
    flex: 0 0 auto !important;
    line-height: 1.3 !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    hyphens: none !important;
  }

  .working-player-table .player-comparison-table tbody tr[data-table-player] > :is(th, td) {
    height: 68px !important;
    white-space: nowrap !important;
  }

  .working-player-table .player-comparison-identity {
    box-sizing: border-box;
    min-height: 67px !important;
    padding-block: 4px !important;
  }

  .working-player-table .player-comparison-identity > span:last-child {
    gap: 1px !important;
  }

  .working-player-table .player-comparison-identity small {
    line-height: 12px !important;
  }

  .working-player-table .player-comparison-identity strong {
    display: -webkit-box !important;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 16px !important;
  }

  .working-player-table .player-comparison-identity em {
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 12px !important;
  }
}

@layer tvoiResponsive {
  /* Check both screen axes so a phone turning sideways keeps its own layout. */
  @media (any-pointer: coarse) and (min-device-width: 600px) and (min-device-height: 600px) and (min-width: 640px) and (min-height: 601px) {
    html[data-tvoi-pro] .browser-screen .hockey-app.fidelity-mobile {
      --phone-navigation-height: 52px !important;
    }

    html[data-tvoi-pro] .browser-screen .hockey-app.fidelity-mobile > .bottom-navigation {
      bottom: 0 !important;
      align-items: flex-end !important;
    }

    html[data-tvoi-pro] .browser-screen .hockey-app.fidelity-mobile > .bottom-navigation > button {
      block-size: 48px !important;
      padding-block-start: 14px !important;
    }

    html[data-tvoi-pro] .browser-screen .hockey-app.fidelity-mobile > .bottom-navigation > button::before {
      top: calc(50% + 7px) !important;
      block-size: 32px !important;
      margin-top: -16px !important;
    }
  }
}

@layer tvoiResponsive {
  html[data-tvoi-pro][data-tvoi-tablet-reserved-bottom] .browser-screen .hockey-app.fidelity-mobile:has(> .bottom-navigation) {
    --app-safe-bottom: max(0px, calc(env(safe-area-inset-bottom, 0px) - 8px - var(--tvoi-tablet-reserved-bottom, 0px))) !important;
  }
}

@layer tvoiResponsive {
  @supports (mask-composite: intersect) {
    html[data-tvoi-pro][data-tvoi-tablet-reserved-bottom]:not([data-tvoi-color-mode="dark"]) .browser-screen :is(.sheet-overlay, .phone-link-share-overlay) {
      --tvoi-sheet-screen-mask: linear-gradient(to bottom, transparent 0, rgba(0, 0, 0, .45) calc(env(safe-area-inset-top, 0px) + 40px), #000 calc(env(safe-area-inset-top, 0px) + 150px));
      --tvoi-sheet-bottom-mask: linear-gradient(to top, transparent 2px, #000 clamp(24px, var(--tvoi-tablet-reserved-bottom), 48px));
      mask-image: var(--tvoi-sheet-screen-mask), var(--tvoi-sheet-bottom-mask) !important;
      mask-composite: intersect !important;
    }

    @media (orientation: landscape) {
      html[data-tvoi-pro][data-tvoi-tablet-reserved-bottom]:not([data-tvoi-color-mode="dark"]) .browser-screen :is(.sheet-overlay, .phone-link-share-overlay) {
        --tvoi-sheet-screen-mask: linear-gradient(to right, transparent 0, #000 calc(env(safe-area-inset-left, 0px) + 72px), #000 calc(100% - env(safe-area-inset-right, 0px) - 72px), transparent 100%);
      }
    }
  }
}

@layer tvoiResponsive {
  /* A phone stays a phone when its longer screen axis becomes horizontal. */
  @media (any-pointer: coarse) and (max-device-width: 599px),
         (any-pointer: coarse) and (max-device-height: 599px) {
    html[data-tvoi-pro] .browser-screen:not([data-phone-keyboard-open]) .hockey-app.fidelity-mobile:not([data-keyboard-visible="true"]):not(:has(.is-native-player-page)) {
      --tvoi-phone-tab-inset: max(4px, env(safe-area-inset-bottom, 0px));
    }

    html[data-tvoi-pro] .browser-screen .hockey-app.fidelity-mobile > :is(.bottom-navigation, .primary-area, .toast, .phone-back-gesture-edge) {
      --app-safe-bottom: var(--tvoi-phone-tab-inset, max(0px, env(safe-area-inset-bottom, 0px) - 8px)) !important;
    }

    html[data-tvoi-pro] .browser-screen:not([data-phone-keyboard-open]) .hockey-app.fidelity-mobile:has(> .bottom-navigation):not([data-keyboard-visible="true"]):not(:has(.is-native-player-page)) > .match-scroll {
      bottom: calc(var(--phone-navigation-height) + var(--tvoi-phone-tab-inset) + var(--app-bottom-action, 0px)) !important;
    }
  }
}
