/* Super Plumber - page chrome. No external fonts or assets. */
:root {
  --bg: #0b0b14;
  --ink: #16121f;
  --panel: #1b1930;
  --panel-2: #262343;
  --line: #3b3763;
  --text: #f3f1ff;
  --muted: #a9a4cc;
  --gold: #ffd23f;
  --gold-dark: #b8720a;
  --red: #e5352b;
  --red-dark: #8f1711;
  --green: #3fa82f;
  --green-dark: #236b22;
  --px: 4px;
  --font: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", "Courier New", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
}
body { overflow: hidden; overscroll-behavior: none; }

/* ------------------------------------------------------------------ lobby */
#lobby {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(12px, 4vh, 48px) 16px 32px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* The backdrop is the game itself: main.js pans the selected level across this canvas. */
#lobbyBg {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 100%;
  pointer-events: none;
  background: var(--bg);
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}
/* dim it so the card reads on bright (overworld) and dark (castle) levels alike */
#lobby::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, rgba(11, 11, 20, .42) 0 35%, rgba(11, 11, 20, .22) 100%);
}

.card {
  position: relative;
  z-index: 1;
  width: min(100%, 460px);
  margin: auto;
  padding: 22px 22px 18px;
  background: var(--panel);
  border: var(--px) solid var(--ink);
  box-shadow:
    inset 0 var(--px) 0 var(--panel-2),
    inset 0 calc(var(--px) * -1) 0 #121024,
    0 0 0 var(--px) var(--line),
    0 calc(var(--px) * 3) 0 var(--px) rgba(0, 0, 0, .45);
  text-align: center;
}

