/* Aesthetic direction — "midnight arcade": cool / electric / precise.
 * Quiet utility chrome around a dense catalog of archived games.
 * - Color: cool slate darks (blue undertone), electric-violet accent, and
 *   one restrained rose-red brand mark for the "re" prefix.
 *   #0b0d12 bg · #e9edf5 text · #8c7bff accent · #ff5c6c brand red.
 * - Type: Space Grotesk (UI) + Space Mono (counts, card meta).
 * - Thumbnails render at their archived size (95×73) — never upscaled.
 * - Spacing on an 8px scale (4px half-step). Radius 8px outer, 4px inner.
 * - Motion: quiet — 150ms ease, color changes only. One exception: the
 *   stage-status loading pulse, frozen under prefers-reduced-motion.
 */

:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --black: #07080b;
  --surface: #12151d;
  --surface-2: #1a1e2a;
  --line: #222837;
  --line-bright: #303850;
  --fg: #e9edf5;
  --muted: #9aa3b8;
  --faint: #818aa0;
  --accent: #8c7bff;
  --accent-bright: #ab9eff;
  --accent-ink: #0b0d12;
  --brand-red: #ff5c6c;
  --brand-red-bright: #ff8792;
  --sans: "Space Grotesk", "Segoe UI", sans-serif;
  --mono: "Space Mono", Consolas, monospace;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --text-xs: 0.75rem;   /* 12px — mono meta, counts */
  --text-sm: 0.8125rem; /* 13px — secondary UI */
  --text-md: 0.875rem;  /* 14px — controls, card titles */
  --text-base: 1rem;    /* 16px — body */
  --text-lg: 1.25rem;   /* 20px — wordmark */
  --text-xl: 1.75rem;   /* 28px — display floor */
  --text-2xl: 2.5rem;   /* 40px — display ceiling */

  --control-h: 36px;
}

* {
  box-sizing: border-box;
}

html {
  /* keep focused cards clear of the sticky toolbar */
  scroll-padding-top: 80px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

a {
  color: inherit;
  text-decoration: none;
}

.sheet {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(var(--space-5), 4vw, var(--space-7));
}

/* ---------- header ---------- */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-4);
  padding: var(--space-6) 0 0;
}

.brand {
  margin: 0;
  font-size: var(--text-lg);
  line-height: 1.2;
}

.wordmark {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  transition: color 150ms ease;
}

.wordmark-re {
  color: var(--brand-red);
  transition: color 150ms ease;
}

.wordmark:hover {
  color: var(--accent-bright);
}

.wordmark:hover .wordmark-re {
  color: var(--brand-red-bright);
}

.tagline {
  flex: 1 1 auto;
  min-width: 280px;
  margin: 0;
  font-size: var(--text-sm);
  color: var(--muted);
}

/* ---------- toolbar ---------- */

