@import url("https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600;700;800&family=EB+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,500&family=Inter:wght@400;500;600;700;800&family=Noto+Serif+JP:wght@400;500;700&display=swap");

:root {
  color-scheme: light;
  --walnut: #2a1810;
  --walnut-deep: #1c0f09;
  --walnut-soft: #3a2418;
  --leather: #4a2b1b;
  --leather-dark: #30180e;
  --parchment: #f5e6c8;
  --parchment-soft: #fff8e8;
  --parchment-aged: #e5c996;
  --brass: #b8860b;
  --brass-dark: #7a5608;
  --ink: #1a0f0a;
  --muted: #6b513b;
  --muted-light: #b89e76;
  --line: rgba(75, 42, 24, 0.28);
  --line-strong: rgba(75, 42, 24, 0.48);
  --shadow: rgba(20, 8, 2, 0.28);
  --focus: #7a5608;
  --danger: #9b3422;
  --success: #4d6f3e;
  --radius: 8px;
  --content: 72rem;
  --border-art: url("images/decor-ornate-border.webp");
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
  background: var(--walnut);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--walnut);
  font-family: "EB Garamond", "Noto Serif JP", Georgia, serif;
  font-size: 1.08rem;
  line-height: 1.58;
}

button,
input,
textarea {
  max-width: 100%;
  font: inherit;
}

button,
a {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(184, 134, 11, 0.24);
}

a {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

h1,
h2,
h3,
.brand-mark,
.room-number {
  font-family: Cinzel, "Noto Serif JP", Georgia, serif;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

.eyebrow,
.section-kicker,
.toplinks,
.landing-nav,
.primary-button,
.ghost-button,
.copy-button,
.icon-button,
.back-link,
input,
textarea,
.room-state,
.small-note,
.height-mark {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.landing-page {
  color: var(--parchment-soft);
}

.landing-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(100% - 2rem, 78rem);
  margin: 0 auto;
  padding: 1.2rem 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--parchment-soft);
  text-shadow: 0 1px 2px rgba(20, 8, 2, 0.8);
  text-decoration: none;
  text-transform: uppercase;
  font-size: 0.9rem;
  font-weight: 800;
}

.brand-mark span:first-child,
.landing-footer span {
  color: var(--brass);
}

.landing-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.landing-nav a {
  border: 1px solid rgba(184, 134, 11, 0.48);
  border-radius: 999px;
  color: var(--parchment-soft);
  background: rgba(28, 15, 9, 0.46);
  text-decoration: none;
  padding: 0.45rem 0.76rem;
  font-size: 0.82rem;
  font-weight: 700;
}

.landing-nav a:hover {
  color: #fff6d9;
  border-color: var(--brass);
}

.landing-hero {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 86svh;
  padding: 7.6rem 1rem 3rem;
  overflow: hidden;
  isolation: isolate;
}

.landing-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg, rgba(20, 8, 2, 0.86), rgba(20, 8, 2, 0.34) 48%, rgba(20, 8, 2, 0.72));
}

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

.hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(16rem, 22rem);
  align-items: end;
  gap: clamp(2rem, 7vw, 5.5rem);
  width: min(72rem, 100%);
  padding: clamp(2.4rem, 7vw, 5.5rem) 0;
}

.hero-copy {
  max-width: 47rem;
}

.hero-copy h1 {
  margin: 0;
  color: #fff1c9;
  text-shadow: 0 0.12rem 0 rgba(27, 12, 6, 0.86);
  font-size: clamp(3.4rem, 9.5vw, 7.8rem);
  line-height: 0.88;
  text-transform: uppercase;
}

.hero-copy h1 span {
  display: block;
}

.hero-copy h1 span:first-child {
  font-size: 0.54em;
  letter-spacing: 0.08em;
}

