/* Plotwick — the midnight reading room.
   A single, deliberate dark world: warm ink ground, candle-gold accent,
   book typography (running heads, drop caps, asterisms). */

:root {
  --ink-well: #131017;   /* ground — warm black, violet-brown bias */
  --page: #1e1826;       /* raised surface */
  --plate: #251d2f;      /* cards */
  --text: #eae4d6;       /* warm ivory */
  --muted: #9b917f;      /* parchment grey */
  --gold: #d9a648;       /* candle gold — the one accent */
  --gold-dim: rgba(217, 166, 72, 0.14);
  --gold-line: rgba(217, 166, 72, 0.4);
  --wine: #9c4d43;       /* oxblood — errors only */
  --hairline: rgba(234, 228, 214, 0.1);
  --display: "Cormorant Garamond", "Palatino Linotype", Palatino, serif;
  --prose: "Crimson Pro", "Iowan Old Style", Georgia, serif;
  --ui: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}

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

body {
  background: var(--ink-well);
  background-image:
    radial-gradient(ellipse 90% 50% at 50% -5%, rgba(217, 166, 72, 0.06), transparent 70%),
    radial-gradient(ellipse at 50% 110%, #1a1422, var(--ink-well) 60%);
  color: var(--text);
  font-family: var(--ui);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

.hidden { display: none !important; }

/* ---------- header ---------- */

.demo-banner {
  background: var(--gold-dim);
  border-bottom: 1px solid var(--gold-line);
  color: var(--gold);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  padding: 0.5rem 1rem;
  text-align: center;
}
.demo-banner code { font-size: 0.75rem; }

.site-header { text-align: center; padding: 3rem 1rem 0.75rem; }
.header-rule { color: var(--gold); opacity: 0.7; font-size: 0.9rem; letter-spacing: 0.4em; }
.logo {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(2.6rem, 6vw, 3.4rem);
  letter-spacing: 0.04em;
  color: var(--gold);
  cursor: pointer;
  line-height: 1.1;
}
.logo a { color: inherit; text-decoration: none; }
.tagline {
  color: var(--muted);
  font-family: var(--ui);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  margin-top: 0.5rem;
}

/* page-load ink-in */
@media (prefers-reduced-motion: no-preference) {
  .site-header, .screen { animation: ink-in 0.7s ease both; }
  .screen { animation-delay: 0.15s; }
  @keyframes ink-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
  }
}

main { width: 100%; max-width: 760px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; flex: 1; }

.site-footer {
  text-align: center;
  color: var(--gold);
  opacity: 0.35;
  padding: 1.5rem;
  font-size: 0.9rem;
}

/* ---------- shared type ---------- */

.screen-title {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.9rem;
  text-align: center;
  text-wrap: balance;
  margin-bottom: 0.4rem;
}
.screen-title.small { font-size: 1.4rem; margin: 2.8rem 0 0.2rem; }
.screen-sub {
  text-align: center;
  color: var(--muted);
  font-family: var(--prose);
  font-style: italic;
  font-size: 1.05rem;
  margin-bottom: 1.2rem;
}

/* ---------- first-story flyleaf ---------- */

.activation-intro {
  background: var(--page);
  border: 1px solid var(--hairline);
  border-left: 2px solid var(--gold-line);
  border-radius: 2px;
  margin: 0.35rem 0 1.8rem;
  padding: 1.15rem 1.35rem;
}
.activation-copy {
  align-items: center;
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(280px, 1.1fr);
}
.activation-kicker, .section-kicker {
  color: var(--gold);
  font-size: 0.66rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}
.activation-kicker {
  grid-column: 1;
  grid-row: 1;
}
.activation-copy h2 {
  color: var(--text);
  font-family: var(--display);
  font-size: clamp(1.75rem, 3.8vw, 2.25rem);
  font-weight: 500;
  grid-column: 1;
  grid-row: 2;
  letter-spacing: -0.015em;
  line-height: 1.05;
  margin: 0.2rem 1.25rem 0 0;
  text-wrap: balance;
}
.activation-copy > p:not(.activation-kicker) {
  border-left: 1px solid var(--hairline);
  color: var(--muted);
  font-family: var(--prose);
  font-size: 0.98rem;
  grid-column: 2;
  grid-row: 1 / 3;
  line-height: 1.45;
  padding-left: 1.35rem;
}
.beta-notice {
  align-items: baseline;
  border-bottom: 1px solid var(--hairline);
  display: flex;
  gap: 1rem;
  margin: -0.45rem 0 1.8rem;
  padding: 0 0.15rem 0.9rem;
}
.beta-notice-title {
  color: var(--gold);
  flex: 0 0 auto;
  font-size: 0.64rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.beta-notice > p:last-child {
  color: var(--muted);
  font-family: var(--prose);
  font-size: 0.86rem;
  line-height: 1.45;
}
.worlds-heading { text-align: center; }
.worlds-heading .screen-title { margin-top: 0.15rem; }
.worlds-heading .screen-sub { margin-bottom: 0; }
.shelf-shortcut {
  align-items: center;
  border-bottom: 1px solid var(--hairline);
  border-top: 1px solid var(--hairline);
  display: flex;
  gap: 1.5rem;
  justify-content: space-between;
  margin-top: 1.5rem;
  padding: 1rem 0;
}
.shelf-shortcut p {
  color: var(--muted);
  font-family: var(--prose);
  font-size: 0.95rem;
}
.shelf-shortcut strong {
  color: var(--text);
  font-weight: 600;
}
.shelf-shortcut > div {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: 0.75rem;
}
.shelf-shortcut span {
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.3;
  max-width: 7rem;
}
#screen-scenario { display: flex; flex-direction: column; }
#activation-intro { order: 0; }
#beta-notice { order: 1; }
#library-section { order: 1; }
.worlds-heading { order: 2; }
#scenario-grid { order: 3; }
#activation-shortcut { order: 4; }

.journey-progress {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  list-style: none;
  margin: 0.2rem 0 2.2rem;
  position: relative;
}
.journey-progress::before {
  background: var(--hairline);
  content: "";
  height: 1px;
  left: 16.66%;
  position: absolute;
  right: 16.66%;
  top: 0.78rem;
}
.journey-progress li {
  color: var(--muted);
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  position: relative;
  text-align: center;
}
.journey-progress li span {
  align-items: center;
  background: var(--ink-well);
  border: 1px solid var(--hairline);
  border-radius: 50%;
  display: flex;
  height: 1.55rem;
  justify-content: center;
  margin: 0 auto 0.35rem;
  position: relative;
  width: 1.55rem;
  z-index: 1;
}
.journey-progress .complete, .journey-progress .current { color: var(--text); }
.journey-progress .complete span {
  background: var(--gold);
  border-color: var(--gold);
  color: #221a0e;
}
.journey-progress .current span {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px var(--gold-dim);
  color: var(--gold);
}
.character-premise {
  border-left: 1px solid var(--gold-line);
  color: var(--muted);
  font-family: var(--prose);
  font-size: 1rem;
  font-style: italic;
  margin: 0 auto 1.8rem;
  max-width: 34rem;
  padding-left: 1rem;
}

.field-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin: 1.6rem 0 0.55rem;
}

input[type="text"], input[type="email"], input[type="password"], textarea, select {
  width: 100%;
  background: var(--page);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  color: var(--text);
  font-family: var(--prose);
  font-size: 1.05rem;
  padding: 0.7rem 0.9rem;
  resize: vertical;
}
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus, textarea:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

/* name field + dice-roll button */
.name-row { display: flex; gap: 0.6rem; align-items: stretch; }
.name-row input { flex: 1; }
.roll-btn {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--ui);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  padding: 0 1rem;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.roll-btn:hover { color: var(--gold); border-color: var(--gold-line); }
.roll-btn:active { transform: translateY(1px); }
@media (max-width: 460px) { .roll-btn { font-size: 0.75rem; padding: 0 0.7rem; } }

/* ---------- book-plate cards ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  align-items: stretch;
  gap: 0.9rem;
  margin: 1.8rem 0 0.5rem;
}
.card-grid.small { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); margin: 0.4rem 0 0.6rem; }

.card {
  --card-accent: var(--gold); /* per-world override via inline style */
  background: var(--plate);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 1.25rem 1.1rem 1.15rem;
  cursor: pointer;
  text-align: center;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--gold-line); }
