/* Fix92 — isolated trainer + arena layout repair. No changes to their game engines. */
@media (max-width: 900px) {
  /* The R64 dashboard remained above each selected trainer subsection. */
  #trainer.r64-active-page:has(.trSection:not(.hidden)) #r64t6Dashboard,
  #trainer.r64-active-page:has(.trSection:not(.hidden)) .r64t6Dashboard { display: none !important; }
  #trainer.r64-active-page > .note,
  #trainer.r64-active-page > .subtabs,
  #trainer.r64-active-page > .head,
  #trainer.r64-active-page .trSection:not(.hidden) > .r59SectionHead { display: none !important; }
  body.sa83Inner #trainer.sa83Content {
    box-sizing: border-box !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    padding: calc(66px + env(safe-area-inset-top, 0px)) 12px calc(22px + env(safe-area-inset-bottom, 0px)) !important;
  }
  #trainer.r64-active-page .trSection:not(.hidden) {
    overflow: visible !important;
    max-height: none !important;
    height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  #trainer.r64-active-page .trSection:not(.hidden) .tablewrap { overflow-x: auto !important; }
  /* Arena: reserve room for the one fixed title/back bar, never overlap top tabs. */
  body.sa83Inner #r56ArenaPage.sa83Content:not(.hidden) {
    box-sizing: border-box !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    min-height: 0 !important;
    width: 100% !important;
    padding: calc(66px + env(safe-area-inset-top, 0px)) 10px calc(10px + env(safe-area-inset-bottom, 0px)) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }
  #r56ArenaPage .sa82ArenaNav {
    display: flex !important;
    flex: 0 0 auto !important;
    flex-direction: column !important;
    gap: 7px !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 2px 0 8px !important;
    overflow: visible !important;
  }
  #r56ArenaPage #r56ArenaTabs {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    width: 100% !important;
    gap: 6px !important;
    overflow: visible !important;
  }
  #r56ArenaPage #r56ArenaTabs button {
    min-height: clamp(53px, 15vw, 75px) !important;
    padding: 7px 3px !important;
    font-size: clamp(11px, 3.2vw, 15px) !important;
    line-height: 1.2 !important;
    white-space: normal !important;
  }
  #r56ArenaPage .sa82ArenaNav > .saFix03Open { min-height: 44px !important; }
  #r56ArenaPage #r56ArenaStatus { flex: 0 0 auto; }
  #r56ArenaPage #r56ArenaBody {
    box-sizing: border-box !important;
    min-height: 0 !important;
    flex: 1 1 auto !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 10px !important;
    scrollbar-gutter: stable;
  }
  /* In a live duel, keep its own question controls in view rather than moving the whole page. */
  #r56ArenaPage.sa92MatchLive #r56ArenaBody {
    overflow-y: hidden !important;
    display: flex !important;
    flex-direction: column !important;
  }
  #r56ArenaPage.sa92MatchLive #r56ArenaBody .r56Match {
    min-height: 0 !important;
    flex: 1 1 auto !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
  }
  #r56ArenaPage.sa92MatchLive .r56Question {
    min-height: 0 !important;
    flex: 1 1 auto !important;
    padding: 8px !important;
    margin-top: 5px !important;
  }
  #r56ArenaPage .r56CodeJoin input, #r56ArenaPage .r56Search input,
  #r56ArenaPage .r56Form select { min-width: 0 !important; max-width: 100% !important; }
  #r56ArenaPage .r56Panel { min-width: 0 !important; }
}
@media (max-width: 360px) {
  #r56ArenaPage #r56ArenaTabs button { min-height: 49px !important; }
  #r56ArenaPage .sa82ArenaNav { gap: 5px !important; }
}
