/* TANHU GAMES 6.8.9 Mobile UX Stability Edition — visual-only safety layer */
:root{--tanhu-safe-bottom:max(18px,env(safe-area-inset-bottom));}
html{scroll-padding-bottom:150px}
body{padding-bottom:calc(108px + env(safe-area-inset-bottom))!important}
#tanhuFeedbackBtn{left:16px!important;bottom:calc(18px + env(safe-area-inset-bottom))!important;max-width:42vw;white-space:nowrap}
#tanhuAssistantBtn,.assistant-fab,.audio-fab,[data-floating-audio]{bottom:calc(18px + env(safe-area-inset-bottom))!important;right:16px!important;max-width:42vw}
#buildMarker{bottom:calc(72px + env(safe-area-inset-bottom))!important;right:14px!important}
footer,.footer,.legal-footer,.site-footer{padding-bottom:calc(105px + env(safe-area-inset-bottom))!important}
.emergency-link,[data-emergency-link]{display:none!important}
@media(max-width:700px){
  .topbar{gap:8px!important;align-items:center!important}
  .top-actions{gap:6px!important;overflow-x:auto!important;scrollbar-width:none!important;padding-bottom:3px}
  .top-actions::-webkit-scrollbar{display:none}
  .top-version-btn{font-size:12px!important;padding:7px 8px!important;white-space:nowrap}
  .mobile-brand-logo{width:48px!important;height:48px!important;object-fit:cover!important}
  .official-brand-watermark{display:none!important}
  .story-grid,.feature-grid,.cinematic-grid{grid-template-columns:1fr!important;overflow:visible!important}
  .story-grid>* ,.feature-grid>* ,.cinematic-grid>*{min-width:0!important;width:100%!important}
}
@media(max-width:430px){
  #tanhuFeedbackBtn{font-size:13px!important;padding:10px 12px!important}
  #tanhuAssistantBtn,.assistant-fab,.audio-fab,[data-floating-audio]{font-size:13px!important;padding:10px 12px!important}
}


/* 6.8.4 tablet stability overrides */
.tanhu-home-fixed{display:none!important}
.layout{align-items:start!important}
.layout>.side{align-self:start!important;height:auto!important;min-height:0!important}
.events,.log{height:auto!important;min-height:92px;max-height:180px;overflow:auto!important}
@media (min-width:701px) and (max-width:1200px){
 #tanhuCoachPanel,#mentor670{position:relative!important;left:auto!important;right:auto!important;bottom:auto!important;width:auto!important;max-width:none!important;max-height:none!important;margin:12px!important;z-index:8!important;box-shadow:none!important}
 #mentor670.m670collapsed{max-height:58px!important;overflow:hidden!important}
}


/* 6.8.9 urgent phone control collision hotfix */
@media(max-width:700px){
  body{padding-bottom:calc(24px + env(safe-area-inset-bottom))!important}
  html{scroll-padding-bottom:24px!important}
  body:has(#game.active) #tanhuAssistantBtn,
  body:has(#game.active) .assistant-fab,
  body:has(#game.active) .audio-fab,
  body:has(#game.active) [data-floating-audio],
  body:has(#game.active) #tanhuFeedbackBtn,
  body:has(#game.active) .tanhu-learning-dock{display:none!important}
  #game.active{padding-bottom:calc(24px + env(safe-area-inset-bottom))!important}
  #game.active .eventsBox,#game.active .events,#game.active .log{margin-bottom:12px!important}
  #tanhuCoachPanel + #mentor670{margin-top:16px!important}
  .tanhuCoachChoice,.m670choice,.m670btn,.m670tabs button{touch-action:manipulation!important;pointer-events:auto!important}
}


/* 6.8.9 emergency no-overlap flow fix — phone + tablet */
body.tanhu-game-page{
  padding-bottom:calc(24px + env(safe-area-inset-bottom))!important;
}
body.tanhu-game-page #tanhuFeedbackBtn,
body.tanhu-game-page #tanhuAssistantBtn,
body.tanhu-game-page .assistant-fab,
body.tanhu-game-page .audio-fab,
body.tanhu-game-page [data-floating-audio],
body.tanhu-game-page .tanhu-learning-dock{
  display:none!important;
}
body.tanhu-game-page #game.active{
  display:flex!important;
  flex-direction:column!important;
  align-items:stretch!important;
  padding-bottom:calc(24px + env(safe-area-inset-bottom))!important;
}
body.tanhu-game-page #game.active .top{order:1}
body.tanhu-game-page #game.active .layout{order:2}
body.tanhu-game-page #game.active .replayBar{order:3}
body.tanhu-game-page #game.active .eventsBox{order:4}
body.tanhu-game-page #game.active #tanhuCoachPanel{order:5}
body.tanhu-game-page #game.active #mentor670{order:6}
body.tanhu-game-page #game.active .copy{order:7}
body.tanhu-game-page #tanhuCoachPanel,
body.tanhu-game-page #mentor670{
  position:relative!important;
  inset:auto!important;
  left:auto!important;
  right:auto!important;
  top:auto!important;
  bottom:auto!important;
  float:none!important;
  clear:both!important;
  transform:none!important;
  width:calc(100% - 24px)!important;
  max-width:1280px!important;
  max-height:none!important;
  margin:14px auto!important;
  overflow:visible!important;
  box-sizing:border-box!important;
  z-index:4!important;
  box-shadow:none!important;
}
body.tanhu-game-page #mentor670.m670collapsed{
  max-height:64px!important;
  overflow:hidden!important;
}
body.tanhu-game-page #tanhuCoachPanel{margin-bottom:8px!important}
body.tanhu-game-page #mentor670{margin-top:8px!important;margin-bottom:20px!important}
body.tanhu-game-page #game.active .eventsBox{
  margin-bottom:8px!important;
}
@media(max-width:700px){
  body.tanhu-game-page #tanhuCoachPanel,
  body.tanhu-game-page #mentor670{width:calc(100% - 20px)!important;margin-left:auto!important;margin-right:auto!important}
  body.tanhu-game-page .tanhuCoachChoices{grid-template-columns:1fr!important}
  body.tanhu-game-page .tanhuCoachChoice{display:block!important;width:100%!important;min-height:60px!important;margin:0!important}
  body.tanhu-game-page .m670tabs{grid-template-columns:1fr!important}
  body.tanhu-game-page .m670tabs button{width:100%!important;min-height:52px!important}
}

/* 6.8.9 absolute safety: menu sound control never floats over active game */
body:has(#game.active) #soundBtn{display:none!important}
