/* =========================================================================
   «Между строк» — main stylesheet
   Palette: plum / wine / dusty rose / antique gold / cream
   ========================================================================= */

:root {
  --plum-950: #120d12;
  --plum-900: #1a1119;
  --plum-850: #211522;
  --wine-900: #2a1520;
  --wine-800: #3b1d2c;
  --wine-700: #4a2233;
  --rose: #d98a9a;
  --rose-soft: #e8b2bd;
  --gold: #e8c07a;
  --gold-deep: #b9822a;
  --gold-soft: #ffd9a0;
  --cream: #f6ede3;
  --cream-dim: #e8d8c4;
  --lavender: #a99bb5;
  --lavender-dim: #7c6f89;
  --line-gold: rgba(232, 192, 122, 0.42);
  --line-soft: rgba(232, 192, 122, 0.2);
  --panel: rgba(24, 14, 22, 0.88);
  --font-head: "Georgia", "Times New Roman", "PT Serif", "DejaVu Serif", "Liberation Serif", serif;
  --font-body: "Segoe UI", "Inter", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --shadow-deep: 0 30px 80px rgba(0, 0, 0, 0.55);
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--plum-950);
  color: var(--cream);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  overflow: hidden;
  overscroll-behavior: none;
}

body.modal-open {
  overflow: hidden;
}

#app {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

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

::selection {
  background: rgba(232, 192, 122, 0.28);
  color: var(--cream);
}

[hidden] {
  display: none !important;
}

/* -------------------------------------------------------------------------
   Shared primitives
   ------------------------------------------------------------------------- */

.screen {
  position: fixed;
  inset: 0;
  overflow: hidden;
  opacity: 1;
  animation: screenIn 0.45s ease both;
}

.page-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.page-bg .image-frame,
.page-bg-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.page-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.screen-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 26px;
  border-radius: 12px;
  border: 1px solid var(--line-soft);
  background: rgba(30, 17, 27, 0.5);
  color: var(--cream);
  font-size: 15px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.25s var(--ease-out), border-color 0.25s, transform 0.25s, box-shadow 0.25s;
}

.btn:hover {
  border-color: var(--line-gold);
  background: rgba(58, 29, 44, 0.72);
  transform: translateY(-1px);
}

.btn svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.btn-gold {
  border-color: rgba(232, 192, 122, 0.65);
  background: linear-gradient(180deg, rgba(122, 63, 79, 0.6), rgba(58, 29, 44, 0.68));
  color: var(--gold-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 12px 30px rgba(0, 0, 0, 0.28);
}

.btn-gold:hover {
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(145, 75, 94, 0.72), rgba(74, 34, 51, 0.8));
  box-shadow: 0 0 32px rgba(232, 192, 122, 0.16), 0 16px 36px rgba(0, 0, 0, 0.32);
}

.btn-ghost {
  background: transparent;
}

.btn-small {
  min-height: 38px;
  padding: 8px 16px;
  font-size: 13px;
  border-radius: 9px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line-soft);
  background: rgba(18, 13, 18, 0.45);
  color: var(--gold);
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s, transform 0.25s, box-shadow 0.25s;
}

.icon-btn:hover {
  border-color: var(--line-gold);
  background: rgba(58, 29, 44, 0.65);
  transform: translateY(-1px);
  box-shadow: 0 0 22px rgba(232, 192, 122, 0.14);
}

.icon-btn svg {
  width: 21px;
  height: 21px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 2px;
  border: none;
  background: none;
  color: var(--lavender);
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.25s;
}

.back-btn:hover {
  color: var(--gold);
}

.back-arrow {
  font-size: 18px;
  line-height: 1;
}

.screen-kicker {
  margin: 0 0 12px;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
}

.screen-subtitle {
  margin: 12px 0 0;
  color: var(--lavender);
  font-family: var(--font-head);
  font-size: 19px;
  font-style: italic;
}

.title-footer {
  position: absolute;
  left: 50%;
  bottom: 22px;
  z-index: 6;
  transform: translateX(-50%);
  color: rgba(232, 216, 196, 0.52);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  white-space: nowrap;
}