.title {
  margin: 0 0 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.title span { display: block; }
.t-super {
  font-size: clamp(18px, 5.2vw, 24px);
  color: var(--gold);
  text-shadow: 2px 2px 0 var(--gold-dark), 4px 4px 0 var(--ink);
  letter-spacing: .5em;
  margin-right: -.5em;
}
.t-plumber {
  font-size: clamp(38px, 12.5vw, 60px);
  color: #fff;
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
  text-shadow:
    0 3px 0 #e2852c, 0 6px 0 #d9731a, 0 9px 0 #9c4f10,   /* the hero's orange */
    4px 12px 0 var(--ink), -4px 12px 0 var(--ink), 0 13px 0 var(--ink);
  padding-bottom: 14px;
}
.tagline { margin: 18px 0 16px; color: var(--muted); font-size: 13px; }
.top-score { margin: -8px 0 14px; font-size: 13px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
.top-score b { color: #fff; letter-spacing: .12em; text-shadow: 2px 2px 0 var(--ink); }

.fields { display: grid; grid-template-columns: 1fr; gap: 12px; text-align: left; }
.field span {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gold);
}
.field input, .field select {
  width: 100%;
  padding: 10px 10px;
  font: 700 16px var(--font);
  color: var(--text);
  background: #0f0e1d;
  border: 3px solid var(--ink);
  border-radius: 0;
  outline: none;
  box-shadow: 0 0 0 2px var(--line), inset 0 3px 0 rgba(0, 0, 0, .5);
  -webkit-appearance: none;
  appearance: none;
}
.field select {
  padding-right: 38px;
  letter-spacing: .08em;
  cursor: pointer;
  /* chunky pixel chevron */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 4' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h7v1H0zM1 1h5v1H1zM2 2h3v1H2zM3 3h1v1H3z' fill='%23ffd23f'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px 8px;
}
.field select option { color: var(--text); background: #0f0e1d; font-weight: 700; }
.field input::placeholder { color: #5c5888; }
.field input:focus, .field select:focus { box-shadow: 0 0 0 2px var(--gold), inset 0 3px 0 rgba(0, 0, 0, .5); }

.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice-4 { grid-template-columns: repeat(4, 1fr); gap: 6px; }
.choice-4 button { padding-left: 2px; padding-right: 2px; font-size: 11px; letter-spacing: .04em; }
.touch-only { display: none; }
@media (hover: none) and (pointer: coarse) { .touch-only { display: block; } }
.choice button {
  padding: 9px 6px 10px;
  font: 700 14px var(--font);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  background: #0f0e1d;
  border: 3px solid var(--ink);
  border-radius: 0;
  box-shadow: 0 0 0 2px var(--line), inset 0 3px 0 rgba(0, 0, 0, .5);
  cursor: pointer;
  touch-action: manipulation;
}
.choice button:hover { color: var(--text); }
.choice button.selected { color: var(--ink); background: var(--gold); box-shadow: 0 0 0 2px var(--gold-dark), inset 0 3px 0 #fff6c4, inset 0 -4px 0 var(--gold-dark); }
.choice button:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* second-lap marker: shown when main.js sets data-quest="2" on #lobby */
.quest-note { display: none; margin: -6px 0 14px; font-size: 12px; font-weight: 700; color: var(--gold); }
#lobby[data-quest="2"] .quest-note { display: flex; align-items: center; justify-content: center; gap: 8px; }
.emblem {
  flex: none; width: 21px; height: 21px;
  image-rendering: pixelated;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 7' shape-rendering='crispEdges'%3E%3Cpath d='M2 0h1v1H2zM4 0h1v1H4zM1 1h2v1H1zM4 1h2v1H4zM0 2h2v1H0zM5 2h2v1H5zM3 3h1v1H3zM0 4h2v1H0zM5 4h2v1H5zM1 5h2v1H1zM4 5h2v1H4zM2 6h1v1H2zM4 6h1v1H4z' fill='%23ffd23f'/%3E%3Cpath d='M3 1h1v1H3zM2 2h1v1H2zM4 2h1v1H4zM1 3h1v1H1zM5 3h1v1H5zM2 4h1v1H2zM4 4h1v1H4zM3 5h1v1H3z' fill='%23fff6c4'/%3E%3C/svg%3E") center / contain no-repeat;
}
.hint-note { margin: 10px 0 0; font-size: 11px; line-height: 1.5; color: var(--muted); }

#playBtn {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 13px 12px 15px;
  font: 900 22px var(--font);
  letter-spacing: .3em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 2px 2px 0 var(--green-dark);
  background: var(--green);
  border: 3px solid var(--ink);
  border-radius: 0;
  box-shadow: inset 0 4px 0 #8fe055, inset 0 -6px 0 var(--green-dark), 0 5px 0 var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}
#playBtn:hover { filter: brightness(1.08); }
#playBtn:active { transform: translateY(4px); box-shadow: inset 0 4px 0 #8fe055, inset 0 -3px 0 var(--green-dark), 0 1px 0 var(--ink); }
#playBtn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
#playBtn:disabled { filter: grayscale(.7) brightness(.8); cursor: default; }

#lobbyError { min-height: 20px; margin-top: 10px; font-size: 13px; font-weight: 700; color: #ff7a6b; }
#lobbyError:empty { min-height: 14px; margin-top: 4px; }

.controls { border-top: 3px dashed var(--line); padding-top: 12px; text-align: left; }
.controls h2 { margin: 0 0 8px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.controls ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.controls li { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); }
.controls .keys { color: #6f6a9c; white-space: nowrap; }
kbd {
  display: inline-block;
  min-width: 22px;
  margin: 0 1px;
  padding: 2px 6px 3px;
  font: 700 11px var(--font);
  text-align: center;
  color: var(--text);
  background: var(--panel-2);
  border: 2px solid var(--ink);
  box-shadow: 0 0 0 1px var(--line), 0 3px 0 var(--ink);
}

/* ------------------------------------------------------------------ game */
#gameWrap {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}
.stage {
  /* largest 16:15 box that fits the window, leaving room for the status bar */
  width: min(100vw, calc((100vh - 34px) * 256 / 240));
  width: min(100vw, calc((100dvh - 34px) * 256 / 240));
}
#game {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 256 / 240;
  background: #3476de;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  box-shadow: 0 0 0 2px #000, 0 0 40px rgba(60, 90, 200, .18);
}
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 34px;
  padding: 0 8px;
  font-size: 12px;
  color: var(--muted);
}
#status { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; letter-spacing: .04em; }
#muteBtn {
  flex: none;
  padding: 4px 10px 5px;
  font: 700 11px var(--font);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text);
  background: var(--panel-2);
  border: 2px solid var(--ink);
  border-radius: 0;
  box-shadow: 0 0 0 1px var(--line), 0 2px 0 #000;
  cursor: pointer;
  touch-action: manipulation;
}
#muteBtn:hover { background: #322e58; }
#muteBtn.muted, #muteBtn[data-muted="true"] { color: #7d789f; background: var(--panel); }

/* ------------------------------------------------------------------ touch */
/* One set of controls, two looks: a translucent overlay (tablets, phones held sideways) and a flat handheld face on
   phones held upright. Flat fills, crisp outlines, hard-edged travel steps; no blur anywhere. The design is this
   project's own. */
#touch { display: none; }
@media (hover: none) and (pointer: coarse) {
  #touch {
    display: block; position: fixed; inset: 0; pointer-events: none; z-index: 5;
    --ink: #1d1a22; --shell: #e8e6e0; --disc: #b4b1a9; --band: #d6d3cb; --key: #33313c; --key-lo: #1f1d26; --key-hi: #45434f;
    --mark: #f3f0e8; --label: #2a2730; --keycap: #f4f2ec; --keycap-lo: #cfccc4; --hi: rgba(255,255,255,.34); --lo: rgba(0,0,0,.2);
    --orange: #f47c14; --teal: #0fb5bd; --gold: #f7c41c; --plum: #a24fd0;   /* this game's own palette, at full strength */
  }
  #touch button {
    pointer-events: auto; position: absolute; margin: 0; padding: 0; border: 0; background: none; color: var(--mark);
    font: 900 12px var(--font); letter-spacing: .08em; text-transform: uppercase;
    -webkit-tap-highlight-color: transparent; touch-action: none; -webkit-user-select: none; user-select: none;
  }
  #touch .ico { display: block; fill: currentColor; shape-rendering: crispEdges; pointer-events: none; }
  #touch .keys { display: none; }

  /* direction pad: one outlined cross drawn in SVG, with four transparent touch areas over its arms */
  .dpad {
    pointer-events: auto; touch-action: none;
    position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom));
    width: clamp(124px, 32vmin, 176px); aspect-ratio: 1; opacity: .84;
  }
  #touch .dpad button { z-index: 2; }
  #touch .dpad #btnUp    { left: 30%; top: 0;    width: 40%; height: 38%; }
  #touch .dpad #btnDown  { left: 30%; bottom: 0; width: 40%; height: 38%; }
  #touch .dpad #btnLeft  { left: 0;   top: 30%;  width: 38%; height: 40%; }
  #touch .dpad #btnRight { right: 0;  top: 30%;  width: 38%; height: 40%; }
  .dpad .cross { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
  .cross .step { fill: var(--ink); stroke: var(--ink); stroke-width: 5; stroke-linejoin: round; transform: translateY(6px); }
  .cross .body { fill: var(--key-hi); stroke: var(--ink); stroke-width: 5; stroke-linejoin: round; }
  .cross .arm { fill: #000; opacity: 0; }
  .cross .tri { fill: var(--mark); }
  .cross .dimple { fill: var(--key-lo); stroke: var(--ink); stroke-width: 3; }
  .cross .cap { transition: transform .12s cubic-bezier(.3, 1.8, .5, 1); }
  /* pressed: the cross sinks onto its step, the held arm darkens and its arrow lights */
  .dpad button.down ~ .cross .cap { transform: translateY(4px); transition-duration: .03s; }
  .dpad #btnUp.down ~ .cross .arm-up, .dpad #btnDown.down ~ .cross .arm-down,
  .dpad #btnLeft.down ~ .cross .arm-left, .dpad #btnRight.down ~ .cross .arm-right { opacity: .32; }
  .dpad #btnUp.down ~ .cross .tri-up, .dpad #btnDown.down ~ .cross .tri-down,
  .dpad #btnLeft.down ~ .cross .tri-left, .dpad #btnRight.down ~ .cross .tri-right { fill: var(--orange); }

  /* action buttons. Overlay look: one JUMP and one RUN, hold RUN with the pad of the thumb and roll up-right onto JUMP */
  .face {
    pointer-events: auto; touch-action: none;
    position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom));
    width: clamp(138px, 36vmin, 196px); aspect-ratio: 1; opacity: .9;
  }
  #touch .face button {
    border-radius: 50%; display: grid; place-items: center; color: var(--ink);
    border: 3px solid var(--ink);
    box-shadow: inset 0 3px 0 var(--hi), inset 0 -4px 0 var(--lo), 0 5px 0 var(--ink);
    transition: transform .14s cubic-bezier(.3, 1.8, .5, 1), box-shadow .1s;
  }
  #touch .face button .ico { width: 44%; }
  #touch .face .f-top .ico { width: 32%; }
  #touch .face .f-right .ico, #touch .face .f-bottom .ico { width: 40%; }
  #touch .face #btnJump  { background: var(--orange); right: 0; top: 2%; width: 52%; height: 52%; }
  #touch .face #btnRun   { background: var(--teal); left: 2%; bottom: 4%; width: 47%; height: 47%; }
  #touch .face #btnJump2 { background: var(--gold); display: none; }   /* the second jump and run exist only on the handheld face */
  #touch .face #btnRun2  { background: var(--plum); display: none; }
  #touch .face button.down {
    transform: translateY(5px); transition-duration: .03s;
    box-shadow: inset 0 3px 0 var(--lo), inset 0 0 0 99px rgba(0,0,0,.13), 0 1px 0 var(--ink);
  }
}