.hero-subtitle {
  max-width: 40rem;
  margin: 1.15rem 0 0;
  color: #f9e8bf;
  font-size: clamp(1.12rem, 2.4vw, 1.52rem);
  font-weight: 600;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.25rem;
}

.hero-badges span {
  border: 1px solid rgba(184, 134, 11, 0.48);
  border-radius: 999px;
  color: #f9e8bf;
  background: rgba(28, 15, 9, 0.18);
  padding: 0.38rem 0.72rem;
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 1.7rem;
}

.hero-note {
  align-self: stretch;
  display: flex;
  align-items: flex-end;
  border-left: 1px solid rgba(184, 134, 11, 0.48);
  padding-left: 1.25rem;
}

.hero-note p {
  margin: 0;
  color: #ead4a8;
  font-size: 1.02rem;
}

.primary-button,
.ghost-button,
.copy-button,
.icon-button,
.back-link,
.toplinks a,
.toplinks button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.38rem;
  min-height: 2.7rem;
  border: 1px solid var(--brass);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--brass);
  box-shadow: 0 0.45rem 1rem rgba(38, 17, 5, 0.16);
  text-decoration: none;
  padding: 0.68rem 0.92rem;
  line-height: 1.16;
  text-align: center;
  font-size: 0.94rem;
  font-weight: 800;
  cursor: pointer;
}

.primary-button::before,
.copy-button::before {
  content: "✦";
  color: rgba(26, 15, 10, 0.7);
  font-size: 0.76rem;
}

.ghost-button,
.icon-button,
.back-link,
.toplinks a,
.toplinks button {
  color: var(--parchment-soft);
  background: transparent;
}

.danger {
  border-color: var(--danger);
  color: #ffe5dc;
}

.primary-button:hover,
.ghost-button:hover,
.copy-button:hover,
.icon-button:hover,
.back-link:hover,
.toplinks a:hover,
.toplinks button:hover {
  transform: translateY(-1px);
}

.primary-button:active,
.ghost-button:active,
.copy-button:active,
.icon-button:active,
.back-link:active,
.toplinks a:active,
.toplinks button:active {
  transform: translateY(1px);
}

.section-band {
  position: relative;
  padding: clamp(4rem, 8vw, 7rem) 1rem;
}

.section-band::before {
  content: "";
  position: absolute;
  top: 0.9rem;
  left: 50%;
  width: min(28rem, calc(100% - 2rem));
  height: 5.1rem;
  background-image: var(--border-art);
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  opacity: 0.36;
  pointer-events: none;
  transform: translateX(-50%);
}

.concept-section,
.play-section {
  color: var(--ink);
  background: var(--parchment-soft);
}

.shelves-section {
  color: var(--parchment-soft);
  background: var(--walnut);
}

.section-inner {
  position: relative;
  width: min(var(--content), 100%);
  margin: 0 auto;
}

.section-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(15rem, 21rem);
  align-items: center;
  gap: clamp(1.5rem, 5vw, 4rem);
}

.section-kicker {
  margin: 0 0 0.55rem;
  color: var(--brass-dark);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.shelves-section .section-kicker,
.shelves-section h2 {
  color: var(--parchment-soft);
}

.section-inner > h2,
.play-layout h2 {
  max-width: 56rem;
  margin: 0;
  color: inherit;
  font-size: clamp(2.25rem, 5vw, 4.3rem);
  line-height: 1.02;
}

.section-inner > h2 span {
  display: block;
}

.concept-lead,
.play-lead {
  max-width: 49rem;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: clamp(1.08rem, 2.1vw, 1.26rem);
  font-weight: 600;
}

.section-art,
.key-art {
  display: block;
  width: 100%;
  border: 1px solid rgba(184, 134, 11, 0.34);
  border-radius: var(--radius);
  box-shadow: 0 1rem 2rem rgba(38, 17, 5, 0.12);
}

.section-art {
  aspect-ratio: 3 / 2;
  object-fit: cover;
}

.key-art {
  max-width: 30rem;
  margin-top: 1.5rem;
}

.ornate-divider {
  display: block;
  width: min(42rem, 100%);
  margin: 1.3rem 0 0;
  border: 1px solid rgba(184, 134, 11, 0.34);
  border-radius: var(--radius);
  opacity: 0.92;
}

.concept-grid,
.shelf-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: clamp(1.7rem, 4vw, 2.7rem);
}