.title-footer span {
  color: var(--gold);
  padding: 0 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  color: var(--lavender);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.text-input {
  width: 100%;
  padding: 13px 16px;
  border-radius: 10px;
  border: 1px solid rgba(232, 192, 122, 0.24);
  background: rgba(12, 8, 13, 0.55);
  color: var(--cream);
  font-family: var(--font-head);
  font-size: 19px;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.text-input:hover {
  border-color: rgba(232, 192, 122, 0.45);
}

.text-input:focus {
  border-color: var(--gold);
  background: rgba(18, 10, 17, 0.8);
  box-shadow: 0 0 0 4px rgba(232, 192, 122, 0.08);
  outline: none;
}

.modal-footnote {
  margin: 22px 0 0;
  color: var(--lavender-dim);
  font-size: 12px;
  letter-spacing: 0.03em;
  text-align: center;
}

.empty-note {
  margin: 26px 0;
  color: var(--lavender);
  font-family: var(--font-head);
  font-size: 19px;
  font-style: italic;
  text-align: center;
}

/* -------------------------------------------------------------------------
   Image frames + styled missing-asset placeholders
   ------------------------------------------------------------------------- */

.image-frame {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(145deg, #24131f, #120d12);
}

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

.image-frame.is-missing {
  background:
    radial-gradient(circle at 30% 18%, hsla(var(--ph-h, 332), 52%, 42%, 0.55), transparent 54%),
    radial-gradient(circle at 78% 72%, hsla(calc(var(--ph-h, 332) + 28), 48%, 34%, 0.48), transparent 62%),
    radial-gradient(circle at 50% 110%, rgba(232, 192, 122, 0.12), transparent 46%),
    linear-gradient(158deg, #261422 0%, #1a0f1a 48%, #0e090f 100%);
}

.image-frame.is-missing::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.22;
  background-image:
    linear-gradient(115deg, transparent 0 46%, rgba(246, 237, 227, 0.08) 46% 46.5%, transparent 46.5%),
    radial-gradient(circle at 50% 38%, rgba(255, 217, 160, 0.2), transparent 46%);
  pointer-events: none;
}

.image-frame.is-missing[data-asset-type="char"]::before {
  inset: 10% 18% 0;
  border-radius: 46% 46% 16% 16%;
  opacity: 0.34;
  background:
    radial-gradient(circle at 50% 27%, rgba(246, 237, 227, 0.26) 0 13%, transparent 13.6%),
    radial-gradient(ellipse at 50% 78%, rgba(246, 237, 227, 0.18) 0 34%, transparent 34.6%),
    linear-gradient(180deg, rgba(217, 138, 154, 0.1), transparent 70%);
}

.asset-fallback {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 16px;
  text-align: center;
  color: rgba(232, 192, 122, 0.72);
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.6);
}

.asset-fallback-ornament {
  font-size: 20px;
  opacity: 0.7;
  margin-bottom: 2px;
}

.asset-fallback-type {
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(232, 216, 196, 0.48);
}

.asset-fallback-id {
  max-width: 90%;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: rgba(232, 192, 122, 0.76);
  word-break: break-word;
}

/* -------------------------------------------------------------------------
   Loading + boot errors
   ------------------------------------------------------------------------- */

.loading-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background:
    radial-gradient(circle at 50% 38%, rgba(74, 34, 51, 0.55), transparent 55%),
    linear-gradient(180deg, #160e16, #0b070c);
}

.loading-ornament {
  margin-bottom: 18px;
  color: var(--gold);
  font-size: 30px;
  animation: softPulse 2.4s ease-in-out infinite;
}

.loading-kicker {
  margin: 0;
  font-family: var(--font-head);
  font-size: 28px;
  letter-spacing: 0.12em;
  color: var(--cream);
}

.loading-text {
  margin: 0;
  color: var(--lavender);
  font-size: 13px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.loading-line {
  width: 180px;
  height: 1px;
  margin-top: 16px;
  overflow: hidden;
  background: rgba(232, 192, 122, 0.14);
}

.loading-line span {
  display: block;
  width: 40%;
  height: 100%;
  background: var(--gold);
  animation: loadingSweep 1.8s ease-in-out infinite;
}

.noscript-note {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100000;
  padding: 30px;
  background: var(--plum-950);
  color: var(--cream);
  font-family: var(--font-head);
  font-size: 22px;
  text-align: center;
}

.error-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 42px;
  background:
    radial-gradient(circle at 18% 15%, rgba(122, 63, 79, 0.4), transparent 48%),
    radial-gradient(circle at 82% 85%, rgba(74, 34, 51, 0.45), transparent 52%),
    linear-gradient(160deg, #1b101a, #0c080d 70%);
  overflow-y: auto;
}

.error-glow {
  position: absolute;
  width: 50vw;
  height: 50vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(217, 138, 154, 0.12), transparent 64%);
  filter: blur(20px);
  pointer-events: none;
}

.error-card {
  position: relative;
  z-index: 2;
  width: min(820px, 100%);
  padding: 40px 44px 34px;
  border: 1px solid rgba(217, 138, 154, 0.32);
  border-radius: 20px;
  background: linear-gradient(160deg, rgba(42, 21, 32, 0.94), rgba(18, 13, 18, 0.97));
  box-shadow: var(--shadow-deep);
}

.error-kicker {
  margin: 0 0 10px;
  color: var(--rose);
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.error-card h1 {
  margin: 0;
  font-family: var(--font-head);
  font-size: 38px;
  font-weight: 400;
  color: var(--cream);
}

.error-intro {
  margin: 12px 0 20px;
  color: var(--lavender);
  font-size: 16px;
  line-height: 1.65;
}

.error-list {
  max-height: 34vh;
  margin: 0;
  padding: 18px 20px 18px 38px;
  overflow: auto;
  border: 1px solid rgba(232, 192, 122, 0.14);
  border-radius: 10px;
  background: rgba(9, 5, 9, 0.45);
  color: #f0c8cf;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.65;
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.error-footnote {
  margin: 20px 0 0;
  color: var(--lavender-dim);
  font-size: 12px;
}

.error-footnote code {
  color: rgba(232, 192, 122, 0.72);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

/* -------------------------------------------------------------------------
   Title screen
   ------------------------------------------------------------------------- */

.title-screen {
  background: #0d080e;
}

.title-bg img {
  filter: blur(3px) saturate(0.92) brightness(0.58);
  transform: scale(1.055);
  animation: pageKenBurns 42s ease-in-out infinite alternate;
}

.title-scrim {
  background:
    linear-gradient(90deg, rgba(18, 13, 18, 0.93) 0%, rgba(18, 13, 18, 0.74) 38%, rgba(18, 13, 18, 0.26) 100%),
    radial-gradient(110% 80% at 50% 0%, rgba(217, 138, 154, 0.1), transparent 56%),
    linear-gradient(0deg, rgba(11, 7, 12, 0.94) 0%, transparent 38%),
    linear-gradient(180deg, rgba(11, 7, 12, 0.55), transparent 28%);
}

.title-glow {
  position: absolute;
  top: -14%;
  left: 50%;
  z-index: 2;
  width: 70vw;
  height: 55vh;
  transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(232, 192, 122, 0.09), transparent 65%);
  pointer-events: none;
}

.title-shell {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: min(720px, 86vw);
  height: 100%;
  margin: 0 auto;
  padding: 4vh 0 8vh;
  text-align: center;
}

.title-eyebrow {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  color: rgba(232, 216, 196, 0.68);
  font-size: 11px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
}

.title-eyebrow span {
  width: 46px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-gold));
}

.title-eyebrow span:last-child {
  background: linear-gradient(90deg, var(--line-gold), transparent);
}

.title-logo {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 400;
  font-size: clamp(58px, 8.6vw, 116px);
  line-height: 0.84;
  letter-spacing: 0.015em;
  color: var(--cream);
  text-shadow: 0 10px 50px rgba(0, 0, 0, 0.55);
}

.title-logo-line {
  display: block;
}

.title-logo-accent {
  color: var(--gold);
  font-style: italic;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #ffe9c4 4%, #e8c07a 52%, #b9822a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 8px 26px rgba(185, 130, 42, 0.18));
}

.title-subtitle {
  margin: 24px 0 0;
  color: var(--rose-soft);
  font-family: var(--font-head);
  font-size: clamp(16px, 1.35vw, 20px);
  font-style: italic;
  letter-spacing: 0.02em;
}

.title-ornament,
.ending-ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  margin: 24px 0 22px;
  color: var(--gold);
}

.title-ornament span,
.ending-ornament span {
  width: 74px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-gold));
}

.title-ornament span:last-child,
.ending-ornament span:last-child {
  background: linear-gradient(90deg, var(--line-gold), transparent);
}

.title-ornament i,
.ending-ornament i {
  font-size: 12px;
  font-style: normal;
  opacity: 0.9;
}

.title-menu {
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: min(510px, 100%);
}

.menu-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  min-height: 62px;
  padding: 11px 20px 11px 22px;
  border: 1px solid rgba(232, 192, 122, 0.16);
  border-radius: 11px;
  background: linear-gradient(90deg, rgba(28, 16, 26, 0.72), rgba(18, 13, 18, 0.34));
  color: var(--cream);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.28s, background 0.28s, transform 0.28s var(--ease-out), box-shadow 0.28s;
}

