/* The hub is one full-screen stage: the selected game's art fills the screen,
   and nothing scrolls. --accent is set per game by script.js; --px and --py
   (-1..1) follow the pointer for a little depth. */
:root {
  --bg: #07090d;
  --accent: #ffb703;
  --edge: clamp(20px, 6vw, 96px);
  --px: 0;
  --py: 0;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- The game's art ---------- */

.backdrops {
  position: absolute;
  inset: -4%;
  transform: translate3d(calc(var(--px) * -18px), calc(var(--py) * -12px), 0);
  transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1), filter 0.7s ease;
}

.backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.9s ease;
  animation: drift 28s ease-in-out infinite alternate;
}

.backdrop.is-active {
  opacity: 1;
}

@keyframes drift {
  from {
    transform: scale(1.03) translate3d(-1%, 0.5%, 0);
  }
  to {
    transform: scale(1.13) translate3d(1.5%, -1%, 0);
  }
}

.dust {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(5, 7, 11, 0.9) 0%, rgba(5, 7, 11, 0.58) 32%, rgba(5, 7, 11, 0) 64%),
    linear-gradient(0deg, rgba(5, 7, 11, 0.94) 0%, rgba(5, 7, 11, 0) 44%),
    linear-gradient(180deg, rgba(5, 7, 11, 0.62) 0%, rgba(5, 7, 11, 0) 22%);
}

/* The game's number, huge and hollow, behind everything else. */
.ghost {
  position: absolute;
  right: calc(var(--edge) * 0.6);
  bottom: -0.12em;
  font-size: clamp(170px, 34vw, 520px);
  font-weight: 900;
  line-height: 0.8;
  letter-spacing: -0.06em;
  color: transparent;
  -webkit-text-stroke: 1.5px rgba(255, 255, 255, 0.13);
  pointer-events: none;
  transform: translate3d(calc(var(--px) * 22px), calc(var(--py) * 14px), 0);
  transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ---------- Top bar ---------- */

.top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(clamp(18px, 3.4vh, 34px), env(safe-area-inset-top)) var(--edge) 0;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.34em;
  text-transform: uppercase;
}

.mark {
  width: 12px;
  height: 12px;
  background: var(--accent);
  transform: rotate(45deg);
  box-shadow: 0 0 18px var(--accent);
  transition: background 0.5s ease, box-shadow 0.5s ease;
}

.counter {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2em;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.6);
}

/* ---------- The selected game ---------- */

.info {
  position: absolute;
  left: var(--edge);
  bottom: max(clamp(40px, 11vh, 120px), env(safe-area-inset-bottom));
  width: min(680px, calc(100% - var(--edge) * 2));
  transform: translate3d(calc(var(--px) * 8px), calc(var(--py) * 5px), 0);
  transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.4s ease;
}

.stage.has-rail .info {
  bottom: calc(clamp(16px, 3vh, 32px) + clamp(68px, 7.9vw, 107px) + clamp(24px, 5vh, 48px));
}

/* Each line rises into place, one after the other, whenever a game is shown. */
.info > * {
  opacity: 0;
}

.info.is-in > * {
  animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.info.is-in > :nth-child(2) {
  animation-delay: 0.07s;
}

.info.is-in > :nth-child(3) {
  animation-delay: 0.14s;
}

.info.is-in > :nth-child(4) {
  animation-delay: 0.22s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translate3d(0, 26px, 0);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  transition: color 0.5s ease;
}

.eyebrow::before {
  content: "";
  width: 34px;
  height: 2px;
  background: currentColor;
}

.title {
  margin: clamp(10px, 1.8vh, 18px) 0 clamp(12px, 2vh, 20px);
  font-size: clamp(44px, min(8.4vw, 17vh), 124px);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.035em;
  text-wrap: balance;
  text-shadow: 0 6px 40px rgba(0, 0, 0, 0.5);
}

.tagline {
  margin: 0;
  max-width: 46ch;
  color: rgba(255, 255, 255, 0.8);
  font-size: clamp(15px, 1.5vw, 19px);
  line-height: 1.45;
}

.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 22px;
  margin-top: clamp(20px, 3.6vh, 34px);
}

.play {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 18px 40px 18px 30px;
  border-radius: 999px;
  background: var(--accent);
  color: #14110a;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-decoration: none;
  box-shadow: 0 16px 44px color-mix(in srgb, var(--accent) 42%, transparent);
  transition: transform 0.16s ease, background 0.5s ease, box-shadow 0.5s ease;
}

.play svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* A ring that keeps pulsing out of the button: this is the thing to press. */
.play::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 2px solid var(--accent);
  animation: ring 2.2s ease-out infinite;
  pointer-events: none;
}

@keyframes ring {
  from {
    transform: scale(1);
    opacity: 0.75;
  }
  to {
    transform: scale(1.22, 1.5);
    opacity: 0;
  }
}

.play:hover,
.play:focus-visible {
  transform: translateY(-2px) scale(1.04);
  outline: none;
}

.play:active {
  transform: scale(0.97);
}

