/* UI 017.0.14 — stable Home scrolling + fine optical alignment + full activity-card clearance.
   Additive only; hero composition, combat packages and game state remain untouched. */

html:has(body.i13-home-open),
body.i13-home-open{
  width:100%!important;
  max-width:100%!important;
  overflow-x:hidden!important;
  overscroll-behavior-x:none!important;
}

body.i13-home-open #i13-home-layer{
  position:fixed!important;
  inset:0!important;
  width:auto!important;
  max-width:none!important;
  height:auto!important;
  max-height:none!important;
  overflow:hidden!important;
  overscroll-behavior:none!important;
}

/* One stable vertical scroll owner. 017.0.14 keeps the accepted total 8px optical
   shift to the left; height and momentum scrolling stay independent from Safari chrome. */
body.i13-home-open #i13-page{
  position:relative!important;
  left:-8px!important;
  width:100%!important;
  max-width:460px!important;
  min-width:0!important;
  height:100%!important;
  min-height:0!important;
  margin:0 auto!important;
  padding-left:6px!important;
  padding-right:6px!important;
  box-sizing:border-box!important;
  overflow-x:hidden!important;
  overflow-y:auto!important;
  -webkit-overflow-scrolling:touch!important;
  overscroll-behavior-x:none!important;
  overscroll-behavior-y:contain!important;
  scroll-behavior:auto!important;
  padding-bottom:calc(var(--i13-dock-h,78px) + env(safe-area-inset-bottom) + 18px)!important;
}

/* While Activities is open, temporarily give the vertical scroller enough tail
   room to move the whole expanded panel above the fixed dock. The dock itself does
   not move; this extra scroll room disappears as soon as Activities closes. */
body.i13-home-open #i13-page.i17-activities-open{
  padding-bottom:calc(var(--i13-dock-h,78px) + env(safe-area-inset-bottom) + 120px)!important;
}

body.i13-home-open #i13-page > header,
body.i13-home-open #i13-page > main{
  width:100%!important;
  max-width:100%!important;
  min-width:0!important;
  margin-left:0!important;
  margin-right:0!important;
  box-sizing:border-box!important;
}

body.i13-home-open #i13-page main > *,
body.i13-home-open #i13-page section{
  min-width:0!important;
  max-width:100%!important;
  box-sizing:border-box!important;
}

/* Dock is anchored by JS to the actual visualViewport lower edge. This is the
   only element whose position follows Safari browser chrome; page geometry never does. */
body.i13-home-open .i13-dock{
  position:fixed!important;
  z-index:2000010!important;
  left:calc(50% - 8px)!important;
  right:auto!important;
  top:var(--i17-dock-top,auto)!important;
  bottom:var(--i17-dock-bottom,calc(env(safe-area-inset-bottom) + 8px))!important;
  width:calc(100% - 12px)!important;
  max-width:448px!important;
  min-width:0!important;
  height:auto!important;
  min-height:var(--i13-dock-h,78px)!important;
  margin:0!important;
  transform:translate3d(-50%,0,0)!important;
  translate:none!important;
  overflow:visible!important;
  contain:none!important;
  box-sizing:border-box!important;
  display:grid!important;
  grid-template-columns:repeat(5,minmax(0,1fr))!important;
  align-items:stretch!important;
  will-change:top!important;
}

body.i13-home-open .i13-dock.i1705-visual-anchored{
  bottom:auto!important;
}

body.i13-home-open .i13-dock > button{
  min-width:0!important;
  width:auto!important;
  max-width:none!important;
  height:100%!important;
  overflow:visible!important;
  box-sizing:border-box!important;
  display:flex!important;
  flex-direction:column!important;
  align-items:center!important;
  justify-content:center!important;
}

body.i13-home-open .i13-dock button span{
  display:block!important;
  width:100%!important;
  max-width:100%!important;
  overflow:visible!important;
  text-overflow:clip!important;
  white-space:nowrap!important;
  text-align:center!important;
  line-height:1.05!important;
}

/* Bottom dock is the only persistent entry to World/Map; the expandable section
   is reserved for secondary activities. */
body.i13-home-open .i13-world.i17-activities .i13-world-links{
  grid-template-columns:repeat(2,minmax(0,1fr))!important;
  gap:8px!important;
}
body.i13-home-open .i13-world.i17-activities .i13-world-links button{
  min-width:0!important;
}

body.i13-home-open .i13-world{
  scroll-margin-bottom:calc(var(--i13-dock-h,78px) + env(safe-area-inset-bottom) + 24px);
}

body.i13-home-open .i13-world-toggle{
  cursor:pointer;
  touch-action:manipulation!important;
  user-select:none;
}

body.i13-home-open .i13-world-links{
  pointer-events:none;
  visibility:hidden;
  transform:translateY(-4px);
  transform-origin:50% 0;
}
body.i13-home-open .i13-world.is-open .i13-world-links{
  pointer-events:auto;
  visibility:visible;
  transform:translateY(0);
}
body.i13-home-open .i13-world.is-open{
  border-color:rgba(205,158,79,.62);
  box-shadow:0 10px 26px rgba(0,0,0,.38),inset 0 1px rgba(255,226,170,.07),0 0 18px rgba(130,54,175,.10);
}
body.i13-home-open .i13-world-links button{
  touch-action:manipulation!important;
}

/* Stateful battle CTA keeps the accepted geometry. */
body.i13-home-open .i13-battle-button{
  touch-action:manipulation!important;
}
body.i13-home-open .i13-battle-button.is-resume{
  box-shadow:0 10px 28px rgba(79,20,111,.46),0 0 20px rgba(183,70,226,.20),inset 0 1px rgba(255,239,205,.24)!important;
}
body.i13-home-open .i13-battle-button.is-new{
  box-shadow:0 10px 28px rgba(79,20,111,.40),0 0 16px rgba(226,173,82,.14),inset 0 1px rgba(255,239,205,.22)!important;
}

@media(max-width:350px){
  body.i13-home-open .i13-world.i17-activities .i13-world-links{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:6px!important;
  }
  body.i13-home-open .i13-dock{
    width:calc(100% - 8px)!important;
  }
  body.i13-home-open .i13-dock button span{
    font-size:9px!important;
  }
}

@media(prefers-reduced-motion:reduce){
  body.i13-home-open .i13-world-links{transition:none!important;transform:none!important}
}