.card.selected { border-color: var(--gold); background: linear-gradient(var(--gold-dim), var(--gold-dim)) var(--plate); }
.card .ornament {
  display: block;
  font-size: 1.25rem;
  color: var(--card-accent);
  opacity: 0.8;
  margin-bottom: 0.5rem;
  transition: opacity 0.15s ease;
}
.card:hover .ornament, .card.selected .ornament { opacity: 1; }
.card .eyebrow {
  display: block;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

/* Each world's card is tinted with its own genre accent so the grid reads as
   a shelf of different books, not one purple deck. */
.scenario-card {
  background:
    linear-gradient(158deg, color-mix(in srgb, var(--card-accent) 15%, transparent), transparent 58%),
    var(--plate);
  border-color: color-mix(in srgb, var(--card-accent) 22%, var(--hairline));
}
.scenario-card:hover { border-color: var(--card-accent); }
.scenario-card .eyebrow { color: color-mix(in srgb, var(--card-accent) 75%, var(--muted)); }
.scenario-card h3 { color: color-mix(in srgb, var(--card-accent) 30%, var(--text)); }

/* world card = a carousel of three stories */
.world-card { position: relative; height: 23rem; padding: 0; overflow: hidden; }
.world-choose {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: center;
  padding: 1.25rem 1.9rem 1.05rem; /* horizontal room for the arrows */
}
.world-choose p {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 8;
  overflow: hidden;
}
.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 3.5rem;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 2.1rem;
  line-height: 1;
  padding: 0;
  border-radius: 4px;
  opacity: 0.78;
  transition: color 0.15s ease, opacity 0.15s ease;
  z-index: 2;
}
.carousel-arrow.left { left: 0.05rem; }
.carousel-arrow.right { right: 0.05rem; }
.carousel-arrow:hover { color: var(--card-accent); opacity: 1; }
.story-dots { display: flex; justify-content: center; gap: 5px; margin-top: auto; padding-top: 0.85rem; }
.story-dots .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--muted); opacity: 0.35;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.story-dots .dot.on { background: var(--card-accent); opacity: 1; }