.menu-btn::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(232, 192, 122, 0.45), transparent);
  opacity: 0.7;
}

.menu-btn:hover {
  border-color: rgba(232, 192, 122, 0.5);
  background: linear-gradient(90deg, rgba(58, 29, 44, 0.82), rgba(29, 17, 28, 0.56));
  transform: translateX(6px);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.24), inset 0 0 24px rgba(232, 192, 122, 0.04);
}

.menu-btn.is-primary {
  border-color: rgba(232, 192, 122, 0.56);
  background: linear-gradient(90deg, rgba(107, 51, 68, 0.76), rgba(58, 29, 44, 0.5));
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.menu-btn.is-primary:hover {
  border-color: var(--gold);
  background: linear-gradient(90deg, rgba(132, 62, 82, 0.86), rgba(66, 32, 49, 0.68));
}

.menu-btn-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.menu-btn-name {
  font-family: var(--font-head);
  font-size: 21px;
  letter-spacing: 0.02em;
  color: var(--cream);
}

.menu-btn.is-primary .menu-btn-name {
  color: var(--gold-soft);
}

.menu-btn-note {
  overflow: hidden;
  color: var(--lavender);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-btn-arrow {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  color: var(--gold);
  opacity: 0.38;
  transition: opacity 0.25s, transform 0.25s;
}

.menu-btn-arrow svg {
  width: 18px;
  height: 18px;
}

.menu-btn:hover .menu-btn-arrow {
  opacity: 1;
  transform: translateX(3px);
}

.title-weather {
  position: absolute;
  top: 32px;
  right: 42px;
  z-index: 6;
  color: rgba(232, 216, 196, 0.48);
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.title-corner {
  position: absolute;
  top: 30px;
  left: 42px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(232, 192, 122, 0.26);
  border-radius: 50%;
  color: var(--gold);
  font-family: var(--font-head);
  font-size: 11px;
  letter-spacing: 0.12em;
}

.motes {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
}

.mote {
  position: absolute;
  border-radius: 50%;
  background: var(--gold-soft);
  box-shadow: 0 0 8px rgba(232, 192, 122, 0.5);
  opacity: 0;
  animation: moteDrift linear infinite;
}

/* -------------------------------------------------------------------------
   Chapters + gallery screens
   ------------------------------------------------------------------------- */

.menu-screen {
  background: var(--plum-950);
}

.menu-scrim {
  background:
    linear-gradient(180deg, rgba(12, 8, 13, 0.82) 0%, rgba(14, 9, 15, 0.76) 48%, rgba(10, 7, 11, 0.94) 100%),
    radial-gradient(90% 65% at 80% 10%, rgba(122, 63, 79, 0.23), transparent 60%),
    linear-gradient(90deg, rgba(18, 13, 18, 0.8), rgba(18, 13, 18, 0.26));
}

.menu-screen .page-bg img {
  filter: blur(2.5px) saturate(0.9) brightness(0.5);
  transform: scale(1.04);
}

.gallery-scrim {
  background:
    linear-gradient(180deg, rgba(12, 8, 13, 0.86) 0%, rgba(14, 9, 15, 0.8) 45%, rgba(10, 7, 11, 0.96) 100%),
    radial-gradient(70% 55% at 20% 20%, rgba(74, 34, 51, 0.32), transparent 60%);
}

.menu-shell {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  width: min(1480px, 89vw);
  min-height: 100%;
  margin: 0 auto;
  padding: 34px 0 76px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(232, 192, 122, 0.3) transparent;
}

.menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
}

.menu-heading {
  margin: clamp(30px, 5.5vh, 64px) 0 clamp(26px, 4vh, 44px);
}

.menu-heading h1 {
  margin: 0;
  color: var(--cream);
  font-family: var(--font-head);
  font-size: clamp(44px, 4.4vw, 68px);
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1;
}

.menu-heading .screen-kicker {
  color: var(--gold);
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 26px;
}

.chapter-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(232, 192, 122, 0.2);
  border-radius: 17px;
  background: linear-gradient(165deg, rgba(49, 26, 39, 0.85), rgba(20, 12, 20, 0.94));
  color: var(--cream);
  text-align: left;
  cursor: pointer;
  transition: transform 0.4s var(--ease-out), border-color 0.4s, box-shadow 0.4s;
}

.chapter-card:hover:not(:disabled) {
  transform: translateY(-7px);
  border-color: rgba(232, 192, 122, 0.62);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.45), 0 0 44px rgba(232, 192, 122, 0.08);
}

.chapter-card.is-locked {
  cursor: not-allowed;
  opacity: 0.62;
}

.chapter-card-cover {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-bottom: 1px solid rgba(232, 192, 122, 0.14);
}

.chapter-card-cover .image-frame {
  position: absolute;
  inset: 0;
}

.chapter-card-cover img {
  transition: transform 0.9s var(--ease-out);
}

.chapter-card:hover:not(:disabled) .chapter-card-cover img {
  transform: scale(1.045);
}

