:root {
  color-scheme: light dark;
  --background: #f6f5f2;
  --surface: #fff;
  --text: #1d1d1b;
  --muted: #5f5d55;
  --border: #ddd8ce;
  --accent: #1e59b4;
}
@media (prefers-color-scheme: dark) {
  :root {
    --background: #161615;
    --surface: #1f1f1d;
    --text: #f0efeb;
    --muted: #b5b2a9;
    --border: #3a3934;
    --accent: #9abcff;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font: 1rem/1.5 system-ui, sans-serif;
}
main { max-width: 84rem; margin: 0 auto; padding-inline: 1.25rem; }
a { color: var(--accent); text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.directory-links { display: flex; flex-wrap: wrap; gap: .35rem 1.25rem; }
.catalog { max-width: 104rem; padding-block: clamp(1.5rem, 5vw, 4rem); }
.catalog h1 { margin: 0; font-size: clamp(2.5rem, 7vw, 4rem); line-height: 1.05; }
#count { margin: .4rem 0 1rem; color: var(--muted); font-size: .875rem; }
.table-scroll { overflow-x: auto; container-type: inline-size; }
#games {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  border: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
}
#catalog-note {
  margin: 0 0 .5rem;
  color: var(--muted);
  font-size: .875rem;
  text-align: left;
}
#games th, #games td {
  padding: .65rem clamp(.4rem, .75vw, .85rem);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  overflow-wrap: anywhere;
}
#games thead { background: var(--background); }
#games .game-name { width: 12%; }
#games .shot-column { width: 12%; }
#games .game-genre { width: 8%; }
#games .summary-column { width: 18%; }
#games .target-column { width: 18%; }
#games .test-time { width: 8%; }
#sort-time {
  padding: 0;
  min-height: 1.5rem;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  text-align: inherit;
  cursor: pointer;
}
#games tbody th { font-weight: 600; }
#games td { color: var(--muted); }
#games small { display: block; color: var(--muted); font-weight: 400; }
#games tbody tr:hover, #games tbody tr:focus-within { background: var(--background); }
#games .screenshot img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #181818;
  border: 1px solid var(--border);
  border-radius: .25rem;
}
@media (max-width: 70rem) {
  .catalog { padding-inline: .75rem; }
  #games {
    --name-width: clamp(5.25rem, 26cqi, 11rem);
    --shot-width: min(12rem, calc((100cqi - var(--name-width) - 2px) / 3));
    width: calc(var(--name-width) + 3 * var(--shot-width) + 46rem + 1px);
    font-size: .875rem;
  }
  #games th, #games td { padding: .5rem .3rem; }
  #games .game-name { width: var(--name-width); }
  #games .shot-column { width: var(--shot-width); }
  #games .game-genre { width: 7rem; }
  #games .summary-column { width: 16rem; }
  #games .target-column { width: 16rem; }
  #games .test-time { width: 7rem; }
}
@media (max-width: 25rem) {
  #games thead th { padding-inline: .2rem; font-size: clamp(.69rem, 3.1vw, .8rem); }
  #games th[scope="row"] { font-size: .8125rem; }
}
.play { padding-block: 1rem 2rem; }
.play h1 { margin: .4rem 0 .65rem; font-size: clamp(1.5rem, 4vw, 2.25rem); line-height: 1.2; }
#game:not([hidden]) {
  display: block;
  width: 100%;
  height: auto;
  margin-inline: auto;
  border: 1px solid var(--border);
  border-radius: .4rem;
  background: #000;
}
#game-stage.scaled {
  position: relative;
  width: min(100%, var(--game-width), calc(85vh * var(--game-ratio)));
  aspect-ratio: var(--game-ratio);
  margin-inline: auto;
  overflow: hidden;
  border-radius: .4rem;
  outline: 1px solid var(--border);
  background: #000;
}
#game-stage.scaled #game {
  position: absolute;
  inset: 0 auto auto 0;
  transform-origin: top left;
  border: 0;
  border-radius: 0;
}
#game.tall-frame { min-height: 50rem; }
@media (max-width: 560px), (max-height: 55rem) {
  #game.tall-frame { width: min(100%, 520px); min-height: 35rem; }
}
#details { margin-top: 1rem; }
#details p { margin: 0 0 .5rem; }

#graphics-help {
  max-width: 80rem;
  margin: .75rem auto;
}
#graphics-help figcaption { margin-bottom: .75rem; }
#preview-image {
  display: block;
  width: min(100%, 125vh);
  height: auto;
  border: 1px solid var(--border);
  border-radius: .4rem;
}
#graphics-help small { color: var(--muted); }
