/* WebKit samples the outer canvas independently of the visible page header.
   Match the canvas to the active header while the page paints its own artwork. */
html[data-ios-standalone]{
  /* Keep header text below the native status-bar blur on notched devices. */
  --ios-header-inset:calc(var(--device-safe-top) + min(20px,var(--device-safe-top)));
  --ios-page-height:100lvh;
  --ios-tab-inset:var(--device-safe-bottom);
  --ios-nav-height:calc(48px + var(--ios-tab-inset));
  --ios-status-color:var(--n-paper,#f8f9f5);
  background-color:var(--n-paper,#f8f9f5);
  overscroll-behavior-y:none;
}
/* On a short restored page WebKit initially reports a smaller dynamic viewport. */
html[data-ios-standalone][data-ios-keyboard]{--ios-page-height:100dvh}
html[data-ios-standalone] body:has(#main){
  min-height:var(--ios-page-height);
  box-sizing:border-box;
  padding-bottom:var(--ios-nav-height);
  background-clip:content-box;
  background-color:var(--ios-status-color);
  overscroll-behavior-y:none;
}
/* The home image and catalogue gradient use representative top-edge colours. */
html[data-ios-standalone]:has(#main > #storefront-home:not([data-startup-home-shell])),
html[data-ios-standalone][data-initial-home]:has(#main > [data-startup-home-shell]),
html[data-ios-standalone]:has(#main > .navigation-pending [data-i18n-key="nav.homeFull"]){
  --ios-status-color:#032817;
}
html[data-ios-standalone]:has(#main > #storefront-catalog),
html[data-ios-standalone]:has(#main > .navigation-pending [data-i18n-key="nav.productsFull"]){
  --ios-status-color:#003f23;
}
html[data-ios-standalone]:has(#main > .orders-screen),
html[data-ios-standalone]:has(#main > .navigation-pending [data-i18n-key="nav.numbersFull"]){
  --ios-status-color:#064b31;
}
html[data-ios-standalone]:has(#main > .account-screen),
html[data-ios-standalone]:has(#main > .navigation-pending [data-i18n-key="nav.accountFull"]){
  --ios-status-color:#075239;
}
html[data-ios-standalone]:has(#main > .points-wheel-page){
  --ios-status-color:#064630;
}
html[data-ios-standalone]:has(#main > .support-chat-screen){
  --ios-status-color:#07573c;
}
html[data-ios-standalone]:has(#main > .history-screen){
  --ios-status-color:#003c24;
}
html[data-ios-standalone]:has(#main > :is(.history-trend-screen,.winner-screen)){
  --ios-status-color:#07583a;
}
html[data-ios-standalone]:has(#main > .detail-screen){
  --ios-status-color:#07563a;
}
html[data-ios-standalone]:has(#main > .wheel-help-page){
  --ios-status-color:#f6f7f3;
}
html[data-ios-standalone]:has(#main > .wheel-records-screen){
  --ios-status-color:#fffdfa;
}
html[data-ios-standalone]:has(#main > .order-logistics-screen){
  --ios-status-color:#f0f5ef;
}
html[data-ios-standalone] #main{
  background-color:#f8f9f5;
  min-height:calc(var(--ios-page-height) - var(--ios-nav-height));
}
/* Enlarge the existing surfaces; their images/gradients/fills remain intact. */
html[data-ios-standalone] #main:has(>#storefront-catalog)::before{
  height:calc(164px + var(--ios-header-inset));
}
html[data-ios-standalone] #main .page-top:not(.home-top){
  height:auto;
  min-height:calc(var(--ios-header-height,56px) + var(--ios-header-inset));
  padding-top:calc(var(--ios-header-padding,6px) + var(--ios-header-inset));
}
/* The brief loading header uses the destination page's canvas as well. */
html[data-ios-standalone] #main > .navigation-pending .page-top{
  background-color:var(--ios-status-color);
  color:#fff;
}
html[data-ios-standalone] #main .orders-top{
  --ios-header-height:64px;
  --ios-header-padding:10px;
}
html[data-ios-standalone] #main .points-wheel-page .secondary-top{
  --ios-header-height:76px;
}
html[data-ios-standalone] #main .account-screen .account-overview{
  padding-top:calc(12px + var(--ios-header-inset));
}
html[data-ios-standalone] #main .order-inquiry{padding-top:calc(12px + var(--ios-header-inset));}
.pwa-window-insets{position:fixed;inset:0 auto auto 0;width:0;height:0;padding-top:env(safe-area-inset-top,0px);padding-bottom:env(safe-area-inset-bottom,0px);margin-top:env(safe-area-max-inset-top,env(safe-area-inset-top,0px));margin-bottom:env(safe-area-max-inset-bottom,env(safe-area-inset-bottom,0px));visibility:hidden;pointer-events:none}
html[data-pwa-window]{--device-safe-top:var(--pwa-safe-top,env(safe-area-inset-top,0px));--device-safe-bottom:var(--pwa-safe-bottom,env(safe-area-inset-bottom,0px))}
html[data-pwa-window] body{min-height:var(--pwa-window-height,100lvh);top:calc(0px - var(--pwa-native-top,0px))}
html[data-pwa-window] #main{min-height:calc(var(--pwa-window-height,100lvh) - 74px - var(--device-safe-bottom))}
/* Keep navigation on the visible viewport when native bars reduce its height.
   The fixed product action sits immediately above the same safe-area tab bar. */
