/* Self-hosted pixel font. */
@font-face {
  font-family: "Press Start 2P";
  src: url("/assets/fonts/press-start-2p.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0a090b;
  --ink: #d8d4cc;
  --dim: #5d5862;
  --line: #1f1c22;

  /* NES bits */
  --nes-grey: #bdbab3;
  --nes-shade: #7f7c77;
  --nes-dark: #2a292b;
  --nes-red: #d82a1f;

  /* SNES bits */
  --snes-body: #cfcad9;
  --snes-shade: #8f88a8;
  --snes-purple: #4b3f8f;
  --snes-lilac: #9b93c9;
  --snes-red: #d93a3a;
  --snes-yellow: #f2c230;
  --snes-green: #3aa55a;
  --snes-blue: #3a64c8;

  --pixel: "Press Start 2P", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--pixel);
  -webkit-tap-highlight-color: transparent;
}

body.game-page {
  overflow: hidden;
  user-select: none;
}

a {
  color: inherit;
}

/* CRT scanlines and a soft vignette over the menus. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 65%, rgba(0, 0, 0, 0.45) 100%);
}

/* No CRT lines over the game while it's actually running. */
body.playing::after {
  display: none;
}

/* Small notice when a controller connects. */
.pad-toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 70;
  transform: translate(-50%, 12px);
  padding: 8px 12px;
  font-family: var(--pixel);
  font-size: 7px;
  letter-spacing: 1px;
  color: var(--nes-dark);
  background: var(--nes-grey);
  box-shadow: 3px 3px 0 var(--nes-red);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s steps(2);
}

.pad-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* ---------- System logo tiles (sized in em, set font-size to scale) ---------- */

.logo {
  position: relative;
  display: inline-block;
  flex: none;
  width: 16em;
  font-size: 8px;
  font-family: var(--pixel);
  line-height: 1;
}

.logo .face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25em;
  height: 12em;
}

.logo .label {
  font-size: 1.625em;
  letter-spacing: 0.08em;
}

/* NES: blocky grey box with pixel edges and a dark strip. */
.logo-nes {
  transform: rotate(-2deg);
}

.logo-nes .face {
  background: var(--nes-grey);
  color: var(--nes-red);
  box-shadow:
    0 -0.5em 0 0 var(--nes-grey),
    0 0.5em 0 0 var(--nes-shade),
    -0.5em 0 0 0 var(--nes-grey),
    0.5em 0 0 0 var(--nes-shade),
    0 1em 0 0 #000;
  border-bottom: 1.25em solid var(--nes-dark);
}

.logo-nes .dots {
  display: flex;
  gap: 0.625em;
}

.logo-nes .dots i {
  display: block;
  width: 1.5em;
  height: 0.625em;
  background: var(--nes-dark);
}

.logo-nes .dots i:last-child {
  width: 0.625em;
  background: var(--nes-red);
}

/* SNES: round lilac pad with four colored buttons. */
.logo-snes {
  transform: rotate(2deg);
}

.logo-snes .face {
  background: var(--snes-body);
  color: var(--snes-purple);
  border-radius: 6em;
  box-shadow: 0 0.625em 0 0 var(--snes-shade), 0 1.125em 0 0 #000;
}

.logo-snes .buttons {
  display: grid;
  grid-template-columns: repeat(3, 0.875em);
  grid-template-rows: repeat(3, 0.875em);
  transform: rotate(-20deg);
}

.logo-snes .buttons i {
  display: block;
  width: 0.875em;
  height: 0.875em;
  border-radius: 50%;
}

.logo-snes .buttons .x {
  grid-area: 1 / 2;
  background: var(--snes-blue);
}

.logo-snes .buttons .y {
  grid-area: 2 / 1;
  background: var(--snes-green);
}

.logo-snes .buttons .a {
  grid-area: 2 / 3;
  background: var(--snes-red);
}

.logo-snes .buttons .b {
  grid-area: 3 / 2;
  background: var(--snes-yellow);
}

/* Any system without its own tile. */
.logo-generic .face {
  background: var(--nes-dark);
  color: var(--ink);
  box-shadow: 0 0.625em 0 0 #000;
}

/* Taped-on note, like "soon". */
.logo .tape {
  position: absolute;
  top: -1.5em;
  right: -2.3em;
  padding: 0.8em 1em;
  font-size: 0.75em;
  letter-spacing: 0.1em;
  background: #efe3a6;
  color: #3b3526;
  transform: rotate(12deg);
  box-shadow: 1px 2px 0 rgba(0, 0, 0, 0.5);
}

/* ---------- Main page list ---------- */

.menu {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
  padding: 40px 16px;
}

.game-list {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 560px;
}

