/* Hub page: an arcade "select a game" screen. Plain CSS, no scripts needed (the page's CSP has style-src 'self'). */
:root {
  --bg: #1d1236;
  --bg-2: #2a1a4a;
  --card: #2f2052;
  --ink: #fbf6ff;
  --ink-soft: #cdbfe6;
  --accent: #ffd27a;
  --note: #8fe3d4;
  --bezel: #140b27;
  --gap: 12px;
  --name-size: 14px;
  --bar-h: 42px;
  --ease: 90ms ease-out;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  position: relative;
  z-index: 0;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(20px, 4vh, 40px);
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.2 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

/* A faint perspective floor grid in the bottom third. */
body::after {
  content: "";
  position: fixed;
  z-index: -1;
  left: 0;
  right: 0;
  bottom: 0;
  height: 34vh;
  background:
    linear-gradient(var(--bg) 0%, transparent 75%),
    repeating-linear-gradient(90deg, var(--bg-2) 0 2px, transparent 2px 64px),
    repeating-linear-gradient(0deg, var(--bg-2) 0 2px, transparent 2px 40px);
  transform: perspective(220px) rotateX(52deg);
  transform-origin: 50% 100%;
  pointer-events: none;
}

/* ---- Marquee ---------------------------------------------------------------------------------------------- */
.marquee {
  position: relative;
  flex: none;
  width: 100%;
  max-width: 760px;
  padding: 24px 30px;
  border: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--bg-2);
  box-shadow: 0 0 24px rgb(255 210 122 / 0.22), inset 0 0 20px rgb(255 210 122 / 0.1);
  text-align: center;
}

/* Bulbs every 18 px inside the edge: gold ones in ::before, every other one mint in ::after (offset by 18 px). */
.marquee::before,
.marquee::after {
  content: "";
  position: absolute;
  inset: 3px;
  padding: 12px 0;
  pointer-events: none;
  /* top and bottom rows, then the side columns, which stop short of the corners */
  background-origin: padding-box, padding-box, content-box, content-box;
  background-clip: padding-box, padding-box, content-box, content-box;
  background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
  background-size: 36px 12px, 36px 12px, 12px 36px, 12px 36px;
  background-position: 0 0, 0 100%, 0 0, 100% 0;
  animation: chase 0.8s steps(2) infinite;
}
.marquee::before {
  background-image:
    radial-gradient(circle at 9px 6px, var(--accent) 0 3px, transparent 4px),
    radial-gradient(circle at 9px 6px, var(--accent) 0 3px, transparent 4px),
    radial-gradient(circle at 6px 9px, var(--accent) 0 3px, transparent 4px),
    radial-gradient(circle at 6px 9px, var(--accent) 0 3px, transparent 4px);
}
.marquee::after {
  background-image:
    radial-gradient(circle at 27px 6px, var(--note) 0 3px, transparent 4px),
    radial-gradient(circle at 27px 6px, var(--note) 0 3px, transparent 4px),
    radial-gradient(circle at 6px 27px, var(--note) 0 3px, transparent 4px),
    radial-gradient(circle at 6px 27px, var(--note) 0 3px, transparent 4px);
}

.marquee__title {
  margin: 0;
  padding-left: 0.08em; /* balances the letter-spacing after the last letter */
  font-size: clamp(28px, 8vw, 56px);
  font-weight: 900;
  line-height: 1.05;
  text-wrap: balance;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  text-shadow: 0 0 2px #fff, 0 0 12px var(--accent), 0 0 28px rgb(255 210 122 / 0.5);
}

/* ---- Game tiles ------------------------------------------------------------------------------------------- */
.select {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 1080px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--gap);
}

.card {
  display: flex;
  width: calc((100% - var(--gap)) / 2);
}

.card__link {
  position: relative;
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 4px;
  border-radius: 6px;
  background: var(--bezel);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.08);
  color: var(--ink);
  text-decoration: none;
  transition: transform var(--ease), box-shadow var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.card__art {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 3px 3px 0 0;
  background: var(--bezel);
}
/* static scanlines */
.card__art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(transparent 0 2px, rgb(0 0 0 / 0.12) 2px 3px);
  pointer-events: none;
}

.card__thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.72) saturate(0.8);
  transition: filter var(--ease);
}
.card--pixel .card__thumb { image-rendering: pixelated; }

.card__bar {
  display: flex;
  align-items: center;
  gap: 7px;
  height: var(--bar-h);
  padding: 4px 10px 4px 8px;
  border-radius: 0 0 3px 3px;
  background: var(--card);
  color: var(--ink);
  font-size: var(--name-size);
  transition: background-color var(--ease), color var(--ease);
}
/* the ▶ cursor, drawn with borders; its space is kept so names never shift */
.card__bar::before {
  content: "";
  flex: none;
  width: 0;
  height: 0;
  border-left: 9px solid currentColor;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  visibility: hidden;
}

.card__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  overflow-wrap: break-word;
}

