/* Nine Slide v7.11.442 — iOS: safe areas and native AdMob banner.
   ONLY runs for html[data-nine-platform="ios"].
   The 320x50pt native banner is anchored by AdMob, with margin:0.
   The WebView reserves the banner plus the Home indicator safe area.
   Keep Android/Web behavior intact. */
html[data-nine-platform="ios"]{
  /* Capacitor/WKWebView can report env()=0 when its native viewport overlaps
     the Dynamic Island. Use a conservative phone fallback in portrait. */
  --nine-ios-top-safe:max(60px, env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px));
  --nine-ios-bottom-safe:max(34px, env(safe-area-inset-bottom, 0px), var(--safe-area-inset-bottom, 0px));
  --nine-ios-banner-dock:calc(var(--nine-native-banner-height, 0px) + var(--nine-ios-bottom-safe));
}
@media(min-width:700px){
  html[data-nine-platform="ios"]{
    --nine-ios-top-safe:max(24px, env(safe-area-inset-top,0px),var(--safe-area-inset-top,0px));
    --nine-ios-bottom-safe:max(20px, env(safe-area-inset-bottom,0px),var(--safe-area-inset-bottom,0px));
  }
}

/* GAME: only one top inset. Before v442, body AND gamePage each reserved the
   camera area, pushing the board down behind the banner on iPhone. */
html[data-nine-platform="ios"] body.nine-playing{
  box-sizing:border-box!important;
  height:100dvh!important;
  min-height:100dvh!important;
  padding-top:var(--nine-ios-top-safe)!important;
  padding-bottom:0!important;
  align-items:flex-start!important;
  justify-content:flex-start!important;
  overflow:hidden!important;
}
html[data-nine-platform="ios"] body.nine-playing .gamePage,
html[data-nine-platform="ios"].nine-native-banner-active body.nine-playing .gamePage{
  box-sizing:border-box!important;
  flex:0 0 auto!important;
  display:block!important;
  width:min(94vw,560px,max(240px,calc(100dvh - var(--nine-ios-top-safe) - var(--nine-ios-banner-dock) - 250px)))!important;
  height:calc(100dvh - var(--nine-ios-top-safe) - var(--nine-ios-banner-dock))!important;
  min-height:0!important;
  max-height:calc(100dvh - var(--nine-ios-top-safe) - var(--nine-ios-banner-dock))!important;
  margin:0 auto!important;
  padding:6px 0 12px!important;
  overflow-x:hidden!important;
  overflow-y:auto!important; /* narrow/short screens can always reach the buttons */
  overscroll-behavior-y:contain!important;
  -webkit-overflow-scrolling:touch;
  scrollbar-width:none;
}
html[data-nine-platform="ios"] body.nine-playing .gamePage::-webkit-scrollbar{display:none}

/* Opaque WebView dock underneath native banner and home indicator.
   Does not intercept taps or claim that the native SDK background is editable. */
html[data-nine-platform="ios"].nine-native-banner-active body::after{
  content:"";
  position:fixed;
  left:0;right:0;bottom:0;
  height:var(--nine-ios-banner-dock);
  background:#bceeff;
  pointer-events:none;
  z-index:9;
}

/* HOME/MODE SELECT: preserve fixed, scrollable homeScreen but protect the
   Dynamic Island even after scrolling the list of levels upward. */
html[data-nine-platform="ios"] #menu .homeScreen,
html[data-nine-platform="ios"] #menu.mode-selected .homeScreen{
  box-sizing:border-box!important;
  padding-top:calc(var(--nine-ios-top-safe) + 10px)!important;
  scroll-padding-top:calc(var(--nine-ios-top-safe) + 10px)!important;
}
html[data-nine-platform="ios"] #menu::before,
html[data-nine-platform="ios"] #shop::before,
html[data-nine-platform="ios"] #settings::before{
  content:"";
  position:fixed;
  top:0;left:0;right:0;
  height:var(--nine-ios-top-safe);
  background:#bceeff;
  pointer-events:none;
  z-index:14;
}

/* MINE: page starts after the island; sticky tabs must stop below it.
   The safe-area mask also prevents scrolled cards appearing under the camera. */
html[data-nine-platform="ios"] #shop .shopPage{
  box-sizing:border-box!important;
  padding-top:calc(var(--nine-ios-top-safe) + 14px)!important;
  padding-bottom:calc(var(--nine-ios-banner-dock) + 28px)!important;
}
html[data-nine-platform="ios"] #shop .mineTabs,
html[data-nine-platform="ios"] #shop .minePageV710.mineQuickWalletActive .mineTabs{
  top:var(--nine-ios-top-safe)!important;
  z-index:16!important;
}

/* SETTINGS: reserve the actual content bottom, not just overlay padding.
   Keeps the irreversible Reset Progress/Delete Account controls reachable. */
html[data-nine-platform="ios"] #settings .settingsPage,
html[data-nine-platform="ios"] #settings .settingsModal{
  box-sizing:border-box!important;
  padding-top:calc(var(--nine-ios-top-safe) + 14px)!important;
  padding-bottom:calc(var(--nine-ios-banner-dock) + 32px)!important;
}

/* Native banner can also appear on other long-form pages: pad the scrollable
   content so buttons are never hidden by the ad when reaching the bottom. */
html[data-nine-platform="ios"].nine-native-banner-active #achievements .achievementsPage,
html[data-nine-platform="ios"].nine-native-banner-active #tutorial .tutorialPage,
html[data-nine-platform="ios"].nine-native-banner-active #profile .playerPage,
html[data-nine-platform="ios"].nine-native-banner-active #ranking .rankingPage,
html[data-nine-platform="ios"].nine-native-banner-active #friendChallenge .friendChallengePage{
  padding-bottom:calc(var(--nine-ios-banner-dock) + 26px)!important;
}

/* The native AdMob view overlays the WKWebView. For long forms, shrink the
   scroll viewport itself: bottom padding alone does not prevent an ad hiding
   a button until the user scrolls. Blue dock remains exposed underneath. */
html[data-nine-platform="ios"].nine-native-banner-active #shop,
html[data-nine-platform="ios"].nine-native-banner-active #settings{
  bottom:var(--nine-ios-banner-dock)!important;
}
