:root {
  color-scheme: dark;
  --night: #141416;
  --line: #37383c;
  --ink: #f4f4f3;
  --muted: #bcbec3;
  --parchment: #eeede8;
  --display: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --leaf-width: min(42vw, calc(max(27rem, 100svh - 8.5rem) * 2 / 3), 35rem);
  font: 100%/1.4 system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  background: radial-gradient(ellipse at 50% 30%, #26272b, var(--night) 73%);
  color: var(--ink);
  margin: 0;
  min-block-size: 100svh;
}

button { color: inherit; font: inherit; }

button:focus-visible, a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 5px;
}

.masthead { border-bottom: 1px solid var(--line); }

.masthead-inner {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-inline: auto;
  min-block-size: 4.25rem;
  width: min(100% - 4rem, 84rem);
}

.wordmark, .masthead-link, .turn-label, .reader-position p {
  letter-spacing: .15em;
  text-transform: uppercase;
}

.wordmark {
  align-items: center;
  color: inherit;
  display: inline-flex;
  font-family: var(--display);
  font-size: 1.13rem;
  font-weight: 700;
  gap: .9rem;
  min-block-size: 2.75rem;
  padding: 0 .25rem;
  text-decoration: none;
}

.device {
  border: 1px solid currentColor;
  color: var(--muted);
  display: grid;
  height: .72rem;
  place-items: center;
  transform: rotate(45deg);
  width: .72rem;
}

.device::after {
  background: currentColor;
  content: "";
  height: .26rem;
  width: .26rem;
}

.masthead-link {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: .875rem;
  min-block-size: 2.75rem;
  text-decoration: none;
  text-underline-offset: .3em;
}

.masthead-link:hover { color: var(--ink); text-decoration: underline; }

.masthead-sections {
  display: flex;
  flex-wrap: wrap;
  gap: 0 clamp(.55rem, 2.5vw, 1.75rem);
  justify-content: flex-end;
}

.reader {
  display: grid;
  justify-items: center;
  padding: 1.65rem 1rem 1.5rem;
}

.cover-preview {
  margin-block-start: clamp(2.25rem, 5vw, 4rem);
  max-inline-size: 100%;
  scroll-margin-block-start: 1rem;
}

.book {
  background: #27282b;
  border: 1px solid #4d4e52;
  border-radius: .25rem;
  box-shadow: 0 3px 0 -1px #34353a, 0 18px 48px #0009;
  display: grid;
  grid-auto-columns: var(--leaf-width);
  grid-auto-flow: column;
  padding: .125rem;
}

.leaf {
  aspect-ratio: 2 / 3;
  background: #242529;
  container-type: inline-size;
  isolation: isolate;
  min-inline-size: 0;
  overflow: hidden;
  position: relative;
}

.leaf::before, .leaf::after {
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
}

.cover { border-radius: .17rem; }

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