.chapter-card-cover.is-locked {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background:
    radial-gradient(circle at 50% 35%, rgba(232, 192, 122, 0.09), transparent 55%),
    linear-gradient(155deg, #251522, #100b11);
  color: rgba(232, 216, 196, 0.38);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.chapter-lock {
  display: flex;
  color: rgba(232, 192, 122, 0.55);
}

.chapter-lock .icon-lock {
  width: 28px;
  height: 28px;
}

.chapter-card-body {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  padding: 22px 24px 24px;
}

.chapter-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.chapter-card-number {
  color: var(--gold);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.chapter-state {
  padding: 3px 8px;
  border: 1px solid rgba(232, 192, 122, 0.22);
  border-radius: 999px;
  color: var(--lavender);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.chapter-state.is-complete {
  border-color: rgba(217, 138, 154, 0.48);
  color: var(--rose-soft);
}

.chapter-state.is-locked {
  opacity: 0.55;
}

.chapter-card h2 {
  margin: 0;
  font-family: var(--font-head);
  font-size: 30px;
  font-weight: 400;
  line-height: 1.1;
  color: var(--cream);
}

.chapter-card-subtitle {
  margin: 6px 0 0;
  color: var(--rose-soft);
  font-family: var(--font-head);
  font-size: 15px;
  font-style: italic;
}

.chapter-card-description {
  min-height: 3.1em;
  margin: 12px 0 18px;
  color: var(--lavender);
  font-size: 13px;
  line-height: 1.55;
}

.chapter-card-open {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.chapter-card-open svg {
  width: 16px;
  height: 16px;
  transition: transform 0.25s;
}

.chapter-card:hover:not(:disabled) .chapter-card-open svg {
  transform: translateX(4px);
}

.chapter-card-open.is-locked {
  color: var(--lavender-dim);
}

.chapter-card-open .icon-lock {
  width: 14px;
  height: 14px;
}

.chapter-card-watermark {
  position: absolute;
  right: 10px;
  bottom: -12px;
  z-index: 1;
  color: rgba(232, 192, 122, 0.045);
  font-family: var(--font-head);
  font-size: 100px;
  line-height: 1;
  pointer-events: none;
}

.gallery-count {
  color: var(--lavender);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.gallery-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(232, 192, 122, 0.18);
  border-radius: 13px;
  background: linear-gradient(160deg, rgba(45, 24, 36, 0.75), rgba(17, 11, 18, 0.92));
  color: var(--cream);
  text-align: left;
  cursor: pointer;
  transition: transform 0.35s var(--ease-out), border-color 0.35s, box-shadow 0.35s;
}

.gallery-card:hover:not(:disabled) {
  transform: translateY(-5px);
  border-color: rgba(232, 192, 122, 0.55);
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.4);
}

.gallery-card.is-locked {
  cursor: not-allowed;
  opacity: 0.62;
}

.gallery-art {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-bottom: 1px solid rgba(232, 192, 122, 0.1);
}

.gallery-art .image-frame {
  position: absolute;
  inset: 0;
}

.gallery-art img {
  transition: transform 0.8s var(--ease-out);
}

.gallery-card:hover:not(:disabled) .gallery-art img {
  transform: scale(1.05);
}

.gallery-lock-art {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background:
    radial-gradient(circle at 50% 38%, rgba(232, 192, 122, 0.08), transparent 50%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 9px),
    linear-gradient(155deg, #231421, #0e090f);
  color: rgba(232, 192, 122, 0.5);
}

.gallery-lock-art span svg {
  width: 26px;
  height: 26px;
}

.gallery-lock-art em {
  color: rgba(232, 216, 196, 0.34);
  font-size: 9px;
  font-style: normal;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.gallery-caption {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 15px 16px 17px;
}

.gallery-number {
  padding-top: 2px;
  color: var(--gold);
  font-family: var(--font-head);
  font-size: 15px;
  font-style: italic;
}

.gallery-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.gallery-text strong {
  overflow: hidden;
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 400;
  color: var(--cream);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-text small {
  overflow: hidden;
  color: var(--lavender);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* -------------------------------------------------------------------------
   Game stage
   ------------------------------------------------------------------------- */

.game-screen {
  background: #060407;
}

.stage-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.stage {
  --px: 0px;
  --py: 0px;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1920px;
  height: 1080px;
  overflow: hidden;
  transform: translate(-50%, -50%) scale(1);
  transform-origin: center center;
  background:
    radial-gradient(90% 75% at 50% 35%, #271524, #0d090e 75%);
  box-shadow: 0 0 120px rgba(0, 0, 0, 0.7);
}

.stage-bg,
.stage-cg,
.stage-shade,
.vignette,
.grain,
.cast {
  position: absolute;
  inset: 0;
}

.stage-bg {
  z-index: 0;
}

.stage-cg {
  z-index: 1;
  pointer-events: none;
}

.bg-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1.15s ease;
}

.bg-slide.is-active {
  opacity: 1;
}

.bg-frame,
.cg-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.bg-frame img,
.cg-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: kenBurns 28s ease-in-out infinite alternate;
  transform-origin: 50% 45%;
  will-change: transform;
}

.cg-slide {
  position: absolute;
  inset: 0;
  animation: cgFade 0.9s ease;
}

.cg-slide .cg-frame img {
  animation-duration: 34s;
}

.stage-shade {
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(0deg, rgba(9, 5, 9, 0.9) 0%, rgba(9, 5, 9, 0.5) 22%, transparent 46%),
    linear-gradient(180deg, rgba(9, 5, 9, 0.58) 0%, transparent 24%);
}

.vignette {
  z-index: 8;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 44%, transparent 38%, rgba(8, 5, 9, 0.32) 76%, rgba(6, 4, 7, 0.7) 100%),
    linear-gradient(90deg, rgba(6, 4, 7, 0.28), transparent 18% 82%, rgba(6, 4, 7, 0.28)),
    linear-gradient(0deg, rgba(6, 4, 7, 0.94) 0%, rgba(6, 4, 7, 0.58) 8%, transparent 22%);
}

.grain {
  z-index: 9;
  pointer-events: none;
  opacity: 0.055;
  background-image: url("../assets/ui/grain.svg");
  background-repeat: repeat;
  background-size: 300px 300px;
  mix-blend-mode: soft-light;
}

.cast {
  z-index: 4;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.stage.is-chapter-card .cast,
.stage.has-cg .cast {
  opacity: 0;
}

.portrait {
  position: absolute;
  bottom: 9.5%;
  height: 79%;
  aspect-ratio: 3 / 4;
  opacity: 0;
  transition: opacity 0.5s ease;
  will-change: opacity;
}

.portrait.is-visible {
  opacity: 1;
}

.portrait.is-leaving {
  opacity: 0;
}

.portrait-left {
  left: 5.2%;
}

.portrait-right {
  right: 5.2%;
}

.portrait-center {
  left: 50%;
  transform: translateX(-50%);
}

.portrait-float {
  width: 100%;
  height: 100%;
  animation: portraitFloat 7.5s ease-in-out infinite alternate;
  animation-delay: var(--float-delay, 0s);
}

.portrait-frame {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 9px;
  border: 1px solid rgba(232, 192, 122, 0.62);
  border-radius: 18px;
  background:
    linear-gradient(160deg, rgba(74, 34, 51, 0.55), rgba(18, 13, 18, 0.7));
  box-shadow:
    0 28px 70px rgba(0, 0, 0, 0.58),
    0 0 46px rgba(232, 192, 122, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transform: translate3d(var(--px, 0), var(--py, 0), 0);
  transition: transform 0.18s ease-out;
}

.portrait-left .portrait-frame {
  transform: translate3d(var(--px, 0), var(--py, 0), 0);
}

.portrait-right .portrait-frame {
  transform: translate3d(calc(var(--px, 0px) * -1), var(--py, 0), 0);
}

.portrait-frame::before {
  content: "";
  position: absolute;
  inset: 4px;
  z-index: 2;
  border: 1px solid rgba(232, 192, 122, 0.22);
  border-radius: 13px;
  pointer-events: none;
}

.portrait-frame img {
  border-radius: 11px;
}

.portrait-frame.is-missing .asset-fallback {
  border-radius: 11px;
}

/* Top bar */

.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 32;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 30px;
  padding: 34px 54px 40px;
  background: linear-gradient(180deg, rgba(9, 5, 9, 0.68), transparent);
  pointer-events: none;
  transition: opacity 0.45s ease;
}

.stage.is-chapter-card .topbar {
  opacity: 0;
}

.topbar-chapter {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-left: 2px;
}

.chapter-kicker {
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.chapter-name {
  color: var(--cream);
  font-family: var(--font-head);
  font-size: 25px;
  letter-spacing: 0.015em;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.5);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 22px;
  pointer-events: auto;
}

.love-meter {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border: 1px solid rgba(232, 192, 122, 0.16);
  border-radius: 999px;
  background: rgba(18, 13, 18, 0.34);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.pause-btn {
  width: 46px;
  height: 46px;
}

/* Hearts */

.hearts {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
}

.heart {
  position: relative;
  display: inline-block;
  width: 1em;
  height: 1em;
  font-size: 26px;
  line-height: 1;
}

.heart-base,
.heart-fill {
  position: absolute;
  inset: 0;
  display: block;
  line-height: 1;
}

.heart-base {
  color: rgba(246, 237, 227, 0.16);
  text-shadow: 0 0 12px rgba(232, 192, 122, 0.05);
}

.heart-fill {
  overflow: hidden;
  color: var(--rose);
  text-shadow: 0 0 10px rgba(217, 138, 154, 0.5);
}

.hearts-small {
  gap: 2px;
}

.heart-small {
  font-size: 15px;
}

/* Dialogue */

.dialogue-area {
  position: absolute;
  left: 5%;
  right: 5%;
  bottom: 3.8%;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 11px;
  pointer-events: none;
}

.dialogue {
  position: relative;
  width: 100%;
  min-height: 214px;
  padding: 42px 58px 48px;
  border: 1px solid rgba(232, 192, 122, 0.48);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(42, 21, 32, 0.82), rgba(18, 13, 18, 0.93));
  box-shadow:
    0 26px 70px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 0 60px rgba(232, 192, 122, 0.035);
  backdrop-filter: blur(11px);
  -webkit-backdrop-filter: blur(11px);
  pointer-events: auto;
  cursor: pointer;
}

.dialogue::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(232, 192, 122, 0.11);
  border-radius: 12px;
  pointer-events: none;
}

.dialogue::after {
  content: "";
  position: absolute;
  left: 32px;
  right: 32px;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(232, 192, 122, 0.35), transparent);
  pointer-events: none;
}

.nameplate {
  position: absolute;
  top: -22px;
  left: 46px;
  z-index: 2;
  padding: 7px 24px 8px;
  border: 1px solid rgba(232, 192, 122, 0.52);
  border-radius: 999px;
  background: linear-gradient(180deg, #432335, #24121e);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: var(--gold);
  font-family: var(--font-head);
  font-size: 24px;
  letter-spacing: 0.08em;
  line-height: 1.1;
}

.nameplate.name-her {
  border-color: rgba(217, 138, 154, 0.62);
  color: var(--rose-soft);
}

.nameplate.name-me {
  border-color: rgba(232, 192, 122, 0.62);
  color: var(--gold-soft);
}

.dialogue-text {
  margin: 0;
  min-height: 3.2em;
  color: var(--cream);
  font-size: 31px;
  font-weight: 400;
  line-height: 1.62;
  letter-spacing: 0.004em;
  text-shadow: 0 1px 18px rgba(0, 0, 0, 0.25);
}

.dialogue.is-narrator .dialogue-text {
  color: #e9dfd3;
  font-style: italic;
}

.continue-indicator {
  position: absolute;
  right: 34px;
  bottom: 18px;
  color: var(--gold);
  font-size: 23px;
  line-height: 1;
  text-shadow: 0 0 14px rgba(232, 192, 122, 0.42);
  animation: continueBounce 1.45s ease-in-out infinite;
}

.game-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 28px;
  padding: 0 14px 0 20px;
  pointer-events: auto;
}

.control-btn {
  position: relative;
  padding: 5px 0;
  border: none;
  background: none;
  color: rgba(232, 216, 196, 0.56);
  font-size: 14px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.22s;
}

.control-btn::after {
  content: "";
  position: absolute;
  left: 50%;
  right: 50%;
  bottom: 0;
  height: 1px;
  background: var(--gold);
  transition: left 0.25s, right 0.25s;
}

.control-btn:hover:not(:disabled) {
  color: var(--gold);
}

.control-btn:hover:not(:disabled)::after,
.control-btn.is-active::after {
  left: 0;
  right: 0;
}

.control-btn.is-active {
  color: var(--gold);
}

.control-btn:disabled {
  opacity: 0.28;
  cursor: default;
}

/* Choices */

.choices-layer {
  position: absolute;
  left: 50%;
  bottom: 338px;
  z-index: 36;
  width: min(980px, 66%);
  transform: translateX(-50%);
  pointer-events: none;
}

.choices-panel {
  pointer-events: auto;
  animation: choicesIn 0.45s var(--ease-out);
}

.choices-prompt {
  margin: 0 0 18px;
  color: var(--gold-soft);
  font-family: var(--font-head);
  font-size: 26px;
  font-style: italic;
  letter-spacing: 0.02em;
  text-align: center;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.7);
}

.choice-list {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.choice-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  padding: 15px 22px 15px 17px;
  border: 1px solid rgba(232, 192, 122, 0.3);
  border-radius: 13px;
  background:
    linear-gradient(90deg, rgba(48, 25, 38, 0.94), rgba(22, 13, 21, 0.92));
  color: var(--cream);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  transition: transform 0.25s var(--ease-out), border-color 0.25s, box-shadow 0.25s, background 0.25s;
  animation: choiceIn 0.4s var(--ease-out) both;
}

.choice-card:nth-child(2) { animation-delay: 0.05s; }
.choice-card:nth-child(3) { animation-delay: 0.1s; }
.choice-card:nth-child(4) { animation-delay: 0.15s; }

.choice-card:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.006);
  border-color: rgba(232, 192, 122, 0.72);
  background: linear-gradient(90deg, rgba(74, 34, 51, 0.96), rgba(30, 17, 28, 0.94));
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.42), 0 0 40px rgba(232, 192, 122, 0.09);
}

.choice-card.is-disabled {
  cursor: not-allowed;
  opacity: 0.56;
  border-color: rgba(169, 155, 181, 0.18);
  box-shadow: none;
}

.choice-number {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(232, 192, 122, 0.46);
  border-radius: 50%;
  color: var(--gold);
  font-family: var(--font-head);
  font-size: 16px;
  font-style: italic;
  line-height: 1;
}

.choice-copy {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.choice-text {
  color: var(--cream);
  font-size: 22px;
  line-height: 1.4;
}

.choice-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--lavender);
  font-size: 12px;
  letter-spacing: 0.03em;
}

