/* ozboy.css — OZ BOY, the handheld that phones get instead of the desk.
   The device is authored in "device px" (300 wide in portrait, 600 x 300 in landscape) and scaled
   to the phone with CSS zoom (set from ozboy.js), so it stays crisp at any size. The screen (#lcd)
   is 160 logical px wide and zoomed again to fill the bezel. */

@font-face {
  font-family: 'PS2P';
  src: url('../assets/fonts/press-start-2p-latin-400-normal.woff2') format('woff2');
  font-display: block;
}
@font-face {
  font-family: 'VT323';
  src: url('../assets/fonts/vt323-latin-400-normal.woff2') format('woff2');
  font-display: block;
}
@font-face {
  font-family: 'Archivo Black';
  src: url('../assets/fonts/archivo-black-latin-400-normal.woff2') format('woff2');
  font-display: swap;
}

:root {
  --ink: #14213d;
  --navy: #012169;
  --cream: #fffaf0;
  --coral: #ff5a5f;
  --yellow: #ffd23f;
  --sand: #f2d9a8;
  --edge: #0b2163;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  background: var(--sand);
  color: var(--ink);
  font: 15px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; margin: 0; cursor: pointer; }
a { color: inherit; }

/* ---------------- the beach ---------------- */
#scene { position: fixed; inset: 0; overflow: hidden; }
#scene::before {   /* sand grain */
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(160, 110, 50, .16) 0 1px, transparent 1.5px) 0 0 / 9px 11px,
    radial-gradient(circle at 70% 60%, rgba(255, 255, 255, .5) 0 1px, transparent 1.5px) 0 0 / 13px 7px,
    linear-gradient(160deg, #f6e2b6, #ecc98f);
}
.towel {
  position: absolute; left: 5%; right: 5%; top: 4%; bottom: 3%;
  border-radius: 8px;
  transform: rotate(-3deg);
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .045) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, #ff7a59 0 12%, #fff3dc 12% 21%, #23b0a0 21% 33%, #fff3dc 33% 42%, #ffd23f 42% 46%, #fff3dc 46% 50%);
  box-shadow: 0 10px 24px -10px rgba(90, 50, 10, .45), inset 0 0 0 2px rgba(255, 255, 255, .25);
  transition: transform .7s cubic-bezier(.2, .8, .2, 1), filter .7s;
}
.towel::before, .towel::after {   /* fringe */
  content: ''; position: absolute; left: 3%; right: 3%; height: 12px;
  background: repeating-linear-gradient(90deg, #fff3dc 0 3px, transparent 3px 7px);
}
.towel::before { top: -11px; }
.towel::after { bottom: -11px; }
.palm {   /* a palm frond's shadow drifting over the towel */
  position: absolute; right: -18%; top: -12%; width: 95%; height: 70%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cg fill='%23142a3a'%3E%3Cpath d='M200 0C150 30 110 60 80 110c18-14 30-20 44-22-20 12-34 26-44 40 22-16 40-22 58-22-22 10-38 22-50 38 24-14 44-18 62-16-24 8-40 18-52 32 50-24 90-40 102-44z'/%3E%3Cpath d='M200 20C170 70 150 120 150 190c6-20 12-30 20-38-6 18-8 34-6 48 6-22 14-36 24-44-6 18-6 34-2 46 4-24 10-40 14-48z'/%3E%3C/g%3E%3C/svg%3E") no-repeat 100% 0 / contain;
  opacity: .14;
  filter: blur(2px);
  transform-origin: 100% 0;
  animation: sway 7s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes sway { from { transform: rotate(-3deg); } to { transform: rotate(4deg) translateY(6px); } }

.tag {
  position: absolute; left: 50%; top: calc(var(--safe-t) + 22px);
  transform: translateX(-50%) rotate(-2deg);
  background: #fff; padding: 10px 16px 8px; border-radius: 4px; text-align: center;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .12), 0 8px 18px -8px rgba(0, 0, 0, .35);
  transition: opacity .35s, transform .5s;
  white-space: nowrap;
}
.tag::before {   /* tape */
  content: ''; position: absolute; left: 50%; top: -8px; width: 54px; height: 16px; margin-left: -27px;
  background: rgba(255, 236, 170, .75); transform: rotate(3deg);
}
.tag h1 { margin: 0; font: 14px/1.2 'PS2P', monospace; color: var(--navy); letter-spacing: 1px; }
.tag p { margin: 4px 0 0; font: 19px/1 'VT323', monospace; color: #5b6478; }

.chip {
  position: absolute; z-index: 5; top: calc(var(--safe-t) + 10px);
  height: 36px; padding: 0 14px; border-radius: 18px;
  background: rgba(255, 255, 255, .92); color: var(--ink);
  font: 600 14px system-ui, sans-serif;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .12), 0 6px 14px -6px rgba(0, 0, 0, .3);
  transition: opacity .3s, transform .3s;
}
.chip:active { transform: translateY(1px); }
#putdown { left: 12px; opacity: 0; pointer-events: none; }
#mute { right: 12px; width: 36px; padding: 0; display: grid; place-items: center; }
#mute svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
#mute .spk { fill: var(--ink); }
#mute .x { display: none; }
#mute.muted .wave { display: none; }
#mute.muted .x { display: inline; }

#hint {
  position: absolute; left: 0; right: 0; bottom: calc(var(--safe-b) + 112px); margin: 0;
  text-align: center; pointer-events: none;
  font: 600 15px system-ui, sans-serif; color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .55), 0 0 12px rgba(0, 0, 0, .3);
  transition: opacity .3s;
}
#hint span { display: inline-block; animation: poke 1.2s ease-in-out infinite; }
@keyframes poke { 50% { transform: translateY(-5px); } }