/* "Write your own" — a clean full-width banner across the grid */
.custom-card {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  text-align: left;
  padding: 1.1rem 1.3rem;
}
.custom-card .ornament { margin-bottom: 0; font-size: 1.7rem; }
.custom-card .custom-copy { display: flex; flex-direction: column; gap: 0.15rem; }
.custom-card h3 { margin-bottom: 0.1rem; }
.custom-card p { font-size: 0.92rem; }
.card h3 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1.2;
  text-wrap: balance;
  margin-bottom: 0.45rem;
}
.card p { font-family: var(--prose); font-size: 0.95rem; color: var(--muted); line-height: 1.5; }

/* trait chips */
.chip-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  font-family: var(--ui);
  font-size: 0.85rem;
  padding: 0.42rem 1.05rem;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.chip:hover { border-color: var(--gold-line); }
.chip.selected { border-color: var(--gold); color: var(--gold); background: var(--gold-dim); }

/* ---------- buttons ---------- */

.btn {
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  font-family: var(--ui);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.65rem 1.5rem;
  transition: filter 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary { background: var(--gold); color: #221a0e; }
.btn-primary:not(:disabled):hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--hairline); color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--gold-line); }
.btn-danger { background: rgba(156, 77, 67, 0.12); border-color: rgba(156, 77, 67, 0.5); color: #dfa79f; }
.btn-danger:hover { background: rgba(156, 77, 67, 0.22); }
.btn-small { font-size: 0.78rem; padding: 0.38rem 0.9rem; }

.actions { display: flex; justify-content: space-between; gap: 0.8rem; margin-top: 2.2rem; }
.actions.actions-end { justify-content: flex-end; }

/* Top-left back navigation, consistent across every sub-screen. */
.screen-nav { margin-bottom: 1rem; }
.back-link {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--ui);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  padding: 0.3rem 0.1rem;
  transition: color 0.15s ease;
}
.back-link:hover { color: var(--gold); }

/* ---------- library ---------- */

