/* Phone touch layouts only: tablets and computers keep the existing control. */
@media (pointer:coarse) and (max-width:600px), (pointer:coarse) and (max-width:950px) and (max-height:500px){
#dialog:has(.mg-dialog) #closeDialog{
 width:auto!important;
 min-width:80px!important;
 height:44px!important;
 min-height:44px!important;
 padding:0 14px!important;
 border-radius:999px!important;
 font-size:0!important;
}
#dialog:has(.mg-dialog) #closeDialog::after{
 content:'Kembali';
 font:800 14px/1 Nunito,system-ui,sans-serif;
}
#dialog:has(.mg-dialog) .mg-dialog{padding-top:44px}
}

/* In the Android phone app, the system Back gesture closes quick games and
   leaves the crossword. Other dialogs and the website keep their controls. */
html.jejak-app-phone #dialog:has(.mg-dialog) #closeDialog,
html.jejak-app-phone .app-silang-head #silangBack{display:none!important}
html.jejak-app-phone #dialog:has(.mg-dialog) .mg-dialog{padding-top:0}

/* Phone browsers close quick games with Back; admin-portal URLs keep the
   visible control because those URLs do not use browser history routing. */
html.mind-browser-phone #dialog:has(.mg-dialog) #closeDialog{display:none!important}
html.mind-browser-phone #dialog:has(.mg-dialog) .mg-dialog{padding-top:0}
html.mind-browser-phone #dialog .mg-dialog h2{padding-right:0}

/* Browser Hangman uses the regular Teka Silang header and a real page.
   Keep the existing game design, centred and scrollable on small screens. */
html:not(.jejak-app) body.silang-wide:has(#app .mg-hangman)>main{
 min-height:calc(100dvh - 64px);max-width:none;margin:0 auto;
 padding:20px max(16px,env(safe-area-inset-right)) 32px max(16px,env(safe-area-inset-left));
}
html:not(.jejak-app) #app .mg-hangman{--hangman-key:54px;width:min(100%,730px);max-width:730px;margin:0 auto;align-content:start}
/* Centre a short final row, including Y and Z, without stretching the keys. */
html:not(.jejak-app) #app .mg-hangman .mg-keys{display:flex;flex-wrap:wrap;justify-content:center}
html:not(.jejak-app) #app .mg-hangman .mg-key{flex:0 0 var(--hangman-key);width:var(--hangman-key);min-height:var(--hangman-key);font-size:19px}
@media(min-width:601px) and (max-width:745px){html:not(.jejak-app) #app .mg-hangman .mg-keys{max-width:474px;margin-inline:auto}}
@media(max-width:600px){
 html:not(.jejak-app) body.silang-wide:has(#app .mg-hangman)>main{padding-top:12px}
 html:not(.jejak-app) #app .mg-hangman{--hangman-key:44px;gap:9px}
 html:not(.jejak-app) #app .mg-hangman .mg-keys{max-width:294px;margin-inline:auto}
}
@media(max-width:350px){html:not(.jejak-app) #app .mg-hangman .mg-keys{max-width:284px;gap:4px}}
@media(max-height:700px){html:not(.jejak-app) #app .mg-hangman{gap:9px}}

/* Phone app: Android Back closes the level and ebook pickers. */
html.jejak-app-phone #dialog:has(.level-options) #closeDialog,
html.jejak-app-phone #dialog:has(.gm-ebook-pick) #closeDialog{display:none!important}

/* The phone app uses Android Back to dismiss panels and readers. Keep
   the controls in the DOM for their existing cleanup and web layouts. */
html.jejak-app-phone #dialog > #closeDialog,
html.jejak-app-phone #sideMenu #menuClose,
html.jejak-app-phone #gmDialog .gm-sheet-tools > .x,
html.jejak-app-phone dialog.sirah-book .sb-tools [data-close],
html.jejak-app-phone dialog.sirah-book .sb-aside-head [data-hide-contents],
html.jejak-app-phone dialog.note-reader .nr-header [data-close]{display:none!important}