.pills {
  position: absolute; z-index: 4; left: 16px; right: 16px; bottom: calc(var(--safe-b) + 44px);
  display: flex; gap: 10px; max-width: 420px; margin: 0 auto;
  transition: opacity .3s, transform .4s;
}
.pills button {
  flex: 1; height: 48px; border-radius: 14px;
  font: 700 16px system-ui, sans-serif;
  background: var(--ink); color: #fff;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .3);
}
.pills button + button { background: #fff; color: var(--ink); }
.pills button:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .3); }
.foot {
  position: absolute; z-index: 4; left: 0; right: 0; bottom: calc(var(--safe-b) + 14px); margin: 0;
  text-align: center; font: 13px system-ui, sans-serif; color: #3b2a14;
  transition: opacity .3s;
}
.foot a { font-weight: 600; }
.foot span { opacity: .7; }

/* held: the towel drops away, the chrome swaps */
body.held .towel { transform: rotate(-3deg) scale(1.06); filter: brightness(.88) saturate(.9); }
body.held .tag, body.held #hint, body.held .foot { opacity: 0; pointer-events: none; }
body.held .tag { transform: translateX(-50%) translateY(-20px) rotate(-2deg); }
body.held .pills { opacity: 0; transform: translateY(30px); pointer-events: none; }
body.held #putdown { opacity: 1; pointer-events: auto; }
body.booting #hint { opacity: 0; }

/* landscape: the chrome tucks into the margins beside the handheld */
body.land #hint { display: none; }
body.land .tag { left: 16px; transform: rotate(-2deg); }
body.land.held .tag { transform: translateY(-20px) rotate(-2deg); }
body.land .pills { left: auto; right: 16px; width: 250px; }
body.land #putdown { left: 6px; width: 36px; padding: 0; }
body.land #putdown span { display: none; }
body.land #mute { right: 6px; }

/* ---------------- the handheld ---------------- */
#stage { position: absolute; inset: 0; perspective: 1500px; perspective-origin: 50% 35%; }
#holder, #shadow {
  position: absolute;
  left: var(--hx); top: var(--hy); width: var(--hw); height: var(--hh);
}
#holder {
  transform-style: preserve-3d;
  transition: transform .62s cubic-bezier(.2, .9, .25, 1.06);
  -webkit-tap-highlight-color: transparent;
}
body.rest #holder {
  cursor: pointer;
  transform: translate3d(var(--rest-dx, 0px), var(--rest-dy), 0) scale(var(--rest-s)) rotateX(24deg) rotateZ(-5deg);
}
#shadow {
  border-radius: 12%;
  background: rgba(70, 35, 0, .5);
  filter: blur(14px);
  transition: transform .62s cubic-bezier(.2, .9, .25, 1.06), opacity .62s;
  transform: translate3d(calc(var(--rest-dx, 0px) + 14px), calc(var(--rest-dy) + 26px), 0) scale(var(--rest-s)) rotateX(24deg) rotateZ(-5deg) scaleY(.92);
  opacity: .55;
}
body.held #shadow { transform: translate3d(0, 34px, -60px) scale(1.04); opacity: .22; }
.slab i {   /* the shell's thickness, seen when it tilts */
  position: absolute; inset: 0;
  border-radius: calc(22px * var(--z)) calc(22px * var(--z)) calc(78px * var(--z)) calc(22px * var(--z));
  background: var(--edge);
}
.slab i:nth-child(1) { transform: translateZ(-2px); }
.slab i:nth-child(2) { transform: translateZ(-4px); }
.slab i:nth-child(3) { transform: translateZ(-6px); }
.slab i:nth-child(4) { transform: translateZ(-8px); }
.slab i:nth-child(5) { transform: translateZ(-10px); }
.slab i:nth-child(6) { transform: translateZ(-12px); background: #08184a; }
body.held .slab { visibility: hidden; transition: visibility 0s .62s; }

#boy {
  position: absolute; left: 0; top: 0;
  width: 300px; height: var(--hd);
  zoom: var(--z);
  border-radius: 22px 22px 78px 22px;
  box-shadow: 0 6px 0 var(--edge), 0 8px 2px rgba(0, 0, 0, .2), 0 30px 40px -16px rgba(0, 0, 0, .5);
  --shell: linear-gradient(165deg, rgba(58, 110, 240, .62), rgba(14, 44, 160, .78));
  --logo: rgba(255, 255, 255, .9);
  --pad: #182240;
  --btn: #eef2fa;
  --btnEdge: #9aa6c4;
  --pill: #20294a;
}
#boy > .guts, #boy > .plastic { position: absolute; inset: 0; border-radius: inherit; }
#boy > .guts { background-color: #0c2f3b; background-size: 100% 100%; }
#boy > .plastic {
  background: var(--shell);
  box-shadow: inset 0 2px 1px rgba(255, 255, 255, .6), inset 0 -12px 20px rgba(0, 0, 0, .22),
    inset 10px 0 16px rgba(255, 255, 255, .14), inset -10px 0 16px rgba(0, 0, 0, .14);
}
#boy > .plastic::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(120% 60% at 15% 0%, rgba(255, 255, 255, .26), transparent 55%);
}

