:root {
  --bg-top: #1f1735;
  --bg-mid: #7b2f2f;
  --bg-bottom: #f1d2a6;
  --panel: rgba(30, 20, 28, 0.78);
  --panel-strong: rgba(43, 28, 37, 0.9);
  --panel-border: rgba(255, 225, 169, 0.24);
  --text: #f8f1e4;
  --muted: rgba(248, 241, 228, 0.8);
  --gold: #f3c978;
  --gold-deep: #c98b2f;
  --crimson: #7b263f;
  --shadow: 0 28px 70px rgba(13, 8, 14, 0.38);
  --crisp-line: rgba(255, 229, 181, 0.34);
  --ease-refined: cubic-bezier(0.22, 0.7, 0.16, 1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scrollbar-color: rgba(255, 219, 155, 0.45) rgba(10, 5, 14, 0.45);
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 132px 18px 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  color: var(--text);
  font-family: "Georgia", "Times New Roman", serif;
  line-height: 1.65;
  background:
    linear-gradient(rgba(23, 14, 24, 0.6), rgba(23, 14, 24, 0.6)),
    url("RamayanaBG.webp"),
    radial-gradient(circle at top, rgba(255, 223, 138, 0.22), transparent 24%),
    radial-gradient(circle at 15% 20%, rgba(255, 184, 108, 0.14), transparent 18%),
    linear-gradient(160deg, var(--bg-top) 0%, #382148 22%, var(--bg-mid) 58%, var(--bg-bottom) 100%);
  background-size: cover, cover, auto, auto, auto;
  background-position: center, center, center, center, center;
  background-attachment: fixed, fixed, scroll, scroll, scroll;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 234, 184, 0.18), transparent 34%),
    linear-gradient(90deg, transparent 0%, rgba(255, 247, 220, 0.04) 50%, transparent 100%);
  mix-blend-mode: screen;
}

body::after {
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(255, 236, 199, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 236, 199, 0.08) 1px, transparent 1px);
  background-size: 120px 120px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.35), transparent 92%);
}

#titleContainer,
#storyCard,
#timelineCard {
  width: min(1080px, 100%);
  position: relative;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 245, 221, 0.08), rgba(255, 245, 221, 0.02)),
    var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px rgba(255, 239, 203, 0.08),
    var(--shadow);
  transition: transform 0.5s var(--ease-refined), box-shadow 0.5s var(--ease-refined);
}

#updateInfo {
  padding: 18px;
  border-radius: 16px;
  border: 1px solid rgba(255, 225, 169, 0.24);
  background: rgba(255, 245, 221, 0.04);
}

.scroll-reveal {
  opacity: 0;
  transform: translateY(26px) scale(0.985);
  filter: saturate(0.9);
}

.scroll-reveal.in-view {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: saturate(1);
}


#topNavbar {
  position: sticky;
  top: 10px;
  left: auto;
  transform: none;
  margin: 0 auto;
  width: min(1180px, calc(100vw - 18px));
  z-index: 22;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: nowrap;
  padding: 8px 10px 8px 112px;
  border-radius: 18px;
  border: 1px solid rgba(255, 223, 162, 0.42);
  background: linear-gradient(120deg, rgba(95, 39, 51, 0.86), rgba(42, 22, 47, 0.88));
  box-shadow: 0 12px 28px rgba(14, 6, 20, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow:
    inset 0 0 0 1px rgba(255, 241, 214, 0.1),
    0 12px 28px rgba(14, 6, 20, 0.45);
}

#navbarToggle {
  display: none;
  width: auto;
  min-width: 46px;
  min-height: 42px;
  padding: 6px 11px;
  border-radius: 12px;
  border: 1px solid rgba(255, 223, 162, 0.45);
  background: rgba(35, 18, 34, 0.82);
  color: #fff3d4;
  font-size: 1.28rem;
  line-height: 1;
  box-shadow: 0 6px 14px rgba(14, 6, 20, 0.38);
}

