@font-face {
  font-family: "Lodge Sans";
  src: url("/assets/fonts/inter-regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Lodge Sans";
  src: url("/assets/fonts/inter-medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Lodge Sans";
  src: url("/assets/fonts/inter-semibold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Lodge Sans";
  src: url("/assets/fonts/inter-italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  --bg: #141210;
  --bg-raise: #1c1916;
  --bg-ink: #0e0c0a;
  --ink: #f6f1e7;
  --ink-soft: #e5dac8;
  --ink-dim: #d2c4b0;
  --line: rgba(246, 241, 231, 0.14);
  --line-strong: rgba(246, 241, 231, 0.38);
  --amber: #e2a45c;
  --amber-hot: #f0bc7a;
  --amber-ink: #24160c;
  --focus: #ffe0b5;
  --danger: #ffb4a2;
  --ok: #d7eccf;
  --sans: "Lodge Sans", "Avenir Next", "Segoe UI", sans-serif;
  --measure: 38rem;
  --shell: 44rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  background: var(--bg);
  scroll-padding-top: 8.5rem;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 420px at 8% -12%, rgba(226, 164, 92, 0.09), transparent 58%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--amber);
  color: var(--amber-ink);
}

:focus {
  outline: none;
}

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

a {
  color: var(--amber-hot);
  text-underline-offset: 0.18em;
}

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

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--focus);
  color: var(--amber-ink);
  padding: 0.6rem 0.9rem;
  border-radius: 999px;
  z-index: 5;
  text-decoration: none;
}

.skip:focus {
  position: fixed;
  top: 0.55rem;
  z-index: 40;
}

.top {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #141210;
  border-bottom: 1px solid var(--line);
}

.top-inner,
.shell,
.footer-inner,
body.entrance main {
  width: min(100% - 2.2rem, var(--shell));
  margin-inline: auto;
}

.top-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 0.85rem 0;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.78rem;
  font-weight: 600;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.brand:hover {
  color: var(--amber-hot);
}

.hearth {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 0.12rem;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(226, 164, 92, 0.14);
}

nav[aria-label="Room"] {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.9rem;
}

nav[aria-label="Room"] a {
  color: var(--ink-soft);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

nav[aria-label="Room"] a[aria-current="page"] {
  color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--amber);
}

.account {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

.who {
  color: var(--ink-dim);
  overflow-wrap: anywhere;
  max-width: 12rem;
}

.shell {
  padding: 2.25rem 0 4rem;
}

.footer {
  border-top: 1px solid var(--line);
  color: var(--ink-dim);
  font-size: 0.92rem;
}

.footer-inner {
  padding: 1.1rem 0 1.6rem;
}

h1,
h2,
h3,
.display {
  font-family: var(--sans);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.12;
  scroll-margin-top: 8.5rem;
}

#content,
#chapter,
.chapter-nav {
  scroll-margin-top: 8.5rem;
}

h1 {
  font-size: clamp(2.15rem, 4.2vw, 3rem);
  margin: 0 0 0.8rem;
}

h2 {
  font-size: 1.7rem;
  margin: 2rem 0 0.6rem;
}

.lede,
.note,
.kicker {
  color: var(--ink-soft);
}

.kicker {
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--amber-hot);
  margin: 0 0 0.6rem;
}

.sample-banner {
  border-left: 3px solid var(--amber);
  padding: 0.35rem 0 0.35rem 0.9rem;
  color: var(--ink);
  margin: 0 0 1.4rem;
}

body.entrance {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.entrance main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-top: 1.4rem;
  padding-bottom: 1.2rem;
}

.entrance-main-wrap {
  width: min(100% - 2.2rem, var(--shell));
  margin-inline: auto;
}

.entrance-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 34rem;
  padding: 2rem 0 3rem;
}

.mark {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--amber-hot);
}

.display {
  font-size: clamp(2.8rem, 10vw, 4.6rem);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.02;
  margin: 1.1rem 0 1rem;
  text-wrap: balance;
}

.entrance .lede {
  font-family: var(--sans);
  font-size: 1.2rem;
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: -0.011em;
  max-width: 34rem;
  color: var(--ink-soft);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.2rem;
  align-items: center;
  margin-top: 1.8rem;
}

