:root {
  --white: #ffffff;
  --ink: #1a1a1a;
  --gray: #6b6b6b;
  --gray-line: #e2e2e2;
  --surface: #fafafa;
  --surface-strong: #f1f1f1;
  --red: #d6483f;

  --font-sans: 'Heebo', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --space-6: 48px;
  --space-7: 64px;

  --content-w: 1180px;
}

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

body {
  background: var(--white);
  color: var(--ink);
  font-family: var(--font-sans);
  overflow-x: hidden;
  transition: background 0.4s ease;
}

.mono {
  font-family: var(--font-mono);
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 6vw;
  background: var(--white);
  border-bottom: 1px solid var(--gray-line);
  transition: background 0.4s ease, border-color 0.4s ease;
}

.logo {
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--ink);
  text-decoration: none;
}

.room-links {
  display: flex;
  gap: 1.4rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.room-links a {
  color: var(--gray);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.room-links a:hover {
  color: var(--ink);
}

.room-links a.active {
  color: var(--ink);
  border-bottom-color: var(--red);
}

/* ---------- Rooms (router) ---------- */

.room {
  display: none;
  max-width: var(--content-w);
  margin: 0 auto;
  padding: var(--space-7) 6vw calc(var(--space-7) * 1.5);
}

.room.active {
  display: block;
  animation: roomIn 0.45s ease;
}

@keyframes roomIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.room-head {
  max-width: 52em;
  margin-bottom: var(--space-6);
}

.room-num {
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  color: var(--red);
  margin-bottom: var(--space-2);
}

.room-head h2 {
  font-size: clamp(2.6rem, 8vw, 5.8rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  text-transform: uppercase;
}

.room-tags {
  margin-top: var(--space-3);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gray);
}

.room-intro {
  margin-top: var(--space-4);
  font-size: 1.05rem;
  line-height: 1.7;
}

.room-intro strong {
  font-weight: 700;
}

.room-nav {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: calc(var(--space-7) * 1.2);
  padding-top: var(--space-4);
  border-top: 1px solid var(--gray-line);
}

.room-nav a {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--red);
  padding-bottom: 2px;
}

.room-nav a:hover {
  color: var(--red);
}

/* ---------- Home ---------- */

.lobby-head {
  max-width: 44em;
  margin-bottom: var(--space-6);
}

.lobby-head h1 {
  font-size: clamp(2.2rem, 5.6vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
  text-transform: uppercase;
}

.lobby-sub {
  margin-top: var(--space-4);
  font-size: 1.08rem;
  line-height: 1.7;
  max-width: 36em;
}

.home-hero {
  margin: 0;
  text-align: center;
}

.home-hero img {
  width: 100%;
  max-height: 74vh;
  object-fit: cover;
  display: block;
  border: 1px solid var(--gray-line);
  border-radius: 10px;
}

.home-hero figcaption {
  margin-top: var(--space-2);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--gray);
}

.home-tiles {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-3);
  margin-top: var(--space-6);
}

.home-tile {
  display: block;
  text-decoration: none;
  color: var(--ink);
}

.home-tile img {
  width: 100%;
  aspect-ratio: 3 / 5;
  object-fit: cover;
  display: block;
  border: 1px solid var(--gray-line);
  border-radius: 8px;
  filter: grayscale(1);
  transition: filter 0.45s ease, transform 0.3s ease;
}

.home-tile:hover img,
.home-tile:focus-visible img {
  filter: grayscale(0);
  transform: translateY(-4px);
}

@media (hover: none) {
  .home-tile img {
    filter: grayscale(0);
  }
}

.home-tile > span {
  display: block;
  margin-top: var(--space-2);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--gray);
  line-height: 1.5;
}

.tile-num {
  color: var(--red);
  font-weight: 600;
}

/* ---------- Prompt box (shared) ---------- */

.prompt-box {
  border: 1px solid var(--gray-line);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}

.prompt-box-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: var(--surface-strong);
  border-bottom: 1px solid var(--gray-line);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d4d4d4;
}

.prompt-box-title {
  margin-left: 8px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--gray);
  letter-spacing: 0.03em;
}

.prompt-text {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.65;
  color: var(--ink);
  padding: 16px 18px;
}

.prompt-text .injected {
  color: var(--red);
  font-weight: 500;
}

.prompt-text .shell,
.prompt-text .prompt-comment {
  color: var(--gray);
}

.prompt-text .dg-clause {
  color: var(--red);
  font-weight: 500;
  opacity: 0;
  animation: clauseIn 0.5s ease forwards;
}

@keyframes clauseIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Direction game ---------- */

.direction-game {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 3vw;
  align-items: start;
}

.dg-stage {
  position: relative;
}

.dg-stage img {
  width: 100%;
  display: block;
  border: 1px solid var(--gray-line);
  border-radius: 10px;
}

.dg-blink {
  position: absolute;
  inset: 0;
  background: var(--white);
  opacity: 0;
  pointer-events: none;
  border-radius: 10px;
}