.cover::before {
  background: linear-gradient(180deg, #0b0c0ede, #1414167d 22%, transparent 51%, transparent 80%, #0b0c0e99);
}

.cover-preview .cover::before {
  background: linear-gradient(180deg, #0b0c0eeb, #0b0c0eb3 29%, #0b0c0e54 44%, transparent 58%, transparent 80%, #0b0c0e99);
}

.cover::after {
  border: 1px solid #e5e8ed55;
  inset: 2.5cqw;
  z-index: 2;
}

.cover-type, .chapter-type {
  inset: 10% 7% auto;
  position: absolute;
  text-align: center;
  z-index: 3;
}

.cover-preview .cover-type { inset-block-start: 7%; }

.rule {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: .57rem;
  justify-content: center;
  margin-inline: auto;
}

.rule::before, .rule::after {
  background: currentColor;
  content: "";
  height: 1px;
  opacity: .65;
  width: 9cqw;
}

.rule i {
  background: currentColor;
  height: .3rem;
  transform: rotate(45deg);
  width: .3rem;
}

.cover-title, .chapter h2 {
  font-family: var(--display);
  font-weight: 700;
  line-height: 1.04;
  margin: 4cqw 0 0;
}

.cover-title {
  font-size: 11cqw;
  letter-spacing: -.025em;
  line-height: .98;
  margin-block-start: 2.4cqw;
  text-shadow: 0 2px 12px #08080a, 0 2px 3px #08080a;
}

.cover-subtitle {
  color: var(--ink);
  font-size: clamp(1rem, 3.55cqw, 1.125rem);
  line-height: 1.42;
  margin: 3.5cqw auto 0;
  max-inline-size: 34ch;
  text-shadow: 0 1px 4px #08080a;
}

.cover-series, .chapter h2 span {
  color: #e1e2e6;
  display: block;
  font-family: var(--display);
  font-size: clamp(.72rem, 3.4cqw, 1.1rem);
  font-weight: 700;
  letter-spacing: .23em;
  margin: 3cqw 0 0;
  text-transform: uppercase;
}

.cover-series { margin-block-start: 2.5cqw; }

.cover-launcher {
  align-items: end;
  background: none;
  border: 0;
  cursor: pointer;
  display: grid;
  inset: 0;
  justify-items: center;
  padding: 0 1rem 9cqw;
  position: absolute;
  z-index: 4;
}

.cover-launcher span {
  background: var(--parchment);
  border-radius: .2rem;
  box-shadow: 0 2px 14px #0009;
  color: var(--night);
  font-weight: 650;
  min-block-size: 2.75rem;
  padding: .65rem 1.3rem;
}

.cover-launcher:hover span { background: #dedfe2; }
.cover-launcher:focus-visible { outline-offset: -.42rem; }

.paper {
  background: #f1f1ef;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  padding: 2.6% 2.6% 0;
}

.paper img {
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.paper::after { z-index: 1; }

.left-leaf { border-radius: .17rem 0 0 .17rem; }
.right-leaf { border-radius: 0 .17rem .17rem 0; }

.left-leaf::after {
  background: linear-gradient(90deg, transparent 96%, #191a2038);
}

.right-leaf::after {
  background: linear-gradient(90deg, #191a202b, transparent 4%);
}

.folio {
  color: #3a3b40;
  font: .8125rem/2 var(--display);
  text-align: center;
}

.chapter {
  background: #f1f1ef;
  color: #242529;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 15% 8% 15.75%;
  row-gap: 8%;
}

.chapter::after { z-index: 1; }
.chapter-type { inset: auto; position: relative; }
.chapter .rule { color: #676971; }
.chapter h2 { font-size: 8.3cqw; }
.chapter h2 span { color: #51535a; margin: 0 0 3.5cqw; }

.chapter-illustration {
  /* The inn’s position in cover.png and its destination inside the panel. */
  --inn-x: 83.15%;
  --inn-y: 76.15%;
  --spot-x: 54%;
  --spot-y: 56%;
  --zoom: 6.5;
  background: #373a41;
  border: 1px solid #3c3d42;
  overflow: hidden;
  position: relative;
}

.chapter-art {
  filter: saturate(.88);
  height: auto;
  left: var(--spot-x);
  max-width: none;
  position: absolute;
  top: var(--spot-y);
  transform: translate(calc(-1 * var(--inn-x)), calc(-1 * var(--inn-y)));
  width: calc(100% * var(--zoom));
}

.chapter-illustration::after {
  background:
    radial-gradient(ellipse 35% 30% at var(--spot-x) var(--spot-y),
      #ffc36d5c, #e39e4526 58%, transparent 100%),
    radial-gradient(ellipse 66% 64% at var(--spot-x) var(--spot-y),
      transparent 20%, #17192020 60%, #1719208c 100%);
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
}

.unwritten {
  grid-template-rows: 1fr;
  padding: 0;
  place-items: center;
}

.unwritten p {
  color: #4e5056;
  font: italic clamp(.875rem, 4.6cqw, 1.5rem)/1.45 var(--display);
  margin: 0;
  padding: 0 .75rem;
  text-align: center;
}

.comic-dialog {
  background: #18191c;
  border: 0;
  color: var(--ink);
  height: 100dvh;
  inset: 0;
  margin: 0;
  max-height: none;
  max-width: none;
  overflow: hidden;
  padding: 0;
  width: 100%;
}

.comic-dialog::backdrop { background: #101012; }
body:has(.comic-dialog[open]) { overflow: hidden; }

.reader-screen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
}

.reader-toolbar {
  align-items: center;
  background: var(--night);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: .5rem;
  justify-content: space-between;
  padding: .35rem clamp(.75rem, 2.5vw, 2rem);
}

.reader-toolbar p {
  font: 700 clamp(.92rem, 2vw, 1.15rem)/1.15 var(--display);
  margin: 0;
}

.reader-tools { display: flex; flex: 0 0 auto; gap: .35rem; }

.reader-tools button {
  background: #26272b;
  border: 1px solid #55565d;
  border-radius: .2rem;
  cursor: pointer;
  font-size: .875rem;
  min-height: 2.75rem;
  padding: .35rem .65rem;
}

.reader-tools button:hover { background: #383a40; }

.reader-scroll { container-type: size; overflow: auto; overscroll-behavior: contain; }
.reader-scroll:focus-visible { outline: 2px solid var(--muted); outline-offset: -2px; }

.reader-stage {
  --fit-leaf-width: min(calc((100cqw - 1.5rem) / 2), calc(max(13rem, 100cqh - 1.5rem) * 2 / 3));
  --reader-leaf-width: var(--fit-leaf-width);
  display: grid;
  min-block-size: 100%;
  min-inline-size: 100%;
  padding: .5rem;
  place-items: center;
  position: relative;
  width: max-content;
}

.comic-dialog[data-zoomed] .reader-stage { --reader-leaf-width: calc(var(--fit-leaf-width) * 1.6); }

.reader-book {
  --leaf-width: var(--reader-leaf-width);
  isolation: isolate;
  position: relative;
  touch-action: pan-y pinch-zoom;
}

.comic-dialog[data-zoomed] .reader-book { touch-action: pan-x pan-y pinch-zoom; }

.book-edge {
  border: 0;
  cursor: pointer;
  display: grid;
  inline-size: clamp(2.5rem, 13%, 6rem);
  inset-block: .125rem;
  opacity: 0;
  place-items: center;
  position: absolute;
  z-index: 1;
}

.book-edge::after {
  border: solid var(--ink);
  border-width: 2px 2px 0 0;
  content: "";
  height: .75rem;
  width: .75rem;
}

.book-edge-previous {
  background: linear-gradient(90deg, #141416c7, transparent);
  inset-inline-start: .125rem;
}

.book-edge-next {
  background: linear-gradient(270deg, #141416c7, transparent);
  inset-inline-end: .125rem;
}

.book-edge-previous::after { transform: rotate(-135deg); }
.book-edge-next::after { transform: rotate(45deg); }
.book-edge:focus-visible { opacity: 1; outline-offset: -3px; }
.reader-book[data-closed] .book-edge-next { opacity: 1; }
.book-edge[aria-disabled="true"] { opacity: 0; pointer-events: none; }

@media (hover: hover) {
  .book-edge:not([aria-disabled="true"]):hover { opacity: 1; }
}

.turn-layer {
  inset: 0;
  overflow: clip;
  perspective: 3200px;
  pointer-events: none;
  position: absolute;
}

.turning-leaf, .turn-face, .held-leaf { position: absolute; }
.turning-leaf { transform-style: preserve-3d; z-index: 1; }
.turn-concealed { opacity: 0; }
.turn-face { backface-visibility: hidden; inset: 0; }
.turn-face > .leaf, .held-leaf > .leaf { height: 100%; width: 100%; }
.turn-back { transform: rotateY(180deg); }
.turning-cover .turn-back { background: #eeede8; }
.opening-stack { border-radius: .17rem; box-shadow: 0 0 0 2px #3b3c40, 0 5px 16px #0006; }

.turn-face::after {
  animation: turn-shadow .9s ease-in-out both;
  background: linear-gradient(90deg, #1719208c, #1719201c 55%, #17192062);
  content: "";
  inset: 0;
  position: absolute;
}

.turning-cover .turn-face::after { animation-duration: 1.1s; }

@keyframes turn-shadow {
  0%, 100% { opacity: 0; }
  50% { opacity: .85; }
}

.reader-nav {
  align-items: start;
  display: grid;
  grid-template-columns: minmax(4.75rem, 1fr) auto minmax(4.75rem, 1fr);
  margin: .25rem auto .45rem;
  width: min(100% - 1.5rem, 29rem);
}

.turn {
  align-items: center;
  background: none;
  border: 0;
  cursor: pointer;
  display: flex;
  gap: .72rem;
  min-block-size: 2.75rem;
  padding: 0;
  text-align: start;
}

.previous { justify-self: start; }
.next { flex-direction: row-reverse; justify-self: end; text-align: end; }

.turn-icon {
  background: #27282c;
  border: 1px solid #6a6b72;
  border-radius: 50%;
  color: var(--ink);
  display: grid;
  flex: 0 0 auto;
  height: 2.75rem;
  place-items: center;
  transition: background .18s, border-color .18s;
  width: 2.75rem;
}

.turn-icon::before {
  border: solid currentColor;
  border-width: 1px 1px 0 0;
  content: "";
  height: .62rem;
  transform: translateX(-.1rem) rotate(45deg);
  width: .62rem;
}

.previous .turn-icon::before { transform: translateX(.1rem) rotate(-135deg); }
.turn-label { font-size: .875rem; }
.reader-position p { font-size: .75rem; }
.turn[aria-disabled="true"] { color: var(--muted); cursor: default; }
.turn[aria-disabled="true"] .turn-icon { background: transparent; border-color: var(--line); color: var(--muted); }

@media (hover: hover) {
  .turn:not([aria-disabled="true"]):hover .turn-icon {
    background: #383a40;
    border-color: var(--muted);
  }
}

.reader-position { color: var(--muted); text-align: center; }
.reader-position p { margin: 0; }
.bookmarks { display: flex; justify-content: center; }

.bookmarks button {
  background: none;
  border: 0;
  cursor: pointer;
  display: grid;
  height: 1.75rem;
  padding: 0;
  place-items: center;
  width: 1.6rem;
}

.bookmarks button::after {
  background: #64666e;
  border-radius: 2px;
  content: "";
  height: 3px;
  width: .86rem;
}

.bookmarks button[aria-current]::after, .bookmarks button:hover::after { background: var(--ink); }
.noscript { color: var(--muted); padding-top: 1rem; }

.prologue {
  scroll-margin-block-start: 1rem;
  width: min(100%, 58rem);
}

.prologue h2 {
  font: 700 clamp(1.6rem, 4vw, 2.4rem)/1.1 var(--display);
  margin: 0 0 .85rem;
}

.prologue-video {
  aspect-ratio: 16 / 9;
  background: #080809;
  border: 1px solid var(--line);
  border-radius: .25rem;
  display: block;
  height: auto;
  width: 100%;
}

.prologue-link {
  color: var(--muted);
  display: inline-block;
  font-size: .875rem;
  margin-block-start: .65rem;
  text-underline-offset: .22em;
}

.prologue-link:hover { color: var(--ink); }

.game-info {
  align-items: start;
  border-block-start: 1px solid var(--line);
  display: grid;
  gap: clamp(2rem, 5vw, 4.5rem);
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
  margin-block-start: clamp(3.5rem, 8vw, 6.5rem);
  padding-block: clamp(2.5rem, 5vw, 4.5rem);
  scroll-margin-block-start: 1rem;
  width: min(100%, 67rem);
}

.game-info-copy h2, .game-info-copy h3, .world-state-header h3 {
  font-family: var(--display);
  line-height: 1.1;
  margin: 0;
}

.game-info-copy h2 { font-size: clamp(2.25rem, 5vw, 3.5rem); }
.game-info-copy h3 { font-size: 1.3rem; margin-block-start: 1.65rem; }

.game-info:focus { outline: none; }

.game-info:focus-visible h2 {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .22em;
}

.game-info-copy p {
  color: var(--muted);
  line-height: 1.65;
  margin: .55rem 0 0;
  max-width: 56ch;
}

.game-info-copy .game-intro {
  color: var(--ink);
  font-size: 1.15rem;
  line-height: 1.5;
  margin-block-start: .9rem;
}

.game-info-copy .game-tagline {
  color: var(--ink);
  font: italic clamp(1.1rem, 2vw, 1.4rem)/1.4 var(--display);
  margin-block-start: .65rem;
}

.game-info-copy .game-pitch {
  color: var(--ink);
  display: grid;
  gap: .12rem;
  margin-block: 1rem;
}

.world-state { margin: 0; }

.world-state figcaption {
  color: var(--muted);
  font-size: .875rem;
  margin-block-end: .75rem;
}

.world-state-preview {
  background: var(--parchment);
  border: 1px solid #55565a;
  border-radius: .25rem;
  box-shadow: 0 14px 36px #0005;
  color: #242529;
  overflow: hidden;
}

.world-state-header {
  background:
    linear-gradient(90deg, #141416f2, #141416a6 62%, #14141635),
    url("./art/cover.png") center 77% / cover;
  color: var(--ink);
  padding: 1.25rem clamp(1rem, 3vw, 1.5rem) 1.4rem;
}

.world-state-header p {
  font-size: .8125rem;
  letter-spacing: .1em;
  margin: 0 0 .6rem;
  text-transform: uppercase;
}

.world-state-header h3 { font-size: clamp(1.6rem, 4vw, 2.25rem); }
.world-state-details { padding: 1rem clamp(1rem, 3vw, 1.5rem) 1.25rem; }

.world-state-stats {
  display: grid;
  gap: .6rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
}

.world-state-stats div {
  display: grid;
  gap: .15rem;
  grid-template-rows: auto 1fr;
}

.world-state-stats dt { color: #43454b; font-size: .875rem; }

.world-state-stats dd {
  align-self: end;
  font: 700 2rem/1.05 var(--display);
  margin: 0;
}

.world-state-work {
  border-block-start: 1px solid #c9cace;
  display: grid;
  gap: .4rem;
  margin: 1rem 0 0;
  padding-block-start: .85rem;
}

.world-state-work div {
  display: grid;
  gap: .75rem;
  grid-template-columns: 6.75rem minmax(0, 1fr);
}

.world-state-work dt { font-weight: 650; }
.world-state-work dd { margin: 0; }

.world-state-choice {
  background: #e3e4e5;
  border-inline-start: 2px solid #666970;
  margin-block-start: 1rem;
  padding: .7rem .8rem;
}

.world-state-choice h4 { font-size: .875rem; margin: 0 0 .2rem; }
.world-state-choice p { margin: 0; }

@media (max-width: 800px) {
  .game-info { grid-template-columns: minmax(0, 1fr); width: min(100%, 34rem); }
}

@media (max-width: 760px) {
  :root { --leaf-width: min(calc(100vw - 2.5rem), 28rem); }
  .masthead-inner { min-block-size: 3.5rem; width: calc(100% - 2rem); }
  .reader { padding-top: 1.1rem; }
  .reader-stage {
    --fit-leaf-width: min(calc(100cqw - 1.5rem), calc(max(13rem, 100cqh - 1.5rem) * 2 / 3));
  }
  .reader-book[data-final-spread] { --leaf-width: calc(var(--reader-leaf-width) / 2); }
  .paper { border-radius: .17rem; }
  .paper::after { background: none; }
}

@media (max-width: 470px) {
  .masthead-inner { gap: .65rem; }
  .wordmark, .masthead-link { letter-spacing: .1em; }
  .masthead-link { font-size: .8125rem; text-align: end; }
  .reader-nav { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr); }
  .turn { flex-direction: column; gap: .32rem; min-width: 4.25rem; text-align: center; }
  .turn-label { font-size: .75rem; }
  .reader-position p { font-size: .6875rem; }
  .reader-position { padding-top: .2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .turn-icon { transition: none; }
}