.button,
.linkish {
  font: inherit;
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.7rem 1.25rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--amber);
  color: var(--amber-ink);
  text-decoration: none;
  font-weight: 600;
}

.button:hover {
  background: var(--amber-hot);
  color: var(--amber-ink);
}

.button.secondary,
.linkish {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}

.linkish {
  border: 0;
  padding: 0.4rem 0;
  min-height: 44px;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.button.secondary:hover,
.linkish:hover {
  color: var(--ink);
  border-color: var(--ink-soft);
}

form.stack {
  display: grid;
  gap: 0.9rem;
  max-width: 28rem;
  margin-top: 1.4rem;
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

input {
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 0.9rem;
  border-radius: 0.7rem;
  border: 1px solid var(--line-strong);
  background: var(--bg-ink);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}

input:focus-visible {
  border-color: var(--amber);
}

.alert {
  max-width: 28rem;
  color: var(--danger);
  margin: 0.4rem 0 0;
}

.alert.ok {
  color: var(--ok);
}

main.shell:has(.library) {
  width: min(100% - 2.2rem, 72rem);
}

.library .lede {
  max-width: 38rem;
}

.shelf {
  margin: 2.2rem 0 0;
}

.shelf h2 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 0.9rem;
}

.shelf-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.35rem;
}

.book {
  display: block;
  color: inherit;
  text-decoration: none;
  background: var(--bg-raise);
  border: 1px solid var(--line-strong);
  border-radius: 1rem;
  min-height: 44px;
}

.book:hover {
  border-color: var(--amber);
}

.book:hover .book-title {
  color: var(--amber-hot);
}

.book-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 0.85rem;
}

.book-cover {
  display: flex;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border-radius: 0.55rem;
  overflow: hidden;
  background: #100e0c;
}

.book-spine {
  width: 0.85rem;
  flex: none;
  background: linear-gradient(90deg, #8a5a28, var(--amber) 55%, #6e4520);
}

.book-face {
  position: relative;
  flex: 1;
  min-width: 0;
  background: #141210;
}

.cover-plate {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 42%;
  z-index: 0;
}

.cover-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
  pointer-events: none;
}

.book:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.cover-ember {
  transform-box: fill-box;
  transform-origin: center;
  animation: cover-ember 14s ease-in-out infinite;
}

.cover-glow {
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0.28;
  animation: cover-glow 14s ease-in-out infinite;
}

@keyframes cover-ember {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(34px, -5px, 0);
  }
}

@keyframes cover-glow {
  0%,
  100% {
    opacity: 0.22;
  }
  50% {
    opacity: 0.48;
  }
}

.book-frame {
  position: absolute;
  inset: 0.55rem;
  z-index: 2;
  border: 1px solid rgba(226, 164, 92, 0.45);
  border-radius: 0.2rem;
  pointer-events: none;
}

.book-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0.15rem 0.25rem 0.35rem;
}

.book-title {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.book-synopsis {
  margin: 0.45rem 0 0;
  color: var(--ink-soft);
  font-size: 0.98rem;
  line-height: 1.45;
}

.book-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  list-style: none;
  margin: 0.8rem 0 0;
  padding: 0;
}

.book-counts li {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink);
}

.book-empty {
  background: transparent;
  border-style: dashed;
}

.book-empty .book-spine {
  background: rgba(226, 164, 92, 0.35);
}

.book-empty .book-face {
  background: transparent;
}

.card {
  display: block;
  text-decoration: none;
  color: inherit;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 1.2rem 0;
  margin-top: 1.4rem;
}

.card:hover h2 {
  color: var(--amber-hot);
}

.card h2 {
  margin: 0.2rem 0 0.55rem;
  font-size: clamp(2rem, 4vw, 2.7rem);
}

.meta {
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}

.slots {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
}

.slots li {
  border-top: 1px solid var(--line);
}

.slots li:last-child {
  border-bottom: 1px solid var(--line);
}

.row,
.slots a.row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  min-height: 52px;
  padding: 0.55rem 0;
  text-decoration: none;
  color: inherit;
}