.library {
  border-bottom: 1px solid var(--hairline);
  border-top: 1px solid var(--gold-line);
  margin: 0.4rem 0 3rem;
  padding: 2rem 0 2.4rem;
}
.library-header {
  align-items: end;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.library-header .screen-title {
  margin: 0.15rem 0 0;
  text-align: left;
}
.library-summary {
  color: var(--muted);
  font-family: var(--prose);
  font-size: 0.9rem;
  margin-top: 0.15rem;
}
.library-filters { display: flex; gap: 0.3rem; }
.library-filters button {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--ui);
  font-size: 0.68rem;
  padding: 0.35rem 0.7rem;
}
.library-filters button:hover { color: var(--text); }
.library-filters button.active {
  background: var(--gold-dim);
  border-color: var(--gold-line);
  color: var(--gold);
}
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.9rem;
  margin-top: 1.4rem;
}
.library-card {
  display: flex;
  gap: 0.9rem;
  background: var(--page);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 0.8rem;
  align-items: stretch;
}
.library-card .cover {
  width: 64px;
  min-width: 64px;
  aspect-ratio: 2 / 3;
  border-radius: 2px;
  overflow: hidden;
  background: var(--plate);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-size: 1.3rem;
}
.library-card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.library-card .lib-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.library-card .lib-status {
  align-self: flex-start;
  color: var(--muted);
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
}
.library-card .lib-status.reading { color: var(--gold); }
.library-card h3 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.1rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
}
.library-card .lib-meta { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.04em; margin: 0.25rem 0 0; }
.library-card .lib-progress {
  background: var(--hairline);
  height: 2px;
  margin-top: 0.55rem;
  overflow: hidden;
  width: 100%;
}
.library-card .lib-progress span { background: var(--gold); display: block; height: 100%; }
.library-card .lib-updated { color: var(--muted); font-size: 0.65rem; margin-top: 0.35rem; }
.library-card .lib-actions { display: flex; gap: 0.5rem; margin-top: 0.6rem; }
.library-empty {
  color: var(--muted);
  font-family: var(--prose);
  font-style: italic;
  grid-column: 1 / -1;
  padding: 1.5rem 0;
  text-align: center;
}

/* ---------- story screen: the book page ---------- */

.running-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 0.65rem;
}
.running-head #story-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.story-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; justify-content: flex-end; margin: 0.7rem 0 1.4rem; }

/* A quiet marker that something finished writing below the fold. It sits out of
   the reading column, waits to be clicked, and never moves the page by itself. */
.jump-pill {
  position: fixed;
  right: 1.6rem;
  bottom: 1.6rem;
  z-index: 40;
  background: var(--page);
  color: var(--story-accent, var(--gold));
  border: 1px solid var(--gold-line);
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--ui);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.55rem 1.1rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  opacity: 0.92;
  animation: pill-in 0.28s ease both;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.jump-pill:hover { opacity: 1; transform: translateY(-1px); }
.jump-pill.hidden { display: none; }
@keyframes pill-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 0.92; transform: none; } }
@media (prefers-reduced-motion: reduce) { .jump-pill { animation: none; } }
@media (max-width: 640px) { .jump-pill { right: 50%; transform: translateX(50%); }
  .jump-pill:hover { transform: translateX(50%) translateY(-1px); } }
.tool-btn {
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--ui);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 0.32rem 0.9rem;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.tool-btn:hover { color: var(--text); }
.tool-btn[aria-pressed="true"] { color: var(--gold); border-color: var(--gold-line); background: var(--gold-dim); }

.journal {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  background: var(--page);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 1rem 1.2rem;
  margin-bottom: 1.6rem;
}
.journal h4 {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--story-accent);
  margin-bottom: 0.35rem;
  font-weight: 500;
}
.journal p, .journal li { font-family: var(--prose); font-size: 0.95rem; color: var(--text); }
.journal ul { list-style: none; }
.journal li + li { margin-top: 0.15rem; }
.journal .standing { color: var(--muted); font-style: italic; }

/* The reading view is tinted with the current world's accent, set as an inline
   --story-accent on #screen-story (custom stories fall back to house gold). */
#screen-story { --story-accent: var(--gold); }

.story-text {
  font-family: var(--prose);
  font-size: 1.17rem;
  line-height: 1.85;
  max-width: 62ch;
  margin: 0 auto;
}
.story-text p { margin-bottom: 1.1em; }
/* While a chapter is being written, hold a screen of room beneath it so its
   first line can sit at the top of the view. Released once the chapter lands. */
.story-text.reserving { padding-bottom: 78vh; }

/* ---------- page view: the story as turning pages ---------- */
/* Reading a book, the room goes quiet: the masthead steps aside so the page
   itself gets the screen. The running head still names the story. */
body.paged-reading .site-header,
body.paged-reading .demo-banner { display: none; }
body.paged-reading main { padding-top: 1rem; }
body.paged-reading .site-footer { display: none; }
body.paged-reading .story-toolbar { margin: 0.5rem 0 0.8rem; }
body.paged-reading .screen-nav { margin-bottom: 0.4rem; }

/* The reader is a fixed-height window; the article inside is laid out as
   screen-wide columns and slid sideways one page at a time. The browser does
   the line-breaking, so a page always fits the screen it is being read on. */