.switch { position: absolute; top: -6px; left: 30px; width: 54px; height: 8px; border-radius: 4px 4px 0 0; background: var(--edge); }
.switch i {
  position: absolute; left: 4px; top: 1px; width: 18px; height: 6px; border-radius: 2px;
  background: linear-gradient(#f2f4fa, #b9c0d4);
  transition: left .2s cubic-bezier(.5, 0, .3, 1.4);
}
.switch span { position: absolute; top: 11px; left: 2px; font: 4px 'PS2P', monospace; color: rgba(255, 255, 255, .7); white-space: nowrap; }
#boy.on .switch i { left: 32px; }
.switch { cursor: pointer; }
.switch::after { content: ''; position: absolute; inset: -14px -10px -18px; }   /* thumb-sized touch target */
.switch.nudge { animation: nudge .5s ease-in-out 2; box-shadow: 0 0 0 3px var(--yellow), 0 0 14px 4px rgba(255, 210, 63, .7); }
@keyframes nudge { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

.bezel {
  position: absolute; left: 14px; right: 14px; top: 20px; bottom: 250px;
  background: linear-gradient(#474b59, #3a3e4b);
  border-radius: 9px 9px 36px 9px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .7), 0 1px 0 rgba(255, 255, 255, .35);
}
.bezel .lbl {
  position: absolute; top: 8px; left: 12px; right: 12px; display: flex; align-items: center; gap: 6px;
  font: 5px 'PS2P', monospace; color: #c9cbd6; letter-spacing: .5px; white-space: nowrap;
}
.bezel .lbl i { flex: 1; height: 2px; background: linear-gradient(#b1407a 0 50%, #3f5fbf 50%); }
.led { position: absolute; left: 7px; top: 42%; width: 8px; height: 8px; border-radius: 50%; background: #5a1f22; transition: background .2s, box-shadow .2s; }
#boy.on .led { background: #ff3b30; box-shadow: 0 0 6px 2px rgba(255, 59, 48, .65); }
.ledlbl { position: absolute; left: 3px; top: calc(42% + 12px); font: 3px 'PS2P', monospace; color: #c9cbd6; }

#screen {
  position: absolute; left: 22px; right: 22px; top: 20px; bottom: 16px;
  display: flex; align-items: center; justify-content: center;
  background: #0f1513; border-radius: 2px; overflow: hidden;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .35);
}
#screen .glass {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(125deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, 0) 36%), radial-gradient(130% 100% at 50% 50%, transparent 70%, rgba(0, 0, 0, .25));
}
#screen.off .glass { background: linear-gradient(125deg, rgba(255, 255, 255, .2), rgba(255, 255, 255, .02) 40%, rgba(255, 255, 255, 0) 60%), #1a2622; }
#screen.off #lcd { visibility: hidden; }

.logo {
  position: absolute; left: 24px; bottom: 214px;
  font: 21px 'Archivo Black', 'Arial Black', Impact, system-ui, sans-serif; font-weight: 900;
  color: var(--logo); transform: skewX(-12deg); letter-spacing: .5px;
  display: flex; align-items: baseline; gap: 6px;
}
.logo em { font: 7px 'PS2P', monospace; font-style: normal; letter-spacing: 1px; }
.logo em b { font-weight: 400; }
.logo em b:nth-child(1) { color: #ff4d6d; } .logo em b:nth-child(2) { color: #ffb703; } .logo em b:nth-child(3) { color: #2ec4b6; }
.logo em b:nth-child(4) { color: #7fb2ff; } .logo em b:nth-child(5) { color: #c08cff; }

.ctl { position: absolute; left: 0; right: 0; bottom: 0; height: 214px; }
body.rest .ctl { pointer-events: none; }
.dpad { position: absolute; left: 22px; top: 24px; width: 100px; height: 100px; touch-action: none; }
.dpad::before { content: ''; position: absolute; inset: -6px; border-radius: 50%; background: rgba(0, 0, 0, .14); box-shadow: inset 0 2px 5px rgba(0, 0, 0, .3); }
.dpad::after { content: ''; position: absolute; inset: -18px; }   /* bigger touch target */
.dpad i, .dpad b, .dpad u { transition: transform .06s; }
.dpad i { position: absolute; background: var(--pad); border-radius: 4px; box-shadow: inset 0 2px 1px rgba(255, 255, 255, .18), 0 3px 0 rgba(0, 0, 0, .5), 0 5px 6px rgba(0, 0, 0, .3); }
.dpad i:nth-child(1) { left: 34px; top: 0; width: 32px; height: 100px; }
.dpad i:nth-child(2) { left: 0; top: 34px; width: 100px; height: 32px; }
.dpad b { position: absolute; left: 42px; top: 42px; width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 50% 35%, rgba(0, 0, 0, .45), rgba(255, 255, 255, .08)); }
.dpad u { position: absolute; width: 0; height: 0; border: 5px solid transparent; opacity: .5; }
.dpad u:nth-of-type(1) { left: 45px; top: 6px; border-bottom-color: #000; }
.dpad u:nth-of-type(2) { left: 45px; top: 84px; border-top-color: #000; }
.dpad u:nth-of-type(3) { left: 6px; top: 45px; border-right-color: #000; }
.dpad u:nth-of-type(4) { left: 84px; top: 45px; border-left-color: #000; }
.dpad { transition: transform .06s; transform-style: preserve-3d; }
.dpad[data-dir="up"] { transform: perspective(240px) rotateX(9deg); }
.dpad[data-dir="down"] { transform: perspective(240px) rotateX(-9deg); }
.dpad[data-dir="left"] { transform: perspective(240px) rotateY(-9deg); }
.dpad[data-dir="right"] { transform: perspective(240px) rotateY(9deg); }

.ab { position: absolute; left: 156px; top: 30px; width: 128px; height: 72px; transform: rotate(-25deg); }
.ab::before { content: ''; position: absolute; inset: 4px -4px; border-radius: 40px; background: rgba(0, 0, 0, .13); box-shadow: inset 0 2px 5px rgba(0, 0, 0, .28); }
.btn {
  position: absolute; top: 10px; width: 52px; height: 52px; border-radius: 50%; touch-action: none;
  background: radial-gradient(circle at 38% 30%, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0) 45%), var(--btn);
  box-shadow: 0 4px 0 var(--btnEdge), 0 7px 8px rgba(0, 0, 0, .35);
  transition: transform .05s, box-shadow .05s;
}
.btn::after { content: ''; position: absolute; inset: -10px; border-radius: 50%; }
.btn.b { left: 2px; }
.btn.a { left: 70px; }
.btn span { position: absolute; top: 62px; left: 0; right: 0; text-align: center; font: 9px 'PS2P', monospace; color: var(--logo); transform: rotate(25deg); }
.btn.down { transform: translateY(3px); box-shadow: 0 1px 0 var(--btnEdge), 0 2px 3px rgba(0, 0, 0, .35); }
/* what each button does right now, printed under it and updated per screen */
.btn span em, .ss span em { display: block; margin-top: 3px; font: 12px/1 'VT323', monospace; font-style: normal; letter-spacing: .5px; color: var(--yellow); white-space: nowrap; }
.ss span em { margin-top: 2px; }
.btn span em:empty, .ss span em:empty, .cap:empty { display: none; }
.dcap { position: absolute; left: 22px; top: 136px; width: 100px; text-align: center; font: 12px/1 'VT323', monospace; letter-spacing: .5px; color: var(--yellow); white-space: nowrap; }

.ss { position: absolute; top: 150px; left: 84px; display: flex; gap: 20px; }
.ss button {
  position: relative; width: 44px; height: 12px; border-radius: 6px; touch-action: none;
  background: var(--pill); transform: rotate(-25deg);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, .1), 0 2px 0 rgba(0, 0, 0, .45);
  transition: transform .05s, box-shadow .05s;
}
.ss button::after { content: ''; position: absolute; inset: -12px -6px; }
.ss button.down { transform: rotate(-25deg) translateY(2px); box-shadow: 0 0 0 4px rgba(0, 0, 0, .1), 0 0 0 rgba(0, 0, 0, .45); }
.ss span { position: absolute; top: 18px; left: -6px; width: 56px; text-align: center; font: 5px 'PS2P', monospace; color: var(--logo); }
.grill { position: absolute; left: 222px; top: 124px; display: flex; gap: 7px; transform: rotate(-30deg); }
.grill i { width: 5px; height: 44px; border-radius: 3px; background: rgba(0, 0, 0, .28); box-shadow: inset 0 2px 3px rgba(0, 0, 0, .45), 0 1px 0 rgba(255, 255, 255, .25); }

/* cartridges: the one in the slot sits behind the shell, so only its top sticks out;
   #flycart is the same cartridge flying across the screen on its way in or out */
.cartbody {
  border-radius: 7px 7px 3px 3px;
  background: linear-gradient(90deg, #8a8e97, #bcc0c9 12%, #aeb2bb 88%, #868a93);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .55), inset 0 -3px 0 rgba(0, 0, 0, .12);
}
.cartbody .grip { position: absolute; left: 8px; right: 8px; top: 5px; height: 9px; border-radius: 2px;
  background: repeating-linear-gradient(90deg, rgba(0, 0, 0, .22) 0 2px, rgba(255, 255, 255, .3) 2px 3px, transparent 3px 6px); }
.cartbody .label { position: absolute; left: 10px; right: 10px; top: 17px; height: 92px; border-radius: 3px; overflow: hidden;
  background: #fff; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .7), 0 1px 0 rgba(0, 0, 0, .25); }
.cartbody .label b { display: block; height: 15px; padding-top: 4px; text-align: center; font: 7px 'PS2P', monospace; font-weight: 400; color: #fff; background: var(--cart-c, var(--navy)); }
.cartbody .label span { display: block; height: 77px; background-size: 100% 100%; image-rendering: pixelated; }

.slotcart { position: absolute; left: 85px; top: -44px; width: 130px; height: 120px; visibility: hidden; transform: translateY(-76px); }
.slotcart.seated { visibility: visible; transform: none; }
.slotcart.push { visibility: visible; animation: cartpush .36s cubic-bezier(.6, 0, .9, .6) forwards; }
.slotcart.pop { visibility: visible; animation: cartpop .3s cubic-bezier(.2, 1.4, .4, 1) forwards; }
@keyframes cartpush {
  0% { transform: translateY(-76px); }
  58% { transform: translateY(5px); animation-timing-function: ease-out; }
  78% { transform: translateY(-2px); }
  100% { transform: translateY(0); }
}
@keyframes cartpop { 0% { transform: translateY(0); } 55% { transform: translateY(-92px); } 100% { transform: translateY(-76px); } }

#flycart { position: fixed; z-index: 7; display: none; pointer-events: none; filter: drop-shadow(0 18px 16px rgba(0, 0, 0, .45)); }
#flycart .cartbody { position: relative; width: 130px; height: 120px; zoom: var(--fz, 1); }
#flycart.in { display: block; animation: flyin 1.15s forwards; }
#flycart.out { display: block; animation: flyout .76s forwards; }
@keyframes flyin {
  0% { transform: translate(var(--x0), var(--y0)) rotate(28deg) scale(1.45); animation-timing-function: cubic-bezier(.2, .75, .3, 1); }
  42% { transform: translate(var(--x1), var(--y1)) rotate(-5deg) scale(1.65); animation-timing-function: ease-in-out; }
  64% { transform: translate(var(--x1), calc(var(--y1) - 8px)) rotate(0deg) scale(1.7); animation-timing-function: cubic-bezier(.55, 0, .8, .45); }
  100% { transform: translate(0, 0) rotate(0deg) scale(1); }
}
@keyframes flyout {
  0% { transform: translate(0, 0) rotate(0deg) scale(1); animation-timing-function: cubic-bezier(.2, .6, .4, 1); }
  38% { transform: translate(calc(var(--x1) * .5), calc(var(--y1) * .45)) rotate(-8deg) scale(1.4); animation-timing-function: cubic-bezier(.6, 0, .9, .6); }
  100% { transform: translate(var(--x0), var(--y0)) rotate(30deg) scale(1.5); }
}
#flycart.in .label::after {   /* the label catching the light */
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .8) 50%, transparent 65%);
  transform: translateX(-130%); animation: shine .5s .52s ease-in-out forwards;
}
@keyframes shine { to { transform: translateX(130%); } }

#dim {
  position: absolute; inset: 0; z-index: 6; pointer-events: none; opacity: 0; transition: opacity .35s;
  background: radial-gradient(120% 90% at 50% 38%, rgba(10, 14, 26, .3), rgba(10, 14, 26, .7));
}
body.swapping #dim { opacity: 1; }

/* the moment it seats: the handheld jolts, a flash of light at the slot, and the screen flashes on */
#boy.seat { animation: seat .3s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes seat { 30% { transform: translateY(6px) rotate(-.8deg); } 60% { transform: translateY(-2px) rotate(.3deg); } }
.spark { position: absolute; left: 150px; top: 0; width: 0; height: 0; pointer-events: none; }
.spark.go::before {
  content: ''; position: absolute; left: -100px; top: -16px; width: 200px; height: 32px;
  background: radial-gradient(closest-side, rgba(255, 255, 255, .95), rgba(255, 246, 200, .5) 45%, rgba(255, 255, 255, 0));
  animation: sparkb .42s ease-out forwards;
}
@keyframes sparkb { from { transform: scaleX(.3); opacity: 1; } to { transform: scaleX(1.4); opacity: 0; } }
#screen.pflash .glass { animation: pflash .4s ease-out; }
@keyframes pflash { 0% { box-shadow: inset 0 0 0 999px rgba(255, 255, 255, .9); } 100% { box-shadow: inset 0 0 0 999px rgba(255, 255, 255, 0); } }
body.land .spark { left: 300px; }
body.land .slotcart { left: 235px; }

/* landscape: a wide handheld, screen in the middle, controls under the thumbs */
body.land #boy { width: 600px; height: 300px; border-radius: 34px 34px 70px 70px / 34px 34px 90px 90px; }
body.land .slab i { border-radius: calc(34px * var(--z)) calc(34px * var(--z)) calc(70px * var(--z)) calc(70px * var(--z)) / calc(34px * var(--z)) calc(34px * var(--z)) calc(90px * var(--z)) calc(90px * var(--z)); }
body.land .bezel { left: 150px; right: 150px; top: 16px; bottom: 40px; border-radius: 10px; }
body.land .switch { left: 64px; }
body.land .logo { left: auto; right: 22px; bottom: 16px; font-size: 15px; }
body.land .ctl { top: 0; height: auto; }
body.land .dpad { left: 28px; top: 96px; }
body.land .ab { left: 452px; top: 96px; width: 128px; }
body.land .ss { left: 168px; top: 272px; gap: 150px; }
body.land .ss button { transform: none; }
body.land .ss button.down { transform: translateY(2px); }
body.land .ss span { top: auto; bottom: 16px; }
body.land .dcap { left: 28px; top: 206px; }
body.land .grill { left: 40px; top: 222px; transform: rotate(-20deg) scale(.6); }

/* ---------------- the screen ---------------- */
#lcd {
  position: relative;
  width: 160px; height: var(--lcdh, 160px);
  zoom: var(--lz, 1.425);
  display: flex; flex-direction: column;
  background: var(--cream); color: var(--ink);
  font: 8px/1 'PS2P', monospace;
  overflow: hidden;
}
#lcd .bar {
  flex: none; height: 12px; padding: 0 3px 0 4px;
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  background: var(--navy); color: #fff; white-space: nowrap;
}
#lcd .bar .ttl { overflow: hidden; text-overflow: clip; }
#lcd .bar .stat { display: flex; align-items: center; gap: 3px; }
#lcd .note { font: 10px/1 'VT323', monospace; color: var(--yellow); }
#lcd .note.off { color: #6e7fae; text-decoration: line-through; }
#lcd .batt { position: relative; width: 12px; height: 6px; border: 1px solid #fff; }
#lcd .batt::before { content: ''; position: absolute; left: 1px; top: 1px; bottom: 1px; width: 6px; background: var(--yellow); }
#lcd .batt::after { content: ''; position: absolute; right: -3px; top: 1px; width: 2px; height: 2px; background: #fff; }
#lcd .view {
  position: relative; flex: 1; min-height: 0;
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; scrollbar-width: none; touch-action: pan-y;
  padding: 4px 6px 6px 5px;
}
#lcd .view::-webkit-scrollbar { display: none; }
#lcd .sbar { position: absolute; right: 1px; top: 13px; bottom: 12px; width: 2px; pointer-events: none; }
#lcd .sbar i { position: absolute; left: 0; width: 2px; background: rgba(20, 33, 61, .35); }
#lcd .hints {
  flex: none; height: 11px; padding: 0 3px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--ink); color: #fff; white-space: nowrap;
}
#lcd .hints b { color: var(--yellow); font-weight: 400; margin-right: 2px; }
#lcd.full .bar, #lcd.full .hints, #lcd.full .sbar { display: none; }
#lcd.full .view { padding: 0; overflow: hidden; }

/* text */
#lcd p { margin: 0 0 4px; font: 10px/10px 'VT323', monospace; }
#lcd .k { font: 10px/10px 'VT323', monospace; color: var(--coral); text-transform: uppercase; letter-spacing: .3px; }
#lcd .h { margin: 6px 0 4px; color: var(--navy); line-height: 9px; }
#lcd .h:first-child { margin-top: 1px; }
#lcd .dim { color: #69708a; }
#lcd ul { margin: 0 0 4px; padding: 0; list-style: none; }
#lcd li { position: relative; padding-left: 7px; margin-bottom: 2px; font: 10px/10px 'VT323', monospace; }
#lcd li::before { content: ''; position: absolute; left: 1px; top: 4px; width: 3px; height: 3px; background: var(--coral); }
#lcd .chips { display: flex; flex-wrap: wrap; gap: 2px; margin: 2px 0 5px; }
#lcd .chips span { font: 10px/10px 'VT323', monospace; padding: 0 3px 1px; background: #e6ecfb; color: var(--navy); }
#lcd .card { background: #fff; border: 1px solid #e3dccb; padding: 4px 4px 3px; margin-bottom: 4px; }
#lcd .card b { display: block; font-weight: 400; color: var(--navy); line-height: 9px; }
#lcd .card .k { margin: 2px 0 2px; }
#lcd .grp { display: flex; align-items: center; gap: 4px; margin: 2px 0 4px; font: 10px/10px 'VT323', monospace; color: #8a8fa3; text-transform: uppercase; white-space: nowrap; }
#lcd .grp::before, #lcd .grp::after { content: ''; flex: 1; height: 1px; background: #ddd3bf; }
#lcd .grp:not(:first-child) { margin-top: 7px; }

/* focusable things: tiles, rows, buttons */
#lcd [data-f] { cursor: pointer; position: relative; }
#lcd .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
#lcd .tile {
  height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  background: #fff; border: 1px solid #e3dccb; color: var(--ink);
}
#lcd .tile img { width: 24px; image-rendering: pixelated; }
#lcd .row {
  display: flex; align-items: center; gap: 6px; min-height: 22px; padding: 3px 4px;
  margin-bottom: 3px; background: #fff; border: 1px solid #e3dccb;
}
#lcd .row img { width: 16px; flex: none; image-rendering: pixelated; }
#lcd .row .tx { min-width: 0; flex: 1; }
#lcd .row .tx small { display: block; margin-top: 2px; font: 10px/9px 'VT323', monospace; color: #69708a; }
#lcd .row .go { flex: none; color: #b7b0a0; }
#lcd .row .ic { flex: none; width: 18px; height: 14px; display: grid; place-items: center; background: var(--navy); color: #fff; font: 10px/1 'VT323', monospace; }
body.rest #lcd { pointer-events: none; }
#lcd .pbtn {
  display: flex; align-items: center; justify-content: center; gap: 4px; height: 17px; margin-top: 4px;
  background: var(--navy); color: #fff; border: 1px solid var(--navy);
}
#lcd .pbtn.alt { background: #fff; color: var(--navy); }
#lcd .sel { border-color: var(--coral); box-shadow: 0 0 0 1px var(--coral); color: var(--coral); z-index: 1; }
#lcd .pbtn.sel { background: var(--coral); border-color: var(--coral); color: #fff; box-shadow: 0 0 0 1px #fff, 0 0 0 2px var(--coral); }
#lcd .row.sel .go { color: var(--coral); }
#lcd .flash { animation: flash .18s steps(2) 1; }
@keyframes flash { 50% { background: var(--coral); color: #fff; } }

/* section "cartridge" header */
#lcd .cart {
  margin: -4px -6px 5px -5px; padding: 6px 6px 5px; min-height: 40px;
  display: flex; flex-direction: column; justify-content: flex-end;
  color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, .35);
}
#lcd .cart .k { color: rgba(255, 255, 255, .85); }
#lcd .cart .big { font-size: 16px; line-height: 16px; margin-top: 2px; }
#lcd .cart.dive { background: linear-gradient(#5cc8f0, #1a8fd0 55%, #0b4f8f); }
#lcd .cart.mat { background: radial-gradient(circle at 80% 120%, #d2304a 0 22px, #fff 22px 24px, transparent 24px), linear-gradient(#2a4fb8, #012169); }
#lcd .cart.track { background: repeating-linear-gradient(0deg, #c94a3a 0 7px, #fff 7px 8px); }
#lcd .cart.shop { background: repeating-linear-gradient(94deg, #9c6b43 0 6px, #a8774c 6px 10px, #8f5f39 10px 15px); }
#lcd .cart.code { background: linear-gradient(#2a3b8f, #14213d); }
#lcd .cart.pics { background: linear-gradient(#ff8fa3, #ff5a7a); }
#lcd .ph { display: block; width: 100%; height: 82px; object-fit: cover; border: 1px solid var(--ink); background: #ddd; }
#lcd .phwrap { margin-bottom: 4px; }
#lcd .phwrap.sel { box-shadow: 0 0 0 1px var(--coral); }
#lcd .phwrap .cap { display: flex; justify-content: space-between; margin-top: 2px; font: 10px/10px 'VT323', monospace; color: #69708a; }
#lcd .art { display: block; width: 100%; image-rendering: pixelated; border: 1px solid var(--ink); background: #bfe4f7; margin-bottom: 4px; }