#navbarToggle:hover,
#navbarToggle:focus-visible {
  transform: translateY(-1px);
  background: rgba(243, 201, 120, 0.2);
  border-color: rgba(255, 230, 173, 0.7);
}

#topNavbar.nav-open {
  flex-wrap: wrap;
  justify-content: space-between;
}

#topNavbar.nav-open #navLinks,
#topNavbar.nav-open #soundtrackBadge {
  display: flex;
}

#updateBadge {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 24;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 223, 162, 0.55);
  background: linear-gradient(120deg, rgba(95, 39, 51, 0.92), rgba(42, 22, 47, 0.9));
  color: #fff3d4;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 8px 18px rgba(14, 6, 20, 0.35);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.26);
}

#updateBadge {
  text-decoration: none;
  cursor: pointer;
}

#updateBadge::after {
  content: " • " attr(data-resolution-label);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(255, 239, 198, 0.9);
}

body[data-resolution-tier="hd"] {
  --bg-top: #203362;
  --bg-mid: #6e2b47;
  --bg-bottom: #f2c88f;
  --panel-border: rgba(166, 214, 255, 0.28);
}

body[data-resolution-tier="fhd"] {
  --bg-top: #2e1a4a;
  --bg-mid: #7b2f2f;
  --bg-bottom: #f1d2a6;
  --panel-border: rgba(255, 225, 169, 0.24);
}

body[data-resolution-tier="qhd"] {
  --bg-top: #183f5a;
  --bg-mid: #2f5c7b;
  --bg-bottom: #d2f0f1;
  --panel-border: rgba(174, 247, 255, 0.3);
}

body[data-resolution-tier="uhd"] {
  --bg-top: #111b3f;
  --bg-mid: #283a7d;
  --bg-bottom: #9bc0ff;
  --panel-border: rgba(206, 227, 255, 0.34);
}

#navLinks {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#aboutButton,
.nav-link-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 223, 162, 0.4);
  color: #fff3d4;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.85rem;
  background: rgba(35, 18, 34, 0.72);
  transition: transform 0.2s var(--ease-refined), border-color 0.2s var(--ease-refined), background 0.2s var(--ease-refined);
}

#aboutButton:hover,
#aboutButton:focus-visible,
.nav-link-pill:hover,
.nav-link-pill:focus-visible {
  background: rgba(243, 201, 120, 0.18);
  transform: translateY(-1px);
  outline: none;
}

#aboutButton.nav-link-current,
.nav-link-pill.nav-link-current,
#updateBadge.nav-link-current {
  position: relative;
}

#aboutButton.nav-link-current::before,
.nav-link-pill.nav-link-current::before,
#updateBadge.nav-link-current::before {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 4px;
  height: 2px;
  border-radius: 999px;
  background: rgba(255, 235, 194, 0.95);
}

#peopleControls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

#peopleGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.people-card {
  border: 1px solid rgba(255, 223, 162, 0.35);
  border-radius: 16px;
  padding: 14px;
  background: linear-gradient(135deg, rgba(59, 26, 45, 0.7), rgba(28, 21, 49, 0.72));
}

.people-card h3 {
  margin-top: 0;
  margin-bottom: 8px;
  color: #51e3bf;
}

.people-card-role,
.people-card-type {
  margin: 0;
  color: var(--gold);
  font-weight: 600;
  font-size: 0.9rem;
}

.people-card .wiki-link-button {
  display: inline-block;
  margin-top: 10px;
  text-decoration: none;
}


#soundtrackBadge {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid rgba(255, 223, 162, 0.35);
  background: rgba(22, 12, 26, 0.4);
}

.soundtrack-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 235, 194, 0.78);
}

.soundtrack-track-name {
  margin: 0;
  font-size: 0.78rem;
  color: #fff3d4;
}