.reader.paged {
  /* exactly one page wide, so the next column is clipped at the page edge
     instead of peeking past it */
  width: var(--page-w, 100%);
  margin-inline: auto;
  height: var(--page-h, 60vh);
  overflow: hidden;
  position: relative;
  touch-action: pan-y;
}
.reader.paged .story-text {
  max-width: none;
  width: var(--page-w, 100%);
  height: 100%;
  margin: 0 auto;
  column-width: var(--page-w, 100%);
  column-gap: var(--page-gap, 3rem);
  column-fill: auto;
  transform: translateX(calc(-1 * var(--page-i, 0) * (var(--page-w, 0px) + var(--page-gap, 3rem))));
  transition: transform 0.38s cubic-bezier(0.22, 0.61, 0.36, 1);
}
@media (prefers-reduced-motion: reduce) {
  .reader.paged .story-text { transition: none; }
}
/* every chapter opens a fresh page, the way a book does */
.reader.paged .chapter { break-before: column; }
.reader.paged .chapter:first-child { break-before: auto; }
.reader.paged .player-action, .reader.paged .asterism { break-inside: avoid; }
/* the choices are the chapter's last page, not a panel under it */
.reader.paged #choices-area,
.reader.paged #ending-area {
  break-before: column;
  margin-top: 0;
  max-width: none;
  padding-top: 0.5rem;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.4rem;
  margin: 0.9rem auto 0;
  max-width: 62ch;
}
.pager.hidden { display: none; }
.page-arrow {
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.3rem 0.85rem;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.page-arrow:hover:not(:disabled) { color: var(--story-accent, var(--gold)); border-color: var(--gold-line); }
.page-arrow:disabled { opacity: 0.28; cursor: default; }
.page-count {
  color: var(--muted);
  font-family: var(--ui);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  min-width: 6ch;
  text-align: center;
}

/* drop cap on each chapter's first paragraph */
.chapter > p:first-of-type::first-letter {
  font-family: var(--display);
  font-weight: 600;
  font-size: 3.3em;
  line-height: 0.82;
  color: var(--story-accent);
  float: left;
  padding: 0.06em 0.12em 0 0;
}

.player-action {
  color: var(--story-accent);
  font-style: italic;
  font-size: 1.02rem;
  margin: 1.9em 0 0;
}
.player-action::before { content: "❧ "; font-style: normal; }
.asterism {
  text-align: center;
  color: var(--muted);
  letter-spacing: 0.6em;
  margin: 1.6em 0;
  font-size: 0.95rem;
}

.typing {
  color: var(--muted);
  font-family: var(--prose);
  font-style: italic;
  text-align: center;
  margin: 1.4rem 0;
}
.dots span { animation: blink 1.4s infinite; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.2; } 30% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dots span { animation: none; } }

/* ---------- choices ---------- */

.choices { margin: 2.2rem auto 0; max-width: 62ch; }
.choices-label {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.25rem;
  color: var(--story-accent);
  text-align: center;
  margin-bottom: 1rem;
}
#choice-buttons { display: flex; flex-direction: column; gap: 0.6rem; }
.choice-btn {
  background: var(--page);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  color: var(--text);
  cursor: pointer;
  font-family: var(--prose);
  font-size: 1.05rem;
  padding: 0.85rem 1.15rem;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, padding-left 0.15s ease;
}
.choice-btn:hover {
  border-color: color-mix(in srgb, var(--story-accent) 55%, transparent);
  background: linear-gradient(color-mix(in srgb, var(--story-accent) 12%, transparent), color-mix(in srgb, var(--story-accent) 12%, transparent)) var(--page);
  padding-left: 1.5rem;
}

.custom-action { display: flex; gap: 0.6rem; margin-top: 0.9rem; }
.custom-action input { flex: 1; }

/* The unclaimed teaser: choices stay legible but inert, so the reader can see
   exactly what they're being asked to sign in for. Muted rather than greyed —
   they should still read as real options, not as broken buttons. */
.choice-btn:disabled {
  cursor: default;
  opacity: 0.62;
}
.choice-btn:disabled:hover {
  border-color: var(--hairline);
  background: var(--page);
  padding-left: 1.15rem;
}

