:root {
  --ink: #120f17;
  --ink-raised: #1b1722;
  --ink-line: #2e2836;
  --paper: #f3ead9;
  --paper-muted: #b9ae9c;
  --paper-faint: #7d7466;
  --vermilion: #e5543d;
  --vermilion-deep: #b83a26;
  --gold: #d6b26a;
  --player: #8fb8c9;

  --font-display: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", serif;
  --font-body: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;

  --text-hero: clamp(2.6rem, 1.4rem + 5.2vw, 5.6rem);
  --text-section: clamp(1.7rem, 1.2rem + 2vw, 2.7rem);
  --text-base: clamp(0.98rem, 0.94rem + 0.2vw, 1.06rem);

  --space-page: clamp(20px, 4vw, 64px);
  --space-section: clamp(72px, 9vw, 140px);
  --radius-sm: 6px;
  --radius-lg: 18px;

  --duration-fast: 160ms;
  --duration-slow: 700ms;
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: dark; }

body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 60% 50% at 78% 8%, rgba(229, 84, 61, 0.16), transparent 70%),
    radial-gradient(ellipse 50% 40% at 6% 40%, rgba(214, 178, 106, 0.07), transparent 70%),
    var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

/* Film grain keeps the dark field from looking flat. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── Header ─────────────────────────────────────────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px var(--space-page);
  background: rgba(18, 15, 23, 0.78);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(243, 234, 217, 0.07);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--vermilion);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.05rem;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.08rem;
  letter-spacing: 0.06em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-link {
  position: relative;
  padding: 6px 12px;
  color: var(--paper-muted);
  text-decoration: none;
  font-size: 0.93rem;
  transition: color var(--duration-fast) ease;
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 2px;
  height: 1px;
  background: var(--vermilion);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--duration-fast) var(--ease-out-expo);
}

.nav-link:hover { color: var(--paper); }
.nav-link:hover::after { transform: scaleX(1); }

.nav-admin { color: var(--gold); }

.nav-divider {
  width: 1px;
  height: 18px;
  margin: 0 8px;
  background: var(--ink-line);
}

.nav-login {
  padding: 6px 16px;
  border: 1px solid rgba(243, 234, 217, 0.28);
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.9rem;
  transition: background var(--duration-fast) ease, border-color var(--duration-fast) ease;
}

.nav-login:hover {
  background: var(--paper);
  border-color: var(--paper);
  color: var(--ink);
}

.nav-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.nav-user[hidden],
.nav-login[hidden],
.nav-user-role[hidden],
.nav-admin[hidden] { display: none; }

.nav-user-name {
  color: var(--paper);
  text-decoration: none;
  border-bottom: 1px dashed transparent;
  transition: color var(--duration-fast) ease, border-color var(--duration-fast) ease;
}

.nav-user-name:hover { color: var(--gold); border-bottom-color: currentColor; }
.nav-user-name:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.nav-user-role {
  padding: 1px 8px;
  border: 1px solid rgba(214, 178, 106, 0.45);
  border-radius: 999px;
  color: var(--gold);
  font-size: 0.74rem;
}

.nav-logout {
  padding: 4px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--paper-faint);
  font: inherit;
  cursor: pointer;
  transition: color var(--duration-fast) ease;
}

.nav-logout:hover { color: var(--vermilion); }

/* ── Shared section pieces ──────────────────────────────────────────────── */

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

main > section {
  padding: 0 var(--space-page);
  max-width: 1280px;
  margin: 0 auto var(--space-section);
}

.section-head {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 20px;
  align-items: baseline;
  margin-bottom: clamp(28px, 4vw, 56px);
  max-width: 760px;
}

.section-head h2,
.designer-copy h2 {
  font-family: var(--font-display);
  font-size: var(--text-section);
  line-height: 1.25;
  letter-spacing: 0.02em;
}

.section-head > p:not(.section-index) {
  grid-column: 2;
  margin-top: 10px;
  color: var(--paper-muted);
}