.ornate-card,
.shelf-card,
.step-list li,
.side-panel,
.game-panel,
.doc-shell,
.vault-shell,
.brief-box,
.answer-box,
.copy-box,
.paper-card,
.locked-card,
.success-card {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--parchment);
  box-shadow: 0 0.85rem 1.7rem rgba(38, 17, 5, 0.1);
}

.ornate-card,
.shelf-card,
.step-list li {
  padding: 1.35rem;
}

.ornate-card:hover,
.shelf-card:hover,
.step-list li:hover {
  border-color: rgba(184, 134, 11, 0.72);
  transform: translateY(-2px);
}

.card-icon {
  display: grid;
  place-items: center;
  width: 3.1rem;
  aspect-ratio: 1;
  border: 1px solid rgba(184, 134, 11, 0.48);
  border-radius: 50%;
  margin-bottom: 0.9rem;
  background: var(--parchment-soft);
  font-size: 1.45rem;
}

.ornate-card h3,
.shelf-card h3 {
  margin: 0;
  color: var(--walnut);
  font-size: 1.2rem;
  line-height: 1.25;
}

.ornate-card p,
.shelf-card p {
  margin: 0.7rem 0 0;
  color: var(--muted);
}

.shelf-preview-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.shelf-card {
  border-color: rgba(184, 134, 11, 0.34);
  background: var(--parchment-soft);
  overflow: hidden;
  padding: 0;
}

.shelf-card::after {
  content: attr(data-sigil);
  position: absolute;
  top: 0.85rem;
  left: 0.85rem;
  display: grid;
  place-items: center;
  width: 2.35rem;
  aspect-ratio: 1;
  border: 1px solid var(--brass);
  border-radius: 50%;
  color: var(--walnut);
  background: rgba(255, 248, 232, 0.88);
  font-family: Cinzel, Georgia, serif;
  font-weight: 800;
}

.shelf-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.shelf-card h3,
.shelf-card p {
  padding-inline: 1.15rem;
}

.shelf-card h3 {
  margin-top: 1.05rem;
}

.shelf-card p {
  padding-bottom: 1.2rem;
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(18rem, 1fr);
  gap: clamp(1.5rem, 5vw, 4rem);
  align-items: start;
}

.step-list {
  display: grid;
  gap: 0.85rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.step-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.95rem;
  background: var(--parchment);
}

.step-list span {
  display: grid;
  place-items: center;
  width: 2.3rem;
  aspect-ratio: 1;
  border: 1px solid var(--brass);
  border-radius: 50%;
  color: var(--walnut);
  background: transparent;
  font-family: Cinzel, Georgia, serif;
  font-weight: 800;
}

.step-list p {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
}

.landing-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  border-top: 1px solid rgba(184, 134, 11, 0.28);
  color: var(--parchment-soft);
  background: var(--walnut-deep);
  padding: 1.4rem 1rem;
  text-align: center;
}

.landing-footer p {
  margin: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid rgba(184, 134, 11, 0.36);
  color: var(--parchment-soft);
  background: var(--walnut-deep);
  padding: 0.95rem 1.25rem;
  box-shadow: 0 0.7rem 1.4rem rgba(24, 10, 4, 0.18);
}