.controls {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  margin-top: var(--space-5);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--line);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.seek {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1 1 200px;
  max-width: 320px;
  height: var(--control-h);
  padding: 0 var(--space-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color 150ms ease;
}

.seek:hover {
  border-color: var(--line-bright);
}

.seek:focus-within {
  border-color: var(--accent);
}

.seek:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.seek input {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 0;
  background: none;
  font: 400 var(--text-md)/1.4 var(--sans);
  color: var(--fg);
}

.seek input:focus {
  outline: none;
}

.seek input::placeholder {
  color: var(--faint);
}

.seek-key {
  font: 400 var(--text-xs)/1.4 var(--mono);
  color: var(--faint);
  border: 1px solid var(--line-bright);
  border-radius: 4px;
  padding: 0 var(--space-1);
}

.seek:focus-within .seek-key {
  display: none;
}

@media (hover: none) {
  .seek-key {
    display: none;
  }
}

.pick {
  appearance: none;
  flex: 0 1 auto;
  max-width: 190px;
  height: var(--control-h);
  padding: 0 var(--space-6) 0 var(--space-3);
  background-color: var(--surface);
  /* chevron stroke is --faint #818aa0 — data URIs cannot read tokens */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23818aa0' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: 400 var(--text-md)/1.4 var(--sans);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease;
}

.pick.picked {
  color: var(--accent-bright);
  border-color: var(--line-bright);
}

.pick:hover {
  color: var(--fg);
  border-color: var(--line-bright);
}

.pick:focus {
  border-color: var(--accent);
}

.pick option {
  background: var(--surface);
  color: var(--fg);
}

/* runtime filter — one segmented control */

.shelves {
  display: flex;
  gap: var(--space-1);
  flex: 0 0 auto;
  margin-left: auto;
  height: var(--control-h);
  padding: var(--space-1);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.shelves button {
  appearance: none;
  border: 0;
  background: none;
  padding: 0 var(--space-3);
  border-radius: 4px;
  font: 500 var(--text-sm)/1 var(--sans);
  color: var(--muted);
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease;
}

.shelves button:hover {
  color: var(--fg);
}

.shelves button:active {
  background: var(--surface-2);
}

.shelves button.active {
  background: var(--accent);
  color: var(--accent-ink);
}

/* ---------- the catalog ---------- */

.results {
  margin: var(--space-4) 0 0;
  font: 400 var(--text-xs)/1.4 var(--mono);
  color: var(--muted);
}

.index {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: var(--space-2);
  padding: var(--space-3) 0 var(--space-7);
}

.card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  content-visibility: auto;
  contain-intrinsic-size: 250px 91px;
  transition: border-color 150ms ease, background 150ms ease;
}

.card:hover {
  border-color: var(--line-bright);
  background: var(--surface-2);
}

/* archived thumbnails are 95×73 — shown 1:1 so they stay crisp */
.thumb {
  flex: 0 0 auto;
  width: 95px;
  height: 73px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--surface-2);
}

/* honest placeholder for games with no archived thumbnail */
.thumb-empty {
  background: repeating-linear-gradient(
    45deg,
    var(--surface-2),
    var(--surface-2) 8px,
    var(--surface) 8px,
    var(--surface) 16px
  );
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.card .t {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: color 150ms ease;
}

.card:hover .t {
  color: var(--accent-bright);
}

.card .m {
  font: 400 var(--text-xs)/1.4 var(--mono);
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card.held .thumb {
  filter: grayscale(0.8);
  opacity: 0.6;
}

.card.held .t {
  color: var(--muted);
}

.card.held:hover .t {
  color: var(--accent-bright);
}

.empty {
  margin: 0;
  padding: var(--space-6) 0;
  grid-column: 1 / -1;
  font-size: var(--text-md);
  color: var(--muted);
}

/* ---------- footer ---------- */

.colophon {
  border-top: 1px solid var(--line);
  padding: var(--space-5) 0 var(--space-7);
}

.colophon p {
  max-width: 640px;
  margin: 0 0 var(--space-2);
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--faint);
}

/* ---------- player page ---------- */

.player-page .masthead {
  display: block;
  padding: var(--space-6) 0 0;
}

.player-page .mast-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-5);
}

.back {
  font-size: var(--text-md);
  color: var(--muted);
  transition: color 150ms ease;
}

.back:hover {
  color: var(--accent-bright);
}

.player-layout {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  gap: var(--space-7);
  align-items: start;
  padding: var(--space-6) 0 var(--space-7);
}

.shelf-rail {
  position: sticky;
  top: var(--space-5);
  max-height: calc(100vh - 2 * var(--space-5));
  overflow: auto;
  padding-right: var(--space-2);
  scrollbar-width: thin;
  scrollbar-color: var(--line-bright) transparent;
}

.shelf-rail input {
  width: 100%;
  height: var(--control-h);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 var(--space-3);
  font: 400 var(--text-md)/1.4 var(--sans);
  color: var(--fg);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 1;
  transition: border-color 150ms ease;
}

.shelf-rail input:hover {
  border-color: var(--line-bright);
}

.shelf-rail input:focus {
  border-color: var(--accent);
}

.shelf-rail input::placeholder {
  color: var(--faint);
}

#sideList {
  padding-top: var(--space-3);
}

