/* SUSHI BOY web player */
:root {
  --ink: #07080f;
  --ink2: #0f111c;
  --card: rgba(18, 20, 33, 0.78);
  --line: rgba(231, 180, 80, 0.28);
  --gold: #e7b450;
  --gold2: #ffd98a;
  --red: #d7322b;
  --salmon: #ff7a45;
  --cream: #f7ecd9;
  --muted: #a3a8bd;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--cream); font: 500 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; }
button { font: inherit; color: inherit; }
a { color: inherit; }
.logo-text { font-family: Bungee, Inter, sans-serif; letter-spacing: 0.02em; color: #ffd21f; -webkit-text-stroke: 2px #1c49c8; paint-order: stroke fill; text-shadow: 0 3px 0 #0b2a85, 0 10px 30px rgba(255, 210, 31, 0.25); }

/* ---------- buttons, chips, toasts ---------- */
.btn-ghost { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 999px; cursor: pointer; text-decoration: none;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.12); color: var(--cream); font-weight: 600; font-size: 14px; transition: background .12s; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.11); }
.btn-ghost svg { width: 18px; height: 18px; flex: none; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font: 800 11px/1 Inter, sans-serif; letter-spacing: 0.12em; text-transform: uppercase; }
.badge.gba { background: rgba(124, 92, 255, 0.18); color: #c9b9ff; border: 1px solid rgba(160, 135, 255, 0.35); }
.badge.gbc { background: rgba(231, 180, 80, 0.16); color: var(--gold2); border: 1px solid rgba(231, 180, 80, 0.4); }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--sab)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 90;
  padding: 11px 18px; border-radius: 14px; background: rgba(15, 17, 28, 0.94); border: 1px solid var(--line); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); font-weight: 600; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- unlock dialog ---------- */
dialog.unlock { border: 1px solid var(--line); border-radius: 22px; background: #11131f; color: var(--cream); padding: 26px; width: min(380px, calc(100vw - 32px)); box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7); }
dialog.unlock::backdrop { background: rgba(4, 5, 10, 0.72); backdrop-filter: blur(6px); }
dialog.unlock h2 { margin: 0 0 6px; font: 400 22px/1.2 Bungee, sans-serif; color: var(--gold2); }
dialog.unlock p { margin: 0 0 16px; color: var(--muted); }
dialog.unlock input { width: 100%; min-height: 50px; padding: 0 16px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.16); background: rgba(255, 255, 255, 0.05); color: var(--cream); font: 700 18px/1 Inter, sans-serif; letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 14px; outline: none; }
dialog.unlock input:focus { border-color: var(--gold); }
dialog.unlock .err { color: #ff9b8f; min-height: 20px; margin: -6px 0 10px; font-size: 13px; }
dialog.unlock .gbtn { width: 100%; }

/* ---------- the iPhone "Add to Home Screen" hint ---------- */
.ios-hint { display: none; margin-top: 18px; padding: 12px 14px; border-radius: 16px; background: rgba(255, 255, 255, 0.05); border: 1px dashed rgba(255, 255, 255, 0.16); color: var(--muted); font-size: 13px; }
.ios-hint.show { display: block; }

/* ================= PLAYER ================= */
body.player { position: fixed; inset: 0; overflow: hidden; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: pan-y; background: #000; }
#pad .pb, #pad .dpad, #pad .chip { touch-action: none; } /* the controls never scroll or refresh the page */
body.player.skin-nihao { --accent: var(--gold); --panel: url(../img/ui/nihao_panel.jpg); --bezel: #0b0b10; }
#app { position: absolute; inset: 0; display: flex; flex-direction: column; }
#screenWrap { position: relative; flex: none; display: grid; place-items: center; padding: calc(10px + var(--sat)) calc(10px + var(--sar)) 10px calc(10px + var(--sal)); background: radial-gradient(120% 120% at 50% 0%, #1a1c2b 0%, #07080f 70%); }
#screen { position: relative; width: var(--sw, 100%); height: var(--sh, auto); border-radius: 10px; overflow: hidden; background: #000; box-shadow: 0 0 0 3px var(--bezel), 0 0 0 4px rgba(231, 180, 80, 0.35), 0 16px 40px rgba(0, 0, 0, 0.6); }
#game { position: absolute; inset: 0; }
#game canvas { image-rendering: pixelated; }
/* the emulator's own bars and pads are replaced by ours */
#game .ejs_menu_bar, #game .ejs_virtualGamepad_parent, #game .ejs_context_menu, #game .ejs_virtualGamepad_open, #game .ejs_start_button { display: none !important; }
#game .ejs_message { font: 600 13px Inter, sans-serif !important; }

/* ---------- the controller ---------- */
#pad { position: relative; flex: 1; min-height: 0; background: var(--panel) center top / cover no-repeat, #0a0a10; border-top: 1px solid rgba(231, 180, 80, 0.25); touch-action: none; }
#pad::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0) 30%); pointer-events: none; }
.pb { position: absolute; display: grid; place-items: center; border: 0; padding: 0; background: none; cursor: pointer; touch-action: none; -webkit-user-select: none; user-select: none; }
.pb img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; -webkit-user-drag: none; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.55)); transition: transform .05s, filter .05s; }
.pb .lbl { position: absolute; pointer-events: none; font: 800 var(--lsize, 22px)/1 Inter, sans-serif; color: rgba(255, 244, 220, 0.92); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.pb.on img { transform: scale(0.94); filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6)) brightness(1.15); }
.pb.cap .lbl { position: static; margin-top: 6px; font-size: 11px; letter-spacing: 0.16em; color: rgba(247, 236, 217, 0.72); }
.pb.cap { display: flex; flex-direction: column; align-items: center; }
.pb.cap img { height: auto; }
/* iPhone: the invisible switch a finger flips for the phone's tick (player.js buildPad); it takes the tap, the control acts */
#pad .hap { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; z-index: 2; cursor: pointer; }
.dpad { position: absolute; touch-action: none; }
.dpad img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.6)); transition: transform .06s; }
.dpad[data-dir="u"] img { transform: perspective(500px) rotateX(9deg); }
.dpad[data-dir="d"] img { transform: perspective(500px) rotateX(-9deg); }
.dpad[data-dir="l"] img { transform: perspective(500px) rotateY(-9deg); }
.dpad[data-dir="r"] img { transform: perspective(500px) rotateY(9deg); }
/* the D-pad's touch area reaches 10 px past its picture (not on the right, where B is): a thumb a little off an arm
   still presses it */
