/* PLAY MENU (js/play-menu.js): the three header buttons, the one settings sheet, and the hiding of everything it replaces.
   A phone gets a bottom sheet, a wide screen a panel on the right. Tap targets are at least 44 px. */
/* the header keeps only the brand and our three buttons; the old toggles and links, and the engine's ☰ orb, are reached through the sheet */
html body.ps-on .pl-head .pl-nav > :not(.ps-hb){display:none!important}
html body.ps-on #settings #setBtn{display:none!important}
html body.ps-on.menu-open #settings #setBtn{display:flex!important}     /* while the engine's own panel is open, its ☰ is the way to close it */
html body.ps-on .pl-head{padding-right:max(10px,env(safe-area-inset-right))!important}
html body.ps-on .pl-head .pl-nav{margin-left:auto;gap:8px}
/* Eivind, 2026-10-08: "no big round circle around the shortcut icons, just icons that highlight; settings is the ship's wheel, outstanding".
   Shortcuts: bare glyphs with a shadow, no disc or border; on = gold. The wheel is bigger and gold, with its own soft glow. */
html body.ps-on .pl-head .pl-nav .ps-hb{display:inline-flex!important;align-items:center;justify-content:center;gap:0;min-width:40px;width:40px!important;height:44px;min-height:44px;padding:0!important;
  border:0!important;background:none!important;backdrop-filter:none!important;-webkit-backdrop-filter:none!important;border-radius:0;color:#e8dcc4;opacity:.78;
  font-size:0!important;position:relative;touch-action:manipulation;filter:drop-shadow(0 1px 3px rgba(0,0,0,.9)) drop-shadow(0 0 6px rgba(0,0,0,.6));transition:opacity .2s,color .2s}
