/* Telegram iOS fullscreen safety: native Close/Menu pills overlay the WebView.
   Load AFTER all world / Kraken / map styles so their generic padding cannot
   override the actual Telegram safe insets again. */
html.in-telegram[data-screen="map-screen"] .adventure-shell,
html.in-telegram[data-screen="game-screen"] .adventure-shell,
html.in-telegram[data-screen="result-screen"] .adventure-shell{
  box-sizing:border-box;
  padding-top:max(18px,calc(var(--mini-safe-top,0px) + 10px),env(safe-area-inset-top,0px));
  padding-right:max(10px,var(--mini-safe-right,0px));
  padding-left:max(10px,var(--mini-safe-left,0px));
  padding-bottom:max(58px,calc(var(--mini-safe-bottom,0px) + 28px),calc(env(safe-area-inset-bottom,0px) + 28px));
}
/* Important: on an iPhone in immersive fullscreen the Telegram header pills
   can overlap even when its SDK initially reports zero contentSafeAreaInset.
   102 CSS px is a conservative fallback until safeAreaChanged arrives. */
html.in-telegram.mini-fullscreen[data-screen="map-screen"] .adventure-shell,
html.in-telegram.mini-fullscreen[data-screen="game-screen"] .adventure-shell,
html.in-telegram.mini-fullscreen[data-screen="result-screen"] .adventure-shell{
  padding-top:max(102px,calc(var(--mini-safe-top,0px) + 12px),calc(env(safe-area-inset-top,0px) + 54px));
}
/* A shorter, scrollable map keeps the farm and play actions reachable after
   reserving top chrome space; no interactive item gets hidden or clipped. */
html.in-telegram.mini-fullscreen[data-screen="map-screen"] .voyage-window,
html.in-telegram.mini-fullscreen[data-world="reef"][data-screen="map-screen"] .voyage-window{
  height:clamp(320px,calc(var(--mini-height,100svh) - 425px),540px);
}
html.in-telegram.mini-fullscreen[data-screen="map-screen"] .adventure-header{
  position:relative;
  z-index:2;
}
/* Browsers without fullscreen support retain the compact ordinary layout. */
@media(max-height:660px){
  html.in-telegram.mini-fullscreen[data-screen="map-screen"] .voyage-window,
  html.in-telegram.mini-fullscreen[data-world="reef"][data-screen="map-screen"] .voyage-window{
    height:310px;
  }
}