#sideList a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  margin: 0 calc(-1 * var(--space-2));
  border-radius: 8px;
  transition: background 150ms ease;
}

#sideList a:hover {
  background: var(--surface);
}

/* rail thumbs at half the archived size, ratio preserved (95:73 ≈ 48:37) */
#sideList img,
#sideList .rail-blank {
  flex: 0 0 auto;
  width: 48px;
  height: 37px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--surface-2);
}

#sideList .rail-blank {
  background: repeating-linear-gradient(
    45deg,
    var(--surface-2),
    var(--surface-2) 8px,
    var(--surface) 8px,
    var(--surface) 16px
  );
}

#sideList a span {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: var(--text-md);
  font-weight: 500;
  transition: color 150ms ease;
}

#sideList a small {
  flex: 0 0 auto;
  font: 400 var(--text-xs)/1.4 var(--mono);
  color: var(--faint);
  text-transform: lowercase;
}

#sideList a:hover span {
  color: var(--accent-bright);
}

#sideList a.active {
  background: var(--surface-2);
}

#sideList a.active span {
  color: var(--accent-bright);
  font-weight: 600;
}

.exhibit-head .crumb {
  margin: 0 0 var(--space-2);
  font: 400 var(--text-xs)/1.4 var(--mono);
  color: var(--muted);
}

.exhibit-head h1 {
  margin: 0;
  font-size: clamp(var(--text-xl), 4vw, var(--text-2xl));
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.mount {
  margin: var(--space-5) 0 0;
}

.stage {
  position: relative;
  width: min(100%, max(var(--game-width, 640px), 320px));
  aspect-ratio: var(--game-aspect, 640 / 480);
  min-height: 320px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--black);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stage-status {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--space-2);
  text-align: center;
  font: 400 var(--text-xs)/1.4 var(--mono);
  color: var(--muted);
  pointer-events: none;
  animation: stage-status-pulse 1.6s ease-in-out infinite;
}

@keyframes stage-status-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.stage ruffle-player,
.stage cheerpj-applet,
.stage object,
.stage embed,
.stage canvas,
.stage iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.stage .empty {
  color: var(--muted);
  padding: var(--space-5);
}

.mount-caption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-top: var(--space-3);
  font: 400 var(--text-xs)/1.4 var(--mono);
  color: var(--faint);
}

.mount-caption a {
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: var(--line-bright);
  text-underline-offset: 3px;
  transition: color 150ms ease, text-decoration-color 150ms ease;
}

.mount-caption a:hover {
  color: var(--accent-bright);
  text-decoration-color: var(--accent);
}

.notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-6);
  max-width: 920px;
  margin-top: var(--space-6);
}

.notes h2 {
  margin: 0 0 var(--space-2);
  font: 700 var(--text-xs)/1.4 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.notes p {
  margin: 0;
  font-size: var(--text-md);
  line-height: 1.6;
  color: var(--muted);
}

/* high-score panel — spans the full notes width below description/instructions */
.notes-scores {
  grid-column: 1 / -1;
}

/* period switch — same language as the catalog .shelves segmented control */
.score-tabs {
  display: inline-flex;
  gap: var(--space-1);
  margin: 0 0 var(--space-3);
  padding: var(--space-1);
  height: var(--control-h);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.score-tabs button {
  appearance: none;
  border: 0;
  background: none;
  padding: 0 var(--space-3);
  border-radius: 4px;
  font: 500 var(--text-sm)/1 var(--sans);
  color: var(--muted);
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease;
}

.score-tabs button:hover {
  color: var(--fg);
}

.score-tabs button:active {
  background: var(--surface-2);
}

.score-tabs button.active {
  background: var(--accent);
  color: var(--accent-ink);
}

.score-table {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.score-table li {
  display: grid;
  grid-template-columns: 2.5ch minmax(0, 1fr) auto;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--line);
}

.score-table li:first-child {
  border-top: 0;
}

.score-rank {
  font: 400 var(--text-xs)/1.4 var(--mono);
  color: var(--faint);
  text-align: right;
}

.score-name {
  font-size: var(--text-md);
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-pts {
  font: 400 var(--text-md)/1.4 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--accent-bright);
}

.score-empty {
  display: block;
  padding: var(--space-3);
  font-size: var(--text-sm);
  font-style: italic;
  color: var(--faint);
}

/* classic name entry on a new high score */
.score-name-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--black) 70%, transparent);
  backdrop-filter: blur(4px);
}