/* ---- phones held upright: the whole screen becomes a flat handheld face.
   Proportions: the game picture on top at full width, flat shell directly below it; direction pad centred at 23% of
   the width, face-button disc at 72%, both at 45% of the shell's height; two small keys at 42% / 58%, 82% down. */
@media (hover: none) and (pointer: coarse) and (orientation: portrait) and (max-width: 540px) {
  #gameWrap {
    justify-content: flex-start; padding: env(safe-area-inset-top) 0 0; background: #000;
    /* height of the screen area: exactly the picture's height at full width, so no black strip is left under it;
       less only when the shell (at least 80vw tall) needs the room on a short phone */
    --scr: max(96px, min(100vw * 240 / 256, 100vh - 80vw - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
  }
  @supports (height: 100dvh) {
    #gameWrap { --scr: max(96px, min(100vw * 240 / 256, 100dvh - 80vw - env(safe-area-inset-top) - env(safe-area-inset-bottom))); }
  }
  /* the screen: flush to the top and both sides, the picture top-aligned at full width, black below it */
  .stage { flex: none; width: 100%; height: var(--scr); background: #000; overflow: hidden; }
  #game { width: min(100%, calc(var(--scr) * 256 / 240)); margin: 0 auto; box-shadow: none; }
  .bar { display: none; }

  /* the shell: one flat panel filling everything below, meeting the screen in a straight line */
  #touch {
    position: relative; inset: auto; flex: 1 1 0; align-self: stretch; min-height: 0;
    display: block; pointer-events: auto; touch-action: none;
    background: var(--shell); border-top: 3px solid var(--ink);
  }

  .dpad { left: 2.5vw; bottom: auto; top: 45.5%; width: 41vw; margin-top: -20.5vw; opacity: 1; }

  /* four equal face buttons in a diamond, set in a round disc; two light bands pair them (run pair, jump pair) */
  .face { right: 2.5vw; bottom: auto; top: 45.5%; width: 51vw; margin-top: -25.5vw; opacity: 1; border-radius: 50%;
    background: var(--disc); border: 3px solid var(--ink); }
  .face::before, .face::after { content: ""; position: absolute; width: 76%; height: 35%; border-radius: 999px;
    background: var(--band); transform: rotate(-45deg); }
  .face::before { left: -2.5%; top: 19%; }
  .face::after  { left: 26.5%; top: 48%; }
  #touch .face #btnJump, #touch .face #btnRun, #touch .face #btnJump2, #touch .face #btnRun2 {
    display: grid; width: 30.8%; height: 30.8%; left: auto; right: auto; top: auto; bottom: auto; z-index: 1; border-width: 2.5px; }
  #touch .face #btnRun2  { left: 34.6%; top: 5.6%; }
  #touch .face #btnRun   { left: 5.6%;  top: 34.6%; }
  #touch .face #btnJump2 { right: 5.6%; top: 34.6%; }
  #touch .face #btnJump  { left: 34.6%; top: 63.6%; }

  /* two small round keys at the bottom centre, labelled beneath */
  #touch .keys { display: block; position: absolute; left: 0; right: 0; top: 82%; height: 0; }
  #touch .keys label { position: absolute; top: 0; width: 16vw; margin: -2.75vw 0 0 -8vw; display: grid; justify-items: center; gap: 7px;
    font: 900 9px var(--font); letter-spacing: .14em; text-transform: uppercase; color: var(--label); }
  #touch .keys label:nth-child(1) { left: 42%; }
  #touch .keys label:nth-child(2) { left: 58%; }
  #touch .keys button { position: relative; width: max(5.5vw, 20px); height: max(5.5vw, 20px); border-radius: 50%; background: var(--keycap); border: 2.5px solid var(--ink);
    box-shadow: inset 0 2px 0 var(--hi), 0 3px 0 var(--ink); transition: transform .14s cubic-bezier(.3, 1.8, .5, 1), box-shadow .1s; }
  #touch .keys button::after { content: ""; position: absolute; inset: -14px -13px -26px; }   /* roomier touch target, covers the label */
  #touch .keys button.down { transform: translateY(3px); transition-duration: .03s; background: var(--keycap-lo); box-shadow: 0 0 0 var(--ink); }
  #touch .keys button.on { background: var(--orange); }

  /* the screen switches on */
  #gameWrap:not([hidden]) #game { animation: screen-on .55s ease-out both; }
  @keyframes screen-on {
    0% { filter: brightness(0); transform: scaleY(.012); }
    38% { filter: brightness(2.2); transform: scaleY(.012); }
    70% { filter: brightness(1.5); transform: scaleY(1); }
    100% { filter: none; transform: none; }
  }
}
@media (hover: none) and (pointer: coarse) and (orientation: portrait) and (max-width: 540px) and (prefers-color-scheme: dark) {
  #touch {
    --ink: #08070b; --shell: #33323a; --disc: #1f1e25; --band: #45434e; --key: #15141a; --key-lo: #0c0b10; --key-hi: #23222b;
    --mark: #e9e6de; --label: #c9c5d0; --hi: rgba(255,255,255,.24); --keycap: #5a5864; --keycap-lo: #45434e;
  }
}
/* ---- phones held sideways: the same handheld turned on its side. The picture fills the height in the middle and the
   shell wraps both sides: direction pad on the left panel, the four-button disc on the right, a small key under each. */