#backgroundMusic {
  width: min(260px, 45vw);
  height: 30px;
  border-radius: 10px;
  accent-color: #f6c26f;
  filter: drop-shadow(0 4px 8px rgba(8, 2, 12, 0.35));
}



#storyCardToolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

#undoButton {
  padding: 6px 12px;
  font-size: 0.85rem;
}

#startBtn,
#undoButton.art-button {
  position: relative;
  min-height: 48px;
  padding: 10px 24px;
  border: 1px solid rgba(255, 244, 184, 0.95);
  border-radius: 999px;
  background: linear-gradient(140deg, #fff6a8 0%, #ffd54f 30%, #ffb300 64%, #ff9100 100%);
  background-repeat: no-repeat;
  background-position: center;
  box-shadow: 0 0 24px rgba(255, 203, 73, 0.7), 0 8px 18px rgba(255, 166, 0, 0.45);
  color: #2d1800;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
  overflow: hidden;
  transition:
    filter 0.25s var(--ease-refined),
    transform 0.25s var(--ease-refined),
    opacity 0.2s var(--ease-refined);
  filter: brightness(1.04) saturate(1.3) drop-shadow(0 5px 10px rgba(255, 186, 77, 0.45));
}

#startBtn {
  margin-top: 24px;
}

#startBtn[data-tooltip]:hover::after,
#undoButton.art-button[data-tooltip]:hover::after,
#startBtn[data-tooltip]:focus-visible::after,
#undoButton.art-button[data-tooltip]:focus-visible::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 223, 162, 0.5);
  background: rgba(18, 10, 20, 0.93);
  color: #fff3d4;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: none;
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
}

#undoButton.art-button {
  width: 150px;
  height: 48px;
  padding: 0;
  border: 0;
  background-color: transparent;
  border-radius: 0;
  color: transparent;
  font-size: 0;
  text-shadow: none;
  box-shadow: none;
  background-image: url("undoBtn");
  background-size: contain;
}


#startBtn:hover,
#undoButton.art-button:hover {
  filter: brightness(1.14) saturate(1.35) drop-shadow(0 10px 18px rgba(255, 194, 96, 0.6));
  transform: translateY(-2px) scale(1.02);
}

#startBtn:focus-visible,
#undoButton.art-button:focus-visible {
  outline: none;
  filter: brightness(1.22) saturate(1.25) drop-shadow(0 0 0 3px rgba(255, 230, 163, 0.42)) drop-shadow(0 8px 14px rgba(255, 194, 96, 0.4));
}


#undoButton.art-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.1) brightness(0.92);
}

#topNavbar button {
  width: auto;
  padding: 8px 14px;
}

#storyAnswerInput {
  width: min(680px, 100%);
  margin-top: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 223, 162, 0.35);
  background: rgba(20, 12, 24, 0.76);
  color: #fff3d4;
  padding: 10px 12px;
  font: inherit;
}
#undoButton:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#titleContainer::before,
#storyCard::before,
#timelineCard::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(243, 201, 120, 0.14), transparent 34%),
    radial-gradient(circle at top right, rgba(255, 214, 146, 0.12), transparent 28%);
  pointer-events: none;
}

#titleContainer {
  padding: 52px clamp(22px, 5vw, 56px);
  text-align: center;
}

header {
  max-width: 760px;
  margin: 0 auto;
}

h1,
h2,
h3,
h4 {
  margin: 0;
}

h1 {
  font-size: clamp(3rem, 7vw, 5.1rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff3d4;
  text-shadow: 0 10px 30px rgba(25, 13, 18, 0.4);
}

.subtitle {
  margin-top: 14px;
  font-size: clamp(1rem, 2vw, 1.25rem);
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--gold);
}

#description {
  margin-top: 26px;
  font-size: clamp(1.2rem, 2.4vw, 1.7rem);
  font-weight: 500;
  color: var(--text);
}

p {
  margin: 16px auto 0;
  max-width: 68ch;
  font-size: 1.05rem;
  color: var(--muted);
}