.game-list li + li {
  border-top: 2px dashed var(--line);
}

.game-row {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 22px 14px 26px 8px;
  text-decoration: none;
  outline: none;
}

.game-row .cursor {
  flex: none;
  width: 12px;
  font-size: 12px;
  color: var(--nes-red);
  visibility: hidden;
}

.game-row:hover .cursor,
.game-row:focus-visible .cursor {
  visibility: visible;
  animation: blink 0.8s steps(1) infinite;
}

.game-row:hover,
.game-row:focus-visible {
  background: rgba(255, 255, 255, 0.03);
}

.game-row .logo {
  font-size: 5px;
}

.game-row .info {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.game-row .title {
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink);
}

.game-row .meta {
  font-size: 7px;
  letter-spacing: 1px;
  color: var(--dim);
}

.game-row .meta b {
  font-weight: normal;
  color: var(--nes-red);
}

.game-row.soon .title {
  color: #8d8795;
}

.game-row.soon .meta b {
  color: var(--snes-shade);
}

.whisper {
  font-size: 7px;
  letter-spacing: 1px;
  color: var(--dim);
}

.menu-error {
  font-size: 8px;
  line-height: 2;
  color: var(--dim);
  text-align: center;
}

@media (max-width: 460px) {
  .game-row {
    gap: 16px;
  }

  .game-row .logo {
    font-size: 4px;
  }

  .game-row .title {
    font-size: 10px;
  }
}

/* ---------- Game page ---------- */

.stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.stage canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.stage.idle {
  cursor: none;
}

/* Full-screen overlays: start, paused, coming soon. */
.screen {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 16px;
  text-align: center;
}

.screen.show {
  display: flex;
}

.start-screen {
  background: var(--bg);
  cursor: pointer;
  gap: 26px;
}

.start-screen .logo {
  font-size: 7px;
  margin-bottom: 10px;
}

.start-screen h1 {
  margin: 0;
  font-size: 14px;
  font-weight: normal;
  line-height: 1.7;
  letter-spacing: 1px;
}

.start-screen .status {
  margin: 0;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--nes-red);
}

.start-screen .status.ready {
  animation: blink 1s steps(1) infinite;
}

.start-screen .status.error {
  color: var(--nes-red);
  animation: none;
  line-height: 2;
}

.start-screen .small {
  margin: 0;
  font-size: 7px;
  letter-spacing: 1px;
  color: var(--dim);
}

.paused-screen {
  background: rgba(0, 0, 0, 0.72);
  cursor: pointer;
}

/* Controls list on the start and pause screens. */
.controls {
  display: grid;
  grid-template-columns: auto auto;
  gap: 9px 14px;
  margin-top: 8px;
  padding: 14px 18px;
  border: 2px dashed var(--line);
  font-size: 7px;
  letter-spacing: 1px;
  line-height: 1.4;
  text-align: left;
  color: var(--dim);
}

.controls:empty {
  display: none;
}

.controls .controls-title {
  grid-column: 1 / -1;
  margin-bottom: 4px;
  text-align: center;
  color: var(--ink);
}

.controls .k {
  text-align: right;
  color: var(--nes-red);
}

.paused-screen .controls {
  background: rgba(10, 9, 11, 0.85);
  border-color: #2e2a33;
}

/* Short screens: let screens scroll and drop the logo so the controls fit.
   Spacers above and below centre the content without clipping its top when it overflows. */
.screen {
  overflow-y: auto;
  justify-content: flex-start;
}

.screen::before,
.screen::after {
  content: "";
  margin: auto 0;
}

@media (max-height: 560px) {
  .start-screen .logo {
    display: none;
  }

  .start-screen {
    gap: 16px;
  }
}

.paused-screen .big {
  font-size: 22px;
  letter-spacing: 3px;
  color: var(--nes-grey);
  text-shadow: 3px 3px 0 var(--nes-red);
}

.paused-screen .small {
  font-size: 8px;
  letter-spacing: 1px;
  color: var(--dim);
  animation: blink 1s steps(1) infinite;
}

.soon-screen {
  background: var(--bg);
  gap: 20px;
}

.soon-screen .dots {
  display: flex;
  gap: 8px;
}

.soon-screen .dots i {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: bob 1.2s steps(3) infinite;
}

.soon-screen .dots i:nth-child(1) {
  background: var(--snes-red);
}

.soon-screen .dots i:nth-child(2) {
  background: var(--snes-yellow);
  animation-delay: 0.15s;
}

.soon-screen .dots i:nth-child(3) {
  background: var(--snes-blue);
  animation-delay: 0.3s;
}