html body.ps-on .pl-head .pl-nav .ps-hb:hover{opacity:1}
html body.ps-on .pl-head .pl-nav .ps-hb .hb-l{display:none!important}
html body.ps-on .pl-head .pl-nav .ps-hb[aria-pressed=true]{color:#e0b873;opacity:1}
html body.ps-on .pl-head .pl-nav .ps-hb[aria-pressed=true]::after{content:'';position:absolute;left:50%;bottom:3px;width:4px;height:4px;margin-left:-2px;border-radius:50%;background:#e0b873}
html body.ps-on .pl-head .pl-nav #menuBtn{color:#e0b873;opacity:1;width:48px!important;margin-left:4px;filter:drop-shadow(0 1px 3px rgba(0,0,0,.9)) drop-shadow(0 0 8px rgba(224,184,115,.35))}
html body.ps-on .pl-head .pl-nav #menuBtn:hover svg{transform:rotate(22deg)}
html body.ps-on .pl-head .pl-nav #menuBtn svg{transition:transform .4s ease}
@media (max-width:699px){ html body.ps-on .pl-head .pl-nav{gap:2px} html body.ps-on .pl-head .pl-nav .ps-hb{width:36px!important;min-width:36px} html body.ps-on .pl-head .pl-nav #menuBtn{width:42px!important;margin-left:0} }   /* five fit beside the brand on a 390 px phone */
body.pm-open{overflow:hidden}

/* THE SETTINGS ROOM (Eivind, 2026-10-11: "a beautiful unified system settings ... showing all our hard work"). One sheet, four cards,
   nothing folded. Phone (<700px): a bottom sheet, the cards in one column (Emulation, Music room, The story, The game).
   700-1059px: a panel on the right, same column. 1060px and up: a centred console in two columns that fits without scrolling. */
#psMenu{position:fixed;inset:0;z-index:45;--pm-gold:#e0b873;--pm-gold2:#f3d48c;--pm-ink:#f3e9d2;--pm-dim:#bfae8d;--pm-line:rgba(216,176,106,.24)}
#psMenu[hidden]{display:none}
.pm-scrim{position:absolute;inset:0;background:radial-gradient(ellipse at 50% 40%,rgba(10,6,4,.55),rgba(4,3,6,.82));backdrop-filter:blur(5px);-webkit-backdrop-filter:blur(5px)}
.pm-sheet{position:absolute;left:0;right:0;bottom:0;max-height:92dvh;display:flex;flex-direction:column;border-radius:22px 22px 0 0;
  background:radial-gradient(120% 60% at 50% 0%,rgba(224,184,115,.10),transparent 60%),linear-gradient(#1c130a,#120c07 45%,#0b0805);
  color:var(--pm-ink);font-family:var(--ps-sans,system-ui);box-shadow:0 0 0 1px rgba(216,176,106,.38),0 -18px 60px rgba(0,0,0,.75);animation:pmUp .24s ease-out}
@keyframes pmUp{from{transform:translateY(24px);opacity:0}to{transform:none;opacity:1}}
.pm-sheet > header{display:flex;align-items:center;gap:10px;padding:14px 14px 8px 18px}
.pm-crest{display:inline-flex;color:var(--pm-gold);filter:drop-shadow(0 0 8px rgba(224,184,115,.35))}
.pm-crest svg{width:26px;height:26px}
.pm-sheet > header b{flex:1;font:600 24px Georgia,serif;color:#f6e7c3;letter-spacing:.01em}
.pm-x{width:44px;height:44px;border-radius:50%;border:1px solid rgba(216,176,106,.45);background:rgba(12,9,16,.6);color:inherit;font-size:17px;cursor:pointer;touch-action:manipulation}
.pm-x:hover{border-color:var(--pm-gold)}
.pm-body{display:flex;flex-direction:column;gap:12px;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;padding:4px 14px max(20px,env(safe-area-inset-bottom))}
.pm-col{display:contents}
.pm-emu{order:1}.pm-music{order:2}.pm-story{order:3}.pm-game{order:4}
.pm-card{position:relative;padding:12px 12px 12px;border-radius:16px;border:1px solid var(--pm-line);
  background:linear-gradient(180deg,rgba(255,236,200,.06),rgba(255,236,200,.02));box-shadow:inset 0 1px 0 rgba(255,255,255,.05),0 6px 18px rgba(0,0,0,.25)}
.pm-card h3{display:flex;align-items:center;gap:10px;margin:0 2px 10px;font:700 11px var(--ps-sans,system-ui);letter-spacing:.26em;text-transform:uppercase;color:var(--pm-gold)}
.pm-card h3::after{content:'';flex:1;height:1px;background:linear-gradient(90deg,var(--pm-line),transparent)}
.pm-card h4{margin:12px 2px 6px;font:600 10.5px var(--ps-sans,system-ui);letter-spacing:.2em;text-transform:uppercase;color:var(--pm-dim)}
.pm-note{margin:6px 4px 0;font:400 12px/1.35 var(--ps-sans,system-ui);color:var(--pm-dim);min-height:1.35em}
#psMenu [hidden]{display:none!important}

/* the little screen: what the stage shows now, in the chosen dress */
.pm-screen{position:relative;height:118px;margin:0 0 10px;border-radius:12px;overflow:hidden;background:#000;
  box-shadow:inset 0 0 0 1px rgba(216,176,106,.35),0 0 0 3px rgba(0,0,0,.45),0 0 0 4px rgba(216,176,106,.18)}
.pm-screen img{width:100%;height:100%;object-fit:cover;display:block}
.pm-screen.pix img{image-rendering:pixelated}
.pm-screen .pm-scan{position:absolute;inset:0;pointer-events:none;opacity:0;transition:opacity .25s;
  background:repeating-linear-gradient(0deg,rgba(0,0,0,.38) 0 1px,transparent 1px 3px),radial-gradient(ellipse at center,transparent 55%,rgba(0,0,0,.55))}
.pm-screen.crt .pm-scan{opacity:1}
.pm-screen-l{position:absolute;left:10px;bottom:8px;padding:3px 9px;border-radius:999px;background:rgba(10,7,4,.72);font:600 11px var(--ps-sans,system-ui);letter-spacing:.08em;color:var(--pm-gold2)}

/* SYSTEM · lock · SOUND */
.pm-pair{display:grid;grid-template-columns:1fr 44px 1fr;align-items:end;gap:6px}
.pm-dd{position:relative;min-width:0}
.pm-cap{display:block;margin:0 4px 4px;font:600 10.5px var(--ps-sans,system-ui);letter-spacing:.2em;text-transform:uppercase;color:var(--pm-dim)}
.pm-ddb{display:flex;align-items:center;gap:9px;width:100%;min-height:56px;padding:8px 10px;border-radius:12px;border:1px solid rgba(216,176,106,.42);
  background:linear-gradient(180deg,rgba(255,236,200,.08),rgba(0,0,0,.25));color:inherit;text-align:left;cursor:pointer;touch-action:manipulation;font:inherit;transition:border-color .2s,box-shadow .2s,opacity .2s}
.pm-ddb:hover,.pm-dd.open .pm-ddb{border-color:var(--pm-gold);box-shadow:0 0 0 3px rgba(224,184,115,.14)}
.pm-ddb > svg:last-child{flex:none;margin-left:auto;color:var(--pm-gold);transition:transform .2s}
.pm-dd.open .pm-ddb > svg:last-child{transform:rotate(180deg)}
.pm-ddt{min-width:0;font:600 15px/1.2 Georgia,serif;color:#f6e7c3;overflow:hidden}
.pm-ddt small{display:block;margin-top:2px;font:400 11.5px/1.25 var(--ps-sans,system-ui);color:var(--pm-dim);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pm-swatch{flex:none;display:grid;grid-template-columns:1fr 1fr;width:26px;height:26px;border-radius:7px;overflow:hidden;box-shadow:0 0 0 1px rgba(255,255,255,.18),0 2px 6px rgba(0,0,0,.5)}
.pm-swatch b{display:block}
.pm-ico{flex:none;display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:7px;background:rgba(224,184,115,.14);color:var(--pm-gold2)}
.pm-pair.locked [data-ddwrap="snd"] .pm-ddb{border-style:dashed;opacity:.72}
.pm-lock{position:relative;width:44px;height:56px;border:0;background:none;color:var(--pm-dim);cursor:pointer;touch-action:manipulation;display:flex;align-items:center;justify-content:center}
.pm-lock::before,.pm-lock::after{content:'';position:absolute;top:50%;width:8px;height:2px;margin-top:-1px;background:rgba(216,176,106,.35);transition:background .2s,opacity .2s}
.pm-lock::before{left:-2px}.pm-lock::after{right:-2px}
.pm-lock svg{position:relative;padding:7px;width:36px;height:36px;box-sizing:border-box;border-radius:50%;background:rgba(0,0,0,.35);box-shadow:0 0 0 1px rgba(216,176,106,.35);transition:color .2s,box-shadow .2s,transform .2s}
.pm-lock[aria-pressed=true]{color:var(--pm-gold)}
.pm-lock[aria-pressed=true] svg{box-shadow:0 0 0 1px var(--pm-gold),0 0 12px rgba(224,184,115,.35)}
.pm-lock[aria-pressed=true]::before,.pm-lock[aria-pressed=true]::after{background:var(--pm-gold)}
.pm-lock[aria-pressed=false]::before,.pm-lock[aria-pressed=false]::after{opacity:.25}
.pm-lock:hover svg{transform:scale(1.06)}
.pm-ddl{position:absolute;z-index:3;left:0;top:calc(100% + 6px);min-width:100%;width:max-content;max-width:min(300px,86vw);padding:6px;border-radius:14px;
  background:linear-gradient(#21170c,#130d07);border:1px solid rgba(216,176,106,.5);box-shadow:0 18px 40px rgba(0,0,0,.7);animation:pmDd .14s ease-out}
[data-ddwrap="snd"] .pm-ddl{left:auto;right:0}
@keyframes pmDd{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}
.pm-ddl button{display:flex;align-items:center;gap:10px;width:100%;min-height:48px;padding:6px 10px;border:0;border-radius:10px;background:none;color:inherit;text-align:left;cursor:pointer;font:inherit}
.pm-ddl button:hover,.pm-ddl button:focus-visible{background:rgba(224,184,115,.12);outline:none}
.pm-ddl button.on{background:rgba(224,184,115,.16)}
.pm-ddl button > svg{margin-left:auto;color:var(--pm-gold);flex:none}
.pm-ddl .pm-ddt small{white-space:normal}

/* Screen chips: CRT, Weather, Moving picture */
.pm-chips{display:flex;flex-wrap:wrap;gap:6px}
.pm-chip{position:relative;flex:1 1 0;min-width:96px;display:flex;align-items:center;gap:7px;min-height:46px;padding:0 12px;border-radius:12px;border:1px solid rgba(216,176,106,.22);
  background:rgba(0,0,0,.28);color:#d9ccb0;font:600 13px var(--ps-sans,system-ui);cursor:pointer;touch-action:manipulation;transition:all .2s}
.pm-chip.on{color:#f6e7c3;border-color:rgba(224,184,115,.7);background:linear-gradient(180deg,rgba(224,184,115,.18),rgba(224,184,115,.06))}
.pm-chip.on svg{color:var(--pm-gold2)}
.pm-lamp{position:absolute;top:7px;right:7px;width:6px;height:6px;border-radius:50%;background:rgba(255,255,255,.14);transition:all .2s}
.on > .pm-lamp{background:var(--pm-gold2);box-shadow:0 0 8px rgba(243,212,140,.9)}

/* pills */
.pm-segrow{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:6px 12px;margin:0 0 8px}
.pm-segrow:last-child{margin-bottom:0}
.pm-k{font:600 15px Georgia,serif;color:#f1e5c8;padding-left:4px}
.pm-seg{display:flex;flex:1 1 auto;justify-content:stretch;gap:3px;padding:3px;border-radius:12px;background:rgba(0,0,0,.38);box-shadow:inset 0 1px 3px rgba(0,0,0,.5)}
.pm-k + .pm-seg{flex:0 1 auto}
.pm-seg button{flex:1 1 0;white-space:nowrap;min-height:40px;padding:0 12px;border:0;border-radius:9px;background:none;color:#d9ccb0;font:600 13px var(--ps-sans,system-ui);cursor:pointer;touch-action:manipulation;transition:background .2s,color .2s}
.pm-seg button:hover{color:#f6e7c3}
.pm-seg button.on{background:linear-gradient(#ecc887,#d9a95c);color:#241808;box-shadow:0 1px 0 rgba(255,255,255,.35) inset,0 2px 6px rgba(0,0,0,.35)}

/* MUSIC ROOM: master pills, then the four beds as lit tiles */
.pm-tiles{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-top:8px;transition:opacity .2s}
.pm-tiles.dim{opacity:.6}
.pm-tile{position:relative;display:flex;align-items:center;gap:10px;min-height:58px;padding:8px 12px;border-radius:12px;border:1px solid rgba(216,176,106,.22);background:rgba(0,0,0,.28);
  color:#cdbf9f;text-align:left;cursor:pointer;touch-action:manipulation;font:inherit;transition:all .2s}
.pm-tile .pm-tl{font:600 14px/1.2 Georgia,serif;color:#e9dcc0}
.pm-tile .pm-tl small{display:block;margin-top:1px;font:400 11.5px var(--ps-sans,system-ui);color:var(--pm-dim)}
.pm-tile.on{border-color:rgba(224,184,115,.7);background:linear-gradient(180deg,rgba(224,184,115,.16),rgba(224,184,115,.05));color:var(--pm-gold2)}
.pm-tile.on .pm-tl{color:#f6e7c3}

/* story rows */
.pm-row{display:flex;align-items:center;justify-content:space-between;gap:14px;width:100%;min-height:52px;margin:0 0 6px;padding:8px 12px;border-radius:12px;border:0;
  background:rgba(255,255,255,.045);color:inherit;text-align:left;cursor:pointer;touch-action:manipulation;font:inherit}
.pm-row:hover{background:rgba(255,255,255,.07)}
.pm-l{font:600 15px/1.25 Georgia,serif;color:#f1e5c8}
.pm-l small{display:block;margin-top:2px;font:400 12px/1.3 var(--ps-sans,system-ui);color:var(--pm-dim)}
.pm-sw{flex:none;position:relative;width:46px;height:26px;border-radius:13px;background:rgba(255,255,255,.16);transition:background .2s}
.pm-sw::after{content:'';position:absolute;left:3px;top:3px;width:20px;height:20px;border-radius:50%;background:#e9dcc0;transition:transform .2s}
.pm-t.on .pm-sw{background:var(--pm-gold)}.pm-t.on .pm-sw::after{transform:translateX(20px);background:#241808}
.pm-go{font-size:22px;color:#d9ccb0;opacity:.7;padding:0 6px;font-style:normal}
.pm-story .pm-segrow{margin:2px 0 8px;padding:2px 0 2px}
.pm-links{display:flex;gap:6px;flex-wrap:wrap;margin-top:10px}
.pm-links button{flex:1 1 70px;min-height:44px;border-radius:12px;border:1px solid rgba(216,176,106,.3);background:rgba(255,255,255,.04);color:#e9dcc0;font:600 12.5px var(--ps-sans,system-ui);letter-spacing:.05em;cursor:pointer}
.pm-links button:hover{border-color:var(--pm-gold);color:#f6e7c3}

@media (max-width:420px){ .pm-pair{grid-template-columns:1fr 38px 1fr;gap:4px} .pm-lock{width:38px} .pm-ddb{gap:7px;padding:8px} .pm-ddt{font-size:14px} .pm-ddb .pm-swatch,.pm-ddb .pm-ico{width:22px;height:22px} .pm-seg button{padding:0 8px} }
@media (min-width:700px) and (max-width:1059px){
  .pm-sheet{left:auto;top:0;bottom:0;width:min(480px,94vw);max-height:none;border-radius:0;animation-name:pmIn}
  @keyframes pmIn{from{transform:translateX(24px);opacity:0}to{transform:none;opacity:1}} }
@media (min-width:1060px){
  .pm-sheet{left:50%;top:50%;right:auto;bottom:auto;width:min(980px,94vw);max-height:94dvh;border-radius:22px;transform:translate(-50%,-50%);animation:pmPop .24s ease-out;
    box-shadow:0 0 0 1px rgba(216,176,106,.4),0 30px 90px rgba(0,0,0,.8)}
  @keyframes pmPop{from{transform:translate(-50%,-48%) scale(.985);opacity:0}to{transform:translate(-50%,-50%);opacity:1}}
  .pm-sheet > header{padding:16px 18px 8px 22px}
  .pm-body{display:grid;grid-template-columns:1.08fr 1fr;align-items:start;gap:14px;padding:6px 18px 18px}
  .pm-col{display:flex;flex-direction:column;gap:14px;min-width:0}
  .pm-card{padding:14px}
  .pm-screen{height:150px} }
/* phones: nothing in the sheet may be cut off or squeezed. Subtitles wrap to two lines instead of an ellipsis, the System/Sound boxes
   drop their leading icon on the narrowest screens, and the close button never shrinks. */
.pm-x{flex:none;min-width:44px}
@media (max-width:520px){
  .pm-ddt{overflow:visible;overflow-wrap:anywhere}
  .pm-ddt small{white-space:normal;overflow:visible;text-overflow:clip;line-height:1.25}
  .pm-ddb{align-items:center;padding:8px 8px}
}
@media (max-width:380px){ .pm-sheet > header{gap:6px;padding:12px 10px 8px 14px} .pm-sheet > header b{font-size:20px;min-width:0} .pm-nav{margin-right:0;gap:0} .pm-nav button{width:34px;height:34px} .pm-crest svg{width:22px;height:22px} }
@media (max-width:400px){ .pm-ddb .pm-ico{display:none} .pm-ddb .pm-swatch{width:18px;height:18px} .pm-ddt{font-size:13.5px} .pm-ddt small{font-size:11px} }
@media (prefers-reduced-motion:reduce){ .pm-sheet,.pm-ddl{animation:none} .pm-sw,.pm-sw::after,.pm-lock svg{transition:none} }
html body.ps-still .pm-sheet,html body.ps-still .pm-ddl{animation:none}
html body.ps-still .pm-sw,html body.ps-still .pm-sw::after,html body.ps-still .pm-lock svg{transition:none}
html body.ps-on #choices > button.ap-pick{animation:apPick 1.2s ease-in-out!important;border-color:#f3d48c;box-shadow:0 0 0 3px rgba(243,212,140,.5),0 4px 14px rgba(0,0,0,.4)}
@keyframes apPick{0%,100%{transform:none}50%{transform:scale(1.025)}}

/* the ways out (2026-10-11): quiet icons in the header beside the close button, gold on hover */
.pm-nav{display:flex;align-items:center;gap:2px;margin-right:6px}
.pm-nav button{width:38px;height:38px;display:inline-flex;align-items:center;justify-content:center;border:0;border-radius:50%;background:none;
  color:var(--pm-dim);cursor:pointer;touch-action:manipulation;transition:color .2s,background .2s}
.pm-nav button:hover,.pm-nav button:focus-visible{color:var(--pm-gold2);background:rgba(224,184,115,.1);outline:none}

/* notes under a control are ONE line, always: cut with … rather than wrap, so a change never moves anything below (2026-10-12) */
#psMenu .pm-note{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-height:1.35em}

/* BIGGER, EASIER, CENTRED (Eivind, 2026-10-12: "make the icons little bit larger and easier to click. middle centered"). Desktop/tablet:
   a taller header (54px, every layout reads --ps-head), 52px hit areas, 24px glyphs, the wheel 38px, each glyph in the middle of its
   button and the button the full header height. Phone: 40px buttons with 22px glyphs, the wheel 44px (five still fit beside the brand). */
@media (min-width:700px){ :root{--ps-head:54px} }
html body.ps-on .pl-head{align-items:center}
html body.ps-on .pl-head .pl-nav{align-self:stretch;align-items:center}
html body.ps-on .pl-head .pl-nav .ps-hb{height:100%!important;min-height:44px}
html body.ps-on .pl-head .pl-nav .ps-hb svg{width:22px;height:22px;display:block}
html body.ps-on .pl-head .pl-nav #menuBtn svg{width:34px;height:34px}
@media (min-width:700px){
  html body.ps-on .pl-head .pl-nav{gap:6px}
  html body.ps-on .pl-head .pl-nav .ps-hb{width:52px!important;min-width:52px}
  html body.ps-on .pl-head .pl-nav .ps-hb svg{width:24px;height:24px}
  html body.ps-on .pl-head .pl-nav #menuBtn{width:58px!important}
  html body.ps-on .pl-head .pl-nav #menuBtn svg{width:38px;height:38px}
  html body.ps-on .pl-head .pl-nav .ps-hb[aria-pressed=true]::after{bottom:6px;width:5px;height:5px;margin-left:-2.5px}
}
@media (max-width:699px){
  html body.ps-on .pl-head .pl-nav .ps-hb{width:40px!important;min-width:40px}
  html body.ps-on .pl-head .pl-nav #menuBtn{width:44px!important}
}

/* LETTERBOX: the title and the icons sit in the vertical middle of the whole black band above the picture (Eivind, 2026-10-12: "pls make
   middle aligned ... i mean vertically"). The header clips its contents, so they cannot be shifted; instead a pseudo row as tall as
   the band is drawn under it... simplest: pad the header's top by the band, so its foot (which the letterbox code measures) does not
   move, but its contents centre in header + band. Done by negative margin on the header: it grows UP into nothing (top 0 is fixed),
   so we grow its height by the band and keep --lb-hb read from the unchanged inner row. */
html body.ps-on.ps-lb .pl-head{overflow:visible!important}
html body.ps-on.ps-lb .pl-head > *{transform:translateY(calc(var(--lb-top,0px) / 2));transition:transform .25s ease}
html body.ps-still.ps-on.ps-lb .pl-head > *{transition:none}
