/* RUINROLL · 95-compact.css — bv55 (playtest findings). Loaded last.
   1) Phones with a short viewport (a 6.1–6.4" phone in a browser with its bars showing, ≈ 300–350 px tall):
      panels that were designed for 390 px clipped their own content (Power Lab titles, the Journey PLAY button,
      character cards) and the home screen overlapped its own buttons. These rules make the content scroll and
      shrink instead of being cut off.
   2) All phones: the GPS map no longer sits right above the MOVE joystick, and the HUD is a little smaller.
   Edit here, not in the screen files: these rules deliberately win by load order. */

/* ---------- all phones (landscape, up to 470 px tall) ---------- */
@media (max-height: 470px) {
  /* GPS map: smaller and tucked under the player panel, well above the joystick */
  html body #miniMap {
    width: clamp(64px, 21vh, 96px) !important;
    height: clamp(64px, 21vh, 96px) !important;
    top: calc(env(safe-area-inset-top) + clamp(60px, 17vh, 76px)) !important;
    left: max(8px, calc(env(safe-area-inset-left) + 4px)) !important;
  }
  html body #miniMap.full {
    width: clamp(140px, 46vh, 190px) !important;
    height: clamp(140px, 46vh, 190px) !important;
  }
  html body #miniMap .mmTag { font-size: 7px; }
  /* settings: the list must scroll on every phone */
  html body #homeSettingsPanel { height: 100%; max-height: 100dvh; }
  html body #homeSettingsPanel .setBody {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y !important;
    padding-bottom: 24px;
  }
}

/* ---------- short viewport: browser bars showing on a 6.1–6.4" phone ---------- */
@media (max-height: 350px) {
  /* HOME: no tagline, tighter buttons, no overlap between CTA and daily card */
  html body#rr-app.rr-ui #menu .mainCTA h2 { display: none !important; }
  html body#rr-app.rr-ui #menu .mainCTA { top: 23% !important; gap: 4px !important; }
  html body#rr-app.rr-ui #menu .mainCTA #homePlay button,
  html body#rr-app.rr-ui #menu .mainCTA > button,
  html body#rr-app.rr-ui #menu #quickDuelBtn {
    min-height: 30px !important;
    height: 30px !important;
    padding: 2px 10px !important;
    font-size: 12px !important;
  }
  html body#rr-app.rr-ui #menu .mainCTA #homePlay button small,
  html body#rr-app.rr-ui #menu #quickDuelBtn small { display: none !important; }
  html body#rr-app.rr-ui #menu .dailyCard { transform: scale(.78); transform-origin: top right; margin-top: 2px !important; }
  html body#rr-app.rr-ui #menu .heroText { top: 12% !important; }
  html body #rrNexusHome { min-height: 30px !important; padding: 2px 8px !important; }

  /* VILLAIN VAULT: pages scroll, cards keep their natural height, titles never clipped */
  html body#rr-app.rr-ui #shopPanel .shopPage {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y !important;
    max-height: calc(100dvh - 96px);
    padding-bottom: 10px;
  }
  html body#rr-app.rr-ui #shopPanel #upgradeGrid,
  html body#rr-app.rr-ui #shopPanel #fortressGrid,
  html body#rr-app.rr-ui #shopPanel #boostShop {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: stretch !important;
    align-content: flex-start !important;
    gap: 6px !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: visible !important;
  }
  html body#rr-app.rr-ui #shopPanel #upgradeGrid > *,
  html body#rr-app.rr-ui #shopPanel #fortressGrid > *,
  html body#rr-app.rr-ui #shopPanel #boostShop > * { flex: 1 1 30% !important; min-width: 150px !important; }
  html body#rr-app.rr-ui #shopPanel .shopPage > * { max-height: none !important; }
  html body#rr-app.rr-ui #shopPanel .techCard {
    grid-template-rows: auto auto auto auto auto !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    align-content: start !important;
    padding: 5px 7px !important;
    gap: 3px !important;
  }
  html body#rr-app.rr-ui #shopPanel .techCard .techIcon { max-height: 28px !important; height: 28px !important; }
  html body#rr-app.rr-ui #shopPanel .techCard .techHead b { font-size: 11px !important; line-height: 1.1 !important; white-space: normal !important; }
  html body#rr-app.rr-ui #shopPanel #skinsGrid {
    grid-auto-rows: auto !important;
    overflow: visible !important;
  }
  html body#rr-app.rr-ui #shopPanel #skinsGrid .skinCard,
  html body#rr-app.rr-ui #shopPanel #skinsGrid > * { min-height: 0 !important; height: auto !important; }
  html body#rr-app.rr-ui #shopPanel .vaultCharacters { max-height: calc(100dvh - 96px); overflow-y: auto !important; }
  html body#rr-app.rr-ui #shopPanel .shopSections button { min-height: 24px !important; font-size: 9px !important; padding: 2px 6px !important; }

  /* JOURNEY: the details column scrolls and PLAY DUEL stays pinned at its bottom */
  html body#rr-app.rr-ui #stagePanel .journeyDetails {
    display: flex !important;
    flex-direction: column !important;
    grid-template-rows: none !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y !important;
    min-height: 0 !important;
    gap: 4px !important;
  }
  html body#rr-app.rr-ui #stagePanel .journeyDetails > * { flex: 0 0 auto !important; }
  html body#rr-app.rr-ui #stagePanel #journeyLaunch {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 3;
    height: 36px !important;
    min-height: 36px !important;
    margin-top: auto !important;
    box-shadow: 0 -8px 12px #140a2a;
  }
  html body#rr-app.rr-ui #stagePanel .journeyBrand small { display: none !important; }
  html body#rr-app.rr-ui #stagePanel .journeyDetails img,
  html body#rr-app.rr-ui #stagePanel .journeyDetails .jdArt,
  html body#rr-app.rr-ui #stagePanel .journeyDetails .levelArt { max-height: 34px !important; height: 34px !important; object-fit: cover; }

  /* MATCH HUD: smaller joystick and buttons, GPS even smaller, no GPS label */
  html body #miniMap { width: 58px !important; height: 58px !important; top: calc(env(safe-area-inset-top) + 56px) !important; }
  html body #miniMap .mmTag { display: none !important; }
  html body #joystick { width: 84px !important; height: 84px !important; }
  html body #controls .ability { transform: scale(.88); transform-origin: bottom right; }
  html body #gameFeed { max-width: 42vw !important; font-size: 10px !important; }

  /* PRE-MATCH LOADOUT: boost cards scroll instead of pushing START BATTLE off screen */
  html body#rr-app.rr-ui #loadoutPanel .preMatchBoosts,
  html body#rr-app.rr-ui #loadoutPanel #boostGrid { overflow-y: auto !important; max-height: 44vh !important; touch-action: pan-y !important; }

  /* RESULTS: share button and the Map 06 call do not cover each other */
  html body #resultPanel #rrNexusGo { bottom: 4px !important; min-height: 34px !important; }

  /* generic sheets: anything taller than the screen scrolls instead of being cut */
  html body .sheet { overflow-y: auto !important; -webkit-overflow-scrolling: touch; }
}