#beginningContainer {
  display: flex;
  justify-content: center;
  margin-top: 34px;
}

.intro-card {
  width: min(520px, 100%);
  padding: 28px 24px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 248, 229, 0.08), rgba(255, 248, 229, 0.03));
  border: 1px solid rgba(255, 232, 182, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.intro-card h2 {
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  color: #fff0c3;
}

.name-grid {
  display: grid;
  gap: 10px;
  justify-items: center;
}

/* Family setup feature disabled.
.family-setup-fields {
  margin-top: 10px;
}

.setup-notice {
  margin: 10px auto 0;
  width: min(320px, 100%);
  text-align: left;
  min-height: 1.4em;
  font-size: 0.88rem;
  color: #ffd98c;
}

#toggleFamilySetupBtn {
  margin-top: 18px;
}
*/

.setup-label {
  margin: 12px 0 0;
  width: min(320px, 100%);
  text-align: left;
  font-size: 0.88rem;
  color: rgba(255, 236, 189, 0.88);
}

.name-grid input,
.name-grid select {
  width: min(320px, 100%);
  margin-top: 6px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 224, 168, 0.24);
  background: rgba(22, 14, 20, 0.55);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.name-grid input::placeholder {
  color: rgba(248, 241, 228, 0.45);
}

.name-grid input:focus,
.name-grid select:focus {
  border-color: rgba(243, 201, 120, 0.75);
  box-shadow: 0 0 0 4px rgba(243, 201, 120, 0.12);
  transform: translateY(-1px);
}

#storyCard {
  padding: 38px clamp(20px, 4vw, 40px);
  min-height: 180px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  text-align: center;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 223, 165, 0.42) rgba(12, 8, 14, 0.5);
}

#timelineCard {
  width: min(96vw, 1900px);
  max-height: min(92vh, 1200px);
  padding: 30px clamp(16px, 3vw, 30px);
}

#inventoryCard {
  width: min(760px, 96vw);
  max-height: min(82vh, 860px);
  overflow: auto;
  padding: 26px clamp(16px, 3vw, 24px);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 245, 221, 0.08), rgba(255, 245, 221, 0.02)),
    var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

#inventoryList {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.inventory-item {
  text-align: left;
  padding: 14px 14px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 225, 169, 0.2);
  background: rgba(12, 8, 14, 0.38);
}

.inventory-item h4 {
  color: #ffe3ad;
}

.inventory-item p {
  margin-top: 8px;
  max-width: none;
}

.timeline-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 5, 10, 0.72);
  backdrop-filter: blur(6px);
}

.timeline-modal.open {
  display: flex;
}

.timeline-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.timeline-close {
  border-radius: 12px;
  min-width: 44px;
  padding: 8px 10px;
  font-size: 1.2rem;
  line-height: 1;
}

#timelineCard h2 {
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  color: #fff0c6;
  text-align: left;
}

#timelineCard > p {
  text-align: left;
}

#timelineLegend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 14px;
  margin-top: 16px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 241, 214, 0.08);
  border: 1px solid rgba(255, 224, 168, 0.22);
  color: var(--muted);
  font-size: 0.92rem;
}

.legend-swatch {
  width: 18px;
  height: 10px;
  border-radius: 99px;
  background: rgba(255, 225, 169, 0.5);
}

.legend-swatch.highlight {
  background: #51e3bf;
}

.legend-swatch.current {
  background: #00fff0;
}


#timelineZoomControls {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 225, 169, 0.18);
  background: rgba(10, 6, 14, 0.45);
}

#timelineZoomControls button {
  width: auto;
  min-width: 40px;
  padding: 6px 10px;
}

#timelineZoomValue {
  min-width: 52px;
  text-align: center;
  color: #ffe8be;
  font-weight: 700;
}