.score-name-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: min(92vw, 320px);
  padding: var(--space-5);
  background: var(--surface-2);
  border: 1px solid var(--line-bright);
  border-radius: 12px;
}

.score-name-title {
  margin: 0;
  font: 700 var(--text-xs)/1.4 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.score-name-input {
  height: var(--control-h);
  padding: 0 var(--space-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: 600 var(--text-base)/1 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg);
}

.score-name-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--line-bright);
}

.score-name-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

.score-name-skip,
.score-name-go {
  height: var(--control-h);
  padding: 0 var(--space-4);
  border-radius: 8px;
  font: 500 var(--text-md)/1 var(--sans);
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}

.score-name-skip {
  border: 1px solid var(--line);
  background: none;
  color: var(--muted);
}

.score-name-skip:hover {
  color: var(--fg);
  border-color: var(--line-bright);
}

.score-name-go {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.score-name-go:hover {
  background: var(--accent-bright);
  border-color: var(--accent-bright);
}

/* held-for-recovery note on the black stage */
.stampbox {
  max-width: 440px;
  margin: var(--space-5);
  text-align: center;
}

.stampbox strong {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--accent-bright);
}

.stampbox p {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--muted);
}

/* ---------- touch play ---------- */

.stage {
  touch-action: manipulation; /* no double-tap zoom while tapping into games */
}