.teaser-wall {
  margin-top: 1.4rem;
  padding: 1.3rem 1.2rem 1.4rem;
  border: 1px solid color-mix(in srgb, var(--story-accent) 32%, transparent);
  border-radius: 3px;
  background: color-mix(in srgb, var(--story-accent) 7%, var(--page));
  text-align: center;
}
.teaser-wall-lede {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.3rem;
  color: var(--story-accent);
  margin-bottom: 0.4rem;
}
.teaser-wall-sub {
  font-family: var(--prose);
  font-size: 0.98rem;
  color: var(--muted);
  margin: 0 auto 1rem;
  max-width: 44ch;
}

/* ---------- ending & sharing ---------- */

.ending { text-align: center; margin-top: 3rem; }
.ending-mark { color: var(--story-accent); font-size: 1.3rem; letter-spacing: 0.4em; }
.ending-summary {
  color: var(--muted);
  font-family: var(--prose);
  font-size: 1.05rem;
  line-height: 1.55;
  margin: 0.8rem auto 0;
  max-width: 31rem;
}
.discovery-note {
  color: var(--gold);
  font-family: var(--display);
  font-size: 1.12rem;
  margin-top: 1.8rem;
}
.ending-word {
  font-family: var(--display);
  font-style: italic;
  font-size: 2rem;
  margin: 0.4rem 0 1.6rem;
}
.ending-actions { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }
.share-result {
  display: flex;
  gap: 0.5rem;
  max-width: 30rem;
  margin: 1.2rem auto 0;
}
.share-result input { font-family: var(--ui); font-size: 0.85rem; color: var(--muted); }

/* ---------- errors ---------- */