#timelineFlowchart {
  margin-top: 16px;
  overflow: auto;
  max-height: min(72vh, 950px);
  padding: 10px 12px 16px;
  border-radius: 18px;
  background: rgba(12, 8, 14, 0.35);
  border: 1px solid rgba(255, 225, 169, 0.16);
  box-shadow: inset 0 0 0 1px rgba(255, 225, 169, 0.06);
}

#timelineFlowchart svg {
  width: 100%;
  min-width: 3600px;
  height: auto;
  filter: drop-shadow(0 14px 26px rgba(4, 3, 8, 0.35));
}

#timelineFlowchart::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

#timelineFlowchart::-webkit-scrollbar-thumb {
  background: rgba(255, 223, 165, 0.28);
  border-radius: 999px;
}

#timelineFlowchart::-webkit-scrollbar-track {
  background: rgba(12, 8, 14, 0.5);
}

.timeline-column-label {
  fill: rgba(255, 236, 199, 0.72);
  font-size: 15px;
  font-weight: 700;
}

.timeline-edge {
  fill: none;
  stroke: rgba(255, 222, 168, 0.26);
  stroke-width: 3;
  opacity: 0.9;
}

.timeline-edge.chance {
  stroke-dasharray: 7 6;
}

.timeline-edge.active {
  stroke: #51e3bf;
  stroke-width: 7;
}

.edge-label {
  fill: rgba(248, 241, 228, 0.75);
  font-size: 14px;
  text-anchor: middle;
  dominant-baseline: alphabetic;
}

.edge-label-bg {
  fill: rgba(12, 8, 14, 0.88);
  stroke: rgba(255, 225, 169, 0.22);
  stroke-width: 1;
}

.timeline-node {
  fill: rgba(36, 24, 31, 0.9);
  stroke: rgba(255, 225, 169, 0.24);
  stroke-width: 2;
  transition: fill 0.2s ease, stroke 0.2s ease;
}

.timeline-node.visited {
  fill: rgba(29, 73, 67, 0.4);
  stroke: rgba(127, 243, 214, 0.75);
}

.timeline-node.active {
  fill: rgba(28, 92, 83, 0.95);
  stroke: #8fffe0;
  stroke-width: 4;
}

.node-id {
  fill: #ffd99a;
  font-size: 18px;
  font-weight: 700;
}

.node-title {
  fill: #f8f1e4;
  font-size: 14px;
}

#storyCard h2 {
  font-size: clamp(1.9rem, 4vw, 2.8rem);
  color: #fff0c6;
}

#choices {
  margin-top: 26px;
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

#receiptCard {
  margin: 30px auto 0;
  max-width: 760px;
  padding: 24px 22px;
  text-align: left;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 248, 229, 0.12), rgba(255, 248, 229, 0.05)),
    rgba(48, 31, 29, 0.88);
  border: 1px solid rgba(255, 223, 168, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

#receiptCard h3,
#receiptCard h4 {
  margin: 0;
  color: #fff0c6;
}

#receiptCard h3 {
  font-size: 1.6rem;
}

#receiptCard h4 {
  margin-top: 18px;
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}

#receiptCard p {
  max-width: none;
}

.receipt-section ol {
  margin: 12px 0 0;
  padding-left: 22px;
  color: var(--muted);
}

.receipt-section li + li {
  margin-top: 8px;
}

.timeline-scene-description {
  margin: 4px 0 0;
  color: rgba(255, 241, 220, 0.9);
  font-size: 0.92rem;
}

.timeline-current-scene strong,
.timeline-current-scene .timeline-scene-description {
  color: #f3c978;
}

.character-name {
  color: #f3c978;
  font-weight: 700;
}

button,
.btn {
  appearance: none;
  border: 1px solid var(--crisp-line);
  border-radius: 999px;
  min-height: 44px;
  padding: 14px 24px;
  background:
    linear-gradient(135deg, rgba(255, 229, 170, 0.22), rgba(255, 184, 112, 0.12)),
    rgba(255, 248, 234, 0.06);
  color: #fff5dd;
  font: inherit;
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 12px 30px rgba(16, 8, 14, 0.22);
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    border-color 0.22s ease,
    background 0.22s ease,
    filter 0.22s ease;
}