.topbar h1,
.doc-shell h1,
.vault-shell h1 {
  margin: 0;
  color: var(--parchment-soft);
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 0.2rem;
  color: var(--brass);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.toplinks {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(17rem, 22rem) minmax(0, 1fr);
  align-items: start;
  gap: 1rem;
  width: min(94rem, calc(100% - 2rem));
  margin: 1rem auto 2rem;
}

.side-panel,
.game-panel,
.doc-shell,
.vault-shell {
  color: var(--ink);
}

.side-panel {
  align-self: start;
  position: sticky;
  top: 6.2rem;
  padding: 1rem;
}

.side-panel section + section {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.side-panel h2,
.game-panel h2,
.doc-shell h2,
.vault-shell h2 {
  margin: 0 0 0.75rem;
  color: var(--walnut);
}

.side-panel h2 {
  font-size: 1.05rem;
}

.game-panel {
  min-height: 42rem;
  padding: 1.25rem;
  overflow: hidden;
}

#puzzle-content,
.doc-shell,
.vault-shell,
.scene {
  animation: page-reveal 220ms ease-out both;
}

.room-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.progress-rail {
  flex: 0 1 11rem;
  width: 11rem;
  max-width: 100%;
  height: 0.55rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  overflow: hidden;
  background: var(--parchment-aged);
}

.progress-rail span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--brass);
}

.room-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.62rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--parchment-soft);
  padding: 0.86rem;
}

.room-button {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  align-items: center;
  gap: 0.48rem;
  width: 100%;
  min-height: 4.45rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--parchment);
  box-shadow: none;
  text-align: left;
  cursor: pointer;
  padding: 0.58rem;
}

.room-button:hover,
.room-button[aria-current="true"] {
  border-color: var(--brass);
}

.room-button:disabled {
  color: rgba(77, 47, 29, 0.58);
  background: #ddc394;
  cursor: not-allowed;
  opacity: 0.84;
}

.room-number {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--brass);
  border-radius: 50%;
  color: var(--walnut);
  background: transparent;
  font-weight: 800;
}

.room-label {
  min-width: 0;
  color: var(--walnut);
  font-weight: 700;
  line-height: 1.18;
}

.room-state {
  grid-column: 2;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
}

.fragment-list {
  margin: 0;
  padding-left: 1.4rem;
  color: var(--walnut);
}

.fragment-list li + li {
  margin-top: 0.35rem;
}

.empty-fragment,
.protocol p,
.small-note,
.hint,
.locked-note,
.answer-feedback {
  color: var(--muted);
}

.scene {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.brief-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: 1rem;
}

.brief-box,
.answer-box,
.copy-box,
.paper-card,
.locked-card,
.success-card {
  padding: 1rem;
}

.success-card {
  border-color: rgba(77, 111, 62, 0.48);
  background: #eef0d4;
}

.paper-card h3,
.brief-box h3,
.copy-box h3,
.answer-box h3,
.locked-card h3 {
  margin: 0 0 0.6rem;
  color: var(--walnut);
  font-size: 1.05rem;
}

.paper-card p {
  margin: 0;
}

.cipher-text,
.mirror-transcript,
.packet-text,
.data-preview {
  -webkit-overflow-scrolling: touch;
  overflow: auto;
  max-height: 18rem;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--parchment-soft);
  padding: 0.85rem;
  font-family: "Courier New", ui-monospace, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.copy-row,
.answer-row,
.sequence-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.answer-row input {
  flex: 1 1 16rem;
  min-width: 0;
  min-height: 2.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--parchment-soft);
  padding: 0.62rem 0.75rem;
}

.answer-feedback {
  min-height: 1.5rem;
  font-family: Inter, system-ui, sans-serif;
  font-weight: 700;
}

.room-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.shelf-clue {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(2.4rem, 1fr));
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.shelf-clue span {
  display: grid;
  place-items: center;
  min-height: 3.4rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--parchment-soft);
  font-weight: 900;
}

.shelf-clue .active {
  color: var(--walnut);
  border-color: var(--brass);
}

.diary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  gap: 0.8rem;
}

.diary-card {
  min-height: 10rem;
}

