/* ---- Screen bar (src/ui/screen-bar.js, owner 2026-10-18): every menu subscreen has the
   Garage's bottom bar, key hints left, CTAs right (the primary action, then Back, always last),
   and a square back button left of its title. Glyphs follow the last input (body[data-input]):
   keyboard keys, the pad's buttons by brand, nothing on touch. Loaded after style.css. ---- */
.sb-bar {
  --sb-h: 64px; --sb-accent: #00c8ff; --sb-ink: #0a0a1a; --sb-skew: -12deg; --sb-x: var(--rl-x, clamp(24px, 4vw, 72px));
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; height: var(--sb-h); box-sizing: border-box;
  padding: 0 var(--sb-x) env(safe-area-inset-bottom, 0px);
  display: flex; align-items: center; gap: clamp(16px, 2vw, 32px);
  font-family: 'Press Start 2P', monospace; font-size: 12px; color: #a0a0d0; text-transform: none; letter-spacing: 0;
  background: linear-gradient(0deg, rgba(5, 5, 16, 0.9), rgba(5, 5, 16, 0.62)); border-top: 1px solid rgba(0, 200, 255, 0.22);
}
/* one row: a hint that does not fit whole wraps onto the clipped second row, so it goes instead of
   showing cut (QA 2026-10-21: "Drag to look around" ran into Back at 960x540) */