button:hover,
.btn:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 225, 163, 0.5);
  background:
    linear-gradient(135deg, rgba(243, 201, 120, 0.36), rgba(201, 139, 47, 0.18)),
    rgba(255, 248, 234, 0.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 16px 36px rgba(16, 8, 14, 0.28);
  filter: saturate(1.08);
}

button:active,
.btn:active {
  transform: translateY(0);
}

a {
  color: var(--gold);
  text-decoration: none;
}

a:hover {
  color: #ffe7b5;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .scroll-reveal,
  .scroll-reveal.in-view,
  #titleContainer,
  #storyCard,
  #timelineCard,
  button,
  .btn {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
    filter: none !important;
  }
}

blockquote,
.card,
.container {
  background: var(--panel-strong);
  border: 1px solid rgba(255, 225, 169, 0.18);
  border-radius: 18px;
  box-shadow: var(--shadow);
}


@media (max-width: 1024px) {
  body {
    background-attachment: scroll, scroll, scroll, scroll, scroll;
  }

  body::before,
  body::after {
    opacity: 0.55;
  }

  #titleContainer,
  #storyCard,
  #timelineCard {
    width: min(100%, 820px);
    border-radius: 24px;
  }

  #titleContainer {
    padding: 40px 24px 30px;
  }

  #storyCard {
    padding: 30px clamp(16px, 3.5vw, 28px);
  }

  #timelineCard {
    width: min(100vw - 24px, 1200px);
    max-height: min(88vh, 980px);
    padding: 24px 14px 18px;
  }

  #timelineFlowchart svg {
    min-width: 2600px;
  }
}