.section-index {
  font-family: var(--font-display);
  color: var(--vermilion);
  font-size: 0.95rem;
  letter-spacing: 0.1em;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */

.cta-primary {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 16px 30px 16px 34px;
  border-radius: 999px;
  background: var(--vermilion);
  color: #1a0d0a;
  font-weight: 700;
  font-size: 1.12rem;
  letter-spacing: 0.08em;
  text-decoration: none;
  box-shadow: 0 14px 40px -12px rgba(229, 84, 61, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform var(--duration-fast) var(--ease-out-expo), box-shadow var(--duration-fast) ease, background var(--duration-fast) ease;
}

.cta-primary:hover {
  transform: translateY(-2px);
  background: #f0634b;
  box-shadow: 0 20px 48px -12px rgba(229, 84, 61, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.cta-primary:active {
  transform: translateY(1px);
  background: var(--vermilion-deep);
}

.cta-arrow {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(26, 13, 10, 0.16);
  transition: transform var(--duration-fast) var(--ease-out-expo);
}

.cta-primary:hover .cta-arrow { transform: translateX(4px); }

.cta-large {
  padding: 20px 38px 20px 44px;
  font-size: 1.25rem;
}

.cta-secondary,
.cta-ghost {
  color: var(--paper);
  text-decoration: none;
  border-bottom: 1px solid rgba(243, 234, 217, 0.35);
  padding-bottom: 2px;
  transition: border-color var(--duration-fast) ease, color var(--duration-fast) ease;
}

.cta-secondary:hover,
.cta-ghost:hover {
  color: var(--gold);
  border-color: var(--gold);
}

/* ── Hero ───────────────────────────────────────────────────────────────── */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: clamp(32px, 5vw, 80px);
  align-items: center;
  min-height: calc(100vh - 64px);
  padding-top: clamp(40px, 6vw, 80px) !important;
  padding-bottom: clamp(40px, 6vw, 80px) !important;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 22px;
  color: var(--gold);
  font-size: 0.82rem;
  letter-spacing: 0.32em;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: var(--text-hero);
  font-weight: 900;
  line-height: 1.12;
  letter-spacing: 0.01em;
}

.hero h1 em {
  font-style: normal;
  color: var(--vermilion);
  position: relative;
}

.hero h1 em::after {
  content: "";
  position: absolute;
  left: -2%;
  right: -2%;
  bottom: 0.08em;
  height: 0.14em;
  background: rgba(229, 84, 61, 0.28);
  z-index: -1;
}

.hero-lead {
  max-width: 34em;
  margin-top: 28px;
  color: var(--paper-muted);
  font-size: 1.06rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px 30px;
  margin-top: 40px;
}

.hero-note {
  margin-top: 18px;
  color: var(--paper-faint);
  font-size: 0.85rem;
}

/* The stage card: a fake scene that shows what playing looks like. */
.stage {
  position: relative;
  padding: 22px 22px 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(170deg, #221c2a 0%, #18141e 100%);
  border: 1px solid var(--ink-line);
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.8), 0 0 0 8px rgba(243, 234, 217, 0.025);
  transform: rotate(1.2deg);
}

.stage::before {
  content: "";
  position: absolute;
  inset: -14px 18px auto auto;
  width: 120px;
  height: 28px;
  background: rgba(214, 178, 106, 0.18);
  transform: rotate(4deg);
  border-radius: 2px;
}

.stage-chrome {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px dashed var(--ink-line);
  font-size: 0.8rem;
  color: var(--paper-faint);
}

.stage-scene { color: var(--paper); font-weight: 600; }
.stage-clock { color: var(--gold); }

.stage-lines {
  list-style: none;
  display: grid;
  gap: 12px;
}

.line {
  font-size: 0.94rem;
  line-height: 1.7;
}

.line b {
  display: block;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  margin-bottom: 2px;
}

.line-narration {
  color: var(--paper-muted);
  font-family: var(--font-display);
  font-style: italic;
  padding-left: 12px;
  border-left: 2px solid var(--ink-line);
}

.line-character {
  max-width: 88%;
  padding: 10px 14px;
  background: rgba(243, 234, 217, 0.06);
  border-radius: 4px 14px 14px 14px;
}

.line-character b { color: var(--vermilion); }

.line-player {
  justify-self: end;
  max-width: 80%;
  padding: 10px 14px;
  background: rgba(143, 184, 201, 0.12);
  border-radius: 14px 4px 14px 14px;
  text-align: right;
}

.line-player b { color: var(--player); }

.stage-director {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(214, 178, 106, 0.08);
  color: var(--gold);
  font-size: 0.8rem;
}

.director-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 0 rgba(214, 178, 106, 0.6);
  animation: pulse 2.4s ease-out infinite;
}

/* ── Genres: the kinds of story the game can tell ──────────────────────── */

.genres {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.genres > li { grid-column: span 2; display: flex; }
.genres > li:first-child { grid-column: span 4; }

.genre {
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--ink-line);
  background: var(--ink-raised);
  transition: border-color var(--duration-fast) ease, transform var(--duration-fast) var(--ease-out-expo);
}

.genre:hover {
  border-color: rgba(214, 178, 106, 0.45);
  transform: translateY(-3px);
}

.genre-art {
  display: block;
  width: 100%;
  height: 190px;
  object-fit: cover;
  border-bottom: 1px solid var(--ink-line);
  transition: transform var(--duration-slow) var(--ease-out-expo);
}

.genres > li:first-child .genre-art { height: 240px; }

.genre:hover .genre-art { transform: scale(1.04); }

.genre-body {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  padding: 22px 24px 24px;
  background: var(--ink-raised);
}

.genre-tag {
  color: var(--gold);
  font-size: 0.82rem;
  letter-spacing: 0.12em;
}

.genre h3 {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 1.1rem + 0.8vw, 1.8rem);
  line-height: 1.3;
}

.genres > li:first-child .genre h3 { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.3rem); }