.sb-hints { display: flex; flex-wrap: wrap; align-items: center; align-content: flex-start; gap: 12px clamp(14px, 1.8vw, 30px); height: 28px; padding: 2px 0; box-sizing: border-box; min-width: 0; overflow: hidden; }
.sb-hint { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.sb-hint:has(> .sb-g.is-empty) { display: none; }
.sb-g { display: inline-flex; align-items: center; gap: 4px; }
.sb-g.is-empty { display: none; }
.sb-k {
  display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; min-width: 24px; height: 24px; padding: 0 6px; margin: 0;
  font-family: 'Press Start 2P', monospace; font-size: 11px; line-height: 1; color: #e0e0ff; text-transform: none; letter-spacing: 0;
  background: #12122a; box-shadow: inset 0 0 0 1px #333366, 0 2px 0 #222244; border: 0; border-radius: 3px;
}
.sb-k .sb-svg { width: 11px; height: 11px; display: block; }
.sb-k.sb-pad { padding: 0 2px; background: transparent; box-shadow: none; }
.sb-k.sb-pad .sb-svg { width: 22px; height: 22px; }
.sb-k.sb-face { width: 24px; min-width: 24px; padding: 0; border-radius: 50%; color: var(--sb-face, #e0e0ff); background: #12122a; box-shadow: inset 0 0 0 2px var(--sb-face, #6c6ca0); }
body[data-pad-brand="playstation"] .sb-k.sb-face { font-family: system-ui, sans-serif; font-size: 13px; font-weight: 700; }
.sb-k.sb-sh { min-width: 34px; padding: 0 6px; border-radius: 7px 7px 3px 3px; font-size: 10px; }
.sb-ctas { margin-left: auto; display: flex; align-items: center; gap: 14px; flex: none; }
.sb-cta {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; padding: 0 20px; margin: 0; box-sizing: border-box;
  font-family: 'Press Start 2P', monospace; font-size: 13px; letter-spacing: 0.04em; text-transform: none; white-space: nowrap; width: auto; max-width: none; min-width: 0;
  color: var(--sb-accent); background: rgba(0, 200, 255, 0.06); border: 2px solid var(--sb-accent); border-radius: 0; cursor: pointer;
  transform: skewX(var(--sb-skew)); transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.sb-cta > * { transform: skewX(calc(-1 * var(--sb-skew))); }
.sb-cta:hover, .sb-cta:focus-visible, .sb-cta.pn-focus { background: var(--sb-accent); color: var(--sb-ink); box-shadow: 0 0 20px rgba(0, 200, 255, 0.4); outline: none; }
.sb-cta .sb-ico { width: 18px; height: 18px; flex: none; }
.sb-cta.sb-icon { padding: 0 14px; }
.sb-cta.sb-icon .sb-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.sb-cta.sb-primary { min-width: clamp(200px, 14vw, 260px); min-height: 48px; padding: 0 28px; font-size: clamp(13px, 0.95vw, 15px); letter-spacing: 0.1em; text-transform: uppercase; color: var(--sb-ink); background: var(--sb-accent); box-shadow: 0 0 22px rgba(0, 200, 255, 0.4); }
.sb-cta.sb-primary:hover, .sb-cta.sb-primary:focus-visible, .sb-cta.sb-primary.pn-focus { color: var(--sb-ink); background: #66e0ff; box-shadow: 0 0 0 2px #ffffff, 0 0 30px rgba(0, 200, 255, 0.6); }
.sb-cta.sb-primary.is-upgrade { background: #ffcc00; border-color: #ffcc00; box-shadow: 0 0 22px rgba(255, 204, 0, 0.45); }
.sb-cta.sb-primary.is-upgrade:hover, .sb-cta.sb-primary.is-upgrade:focus-visible, .sb-cta.sb-primary.is-upgrade.pn-focus { background: #ffe066; }
.sb-cta.sb-primary .sb-k { color: #0a0a1a; background: rgba(255, 255, 255, 0.55); box-shadow: inset 0 0 0 1px rgba(10, 10, 26, 0.5); }
.sb-cta.sb-primary .sb-k.sb-face { color: #0a0a1a; background: rgba(255, 255, 255, 0.75); box-shadow: inset 0 0 0 2px #0a0a1a; }
.sb-cta.sb-primary .sb-k.sb-pad { background: transparent; box-shadow: none; }
.sb-cta.sb-primary[aria-busy="true"] { cursor: progress; animation: gsBusy 0.9s ease-in-out infinite alternate; }
/* touch: no glyphs, no hints */
body[data-input="touch"] .sb-g, body[data-input="touch"] .sb-hints, body[data-input="touch"] .pause-hints { display: none; }

/* the square back button left of each title */
.gg-title-row { display: flex; align-items: center; gap: clamp(18px, 1.8vw, 30px); }
.gg-title-row .screen-back-btn, .opt-head .opt-up.screen-back-btn, .end-head .screen-back-btn { position: static; transform: none; flex: none; }
.opt-head .opt-up.screen-back-btn { display: flex; padding: 0; color: #8080a0; background: rgba(10, 10, 26, 0.7); border: 2px solid #555580; border-radius: 6px; }
.opt-head .opt-up.screen-back-btn svg { width: 16px; height: 16px; transform: none; }
.opt-head .opt-up.screen-back-btn:hover { border-color: #00c8ff; color: #00c8ff; }
.screen-back-btn:focus-visible, .screen-back-btn.pn-focus { outline: none; border-color: #00c8ff; color: #00c8ff; box-shadow: 0 0 14px rgba(0, 200, 255, 0.5); }

/* per screen: room for the bar */
#garageScreen { --rl-bar-h: 64px; }
#optionsScreen.opt-screen { --rl-bar-h: 64px; }
#garageScreen .sb-bar.gg-hints, #optionsScreen .sb-bar.opt-hints { height: var(--sb-h); padding: 0 var(--sb-x) env(safe-area-inset-bottom, 0px); }
.opt-hints.sb-bar .opt-version { margin-left: auto; font-family: monospace; font-size: 12px; color: #555580; }
.opt-hints.sb-bar .sb-ctas { margin-left: 0; }
.opt[data-page=""] .sb-hint.opt-hint-page { display: none; }
#mapSelectScreen { padding-bottom: calc(64px + 16px); }
#leaderboardScreen.lb-screen { padding-bottom: calc(64px + clamp(16px, 3vh, 34px)); }
#leaderboardScreen .sb-bar.lb-foot { position: absolute; min-height: 0; justify-content: flex-start; margin: 0; width: auto; }
#leaderboardScreen .sb-bar .lb-hint-ghost { display: none; }
#leaderboardScreen.lb-has-ghosts .sb-bar .lb-hint-ghost { display: inline-flex; }
#endScreen { padding-bottom: calc(64px + 1rem); }
#endScreen > .sb-bar.end-bar { position: fixed; animation: none; }
#endScreen.is-ceremony .end-bar .sb-ctas, #endScreen.is-ceremony .end-head .screen-back-btn, #endScreen.is-ceremony .end-hint-again { display: none; }
.end-head { display: flex; align-items: center; justify-content: center; gap: clamp(14px, 1.6vw, 24px); }
.end-head #endTitle { margin: 0; }
#endScreen:not(.end-solo) .end-hint-again { display: none; }
.end-key-g { margin: -0.4rem 0; }
.end-key-g .sb-k { height: 22px; min-width: 22px; font-size: 10px; }
/* the pause popup: the hints under its items */
.pause-hints { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 10px 18px; max-width: 340px; margin-top: 0.4rem; font-family: 'Press Start 2P', monospace; font-size: 11px; color: #a0a0d0; overflow: visible; }
.pause-overlay.is-confirm .pause-hints { display: none; }

/* pad or keyboard focus that a mouse click left without :focus-visible */
.pn-focus:not(:focus-visible):not(.sb-cta):not(.rl-item):not(.rl-door):not(.gt):not(.gg-tab):not(.btn-pause-action):not(.opt-btn):not(.opt-door):not(.tier-tab):not(.screen-back-btn):not(.end-buttons) {
  outline: 2px solid #00ffcc; outline-offset: 3px; box-shadow: 0 0 16px rgba(0, 255, 204, 0.45);
}
.tier-tab.pn-focus { box-shadow: inset 0 0 0 2px #ffffff, 0 0 18px rgba(0, 200, 255, 0.45); }

/* phones: no hints, the title's back button is the way out, the bar keeps the screen's primary
   action at the bottom in thumb reach */
@media (max-width: 760px) and (orientation: portrait), (orientation: landscape) and (max-height: 520px) {
  .sb-bar { --sb-x: 12px; height: auto; min-height: 0; padding: 10px calc(12px + env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) calc(12px + env(safe-area-inset-left, 0px)); background: linear-gradient(180deg, rgba(5, 5, 16, 0), rgba(5, 5, 16, 0.9) 40%); border-top: 0; pointer-events: none; }
  .sb-bar > * { pointer-events: auto; }
  /* the buttons' row spans the bar: only the buttons take taps (QA 2026-10-25: its empty part
     swallowed taps on the cards behind it) */
  .sb-bar > .sb-ctas { pointer-events: none; }
  .sb-bar > .sb-ctas > * { pointer-events: auto; }
  .sb-hints, .pause-hints { display: none; }
  .sb-bar .sb-back { display: none; }
  .sb-bar:not(:has(.sb-cta:not(.sb-back):not([style*="none"]))) { display: none; }
  .sb-ctas { flex: 1; margin-left: 0; justify-content: flex-end; }
  .sb-cta.sb-primary { min-width: 0; min-height: 50px; }
  #garageScreen .sb-bar.gg-hints, #optionsScreen .sb-bar.opt-hints { display: none; }
  .gg-title-row { gap: 12px; }
  .gg-title-row .screen-back-btn, .end-head .screen-back-btn { width: 44px; height: 44px; }
  #mapSelectScreen { padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
  .sb-bar, #leaderboardScreen .sb-bar.lb-foot { position: fixed; }
  #endScreen { padding-bottom: 1rem; }
}
@media (max-width: 760px) and (orientation: portrait) {
  .sb-cta.sb-primary { flex: 1; }
  #leaderboardScreen.lb-screen { padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
}
@media (orientation: landscape) and (max-height: 520px) {
  .sb-cta.sb-primary { width: min(280px, 36vw); }
  /* the leaderboard: Play under the track column, as before */
  #leaderboardScreen.lb-screen { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  #leaderboardScreen .sb-bar.lb-foot { left: calc(var(--rl-x) + env(safe-area-inset-left, 0px)); right: auto; width: var(--lb-col); padding: 0 0 calc(10px + env(safe-area-inset-bottom, 0px)); background: none; }
  #leaderboardScreen .sb-bar.lb-foot .sb-cta.sb-primary { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .sb-cta { transition: none; } .sb-cta.sb-primary[aria-busy="true"] { animation: none; } }
body[data-input="gamepad"] .gg-hint-drag { display: none; }
