/* Safari compatibility; gameplay control dimensions remain owned by the HUD. */
html[data-maven-ios] { -webkit-text-size-adjust:100%; text-size-adjust:100%; }
html[data-maven-ios] input:not([type=checkbox]):not([type=radio]):not([readonly]),
html[data-maven-ios] textarea, html[data-maven-ios] select { font-size:16px !important; }
html[data-maven-ios] :is(button,a) { touch-action:manipulation; }
html[data-maven-ios] #mvm-root :is(button,img,canvas), html[data-maven-ios] canvas.ro-scene { -webkit-touch-callout:none; -webkit-user-select:none; user-select:none; }
html[data-maven-ios] .mvm-chat__log, html[data-maven-ios] .midgard-viewport { -webkit-overflow-scrolling:touch; }
html[data-maven-ios].mvm-game:not(.mvm-rot) .play-stage,
html[data-maven-ios].mvm-game:not(.mvm-rot) > body > #mvm-root {
  height:var(--maven-view-h,100dvh) !important;
}
/* The outermost page provides the physical safe area for nested frames. */
html[data-maven-ios][data-maven-contained] #mvm-root {
  --mvm-notch-t:0px !important; --mvm-notch-r:0px !important;
  --mvm-notch-b:0px !important; --mvm-notch-l:0px !important;
}
html[data-maven-ios]:not([data-maven-contained]).mvm-game:not(.mvm-rot) .play-stage,
html[data-maven-ios]:not([data-maven-contained]).mvm-game:not(.mvm-rot) > body > #mvm-root {
  inset:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) auto env(safe-area-inset-left,0px) !important;
  width:calc(100% - env(safe-area-inset-left,0px) - env(safe-area-inset-right,0px)) !important;
  height:calc(var(--maven-view-h,100dvh) - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px)) !important;
}
html[data-maven-ios]:not([data-maven-contained]).mvm-rot .play-stage,
html[data-maven-ios]:not([data-maven-contained]).mvm-rot > body > #mvm-root {
  width:calc(var(--maven-view-h,100dvh) - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px)) !important;
  height:calc(var(--maven-view-w,100vw) - env(safe-area-inset-left,0px) - env(safe-area-inset-right,0px)) !important;
  top:calc((var(--maven-view-h,100dvh) + env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px))/2) !important;
  left:calc((var(--maven-view-w,100vw) + env(safe-area-inset-left,0px) - env(safe-area-inset-right,0px))/2) !important;
}
html[data-maven-ios]:not([data-maven-contained]):not(.mvm-game) .play-main {
  padding-left:max(16px,env(safe-area-inset-left,0px)); padding-right:max(16px,env(safe-area-inset-right,0px));
}
/* Only the chat panel fits above the optional system keyboard. The scene stays stable. */
html[data-maven-ios][data-maven-keyboard=true] #mvm-root#mvm-root#mvm-root#mvm-root .mvm-chat[data-open=true] {
  top:auto !important; bottom:calc(100% - var(--maven-visible-bottom) + 8px) !important;
  left:calc(var(--maven-visible-left) + 8px) !important; right:auto !important;
  width:min(440px,calc(var(--maven-visible-w) - 16px)) !important;
  max-height:min(176px,calc(var(--maven-visible-h) - 16px)) !important;
  margin:0 !important; transform:none !important; z-index:11001 !important;
}
html[data-maven-ios][data-maven-keyboard=true] #mvm-root .mvm-chat__log { min-height:0 !important; flex:1 1 auto !important; }
html[data-maven-ios][data-maven-keyboard=true] #mvm-root .mvm-chat__input { font-size:16px !important; }
.maven-recovery { position:fixed; z-index:2147483500; left:50%; top:max(12px,env(safe-area-inset-top,0px)); transform:translateX(-50%); display:flex; align-items:center; gap:12px; max-width:calc(100% - 32px); padding:10px 14px; border:1px solid #b9e3f580; border-radius:4px 14px; background:#102c42ed; color:#edf7ff; font:16px 'Barlow Semi Condensed',sans-serif; -webkit-backdrop-filter:blur(12px); backdrop-filter:blur(12px); }
.maven-recovery button { min-height:40px; padding:4px 12px; border:1px solid #aedaf0; border-radius:4px 10px; background:#20658b; color:#fff; font:inherit; }
.maven-recovery[hidden] { display:none; }