.soon-screen .dots i:nth-child(4) {
  background: var(--snes-green);
  animation-delay: 0.45s;
}

@keyframes bob {
  50% {
    transform: translateY(-6px);
  }
}

.soon-screen h1 {
  margin: 0;
  font-size: 12px;
  font-weight: normal;
  letter-spacing: 2px;
  color: var(--snes-body);
}

.soon-screen h1::after {
  content: "_";
  animation: blink 1s steps(1) infinite;
}

.soon-screen p {
  margin: 0;
  font-size: 7px;
  line-height: 2;
  color: var(--dim);
}

/* Pop-up back button, styled per system. */
.back {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  z-index: 60;
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 1px;
  padding: 7px 9px;
  text-decoration: none;
  background: var(--nes-grey);
  color: var(--nes-dark);
  box-shadow: 3px 3px 0 var(--nes-red);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s steps(2);
}

.back.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.back.sys-snes {
  background: var(--snes-body);
  color: var(--snes-purple);
  border-radius: 20px;
  box-shadow: 0 3px 0 var(--snes-shade);
}

/* Controls hint that fades after a game starts. */
.hint {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 60;
  font-size: 7px;
  line-height: 2;
  letter-spacing: 1px;
  text-align: right;
  opacity: 0;
  transition: opacity 0.6s;
  pointer-events: none;
  text-shadow: 1px 1px 0 #000;
}

.hint.show {
  opacity: 0.8;
}

.hint b {
  color: var(--nes-red);
  font-weight: normal;
}

/* ---------- Touch controls ---------- */

body.game-page {
  touch-action: manipulation;
  -webkit-touch-callout: none;
}

/* A see-through layer over the game. Buttons are faded and light up when pressed. */
.touch-pad {
  --dpad: min(40vmin, 176px);
  --fb: min(17vmin, 74px);
  --rest: 0.45;
  --press: 0.9;
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

body.touch.playing .touch-pad {
  display: block;
}

.touch-pad [data-group] {
  position: absolute;
  pointer-events: auto;
  touch-action: none;
}

/* D-pad: cross from a 3x3 grid. */
.tp-dpad {
  width: var(--dpad);
  height: var(--dpad);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

.tp-dpad .arm {
  background: #3a383e;
  opacity: var(--rest);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.6);
  transition: opacity 0.08s;
}

.tp-dpad .arm.up {
  border-radius: 6px 6px 0 0;
}

.tp-dpad .arm.down {
  border-radius: 0 0 6px 6px;
}

.tp-dpad .arm.left {
  border-radius: 6px 0 0 6px;
}

.tp-dpad .arm.right {
  border-radius: 0 6px 6px 0;
}

.tp-dpad .arm.on {
  opacity: var(--press);
  background: #58555e;
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.6);
}

/* Face buttons: red and round, like the NES pad. */
.tp-face .fb {
  position: absolute;
  width: var(--fb);
  height: var(--fb);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--pixel);
  font-size: calc(var(--fb) * 0.2);
  color: rgba(255, 255, 255, 0.9);
  background: var(--nes-red);
  opacity: var(--rest);
  box-shadow: 0 5px 0 #7a150f;
  transition: opacity 0.08s;
}

.tp-face .fb.on {
  opacity: var(--press);
  transform: translateY(4px);
  box-shadow: 0 1px 0 #7a150f;
}

.tp-face.two {
  width: calc(var(--fb) * 2.35);
  height: calc(var(--fb) * 1.5);
}

.tp-face.two .b {
  left: 0;
  bottom: 0;
}

.tp-face.two .a {
  right: 0;
  top: 0;
}

.tp-face.four {
  width: calc(var(--fb) * 2.6);
  height: calc(var(--fb) * 2.6);
}

.tp-face.four .x {
  left: calc(50% - var(--fb) / 2);
  top: 0;
}

.tp-face.four .y {
  left: 0;
  top: calc(50% - var(--fb) / 2);
}

.tp-face.four .a {
  right: 0;
  top: calc(50% - var(--fb) / 2);
}

.tp-face.four .b {
  left: calc(50% - var(--fb) / 2);
  bottom: 0;
}

/* SNES-style colors for four-button systems. */
.sys-snes .tp-face .x {
  background: var(--snes-blue);
}

.sys-snes .tp-face .y {
  background: var(--snes-green);
}

.sys-snes .tp-face .a {
  background: var(--snes-red);
}

.sys-snes .tp-face .b {
  background: var(--snes-yellow);
}

.sys-snes .tp-face .fb {
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.55);
}

.sys-snes .tp-face .fb.on {
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.55);
}