/* the photo album */
#lcd .album { display: flex; flex-direction: column; height: 100%; }
#lcd .album .ph { flex: 1; height: auto; min-height: 0; }
#lcd .album .meta { display: flex; justify-content: space-between; align-items: center; margin-top: 3px; }
#lcd .album .meta p { margin: 0; }
#lcd .album .arrows { display: flex; gap: 3px; }
#lcd .album .arrows span { display: inline-block; padding: 2px 3px; background: var(--navy); color: #fff; }

/* boot */
#lcd .boot { position: absolute; inset: 0; background: var(--cream); }
#lcd .boot .mark { position: absolute; left: 0; right: 0; top: -20px; text-align: center; color: var(--navy); font-size: 16px; animation: drop 1.15s steps(24) forwards; }
#lcd .boot .mark small { display: block; margin-top: 3px; font: 7px 'PS2P', monospace; letter-spacing: 1px; }
#lcd .boot .by { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; font: 10px/10px 'VT323', monospace; color: #69708a; opacity: 0; animation: fadein .3s 1.35s forwards; }
@keyframes drop { to { top: calc(50% - 14px); } }
@keyframes fadein { to { opacity: 1; } }

/* the cartridge picker (GAMES) */
#lcd .picker { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
#lcd .picker .rowc { display: flex; align-items: center; gap: 6px; }
#lcd .picker .arw { color: var(--navy); padding: 6px 2px; }
#lcd .ccart {
  position: relative; flex: none; border-radius: 5px 5px 2px 2px;
  background: linear-gradient(90deg, #8a8e97, #bcc0c9 12%, #aeb2bb 88%, #868a93);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 2px 0 #6c7079;
}
#lcd .ccart.sel { box-shadow: 0 0 0 1px var(--coral), inset 0 1px 0 rgba(255, 255, 255, .6), 0 2px 0 #6c7079; }
#lcd .ccart .grip { position: absolute; left: 6px; right: 6px; top: 3px; height: 6px;
  background: repeating-linear-gradient(90deg, rgba(0, 0, 0, .22) 0 1px, transparent 1px 3px); }