html[data-pwa-window] .mobile-nav{bottom:0}
html[data-pwa-system-bars] #main .detail-screen .detail-action{bottom:calc(74px + env(safe-area-inset-bottom,0px))}
/* The payment sheet moves its static footer with it. */
html[data-pwa-system-bars] #paymentDialog{translate:0 var(--pwa-native-bottom-shift,0px)}
html[data-pwa-system-bars] #paymentDialog{max-height:calc(var(--pwa-window-height) - 24px - var(--pwa-safe-top,0px) - var(--pwa-safe-bottom,0px))}
/* A modal top-layer picker does not inherit body's position compensation.
   Only a native-bar transition uses the stable full canvas. Focus/keyboard
   removes this state, restoring the picker's normal dynamic viewport sizing. */
html[data-pwa-system-bars] #picker{top:calc(0px - var(--pwa-native-top,0px));bottom:auto;height:var(--pwa-window-height);max-height:var(--pwa-window-height)}
html[data-pwa-system-bars] #picker .flow-head{padding-top:max(6px,var(--pwa-safe-top,0px))!important}
@media(orientation:portrait),(min-height:541px){
  html[data-pwa-system-bars] #picker #pickStep>.flow-actions,
  html[data-pwa-system-bars] #picker #reviewStep>.flow-actions{translate:0 var(--pwa-native-bottom-shift,0px)}
}
html[data-pwa-system-gesture]{overflow-y:hidden;overscroll-behavior-y:none;overflow-anchor:none;scroll-behavior:auto!important}
/* Render the real home immediately. Do not paint a blank green web frame
   between Android's native launch image and the application's first content. */
