/* Tall touch screens already use the mobile menu pager rules in sports-ui.css.
   This companion covers landscape handhelds whose width misses that breakpoint. */
@media (min-width: 760px) and (max-height: 600px) {
  #game #overlay.short-menu-pages {
    box-sizing: border-box;
    padding: calc(env(safe-area-inset-top, 0px) + 54px) 16px calc(66px + env(safe-area-inset-bottom, 0px));
    touch-action: manipulation;
  }

  #game #overlay.short-menu-pages > .panel {
    box-sizing: border-box;
    width: min(100%, 1100px);
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden !important;
    justify-content: flex-start !important;
  }

  #game #overlay.short-menu-pages .mobile-page-branch {
    display: flex !important;
    flex: none !important;
    flex-direction: column !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }

  #game #overlay.short-menu-pages > .panel [data-mobile-page-hidden] {
    display: none !important;
  }

  #game #overlay.short-menu-pages .mobile-page-branch > * {
    flex-shrink: 0 !important;
  }

  #game #overlay.short-menu-pages .mobile-menu-pager {
    position: absolute;
    right: 24px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    left: 24px;
    z-index: 10;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 72px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 6px;
    border: 1px solid #829ba7;
    border-radius: 14px;
    background: #142d3f;
  }

  #game #overlay.short-menu-pages .mobile-menu-pager button {
    min-height: 42px;
    margin: 0;
    padding: 8px 12px;
    font-size: 14px;
    line-height: 20px;
    touch-action: manipulation;
  }

  #game #overlay.short-menu-pages .mobile-menu-pager span {
    color: #f4f7fa;
    font-size: 13px;
    text-align: center;
  }

}

/* Keep the first-launch ruleset choices visible on short, narrow landscape
   viewports that are too small for the 650px-wide desktop layout. */
@media (min-width: 520px) and (max-width: 649px) and (max-height: 450px) {
  #game #overlay > .panel:has(.rs-welcome) {
    width: 100%;
    max-width: 100%;
    padding: 8px 10px;
  }

  #game #overlay .rs-welcome {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 6px 10px;
    text-align: left;
  }

  #game #overlay .rs-head {
    grid-column: 1;
    grid-row: 1;
    align-self: end;
  }

  #game #overlay .rs-welcome .eyebrow {
    margin: 0 0 4px 4px !important;
  }

  #game #overlay .rs-welcome h1 {
    font-size: clamp(24px, 5vw, 30px) !important;
  }

  #game #overlay .rs-foot {
    grid-column: 1;
    grid-row: 2;
    align-self: start;
    gap: 4px;
  }

  #game #overlay .rs-welcome .rs-status {
    display: none;
  }

  #game #overlay .rs-foot > .compact-help {
    display: none;
  }

  #game #overlay .rs-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px 6px;
  }

  #game #overlay .rs-actions button {
    box-sizing: border-box;
    height: 44px;
    min-width: 0;
    min-height: 44px;
    padding: 6px 8px;
    font-size: 12px !important;
    line-height: 1.1;
  }

  #game #overlay .rs-cards {
    grid-column: 2;
    grid-row: 1 / 3;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  #game #overlay .rs-welcome .rs-copy {
    gap: 2px;
    padding: 5px 6px 7px;
  }

  #game #overlay .rs-welcome .rs-copy small {
    font-size: 10px;
  }

  #game #overlay .rs-welcome .rs-copy b {
    font-size: 22px;
  }

  #game #overlay .rs-welcome .rs-copy > span {
    font-size: 10px;
    line-height: 1.15;
  }
}

@media (min-width: 760px) and (max-height: 600px) {
  #game #overlay.short-menu-pages.release-notes-panel > .panel .rn-shell {
    height: calc(100% - 60px) !important;
    max-height: calc(100% - 60px) !important;
  }
}

@media (orientation: landscape) and (max-height: 600px) {
  html,
  body {
    height: 100%;
    min-height: 0;
    overflow: hidden !important;
  }

  #game {
    height: var(--app-height, 100dvh) !important;
    min-height: 0 !important;
    max-height: var(--app-height, 100dvh);
  }
}

@media (max-width: 759px), (max-height: 600px) {
  /* The generic short-menu branch selector repeats #overlay and otherwise
     turns this purpose-built notes grid back into a flex column. */
  #game #overlay#overlay.release-notes-panel.mobile-pages > .panel .rn-shell {
    display: grid !important;
    flex: 1 1 auto !important;
    height: calc(100% - 60px) !important;
    min-height: 0 !important;
    max-height: calc(100% - 60px) !important;
    grid-template-rows: auto minmax(0, 1fr) auto !important;
  }

  #game #overlay#overlay.release-notes-panel.mobile-pages .rn-history {
    display: block !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  #game #overlay.release-notes-panel.mobile-pages .rn-scroll-hint,
  #game #overlay.release-notes-panel.mobile-pages #rn-newer,
  #game #overlay.release-notes-panel.mobile-pages #rn-older {
    display: none !important;
  }

  #game #overlay#overlay.release-notes-panel.mobile-pages .rn-footer {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
  }
}