#lcd .ccart .label { position: absolute; left: 7px; right: 7px; top: 12px; bottom: 7px; overflow: hidden; background: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .7); }
#lcd .ccart .label b { display: block; height: 12px; padding-top: 2px; text-align: center; font-weight: 400; color: #fff; }
#lcd .ccart .label b.slim { font: 12px/9px 'VT323', monospace; padding-top: 1px; }
#lcd .ccart .label span { position: absolute; left: 0; right: 0; top: 12px; bottom: 0; background-size: 100% 100%; image-rendering: pixelated; }
#lcd .ccart.from-r { animation: fromr .16s ease-out; }
#lcd .ccart.from-l { animation: froml .16s ease-out; }
@keyframes fromr { from { transform: translateX(24px); opacity: 0; } }
@keyframes froml { from { transform: translateX(-24px); opacity: 0; } }
#lcd .picker .cname { margin: 2px 0 0; color: var(--navy); font: 8px/1 'PS2P', monospace; }
#lcd .picker .csub { margin: 0; text-align: center; }
#lcd .picker .dots { display: flex; gap: 3px; }
#lcd .picker .dots i { width: 4px; height: 4px; background: #d8cfbc; }
#lcd .picker .dots i.on { background: var(--coral); }

/* options menu and toasts */
#lcd .menu {
  position: absolute; z-index: 5; right: 4px; top: 14px; width: 122px;
  background: #fff; border: 2px solid var(--ink); box-shadow: 2px 2px 0 rgba(20, 33, 61, .3); padding: 3px 0;
}
#lcd .menu .opt { padding: 4px 4px 4px 12px; white-space: nowrap; }
#lcd .menu .opt.sel { box-shadow: none; border: 0; color: var(--coral); }
#lcd .menu .opt.sel::before { content: ''; position: absolute; left: 4px; top: 4px; border: 4px solid transparent; border-left-color: var(--coral); border-right: 0; }
#lcd .toast {
  position: absolute; z-index: 6; left: 5px; right: 5px; bottom: 15px; padding: 4px 5px;
  background: #fff; border: 2px solid var(--ink); font: 10px/10px 'VT323', monospace;
  animation: fadein .12s forwards;
}
#lcd .game { position: relative; width: 160px; height: var(--lcdh); }
#lcd .game canvas { display: block; width: 160px; height: var(--lcdh); image-rendering: pixelated; touch-action: none; }