.diary-date {
  display: inline-block;
  margin-bottom: 0.45rem;
  color: var(--brass-dark);
  font-family: Inter, system-ui, sans-serif;
  font-weight: 800;
}

.mirror-plate {
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #efe5d1;
  padding: 1rem;
}

.mirror-plate p {
  margin: 0;
  color: var(--ink);
  font-family: "EB Garamond", Georgia, serif;
  font-size: 1.28rem;
  transform: scaleX(-1);
  white-space: pre-wrap;
}

.vault-link-note {
  border-left: 3px solid var(--brass);
  padding-left: 0.8rem;
  color: var(--walnut);
}

.stats-wrap {
  -webkit-overflow-scrolling: touch;
  overflow: auto;
  max-height: 27rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--parchment-soft);
  scrollbar-gutter: stable both-edges;
}

.stats-table {
  width: 100%;
  min-width: 52rem;
  border-collapse: collapse;
  font-family: "Courier New", ui-monospace, monospace;
  font-size: 0.82rem;
}

.stats-table th,
.stats-table td {
  border: 1px solid var(--line);
  padding: 0.35rem 0.45rem;
  color: var(--ink);
  background: var(--parchment-soft);
  text-align: right;
}

.stats-table th {
  color: var(--parchment-soft);
  background: var(--walnut-soft);
}

.stats-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.stats-table th[scope="row"] {
  position: sticky;
  left: 0;
  z-index: 1;
}

.stats-table thead th:first-child {
  left: 0;
  z-index: 3;
}

.stats-table td.clickable {
  cursor: pointer;
}

.stats-table td.clickable:hover,
.stats-table td.marked {
  outline: 2px solid var(--brass);
  outline-offset: -2px;
  background: #fff0c2;
}

.burn-message {
  display: grid;
  gap: 0.2rem;
  width: max-content;
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--parchment-soft);
  padding: 1rem;
}

.burn-row {
  display: flex;
  gap: 0.2rem;
}

.burn-pixel {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 2px;
  background: rgba(83, 49, 26, 0.18);
}

.burn-pixel.on {
  background: var(--brass);
}

.book-wall {
  --book-width: 6rem;
  --book-half: 3rem;
  position: relative;
  min-height: 24rem;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--walnut-soft);
  padding: 1rem;
}

.book-wall::before,
.book-wall::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 0.5rem;
  background: var(--walnut-deep);
}

.book-wall::before {
  top: 33%;
}

.book-wall::after {
  top: 66%;
}

.book-button {
  position: absolute;
  left: clamp(calc(var(--book-half) + 0.25rem), var(--x), calc(100% - var(--book-half) - 0.25rem));
  bottom: var(--rise);
  width: var(--book-width);
  min-height: 4.2rem;
  border: 1px solid rgba(184, 134, 11, 0.42);
  border-radius: var(--radius);
  color: var(--parchment-soft);
  background: var(--leather-dark);
  cursor: pointer;
  padding: 0.45rem;
  overflow-wrap: anywhere;
  transform: translateX(-50%);
}

.book-button:hover,
.book-button.selected {
  border-color: var(--brass);
}

.height-mark {
  display: block;
  color: var(--brass);
  font-size: 0.78rem;
  font-weight: 800;
}

.sequence-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-height: 2rem;
}

.sequence-pills span {
  border: 1px solid rgba(184, 134, 11, 0.42);
  border-radius: 999px;
  color: var(--walnut);
  background: var(--parchment-soft);
  padding: 0.25rem 0.55rem;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
  gap: 0.7rem;
}

.memory-card {
  min-height: 9rem;
}

.escape-seal {
  border: 1px solid rgba(184, 134, 11, 0.48);
  border-radius: var(--radius);
  color: var(--parchment-soft);
  background: var(--walnut-soft);
  padding: 1rem;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  max-width: min(28rem, calc(100% - 2rem));
  border: 1px solid rgba(184, 134, 11, 0.62);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--parchment-soft);
  box-shadow: 0 0.75rem 1.5rem var(--shadow);
  padding: 0.8rem 1rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.75rem);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.doc-page,