@media (max-width: 768px) {
  body {
    min-height: 100dvh;
    padding: 112px 10px calc(20px + env(safe-area-inset-bottom));
    gap: 14px;
    background-position: center top, center top, center, center, center;
  }

  body::before,
  body::after {
    display: none;
  }

  #titleContainer,
  #storyCard,
  #timelineCard,
  #inventoryCard {
    border-radius: 20px;
    border-color: rgba(162, 255, 233, 0.32);
    background:
      linear-gradient(180deg, rgba(116, 255, 225, 0.1), rgba(116, 255, 225, 0.02)),
      rgba(12, 20, 34, 0.86);
  }

  #titleContainer {
    padding: 30px 14px 24px;
  }

  h1 {
    letter-spacing: 0.03em;
  }

  #description {
    font-size: clamp(1.1rem, 4.4vw, 1.4rem);
  }

  p {
    font-size: 1.05rem;
  }

  .subtitle {
    letter-spacing: 0.16em;
    color: #8ef6e3;
  }

  .intro-card {
    padding: 18px 14px;
    border-color: rgba(116, 255, 225, 0.28);
  }

  #storyCard {
    max-height: none;
    overflow-y: visible;
    padding: 22px 14px;
  }

  #storyCardToolbar {
    position: static;
    z-index: 3;
    margin: 0 0 10px;
    padding: 0;
    background: none;
  }

  #storyCard h2 {
    font-size: clamp(1.55rem, 7vw, 2.1rem);
    line-height: 1.26;
  }

  #choices {
    margin-top: 20px;
    gap: 10px;
  }

  #receiptCard {
    margin-top: 20px;
    padding: 18px 14px;
    border-color: rgba(116, 255, 225, 0.3);
    background:
      linear-gradient(180deg, rgba(112, 242, 223, 0.16), rgba(112, 242, 223, 0.04)),
      rgba(13, 24, 33, 0.92);
  }

  #timelineFlowchart svg {
    min-width: 1800px;
  }

  #timelineModal,
  #inventoryModal {
    align-items: flex-end;
    padding: 8px;
  }

  #timelineCard,
  #inventoryCard {
    width: min(100%, 100vw - 16px);
    max-height: min(88dvh, 820px);
    border-radius: 18px 18px 14px 14px;
    padding: 18px 12px calc(14px + env(safe-area-inset-bottom));
  }

  .timeline-modal-header {
    gap: 10px;
    margin-bottom: 8px;
  }

  .timeline-close {
    min-width: 40px;
    min-height: 40px;
    padding: 8px;
  }

  #timelineCard h2,
  #timelineCard > p,
  #inventoryCard h2,
  #inventoryCard > p {
    text-align: center;
  }

  #timelineLegend {
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
  }

  .legend-item {
    font-size: 0.82rem;
    padding: 5px 8px;
    gap: 6px;
  }

  .legend-swatch {
    width: 14px;
    height: 8px;
  }

  #timelineZoomControls {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    padding: 8px;
    border-radius: 14px;
  }

  #timelineZoomControls button {
    min-width: 0;
    padding: 9px 8px;
    font-size: 0.92rem;
  }

  #timelineZoomValue {
    width: 100%;
    min-width: 0;
    align-self: stretch;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    border: 1px solid rgba(116, 255, 225, 0.35);
    background: rgba(10, 22, 34, 0.5);
  }

  button,
  .btn {
    width: 100%;
    border-radius: 14px;
    min-height: 44px;
    padding: 14px 18px;
    border-color: rgba(116, 255, 225, 0.35);
    background:
      linear-gradient(145deg, rgba(81, 227, 191, 0.35), rgba(59, 161, 255, 0.2)),
      rgba(10, 22, 34, 0.62);
  }

  #topNavbar {
    top: max(6px, env(safe-area-inset-top));
    width: calc(100vw - 10px);
    justify-content: flex-end;
    border-radius: 14px;
    padding: 7px;
    gap: 8px;
    justify-content: center;
    border-radius: 12px;
    padding: 6px;
    gap: 6px;
  }

  #navbarToggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    min-height: 38px;
    padding: 5px 9px;
    font-size: 1.15rem;
  }

  #topNavbar #navLinks,
  #topNavbar #soundtrackBadge {
    display: none;
  }

  #topNavbar.nav-open {
    justify-content: center;
  }

  #navLinks,
  #soundtrackBadge {
    width: 100%;
    justify-content: center;
  }

  #navLinks {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  #navLinks a,
  #navLinks button {
    width: 100%;
    min-height: 40px;
  }

  #topNavbar button {
    width: auto;
  }

  #peopleControls {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  #peopleControls label {
    font-size: 0.88rem;
  }

  #peopleCategory {
    width: 100%;
    min-height: 40px;
  }

  #peopleGrid {
    grid-template-columns: 1fr;
  }

  #soundtrackBadge {
    padding: 6px 8px;
    gap: 5px;
    justify-content: center;
  }

  .soundtrack-label {
    display: none;
  }

  .soundtrack-track-name {
    display: none;
  }

  #backgroundMusic {
    width: min(180px, calc(55vw));
    height: 26px;
  }


  #updateBadge {
    top: auto;
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: 8px;
    font-size: 0.7rem;
    padding: 5px 10px;
    letter-spacing: 0.04em;
  }

  #storyAnswerInput,
  .name-grid input,
  .name-grid select {
    width: 100%;
  }

  #inventoryList {
    gap: 10px;
    margin-top: 10px;
  }

  .inventory-item {
    padding: 12px 10px;
    border-radius: 12px;
  }
}