.home-loading-products{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;grid-column:1/-1}
.home-loading-products>div{min-height:280px;border:1px solid #e0e6e0;border-radius:16px;background:#fff;padding:9px}
.home-loading-products>div::before{content:"";display:block;aspect-ratio:1;background:#eef2ed;border-radius:12px}
.home-loading-products>div::after{content:"";display:block;width:65%;height:14px;margin-top:12px;background:#eef2ed;border-radius:4px}
html:not([data-ios-standalone]) #storefront-home[aria-busy=true] #homeHeroTitle{visibility:hidden}
/* Only a drag beginning on the fixed tab bar is excluded from content scroll.
   Android's own system-edge gesture and all normal page scrolling stay native. */
.mobile-nav{touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
.mobile-nav *{-webkit-user-drag:none;user-select:none;-webkit-user-select:none}

/* The tabs stay fixed while the route and its loading state are replaced. */
html[data-ios-standalone] body:has(#main) .mobile-nav{
  box-sizing:border-box;
  height:var(--ios-nav-height);
  min-height:0;
}
@media not all and (orientation:portrait) and (max-width:600px){
  html[data-ios-standalone] body:has(#main) .mobile-nav{
    padding-block:1px var(--ios-tab-inset);
    align-items:stretch;
    background:#fff;
    border-color:#e2e7e1;
    box-shadow:0 -2px 8px #0000000a;
  }
  html[data-ios-standalone] body:has(#main) .mobile-nav button{
    height:auto;
    min-height:44px;
    justify-content:flex-end;
    padding-block:1px 0;
    gap:3px;
  }
  html[data-ios-standalone] body:has(#main) .mobile-nav button.active{
    background:#e7f2e3;
    color:#075b39;
  }
}
html[data-ios-standalone] #main .product-detail-page .detail-action{
  bottom:var(--ios-nav-height);
}

/* Paint the web canvas before scripts run in an installed iOS app. */
@supports (-webkit-touch-callout:none){
  @media (display-mode:standalone),(display-mode:fullscreen){
    html:not([data-app-bootstrap-ready]),
    html:not([data-app-bootstrap-ready]) body{background-color:var(--ios-status-color,#064b31)}
  }
}

/* On portrait phones use the shared 60px centred buttons and their route
   colours. Reserve the same bar height for the page and fixed detail actions. */
@media (orientation:portrait) and (max-width:600px){
  html[data-ios-standalone]{
    --ios-header-inset:calc(var(--device-safe-top) + min(12px,var(--device-safe-top)));
    --ios-tab-inset:max(0px,calc(var(--device-safe-bottom) - 34px));
    --ios-nav-height:calc(74px + var(--ios-tab-inset));
  }
  html[data-ios-standalone] body:has(#main) .mobile-nav{
    padding-block:6px calc(6px + var(--ios-tab-inset));
    touch-action:auto;
  }
  html[data-ios-standalone] body:has(#main) .mobile-nav button{touch-action:manipulation}
  html[data-ios-standalone] #storefront-catalog .catalog-page-top > :is(h1,#catalogSupport){
    translate:0 -4px;
  }
  html[data-ios-standalone] #storefront-catalog .catalog-page-top h1{
    font-weight:650;
  }
  html[data-ios-standalone] #storefront-catalog #catalogSupport svg{
    stroke-width:2.3;
  }
}

/* With the iOS keyboard open, keep focused forms inside the visible viewport. */
html[data-ios-keyboard] dialog[open]:focus-within:not(#picker){
  --dialog-top:max(var(--device-safe-top),calc(var(--ios-visible-top) + 12px));
  position:fixed;
  top:var(--dialog-top);
  bottom:auto;
  margin-block:0;
  max-height:calc(var(--ios-visible-top) + var(--ios-visible-height) - var(--dialog-top) - 12px);
  overflow-y:auto;
}
html[data-ios-keyboard] #main > .support-chat-screen:focus-within{
  --chat-top:max(var(--device-safe-top),var(--ios-visible-top));
  position:fixed;
  top:var(--chat-top);
  left:50%;
  translate:-50% 0;
  width:min(100%,390px);
  height:calc(var(--ios-visible-top) + var(--ios-visible-height) - var(--chat-top));
  margin-inline:0;
}
html[data-ios-keyboard]:has(.support-chat-form:focus-within) .mobile-nav{
  visibility:hidden;
}

/* Extend the quiet left side of the original photograph through the status bar. */
@media (orientation: portrait) and (max-width: 600px) {
  html[data-ios-standalone] #main #storefront-home .hero {
    --photo-origin: var(--device-safe-top);
    background-image: url('/home-hero-commerce-v2.webp');
    background-size: 275% auto;
    background-position: left top;
    background-repeat: no-repeat;
  }
  html[data-ios-standalone] #main #storefront-home .hero::before {
    all: unset;
    content: "";
    display: block;
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: url('/home-hero-commerce-v2.webp') right 0 top var(--photo-origin) / 100% auto no-repeat;
    -webkit-mask-image: linear-gradient(to bottom, transparent var(--photo-origin), black calc(var(--photo-origin) + min(34px, var(--photo-origin))));
    mask-image: linear-gradient(to bottom, transparent var(--photo-origin), black calc(var(--photo-origin) + min(34px, var(--photo-origin))));
  }
  html[data-ios-standalone] #main #storefront-home .home-top {
    top: var(--ios-header-inset);
  }
  html[data-ios-standalone] #main #storefront-home .home-top + .hero {
    padding-top: calc(96px + var(--device-safe-top) + min(32px, var(--device-safe-top)));
  }
  @media (max-width: 350px) {
    html[data-ios-standalone] #main #storefront-home .home-top + .hero {
      padding-top: calc(92px + var(--device-safe-top) + min(32px, var(--device-safe-top)));
    }
  }
}

