:root {
  color-scheme: dark;
  --bg: #171816;
  --surface: rgba(31, 32, 28, 0.76);
  --text: #eee9df;
  --muted: #aaa59a;
  --border: rgba(238, 233, 223, 0.11);
  --shadow: 0 16px 38px rgba(0, 0, 0, 0.34);
  --accent: #9eaa82;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f3eee5;
  --surface: rgba(255, 251, 244, 0.72);
  --text: #292722;
  --muted: #746f66;
  --border: rgba(42, 38, 31, 0.10);
  --shadow: 0 14px 32px rgba(54, 45, 32, 0.12);
  --accent: #5d684c;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--bg);
  transition: background-color .35s ease, color .35s ease;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 0%, rgba(164, 145, 106, .10), transparent 30rem),
    radial-gradient(circle at 92% 35%, rgba(105, 120, 82, .08), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: ui-rounded, "Nunito Sans", "Avenir Next", system-ui, sans-serif;
  transition: background-color .35s ease, color .35s ease;
}

a { color: inherit; }

.site-header {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-title {
  text-decoration: none;
  font-size: clamp(1.25rem, 2vw, 1.55rem);
  font-weight: 750;
  letter-spacing: .06em;
}

.theme-toggle {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 5px 16px rgba(0,0,0,.05);
  backdrop-filter: blur(8px);
  transition: transform .2s ease, background-color .3s ease, border-color .3s ease;
}

.theme-toggle:hover { transform: rotate(8deg) scale(1.04); }
.theme-toggle:active { transform: scale(.96); }

.home {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 80px;
}

.cover-wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 42px 34px;
  align-items: start;
}

.game-tile {
  display: block;
  min-width: 0;
  text-decoration: none;
  outline: none;
  border-radius: 14px;
}

.cover-wrap {
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: 12px;
  background: #24251f;
  box-shadow: 0 8px 18px rgba(35, 31, 24, .12);
  transition: transform .28s cubic-bezier(.2,.8,.2,1),
              box-shadow .28s ease,
              filter .28s ease;
}

.cover-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.045), transparent 40%, rgba(0,0,0,.045));
  opacity: .18;
  pointer-events: none;
  transition: opacity .28s ease;
}

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

.game-tile:hover .cover-wrap,
.game-tile:focus-visible .cover-wrap {
  transform: translateY(-7px) scale(1.018);
  box-shadow: var(--shadow);
  filter: saturate(1.04);
}

.game-tile:hover .cover-wrap::after,
.game-tile:focus-visible .cover-wrap::after {
  opacity: .08;
}

.game-name {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  padding: 9px 11px;
  border-radius: 9px;
  background: rgba(18, 18, 16, .38);
  color: #fff;
  font-size: .9rem;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: .01em;
  opacity: 0;
  transform: translateY(5px);
  transition: opacity .2s ease, transform .2s ease;
  backdrop-filter: blur(3px);
}

.game-tile:hover .game-name,
.game-tile:focus-visible .game-name {
  opacity: 1;
  transform: translateY(0);
  background: rgba(18, 18, 16, .16);
}

.placeholder-cover {
  height: 100%;
  display: grid;
  place-items: end start;
  padding: 20px;
  background:
    radial-gradient(circle at 75% 18%, rgba(255,255,255,.20), transparent 22%),
    linear-gradient(145deg, #4e594b, #20251f 62%, #151713);
  color: #f4f0e8;
}

.placeholder-cover.mass {
  background:
    radial-gradient(circle at 70% 20%, rgba(228, 160, 86, .34), transparent 25%),
    linear-gradient(145deg, #28333b, #121a1f 65%, #0e1214);
}

.placeholder-cover.metro {
  background:
    radial-gradient(circle at 30% 25%, rgba(189, 141, 83, .30), transparent 24%),
    linear-gradient(145deg, #423a32, #181716 65%, #10100f);
}

.placeholder-title {
  font-family: Georgia, serif;
  font-size: 1.7rem;
  line-height: .95;
  letter-spacing: .02em;
}

.site-footer {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 0 0 28px;
  color: var(--muted);
  font-size: .82rem;
}

.game-scroll-stage {
  /* How far the reader scrolls while the artwork splits open. */
  --reveal-distance: 120svh;
  position: relative;
  isolation: isolate;
}

/* Extra scroll room at the end so the review stays still while the artwork opens,
   no matter how long the writing is. */
.game-scroll-stage::after {
  content: "";
  display: block;
  height: var(--reveal-distance);
}

.game-reveal-sticky {
  position: sticky;
  top: 0;
  width: 100%;
  height: 100svh;
  overflow: hidden;
  background: transparent;
  z-index: 2;
  pointer-events: none;
}

.game-reveal-canvas,
.game-artwork {
  position: absolute;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  display: block;
}

.game-reveal-canvas {
  width: 100%;
  opacity: 0;
}

.game-artwork {
  object-fit: cover;
  object-position: center top;
}

.game-scroll-stage--ready .game-reveal-canvas {
  opacity: 1;
}

.game-scroll-stage--ready .game-artwork {
  display: none;
}

.game-diary {
  width: min(100% - 40px, 690px);
  min-height: 100svh;
  margin: -100svh auto 0;
  padding: clamp(56px, 10vh, 118px) 0 96px;
  position: sticky;
  top: 0;
  z-index: 1;
}

.game-diary .back {
  position: relative;
  z-index: 3;
  display: inline-block;
  margin-bottom: 30px;
  color: var(--muted);
  font-size: .92rem;
  text-decoration: none;
  transition: color .2s ease, transform .2s ease;
}

.game-diary .back:hover,
.game-diary .back:focus-visible {
  color: var(--text);
  transform: translateX(-3px);
}

.game-diary h1 {
  margin: 0 0 24px;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.04;
  letter-spacing: -.035em;
}

.game-diary .entry-date {
  margin: -12px 0 24px;
  color: var(--muted);
  font-size: .88rem;
}

.game-diary .writing {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.05rem, 2.4vw, 1.18rem);
  line-height: 1.8;
}

.game-diary .writing p { margin: 0 0 1.45em; }
.game-diary .writing p:last-child { margin-bottom: 0; }

.game-diary .writing-placeholder { color: var(--muted); }

@media (max-width: 700px) {
  .site-header,
  .home,
  .site-footer { width: min(100% - 28px, 560px); }

  .site-header { padding-top: 24px; }

  .cover-wall {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 30px 18px;
  }

  .game-name {
    opacity: 1;
    transform: none;
    background: linear-gradient(transparent, rgba(18,18,16,.42));
    inset: auto 0 0;
    border-radius: 0;
    padding: 28px 11px 10px;
    backdrop-filter: none;
  }

  .game-scroll-stage { --reveal-distance: 90svh; }

  .game-artwork { object-fit: contain; }

  .game-diary {
    width: min(100% - 28px, 690px);
    padding-bottom: 70px;
  }
}

@media (max-width: 370px) {
  .cover-wall { gap: 24px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }

  .game-scroll-stage::after { display: none; }

  /* No animation: show the artwork first, then the writing below it. */
  .game-diary {
    margin-top: 0;
    min-height: 0;
    position: relative;
    padding-top: 40px;
  }

  .game-reveal-sticky {
    position: relative;
    height: auto;
  }

  .game-reveal-canvas { display: none; }

  .game-artwork {
    position: relative;
    width: 100%;
    height: auto;
    display: block;
  }
}