/* Select, start, pause and shoulders: small grey pills. */
.tp-single {
  min-width: 64px;
  padding: 9px 12px;
  border-radius: 999px;
  font-family: var(--pixel);
  font-size: 7px;
  letter-spacing: 1px;
  text-align: center;
  color: var(--nes-dark);
  background: var(--nes-grey);
  opacity: var(--rest);
  box-shadow: 0 3px 0 var(--nes-shade);
  transition: opacity 0.08s;
}

.tp-single.on {
  opacity: var(--press);
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--nes-shade);
}

.tp-single.pause {
  min-width: 0;
  right: max(14px, env(safe-area-inset-right));
  top: max(14px, env(safe-area-inset-top));
}

/* Portrait: game stays centered, controls along the bottom. */
@media (orientation: portrait) {
  .tp-dpad {
    left: max(18px, env(safe-area-inset-left));
    bottom: calc(max(16px, env(safe-area-inset-bottom)) + 52px);
  }

  .tp-face {
    right: max(18px, env(safe-area-inset-right));
    bottom: calc(max(16px, env(safe-area-inset-bottom)) + 52px);
  }

  .tp-single.select {
    left: calc(50% - 74px);
    bottom: max(16px, env(safe-area-inset-bottom));
  }

  .tp-single.start {
    left: calc(50% + 10px);
    bottom: max(16px, env(safe-area-inset-bottom));
  }

  .tp-single.l {
    left: max(18px, env(safe-area-inset-left));
    bottom: calc(max(16px, env(safe-area-inset-bottom)) + 68px + var(--dpad));
  }

  .tp-single.r {
    right: max(18px, env(safe-area-inset-right));
    bottom: calc(max(16px, env(safe-area-inset-bottom)) + 68px + var(--fb) * 2.6);
  }
}

/* Landscape: controls in the dark space either side of the picture. */
@media (orientation: landscape) {
  .tp-dpad {
    left: max(20px, env(safe-area-inset-left));
    bottom: max(20px, env(safe-area-inset-bottom));
  }

  .tp-face {
    right: max(24px, env(safe-area-inset-right));
    bottom: max(24px, env(safe-area-inset-bottom));
  }

  .tp-single.select {
    left: max(20px, env(safe-area-inset-left));
    bottom: calc(var(--dpad) + 40px);
  }

  .tp-single.start {
    right: max(24px, env(safe-area-inset-right));
    bottom: calc(var(--fb) * 1.5 + 44px);
  }

  .tp-face.four ~ .tp-single.start {
    bottom: calc(var(--fb) * 2.6 + 44px);
  }

  .tp-single.l {
    left: max(20px, env(safe-area-inset-left));
    top: calc(max(14px, env(safe-area-inset-top)) + 52px);
  }

  .tp-single.r {
    right: max(90px, env(safe-area-inset-right));
    top: max(14px, env(safe-area-inset-top));
  }
}

/* ---------- Pixel icons ---------- */

.px-icon {
  display: block;
  width: 1em;
  height: 1em;
  fill: currentColor;
}

/* ---------- Menu: soundtrack buttons beside each game ---------- */

.game-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.game-item .game-row {
  flex: 1;
  min-width: 0;
}

.st-btn {
  flex: none;
  position: relative;
  width: 58px;
  height: 58px;
  margin-right: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  outline: none;
  font-size: 18px;
  transition: transform 0.12s steps(2);
}

.st-btn .st-label {
  font-size: 6px;
  letter-spacing: 1px;
}

.st-btn:hover,
.st-btn:focus-visible {
  transform: translateY(-3px);
}

.st-btn:focus-visible {
  outline: 2px dashed var(--ink);
  outline-offset: 5px;
}

.st-btn:active {
  transform: translateY(2px);
}

/* NES: grey block with a dark strip, like the console. */
.st-nes {
  color: var(--nes-red);
  background: var(--nes-grey);
  border-bottom: 8px solid var(--nes-dark);
  box-shadow: 3px 3px 0 #000;
}

.st-nes .st-label {
  color: var(--nes-dark);
}

/* SNES: rounded lilac pad with purple ink. */
.st-snes {
  color: var(--snes-purple);
  background: var(--snes-body);
  border-radius: 14px;
  box-shadow: 0 4px 0 var(--snes-shade), 0 7px 0 #000;
}

/* Anything else. */
.st-btn:not(.st-nes):not(.st-snes) {
  color: var(--ink);
  background: var(--nes-dark);
  box-shadow: 3px 3px 0 #000;
}

@media (max-width: 460px) {
  .st-btn {
    width: 48px;
    height: 48px;
    font-size: 15px;
    margin-right: 4px;
  }

  .game-item {
    gap: 4px;
  }
}

/* ---------- Soundtrack player page ---------- */