.genre-hook { color: var(--paper-muted); }

.genre-line {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px dashed var(--ink-line);
  color: var(--player);
  font-size: 0.94rem;
}

.genre-line b {
  margin-right: 8px;
  color: var(--paper-faint);
  font-weight: 500;
}

/* ── Feature bento ──────────────────────────────────────────────────────── */

.bento {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.tile {
  position: relative;
  overflow: hidden;
  padding: 28px;
  border-radius: var(--radius-lg);
  background: var(--ink-raised);
  border: 1px solid var(--ink-line);
  transition: border-color var(--duration-fast) ease, transform var(--duration-fast) var(--ease-out-expo);
}

.tile:hover {
  border-color: rgba(214, 178, 106, 0.4);
  transform: translateY(-3px);
}

.tile h3 {
  font-family: var(--font-display);
  font-size: 1.32rem;
  margin-bottom: 10px;
}

.tile p { color: var(--paper-muted); font-size: 0.93rem; }

.tile-graph { grid-column: span 4; grid-row: span 2; display: flex; flex-direction: column; }
.tile-clock { grid-column: span 2; background: var(--paper); color: var(--ink); border-color: var(--paper); }
.tile-clock p { color: #5a5146; }
.tile-memory { grid-column: span 2; }
.tile-save { grid-column: span 6; display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: baseline; }
.tile-save h3 { margin: 0; }

.tile-figure {
  font-family: var(--font-display);
  font-size: 3rem !important;
  font-weight: 900;
  line-height: 1;
  color: var(--vermilion) !important;
  margin-bottom: 18px;
}

.graph-art {
  margin-top: auto;
  padding-top: 28px;
  width: 100%;
  max-width: 560px;
  height: auto;
}

.graph-art path {
  fill: none;
  stroke: var(--paper-faint);
  stroke-width: 1.5;
  stroke-dasharray: 4 5;
}

.graph-art circle {
  fill: var(--ink);
  stroke: var(--paper-muted);
  stroke-width: 2;
}

.graph-art circle.is-active {
  fill: var(--vermilion);
  stroke: var(--vermilion);
}

/* ── Designer band ──────────────────────────────────────────────────────── */

.designer-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(28px, 5vw, 72px);
  align-items: center;
  max-width: none !important;
  margin: 0 0 var(--space-section) !important;
  padding: clamp(56px, 7vw, 100px) max(var(--space-page), calc((100vw - 1280px) / 2 + var(--space-page))) !important;
  background: linear-gradient(120deg, #1f1a26 0%, #16121b 100%);
  border-top: 1px solid var(--ink-line);
  border-bottom: 1px solid var(--ink-line);
}

.designer-copy .section-index { margin-bottom: 12px; }

.designer-copy p:not(.section-index) {
  margin: 18px 0 28px;
  color: var(--paper-muted);
  max-width: 30em;
}

.designer-points {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--ink-line);
  border: 1px solid var(--ink-line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.designer-points li {
  padding: 22px;
  background: var(--ink);
  color: var(--paper-muted);
  font-size: 0.9rem;
}

.designer-points b {
  display: block;
  margin-bottom: 4px;
  color: var(--paper);
  font-size: 1.02rem;
}

/* ── Steps ──────────────────────────────────────────────────────────────── */

.steps {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.step-list {
  list-style: none;
  counter-reset: step;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px 56px;
  margin-bottom: 44px;
  color: var(--paper-muted);
  font-size: 0.93rem;
}

.step-list li { counter-increment: step; }

.step-list span {
  display: block;
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--paper);
}

.step-list span::before {
  content: counter(step) " ";
  color: var(--vermilion);
  font-size: 0.9rem;
  vertical-align: super;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */

.site-footer {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  padding: 28px var(--space-page);
  border-top: 1px solid var(--ink-line);
  color: var(--paper-faint);
  font-size: 0.82rem;
}

/* ── Motion ─────────────────────────────────────────────────────────────── */

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(214, 178, 106, 0.55); }
  70% { box-shadow: 0 0 0 10px rgba(214, 178, 106, 0); }
  100% { box-shadow: 0 0 0 0 rgba(214, 178, 106, 0); }
}

.hero-copy > *,
.stage .line,
.stage-director {
  animation: rise var(--duration-slow) var(--ease-out-expo) both;
}

.hero-copy > :nth-child(2) { animation-delay: 80ms; }
.hero-copy > :nth-child(3) { animation-delay: 160ms; }
.hero-copy > :nth-child(4) { animation-delay: 240ms; }
.hero-copy > :nth-child(5) { animation-delay: 300ms; }
.stage .line:nth-child(1) { animation-delay: 300ms; }
.stage .line:nth-child(2) { animation-delay: 650ms; }
.stage .line:nth-child(3) { animation-delay: 1000ms; }
.stage .line:nth-child(4) { animation-delay: 1350ms; }
.stage-director { animation-delay: 1750ms; }

@media (prefers-reduced-motion: reduce) {
  .genre:hover, .genre:hover .genre-art { transform: none; }

  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 960px) {
  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .stage { transform: none; max-width: 560px; }

  .genres { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .genres > li, .genres > li:first-child { grid-column: span 1; }
  .genres > li:first-child { grid-column: 1 / -1; }

  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-graph { grid-column: span 2; grid-row: auto; }
  .tile-clock, .tile-memory { grid-column: span 1; }
  .tile-save { grid-column: span 2; grid-template-columns: 1fr; gap: 8px; }

  .designer-band { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .site-header { flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
  .site-nav { width: 100%; justify-content: flex-start; margin-left: -12px; }
  .nav-divider { display: none; }
  .nav-login, .nav-user { margin-left: auto; }

  .section-head { grid-template-columns: 1fr; }
  .section-head > p:not(.section-index) { grid-column: 1; }

  .genres { grid-template-columns: 1fr; }
  .genres > li, .genres > li:first-child { grid-column: 1; }
  .genre-art, .genres > li:first-child .genre-art { height: 180px; }

  .bento { grid-template-columns: 1fr; }
  .tile-graph, .tile-clock, .tile-memory, .tile-save { grid-column: auto; }

  .designer-points { grid-template-columns: 1fr; }

  .cta-primary { width: 100%; justify-content: space-between; }
}

/* Component display rules must never un-hide an element the page script hid. */
[hidden] { display: none !important; }
