/* The Flutter WebView draws beneath Android's transparent status bar. The
   native inset protects interactive content while page backgrounds continue
   behind the status icons. Older app versions have a zero inset. */
@media (pointer:coarse) and (max-device-width:600px), (pointer:coarse) and (max-device-height:600px) {
  html.jejak-app body:not(:has(.hero-banner)):not(:has(.settings-page)):not(.adventure-mode):not(.arcade-page)>main {
    padding-top:calc(14px + var(--jejak-app-inset-top, 0px));
  }
  html.jejak-app .settings-page {
    padding-top:calc(28px + var(--jejak-app-inset-top, 0px));
  }
  /* Home artwork begins at the top of the viewport, behind the status bar. */
  html.jejak-app body:has(.hero-banner)>main{padding-top:0}
  html.jejak-app #gmDialog .gm-sheet {
    top:max(8px,env(safe-area-inset-top),var(--jejak-app-inset-top, 0px));
  }
  html.jejak-app dialog:not(.gm-dialog):not(.sirah-book) {
    top:var(--jejak-app-inset-top, 0px);
    max-height:calc(100dvh - var(--jejak-app-inset-top, 0px) - 24px);
  }
  html.jejak-app dialog.sirah-book .sb-header {
    padding-top:calc(10px + var(--jejak-app-inset-top, 0px));
  }
  html.jejak-app dialog.sirah-book .sb-contents {
    top:calc(77px + var(--jejak-app-inset-top, 0px));
  }
  html.jejak-app body.adventure-mode.arcade-phone .adventure-hud {
    top:calc(12px + var(--jejak-app-inset-top, 0px));
  }
  html.jejak-app body.adventure-mode.arcade-phone .adventure-heading {
    top:calc(65px + var(--jejak-app-inset-top, 0px));
  }
  html.jejak-app .adventure-rotate {
    padding-top:max(24px,var(--jejak-app-inset-top, 0px));
  }
}

/* Keep each era name intact on Android phones, even with larger text. */
html.jejak-app-phone .journey-tabs{
  grid-template-columns:repeat(3,minmax(max-content,1fr));
  max-width:100%;
  overflow-x:auto;
  overscroll-behavior-inline:contain;
  scrollbar-width:thin;
}
html.jejak-app-phone body:has(.journey-page) .journey-tabs [role=tab],
html.jejak-app-phone body:has(.gm-hero) .journey-tabs [role=tab]{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:2px;
  min-width:max-content;
  min-height:48px;
  padding:8px 8px;
  font-size:clamp(13px,3.8vw,15px);
  line-height:1.2;
  white-space:nowrap;
  overflow-wrap:normal;
  word-break:normal;
}
html.jejak-app-phone .journey-tabs [role=tab] span{display:block;margin:0;line-height:1}

/* The four help panels fill the phone app while keeping Android bars clear. */
html.jejak-app-phone dialog#dialog:is(.how-dialog,.about-dialog,:has(.contact-details),:has(.menu-faq)){
  position:fixed;inset:0!important;width:100%!important;max-width:none!important;
  height:100dvh!important;max-height:100dvh!important;margin:0!important;
  border:0!important;border-radius:0!important;box-shadow:none!important;
  padding:calc(max(env(safe-area-inset-top),var(--jejak-app-inset-top,0px)) + 22px)
    max(22px,env(safe-area-inset-right))
    calc(max(env(safe-area-inset-bottom),var(--jejak-app-inset-bottom,0px)) + 22px)
    max(22px,env(safe-area-inset-left))!important;
  overflow-y:auto;overscroll-behavior:contain;scrollbar-gutter:auto;
}

/* Phone guide: one continuous page instead of one step per screen. */
html.jejak-app-phone #dialog.how-dialog .how-pages{min-height:0;margin:0;padding-left:24px}
html.jejak-app-phone #dialog.how-dialog .how-page{display:list-item;margin:0 0 18px;padding-left:3px}
html.jejak-app-phone #dialog.how-dialog .how-page:last-child{margin-bottom:0}
html.jejak-app-phone #dialog.how-dialog .how-page h3{font-size:16px;line-height:1.35;margin:0 0 5px}
html.jejak-app-phone #dialog.how-dialog .how-page p{font-size:14px;line-height:1.5;text-align:left;text-justify:auto}
html.jejak-app-phone #dialog.how-dialog .how-pagination{display:none!important}

/* Centre the complete contact block within the phone's safe area. */
html.jejak-app-phone #dialog:has(.contact-details) #dialogBody{
  min-height:calc(100dvh - max(env(safe-area-inset-top),var(--jejak-app-inset-top,0px)) - max(env(safe-area-inset-bottom),var(--jejak-app-inset-bottom,0px)) - 44px);
  display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;
}
html.jejak-app-phone #dialog:has(.contact-details) .contact-details{text-align:center}
/* Contact has no close control on phone: remove its reserved heading space. */
html.jejak-app-phone #dialog:has(.contact-details) #dialogBody h2{padding:0;text-align:center}
html.jejak-app-phone #dialog:has(.contact-details) .whatsapp-button{width:100%;max-width:340px;margin-inline:auto;scroll-margin-bottom:32px}
/* Center when it fits; keep the title reachable when the screen is short. */
html.jejak-app-phone #dialog:has(.contact-details) #dialogBody{justify-content:safe center}

/* Tentang Kami: show all paragraphs on one scrollable phone page. */
html.jejak-app-phone #dialog.about-dialog .about-pages{min-height:0}
html.jejak-app-phone #dialog.about-dialog .about-page{display:block}
html.jejak-app-phone #dialog.about-dialog .about-page p{margin:0 0 16px;line-height:1.55;text-align:left;text-justify:auto}
html.jejak-app-phone #dialog.about-dialog .about-page .about-closing{margin-top:4px}
html.jejak-app-phone #dialog.about-dialog .about-page .about-founder{margin-top:8px}
html.jejak-app-phone #dialog.about-dialog .about-pagination{display:none!important}

/* Keep the contact group compact and visually centred on phone screens. */
html.jejak-app-phone #dialog:has(.contact-details) .contact-details{margin:12px 0 16px;padding:0!important;line-height:1.35}
html.jejak-app-phone #dialog:has(.contact-details) .contact-details p{margin:0;line-height:1.4}
html.jejak-app-phone #dialog:has(.contact-details) .contact-details p+p{margin-top:12px}