.ost-page {
  min-height: 100%;
}

.ost {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 34px;
  padding: 70px 16px 40px;
}

/* The deck: a piece of hardware in the game's console style. */
.deck {
  position: relative;
  width: 100%;
  max-width: 440px;
  padding: 18px 20px 0;
  user-select: none;
  -webkit-user-select: none;
}

.deck-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}

.deck-top .brand {
  font-size: 9px;
  letter-spacing: 2px;
}

.deck-top .sysname {
  font-size: 12px;
  letter-spacing: 2px;
}

/* Screen: dark glass with pixel text. */
.lcd {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 14px 12px;
  background: #0c0b0e;
  color: var(--ink);
  box-shadow: inset 0 0 0 3px #000, inset 0 0 22px rgba(0, 0, 0, 0.9);
  overflow: hidden;
}

.lcd::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.25) 0 1px, transparent 1px 3px);
}

.lcd-row {
  display: flex;
  justify-content: space-between;
  font-size: 7px;
  letter-spacing: 1px;
  color: var(--dim);
}

.lcd .counter,
.lcd .loop-ind {
  color: var(--nes-red);
}

.marquee {
  overflow: hidden;
  white-space: nowrap;
}

.track-title {
  display: inline-block;
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 1px;
}

.marquee.scroll .track-title {
  animation: marquee 9s steps(60) infinite alternate;
}

@keyframes marquee {
  0%,
  15% {
    transform: translateX(0);
  }

  85%,
  100% {
    transform: translateX(var(--shift, 0));
  }
}

.game-name {
  font-size: 7px;
  letter-spacing: 1px;
  color: var(--dim);
}

/* Level bars built from stacked blocks. */
.viz {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 44px;
  margin-top: 2px;
}

.viz .bar {
  flex: 1;
  height: 0;
  background: repeating-linear-gradient(0deg, var(--nes-red) 0 4px, transparent 4px 5.5px);
  transition: height 0.07s steps(1);
}

.progress {
  position: relative;
  height: 10px;
  background: #1c1b1e;
  box-shadow: inset 0 0 0 2px #000;
  cursor: pointer;
  touch-action: none;
}

.progress .fill {
  position: absolute;
  left: 2px;
  top: 2px;
  bottom: 2px;
  width: 0;
  max-width: calc(100% - 4px);
  background: repeating-linear-gradient(90deg, var(--ink) 0 4px, transparent 4px 6px);
}

.lcd .times {
  color: var(--ink);
}

.lcd-flash {
  position: absolute;
  right: 12px;
  top: 30px;
  z-index: 2;
  padding: 6px 8px;
  font-size: 8px;
  letter-spacing: 1px;
  color: #000;
  background: var(--ink);
  opacity: 0;
  transition: opacity 0.15s steps(2);
}

.lcd-flash.show {
  opacity: 1;
}

/* Buttons: d-pad style arrows and a big round play button. */
.deck-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 22px 0 14px;
}

.deck button {
  font-family: var(--pixel);
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.deck button:focus-visible {
  outline: 2px dashed var(--ink);
  outline-offset: 4px;
}

.deck .arrow {
  width: 62px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #6c6875;
  background: #1c1b1e;
  box-shadow: inset 0 -4px 0 #000;
}

.deck .arrow.prev {
  border-radius: 6px 0 0 6px;
}

.deck .arrow.next {
  border-radius: 0 6px 6px 0;
}

.deck .arrow:active {
  background: #3a383e;
  box-shadow: inset 0 3px 0 #000;
}

.deck .play-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: rgba(255, 255, 255, 0.92);
  background: var(--nes-red);
  box-shadow: 0 6px 0 #7a150f, 0 0 0 5px #1c1b1e;
}

.deck .play-btn:active {
  transform: translateY(5px);
  box-shadow: 0 1px 0 #7a150f, 0 0 0 5px #1c1b1e;
}

.deck-pills {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding-bottom: 20px;
}

.deck .pill {
  min-width: 70px;
  padding: 9px 12px;
  border-radius: 999px;
  font-size: 7px;
  letter-spacing: 1px;
  color: var(--nes-dark);
  background: #8f8c86;
  box-shadow: 0 3px 0 #5e5c58;
}

.deck .pill.on {
  background: var(--nes-grey);
  color: var(--nes-red);
}

.deck .pill:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #5e5c58;
}

.deck-foot {
  height: 26px;
  margin: 0 -20px;
}

/* NES deck: grey top, dark ridged base, red lettering. */
.deck.sys-nes {
  background: var(--nes-grey);
  color: var(--nes-red);
  box-shadow: 0 8px 0 var(--nes-shade), 0 18px 34px rgba(0, 0, 0, 0.6);
}