/* a little speech bubble pointing at a control (e.g. the power switch when the handheld is off) */
#tip {
  position: fixed; z-index: 9; max-width: 220px; padding: 8px 12px; border-radius: 10px;
  background: #fff; color: var(--ink); font: 600 14px/1.25 system-ui, sans-serif;
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, .45); pointer-events: none;
  animation: fadein .15s forwards;
}
#tip::before { content: ''; position: absolute; left: var(--ax, 24px); top: -7px; border: 7px solid transparent; border-top: 0; border-bottom-color: #fff; }

/* first-time "how to play": rings around each control with what it does */
#coach { position: fixed; inset: 0; z-index: 30; background: rgba(8, 12, 24, .74); animation: fadein .2s forwards; }
#coach[hidden] { display: none; }
#coach .ring { position: fixed; border: 2px dashed var(--yellow); border-radius: 50%; box-shadow: 0 0 0 4px rgba(255, 210, 63, .18); }
#coach .ring.sq { border-radius: 10px; }
#coach .num {
  position: fixed; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--yellow); color: var(--ink); font: 800 13px system-ui, sans-serif; box-shadow: 0 2px 0 #c79a10;
}
#coach .card {
  position: fixed; overflow: auto; padding: 12px 14px 14px; border-radius: 12px; background: #fff; color: var(--ink);
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .6); font: 14px/1.3 system-ui, sans-serif;
}
#coach .card h2 { margin: 0 0 8px; font: 12px/1.2 'PS2P', monospace; color: var(--navy); }
#coach .card ol { margin: 0 0 8px; padding-left: 22px; }
#coach .card li { margin-bottom: 3px; }
#coach .card li::marker { font-weight: 800; color: #c79a10; }
#coach .card p { margin: 0 0 10px; color: #5b6478; font-size: 13px; }
#coach .ok {
  display: block; width: 100%; height: 44px; border-radius: 22px; background: var(--yellow); color: var(--ink);
  font: 800 16px system-ui, sans-serif; box-shadow: 0 3px 0 #c79a10;
}

/* full-screen photo, outside the handheld */
#photo-view {
  position: fixed; z-index: 20; inset: 0; padding: calc(var(--safe-t) + 56px) 12px calc(var(--safe-b) + 20px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: rgba(10, 14, 26, .94);
}
#photo-view[hidden] { display: none; }
#photo-view img { max-width: 100%; max-height: 78vh; border-radius: 4px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
#photo-view p { margin: 0; color: #e8ecf6; font: 20px/1.1 'VT323', monospace; text-align: center; }
#photo-view .chip { top: calc(var(--safe-t) + 10px); right: 12px; }

.noscript { position: fixed; inset: auto 16px 40px; padding: 14px; background: #fff; border-radius: 10px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  #holder, #shadow, .towel { transition-duration: .01s; }
  .palm, #hint span { animation: none; }
}