.choice-hint .icon-lock {
  width: 13px;
  height: 13px;
  color: var(--rose);
}

.choice-arrow {
  display: flex;
  flex: 0 0 auto;
  color: var(--gold);
  opacity: 0.35;
  transition: opacity 0.2s, transform 0.2s;
}

.choice-card:hover:not(:disabled) .choice-arrow {
  opacity: 1;
  transform: translateX(4px);
}

.choice-arrow svg {
  width: 19px;
  height: 19px;
}

/* Chapter card (inside the stage) */

.chapter-layer {
  position: absolute;
  inset: 0;
  z-index: 44;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #0b070c;
  cursor: pointer;
}

.chapter-card-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0.62;
}

.chapter-card-bg .image-frame {
  position: absolute;
  inset: 0;
}

.chapter-card-bg img {
  filter: saturate(0.9) brightness(0.9);
  animation: kenBurns 34s ease-in-out infinite alternate;
}

.chapter-card-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(ellipse at 50% 46%, rgba(15, 9, 15, 0.1) 0%, rgba(12, 8, 13, 0.52) 58%, rgba(9, 5, 9, 0.9) 100%),
    linear-gradient(0deg, rgba(9, 5, 9, 0.92), transparent 42%, rgba(9, 5, 9, 0.62));
}