.dg-blink.on {
  animation: dgBlink 0.35s ease-out;
}

@keyframes dgBlink {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

.dg-dots {
  margin-top: var(--space-2);
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  color: var(--gray-line);
}

.dg-dots .done {
  color: var(--red);
}

.dg-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.dg-question {
  font-size: 1.15rem;
  font-weight: 700;
}

.dg-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.dg-option {
  text-align: left;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  padding: 12px 18px;
  background: var(--white);
  border: 1px solid var(--gray-line);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.dg-option:hover {
  border-color: var(--ink);
}

.dg-option.wrong {
  animation: optShake 0.4s ease;
  border-color: var(--gray-line);
  color: var(--gray);
}

@keyframes optShake {
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

.dg-feedback {
  min-height: 1.4em;
  font-size: 0.78rem;
  color: var(--gray);
}

.dg-feedback.correct {
  color: var(--red);
}

.dg-final {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--gray-line);
}

.dg-final-line {
  font-size: clamp(1.15rem, 2.4vw, 1.6rem);
  font-weight: 700;
  max-width: 30em;
}

.dg-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.dg-strip img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border: 1px solid var(--gray-line);
  border-radius: 6px;
}

.dg-epilogue {
  margin-top: var(--space-6);
}

.dg-epilogue-title {
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: var(--space-3);
}

.dg-project {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
}

.dg-project img,
.dg-project .dg-video {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  display: block;
  border: 1px solid var(--gray-line);
  border-radius: 10px;
}

.dg-restart {
  margin-top: var(--space-5);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  background: none;
  border: 1px solid var(--gray-line);
  border-radius: 999px;
  padding: 8px 18px;
  color: var(--gray);
  cursor: pointer;
}

.dg-restart:hover {
  color: var(--ink);
  border-color: var(--ink);
}

/* ---------- Projection room (black) ---------- */

body[data-room="projection"] {
  background: #0c0c0c;
}

body[data-room="projection"] .site-header {
  background: #0c0c0c;
  border-bottom-color: #262626;
}

body[data-room="projection"] .logo {
  color: #f2f2f2;
}

body[data-room="projection"] .room-links a {
  color: #8f8f8f;
}

body[data-room="projection"] .room-links a:hover,
body[data-room="projection"] .room-links a.active {
  color: #f2f2f2;
}

#room-projection {
  color: #eaeaea;
}

#room-projection .room-head h2 {
  color: #f5f5f5;
}

#room-projection .room-intro {
  color: #c9c9c9;
}

#room-projection .prompt-box {
  background: #161616;
  border-color: #2e2e2e;
}

#room-projection .prompt-box-bar {
  background: #1e1e1e;
  border-bottom-color: #2e2e2e;
}

#room-projection .prompt-box-bar .dot {
  background: #3a3a3a;
}

#room-projection .prompt-box-title {
  color: #9a9a9a;
}

#room-projection .prompt-text {
  color: #dcdcdc;
}

#room-projection .prompt-text .shell {
  color: #9a9a9a;
}

#room-projection .room-nav {
  border-top-color: #262626;
}

#room-projection .room-nav a {
  color: #eaeaea;
}

.projection {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.proj-stage {
  position: relative;
  width: min(660px, 92vw, 74vh);
  aspect-ratio: 1;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
}

.proj-slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
}

.proj-slide.active {
  opacity: 1;
}

.proj-blink {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
}

.proj-blink.on {
  animation: projBlink 0.3s ease-out;
}

@keyframes projBlink {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

.proj-prompt {
  width: min(660px, 92vw);
}

.proj-controls {
  justify-content: center;
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.proj-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #eaeaea;
  background: transparent;
  color: #eaeaea;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.proj-btn:hover {
  background: #eaeaea;
  color: #0c0c0c;
}

.proj-count {
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  color: #9a9a9a;
}

.proj-count span {
  color: var(--red);
}

.proj-hint {
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: #9a9a9a;
}

/* ---------- What Remains: the deck ---------- */

.deck-section {
  position: relative;
  height: calc((var(--cards) + 1) * 90vh);
}

.deck-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  overflow: hidden;
}

.deck {
  position: relative;
  width: min(400px, 78vw);
  aspect-ratio: 4 / 5;
}

.deck-card {
  position: absolute;
  inset: 0;
  margin: 0;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  transition: transform 0.55s ease, opacity 0.45s ease;
  will-change: transform, opacity;
}

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

.deck-card.leaving {
  transform: translate(-78%, -6%) rotate(-15deg) !important;
}

.deck-count {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gray);
}

.deck-count span {
  color: var(--red);
}

/* static fallback */

.deck-section.static {
  height: auto;
}

.deck-section.static .deck-sticky {
  position: static;
  height: auto;
  overflow: visible;
  display: block;
}