.dpad::after { content: ""; position: absolute; inset: -10px 0 -10px -10px; }
.sh .lbl { font-size: 16px; letter-spacing: 0.1em; }
.sh-r img { transform: scaleX(-1); }
.sh-r.on img { transform: scaleX(-1) scale(0.95); }
.chip { position: absolute; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; min-width: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid rgba(231, 180, 80, 0.35);
  background: rgba(10, 10, 16, 0.78); color: var(--cream); font: 800 12px/1 Inter, sans-serif; letter-spacing: 0.08em; cursor: pointer; touch-action: none; }
.chip svg { width: 18px; height: 18px; }
.chip.c-mute { width: 36px; padding: 0; }
/* owner 2026-10-07: a small menu button, far from the D-pad (a missed UP opened the menu) */
#pad .chip { height: 30px; min-width: 30px; }
#pad .chip.c-menu, #pad .chip.c-mute { width: 30px; padding: 0; }
#pad .chip.c-ff { width: 54px; padding: 0; }
/* A and B are round: their touch areas too, so a tap on B never lands in A's corner */
#pad .b-a, #pad .b-b { border-radius: 50%; }
.chip.c-mute.muted { color: #ff8a7a; border-color: rgba(255, 120, 100, 0.55); }
.chip.on { background: linear-gradient(180deg, #ffe7a6, #d99a2e); color: #241503; border-color: transparent; box-shadow: 0 0 18px rgba(231, 180, 80, 0.55); }

/* portrait phone: the screen on top, the controller below (positions in % of the pad) */
body.layout-portrait #screenWrap { padding-bottom: 14px; }
/* the D-pad big (D), A and B smaller (S) and centred on it, SELECT/START right under them (owner) */
body.layout-portrait #pad { --D: min(44vw, 200px); --S: min(19vw, 90px); --P: min(17vw, 76px); --SH: min(25vw, 140px); --T: calc(4% + var(--SH) * 0.29 + 22px); }
body.layout-portrait .dpad { left: 3%; top: var(--T); width: var(--D); height: var(--D); }
body.layout-portrait .b-a { right: 4%; top: calc(var(--T) + var(--D) / 2 - var(--S) * 0.83); width: var(--S); height: var(--S); --lsize: 25px; }
body.layout-portrait .b-b { right: calc(4% + var(--S) * 0.98); top: calc(var(--T) + var(--D) / 2 - var(--S) * 0.83 + var(--S) * 0.66); width: var(--S); height: var(--S); --lsize: 25px; }
body.layout-portrait .sh-l { left: 3%; top: 4%; width: var(--SH); height: auto; }
body.layout-portrait .sh-r { right: 3%; top: 4%; width: var(--SH); height: auto; }
/* owner's marks: SELECT right under B, START right under A (small pills, one line) */
body.layout-portrait .b-select { right: calc(4% + var(--S) * 0.98 + (var(--S) - var(--P)) / 2); top: calc(var(--T) + var(--D) / 2 + var(--S) * 0.83 + 16px); width: var(--P); }
body.layout-portrait .b-start { right: calc(4% + (var(--S) - var(--P)) / 2); top: calc(var(--T) + var(--D) / 2 + var(--S) * 0.83 + 16px); width: var(--P); }
/* owner 2026-10-07: the chip row (menu, sound, fast forward) sits between L and R, on their line: far from the D-pad */
body.layout-portrait .c-menu, body.layout-portrait .c-mute, body.layout-portrait .c-ff { top: calc(4% + var(--SH) * 0.145 - 15px); }
body.layout-portrait .c-menu { left: calc(50% - 63px); }
body.layout-portrait .c-mute { left: calc(50% - 27px); }
body.layout-portrait .c-ff { left: calc(50% + 9px); }

/* landscape phone: the screen centred, the controls float at its sides */
body.layout-landscape #app { flex-direction: row; }
body.layout-landscape #screenWrap { position: absolute; inset: 0; padding: calc(6px + var(--sat)) calc(6px + var(--sar)) calc(6px + var(--sab)) calc(6px + var(--sal)); background: radial-gradient(90% 120% at 50% 50%, #151726 0%, #05060b 75%); }
body.layout-landscape #pad { position: absolute; inset: 0; background: none; border: 0; pointer-events: none; }
body.layout-landscape #pad::before { display: none; }
body.layout-landscape #pad > * { pointer-events: auto; }
body.layout-landscape .pb img, body.layout-landscape .dpad img { opacity: 0.88; }
body.layout-landscape #pad { --D: min(19vw, 40vh, 176px); --S: min(9vw, 20vh, 84px); }
body.layout-landscape .dpad { left: calc(2.5vw + var(--sal)); top: calc(50% - var(--D) / 2 + 4vh); width: var(--D); height: var(--D); }
body.layout-landscape .b-a { right: calc(2.5vw + var(--sar)); top: calc(50% - var(--S) + 2vh); width: var(--S); height: var(--S); --lsize: 22px; }
body.layout-landscape .b-b { right: calc(2.5vw + var(--sar) + var(--S) * 0.98); top: calc(50% - var(--S) * 0.35 + 2vh); width: var(--S); height: var(--S); --lsize: 22px; }
body.layout-landscape .sh-l { left: calc(1.5vw + var(--sal)); top: calc(3vh + var(--sat)); width: min(16vw, 140px); }
body.layout-landscape .sh-r { right: calc(1.5vw + var(--sar)); top: calc(3vh + var(--sat)); width: min(16vw, 140px); }
body.layout-landscape .b-select { left: calc(3vw + var(--sal)); bottom: calc(4vh + var(--sab)); width: min(11vw, 90px); }
body.layout-landscape .b-start { right: calc(3vw + var(--sar)); bottom: calc(4vh + var(--sab)); width: min(11vw, 90px); }
/* the chips together on the right, above A and B (the menu sat right above the D-pad's UP) */
body.layout-landscape .c-menu, body.layout-landscape .c-mute, body.layout-landscape .c-ff { top: max(calc(50% - var(--S) - 52px), calc(3vh + var(--sat) + min(16vw, 140px) * 0.3 + 8px)); }
body.layout-landscape .c-ff { right: calc(2vw + var(--sar)); }
body.layout-landscape .c-mute { right: calc(2vw + var(--sar) + 62px); }
body.layout-landscape .c-menu { right: calc(2vw + var(--sar) + 98px); }

/* desktop: the sound switch on top, a big screen, the arcade control bar and the keyboard map under it ("Touch
   controls" switches a computer to the landscape console layout above) */
body.layout-desktop #app { flex-direction: column; background: radial-gradient(80% 90% at 50% 30%, #1a1c2c 0%, #05060b 70%); }
body.layout-desktop #screenWrap { flex: 1; background: none; padding: 6px 18px 8px; }
body.layout-desktop #pad { display: none; }
/* DS: a fixed large game screen and a small stylus view among the controls. */
body.dual-screen #screenWrap { position: absolute; inset: 0; padding: 0; display: block; background: #080910; }
#screen.ds-display { position: absolute; inset: 0; background: transparent; box-shadow: none; border-radius: 0; overflow: visible; }
/* WebKit stops updating WebGL at opacity:0. Keep the source composited at an
   imperceptible nonzero alpha while the visible canvases copy its two screens. */
#game.ds-source { position: fixed; inset: auto; left: 0; top: 0; width: 256px; height: 384px; opacity: .001; pointer-events: none; }
.ds-main, .ds-touch { position: absolute; border-radius: 6px; background: #000; image-rendering: pixelated;
  box-shadow: 0 0 0 2px #121119, 0 0 0 3px rgba(231,180,80,.35); }
.ds-main { pointer-events: none; }
.ds-touch { touch-action: none; cursor: crosshair; z-index: 3; }
.ds-main[hidden], .ds-touch[hidden] { display: none; }
body.dual-screen #pad { position: absolute; inset: 0; min-height: 0; background: none; border: 0; pointer-events: none; }
body.dual-screen #pad::before { display: none; }
body.dual-screen #pad > * { pointer-events: auto; }
body.dual-screen #pad .pb, body.dual-screen #pad .dpad, body.dual-screen #pad .chip { position: absolute; margin: 0; }
body.dual-screen #pad .pb { --lsize: 19px; }
body.dual-screen #pad .sh { background: linear-gradient(155deg,#39342a,#131315 48%,#070709); border: 1px solid #927849; border-radius: 13px;
  box-shadow: inset 0 1px 2px #e7ce9066,0 3px 5px #0008; --lsize: 16px; }
body.dual-screen #pad .sh img { display: none; }
body.dual-screen #pad .b-x, body.dual-screen #pad .b-y { border-radius: 50%; }
/* Empty cross corners must pass a touch through to the inset screen. */
body.dual-screen #pad .dpad { clip-path: polygon(33% 0,67% 0,67% 33%,100% 33%,100% 67%,67% 67%,67% 100%,33% 100%,33% 67%,0 67%,0 33%,33% 33%); }
body.dual-screen #pad .dpad::after { display: none; }
body.dual-screen #pad .sh.on { background: linear-gradient(155deg,#665332,#242018 48%,#171209); }
body.dual-screen #pad .cap { justify-content: center; }
body.dual-screen #pad .cap img { width: 62px; max-width: 100%; }
body.dual-screen #pad .cap .lbl { font-size: 10px; margin-top: 4px; }
body.dual-screen #pad .sh img { object-fit: fill; }
body.dual-screen #pad .chip { padding: 0; gap: 4px; font-size: 12px; }
body.dual-screen #pad .chip svg { width: 16px; height: 16px; }
body.dual-screen #topbar, body.dual-screen #deskbar { position: relative; z-index: 5; pointer-events: none; }
body.dual-screen #topbar > *, body.dual-screen #deskbar > * { pointer-events: auto; }
body.dual-screen.layout-desktop #deskbar { margin-top: auto; }
#topbar, #deskbar { display: none; }
body.layout-desktop #topbar { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 12px 18px 0; }
body.layout-desktop #deskbar { display: flex; justify-content: center; padding: 6px 16px 14px; }

/* the arcade pieces: black urushi lacquer, gold trim, Bungee lettering */
.dbar { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: calc(100vw - 32px); padding: 10px 14px 12px; border-radius: 20px;
  background: linear-gradient(180deg, rgba(22, 18, 12, 0.86), rgba(7, 7, 11, 0.94)), url(../img/ui/nihao_panel.jpg) center / cover;
  border: 1px solid rgba(231, 180, 80, 0.38); box-shadow: inset 0 1px 0 rgba(255, 231, 166, 0.14), 0 0 0 1px rgba(0, 0, 0, 0.7), 0 18px 40px rgba(0, 0, 0, 0.55); }
.dbar-row { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 10px; }
.arc, .soundbtn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 12px; cursor: pointer;
  font: 400 13px/1 Bungee, Inter, sans-serif; letter-spacing: 0.04em; color: #ffe7a6; text-shadow: 0 1px 0 #000;
  background: linear-gradient(180deg, #2a251c 0%, #0e0d11 100%); border: 1px solid rgba(231, 180, 80, 0.6);
  box-shadow: inset 0 1px 0 rgba(255, 231, 166, 0.2), inset 0 -2px 0 rgba(0, 0, 0, 0.6), 0 3px 0 #000, 0 6px 14px rgba(0, 0, 0, 0.5);
  transition: transform .08s ease, box-shadow .08s ease, filter .12s ease; }
.arc svg, .soundbtn svg { width: 16px; height: 16px; color: var(--gold); flex: none; }
.arc:hover, .soundbtn:hover { filter: brightness(1.18); }
.arc:active, .soundbtn:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255, 231, 166, 0.12), 0 1px 0 #000; }
.arc.on { color: #241503; text-shadow: none; background: linear-gradient(180deg, #ffe7a6 0%, #f2c15a 45%, #c98a22 100%); border-color: #ffe7a6; box-shadow: 0 3px 0 #6b4510, 0 0 18px rgba(231, 180, 80, 0.45); }
.arc.on svg { color: #241503; }
.walkseg { display: inline-flex; align-items: center; height: 38px; padding: 3px; gap: 3px; border-radius: 12px; background: #0b0a0e;
  border: 1px solid rgba(231, 180, 80, 0.6); box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.7), 0 3px 0 #000; }
.walkseg span { padding: 0 6px 0 9px; font: 400 11px/1 Bungee, Inter, sans-serif; letter-spacing: 0.08em; color: rgba(255, 231, 166, 0.6); }
.walkseg button { height: 30px; padding: 0 12px; border: 0; border-radius: 9px; cursor: pointer; background: transparent; font: 400 12px/1 Bungee, Inter, sans-serif; letter-spacing: 0.04em; color: rgba(255, 231, 166, 0.72); }
.walkseg button.sel { color: #241503; background: linear-gradient(180deg, #ffe7a6 0%, #f2c15a 45%, #c98a22 100%); box-shadow: 0 2px 0 #6b4510; }
/* the sound switch: raised gold while the sound plays, pressed in (and red) while it is off */
.soundbtn { height: 42px; padding: 0 18px; }
.soundbtn.muted { color: #ff9b8f; transform: translateY(2px); background: linear-gradient(180deg, #120b0b 0%, #1d1111 100%); border-color: rgba(255, 120, 100, 0.6);
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.85), inset 0 -1px 0 rgba(255, 140, 120, 0.12), 0 1px 0 #000; }
.soundbtn.muted svg { color: #ff8a7a; }

/* the controls legend: each Game Boy button as its picture (one height for all), then its key */
.legend { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; }
.kitem { display: inline-flex; align-items: center; gap: 7px; height: 46px; padding: 0 8px 0 6px; border-radius: 12px; background: rgba(0, 0, 0, 0.42); border: 1px solid rgba(255, 231, 166, 0.09); }
.kitem .or { margin: 0 -3px; font: 800 12px/1 Inter, sans-serif; color: rgba(255, 231, 166, 0.5); }
.kitem small { font: 800 10px/1 Inter, sans-serif; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(255, 231, 166, 0.6); }
.gb { position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none; height: 34px; }
.gb img { display: block; height: 100%; width: auto; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.65)); }
.gb.sh { height: 22px; }
.gb.pill { height: 22px; }
.gb b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font: 800 15px/1 Inter, sans-serif; color: rgba(255, 244, 220, 0.96); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75); }
.gb.sh b { font-size: 12px; letter-spacing: 0.12em; }
.gb.pill b { font: 400 9px/1 Bungee, Inter, sans-serif; letter-spacing: 0.1em; color: rgba(255, 231, 166, 0.95); }
.fn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: radial-gradient(circle at 40% 30%, #2c271d, #0c0b0f); border: 1px solid rgba(231, 180, 80, 0.5); }
.fn svg { width: 17px; height: 17px; color: var(--gold); }
kbd.cap { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; padding: 0 9px; border-radius: 7px;
  font: 800 12px/1 Inter, sans-serif; letter-spacing: 0.02em; color: #1b1408;
  background: linear-gradient(180deg, #fff8e8 0%, #f1e3c4 65%, #dbc89f 100%); border: 1px solid #8a6a2c;
  box-shadow: inset 0 -3px 0 rgba(120, 90, 30, 0.35), 0 2px 0 #5a4210, 0 4px 8px rgba(0, 0, 0, 0.45); }
.walk-keys { display: inline-flex; gap: 4px; }
.walk-keys kbd.cap { min-width: 26px; padding: 0 5px; font-size: 14px; }
kbd.cap.mini { min-width: 24px; height: 24px; padding: 0 6px; font-size: 11px; }
.menu-legend { justify-content: flex-start; }

/* ---------- start overlay ---------- */
#start { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; background: #05060b; overflow: auto; touch-action: pan-y; }
#start .bg { position: absolute; inset: 0; background: center / cover no-repeat; filter: blur(22px) brightness(0.45) saturate(1.2); transform: scale(1.1); }
#start .card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: calc(16px + var(--sat)) 16px calc(16px + var(--sab)); text-align: center; width: min(100%,560px); box-sizing: border-box; }
#start .side { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.console-name { color: #e9c575; font: italic 900 13px/1.2 Inter, sans-serif; letter-spacing: .08em; white-space: nowrap; text-shadow: 0 1px 0 #634b25; }
#topbar .console-name { margin-right: auto; font-size: 11px; }
#start .card > img { width: min(82vw, max(160px, calc(100svh - 340px)), 440px); height: auto; aspect-ratio: 1; object-fit: contain; display: block; border-radius: 22px; box-shadow: 0 24px 70px #0009,0 0 0 1px #ffffff14; }
.start-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.btn-ghost.small { min-height: 34px; padding: 0 12px; font-size: 12.5px; }
#start .ios-hint { margin: 0; max-width: 340px; }
#start.loading .start-tools, #start.loading .ios-hint { display: none !important; }
@media (orientation: landscape) and (max-height: 520px) {
  #start .card { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 12px 22px; width: min(100%,760px); }
  #start .card > img { width: min(38vw, max(120px,calc(100svh - 150px)), 340px); }
  #start .card .side { display: flex; flex-direction: column; align-items: center; gap: 12px; }
}
/* the two games (owner 2026-10-22): a choice on the start screen; each opens its own page, ROM and saves */
#start .gamepick { width: 100%; flex: 0 0 100%; max-width: 540px; text-align: left; }
.gamepick-heading { display: flex; justify-content: space-between; align-items: center; margin: 0 2px 8px; font: 700 13px/1.2 Inter,sans-serif; color: var(--cream); }
.gamepick-heading small { color: #c9bfae; font-size: 11px; font-weight: 500; }
.gamepick-list { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; }
#start .gamepick button { position: relative; min-height: 76px; padding: 8px 7px; border: 1px solid #ffffff24; border-radius: 12px; cursor: pointer;
  display: flex; align-items: center; gap: 8px; background: #0a0b11c9; color: #e1d9cc; text-align: left; font: 700 12px/1.3 Inter,sans-serif; }
#start .gamepick button img { width: 40px; height: 40px; flex: none; object-fit: cover; border-radius: 6px; }
#start .gamepick button span { overflow-wrap: normal; }
#start .gamepick button i { position: absolute; right: 5px; top: 3px; font: 700 12px/1 Inter,sans-serif; color: var(--gold); }
#start .gamepick button[aria-pressed="true"] { border-color: #d9ad59; background: linear-gradient(135deg,#54401dd9,#201b15e8); color: #fff4db; box-shadow: inset 0 0 0 1px #e7b45033; cursor: default; }
#start .gamepick button:not([aria-pressed="true"]):hover { border-color: #e7b45080; background: #26221de8; }
#start .gamepick button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media(max-width:560px) { #start .gamepick button { flex-direction: column; align-items: flex-start; gap: 5px; font-size: 11px; min-height: 82px; padding: 7px 9px; } #start .gamepick button img { width: 28px; height: 28px; } }
#start .gamepick.hidden { display: none; }
#start .state { color: var(--muted); font-size: 13px; min-height: 18px; }
#start .bar { width: 220px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.1); overflow: hidden; display: none; }
#start .bar i { display: block; height: 100%; width: 30%; background: var(--gold); border-radius: 2px; animation: load 1.1s ease-in-out infinite; }
#start.loading .bar { display: block; }
#start.loading .gbtn, #start.loading .start-row { display: none; }
@keyframes load { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }
#start .back { position: absolute; top: calc(14px + var(--sat)); left: calc(14px + var(--sal)); }

/* ---------- the pause menu ---------- */
#menu { position: absolute; inset: 0; z-index: 40; display: none; align-items: flex-end; justify-content: center; background: rgba(3, 4, 9, 0.62); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); touch-action: pan-y; }
#menu.open { display: flex; }
.sheet { width: min(560px, 100%); max-height: calc(100% - 20px - var(--sat)); overflow: auto; -webkit-overflow-scrolling: touch; padding: 18px calc(16px + var(--sar)) calc(18px + var(--sab)) calc(16px + var(--sal)); border-radius: 26px 26px 0 0; background: linear-gradient(180deg, #161828 0%, #0c0d16 100%); border: 1px solid var(--line); border-bottom: 0; box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.6); touch-action: pan-y; user-select: none; }
@media (min-width: 700px) and (min-height: 560px) { #menu { align-items: center; } .sheet { border-radius: 26px; border-bottom: 1px solid var(--line); } }
.sheet header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet header h2 { margin: 0; font: 400 19px/1.15 Bungee, sans-serif; }
.sheet header .badge { margin-top: 6px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; min-height: 76px; padding: 10px 4px; border-radius: 18px; border: 1px solid rgba(255, 255, 255, 0.09); background: rgba(255, 255, 255, 0.045); cursor: pointer; font-size: 12px; font-weight: 700; text-align: center; color: var(--cream); }
.tile svg { width: 24px; height: 24px; color: var(--gold2); }
.tile:active { transform: scale(0.97); }
.tile.on { background: linear-gradient(180deg, rgba(255, 231, 166, 0.95), rgba(217, 154, 46, 0.95)); color: #241503; border-color: transparent; }
.tile.on svg { color: #241503; }
.section { margin: 6px 0 14px; }
.section h3 { margin: 0 0 8px 2px; font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.vol { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 200px; }
.vol input { flex: 1; accent-color: var(--gold); }
.vol svg { width: 20px; height: 20px; flex: none; color: var(--muted); }
.slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.slot { position: relative; display: flex; flex-direction: column; border-radius: 14px; overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.1); background: rgba(255, 255, 255, 0.04); cursor: pointer; text-align: left; padding: 0; }
.slot .shot { aspect-ratio: var(--ar, 3 / 2); background: #000 center / cover no-repeat; image-rendering: pixelated; display: grid; place-items: center; color: #4c5066; font-size: 22px; }
.slot .cap { padding: 6px 8px 7px; font-size: 11px; line-height: 1.25; }
.slot .cap b { display: block; font-size: 12px; color: var(--cream); }
.slot .cap span { color: var(--muted); }
.slot .x { position: absolute; top: 5px; right: 5px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.6); color: #fff; display: grid; place-items: center; cursor: pointer; }
.slot .x svg { width: 14px; height: 14px; }
.slot.auto { border-color: rgba(88, 214, 141, 0.35); }
.statesbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.danger { color: #ff9b8f !important; }
.cloudline { margin: 10px 0 0; font-size: 12px; line-height: 1.5; color: var(--muted); }
.cloudline b { color: var(--cream); letter-spacing: 0.08em; white-space: nowrap; user-select: all; -webkit-user-select: all; }
.hidden { display: none !important; }
.ff-badge { position: absolute; z-index: 5; top: calc(14px + var(--sat)); left: 50%; transform: translateX(-50%); padding: 5px 12px; border-radius: 999px; background: linear-gradient(180deg, #ffe7a6, #d99a2e); color: #241503; font: 900 12px/1 Inter, sans-serif; letter-spacing: 0.1em; box-shadow: 0 6px 18px rgba(231, 180, 80, 0.45); pointer-events: none; opacity: 0; transition: opacity .35s; }
.ff-badge.show { opacity: 1; transition: none; }
body.layout-portrait .ff-badge { top: calc(16px + var(--sat)); }

/* the console's logo (owner): where SELECT/START were, portrait only */
.padlogo { display: none; position: absolute; pointer-events: none; -webkit-user-drag: none; }
body.layout-portrait .padlogo { display: block; left: 50%; transform: translateX(-50%); width: min(40vw, 200px); top: max(calc(var(--T) + var(--D) + 26px), calc(var(--T) + var(--D) / 2 + var(--S) * 0.83 + 68px)); opacity: 0.95; }
body.layout-portrait .padlogo.nofit { display: none; }
.ds-padlogo { position: absolute; display: block; object-fit: contain; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.ds-padlogo[hidden] { display: none; }
body.dual-screen #pad .ds-padlogo { pointer-events: none; }

/* start screen: Continue shows where it continues from; Load game / New game; the rarely used links at the bottom */
/* game-box buttons (owner): Play / Continue, Load game, New game and the code dialog's Unlock are text boxes of the
   game: its frame (img/ui/dialog_box.png, from the game, 3x or 2x, pixel-sharp), its font (fonts/firered.woff, made
   from the game's font by tools/make_game_font.py), dark grey letters with the game's light shadow, its menu cursor */
@font-face { font-family: FireRed; src: url(../fonts/firered.woff) format('woff'); font-display: block; }
.gbtn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 0 2px 3px; cursor: pointer;
  border: solid transparent; border-width: 15px 33px; border-image: url(../img/ui/dialog_box.png) 5 11 fill / 15px 33px stretch; image-rendering: pixelated;
  /* white under the frame (12px inside the rim): it fills the hairline gaps where the browser joins the frame's pieces */
  background: linear-gradient(#fffbff, #fffbff) center / calc(100% - 24px) calc(100% - 24px) no-repeat border-box;
  color: #626262; font: 48px/0.8 FireRed, monospace; text-shadow: 3px 0 #d5d5cd, 0 3px #d5d5cd, 3px 3px #d5d5cd; -webkit-font-smoothing: none;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.45)); transition: transform .08s ease, filter .12s ease; -webkit-tap-highlight-color: transparent; }
.gbtn:hover { filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.45)) brightness(1.03); }
.gbtn:active { transform: translateY(3px); }
.gbtn:focus, .gbtn:focus-visible { outline: none; }
.gbtn .ic { flex: none; }
.gbtn.sm { border-width: 10px 22px; border-image-width: 10px 22px; background-size: calc(100% - 16px) calc(100% - 16px); padding: 0 2px 2px; font-size: 32px; text-shadow: 2px 0 #d5d5cd, 0 2px #d5d5cd, 2px 2px #d5d5cd; }
#go { justify-content: flex-start; min-width: min(84vw, 330px); max-width: min(94vw, 680px); text-align: left; }
#go.pending { visibility: hidden; }
#go .thumb { width: 66px; aspect-ratio: 3 / 2; background: #000 center / cover no-repeat; box-shadow: 0 0 0 3px #a5d3e7, 0 0 0 6px #4a71a5; image-rendering: pixelated; flex: none; margin: 3px 4px 0 6px; }
#go.withthumb .ic { display: none; }
#go .golbl { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
#go .golbl .when { white-space: nowrap; font: 32px/0.85 FireRed, monospace; text-shadow: 2px 0 #d5d5cd, 0 2px #d5d5cd, 2px 2px #d5d5cd; }
#go .golbl .when:empty { display: none; }
/* Load game / New game: small game boxes, "or" (in the game's font) between them and Continue */
.start-row { display: flex; flex-wrap: wrap; gap: 2px 10px; justify-content: center; }
.start-row::before { content: 'or'; flex-basis: 100%; text-align: center; font: 32px/1 FireRed, monospace; color: rgba(255, 244, 220, 0.85); text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.55); }
#loadpick { width: min(92vw, 520px); display: flex; flex-direction: column; gap: 10px; align-items: center; }
#loadpick .slots { width: 100%; max-height: 46vh; overflow: auto; }
.linkish { background: none; border: 0; color: var(--muted); font: 600 12.5px Inter, sans-serif; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 4px 6px; }
.start-tools { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

/* ---------- the menu in the game's style (owner): the game's START-menu window (img/ui/menu_box.png, from
   graphics/text_window/std.png, 3x), its font and colours; every button a small game box (.gbtn.sm); the chosen
   speed and SAVE / LOAD carry the game's ▶ cursor ---------- */
#menu .sheet { color: #626262; font: 32px/1.1 FireRed, monospace; text-shadow: 2px 0 #d5d5cd, 0 2px #d5d5cd, 2px 2px #d5d5cd; -webkit-font-smoothing: none;
  border: solid transparent; border-width: 24px; border-image: url(../img/ui/menu_box.png) 8 fill / 24px stretch; image-rendering: pixelated; border-radius: 0;
  background: linear-gradient(#fff, #fff) center / calc(100% - 24px) calc(100% - 24px) no-repeat border-box; box-shadow: none; filter: drop-shadow(0 20px 50px rgba(0, 0, 0, 0.6));
  padding: 2px 6px calc(6px + var(--sab)); }
#menu .sheet header h2 { font: 32px/1.05 FireRed, monospace; color: #626262; }
#menu .sheet header .badge { margin-top: 4px; padding: 0; border: 0; background: none; font: 16px/1 FireRed, monospace; letter-spacing: 0; color: #4a71a5; text-shadow: 1px 1px #c5d7e8; }
#menu .section h3 { margin: 0 0 6px; font: 32px/1 FireRed, monospace; letter-spacing: 0; text-transform: none; color: #4a71a5; text-shadow: 2px 0 #c5d7e8, 0 2px #c5d7e8, 2px 2px #c5d7e8; }
#menu .gbtn.sm { gap: 8px; }
.gbtn.sm svg { width: 20px; height: 20px; flex: none; color: #626262; filter: drop-shadow(2px 2px 0 #d5d5cd); }
.gbtn.sel::before { content: '▶'; margin-right: 2px; }
#menu .gbtn.on { color: #4a71a5; }
#menu .gbtn.on svg { color: #4a71a5; }
#menu .danger { color: #c03028 !important; }
#menu .danger svg { color: #c03028; }
#menu .kitem { background: #f2f7fc; border: 2px solid #a5d3e7; text-shadow: none; }
#menu .kitem small { color: #4a71a5; }
#menu .walkseg { background: #fff; border: 2px solid #a5d3e7; box-shadow: none; }
#menu .walkseg span { font: 16px/1 FireRed, monospace; color: #4a71a5; text-shadow: none; }
#menu .walkseg button { font: 32px/1 FireRed, monospace; color: #626262; text-shadow: none; }
#menu .walkseg button.sel { background: #4a71a5; color: #fff; box-shadow: none; }
/* the menu button in its own colour (owner: it must not get lost among the others): the game's red */
.arc.menu { color: #fff4ea; background: linear-gradient(180deg, #e0412f 0%, #a8160f 100%); border-color: #ffb3a1; }
.arc.menu svg { color: #fff4ea; }
.chip.c-menu { color: #fff4ea; background: linear-gradient(180deg, #e0412f 0%, #a8160f 100%); border-color: rgba(255, 180, 160, 0.75); }
/* Edit controls (desk bar): every Game Boy button can be clicked; the one waiting for its key glows */
.kpen { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border-radius: 50%; cursor: pointer; color: var(--gold);
  background: radial-gradient(circle at 40% 30%, #2c271d, #0c0b0f); border: 1px solid rgba(231, 180, 80, 0.5); }
.kpen svg { width: 16px; height: 16px; }
.kpen:hover { filter: brightness(1.2); }
.kpen.on { color: #241503; background: linear-gradient(180deg, #ffe7a6 0%, #f2c15a 45%, #c98a22 100%); border-color: #ffe7a6; }
body.keyedit .dbar .kitem[data-kb] { cursor: pointer; outline: 2px dashed rgba(255, 231, 166, 0.55); outline-offset: 2px; }
body.keyedit .dbar .kitem[data-kb]:hover { background: rgba(231, 180, 80, 0.16); }
.dbar .kitem.listening { outline: 2px solid #ffe7a6 !important; background: rgba(231, 180, 80, 0.25); animation: kwait 0.9s ease-in-out infinite; }
@keyframes kwait { 50% { box-shadow: 0 0 18px rgba(255, 231, 166, 0.55); } }
/* the walking switch: small and red, beside the arrow keys (owner: the only way to change the walking keys) */
.walkseg.mini { height: 30px; padding: 2px; gap: 2px; margin-left: 2px; border-radius: 9px; border-color: rgba(255, 110, 90, 0.75); background: #170a0a; box-shadow: none; }
.walkseg.mini button { height: 24px; padding: 0 8px; border-radius: 7px; font: 400 10px/1 Bungee, Inter, sans-serif; color: rgba(255, 190, 175, 0.85); }
.walkseg.mini button.sel { color: #fff4ea; background: linear-gradient(180deg, #e0412f 0%, #a8160f 100%); box-shadow: 0 2px 0 #4a0805; }
#menu .walkseg.mini { background: #fff; border: 2px solid #e08a7e; }
#menu .walkseg.mini button { font: 16px/1 FireRed, monospace; color: #8a3a30; }
#menu .walkseg.mini button.sel { color: #fff; background: #c03028; }
.arc kbd.cap.mini { height: 22px; min-width: 22px; padding: 0 5px; margin-left: 2px; font-size: 10px; text-shadow: none; }
dialog.unlock .cancel { display: block; margin: 12px auto 0; }
dialog.switch .gbtn + .gbtn { margin-top: 10px; }
.arc .or { margin: 0 -4px; font: 800 11px/1 Inter, sans-serif; color: rgba(255, 231, 166, 0.6); }

/* ---------- the menu, one window (owner 2026-10-09: one screen, each category on its own, in the game's look) ----------
   GAME / SAVE / LOAD / ONLINE / KEYS: tabs across the top on an upright phone, the START menu's list (with its cursor)
   on the left elsewhere. Only the panel scrolls, and only when a small screen needs it. Text in the game's font: 16px
   (1x) for small text, 24px on a phone and 32px elsewhere for labels. */
#menu { align-items: center; padding: calc(6px + var(--sat)) calc(6px + var(--sar)) calc(6px + var(--sab)) calc(6px + var(--sal)); }
#menu .sheet { width: min(800px, 100%); height: min(640px, 100%); max-height: none; overflow: hidden; display: flex; padding: 0 4px 4px; }
.mwin { --fl: 32px; flex: 1; min-width: 0; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr);
  grid-template-areas: 'head' 'tabs' 'panel'; gap: 6px; }
.mhead { grid-area: head; display: flex; align-items: baseline; gap: 12px; min-width: 0; padding: 2px 2px 0 6px; }
.mhead h2 { margin: 0; font: 32px/1 FireRed, monospace; color: #626262; }
.msub { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 16px/1 FireRed, monospace; color: #4a71a5; text-shadow: 1px 1px #c5d7e8; }
.mbtn.mclose { align-self: center; width: 40px; height: 36px; padding: 0; background: none; box-shadow: none; color: #626262; }
.mbtn.mclose svg { width: 22px; height: 22px; }
.mtabs { grid-area: tabs; display: flex; gap: 4px; padding: 0 2px; border-bottom: 3px solid #a5d3e7; }
.mtab { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px 7px; margin-bottom: -3px; cursor: pointer;
  background: none; border: 0; border-bottom: 3px solid transparent; font: 16px/1 FireRed, monospace; color: #8a8a8a; text-shadow: 1px 1px #e3e3dc; -webkit-tap-highlight-color: transparent; }
.mtab svg { width: 24px; height: 24px; }
.mtab.sel { color: #4a71a5; background: #e8f1f9; border-bottom-color: #4a71a5; text-shadow: 1px 1px #c5d7e8; }
.mtab.sel span::before { content: '▶'; margin-right: 3px; }
.mpanel { grid-area: panel; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 4px 4px 6px; touch-action: pan-y; }
.mhint { margin: 2px 6px 10px; font: 16px/1.35 FireRed, monospace; color: #626262; text-shadow: 1px 0 #d5d5cd, 0 1px #d5d5cd, 1px 1px #d5d5cd; }
/* a small blue game button (the game's YES / NO box colours) */
.mbtn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; width: 100%; min-height: 32px; padding: 6px 8px 8px; cursor: pointer; border: 0;
  background: #4a71a5; color: #fff; box-shadow: inset 0 -3px 0 #2f4f7c; font: 16px/1 FireRed, monospace; text-shadow: 1px 1px #2f4f7c; -webkit-tap-highlight-color: transparent; }
.mbtn:active { transform: translateY(2px); box-shadow: inset 0 -1px 0 #2f4f7c; }
.mbtn svg { width: 15px; height: 15px; flex: none; }
.mbtn.ico { width: 38px; flex: none; padding: 6px 0 8px; }
.mbtn.yes { background: #c03028; box-shadow: inset 0 -3px 0 #7d1d18; text-shadow: 1px 1px #7d1d18; }
.mbtn.off { background: #ecece6; color: #a0a0a0; box-shadow: none; text-shadow: none; cursor: default; }
.mbtn.wide { width: auto; padding: 9px 16px 11px; }
/* GAME: the big actions */
.mtiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 20px; padding: 8px 8px 6px; }
.mtile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 92px; padding: 10px 6px; cursor: pointer; border: 0;
  background: #fff; box-shadow: 0 0 0 3px #a5d3e7, 0 0 0 6px #4a71a5; color: #626262; font: var(--fl)/0.9 FireRed, monospace;
  text-shadow: 2px 0 #d5d5cd, 0 2px #d5d5cd, 2px 2px #d5d5cd; -webkit-tap-highlight-color: transparent; }
.mtile b { font: inherit; }
a.mtile { color: inherit; text-decoration: none; }
.mtile svg { width: 28px; height: 28px; color: #626262; }
.mtile small { font: 16px/1 FireRed, monospace; color: #8a8a8a; text-shadow: none; }
.mtile:active { transform: translateY(2px); }
.mtile.on { color: #4a71a5; background: #e8f1f9; }
.mtile.on svg, .mtile.on small { color: #4a71a5; }
.mtile.prime { background: #4a71a5; color: #fff; text-shadow: 2px 2px #2f4f7c; box-shadow: 0 0 0 3px #a5d3e7, 0 0 0 6px #2f4f7c; }
.mtile.prime svg { color: #fff; }
.mtile.danger, .mtile.danger svg { color: #c03028; }
.mtile.danger { box-shadow: 0 0 0 3px #f2b8b0, 0 0 0 6px #c03028; }
.mtile.ask { background: #fde8e6; }
.mvol { display: flex; align-items: center; gap: 12px; margin: 18px 8px 4px; font: 16px/1 FireRed, monospace; color: #626262; }
.mvol b { font: inherit; }
.mvol input { flex: 1; accent-color: #4a71a5; }
/* SAVE / LOAD: slot cards, each with its own button */
.mslots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; padding: 7px; }
.mslots.many { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mcard { display: flex; flex-direction: column; min-width: 0; background: #fff; box-shadow: 0 0 0 3px #a5d3e7, 0 0 0 6px #4a71a5; }
.mcard.auto { box-shadow: 0 0 0 3px #b6e3c3, 0 0 0 6px #3f8f5a; }
.mcard.empty .mshot { background: repeating-linear-gradient(45deg, #f1f1ec 0 6px, #e6e6e0 6px 12px); }
.mcard.just { animation: mjust 1.2s ease-out 1; }
@keyframes mjust { 0% { box-shadow: 0 0 0 3px #ffe7a6, 0 0 0 6px #d99a2e, 0 0 18px #ffe7a6; } 100% { box-shadow: 0 0 0 3px #a5d3e7, 0 0 0 6px #4a71a5; } }
/* the picture carries when it was kept, on a dark band at its foot, like a photo's date */
.mshot { position: relative; display: block; flex: none; aspect-ratio: var(--ar, 3 / 2); background: #000 center / cover no-repeat; image-rendering: pixelated; }
.mwhen { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 5px 2px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  background: rgba(20, 22, 30, 0.72); font: 16px/1 FireRed, monospace; color: #fff; text-shadow: none; }
.mcard.empty .mwhen { background: none; top: 0; display: grid; place-items: center; color: #a0a0a0; }
.mname { min-width: 0; padding: 6px 7px 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 16px/1 FireRed, monospace; color: #626262; }
.mcard > .mbtn, .mcard > .mask { margin: 2px 6px 6px; width: auto; }
.mask { display: flex; gap: 4px; }
.mask .mbtn { flex: 1; width: auto; }
.mask .mbtn.ico { flex: none; }
.mfoot { display: flex; justify-content: center; padding: 14px 6px 4px; }
/* ONLINE */
.mcode { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; margin: 4px 8px 4px; }
.mcode small { flex-basis: 100%; font: 16px/1 FireRed, monospace; color: #4a71a5; }
.mcode .mbtn { width: auto; padding: 6px 14px 8px; }
#mycode { font: 32px/1 FireRed, monospace; color: #4a71a5; text-shadow: 2px 0 #c5d7e8, 0 2px #c5d7e8, 2px 2px #c5d7e8; user-select: all; -webkit-user-select: all; }
.mlist { display: flex; flex-direction: column; gap: 18px; padding: 7px; }
.mrow { display: flex; align-items: center; gap: 12px; padding: 10px 12px; text-align: left; cursor: pointer; border: 0; background: #fff;
  box-shadow: 0 0 0 3px #a5d3e7, 0 0 0 6px #4a71a5; color: #626262; -webkit-tap-highlight-color: transparent; }
.mrow:active { transform: translateY(2px); }
.mrow svg { width: 26px; height: 26px; flex: none; color: #4a71a5; }
.mrow b { display: block; font: var(--fl)/0.95 FireRed, monospace; text-shadow: 2px 0 #d5d5cd, 0 2px #d5d5cd, 2px 2px #d5d5cd; }
.mrow small { display: block; margin-top: 3px; font: 16px/1.2 FireRed, monospace; color: #8a8a8a; }
/* KEYS */
.mpanel .menu-legend { padding: 6px; }
/* an upright phone: smaller labels, three slots a row */
@media (max-width: 560px) {
  .mwin { --fl: 24px; }
  .mtiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
  .mtile { min-height: 78px; }
  .mslots, .mslots.many { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .mhint { margin-bottom: 6px; }
}
/* wide screens and phones on their side: the categories as the game's START menu, on the left */
@media (min-width: 561px) and (min-aspect-ratio: 1 / 1), (orientation: landscape) and (max-height: 560px) {
  .mwin { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: 'head head' 'tabs panel'; column-gap: 10px; }
  .mtabs { flex-direction: column; gap: 2px; padding: 4px 0; border-bottom: 0; border-right: 3px solid #a5d3e7; }
  .mtab { flex: none; flex-direction: row; justify-content: flex-start; gap: 8px; padding: 8px 14px 9px 8px; margin: 0 -3px 0 0; border-bottom: 0;
    border-right: 3px solid transparent; font: var(--fl)/1 FireRed, monospace; text-shadow: 2px 0 #e3e3dc, 0 2px #e3e3dc; }
  .mtab.sel { border-right-color: #4a71a5; text-shadow: 2px 0 #c5d7e8, 0 2px #c5d7e8; }
  .mtab span::before { content: '▶'; visibility: hidden; margin-right: 3px; }
  .mtab.sel span::before { visibility: visible; }
}
/* a phone on its side: little height, so smaller everything */
@media (orientation: landscape) and (max-height: 560px) {
  #menu .sheet { position: relative; height: 100%; width: min(900px, 100%); }
  .mwin { --fl: 24px; grid-template-rows: minmax(0, 1fr); grid-template-areas: 'tabs panel'; }
  /* no title row: only the close button, top right */
  .mhead { position: absolute; top: 6px; right: 8px; z-index: 2; padding: 0; }
  .mhead h2, .msub { display: none; }
  .mtabs { padding-top: 6px; }
  .mtab { padding: 6px 10px 7px 6px; }
  .mtab svg { width: 20px; height: 20px; }
  .mpanel { padding-right: 44px; }
  .mtiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
  .mtile { min-height: 64px; padding: 6px 4px; }
  .mvol { margin-top: 12px; }
  /* slots as rows: a small picture, the name, the button */
  .mslots, .mslots.many { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .mcard { flex-direction: row; align-items: center; }
  .mcard .mshot { width: 60px; }
  .mcard .mwhen { display: none; }
  .mcard.empty .mwhen { display: grid; font-size: 0; }
  .mcard .mname { flex: 1; display: flex; flex-direction: column; gap: 4px; padding: 4px 6px; }
  .mcard .mname::after { content: attr(data-when); overflow: hidden; text-overflow: ellipsis; color: #8a8a8a; }
  .mcard > .mbtn, .mcard > .mask { flex: none; width: 92px; margin: 0 5px; }
  .mcard > .mask { width: 118px; }
  .mcard > .mask .mbtn.ico { width: 30px; }
  /* ONLINE: the three actions side by side, titles only */
  .mcode { margin-top: 0; }
  .mcode small { display: none; }
  #mycode { font-size: 24px; }
  .mlist { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
  .mrow { flex-direction: column; justify-content: center; gap: 6px; padding: 8px 6px; text-align: center; }
  .mrow small { display: none; }
}
/* an upright phone with little height (an iPhone SE, a browser bar): lower tiles, no explanation lines */
@media (max-width: 560px) and (max-height: 740px) {
  .mhead h2 { font-size: 24px; }
  .mtab { padding: 4px 2px 5px; }
  .mtab svg { width: 20px; height: 20px; }
  .mtiles { gap: 12px; padding-top: 4px; }
  .mtile { min-height: 0; padding: 4px 4px 5px; gap: 2px; }
  .mtile svg { width: 20px; height: 20px; }
  .mtile small { font-size: 14px; }
  .mvol { margin-top: 12px; }
  .mlist { gap: 16px; }
  .mrow { padding: 8px 10px; }
  .mrow small { display: none; }
  #mycode { font-size: 24px; }
}