.keys {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: rgba(255, 255, 255, 0.55);
  font-size: 13px;
}

.keys kbd {
  min-width: 26px;
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.85);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

/* No keyboard to hint at on a touch screen. */
@media (hover: none) {
  .keys {
    display: none;
  }
}

/* ---------- The other games ---------- */

.rail {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(clamp(16px, 3vh, 32px), env(safe-area-inset-bottom));
  display: none;
  gap: 12px;
  padding: 8px var(--edge) 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.rail::-webkit-scrollbar {
  display: none;
}

.stage.has-rail .rail {
  display: flex;
}

.tile {
  position: relative;
  flex: none;
  width: clamp(120px, 14vw, 190px);
  aspect-ratio: 16 / 9;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 12px;
  overflow: hidden;
  background: #11151e;
  color: #fff;
  font: inherit;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tile span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 8px 6px;
  background: linear-gradient(0deg, rgba(5, 7, 11, 0.92), rgba(5, 7, 11, 0));
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile:hover,
.tile:focus-visible {
  opacity: 0.85;
  outline: none;
}

.tile.is-active {
  opacity: 1;
  border-color: var(--accent);
  transform: translateY(-5px);
}

.credit {
  position: absolute;
  right: var(--edge);
  bottom: max(clamp(14px, 2.6vh, 26px), env(safe-area-inset-bottom));
  margin: 0;
  color: rgba(255, 255, 255, 0.32);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.stage.has-rail .credit {
  display: none;
}

/* ---------- Opening ---------- */

.intro {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity 0.55s ease, visibility 0.55s;
}

.intro .wordmark {
  font-size: clamp(16px, 2.6vw, 26px);
  animation: markIn 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes markIn {
  from {
    opacity: 0;
    letter-spacing: 0.9em;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    letter-spacing: 0.34em;
    transform: none;
  }
}

.intro.is-leaving {
  opacity: 0;
  visibility: hidden;
}

/* ---------- Entering a game ---------- */

.stage.is-entering .backdrops {
  transform: scale(1.35);
  filter: blur(6px) brightness(0.7);
  transition: transform 0.8s cubic-bezier(0.6, 0, 0.3, 1), filter 0.8s ease;
}

.stage.is-entering .info,
.stage.is-entering .top,
.stage.is-entering .rail,
.stage.is-entering .ghost,
.stage.is-entering .credit {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.wipe {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: #10141c;
  pointer-events: none;
  clip-path: circle(0 at var(--wx, 50%) var(--wy, 50%));
  transition: clip-path 0.65s cubic-bezier(0.7, 0, 0.3, 1);
}

.wipe.is-on {
  clip-path: circle(150vmax at var(--wx, 50%) var(--wy, 50%));
  pointer-events: auto;
}

.wipe-inner {
  width: min(360px, 76vw);
  text-align: center;
  opacity: 0;
  transform: translate3d(0, 14px, 0);
  transition: opacity 0.35s ease 0.25s, transform 0.35s ease 0.25s;
}

.wipe.is-on .wipe-inner {
  opacity: 1;
  transform: none;
}

.wipe-label {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.34em;
  text-transform: uppercase;
}

.wipe-title {
  margin: 10px 0 22px;
  font-size: clamp(28px, 6vw, 52px);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
}

.wipe-bar {
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.wipe-bar i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
}

.wipe.is-on .wipe-bar i {
  width: 100%;
  transition: width 0.9s cubic-bezier(0.3, 0.6, 0.3, 1) 0.2s;
}

/* ---------- Tall screens (a phone held upright) ---------- */

@media (max-aspect-ratio: 1/1) {
  /* The art fills the upper part only, so that its subject (in the middle of
     the picture) stands above the game's name instead of behind it. */
  .backdrops {
    inset: -4% -4% 26% -4%;
  }

  .shade {
    background:
      linear-gradient(0deg, var(--bg) 0%, var(--bg) 25%, rgba(7, 9, 13, 0.72) 40%, rgba(7, 9, 13, 0) 62%),
      linear-gradient(180deg, rgba(5, 7, 11, 0.7) 0%, rgba(5, 7, 11, 0) 20%);
  }

  .ghost {
    top: 9vh;
    bottom: auto;
    right: 4vw;
    font-size: 46vw;
  }

  .title {
    font-size: clamp(40px, 13.5vw, 84px);
  }

  .actions {
    margin-top: 24px;
  }

  .play {
    width: 100%;
    justify-content: center;
    padding: 19px 30px;
  }

  .info {
    bottom: max(64px, calc(env(safe-area-inset-bottom) + 52px));
  }

  .credit {
    left: var(--edge);
    right: auto;
  }
}

/* ---------- Less motion, where it has been asked for ---------- */

@media (prefers-reduced-motion: reduce) {
  .backdrop,
  .play::before,
  .intro .wordmark {
    animation: none;
  }

  .info.is-in > * {
    animation-duration: 0.01s;
    animation-delay: 0s;
  }

  .backdrops,
  .ghost,
  .info {
    transform: none;
  }

  .wipe {
    transition-duration: 0.01s;
  }
}