.error {
  background: rgba(156, 77, 67, 0.12);
  border: 1px solid rgba(156, 77, 67, 0.45);
  border-radius: 3px;
  padding: 1rem 1.2rem;
  margin: 1.6rem auto 0;
  max-width: 62ch;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.error p { color: #dfa79f; font-family: var(--prose); font-size: 1rem; }

/* ---------- accounts ---------- */

.account-bar {
  position: absolute;
  top: 0.9rem;
  right: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.site-header { position: relative; }
.account-email {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 13, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  z-index: 20;
}
.modal-card {
  position: relative;
  width: min(26rem, 100%);
  background: var(--page);
  border: 1px solid var(--gold-line);
  border-radius: 4px;
  padding: 2rem 1.8rem 1.7rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.8rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.5rem;
  text-align: center;
}
.modal-sub {
  text-align: center;
  color: var(--muted);
  font-family: var(--prose);
  font-style: italic;
  font-size: 0.98rem;
  margin-top: 0.3rem;
}
.modal-actions { display: flex; justify-content: space-between; gap: 0.8rem; margin-top: 1.6rem; }
.auth-message {
  margin-top: 1rem;
  font-size: 0.88rem;
  color: #dfa79f;
}
.auth-message.gentle { color: var(--gold); }

/* ---------- credits & payments ---------- */

.credits-pill {
  background: var(--gold-dim);
  border: 1px solid var(--gold-line);
  border-radius: 3px;
  color: var(--gold);
  cursor: pointer;
  display: grid;
  grid-template-columns: 1.55rem auto;
  align-items: center;
  column-gap: 0.45rem;
  font-family: var(--ui);
  padding: 0.28rem 0.62rem 0.3rem 0.42rem;
  text-align: left;
  transition: filter 0.15s ease;
}
.credits-pill:hover { filter: brightness(1.15); }
.credits-pill.empty { color: var(--wine); border-color: rgba(156, 77, 67, 0.5); background: rgba(156, 77, 67, 0.12); }
.balance-number {
  align-items: center;
  border-right: 1px solid currentColor;
  display: flex;
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 600;
  justify-content: center;
  line-height: 1;
  min-height: 1.55rem;
  padding-right: 0.42rem;
}
.balance-copy { display: flex; flex-direction: column; line-height: 1.05; }
.balance-copy strong {
  color: currentColor;
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.balance-copy small {
  color: var(--muted);
  font-family: var(--prose);
  font-size: 0.66rem;
  font-style: italic;
  letter-spacing: 0;
  margin-top: 0.18rem;
}

/* ---------- publisher's ledger ---------- */

.ledger-masthead {
  align-items: end;
  border-bottom: 1px solid var(--gold-line);
  display: flex;
  gap: 2rem;
  justify-content: space-between;
  padding-bottom: 1.2rem;
}
.ledger-masthead .screen-title { margin: 0.25rem 0 0.2rem; text-align: left; }
.ledger-masthead .screen-sub { margin: 0; text-align: left; }
.ledger-range {
  display: flex;
  flex: 0 0 auto;
}
.ledger-range button {
  background: transparent;
  border: 1px solid var(--hairline);
  color: var(--muted);
  cursor: pointer;
  font: 500 0.65rem var(--ui);
  letter-spacing: 0.08em;
  padding: 0.45rem 0.65rem;
  text-transform: uppercase;
}
.ledger-range button + button { border-left: 0; }
.ledger-range button.selected {
  background: var(--gold-dim);
  border-color: var(--gold-line);
  color: var(--gold);
}
.ledger-reconciliation {
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--gold);
  color: var(--muted);
  font: 0.78rem var(--ui);
  margin: 1.25rem 0 1.6rem;
  padding: 0.7rem 0.85rem;
}
.ledger-reconciliation.verified { color: #9dc5aa; border-left-color: #6ea47f; }
.ledger-reconciliation.mismatch { color: #dfa79f; border-left-color: var(--wine); }
.ledger-section { margin-top: 2rem; }
.ledger-section-title {
  color: var(--muted);
  font: 500 0.67rem var(--ui);
  letter-spacing: 0.18em;
  margin-bottom: 0.7rem;
  text-transform: uppercase;
}
.ledger-kpis {
  border-bottom: 1px solid var(--hairline);
  border-top: 1px solid var(--hairline);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
.ledger-kpi {
  min-height: 7rem;
  padding: 1rem 0.9rem;
}
.ledger-kpi + .ledger-kpi { border-left: 1px solid var(--hairline); }
.ledger-kpi span {
  color: var(--muted);
  display: block;
  font: 0.62rem var(--ui);
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
.ledger-kpi strong {
  color: var(--text);
  display: block;
  font: 600 2rem/1 var(--display);
  margin-top: 0.75rem;
}
.ledger-kpi small {
  color: var(--muted);
  display: block;
  font: italic 0.75rem var(--prose);
  margin-top: 0.45rem;
}
.ledger-funnel { display: grid; gap: 0.55rem; }
.funnel-row {
  align-items: center;
  display: grid;
  gap: 0.7rem;
  grid-template-columns: minmax(8.5rem, 1fr) minmax(8rem, 2fr) 3rem;
}
.funnel-label { color: var(--text); font: 0.78rem var(--ui); }
.funnel-track {
  background: var(--hairline);
  height: 0.42rem;
  overflow: hidden;
}
.funnel-fill {
  background: linear-gradient(90deg, var(--gold-line), var(--gold));
  height: 100%;
  min-width: 2px;
  width: var(--funnel-width);
}
.funnel-value { color: var(--muted); font: 0.72rem var(--ui); text-align: right; }
.ledger-columns {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr 1fr;
}
.ledger-rows { border-top: 1px solid var(--hairline); }
.ledger-row {
  align-items: baseline;
  border-bottom: 1px solid var(--hairline);
  display: grid;
  gap: 0.8rem;
  grid-template-columns: 1fr auto;
  padding: 0.7rem 0.15rem;
}
.ledger-row strong { font: 500 0.82rem var(--ui); }
.ledger-row span { color: var(--muted); font: 0.75rem var(--ui); }
.ledger-empty { color: var(--muted); font: italic 0.9rem var(--prose); padding: 0.9rem 0; }

.pack-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
  margin: 1.4rem 0 0.4rem;
}
.pack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  background: var(--plate);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 1rem 0.5rem;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.pack:hover { border-color: var(--gold); transform: translateY(-2px); }
.pack:disabled { opacity: 0.5; cursor: wait; }
.pack-count { font-family: var(--display); font-weight: 600; font-size: 1.9rem; color: var(--gold); line-height: 1; }
.pack-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.pack-price { font-family: var(--prose); font-size: 1.15rem; margin-top: 0.35rem; }
.pack-each { font-size: 0.68rem; color: var(--muted); }
.buy-fineprint { text-align: center; color: var(--muted); font-size: 0.72rem; margin-top: 1rem; }
.account-actions { display: grid; gap: 0.65rem; margin-top: 1rem; }
.trust-note { color: var(--muted); font-family: var(--ui); font-size: 0.72rem; margin: 0.6rem 0; }
.footer-links { display: flex; justify-content: center; gap: 1rem; }
.footer-links a { color: var(--muted); font-family: var(--ui); font-size: 0.72rem; }
.footer-links a:hover { color: var(--gold); }
.policy-page { max-width: 46rem; margin: 0 auto; padding: 0 1.5rem 4rem; }
.policy-page h2, .policy-page h3 { font-family: var(--display); }
.policy-page h2 { color: var(--gold); font-size: 2rem; }
.policy-page h3 { margin-top: 2rem; font-size: 1.25rem; }
.policy-page p { font-family: var(--prose); color: var(--muted); font-size: 1.08rem; line-height: 1.7; }
.policy-page ul { font-family: var(--prose); color: var(--muted); font-size: 1.08rem; line-height: 1.7; margin: 0.4rem 0 1rem 1.4rem; }
.policy-page li { margin-bottom: 0.4rem; }
.policy-page a { color: var(--gold); }
.policy-page .policy-updated { color: var(--text); font-size: 0.95rem; }
.policy-page .policy-toc { font-size: 0.98rem; }
/* "needs a lawyer" / placeholder callout */
.policy-page .legal-note {
  border: 1px solid var(--gold-line);
  background: var(--gold-dim);
  border-radius: 4px;
  padding: 0.9rem 1.15rem;
  margin: 1.6rem 0;
}
.policy-page .legal-note p { color: var(--text); font-size: 1rem; margin: 0; }
.policy-page .legal-note p + p { margin-top: 0.5rem; }
.policy-page .placeholder { color: var(--gold); font-style: italic; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%) translateY(1rem);
  background: var(--page);
  border: 1px solid var(--gold-line);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.7rem 1.2rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 30;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 460px) {
  .pack-grid { grid-template-columns: 1fr; }
}

/* ---------- share page ---------- */

.share-byline {
  text-align: center;
  color: var(--muted);
  font-family: var(--prose);
  font-style: italic;
  font-size: 1.05rem;
  margin: 0.3rem 0 2.2rem;
}
.share-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  text-align: center;
  text-wrap: balance;
  margin-top: 1rem;
}
.share-footer-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 3rem;
}
.share-footer-note a { color: var(--gold); text-decoration: none; }

/* ---------- responsive ---------- */

@media (max-width: 540px) {
  .site-header { padding-top: 6.5rem; }
  .account-bar {
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
    left: 0.6rem;
    right: 0.6rem;
  }
  .account-email { display: none; }
  .credits-pill { grid-template-columns: 1.25rem auto; }
  .credits-pill .balance-copy small { display: none; }
  .tool-btn { font-size: 0.64rem; padding: 0.32rem 0.65rem; }
  .activation-intro { padding: 1.1rem 1.2rem; }
  .activation-copy { display: block; text-align: center; }
  .activation-copy h2 { margin: 0.2rem 0 0; }
  .activation-copy > p:not(.activation-kicker) {
    border-left: 0;
    border-top: 1px solid var(--hairline);
    margin-top: 0.8rem;
    padding: 0.75rem 0 0;
  }
  .beta-notice { align-items: center; flex-direction: column; gap: 0.35rem; text-align: center; }
  .shelf-shortcut { align-items: stretch; flex-direction: column; gap: 0.8rem; }
  .shelf-shortcut > div { align-items: stretch; flex-direction: column; }
  .shelf-shortcut .btn { width: 100%; }
  .shelf-shortcut span { max-width: none; text-align: center; }
  .journey-progress li { font-size: 0.58rem; }
  .library-header { align-items: flex-start; flex-direction: column; }
  .library-filters { width: 100%; }
  .library-filters button { flex: 1; }
  .story-text { font-size: 1.08rem; }
  .actions { flex-direction: column-reverse; }
  .actions .btn { width: 100%; }
  .running-head { letter-spacing: 0.12em; }
  .world-card { height: 21rem; }
  .ledger-masthead { align-items: stretch; flex-direction: column; gap: 1rem; }
  .ledger-range button { flex: 1; }
  .ledger-kpis { grid-template-columns: repeat(2, 1fr); }
  .ledger-kpi + .ledger-kpi { border-left: 0; }
  .ledger-kpi:nth-child(even) { border-left: 1px solid var(--hairline); }
  .ledger-kpi:nth-child(n + 3) { border-top: 1px solid var(--hairline); }
  .ledger-columns { grid-template-columns: 1fr; }
  .funnel-row { grid-template-columns: minmax(7.5rem, 1fr) minmax(5rem, 1.5fr) 2.5rem; }
}

.buy-mode-note {
  width: fit-content;
  margin: 0.35rem auto 1rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid rgba(215, 166, 65, 0.55);
  border-radius: 999px;
  background: rgba(215, 166, 65, 0.12);
  color: var(--gold);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