.slots a.row:hover .slot-label {
  color: var(--amber-hot);
}

.slot-no {
  font-variant-numeric: tabular-nums;
  color: var(--amber-hot);
  min-width: 2.2rem;
}

.slot-label {
  flex: 1;
}

.slot-state {
  color: var(--ink-dim);
  text-align: right;
}

.waiting {
  color: var(--ink-dim);
}

.prose {
  font-family: var(--sans);
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1.65;
  letter-spacing: -0.011em;
  max-width: 40rem;
}

.prose p,
.prose ul,
.prose ol,
.prose blockquote {
  margin: 0 0 1.05em;
}

.prose h2 {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin: 1.8rem 0 0.55rem;
}

.prose strong {
  font-weight: 600;
}

.prose em {
  font-style: italic;
}

.prose a {
  color: var(--ink);
}

.prose blockquote {
  margin-inline: 0;
  padding-left: 1rem;
  border-left: 2px solid var(--amber);
  color: var(--ink-soft);
}

.prose ul,
.prose ol {
  padding-left: 1.2rem;
}

.prose code,
.prose pre {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.92em;
}

.prose pre {
  overflow-x: auto;
  padding: 0.9rem 1rem;
  background: var(--bg-ink);
  border-radius: 0.6rem;
}

.chapter-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.2rem;
  margin: 1.4rem 0;
}

.player-wrap audio,
.player-wrap video {
  width: min(100%, var(--measure));
  margin: 1.2rem 0 0.4rem;
}

.status {
  min-height: 1.4em;
  color: var(--ok);
  font-size: 0.95rem;
}

.continue {
  margin: 1rem 0 0;
}

@media (min-width: 720px) {
  html {
    scroll-padding-top: 5.5rem;
  }

  h1,
  h2,
  h3,
  #content,
  #chapter,
  .chapter-nav {
    scroll-margin-top: 5.5rem;
  }

  .shelf-grid {
    grid-template-columns: repeat(auto-fill, minmax(16.5rem, 1fr));
    gap: 1.5rem 1.25rem;
    align-items: stretch;
    padding: 0 0 1.15rem;
    background:
      linear-gradient(rgba(226, 164, 92, 0.28), rgba(226, 164, 92, 0.28))
      bottom / 100% 0.45rem no-repeat;
  }

  .book-cover {
    aspect-ratio: 16 / 9;
    height: auto;
  }
}

@media (max-width: 720px) {
  .top-inner,
  .shell,
  .footer-inner,
  body.entrance main,
  main.shell:has(.library) {
    width: min(100% - 1.7rem, 72rem);
  }

  .account {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
  }

  .actions,
  form.stack .button {
    width: 100%;
  }

  .display {
    font-size: clamp(2.7rem, 14vw, 3.6rem);
  }

  .prose {
    font-size: 1.125rem;
  }
}

@media (min-width: 820px) {
  .shell {
    padding-top: 3rem;
  }

  .entrance-main {
    padding-top: 4rem;
  }
}

@media (min-width: 1200px) {
  .shell {
    padding-top: 3.5rem;
  }
}

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

@media (prefers-contrast: more) {
  :root {
    --bg: #0c0b0a;
    --ink: #fffaf3;
    --ink-soft: #fffaf3;
    --ink-dim: #f3e6d4;
    --line: rgba(255, 250, 243, 0.55);
    --line-strong: rgba(255, 250, 243, 0.8);
    --amber-hot: #ffd7a1;
    --focus: #ffffff;
  }

  .button.secondary {
    border-width: 2px;
  }
}

@media (forced-colors: active) {
  .button,
  .brand,
  .hearth {
    forced-color-adjust: auto;
    border: 1px solid ButtonText;
  }
}

@media print {
  body {
    background: #fff;
    color: #16120e;
  }

  .top,
  .skip,
  .footer,
  .chapter-nav,
  .actions,
  .status {
    display: none;
  }

  .sample-banner {
    color: #16120e;
    border-color: #8a5a20;
  }

  .prose,
  .prose a {
    color: #16120e;
  }
}
