/* Set Planner V4 narrow viewport fix. Applied after ALL existing styles.
   No changes to the render engine, items, title logic, or Arcade Outfit iframe. */
@media (max-width:930px), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 html:not(.v4-arcade-mode),html:not(.v4-arcade-mode) body{
  box-sizing:border-box!important;height:100dvh!important;min-height:0!important;
  max-height:100dvh!important;max-width:100%!important;overflow:hidden!important
 }
 html:not(.v4-arcade-mode) body{display:flex!important;flex-direction:column!important}
 html:not(.v4-arcade-mode) header.top{flex:0 0 auto!important;max-height:min(22dvh,130px)!important;overflow:hidden!important}
 html.v4-embedded:not(.v4-arcade-mode) header.top{display:none!important;height:0!important}
 /* Reserve the FIRST row for the existing parent-site menu/search/settings. */
 html:not(.v4-arcade-mode) .v4-mobile-jump.v4-v2-mobile-tabs{
  box-sizing:border-box!important;display:grid!important;position:relative!important;
  top:auto!important;left:auto!important;right:auto!important;
  grid-template-columns:repeat(3,minmax(0,1fr))!important;
  flex:0 0 49px!important;min-height:49px!important;height:49px!important;
  width:auto!important;min-width:0!important;max-width:calc(100% - 16px)!important;
  margin:6px 8px!important;padding:4px!important;gap:4px!important;
  z-index:45!important;overflow:hidden!important;border-radius:12px!important;
  border:1px solid rgba(155,216,246,.3)!important;
  background:linear-gradient(145deg,rgba(59,122,180,.33),rgba(15,40,78,.92))!important
 }
 html.v4-embedded:not(.v4-arcade-mode) .v4-mobile-jump.v4-v2-mobile-tabs{
  margin-top:calc(54px + env(safe-area-inset-top,0px))!important
 }
 html:not(.v4-arcade-mode) .v4-v2-mobile-tabs>button{
  box-sizing:border-box!important;display:grid!important;place-items:center!important;
  width:100%!important;min-width:0!important;min-height:39px!important;
  max-width:100%!important;height:39px!important;
  padding:5px 2px!important;font-size:clamp(12px,2.2vw,14px)!important;
  white-space:nowrap!important;border-radius:9px!important;touch-action:manipulation
 }
 html:not(.v4-arcade-mode) .v4-v2-mobile-tabs>button[aria-selected=true]{
  color:#eaf9ff!important;background:rgba(91,167,220,.30)!important;
  box-shadow:inset 0 1px rgba(255,255,255,.2)!important
 }
 /* Old tablet/phone styles imposed two very short rows and 100dvh main PLUS
    tabs; they clipped the content into the top half of the iframe. */
 html:not(.v4-arcade-mode) main,
 html:not(.v4-arcade-mode) main.v4-inline-resizable-panels,
 html.v4-embedded:not(.v4-arcade-mode) main{
  box-sizing:border-box!important;display:flex!important;flex-direction:column!important;
  flex:1 1 auto!important;width:100%!important;max-width:100%!important;
  height:auto!important;min-height:0!important;max-height:none!important;
  grid-template-columns:none!important;grid-template-rows:none!important;
  padding:4px 8px max(7px,env(safe-area-inset-bottom,0px))!important;
  margin:0!important;gap:0!important;overflow:hidden!important
 }
 html:not(.v4-arcade-mode) main>#v4-planner-chrome,
 html:not(.v4-arcade-mode) main>#v4-planner-controls{
  display:none!important;height:0!important;min-height:0!important
 }
 html:not(.v4-arcade-mode) main>#v4-library,
 html:not(.v4-arcade-mode) main>#v4-character,
 html:not(.v4-arcade-mode) main>.side{
  box-sizing:border-box!important;position:relative!important;
  grid-row:auto!important;grid-column:auto!important;
  display:flex!important;flex-direction:column!important;order:0!important;
  flex:1 1 auto!important;width:100%!important;min-width:0!important;
  max-width:100%!important;height:100%!important;min-height:0!important;max-height:100%!important;
  margin:0!important;overflow-x:hidden!important;overflow-y:auto!important;
  -webkit-overflow-scrolling:touch;overscroll-behavior-y:contain;
  border-radius:14px!important
 }
 /* Keep all three sections mounted: only the currently selected one displays. */
 html:not(.v4-arcade-mode) body[data-v4-view=preview] main>#v4-library,
 html:not(.v4-arcade-mode) body[data-v4-view=preview] main>.side,
 html:not(.v4-arcade-mode) body[data-v4-view=items] main>#v4-character,
 html:not(.v4-arcade-mode) body[data-v4-view=items] main>.side,
 html:not(.v4-arcade-mode) body[data-v4-view=edit] main>#v4-character,
 html:not(.v4-arcade-mode) body[data-v4-view=edit] main>#v4-library{
  display:none!important;flex:0 0 0!important;height:0!important;
  visibility:hidden!important;pointer-events:none!important
 }
 html:not(.v4-arcade-mode) #v4-character .scenetop{
  position:relative!important;display:flex!important;flex-wrap:wrap!important;
  align-items:center!important;gap:7px!important;
  min-width:0!important;min-height:49px!important;
  padding:8px 10px!important;margin:0!important
 }
 html:not(.v4-arcade-mode) #v4-character .scenetop .v4-section-title{
  min-width:0!important;flex:1 1 120px!important
 }
 html:not(.v4-arcade-mode) #v4-character .scenetop .compare-actions{
  display:flex!important;flex-wrap:wrap!important;flex:0 1 auto!important;
  min-width:0!important;max-width:100%!important;gap:5px!important
 }
 html:not(.v4-arcade-mode) #v4-character .canvaswrap{
  box-sizing:border-box!important;position:relative!important;
  display:block!important;flex:0 0 auto!important;align-self:center!important;
  width:calc(100% - 14px)!important;max-width:100%!important;
  height:clamp(270px,47dvh,470px)!important;min-height:270px!important;
  max-height:470px!important;aspect-ratio:auto!important;
  overflow:hidden!important;margin:7px!important
 }
 html:not(.v4-arcade-mode) #v4-character .canvaswrap>canvas#canvas{
  display:block!important;width:100%!important;height:100%!important;
  max-width:100%!important;max-height:100%!important;object-fit:contain!important
 }
 /* That dark centered toast in the screenshot blocks the avatar on touch. */
 html:not(.v4-arcade-mode) #v4-character .canvas-hint{display:none!important}
 html:not(.v4-arcade-mode) #v4-character .v4-preview-background{
  box-sizing:border-box!important;display:flex!important;flex-wrap:wrap!important;
  max-width:calc(100% - 10px)!important;gap:3px!important
 }
 html:not(.v4-arcade-mode) #v4-character #v4-equipped,
 html:not(.v4-arcade-mode) #v4-character .v4-wearing-group{
  box-sizing:border-box!important;min-width:0!important;max-width:100%!important
 }
 html:not(.v4-arcade-mode) #v4-character #v4-equipped .slots{
  display:flex!important;flex-wrap:wrap!important;gap:7px!important
 }
 html:not(.v4-arcade-mode) #v4-character #v4-equipped .v4-equipped-card{
  flex:1 1 min(100%,240px)!important;max-width:100%!important
 }
 html:not(.v4-arcade-mode) main>#v4-library{overflow:hidden!important}
 html:not(.v4-arcade-mode) #v4-library .panelheader{
  flex:0 0 auto!important;min-height:45px!important;padding:8px 10px!important
 }
 html:not(.v4-arcade-mode) #v4-library .catalog-controls{
  box-sizing:border-box!important;flex:0 0 auto!important;min-width:0!important;
  max-height:min(39dvh,250px)!important;
  padding:7px 8px!important;overflow-y:auto!important;overscroll-behavior:contain
 }
 html:not(.v4-arcade-mode) #v4-library .catalog-controls .v4-v2-searchrow{
  display:flex!important;flex-wrap:wrap!important;gap:5px!important;min-width:0!important
 }
 html:not(.v4-arcade-mode) #v4-library .catalog-controls :is(input,select,textarea){
  max-width:100%!important;min-width:0!important;font-size:16px!important
 }
 html:not(.v4-arcade-mode) #v4-library .items,
 html:not(.v4-arcade-mode) #v4-library #results{
  box-sizing:border-box!important;flex:1 1 auto!important;
  min-height:0!important;max-height:none!important;overflow-y:auto!important;
  overscroll-behavior:contain
 }
 html:not(.v4-arcade-mode) main>.side>.panel{
  flex:0 0 auto!important;min-height:0!important;max-width:100%!important
 }
 html:not(.v4-arcade-mode) main .v4-inline-panel-grip{display:none!important}
 html:not(.v4-arcade-mode) :is(#v4-events-dialog,#v4-sort-dropdown-menu){
  box-sizing:border-box!important;max-width:calc(100vw - 12px)!important;
  max-height:calc(100dvh - 12px)!important;overflow-y:auto!important
 }
 html:not(.v4-arcade-mode) #v4-events-dialog .v4-events-content{
  max-height:calc(100dvh - 145px)!important;overflow-y:auto!important
 }
}
@media(max-width:1100px) and (max-height:600px) and (orientation:landscape){
 html.v4-embedded:not(.v4-arcade-mode) .v4-mobile-jump.v4-v2-mobile-tabs{
  margin-top:calc(49px + env(safe-area-inset-top,0px))!important;
  flex-basis:42px!important;height:42px!important;min-height:42px!important
 }
 html:not(.v4-arcade-mode) .v4-v2-mobile-tabs>button{
  min-height:32px!important;height:32px!important
 }
 html:not(.v4-arcade-mode) #v4-character .canvaswrap{
  height:clamp(190px,45dvh,300px)!important;
  min-height:190px!important;max-height:300px!important
 }
 html:not(.v4-arcade-mode) #v4-library .catalog-controls{
  max-height:min(33dvh,175px)!important
 }
}
