/* Mobile contract: stationary stage, reading sheet above it, one navigation dock.
   Kept in one media block so desktop staging never inherits phone geometry. */
@media (max-width:800px){
 html:has(body.realm-page){height:auto;overflow-x:clip;overflow-y:auto;scroll-padding-top:76px;scrollbar-width:none}
 html:has(body.realm-page)::-webkit-scrollbar{display:none}
 body.realm-page.paper-mode{--mobile-stage-height:62.5vw;--mobile-header-height:calc(64px + env(safe-area-inset-top));display:flex;flex-direction:column;position:relative;height:auto;min-height:100dvh;overflow:visible;background:color-mix(in srgb,var(--realm-mid,#9caf92) 32%,#f4e7ce);color:#354e48;padding:0;touch-action:pan-y}
 body.realm-page.paper-mode::after{display:none}
 body.realm-page.paper-mode::before{content:'';display:block;order:2;flex:none;height:var(--mobile-stage-height);width:100%}
 body.realm-page.paper-mode .realm-header{order:1;position:sticky;top:0;left:0;right:auto;transform:none;width:100%;height:var(--mobile-header-height);box-sizing:border-box;display:flex;align-items:center;padding:calc(8px + env(safe-area-inset-top)) 68px 8px 12px;flex:none;z-index:110;background:#f4e7ce}
 body.realm-page.paper-mode .realm-header>a:first-child{font-size:11px;padding:10px 12px;min-height:44px;box-sizing:border-box;display:flex;align-items:center;white-space:normal}
 body.realm-page.paper-mode .paper-sound-toggle{position:fixed;top:calc(10px + env(safe-area-inset-top));right:12px;z-index:115;width:44px;height:44px}
 body.realm-page.paper-mode .realm-environment{position:fixed;inset:var(--mobile-header-height) 0 auto;width:100%;height:var(--mobile-stage-height);overflow:hidden;z-index:0;opacity:1!important}
 body.realm-page.paper-mode .realm-environment .paper-stage>.paper-piece{width:100%;height:100%;left:0;top:0}
 body.realm-page.paper-mode .theatre-proscenium{position:fixed;inset:var(--mobile-header-height) 0 auto!important;width:100%;height:var(--mobile-stage-height);overflow:hidden;opacity:1;z-index:90}
 body.realm-page.paper-mode .theatre-proscenium>.theatre-closeup-frame{left:-41.758241758%;top:-33.333333333%;width:183.736263736%;height:196.041666667%;object-fit:fill}
 body.realm-page.paper-mode .theatre-proscenium.curtain-moving,body.realm-page.paper-mode .theatre-proscenium[data-state=closed]{z-index:200}
 body.realm-page.paper-mode .portal-navigation{position:static;display:block;order:3;padding:0;margin:0;height:0;min-height:0;border:0;background:none;z-index:auto}
 body.realm-page.paper-mode .portal-navigation>.side-portal{position:fixed;top:calc(var(--mobile-header-height) + 14vw);bottom:auto;width:clamp(52px,14vw,90px);max-width:none;min-height:44px;display:flex;flex-direction:column;gap:0;text-align:center;z-index:80;opacity:1}
 body.realm-page.paper-mode .portal-navigation>#realmPrev{left:12%;right:auto}
 body.realm-page.paper-mode .portal-navigation>#realmNext{right:12%;left:auto}
 body.realm-page.paper-mode .side-portal .portal-preview{width:100%;flex:none;box-sizing:border-box;border-width:3px!important}
 body.realm-page.paper-mode .side-portal .cord-line{display:block;top:auto;bottom:calc(100% - 5px);height:calc(14vw + var(--pull,0px));left:calc(50% - 2px);width:4px}
 body.realm-page.paper-mode .side-portal .cord-knot{display:block;width:16px;height:10px;margin-bottom:-4px}
 body.realm-page.paper-mode .side-portal .cord-fringe{display:block;width:61%;height:19px;margin-top:-4px}
 body.realm-page.paper-mode .side-portal small,body.realm-page.paper-mode .side-portal .pull-label,body.realm-page.paper-mode .portal-destination,body.realm-page.paper-mode .portal-gesture-hint{display:none}
 body.realm-page.paper-mode .side-portal b{align-self:center;max-width:90px;margin-top:4px;padding:3px 5px;background:#fff3dfeb;color:#354e48;text-shadow:none;border-radius:6px;font-size:11px;line-height:1.15;box-shadow:0 2px 4px #32241015}
 body.realm-page.paper-mode .realm-layout{order:4;position:relative;inset:auto;display:flex;flex-direction:column;gap:18px;min-height:0;width:100%;padding:26px 18px 12px!important;box-sizing:border-box;pointer-events:auto;z-index:100;isolation:isolate;background:linear-gradient(180deg,#efdbb4,color-mix(in srgb,var(--realm-mid,#9caf92) 48%,#f0e4c8));box-shadow:none}
 body.realm-page.paper-mode .realm-layout::before{content:'';position:absolute;left:0;right:0;top:-38px;height:39px;background:linear-gradient(0deg,#efdbb4,#efdbb400);pointer-events:none}
 body.realm-page.paper-mode .realm-copy{position:relative;inset:auto;transform:none;width:100%;padding:0;box-sizing:border-box}
 body.realm-page.paper-mode .realm-eyebrow{letter-spacing:2px;font-size:9px;color:#53634f}
 body.realm-page.paper-mode .realm-copy h1{color:#304f46;text-shadow:none;font-size:clamp(30px,8vw,40px);line-height:1.08;letter-spacing:-.6px;margin:10px auto 12px;max-width:440px}
 body.realm-page.paper-mode .realm-copy p{color:#435b50;text-shadow:none}
 body.realm-page.paper-mode #realmDescription{font-size:14px;line-height:1.6;max-width:370px}
 body.realm-page.paper-mode .realm-book{position:relative;inset:auto;transform:none;width:min(100%,380px);height:clamp(280px,85vw,360px);margin:0 auto 6px;padding:0;flex:none;isolation:isolate;border:1px solid #bda677;border-radius:26px;background:radial-gradient(ellipse at 50% 32%,#f6e4b9bb,transparent 65%),linear-gradient(140deg,color-mix(in srgb,var(--realm-mid,#9caf92) 60%,#e7d4a9),color-mix(in srgb,var(--realm-mid,#9caf92) 35%,#d3b681));box-shadow:inset 0 0 0 5px #f6e4bd66,0 14px 28px #54472925}
 body.realm-page.paper-mode .realm-book canvas{position:relative;z-index:1;width:100%;height:calc(100% - 36px);touch-action:pan-y}
 body.realm-page.paper-mode .realm-book>p{position:relative;z-index:1;color:#344e43;text-shadow:none;margin:0;padding:2px 14px 10px;font-size:11px;line-height:1.5}
 body.realm-page.paper-mode .realm-actions{order:5;position:relative;inset:auto;transform:none;width:100%;max-width:none;display:flex;flex-direction:column;gap:12px;align-items:center;padding:8px 22px calc(110px + env(safe-area-inset-bottom));box-sizing:border-box;z-index:100;background:color-mix(in srgb,var(--realm-mid,#9caf92) 48%,#f0e4c8)}
 body.realm-page.paper-mode .realm-actions>a{width:min(100%,380px);max-width:100%;box-sizing:border-box;text-align:center;justify-content:center;min-height:48px;font-size:14px!important;white-space:normal;padding:14px 18px}
 body.realm-page.paper-mode #createTheme{background:#f9edcdbb;border-color:#bda97f;color:#435b50;box-shadow:none}
 body.realm-page.paper-mode .mobile-world-nav{z-index:150;bottom:calc(8px + env(safe-area-inset-bottom));left:12px;right:12px;box-shadow:0 5px 18px #203c3026}
 body.realm-page.paper-mode .mobile-world-nav button{min-height:52px}
 body.realm-page.paper-mode .mobile-world-nav b{font-size:11px}
 body.realm-page.paper-mode .constellation{box-sizing:border-box;width:calc(100% - 24px);max-width:560px;max-height:calc(100dvh - 24px);padding:48px 14px 24px;border-width:1px;border-radius:22px;overflow-y:auto;overscroll-behavior:contain}
 body.realm-page.paper-mode .constellation h2{font-size:34px;line-height:1.1;margin:16px 0 24px}
 body.realm-page.paper-mode .constellation-map{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
 body.realm-page.paper-mode .constellation-map a{min-width:0;min-height:124px;font-size:13px}
 body.realm-page.paper-mode .constellation>p:last-child{font-size:12px;line-height:1.6}
 html:has(body.inline-reading){overflow:hidden}
 body.realm-page.paper-mode.inline-reading{overflow:hidden!important}
 body.realm-page.paper-mode .inline-reader{box-sizing:border-box;inset:0;width:100%;height:100dvh;max-width:none;max-height:100dvh;margin:0;padding: max(14px,env(safe-area-inset-top)) 12px max(18px,env(safe-area-inset-bottom));color:#354e48;background:transparent;overflow-y:auto;z-index:250}
 body.realm-page.paper-mode .inline-reader::backdrop{background:#faf1e1f5;backdrop-filter:blur(10px);animation:none}
 body.realm-page.paper-mode .inline-reader[data-phase=zooming]::backdrop{animation:mobileReadingFadeIn 1.2s ease both}
 body.realm-page.paper-mode .inline-reader[data-phase=closing]::backdrop{animation:mobileReadingFadeOut 1.2s ease both}
 body.realm-page.paper-mode .inline-heading{gap:12px;align-items:flex-start}
 body.realm-page.paper-mode .inline-heading small{color:#79633f;letter-spacing:1.6px;font-size:8px}
 body.realm-page.paper-mode .inline-heading h2{font:500 27px/1.1 'Cormorant Garamond',Georgia,serif;margin:8px 0;color:#354e48}
 body.realm-page.paper-mode .inline-reader button,body.realm-page.paper-mode .inline-reader select{color:#36564b;background:#fff9ed;border:1px solid #d3bfa0;min-height:44px}
 body.realm-page.paper-mode #inlineClose{width:44px;min-width:44px;height:44px;padding:0;border-radius:50%;font-size:0;display:grid;place-items:center}
 body.realm-page.paper-mode #inlineClose span{font-size:25px;margin:0}
 body.realm-page.paper-mode .inline-stage{width:100%;height:min(108vw,56dvh);margin:12px auto 16px}
 body.realm-page.paper-mode .inline-stage>canvas{filter:drop-shadow(0 12px 16px #5f452b30);touch-action:none}
 body.realm-page.paper-mode .inline-toolbar{max-width:380px;margin:auto;padding:10px;border:1px solid #e0ceb0;border-radius:20px;background:#fffaf0d9;gap:8px;box-sizing:border-box;flex-wrap:wrap}
 body.realm-page.paper-mode .inline-toolbar>button{width:46px;height:46px;padding:0;border-radius:50%;background:#385d52;color:#fff6e4}
 body.realm-page.paper-mode .inline-toolbar>span{min-width:120px;font-size:12px;color:#455e53}
 body.realm-page.paper-mode .inline-toolbar label{width:100%;justify-content:center;color:#566550;font-size:11px}
 body.realm-page.paper-mode .inline-toolbar select{padding:8px 12px;font-size:16px}
 body.realm-page.paper-mode .inline-hint{color:#566550;font-size:11px;line-height:1.5;padding:0 20px}
 @keyframes mobileReadingFadeIn{from{background:#faf1e100;backdrop-filter:blur(0)}to{background:#faf1e1f5;backdrop-filter:blur(10px)}}
 @keyframes mobileReadingFadeOut{from{background:#faf1e1f5;backdrop-filter:blur(10px)}to{background:#faf1e100;backdrop-filter:blur(0)}}
}
@media(max-width:800px) and (prefers-reduced-motion:reduce){body.realm-page.paper-mode .inline-reader[data-phase]::backdrop{animation-duration:200ms}}
