/* Path to UBI: one game frame of fixed size. The slot's height is reserved from viewport units alone, before any script runs,
   so nothing on the page moves when the game starts, changes screen or is resized by its script.
   --pu-top is the slot's distance from the top of the page: the site bar (56px, or 52px at 640 and under, plus any safe-area inset) and the band's padding.
   The script fits the frame into 100svh - top - 8 (landscape) or - 4 (portrait), so the slot is never shorter than the frame. */
.pu-stage{--pu-top:calc(68px + env(safe-area-inset-top,0px));padding-top:12px;padding-bottom:28px}
.pu-stage>.in,.pu-stage>.in.wide{display:flex;flex-direction:column;gap:18px;max-width:none;padding-left:16px;padding-right:16px}
.pu-slot{order:1;display:grid;place-items:center;box-sizing:border-box;min-height:max(216px,min(calc(100vh - var(--pu-top) - 8px),calc((100vw - 32px)*.54)));min-height:max(216px,min(calc(100svh - var(--pu-top) - 8px),calc((100vw - 32px)*.54)))}
.pu-head{order:2;display:flex;flex-direction:column;gap:14px;align-items:flex-start;width:100%;max-width:1080px;margin:0 auto;box-sizing:border-box}
.pu-stage noscript{order:3}
.pu-keys{margin:0;width:100%;max-width:none;font:500 13px/1.7 var(--mono);color:var(--paper)}
.pu-keys span{display:inline-block;margin-right:18px}
.pu-keys b{display:inline-block;font-weight:500;letter-spacing:.06em;text-transform:uppercase;background:var(--ink);color:var(--paper);padding:1px 8px;border-radius:var(--r-pill);margin-right:4px}
.app .hero.tight.pu-stage{padding-top:12px}
.app .hero.tight.pu-stage h1,.pu-stage h1{font-size:clamp(26px,3.4vw,40px)}
.pu-frame{position:relative;width:400px;height:216px;flex:none;background:#141018;border:0;outline:3px solid var(--ink);box-shadow:8px 8px 0 var(--pink);line-height:0;touch-action:manipulation;-webkit-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}
/* Until the script has fitted the frame (it writes the size as an inline style) the frame is not shown, so it is never seen at the wrong size
   and nothing is seen to move on load. The animation is only a safety net: if the size never arrives, show the frame anyway. */
.pu-frame:not([style]){visibility:hidden;animation:pu-show 0s linear 4s forwards}
@keyframes pu-show{to{visibility:visible}}
/* The script sizes the frame, the slot, the hit buttons and the field and measures them at once. The site turns every transition into a .01ms one
   when the device asks for less motion, which would make those measurements read the old box. Nothing here ever transitions. */
.pu-stage,.pu-slot,.pu-frame,.pu-frame canvas,.pu-hits,.pu-hits button,.pu-field,.pu-sr{transition:none!important}
.pu-frame:focus{outline:3px solid var(--ink)}
.pu-frame:focus-visible{outline:3px solid var(--yellow)}
.pu-frame canvas{display:block;width:100%;height:100%;image-rendering:pixelated;image-rendering:crisp-edges}
.pu-hits{position:absolute;inset:0;overflow:hidden}
.pu-hits button{position:absolute;margin:0;padding:0;border:0;background:transparent;color:transparent;font-size:0;cursor:pointer;-webkit-appearance:none;appearance:none;border-radius:0;touch-action:manipulation;-webkit-tap-highlight-color:transparent}
.pu-hits button:disabled{cursor:default}
.pu-hits button[hidden]{display:none}
.pu-hits button:focus{outline:none}
.pu-hits button:focus-visible{outline:2px solid var(--yellow);outline-offset:-4px}
.pu-hits .pu-sronly{left:0;top:0;width:1px;height:1px;clip-path:inset(50%)}
.pu-field{position:absolute;box-sizing:border-box;margin:0;font:500 16px/1.2 var(--mono);color:var(--ink);background:var(--paper);border:3px solid var(--ink);border-radius:0;padding:4px 8px;outline:3px solid var(--yellow);outline-offset:0;z-index:2}
.pu-field[hidden]{display:none}
.pu-sr{position:absolute;left:0;top:0;width:1px;height:1px;margin:0;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap;font-size:16px;line-height:1.2}
/* portrait: a phone held upright, or any narrow window. The same test is made in the script.
   The frame is drawn at a whole number of device pixels per art pixel, so it can be a little shorter than the space kept for it.
   The slot is the console's dark body: whatever is left over under the frame is grille, not a hole in the page. */
@media not all and (min-width:832px) and (min-height:512px){
  .pu-stage,.app .hero.tight.pu-stage{--pu-top:calc(60px + env(safe-area-inset-top,0px));padding-top:4px}
  .pu-stage>.in,.pu-stage>.in.wide{padding-left:0;padding-right:0;gap:20px}
  .pu-head,.pu-stage noscript{padding:0 16px}
  .pu-slot{min-height:clamp(504px,calc(100vh - var(--pu-top)),187.5vw);min-height:clamp(504px,calc(100svh - var(--pu-top)),187.5vw);place-items:start center;background:#141018 repeating-conic-gradient(#241d2e 0 25%,#141018 0 50%) 0 0/4px 4px;border-bottom:3px solid var(--ink)}
  .pu-frame{outline-width:0;box-shadow:none;width:320px;height:504px}
  .pu-keys span{display:block;margin-right:0}
}
@media (max-width:640px){
  .pu-stage,.app .hero.tight.pu-stage{--pu-top:calc(56px + env(safe-area-inset-top,0px))}
}
/* a phone on its side takes the landscape frame at whatever whole scale fits. Never under 480 wide: where the on-screen keyboard shrinks the viewport,
   an upright 320 phone becomes 320 by 300 while a name is typed, and it must stay in the portrait layout. The script makes the same test. */
@media (orientation:landscape) and (max-height:511px) and (min-width:480px){
  .pu-stage,.app .hero.tight.pu-stage{--pu-top:calc(68px + env(safe-area-inset-top,0px));padding-top:12px}
  .pu-stage>.in,.pu-stage>.in.wide{padding-left:16px;padding-right:16px;gap:18px}
  .pu-head,.pu-stage noscript{padding:0}
  .pu-slot{min-height:max(216px,min(calc(100vh - var(--pu-top) - 8px),calc((100vw - 32px)*.54)));min-height:max(216px,min(calc(100svh - var(--pu-top) - 8px),calc((100vw - 32px)*.54)));place-items:center;background:none;border-bottom:0}
  .pu-frame{outline-width:3px;box-shadow:8px 8px 0 var(--pink);width:400px;height:216px}
  .pu-keys span{display:inline-block;margin-right:18px}
}
@media (orientation:landscape) and (max-height:511px) and (min-width:480px) and (max-width:640px){
  .pu-stage,.app .hero.tight.pu-stage{--pu-top:calc(64px + env(safe-area-inset-top,0px))}
}
/* the art contact sheet, appended by #sheet for checking the drawings */
.pu-sheet{display:flex;flex-wrap:wrap;gap:14px;align-items:flex-end}
.pu-sheet figure{margin:0;display:flex;flex-direction:column;gap:4px;font:500 11px/1.2 var(--mono)}
.pu-sheet canvas{image-rendering:pixelated;image-rendering:crisp-edges;border:2px solid var(--ink);background:#fff}
/* the embed page (/path-to-ubi/embed/): the game frame alone on a dark ground, for playing inside a post. No site bar, so the slot starts at the top. */
body.embed{margin:0;padding:0;background:#141018;min-height:100vh;min-height:100svh;overflow:hidden}
body.embed .embed-main{margin:0}
body.embed .pu-stage,body.embed.app .hero.tight.pu-stage,body.embed .hero.first.tight.pu-stage{--pu-top:0px;padding:0!important;border:0;background:#141018}
body.embed .pu-stage>.in,body.embed .pu-stage>.in.wide{padding:0;gap:0}
body.embed .pu-slot{min-height:0;height:100vh;height:100svh;border-bottom:0;place-items:center;overflow:hidden}
html:has(body.embed){overflow:hidden}
body.embed .pu-frame{box-shadow:none;outline-width:0}
body.embed .embed-foot{position:absolute;left:0;top:0;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
/* the embed page's one control: full screen where the host allows it, otherwise a link to the full page. It sits beside or under the frame, never on it. */
.pu-big{position:fixed;z-index:3;box-sizing:border-box;display:flex;align-items:center;justify-content:center;gap:8px;margin:0;padding:0;background:#241d2e;color:#fffdf6;border:2px solid #4a3f5c;font:500 11px/1 var(--mono);letter-spacing:.1em;text-transform:uppercase;text-decoration:none;cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition:none!important}
.pu-big svg{display:block;flex:none;width:14px;height:14px}
.pu-big.icon span{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.pu-big.strip{border-width:2px 0 0}
.pu-big.off{display:none}
.pu-big:hover,.pu-big:focus-visible{background:#ffe033;color:#141018;border-color:#ffe033;outline:none}