.chapter-card-content {
  position: relative;
  z-index: 2;
  width: min(1120px, 78%);
  text-align: center;
  animation: chapterIn 0.65s var(--ease-out);
}

.chapter-card-eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
}

.chapter-card-numeral {
  margin-bottom: -22px;
  color: rgba(232, 192, 122, 0.09);
  font-family: var(--font-head);
  font-size: 190px;
  line-height: 1;
  letter-spacing: 0.02em;
}

.chapter-card-content h2 {
  margin: 0;
  color: var(--cream);
  font-family: var(--font-head);
  font-size: 78px;
  font-weight: 400;
  line-height: 1.02;
  text-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
}

.chapter-card-subtitle-big {
  margin: 14px 0 0;
  color: var(--rose-soft);
  font-family: var(--font-head);
  font-size: 27px;
  font-style: italic;
}

.chapter-card-description-big {
  max-width: 720px;
  margin: 18px auto 26px;
  color: var(--lavender);
  font-size: 16px;
  line-height: 1.7;
}

.chapter-continue {
  min-width: 220px;
}

.chapter-card-hint {
  margin: 18px 0 0;
  color: rgba(232, 216, 196, 0.4);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

/* -------------------------------------------------------------------------
   Ending screen
   ------------------------------------------------------------------------- */

.ending-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--plum-950);
}

.ending-bg img {
  filter: blur(1.8px) saturate(0.92) brightness(0.58);
  transform: scale(1.04);
  animation: pageKenBurns 46s ease-in-out infinite alternate;
}

.ending-scrim {
  background:
    radial-gradient(ellipse at 50% 45%, rgba(18, 13, 18, 0.2) 0%, rgba(12, 8, 13, 0.7) 58%, rgba(8, 5, 9, 0.96) 100%),
    linear-gradient(0deg, rgba(8, 5, 9, 0.94), transparent 35%, rgba(8, 5, 9, 0.55));
}

.ending-shell {
  position: relative;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(900px, 86vw);
  max-height: 100vh;
  padding: 64px 0 80px;
  overflow-y: auto;
  text-align: center;
  scrollbar-width: none;
}

.ending-shell::-webkit-scrollbar {
  display: none;
}

.ending-kicker {
  margin: 0;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
}

.ending-ornament {
  margin: 22px 0 16px;
}

.ending-title {
  margin: 0;
  color: var(--cream);
  font-family: var(--font-head);
  font-size: clamp(52px, 6vw, 82px);
  font-weight: 400;
  line-height: 1.02;
  text-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.ending-subtitle {
  margin: 14px 0 0;
  color: var(--rose-soft);
  font-family: var(--font-head);
  font-size: 22px;
  font-style: italic;
}

.ending-rule {
  width: 74px;
  height: 1px;
  margin: 26px 0 24px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.ending-text {
  max-width: 700px;
  margin: 0;
  color: var(--cream-dim);
  font-family: var(--font-head);
  font-size: 23px;
  font-style: italic;
  line-height: 1.72;
}

.ending-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 44px;
  margin: 34px 0 30px;
  padding: 17px 28px;
  border-top: 1px solid rgba(232, 192, 122, 0.16);
  border-bottom: 1px solid rgba(232, 192, 122, 0.16);
}

.ending-stat {
  display: flex;
  align-items: center;
  gap: 14px;
}

.ending-stat-label {
  color: var(--lavender);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.ending-stat-value {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--gold);
  font-family: var(--font-head);
  font-size: 15px;
}

.trust-track {
  display: inline-block;
  width: 118px;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(246, 237, 227, 0.12);
}

.trust-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold-soft));
  box-shadow: 0 0 10px rgba(232, 192, 122, 0.3);
}

.ending-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