.deck.sys-nes .deck-top .brand {
  color: var(--nes-dark);
}

.deck.sys-nes .deck-foot {
  background: repeating-linear-gradient(0deg, #1b1b1c 0 3px, #3a3a3c 3px 6px);
}

/* SNES deck: rounded lilac body, purple lettering, colored buttons. */
.deck.sys-snes {
  background: var(--snes-body);
  color: var(--snes-purple);
  border-radius: 28px 28px 34px 34px;
  box-shadow: inset 0 -8px 0 var(--snes-shade), 0 16px 34px rgba(60, 50, 110, 0.35);
}

.deck.sys-snes .deck-top .brand {
  color: #6c6875;
}

.deck.sys-snes .lcd {
  border-radius: 8px;
}

.deck.sys-snes .lcd .counter,
.deck.sys-snes .lcd .loop-ind {
  color: var(--snes-lilac);
}

.deck.sys-snes .viz .bar {
  background: repeating-linear-gradient(0deg, var(--snes-lilac) 0 4px, transparent 4px 5.5px);
}

.deck.sys-snes .play-btn {
  background: var(--snes-green);
  box-shadow: 0 6px 0 #1f6a37, 0 0 0 5px var(--snes-lilac);
}

.deck.sys-snes .play-btn:active {
  box-shadow: 0 1px 0 #1f6a37, 0 0 0 5px var(--snes-lilac);
}

.deck.sys-snes .arrow {
  background: #3b3a40;
  color: #8a8792;
}

.deck.sys-snes .pill {
  background: #6c6875;
  color: var(--snes-body);
  box-shadow: 0 3px 0 #4a4751;
}

.deck.sys-snes .pill.on {
  background: var(--snes-purple);
}

.deck.sys-snes .deck-foot {
  height: 18px;
}

/* Track list. */
.ost-side {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.list-title {
  margin: 0;
  font-size: 12px;
  font-weight: normal;
  line-height: 1.6;
  letter-spacing: 1px;
}

.list-sub {
  margin: 0;
  font-size: 7px;
  line-height: 1.9;
  letter-spacing: 1px;
  color: var(--dim);
}

.tracklist {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tracklist li + li {
  border-top: 2px dashed var(--line);
}

.tracklist .track {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 8px;
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 1px;
  text-align: left;
  color: var(--ink);
  background: none;
  border: none;
  cursor: pointer;
}

.tracklist .track:hover,
.tracklist .track:focus-visible {
  background: rgba(255, 255, 255, 0.03);
  outline: none;
}

.tracklist .num {
  color: var(--dim);
}

.tracklist .name {
  flex: 1;
  line-height: 1.6;
}

.tracklist .dur {
  color: var(--dim);
}

.tracklist .track.current .num,
.tracklist .track.current .name {
  color: var(--nes-red);
}

.sys-snes ~ .ost-side .tracklist .track.current .num,
.sys-snes ~ .ost-side .tracklist .track.current .name {
  color: var(--snes-lilac);
}

.ost-side .controls {
  align-self: flex-start;
}

/* Album header: cover art beside the title, framed like a cartridge label. */
.album-head {
  display: flex;
  align-items: center;
  gap: 18px;
}

.album-cover {
  flex: none;
  width: 140px;
  height: 140px;
  object-fit: cover;
  border: 4px solid var(--nes-grey);
  box-shadow: 4px 4px 0 var(--nes-red), 8px 8px 0 #000;
}

.sys-snes ~ .ost-side .album-cover {
  border-color: var(--snes-body);
  border-radius: 8px;
  box-shadow: 0 5px 0 var(--snes-shade), 0 9px 0 #000;
}

.album-text {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.album-game {
  font-size: 7px;
  letter-spacing: 1px;
  color: var(--nes-red);
}

.sys-snes ~ .ost-side .album-game {
  color: var(--snes-lilac);
}

.album-credits {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 14px;
  border-top: 2px dashed var(--line);
}

.album-credits .credits-title {
  font-size: 7px;
  letter-spacing: 1px;
  color: var(--ink);
}

.album-credits p {
  margin: 0;
  font-size: 6px;
  line-height: 1.9;
  letter-spacing: 0.5px;
  color: var(--dim);
}

@media (max-width: 400px) {
  .album-cover {
    width: 104px;
    height: 104px;
  }
}

/* Wide screens: deck and list side by side, the deck stays in view while a long list scrolls. */
@media (min-width: 900px) {
  .ost {
    flex-direction: row;
    align-items: flex-start;
    gap: 56px;
  }

  .ost .deck {
    position: sticky;
    top: 70px;
  }

  .ost-side {
    max-width: 380px;
  }
}

@media (max-width: 400px) {
  .deck {
    padding: 14px 14px 0;
  }

  .deck-foot {
    margin: 0 -14px;
  }

  .deck-controls {
    gap: 16px;
  }

  .deck .arrow {
    width: 54px;
  }

  .deck .play-btn {
    width: 68px;
    height: 68px;
  }
}

/* ---------- Guide reader ---------- */

body.reader-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* No CRT lines over the pages, so small print stays readable. */
body.reader-page::after {
  display: none;
}

.rd-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px max(14px, env(safe-area-inset-left)) 10px max(14px, env(safe-area-inset-right));
  font-size: 8px;
  letter-spacing: 1px;
  background: var(--nes-grey);
  color: var(--nes-dark);
  z-index: 2;
}

.rd-top {
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 6px solid var(--nes-dark);
}

.rd-foot {
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  border-top: 6px solid var(--nes-dark);
}

.rd-foot[hidden] {
  display: none;
}

.rd-bar button {
  font-family: var(--pixel);
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.rd-bar button:focus-visible {
  outline: 2px dashed var(--nes-dark);
  outline-offset: 3px;
}

.rd-back {
  flex: none;
  padding: 8px 10px;
  font-size: 8px;
  letter-spacing: 1px;
  color: var(--nes-grey);
  background: var(--nes-dark);
  box-shadow: 3px 3px 0 var(--nes-red);
}

.rd-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: center;
  font-size: 9px;
  color: var(--nes-red);
}

.rd-count {
  flex: none;
  min-width: 90px;
  text-align: right;
}

.rd-arrow {
  flex: none;
  width: 52px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #6c6875;
  background: #1c1b1e;
  box-shadow: inset 0 -4px 0 #000;
  border-radius: 6px;
}

.rd-arrow:active {
  box-shadow: inset 0 3px 0 #000;
}

.rd-arrow:disabled {
  opacity: 0.35;
  cursor: default;
}

.rd-pill {
  flex: none;
  min-width: 58px;
  padding: 9px 10px;
  border-radius: 999px;
  font-size: 7px;
  letter-spacing: 1px;
  color: var(--nes-grey);
  background: var(--nes-red);
  box-shadow: 0 3px 0 #7a150f;
}

.rd-pill.on {
  background: var(--nes-dark);
  box-shadow: 0 3px 0 #000;
}

/* Page track: drag or tap to jump. */
.rd-track {
  position: relative;
  flex: 1;
  height: 12px;
  background: #1c1b1e;
  box-shadow: inset 0 0 0 2px #000;
  cursor: pointer;
  touch-action: none;
}

.rd-fill {
  position: absolute;
  left: 2px;
  top: 2px;
  bottom: 2px;
  max-width: calc(100% - 4px);
  background: repeating-linear-gradient(90deg, var(--nes-red) 0 4px, transparent 4px 6px);
}

.rd-thumb {
  position: absolute;
  top: -5px;
  width: 10px;
  height: 22px;
  margin-left: -5px;
  background: var(--nes-dark);
  box-shadow: 0 0 0 2px var(--nes-grey);
}

/* The stage: pages centred on a dark desk. */
.rd-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #121114;
  touch-action: pan-y;
}

.rd-stage.zoomed {
  overflow: auto;
  align-items: flex-start;
  justify-content: flex-start;
  touch-action: auto;
}

.rd-spread {
  margin: auto;
  padding: 12px;
}

.rd-pages {
  display: flex;
  gap: 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
}

.rd-page {
  display: block;
  background: #fff;
}

/* A thin gutter shadow down the middle of a two-page spread. */
.rd-pages .rd-page + .rd-page {
  box-shadow: inset 12px 0 16px -12px rgba(0, 0, 0, 0.45);
}

.rd-spread.turn-next {
  animation: turn-next 0.18s steps(4);
}

.rd-spread.turn-prev {
  animation: turn-prev 0.18s steps(4);
}

@keyframes turn-next {
  from {
    transform: translateX(40px);
    opacity: 0.3;
  }
}

@keyframes turn-prev {
  from {
    transform: translateX(-40px);
    opacity: 0.3;
  }
}

.rd-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  font-size: 9px;
  line-height: 2;
  letter-spacing: 1px;
  color: var(--dim);
  animation: blink 1s steps(1) infinite;
}

.rd-msg.error {
  color: var(--nes-red);
  animation: none;
}

.rd-msg[hidden] {
  display: none;
}

/* Short tip over the pages, like "turn sideways". */
.rd-tip {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 3;
  padding: 9px 12px;
  font-size: 7px;
  letter-spacing: 1px;
  white-space: nowrap;
  color: var(--nes-dark);
  background: var(--nes-grey);
  box-shadow: 3px 3px 0 var(--nes-red);
  opacity: 0;
  transition: opacity 0.3s steps(3);
  pointer-events: none;
}

.rd-tip.show {
  opacity: 1;
}

.rd-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.rd-html .rd-stage {
  align-items: stretch;
}

.rd-html .rd-count {
  display: none;
}

/* SNES look for SNES games. */
.reader-page.sys-snes .rd-bar {
  background: var(--snes-body);
  color: var(--snes-purple);
}

.reader-page.sys-snes .rd-top,
.reader-page.sys-snes .rd-foot {
  border-color: var(--snes-shade);
}

.reader-page.sys-snes .rd-back {
  color: var(--snes-body);
  background: var(--snes-purple);
  border-radius: 20px;
  box-shadow: 0 3px 0 var(--snes-shade);
}

.reader-page.sys-snes .rd-title {
  color: var(--snes-purple);
}

.reader-page.sys-snes .rd-pill {
  background: var(--snes-green);
  box-shadow: 0 3px 0 #1f6a37;
}

.reader-page.sys-snes .rd-pill.on {
  background: var(--snes-purple);
  box-shadow: 0 3px 0 #2d2560;
}

.reader-page.sys-snes .rd-fill {
  background: repeating-linear-gradient(90deg, var(--snes-lilac) 0 4px, transparent 4px 6px);
}

.reader-page.sys-snes .rd-thumb {
  background: var(--snes-purple);
  box-shadow: 0 0 0 2px var(--snes-body);
  border-radius: 3px;
}

@media (max-width: 460px) {
  .rd-count {
    min-width: 0;
  }

  .rd-title {
    font-size: 7px;
  }

  .rd-arrow {
    width: 44px;
  }
}

/* Short screens, like a phone on its side: slimmer bars, more room for the page. */
@media (max-height: 500px) {
  .rd-bar {
    padding-top: max(5px, env(safe-area-inset-top));
    padding-bottom: max(5px, env(safe-area-inset-bottom));
    gap: 10px;
  }

  .rd-top {
    border-bottom-width: 3px;
  }

  .rd-foot {
    border-top-width: 3px;
  }

  .rd-back {
    padding: 6px 8px;
  }

  .rd-arrow {
    height: 28px;
  }

  .rd-pill {
    padding: 6px 10px;
  }

  .rd-spread {
    padding: 6px;
  }
}

/* ---------- Extras in game: buttons on the start and pause screens ---------- */

.extras {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.extras:empty {
  display: none;
}

.extra-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  font-family: var(--pixel);
  font-size: 7px;
  letter-spacing: 1px;
  border: none;
  cursor: pointer;
  color: var(--nes-dark);
  background: var(--nes-grey);
  box-shadow: 3px 3px 0 var(--nes-red);
}

.extra-btn .px-icon {
  width: 12px;
  height: 12px;
  color: var(--nes-red);
}

.extra-btn:hover,
.extra-btn:focus-visible {
  transform: translateY(-2px);
  outline: none;
}

.extra-btn:active {
  transform: translateY(1px);
}

.sys-snes .extra-btn {
  color: var(--snes-purple);
  background: var(--snes-body);
  border-radius: 20px;
  box-shadow: 0 3px 0 var(--snes-shade);
}

.sys-snes .extra-btn .px-icon {
  color: var(--snes-purple);
}

/* Guide open over the game, which stays paused underneath. */
.extra-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  background: #000;
}

.extra-overlay.show {
  display: block;
}

.extra-overlay iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---------- 404 ---------- */

.lost {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 16px;
  text-align: center;
}

.lost h1 {
  margin: 0;
  font-size: 14px;
  font-weight: normal;
  letter-spacing: 2px;
}

.lost p {
  margin: 0;
  font-size: 8px;
  color: var(--dim);
}

.lost a {
  font-size: 8px;
  color: var(--nes-red);
}

/* ---------- Steam shortcut mode (?steam) ---------- */

/* Games use Select to go back, so the pop-up back button stays hidden. */
.mode-steam .game-page .back {
  display: none;
}

/* Cursor hides while the mouse is still. */
html.hide-cursor,
html.hide-cursor * {
  cursor: none !important;
}

/* Exit item at the bottom of the menu. */
.exit-row {
  width: 100%;
  border: 0;
  background: none;
  font-family: var(--pixel);
  cursor: pointer;
  padding-top: 18px;
  padding-bottom: 18px;
}

.exit-row .title {
  font-size: 9px;
  color: var(--dim);
}

.exit-row:hover .title,
.exit-row:focus-visible .title {
  color: var(--ink);
}