@media (max-width: 480px) {
  body {
    padding: 104px 8px calc(16px + env(safe-area-inset-bottom));
  }

  #titleContainer {
    padding: 24px 12px 20px;
  }

  #timelineCard {
    width: calc(100vw - 16px);
    padding: 16px 9px calc(12px + env(safe-area-inset-bottom));
  }

  #timelineFlowchart svg {
    min-width: 1400px;
  }

  h1 {
    font-size: clamp(2rem, 12vw, 2.8rem);
  }

  .subtitle {
    margin-top: 8px;
    font-size: 0.88rem;
    letter-spacing: 0.12em;
  }

  #description {
    margin-top: 14px;
  }

  #topNavbar button,
  #aboutButton,
  .nav-link-pill {
    padding: 7px 10px;
    font-size: 0.75rem;
  }

  #navLinks {
    grid-template-columns: 1fr;
  }

  #soundtrackBadge {
    padding: 5px 6px;
  }

  #backgroundMusic {
    width: min(150px, calc(52vw));
    height: 24px;
  }


  #timelineLegend {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  #timelineZoomControls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #timelineZoomValue {
    grid-column: span 2;
    min-height: 38px;
  }

  #updateBadge {
    left: 6px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    font-size: 0.64rem;
  }
}


#storyCard.scene-card-layout {
  width: min(1200px, 100%);
}

#storyNavigationShell {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 18px;
  margin: 14px 16px 10px;
}

#sceneSidebar {
  border: 1px solid rgba(255, 223, 162, 0.28);
  border-radius: 16px;
  padding: 14px;
  background: rgba(24, 14, 30, 0.62);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 84px;
  max-height: 72vh;
  overflow: auto;
}

#sceneSidebar h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

#sceneSidebar label {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 239, 198, 0.9);
}

#sceneSidebar select,
.toc-link {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 223, 162, 0.35);
  background: rgba(31, 16, 34, 0.85);
  color: var(--text);
  padding: 8px 10px;
}

.toc-link {
  text-align: left;
  cursor: pointer;
  font-size: 0.84rem;
}

.toc-link.active {
  border-color: rgba(255, 223, 162, 0.75);
  background: rgba(243, 201, 120, 0.17);
}

#storyNavMain {
  max-width: 900px;
  margin-inline: auto;
  font-size: 1.08rem;
  line-height: 1.6;
}

.scene-number-label {
  margin: 6px 0 10px;
  font-size: 0.92rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 239, 198, 0.88);
}

.scene-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.scene-progress-wrap {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 235, 194, 0.2);
  overflow: hidden;
  margin-bottom: 12px;
}

.scene-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #f3c978, #ffdca6);
}

.immersion-row {
  margin: 6px 0;
  font-size: 0.96rem;
  color: rgba(248, 241, 228, 0.92);
}

.next-prev-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin: 30px 0 20px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 223, 162, 0.4);
}

.next-prev-controls button {
  min-width: 170px;
}

.next-prev-controls button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#storyNavMain h1 {
  font-size: 2rem;
  margin: 14px 0 10px;
}

#storyNavMain h2 {
  font-size: 2.1rem;
  margin: 22px 0 14px;
}

#storyNavMain p {
  margin: 0 0 22px;
  max-width: 70ch;
  font-size: 1.1rem;
}

@media (max-width: 768px) {
  #storyNavMain {
    font-size: 1.125rem;
  }

  #storyNavMain p {
    font-size: 1.125rem;
    margin-bottom: 24px;
  }

  #storyNavMain h2 {
    margin-top: 26px;
    font-size: clamp(1.95rem, 7vw, 2.3rem);
  }

  .next-prev-controls {
    position: sticky;
    bottom: calc(10px + env(safe-area-inset-bottom));
    background: rgba(12, 20, 34, 0.94);
    border: 1px solid rgba(116, 255, 225, 0.3);
    border-radius: 14px;
    padding: 10px;
    margin: 34px 0 26px;
    flex-direction: column;
    gap: 10px;
    z-index: 4;
  }

  .next-prev-controls button {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 980px) {
  #storyNavigationShell {
    grid-template-columns: 1fr;
  }

  #sceneSidebar {
    position: static;
    max-height: none;
  }

  .scene-meta-grid {
    grid-template-columns: 1fr;
  }
}