/* -------------------------------------------------------------------------
   Modals
   ------------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
  background: rgba(8, 5, 9, 0.72);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.modal-backdrop:not(.is-open) {
  pointer-events: none;
}

.modal-backdrop.is-open {
  opacity: 1;
}

.modal {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(640px, 100%);
  max-height: 88vh;
  overflow: hidden;
  border: 1px solid rgba(232, 192, 122, 0.4);
  border-radius: 20px;
  background:
    radial-gradient(100% 60% at 50% 0%, rgba(90, 44, 61, 0.24), transparent 60%),
    linear-gradient(165deg, rgba(43, 22, 33, 0.98), rgba(17, 11, 18, 0.99));
  box-shadow: 0 40px 110px rgba(0, 0, 0, 0.62), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transform: translateY(18px) scale(0.985);
  transition: transform 0.32s var(--ease-out);
}

.modal-backdrop.is-open .modal {
  transform: translateY(0) scale(1);
}

.modal::before {
  content: "";
  position: absolute;
  inset: 8px;
  z-index: 0;
  border: 1px solid rgba(232, 192, 122, 0.08);
  border-radius: 13px;
  pointer-events: none;
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--lavender);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.modal-close:hover {
  border-color: rgba(232, 192, 122, 0.28);
  background: rgba(58, 29, 44, 0.5);
  color: var(--gold);
}

.modal-close svg {
  width: 19px;
  height: 19px;
}

.modal-head {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  padding: 36px 42px 14px;
}

.modal-head h2 {
  margin: 0;
  color: var(--cream);
  font-family: var(--font-head);
  font-size: 34px;
  font-weight: 400;
  line-height: 1.1;
}

.modal-kicker {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.modal-subtitle {
  margin: 10px 0 0;
  color: var(--lavender);
  font-size: 13px;
  line-height: 1.6;
}

.modal-body {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  padding: 16px 42px 38px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(232, 192, 122, 0.28) transparent;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-thumb {
  border-radius: 6px;
  background: rgba(232, 192, 122, 0.22);
}

.pause-modal {
  width: min(500px, 100%);
}

.pause-love {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 2px 0 20px;
  padding: 12px 16px;
  border: 1px solid rgba(232, 192, 122, 0.14);
  border-radius: 11px;
  background: rgba(12, 8, 13, 0.38);
}

.pause-love-label {
  color: var(--lavender);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-row {
  display: flex;
  align-items: center;
  gap: 15px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(232, 192, 122, 0.14);
  border-radius: 10px;
  background: rgba(22, 13, 21, 0.4);
  color: var(--cream);
  font-family: var(--font-head);
  font-size: 18px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.22s, background 0.22s, padding-left 0.22s;
}

.menu-row:hover {
  padding-left: 21px;
  border-color: rgba(232, 192, 122, 0.45);
  background: rgba(58, 29, 44, 0.5);
}

.menu-row-index {
  color: var(--gold);
  font-family: var(--font-body);
  font-size: 9px;
  letter-spacing: 0.16em;
  opacity: 0.7;
}

.menu-row-arrow {
  margin-left: auto;
  color: var(--gold);
  opacity: 0.4;
  transition: opacity 0.2s, transform 0.2s;
}

.menu-row:hover .menu-row-arrow {
  opacity: 1;
  transform: translateX(3px);
}

.menu-row-quiet {
  color: var(--lavender);
}

.pause-hint {
  margin: 20px 0 0;
  color: var(--lavender-dim);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-align: center;
}

/* Name modal */

.name-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

/* Settings modal */

.settings-modal {
  width: min(760px, 100%);
}

.settings-section {
  padding: 20px 0;
  border-top: 1px solid rgba(232, 192, 122, 0.12);
}

.settings-section:first-child {
  padding-top: 4px;
  border-top: none;
}

.settings-section h3 {
  margin: 0 0 14px;
  color: var(--gold);
  font-family: var(--font-head);
  font-size: 17px;
  font-weight: 400;
  letter-spacing: 0.06em;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 26px;
  padding: 11px 0;
}

.setting-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.setting-title {
  color: var(--cream);
  font-size: 14px;
}

.setting-note {
  color: var(--lavender-dim);
  font-size: 11px;
  line-height: 1.4;
}

.segmented {
  display: flex;
  flex: 0 0 auto;
  padding: 3px;
  border: 1px solid rgba(232, 192, 122, 0.16);
  border-radius: 9px;
  background: rgba(10, 6, 11, 0.4);
}

.segment {
  padding: 7px 11px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--lavender);
  font-size: 11px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.segment:hover {
  color: var(--cream);
}

.segment.is-active {
  background: rgba(122, 63, 79, 0.55);
  color: var(--gold-soft);
  box-shadow: inset 0 0 0 1px rgba(232, 192, 122, 0.22);
}

.range-wrap {
  display: flex;
  flex: 0 0 250px;
  align-items: center;
  gap: 13px;
}

.range {
  width: 100%;
  height: 4px;
  accent-color: var(--gold);
  cursor: pointer;
}

.range-value {
  flex: 0 0 50px;
  color: var(--gold);
  font-size: 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.switch {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  cursor: pointer;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: relative;
  display: block;
  width: 48px;
  height: 26px;
  border: 1px solid rgba(232, 192, 122, 0.25);
  border-radius: 999px;
  background: rgba(10, 6, 11, 0.5);
  transition: background 0.25s, border-color 0.25s;
}

.switch-track span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--lavender);
  transition: transform 0.25s var(--ease-out), background 0.25s;
}

.switch input:checked + .switch-track {
  border-color: rgba(232, 192, 122, 0.55);
  background: rgba(122, 63, 79, 0.5);
}