.touchpanel {
  position: sticky;
  bottom: var(--space-2);
  z-index: 30;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: var(--space-3);
  width: min(100%, max(var(--game-width, 640px), 320px));
  margin-top: var(--space-3);
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-dpad {
  position: relative;
  flex: 0 0 auto;
  width: 136px;
  height: 136px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 150ms ease;
}

.touch-dpad::before {
  content: "";
  position: absolute;
  inset: 42%;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.touch-dpad[data-direction]:not([data-direction=""]) {
  border-color: var(--accent);
}

.touch-dpad-mark {
  position: absolute;
  min-width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  font: 700 var(--text-sm)/1 var(--mono);
  color: var(--faint);
  transition: color 150ms ease;
}

.touch-dpad-mark[data-dir="up"] { top: 0; left: 50%; transform: translateX(-50%); }
.touch-dpad-mark[data-dir="right"] { right: 0; top: 50%; transform: translateY(-50%); }
.touch-dpad-mark[data-dir="down"] { bottom: 0; left: 50%; transform: translateX(-50%); }
.touch-dpad-mark[data-dir="left"] { left: 0; top: 50%; transform: translateY(-50%); }

.touch-dpad[data-direction~="up"] .touch-dpad-mark[data-dir="up"],
.touch-dpad[data-direction~="right"] .touch-dpad-mark[data-dir="right"],
.touch-dpad[data-direction~="down"] .touch-dpad-mark[data-dir="down"],
.touch-dpad[data-direction~="left"] .touch-dpad-mark[data-dir="left"] {
  color: var(--accent-bright);
}

.touch-axis {
  display: flex;
  flex: 1 1 auto;
  min-height: 64px;
  max-width: 480px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  overflow: hidden;
  cursor: pointer;
}

.touch-axis span {
  flex: 1;
  display: grid;
  place-items: center;
  font: 700 var(--text-sm)/1 var(--mono);
  color: var(--faint);
  transition: color 150ms ease, background 150ms ease;
}

.touch-axis span:first-child {
  border-right: 1px solid var(--line);
}

.touch-axis[data-direction="left"] span[data-dir="left"],
.touch-axis[data-direction="right"] span[data-dir="right"] {
  color: var(--accent-bright);
  background: var(--surface);
}

.touch-actions {
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

.touch-btn {
  appearance: none;
  min-width: 64px;
  min-height: 56px;
  display: grid;
  place-items: center;
  gap: var(--space-1);
  padding: var(--space-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font: 700 var(--text-xs)/1 var(--mono);
  text-transform: uppercase;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: color 150ms ease, border-color 150ms ease;
}

.touch-btn small {
  max-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 400 var(--text-xs)/1.2 var(--mono);
  text-transform: lowercase;
  color: var(--faint);
  transition: color 150ms ease;
}

.touch-btn:hover {
  border-color: var(--line-bright);
}

.touch-btn.is-pressed {
  border-color: var(--accent);
  color: var(--accent-bright);
}

.touch-btn.is-pressed small {
  color: var(--accent-bright);
}

.touch-keys {
  position: relative;
  display: flex;
  align-items: center;
}

.touch-hidden-input {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: 0;
  padding: 0;
}

.touch-disabled {
  margin: 0;
  align-self: center;
  font: 400 var(--text-sm)/1.5 var(--sans);
  color: var(--muted);
}

.touch-trackpad {
  position: absolute;
  inset: 0;
  z-index: 5;
  touch-action: none;
}

.touch-cursor {
  position: absolute;
  z-index: 6;
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent-bright);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.touch-toggle {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  font: inherit;
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: var(--line-bright);
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 150ms ease, text-decoration-color 150ms ease;
}

.touch-toggle:hover {
  color: var(--accent-bright);
  text-decoration-color: var(--accent);
}

/* Short landscape phones: split the panel into corner clusters that flank the
   width-capped stage instead of pushing it off screen. */
@media (orientation: landscape) and (max-height: 540px) {
  /* center the stage so the fixed clusters sit in the side gutters */
  .player-page .mount {
    display: grid;
    justify-items: center;
  }

  .touchpanel {
    position: static;
    width: auto;
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    pointer-events: none;
  }

  .touchpanel > * {
    pointer-events: auto;
  }

  .touch-dpad {
    position: fixed;
    left: max(var(--space-3), env(safe-area-inset-left));
    bottom: max(var(--space-3), env(safe-area-inset-bottom));
    z-index: 40;
    width: 120px;
    height: 120px;
    background: color-mix(in srgb, var(--surface-2) 78%, transparent);
  }

  .touch-axis {
    position: fixed;
    left: max(var(--space-3), env(safe-area-inset-left));
    bottom: max(var(--space-3), env(safe-area-inset-bottom));
    z-index: 40;
    width: 200px;
    background: color-mix(in srgb, var(--surface-2) 78%, transparent);
  }

  .touch-actions,
  .touch-keys {
    position: fixed;
    right: max(var(--space-3), env(safe-area-inset-right));
    bottom: max(var(--space-3), env(safe-area-inset-bottom));
    z-index: 40;
  }

  .touch-actions .touch-btn,
  .touch-keys .touch-btn {
    background: color-mix(in srgb, var(--surface-2) 78%, transparent);
  }

  .touch-keys {
    right: max(var(--space-3), env(safe-area-inset-right));
    bottom: calc(max(var(--space-3), env(safe-area-inset-bottom)) + 72px);
  }
}

/* ---------- responsive ---------- */

@media (max-width: 980px) {
  .player-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-6);
  }

  .shelf-rail {
    position: relative;
    top: auto;
    order: 2;
    max-height: 320px;
    padding-right: 0;
    border-top: 1px solid var(--line);
    padding-top: var(--space-4);
  }

  .exhibit {
    order: 1;
  }
}

@media (max-width: 680px) {
  /* the wrapped toolbar is too tall to pin over a small screen */
  .controls {
    position: static;
  }

  .seek {
    flex-basis: 100%;
    max-width: none;
  }

  .pick {
    flex: 1 1 auto;
    max-width: none;
  }

  .shelves {
    flex: 1 1 100%;
    margin-left: 0;
  }

  .shelves button {
    flex: 1;
  }

  .index {
    grid-template-columns: minmax(0, 1fr);
  }

  .notes {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