.vault-page {
  min-height: 100vh;
  padding: 1rem;
}

.doc-shell,
.vault-shell {
  width: min(54rem, 100%);
  margin: 0 auto;
  padding: 1.25rem;
}

.doc-shell h1,
.vault-shell h1 {
  margin: 0.5rem 0 1rem;
  color: var(--walnut);
}

.back-link {
  display: inline-flex;
  align-items: center;
  margin-bottom: 1rem;
}

.vault-instruction {
  color: var(--walnut);
}

.moon-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(2.8rem, 1fr));
  gap: 0.6rem;
  width: min(27rem, 100%);
  margin: 1.25rem auto;
}

.moon-grid span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: rgba(80, 45, 24, 0.54);
  background: var(--parchment);
  font-family: Cinzel, Georgia, serif;
  font-size: 1.5rem;
  font-weight: 800;
}

.moon-grid .moon {
  border-color: var(--brass);
  color: var(--walnut);
  background: var(--parchment-soft);
}

.noscript {
  margin: 1rem;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  color: var(--parchment-soft);
  background: var(--walnut-soft);
  padding: 1rem;
}

@keyframes page-reveal {
  from {
    opacity: 0;
    transform: translateY(0.25rem);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .landing-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .landing-hero {
    min-height: 84svh;
    padding-top: 9rem;
  }

  .hero-inner {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: clamp(2rem, 7vw, 4rem) 0;
  }

  .hero-note {
    border-left: 0;
    border-top: 1px solid rgba(184, 134, 11, 0.48);
    padding: 1rem 0 0;
  }

  .section-heading,
  .concept-grid,
  .shelf-preview-grid,
  .play-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toplinks {
    justify-content: flex-start;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
  }

  .brief-grid,
  .diary-grid,
  .memory-grid {
    grid-template-columns: 1fr;
  }

  .progress-rail {
    width: 8rem;
  }

  .book-wall {
    --book-width: 5.3rem;
    --book-half: 2.65rem;
    min-height: 32rem;
  }

  .book-button {
    min-height: 4rem;
  }
}

@media (max-width: 620px) {
  body {
    font-size: 1rem;
  }

  .landing-header {
    width: min(100% - 1.5rem, 78rem);
  }

  .landing-nav {
    width: 100%;
    justify-content: flex-start;
  }

  .landing-nav a {
    flex: 1 1 auto;
    text-align: center;
  }

  .landing-hero {
    min-height: 88svh;
    padding: 9.6rem 0.85rem 3rem;
  }

  .hero-inner {
    padding: 2.2rem 0;
  }

  .hero-copy h1 {
    font-size: clamp(3.25rem, 17vw, 5rem);
  }

  .hero-note {
    display: none;
  }

  .hero-actions,
  .copy-row,
  .answer-row,
  .sequence-row {
    width: 100%;
  }

  .hero-actions a,
  .toplinks a,
  .toplinks button,
  .copy-button,
  .primary-button,
  .ghost-button {
    width: 100%;
    justify-content: center;
  }

  .section-band {
    padding: 3.5rem 0.85rem;
  }

  .shelf-card {
    padding: 0;
  }

  .shelf-card::after {
    top: 0.75rem;
    left: 0.75rem;
  }

  .room-nav {
    grid-template-columns: 1fr;
  }

  .game-panel,
  .side-panel,
  .doc-shell,
  .vault-shell {
    padding: 0.85rem;
  }

  .room-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .shelf-clue {
    grid-template-columns: repeat(4, minmax(2rem, 1fr));
  }

  .moon-grid {
    gap: 0.4rem;
  }

  .moon-grid span {
    font-size: 1.15rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