.deck-section.static .deck {
  position: static;
  width: 100%;
  aspect-ratio: auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

.deck-section.static .deck-card {
  position: static;
  transform: none !important;
  opacity: 1;
  box-shadow: none;
  border: 1px solid var(--gray-line);
  border-radius: 8px;
  aspect-ratio: 4 / 5;
}

.deck-section.static .deck-count {
  display: none;
}

.remains-prompt {
  max-width: 760px;
  margin-top: var(--space-6);
}

.cutting-room {
  margin-top: var(--space-7);
}

.cutting-room-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--red);
  margin-bottom: var(--space-2);
}

.cutting-room-sub {
  color: var(--gray);
  max-width: 40em;
  margin-bottom: var(--space-4);
}

.work-process {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  max-width: 760px;
}

.work-process figure {
  margin: 0;
}

.work-process img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  border: 1px dashed var(--gray-line);
  border-radius: 8px;
  filter: grayscale(0.35);
  opacity: 0.85;
}

.work-process figcaption {
  margin-top: 6px;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--gray);
}

.work-process figcaption.cut {
  color: var(--red);
  text-decoration: line-through;
}

/* ---------- Novel rooms ---------- */

.novel-lead {
  max-width: 760px;
}

.cast-card {
  position: relative;
  cursor: pointer;
  outline: none;
}

.cast-card img {
  width: 100%;
  display: block;
  border: 1px solid var(--gray-line);
  border-radius: 10px;
}

.cast-scrim {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: rgba(10, 10, 10, 0.82);
  display: flex;
  align-items: flex-end;
  padding: var(--space-4);
  opacity: 0;
  transition: opacity 0.35s ease;
}

.cast-card:hover .cast-scrim,
.cast-card:focus-visible .cast-scrim,
.cast-card.open .cast-scrim {
  opacity: 1;
}

.cast-quote {
  color: #eaeaea;
  font-size: 0.8rem;
  line-height: 1.65;
}

.cast-quote .prompt-comment {
  color: #8f8f8f;
}

.cast-hint {
  margin-top: var(--space-2);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--gray);
}

.novel-thumbs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin-top: var(--space-4);
  max-width: 760px;
}

.novel-thumbs img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  border: 1px solid var(--gray-line);
  border-radius: 8px;
}

/* ---------- Exit ---------- */

#room-exit .exit-inner {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

#room-exit h2 {
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  max-width: 22em;
}

.exit-sub {
  margin-top: var(--space-3);
  color: var(--gray);
  font-size: 1.02rem;
}

.footer-links {
  margin-top: var(--space-5);
  font-size: 0.9rem;
  color: var(--gray);
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  justify-content: center;
}

.footer-links a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--red);
  padding-bottom: 1px;
}

.footer-links a:hover {
  color: var(--red);
}

.exit-nav {
  border-top: none;
  margin-top: var(--space-6);
  justify-content: center;
}

/* ---------- Lightbox ---------- */

img.lb {
  cursor: zoom-in;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(12, 12, 12, 0.96);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: 4vmin;
  cursor: zoom-out;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lightbox[hidden] {
  display: none;
}

.lightbox.open {
  opacity: 1;
}

.lightbox-media {
  max-width: 84vw;
  max-height: 84vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox img,
.lightbox video {
  max-width: 84vw;
  max-height: 82vh;
  object-fit: contain;
}

.lightbox-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid #555;
  background: rgba(20, 20, 20, 0.7);
  color: #eaeaea;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  transition: background 0.2s ease, color 0.2s ease;
}

.lightbox-btn:hover {
  background: #eaeaea;
  color: #0c0c0c;
}

.lightbox-prev {
  left: 3vw;
}

.lightbox-next {
  right: 3vw;
}

.lightbox-count {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: #8f8f8f;
}

.lightbox-cap {
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: #b9b9b9;
  text-align: center;
  max-width: 70ch;
}

html.lightbox-open {
  overflow: hidden;
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .site-header {
    padding: 1rem 4vw;
  }

  .room-links {
    gap: 0.7rem;
    font-size: 0.7rem;
  }

  .home-tiles {
    grid-template-columns: repeat(3, 1fr);
  }

  .lightbox-btn {
    top: auto;
    bottom: 4vh;
    transform: none;
  }

  .direction-game,
  .projection {
    grid-template-columns: 1fr;
    gap: var(--space-5);
  }

  .proj-side {
    max-width: none;
  }

  .dg-strip,
  .dg-project {
    grid-template-columns: repeat(3, 1fr);
  }

  .novel-thumbs {
    grid-template-columns: repeat(2, 1fr);
  }

  .work-process {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .room.active {
    animation: none;
  }

  body,
  .site-header,
  .home-tile img,
  .cast-scrim,
  .deck-card,
  .lightbox,
  .proj-slide {
    transition: none;
  }

  .dg-blink.on,
  .proj-blink.on,
  .dg-option.wrong {
    animation: none;
  }

  .prompt-text .dg-clause {
    animation: none;
    opacity: 1;
  }
}
