/* Mobile fit. Loaded last; overrides the 9:16 canvas rules spread across earlier layers.
   The painted UI stays a 9:16 canvas (#app). On taller phones it sits on the bottom
   safe edge, and the space above is filled by a mirrored continuation of the scene art. */

:root{
  --sat:env(safe-area-inset-top,0px);
  --sab:env(safe-area-inset-bottom,0px);
  /* Canvas height: the screen minus notch and home indicator, capped by the 9:16 width. */
  --cvh:min(calc(100dvh - var(--sat) - var(--sab)),177.7778vw);
  --cvw:min(100vw,calc(var(--cvh) * .5625));
  --band:calc(100dvh - var(--sab) - var(--cvh));
  --scene:url("v5/home-base.webp");
  --strip:#061313;
  --edge:#111816;
  -webkit-text-size-adjust:100%;text-size-adjust:100%;
}
html body{display:grid;place-items:end center;box-sizing:border-box;padding-bottom:var(--sab);background:#070d0b}
html #app{width:var(--cvw);height:var(--cvh);
  /* Continue the nav colour under the home indicator. */
  box-shadow:0 var(--sab) 0 0 var(--strip),0 0 60px #000a}

/* Ambient backdrop for side bands (tablets, desktop windows). */
html body::before{content:"";position:fixed;inset:-40px;z-index:-2;pointer-events:none;
  background:linear-gradient(#060c0ad0,#060c0ae8),var(--scene) center/cover;filter:blur(22px)}
/* Above the canvas on tall screens: the panel silk texture, darkening toward the status
   bar and settling into the colour of the scene's own top edge at the seam. */
html body::after{content:"";position:fixed;z-index:-1;pointer-events:none;top:0;left:50%;
  width:var(--cvw);height:max(0px,var(--band));transform:translateX(-50%);
  background:linear-gradient(#050a08 0%,#050a08b0 30%,transparent 62%,var(--edge) 100%),url("v6/silk.webp") var(--edge)}

body:has(#opening[data-stage=film]:not([hidden])){--scene:url("opening-first.jpg");--edge:#271f1a;--strip:#1e2424}
body:has(#opening[data-stage=gate]:not([hidden])){--scene:url("folio-landscape.jpg");--edge:#4b4a3b;--strip:#2a2a22}
body:has(#lobby:not([hidden]) #events:not([hidden])){--scene:url("v5/events-base.webp");--edge:#19160f}
body:has(#lobby:not([hidden]) #staking:not([hidden])){--scene:url("v5/ritual/station.webp");--edge:#181f1a}
body:has(#lobby:not([hidden]) #shop:not([hidden])){--scene:url("v7/exclusive.webp");--edge:#0b1614;--strip:#141c17}

/* Phones held sideways: the 9:16 canvas would be ~220px wide, so ask for portrait. */
#rotate-hint{display:none}
@media (orientation:landscape) and (max-height:500px) and (pointer:coarse){
  #rotate-hint{display:grid;place-content:center;gap:12px;position:fixed;inset:0;z-index:2147483647;
    background:#08110eF2;color:#ecd398;text-align:center;font:17px/1.6 "KaiTi","STKaiti","Songti SC",serif;letter-spacing:.08em}
  #rotate-hint::before{content:"";justify-self:center;width:34px;height:56px;border:2px solid #d8b875;border-radius:7px;
    transform:rotate(90deg);animation:rotate-hint 2.4s ease-in-out infinite}
  @keyframes rotate-hint{0%,25%{transform:rotate(90deg)}55%,100%{transform:rotate(0)}}
}

/* iOS zooms the page when a focused input is under 16px. */
html #query,html #bag-filter{font-size:max(16px,3.65cqw)!important}
html #searchbox input{align-self:stretch;height:auto}
html #bag-filter{min-height:38px;box-sizing:border-box}

/* Readability floors for text drawn in width-relative units on narrow phones. */
html #settle-time,html #pinned-yield{font-size:max(11px,2.65cqw)!important}
html #detail-yield{font-size:max(11px,2.58cqw)!important}
html #route-daily,html .yield span{font-size:max(11.5px,3.1cqw)!important}
html #stone-tier{font-size:max(12px,3.24cqw)!important}
html #all-paths{font-size:max(12px,3.35cqw)!important}
html #v7-signout{font-size:max(11.5px,3.2cqw)!important}
html #v5-catalog .caption>span,html #v5-catalog .caption>small{font-size:max(11px,3.05cqw)!important}
html #atlas-account,html #map-phase,html #map-price,html #map-from,html .atlas-tiers span{font-size:max(11.5px,3cqw)!important}
html #map-effect{font-size:max(12px,3.24cqw)!important}
html #map-preview{font-size:max(12px,3.38cqw)!important}
html #map-board .map-node{font-size:max(11.5px,3.43cqw)!important}

/* Larger invisible touch areas around compact text buttons. */
html #manage-stakes,html #demo-day{position:relative}
html #manage-stakes::after,html #demo-day::after,html #all-paths::after{content:"";position:absolute;inset:-8px -5px}
html #account-menu{position:relative}
html #account-menu::after{content:"";position:absolute;inset:-6px -4px}
/* Event signs live on the scaled 941px stage: 22 stage px is ~8 screen px on a 360px phone. */
html .v5sign::before{content:"";position:absolute;inset:-22px -6px}