/* The game uses the space above the tab bar. Let its artwork shrink first. */
@media (max-width:600px), (pointer:coarse){
  html:has(#main > .points-wheel-page){
    overflow:clip;
    overscroll-behavior:none;
  }
  html #main:has(> .points-wheel-page){
    height:calc(var(--ios-page-height,var(--pwa-window-height,100dvh)) - var(--ios-nav-height,calc(74px + var(--device-safe-bottom))));
    padding-bottom:0;
    overflow:clip;
  }
  #main > .points-wheel-page{
    height:100%;
    min-height:0;
    padding-bottom:0;
  }
  #main .points-wheel-content,
  #main .points-wheel-page .points-draw-panels{
    flex:1 1 0;
    min-height:0;
  }
  #main .points-wheel-page .points-draw-panels{
    grid-template-rows:minmax(0,var(--draw-stage-size)) auto minmax(50px,auto) minmax(44px,auto);
    align-content:start;
  }
  #main .points-wheel-page .points-draw-stage-slot{
    min-height:0;
    container-type:size;
  }
  #main .points-wheel-page .points-draw-stage-slot .points-wheel-stage{
    max-width:max(0px,calc(100cqh - 25px));
  }
  #main .points-wheel-page .points-draw-stage-slot .egg-preview-scene{
    max-width:max(0px,calc(100cqh - 12px));
  }
}
@media (max-width:600px) and (orientation:portrait) and (max-height:720px){
  #main .points-wheel-content{
    display:grid;
    grid-template: auto minmax(0,1fr) / minmax(0,1fr) minmax(0,1fr);
    align-items:center;
    gap:4px;
    padding-bottom:4px;
  }
  #main .points-wheel-balance{min-height:48px;padding:2px 4px}
  #main .points-wheel-page .points-draw-panels{grid-column:1 / -1;align-self:stretch}
}
@media (pointer:coarse) and (orientation:landscape) and (max-height:540px){
  #main > .points-wheel-page{
    display:grid;
    grid-template: auto auto minmax(0,1fr) / minmax(0,.55fr) minmax(0,1.45fr);
    gap:8px 12px;
  }
  #main .points-wheel-content{display:contents}
  #main .points-wheel-page > .secondary-top{grid-area:1 / 1}
  #main .points-wheel-balance{grid-area:2 / 1}
  #main .points-draw-tabs{grid-area:3 / 1;align-self:start}
  #main .points-wheel-page .points-draw-panels{
    grid-area:1 / 2 / span 3;
    grid-template-columns:minmax(0,1fr) minmax(0,1fr);
    grid-template-rows:minmax(0,1fr) auto minmax(50px,auto) minmax(44px,auto) minmax(0,1fr);
    padding-block:var(--device-safe-top) 4px;
  }
  #main .points-wheel-page .points-draw-panels > .points-draw-panel,
  #main .points-wheel-page .points-wheel-card,
  #main .points-wheel-page .egg-draw-preview{
    grid-area:1 / 1 / -1 / -1;
    grid-template-columns:subgrid;
  }
  #main .points-wheel-page .points-draw-stage-slot{grid-area:1 / 1 / -1 / 2}
  #main .points-wheel-page #pointsWheelPanel .points-draw-stage-slot{width:100%;margin-inline:0}
  #main .points-wheel-card .points-draw-options{grid-area:2 / 2}
  #main .points-wheel-card .points-draw-action{grid-area:3 / 2}
  #main .points-wheel-page #wheelRecords{grid-area:4 / 2}
  #main .points-wheel-page .egg-preview-controls{grid-area:2 / 2 / 5 / 3}
}