.switch input:checked + .switch-track span {
  background: var(--gold);
  transform: translateX(22px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.names-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* History modal */

.history-modal {
  width: min(740px, 100%);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-height: 58vh;
  padding-right: 8px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(232, 192, 122, 0.28) transparent;
}

.history-item {
  padding-left: 14px;
  border-left: 1px solid rgba(232, 192, 122, 0.18);
}

.history-who {
  display: block;
  margin-bottom: 4px;
  color: var(--gold);
  font-family: var(--font-head);
  font-size: 14px;
  letter-spacing: 0.08em;
}

.history-item.is-narrator .history-who {
  color: var(--lavender-dim);
  font-family: var(--font-body);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.history-text {
  margin: 0;
  color: var(--cream-dim);
  font-size: 15px;
  line-height: 1.62;
}

.history-item.is-narrator .history-text {
  color: var(--lavender);
  font-family: var(--font-head);
  font-style: italic;
}

/* Save modal */

.save-modal {
  width: min(780px, 100%);
}

.save-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.save-slot {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 15px 17px;
  border: 1px solid rgba(232, 192, 122, 0.13);
  border-radius: 12px;
  background: rgba(12, 8, 13, 0.3);
}

.save-slot.has-data,
.save-slot-auto {
  border-color: rgba(232, 192, 122, 0.24);
  background: rgba(30, 17, 27, 0.4);
}

.save-slot-head {
  display: flex;
  flex: 0 0 96px;
  flex-direction: column;
  gap: 4px;
}

.slot-badge {
  color: var(--gold);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.slot-time {
  color: var(--lavender-dim);
  font-size: 9px;
  letter-spacing: 0.03em;
}

.save-slot-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.save-slot-main strong {
  overflow: hidden;
  color: var(--cream);
  font-family: var(--font-head);
  font-size: 17px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-slot-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--lavender);
  font-size: 10px;
  letter-spacing: 0.03em;
}

.save-slot-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

/* Viewer */

.viewer-modal {
  background: rgba(5, 3, 6, 0.93);
  padding: 3vh 3vw;
}

.viewer-panel {
  width: 94vw;
  height: 92vh;
  max-height: 92vh;
  border: none;
  border-radius: 6px;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
}

.viewer-panel::before {
  display: none;
}

.viewer-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid rgba(232, 192, 122, 0.28);
  border-radius: 50%;
  background: rgba(10, 7, 11, 0.7);
  color: var(--cream);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.viewer-close:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(58, 29, 44, 0.8);
}

.viewer-close svg {
  width: 20px;
  height: 20px;
}

.viewer-frame {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(232, 192, 122, 0.2);
  border-radius: 8px;
  background: #08050a;
}

.viewer-frame .image-frame {
  position: absolute;
  inset: 0;
}

.viewer-frame img {
  object-fit: contain;
}

.viewer-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 80px 36px 28px;
  background: linear-gradient(0deg, rgba(6, 4, 7, 0.94), transparent);
  pointer-events: none;
}

.viewer-caption {
  pointer-events: auto;
}

.viewer-number {
  color: var(--gold);
  font-size: 10px;
  letter-spacing: 0.24em;
}

.viewer-caption h2 {
  margin: 5px 0 2px;
  color: var(--cream);
  font-family: var(--font-head);
  font-size: 28px;
  font-weight: 400;
}

.viewer-caption p {
  margin: 0;
  color: var(--lavender);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.viewer-nav {
  display: flex;
  gap: 9px;
  pointer-events: auto;
}

.viewer-nav .icon-btn {
  background: rgba(18, 13, 18, 0.65);
}

/* -------------------------------------------------------------------------
   Toast
   ------------------------------------------------------------------------- */

.toast-root {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 5000;
  max-width: min(560px, calc(100vw - 40px));
  padding: 12px 24px;
  border: 1px solid rgba(232, 192, 122, 0.42);
  border-radius: 999px;
  background: rgba(18, 13, 18, 0.96);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.45);
  color: var(--cream);
  font-size: 13px;
  letter-spacing: 0.02em;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 0.28s ease, transform 0.28s var(--ease-out);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.toast-root.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast-root.toast-success {
  border-color: rgba(232, 192, 122, 0.55);
}

.toast-root.toast-error {
  border-color: rgba(217, 138, 154, 0.6);
  color: #facdd4;
}

/* -------------------------------------------------------------------------
   Animations
   ------------------------------------------------------------------------- */

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

@keyframes kenBurns {
  0% { transform: scale(1.035) translate3d(0, 0, 0); }
  100% { transform: scale(1.11) translate3d(-1.4%, -1.2%, 0); }
}

@keyframes pageKenBurns {
  0% { transform: scale(1.045) translate3d(0, 0, 0); }
  100% { transform: scale(1.115) translate3d(-1%, -0.8%, 0); }
}

@keyframes portraitFloat {
  0% { transform: translateY(0); }
  100% { transform: translateY(-9px); }
}

@keyframes continueBounce {
  0%, 100% { transform: translateY(0); opacity: 0.55; }
  50% { transform: translateY(5px); opacity: 1; }
}

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

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

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

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

@keyframes softPulse {
  0%, 100% { opacity: 0.45; transform: scale(0.94); }
  50% { opacity: 1; transform: scale(1.06); }
}

@keyframes loadingSweep {
  0% { transform: translateX(-110%); }
  60%, 100% { transform: translateX(260%); }
}

@keyframes moteDrift {
  0% { opacity: 0; transform: translate3d(0, 20px, 0) scale(0.7); }
  18% { opacity: 0.48; }
  70% { opacity: 0.3; }
  100% { opacity: 0; transform: translate3d(16px, -90px, 0) scale(1.15); }
}

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

.reduce-motion .screen,
.reduce-motion .mote,
.reduce-motion .loading-ornament,
.reduce-motion .continue-indicator,
.reduce-motion .portrait-float,
.reduce-motion .bg-frame img,
.reduce-motion .cg-frame img,
.reduce-motion .chapter-card-bg img,
.reduce-motion .title-bg img,
.reduce-motion .ending-bg img {
  animation: none !important;
}

.reduce-motion .motes {
  display: none;
}

.reduce-motion .bg-slide,
.reduce-motion .portrait,
.reduce-motion .modal-backdrop,
.reduce-motion .modal,
.reduce-motion .menu-btn,
.reduce-motion .choice-card,
.reduce-motion .chapter-card,
.reduce-motion .gallery-card,
.reduce-motion .btn,
.reduce-motion .toast-root {
  transition-duration: 0.01ms !important;
}

.reduce-motion .choice-card,
.reduce-motion .choices-panel,
.reduce-motion .chapter-card-content {
  animation: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .screen,
  .mote,
  .loading-ornament,
  .continue-indicator,
  .portrait-float,
  .bg-frame img,
  .cg-frame img,
  .chapter-card-bg img,
  .title-bg img,
  .ending-bg img {
    animation: none !important;
  }

  .motes {
    display: none;
  }
}

/* -------------------------------------------------------------------------
   Responsive refinements (desktop-first)
   ------------------------------------------------------------------------- */

@media (max-height: 820px) {
  .title-shell {
    padding: 3vh 0 6vh;
  }

  .title-logo {
    font-size: clamp(54px, 7.4vw, 96px);
  }

  .title-subtitle {
    margin-top: 18px;
  }

  .title-ornament {
    margin: 18px 0 16px;
  }

  .menu-btn {
    min-height: 56px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .menu-btn-name {
    font-size: 19px;
  }

  .menu-heading {
    margin: 26px 0 24px;
  }

  .chapter-card-body {
    padding: 17px 20px 19px;
  }

  .chapter-card h2 {
    font-size: 26px;
  }

  .chapter-card-description {
    margin: 9px 0 14px;
  }
}

@media (max-width: 1100px) {
  .chapter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .title-weather,
  .title-corner {
    display: none;
  }

  .setting-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .range-wrap {
    width: 100%;
    flex-basis: auto;
  }
}

@media (max-width: 760px) {
  .chapter-grid,
  .names-grid {
    grid-template-columns: 1fr;
  }

  .menu-shell {
    width: 92vw;
    padding-top: 22px;
  }

  .title-shell {
    width: 92vw;
  }

  .menu-heading h1 {
    font-size: 42px;
  }

  .chapter-card-watermark {
    font-size: 74px;
  }

  .modal {
    max-height: 92vh;
  }

  .modal-head {
    padding: 30px 24px 10px;
  }

  .modal-body {
    padding: 14px 24px 30px;
  }

  .modal-head h2 {
    font-size: 28px;
  }

  .save-slot {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .save-slot-head {
    flex-direction: row;
    flex-basis: auto;
    align-items: baseline;
    gap: 10px;
  }

  .save-slot-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .viewer-caption h2 {
    font-size: 22px;
  }

  .viewer-bottom {
    padding: 60px 20px 20px;
  }
}