@media (hover: none) and (pointer: coarse) and (orientation: landscape) and (max-height: 540px) {
  #gameWrap {
    background: #e8e6e0; padding: 0; justify-content: center;
    --p: calc((100vw - 100vh * 256 / 240) / 2);          /* width of each side panel */
    --dw: min(calc(var(--p) - 30px), 50vh);              /* direction pad size */
    --fw: min(calc(var(--p) - 22px), 60vh);              /* face disc size */
  }
  @supports (height: 100dvh) { #gameWrap { --p: calc((100vw - 100dvh * 256 / 240) / 2); --dw: min(calc(var(--p) - 30px), 50dvh); --fw: min(calc(var(--p) - 22px), 60dvh); } }
  .stage { width: auto; height: 100%; aspect-ratio: 256 / 240; background: #000; box-shadow: 0 0 0 3px #1d1a22; }
  #game { width: 100%; height: 100%; box-shadow: none; }
  .bar { display: none; }
  #touch { pointer-events: none; }

  .dpad { left: calc((var(--p) - var(--dw)) / 2); right: auto; bottom: auto; top: 43%; width: var(--dw); margin-top: calc(var(--dw) / -2); opacity: 1; }

  /* four equal face buttons in a diamond, set in a round disc; two light bands pair them (run pair, jump pair) */
  .face { right: 2.5vw; bottom: auto; top: 45.5%; width: 51vw; margin-top: -25.5vw; opacity: 1; border-radius: 50%;
    background: var(--disc); border: 3px solid var(--ink); }
  .face::before, .face::after { content: ""; position: absolute; width: 76%; height: 35%; border-radius: 999px;
    background: var(--band); transform: rotate(-45deg); }
  .face::before { left: -2.5%; top: 19%; }
  .face::after  { left: 26.5%; top: 48%; }
  #touch .face #btnJump, #touch .face #btnRun, #touch .face #btnJump2, #touch .face #btnRun2 {
    display: grid; width: 30.8%; height: 30.8%; left: auto; right: auto; top: auto; bottom: auto; z-index: 1; border-width: 2.5px; }
  #touch .face #btnRun2  { left: 34.6%; top: 5.6%; }
  #touch .face #btnRun   { left: 5.6%;  top: 34.6%; }
  #touch .face #btnJump2 { right: 5.6%; top: 34.6%; }
  #touch .face #btnJump  { left: 34.6%; top: 63.6%; }

  /* two small round keys at the bottom centre, labelled beneath */
  #touch .keys { display: block; position: absolute; left: 0; right: 0; top: 82%; height: 0; }
  #touch .keys label { position: absolute; top: 0; width: 16vw; margin: -2.75vw 0 0 -8vw; display: grid; justify-items: center; gap: 7px;
    font: 900 9px var(--font); letter-spacing: .14em; text-transform: uppercase; color: var(--label); }
  #touch .keys label:nth-child(1) { left: 42%; }
  #touch .keys label:nth-child(2) { left: 58%; }
  #touch .keys button { position: relative; width: max(5.5vw, 20px); height: max(5.5vw, 20px); border-radius: 50%; background: var(--keycap); border: 2.5px solid var(--ink);
    box-shadow: inset 0 2px 0 var(--hi), 0 3px 0 var(--ink); transition: transform .14s cubic-bezier(.3, 1.8, .5, 1), box-shadow .1s; }
  #touch .keys button::after { content: ""; position: absolute; inset: -14px -13px -26px; }   /* roomier touch target, covers the label */
  #touch .keys button.down { transform: translateY(3px); transition-duration: .03s; background: var(--keycap-lo); box-shadow: 0 0 0 var(--ink); }
  #touch .keys button.on { background: var(--orange); }
  .face { right: calc((var(--p) - var(--fw)) / 2); left: auto; bottom: auto; top: 43%; width: var(--fw); margin-top: calc(var(--fw) / -2); }

  /* one small key centred under each cluster */
  #touch .keys { top: 86%; }
  #touch .keys label { width: 72px; margin: -13px 0 0 -36px; gap: 5px; font-size: 8px; }
  #touch .keys label:nth-child(1) { left: calc(var(--p) / 2); }
  #touch .keys label:nth-child(2) { left: calc(100vw - var(--p) / 2); }
  #touch .keys button { width: 24px; height: 24px; }
}
@media (hover: none) and (pointer: coarse) and (orientation: landscape) and (max-height: 540px) and (prefers-color-scheme: dark) {
  #gameWrap { background: #33323a; }
  .stage { box-shadow: 0 0 0 3px #08070b; }
  #touch {
    --ink: #08070b; --shell: #33323a; --disc: #1f1e25; --band: #45434e; --key: #15141a; --key-lo: #0c0b10; --key-hi: #23222b;
    --mark: #e9e6de; --label: #c9c5d0; --hi: rgba(255,255,255,.24); --keycap: #5a5864; --keycap-lo: #45434e;
  }
}
@media (prefers-reduced-motion: reduce) {
  #gameWrap:not([hidden]) #game { animation: none !important; }
  .cross .cap, #touch button { transition: none !important; }
}