/* START: at the bar's right end when the tile is wide enough, otherwise a tag on the art's corner. */
.card__start {
  display: none;
  position: absolute;
  right: 10px;
  bottom: calc(4px + var(--bar-h) + 6px);
  padding: 2px 5px;
  border-radius: 3px;
  background: var(--accent);
  color: var(--bg);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: 0.12em;
}
@container (min-width: 250px) {
  .card__start {
    position: static;
    flex: none;
    padding: 0;
    background: none;
    color: inherit;
    font-size: 11px;
  }
}

/* ---- The selected tile: keyboard focus wins, then the hovered tile, else the first tile. One lit at a time. ---- */
:is(.card__link:focus-visible,
    .grid:not(:has(.card__link:focus-visible)) .card__link:hover,
    .grid:not(:has(.card__link:hover, .card__link:focus-visible)) > .card:first-child > .card__link) {
  z-index: 1;
  outline: none;
  transform: scale(1.06);
  box-shadow: 0 0 0 4px var(--accent), 0 0 28px 4px rgb(255 210 122 / 0.45);
}
:is(.card__link:focus-visible,
    .grid:not(:has(.card__link:focus-visible)) .card__link:hover,
    .grid:not(:has(.card__link:hover, .card__link:focus-visible)) > .card:first-child > .card__link) .card__thumb {
  filter: none;
}
:is(.card__link:focus-visible,
    .grid:not(:has(.card__link:focus-visible)) .card__link:hover,
    .grid:not(:has(.card__link:hover, .card__link:focus-visible)) > .card:first-child > .card__link) .card__bar {
  background: var(--accent);
  color: var(--bg);
}
:is(.card__link:focus-visible,
    .grid:not(:has(.card__link:focus-visible)) .card__link:hover,
    .grid:not(:has(.card__link:hover, .card__link:focus-visible)) > .card:first-child > .card__link) .card__bar::before {
  visibility: visible;
  animation: blink 1s steps(2, jump-none) infinite;
}
:is(.card__link:focus-visible,
    .grid:not(:has(.card__link:focus-visible)) .card__link:hover,
    .grid:not(:has(.card__link:hover, .card__link:focus-visible)) > .card:first-child > .card__link) .card__start {
  display: block;
  animation: blink 1s steps(2, jump-none) infinite;
}

/* ---- Not-found page --------------------------------------------------------------------------------------- */
.back {
  display: inline-block;
  padding: 14px 22px;
  border: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--bezel);
  color: var(--accent);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-decoration: none;
  text-transform: uppercase;
  transition: box-shadow var(--ease);
}
.back:hover,
.back:focus-visible {
  outline: none;
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 0 28px 4px rgb(255 210 122 / 0.45);
}

/* ---- Sizes ------------------------------------------------------------------------------------------------ */
@media (min-width: 600px) {
  :root { --gap: 16px; }
  .card { width: calc((100% - 2 * var(--gap)) / 3); }
}
@media (min-width: 1024px) {
  :root { --gap: 24px; --name-size: 16px; --bar-h: 48px; }
}
/* Only four games: two per row (at three-per-row tile size on wider screens). */
.grid:has(> .card:nth-child(4):last-child) > .card { width: calc((100% - var(--gap)) / 2); }
@media (min-width: 600px) {
  .grid:has(> .card:nth-child(4):last-child) { max-width: 712px; }
}

/* ---- Motion ----------------------------------------------------------------------------------------------- */
@keyframes blink {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes chase {
  to { background-position: 36px 0, -36px 100%, 0 -36px, 100% 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .card__link, .card__thumb, .card__bar, .back { transition: none; }
  .marquee::before, .marquee::after { animation: none; }
  :is(.card__link:focus-visible,
      .grid:not(:has(.card__link:focus-visible)) .card__link:hover,
      .grid:not(:has(.card__link:hover, .card__link:focus-visible)) > .card:first-child > .card__link) {
    transform: none;
  }
  :is(.card__link:focus-visible,
      .grid:not(:has(.card__link:focus-visible)) .card__link:hover,
      .grid:not(:has(.card__link:hover, .card__link:focus-visible)) > .card:first-child > .card__link) .card__bar::before,
  :is(.card__link:focus-visible,
      .grid:not(:has(.card__link:focus-visible)) .card__link:hover,
      .grid:not(:has(.card__link:hover, .card__link:focus-visible)) > .card:first-child > .card__link) .card__start {
    animation: none;
  }
}

@media (forced-colors: active) {
  :is(.card__link:focus-visible,
      .grid:not(:has(.card__link:focus-visible)) .card__link:hover,
      .grid:not(:has(.card__link:hover, .card__link:focus-visible)) > .card:first-child > .card__link) {
    outline: 4px solid Highlight;
    outline-offset: 2px;
  }
  /* keep the cursor a triangle (its transparent borders would otherwise be painted) */
  .card__bar::before { forced-color-adjust: none; }
  .back:hover, .back:focus-visible { outline: 4px solid Highlight; }
}
