:root {
  --night: #0c0b0a;
  --ink: #efe8dc;
  --ink-2: rgba(239, 232, 220, .72);
  --ink-3: rgba(239, 232, 220, .46);
  --line: rgba(239, 232, 220, .16);
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --gutter: clamp(20px, 3.6vw, 56px);
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; background: var(--night); }
body {
  color: var(--ink);
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: 18px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
a { color: inherit; text-decoration: none; }
ol { list-style: none; }
::selection { background: rgba(239, 232, 220, .85); color: var(--night); }
:focus-visible { outline: 1px solid var(--ink); outline-offset: 6px; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* ---------- The clearing (splat) ---------- */
/* lvh so the layer never resizes while a phone's URL bar slides in and out */
.scene {
  position: fixed;
  inset: 0 0 auto 0;
  height: 100vh;
  height: 100lvh;
  z-index: 0;
  overflow: hidden;
  isolation: isolate;
  background: var(--night);
  transform-origin: 50% 62%;
  will-change: filter, transform;
}
.splat-poster, .splat-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
/* the poster is the renderer's own opening frame, so the live canvas paints straight over it */
.splat-poster { object-fit: cover; }

/* Shade for legibility: a low horizon of dusk along the bottom, a soft vignette */
.veil {
  position: fixed;
  inset: 0 0 auto 0;
  height: 100vh;
  height: 100lvh;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(0deg, rgba(10, 9, 8, .78) 0%, rgba(10, 9, 8, .34) 26%, rgba(10, 9, 8, 0) 48%),
    radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(10, 9, 8, .5) 100%);
}

main { position: relative; z-index: 2; }

/* ---------- Arrival ---------- */
.arrival {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: var(--gutter);
  padding-bottom: calc(var(--gutter) + env(safe-area-inset-bottom));
}
.arrival-text { max-width: 36rem; will-change: transform, opacity; }

.arrival h1 {
  font-weight: 300;
  font-size: clamp(52px, 7.4vw, 124px);
  line-height: .9;
  letter-spacing: -.028em;
  margin-left: -.04em;
}
.lede {
  margin-top: 22px;
  max-width: min(21em, 27vw);
  font-size: clamp(17px, 1.3vw, 20px);
  line-height: 1.38;
  color: var(--ink-2);
}

.descend {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 17px;
  font-style: italic;
  color: var(--ink-2);
  white-space: nowrap;
  transition: color .3s;
}
.descend:hover { color: var(--ink); }
.descend svg { width: 12px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
@media (prefers-reduced-motion: no-preference) {
  .descend svg { animation: drift 2.8s var(--ease) infinite; }
}
@keyframes drift { 0%, 100% { transform: translateY(-2px); } 50% { transform: translateY(3px); } }

/* Only when the scene is stuck on its still poster */
.still-note {
  position: absolute;
  top: calc(var(--gutter) + env(safe-area-inset-top));
  right: var(--gutter);
  max-width: 19em;
  font-style: italic;
  font-size: 16px;
  line-height: 1.42;
  text-align: right;
  color: var(--ink-2);
  text-shadow: 0 1px 14px rgba(10, 9, 8, .7);
}
@media (prefers-reduced-motion: no-preference) {
  .still-note:not([hidden]) { animation: note-in 1.4s ease 1.6s both; }
}
@keyframes note-in { from { opacity: 0; } }

/* Entrance */
@media (prefers-reduced-motion: no-preference) {
  html.js .arrival-text h1,
  html.js .arrival-text .lede,
  html.js .descend { opacity: 0; transform: translateY(14px); animation: arrive 1.6s var(--ease) forwards; }
  html.js .arrival-text h1 { animation-delay: .35s; }
  html.js .arrival-text .lede { animation-delay: .75s; }
  html.js .descend { animation-delay: 1.3s; }
}
@keyframes arrive { to { opacity: 1; transform: none; } }

/* ---------- The games (landing) ---------- */
.games {
  padding: 30vh var(--gutter) 24vh;
  max-width: 1480px;
  margin: 0 auto;
}
.games h2 {
  font-weight: 300;
  font-size: clamp(40px, 4.6vw, 72px);
  line-height: 1;
  letter-spacing: -.024em;
  margin-bottom: clamp(40px, 6vw, 88px);
}

/* Two columns, the right one dropped a little lower: reads as a spread, not a grid of tiles */
.cards {
  --stagger: clamp(0px, 9vw, 150px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: clamp(28px, 4.5vw, 72px);
  row-gap: clamp(64px, 8vw, 128px);
  padding-bottom: var(--stagger);
}
.card:nth-child(even) { transform: translateY(var(--stagger)); }
.card a { display: block; }

.card-art { aspect-ratio: 4 / 3; overflow: hidden; background: rgba(239, 232, 220, .04); }
.card-art img, .g-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-art img { transition: transform 1.4s var(--ease), filter .8s; }
.card a:hover .card-art img, .card a:focus-visible .card-art img { transform: scale(1.035); }

.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; margin-top: 22px; }
.card-title { font-weight: 300; font-size: clamp(30px, 2.8vw, 44px); line-height: 1.05; letter-spacing: -.02em; }
.card-state { display: inline-flex; align-items: center; gap: 10px; font-size: 17px; color: var(--ink-3); white-space: nowrap; }
.card-summary { margin-top: 10px; max-width: 30em; font-size: 18px; line-height: 1.45; color: var(--ink-2); }
.card-meta { margin-top: 14px; font-style: italic; font-size: 16px; color: var(--ink-3); }

.is-open .card-state { color: var(--ink); }
.is-soon .card-art img { filter: saturate(.5) brightness(.7); }
.is-soon a:hover .card-art img { filter: saturate(.75) brightness(.85); }

/* shared arrow */
.card-state svg, .back svg, .join svg, .btn svg {
  width: 28px; height: 12px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round;
  transition: transform .6s var(--ease);
}
.card a:hover .card-state svg, .card a:focus-visible .card-state svg { transform: translateX(6px); }

.more {
  margin-top: clamp(64px, 8vw, 120px);
  font-style: italic;
  font-size: 17px;
  color: var(--ink-3);
}

/* ---------- A game's page ---------- */
/* Same forest, held at the landing page's fully-scrolled state, so moving between them
   only changes the words. A still poster here: no need to run the live scene twice. */
.page-game .scene { filter: blur(16px) brightness(.48); transform: scale(1.06); will-change: auto; }

.game-page {
  max-width: 1480px;
  margin: 0 auto;
  padding: calc(var(--gutter) + env(safe-area-inset-top)) var(--gutter) 20vh;
}
.back {
  display: inline-flex; align-items: center; gap: 12px;
  font-style: italic; font-size: 17px; color: var(--ink-2);
  transition: color .3s;
}
.back:hover { color: var(--ink); }
.back svg { transform: scaleX(-1); }
.back:hover svg { transform: scaleX(-1) translateX(6px); }

.g-head { margin-top: clamp(56px, 11vh, 132px); }
.g-title {
  font-weight: 300;
  font-size: clamp(56px, 9vw, 152px);
  line-height: .9;
  letter-spacing: -.03em;
  margin-left: -.04em;
}
.g-tagline { margin-top: 22px; max-width: 26em; font-size: clamp(18px, 1.5vw, 22px); line-height: 1.4; color: var(--ink-2); }

.g-cover { margin-top: clamp(36px, 5vw, 64px); aspect-ratio: 21 / 9; overflow: hidden; background: rgba(239, 232, 220, .04); }
.page-game .is-soon .g-cover img { filter: saturate(.5) brightness(.7); }

.g-body {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 4fr);
  gap: clamp(40px, 7vw, 120px);
  margin-top: clamp(48px, 6vw, 96px);
  align-items: start;
}
.g-about p { max-width: 34em; font-size: clamp(19px, 1.45vw, 22px); line-height: 1.5; }
.g-about p + p { margin-top: 1em; }

.g-facts dl { border-bottom: 1px solid var(--line); }
.g-facts dl > div { display: flex; justify-content: space-between; gap: 16px; padding: 13px 0; border-top: 1px solid var(--line); font-size: 17px; }
.g-facts dt { font-style: italic; color: var(--ink-3); }

.btn {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  width: 100%;
  margin-top: 28px;
  padding: 17px 20px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 18px;
  cursor: pointer;
  transition: background .35s, color .35s;
}
.btn:hover { background: var(--ink); color: var(--night); }
.btn:hover svg { transform: translateX(6px); }
.g-note { margin-top: 28px; font-style: italic; font-size: 17px; color: var(--ink-3); }

/* Lobbies */
.g-lobbies { margin-top: clamp(80px, 10vw, 160px); }
.g-lobbies-head { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.g-lobbies h2, .g-soon h2 { font-weight: 300; font-size: clamp(36px, 4vw, 60px); line-height: 1; letter-spacing: -.024em; }
.g-count { font-style: italic; font-size: 17px; color: var(--ink-3); }

.lobbies { border-bottom: 1px solid var(--line); }
.lobby {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr) 6.5em;
  grid-template-areas: "name host seats action";
  align-items: center;
  column-gap: 24px;
  padding: 22px 0;
  border-top: 1px solid var(--line);
}
.lobby-name { grid-area: name; font-size: clamp(22px, 2vw, 30px); font-weight: 350; letter-spacing: -.012em; line-height: 1.15; }
.lobby-host { grid-area: host; font-style: italic; font-size: 17px; color: var(--ink-3); }
.seats { grid-area: seats; display: inline-flex; align-items: center; gap: 14px; font-size: 16px; color: var(--ink-2); }
.seats span { display: inline-flex; gap: 5px; }
.seats i { width: 7px; height: 7px; border-radius: 50%; border: 1px solid var(--ink-3); }
.seats i.on { background: var(--ink); border-color: var(--ink); }
.lobby-action { grid-area: action; justify-self: end; font-size: 17px; }
.join {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 0; border: 0; background: none; color: var(--ink);
  font: inherit; cursor: pointer;
}
.join:hover svg { transform: translateX(6px); }
.lobby-busy { font-style: italic; color: var(--ink-3); }
.lobby.is-busy .lobby-name { color: var(--ink-2); }

.lobbies-empty { padding: 26px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-style: italic; font-size: 18px; color: var(--ink-2); }

.g-soon { margin-top: clamp(80px, 10vw, 160px); padding-top: 26px; border-top: 1px solid var(--line); }
.g-soon p { margin-top: 16px; max-width: 30em; font-size: 18px; color: var(--ink-2); }

.g-missing { margin-top: clamp(56px, 11vh, 132px); }
.g-missing p { margin-top: 18px; font-size: 18px; color: var(--ink-2); }

/* ---------- Moving between pages ---------- */
/* Where supported, the card's picture grows into the game page's cover, and back */
@view-transition { navigation: auto; }
.card-art img, .g-cover img { view-transition-class: cover; }
::view-transition-group(root) { animation-duration: .45s; }
::view-transition-group(*.cover) { animation-duration: .75s; animation-timing-function: cubic-bezier(.2, .7, .2, 1); }
::view-transition-old(*.cover), ::view-transition-new(*.cover) { height: 100%; object-fit: cover; overflow: clip; }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

/* ---------- Portrait screens: the desk fills the lower half, so the words move up top ---------- */
@media (max-aspect-ratio: 1/1), (max-width: 760px) {
  .veil {
    background:
      linear-gradient(180deg, rgba(10, 9, 8, .72) 0%, rgba(10, 9, 8, .3) 30%, rgba(10, 9, 8, 0) 50%),
      linear-gradient(0deg, rgba(10, 9, 8, .55) 0%, rgba(10, 9, 8, 0) 22%);
  }
  .arrival {
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    padding-top: calc(var(--gutter) + env(safe-area-inset-top) + 8px);
  }
  .arrival h1 { font-size: clamp(52px, 13vw, 112px); }
  .lede { margin-top: 16px; max-width: 19em; }
  /* the headline owns the top here, so the note sits just above "See the games" */
  .still-note {
    top: auto;
    right: auto;
    left: var(--gutter);
    bottom: calc(var(--gutter) + env(safe-area-inset-bottom) + 44px);
    max-width: 20em;
    text-align: left;
  }
}

/* ---------- Small screens ---------- */
@media (max-width: 760px) {
  .arrival h1 { font-size: clamp(52px, 15vw, 84px); }
  .lede { font-size: 17px; }
  .descend { font-size: 16px; }

  .games { padding-top: 30vh; }
  .cards { grid-template-columns: minmax(0, 1fr); row-gap: 64px; padding-bottom: 0; }
  .card:nth-child(even) { transform: none; }
  .card-head { margin-top: 18px; }
  .card-summary { font-size: 17px; }

  .g-body { grid-template-columns: minmax(0, 1fr); }
  .g-cover { aspect-ratio: 4 / 3; margin-left: calc(var(--gutter) * -1); margin-right: calc(var(--gutter) * -1); }
  .lobby {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "name action" "host host" "seats seats";
    row-gap: 8px;
    padding: 20px 0;
  }
  .lobby-host, .seats { font-size: 16px; }
}
