:root {
  --paper: #eadfc6;
  --paper-deep: #cab98f;
  --ink: #1f2924;
  --ink-soft: rgba(31, 41, 36, 0.56);
  --ink-faint: rgba(31, 41, 36, 0.2);
  --gold: #bc8d3d;
  --jade: #698671;
  --night: #253138;
  --rain: #61747b;
  color-scheme: light;
  font-family: "Xingkai SC", "Kaiti SC", "STKaiti", "KaiTi", "BiauKai", "Songti SC", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #1e231f;
}

button {
  font: inherit;
}

.scroll-app {
  position: relative;
  min-height: 100vh;
  width: 100vw;
  display: block;
  padding: 0;
  background:
    radial-gradient(circle at 17% 16%, rgba(168, 78, 48, 0.14), transparent 25%),
    linear-gradient(135deg, #2b3029, #111511 58%, #26231b);
  isolation: isolate;
}

.paper-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  mix-blend-mode: overlay;
  background-image:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 7px 11px;
  z-index: 4;
}

.stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  border-radius: 0;
  box-shadow: inset 0 0 0 1px rgba(70, 45, 22, 0.18);
  background: var(--paper);
}

.ink-scene {
  display: block;
  width: 100%;
  height: 100%;
}

.sky-wash path {
  fill: rgba(109, 139, 141, 0.13);
  stroke: rgba(60, 75, 70, 0.12);
  stroke-width: 9;
}

.mountains path {
  stroke: rgba(25, 32, 30, 0.24);
  stroke-width: 3;
}

.mountains.far path {
  fill: rgba(62, 83, 79, 0.12);
}

.mountains.mid path {
  fill: rgba(40, 55, 50, 0.2);
}

.clouds {
  fill: none;
  stroke: rgba(42, 54, 51, 0.21);
  stroke-width: 14;
  stroke-linecap: round;
  animation: cloudDrift 58s ease-in-out infinite alternate;
}

.rain-layer {
  opacity: 0;
  fill: none;
  stroke: var(--rain);
  stroke-width: 3;
  stroke-linecap: round;
  animation: rainFall 1.8s linear infinite;
}

.ground-wash {
  fill: rgba(80, 94, 77, 0.14);
}

.walking-landscape {
  opacity: 0;
  transition: opacity 700ms ease;
}

.open-hill {
  fill: rgba(79, 99, 78, 0.17);
  stroke: rgba(35, 49, 40, 0.14);
  stroke-width: 4;
}

.mountain-path,
.path-edge,
.path-stones,
.distant-birds {
  fill: none;
  stroke: rgba(33, 44, 37, 0.34);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mountain-path {
  stroke-width: 26;
  opacity: 0.22;
}

.path-edge {
  stroke-width: 5;
  opacity: 0.42;
}

.path-stones,
.distant-birds {
  stroke-width: 4;
}

.pine-trunk,
.pine-branch {
  fill: none;
  stroke: rgba(28, 37, 32, 0.52);
  stroke-width: 18;
  stroke-linecap: round;
  filter: url(#inkBleed);
}

.pine-branch {
  stroke-width: 12;
}

.pine-needles {
  fill: rgba(36, 71, 58, 0.22);
  stroke: rgba(31, 49, 42, 0.2);
}

.branch-a,
.branch-b {
  animation: branchSway 11s ease-in-out infinite alternate;
  transform-origin: 1190px 300px;
}

.room-floor {
  fill: rgba(104, 82, 48, 0.1);
}

.screen {
  fill: rgba(236, 224, 198, 0.46);
  stroke: rgba(47, 38, 25, 0.28);
  stroke-width: 5;
}

.screen-panel,
.screen-horizon {
  fill: none;
  stroke: rgba(50, 44, 34, 0.18);
  stroke-width: 3;
}

.window-light {
  fill: rgba(230, 177, 77, 0.06);
  opacity: 0.2;
}

.mat {
  fill: rgba(63, 73, 58, 0.26);
}

.desk,
.tea-table {
  fill: rgba(74, 54, 34, 0.35);
  stroke: rgba(42, 29, 18, 0.34);
  stroke-width: 3;
}

.objects path,
.objects ellipse {
  fill: none;
  stroke: rgba(31, 37, 32, 0.48);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.incense-stick {
  stroke-width: 3;
}

.smoke,
.cup-steam {
  stroke: rgba(63, 68, 61, 0.24);
  animation: smokeDrift 7s ease-in-out infinite;
}

.smoke-b,
.cup-steam {
  animation-delay: -2.7s;
}

.glow {
  fill: url(#lampGlow);
  stroke: none;
  opacity: 0;
  animation: lampBreath 5s ease-in-out infinite;
}

.flame {
  fill: rgba(190, 101, 37, 0.62);
  stroke: rgba(128, 62, 26, 0.34);
  animation: flameFlicker 2.4s ease-in-out infinite;
}

.candle-body,
.tea path,
.tea ellipse,
.qin-body,
.scroll-sheet {
  fill: rgba(232, 218, 188, 0.18);
}

.qin-string {
  animation: stringHum 3.2s ease-in-out infinite;
}

.string-two {
  animation-delay: -1s;
}

.calligraphy,
.scripture-lines {
  stroke-width: 3;
  stroke: rgba(25, 32, 28, 0.44);
}

.broom,
.guqin,
.scroll-object,
.visitor {
  opacity: 0;
  transition: opacity 900ms ease;
}

.visitor-body,
.visitor-head,
.visitor-cushion {
  fill: rgba(35, 43, 38, 0.2);
  stroke: rgba(23, 31, 27, 0.32);
}

.cultivator path {
  fill: rgba(28, 38, 35, 0.62);
  stroke: rgba(21, 27, 25, 0.38);
  stroke-width: 3;
  stroke-linejoin: round;
}

.cultivator .sleeve,
.cultivator .shoulder-line,
.cultivator .robe-fold {
  fill: none;
  stroke: rgba(22, 30, 27, 0.42);
  stroke-linecap: round;
}

.cultivator .sleeve {
  stroke-width: 5;
  opacity: 0.62;
}

.cultivator .shoulder-line,
.cultivator .robe-fold {
  stroke-width: 4;
  opacity: 0.5;
}

.walking-cultivator {
  opacity: 0;
  transition: opacity 700ms ease;
}

.walking-cultivator path {
  fill: rgba(28, 38, 35, 0.62);
  stroke: rgba(21, 27, 25, 0.4);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.walking-cultivator .walk-shadow {
  fill: rgba(24, 24, 22, 0.17);
}

.walking-cultivator .walk-foot,
.walking-cultivator .walk-sleeve,
.walking-cultivator .walk-neck,
.walking-cultivator .walk-shoulder,
.walking-cultivator .robe-fold,
.walking-cultivator .robe-hem,
.walking-cultivator .staff {
  fill: none;
  stroke: rgba(25, 32, 28, 0.48);
}

.walking-cultivator .walk-neck,
.walking-cultivator .walk-shoulder,
.walking-cultivator .robe-fold,
.walking-cultivator .robe-hem {
  stroke-width: 4;
}

.walking-cultivator .walk-sleeve {
  stroke-width: 5;
  opacity: 0.58;
}

.walking-cultivator .walk-foot {
  stroke-width: 5;
  opacity: 0.5;
}

.walking-cultivator .staff {
  stroke-width: 6;
}

.body-shadow {
  fill: rgba(24, 24, 22, 0.18);
}

.hands {
  fill: none !important;
  stroke: rgba(229, 207, 167, 0.38) !important;
  stroke-width: 5 !important;
}

.activity-markers {
  opacity: 0;
  fill: none;
  stroke: rgba(28, 37, 32, 0.22);
  stroke-width: 4;
  stroke-dasharray: 12 18;
}

.inscription {
  position: absolute;
  right: clamp(18px, 5vw, 72px);
  bottom: clamp(18px, 4vw, 64px);
  width: min(34ch, 36vw);
  color: rgba(32, 37, 32, 0.72);
  writing-mode: vertical-rl;
  line-height: 1.9;
  letter-spacing: 0;
  font-size: clamp(15px, 1.35vw, 21px);
  text-shadow: 0 1px rgba(255, 255, 255, 0.25);
}

.inscription p {
  margin: 0 0 0 16px;
}

.info-layer {
  position: absolute;
  left: clamp(24px, 5vw, 74px);
  top: clamp(24px, 5vw, 66px);
  max-width: min(320px, 38vw);
  color: rgba(30, 37, 33, 0.76);
  background: rgba(238, 226, 199, 0.42);
  border-left: 2px solid rgba(47, 35, 23, 0.22);
  padding: 12px 0 12px 18px;
  transition: opacity 260ms ease, transform 260ms ease;
  z-index: 3;
}

.info-layer.hidden {
  opacity: 0;
  transform: translateX(-10px);
  pointer-events: none;
}

.info-layer h1 {
  margin: 0 0 10px;
  font-weight: 500;
  font-size: clamp(26px, 3.2vw, 52px);
  line-height: 1.04;
  letter-spacing: 0;
}

.info-layer p {
  margin: 7px 0;
  font-size: clamp(13px, 1vw, 16px);
  line-height: 1.55;
}

.season-seal {
  position: absolute;
  left: clamp(24px, 5vw, 74px);
  bottom: clamp(22px, 4vw, 56px);
  display: grid;
  place-items: center;
  width: clamp(48px, 5vw, 64px);
  min-height: clamp(48px, 5vw, 64px);
  margin: 0;
  padding: 8px;
  border: 2px solid rgba(143, 37, 27, 0.82);
  color: rgba(143, 37, 27, 0.9);
  background: rgba(235, 219, 190, 0.22);
  font-size: clamp(16px, 1.4vw, 22px);
  line-height: 1.05;
  letter-spacing: 0;
  writing-mode: vertical-rl;
  box-shadow: inset 0 0 0 2px rgba(143, 37, 27, 0.08);
  z-index: 3;
  transition: opacity 260ms ease, transform 260ms ease;
}

.season-seal.hidden {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.controls {
  position: absolute;
  right: clamp(16px, 3vw, 36px);
  top: clamp(16px, 3vw, 32px);
  display: flex;
  gap: 10px;
  z-index: 5;
}

.controls button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(239, 226, 194, 0.42);
  border-radius: 50%;
  color: rgba(241, 226, 194, 0.9);
  background: rgba(19, 24, 20, 0.5);
  cursor: pointer;
  transition: background 180ms ease, transform 180ms ease;
}

.controls button:hover,
.controls button:focus-visible {
  background: rgba(92, 71, 40, 0.7);
  outline: none;
  transform: translateY(-1px);
}

.controls button[aria-pressed="true"] {
  color: #fff4d5;
  border-color: rgba(205, 143, 64, 0.72);
}

.controls svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.scroll-app[data-period="sleep"],
.scroll-app[data-period="night"] {
  background:
    radial-gradient(circle at 68% 20%, rgba(185, 159, 99, 0.13), transparent 22%),
    linear-gradient(135deg, #101821, #080d10 65%, #262015);
}

.scroll-app[data-period="waking"] .ink-scene {
  filter: saturate(0.9) brightness(1.04);
}

.scroll-app[data-period="waking"] .sky-wash path {
  fill: rgba(185, 155, 96, 0.16);
}

.scroll-app[data-period="practice"] .ink-scene {
  filter: saturate(0.98) contrast(1.04);
}

.scroll-app[data-period="practice"] .ground-wash {
  fill: rgba(83, 117, 83, 0.18);
}

.scroll-app[data-period="scripture"] .screen,
.scroll-app[data-period="calligraphy"] .screen,
.scroll-app[data-period="reading"] .screen {
  fill: rgba(239, 226, 197, 0.56);
}

.scroll-app[data-period="scripture"] .clouds,
.scroll-app[data-period="calligraphy"] .clouds {
  opacity: 0.54;
}

.scroll-app[data-period="sweeping"] .ground-wash {
  fill: rgba(114, 119, 88, 0.2);
}

.scroll-app[data-period="settling"] .ink-scene {
  filter: saturate(0.85) brightness(1.02);
}

.scroll-app[data-period="qin"] .ink-scene {
  filter: saturate(0.82) contrast(1.05);
}

.scroll-app[data-period="qin"] .screen-horizon {
  stroke: rgba(36, 54, 48, 0.28);
}

.scroll-app[data-period="discourse"] .window-light {
  opacity: 0.66;
}

.scroll-app[data-period="walking"] .sky-wash path {
  fill: rgba(178, 149, 89, 0.16);
}

.scroll-app[data-period="walking"] .mountains.mid path {
  fill: rgba(43, 64, 48, 0.28);
}

.scroll-app[data-period="meal"] .ink-scene {
  filter: saturate(0.96) brightness(0.98);
}

.scroll-app[data-period="sleep"] .ink-scene,
.scroll-app[data-period="night"] .ink-scene {
  filter: saturate(0.78) brightness(0.68);
}

.scroll-app[data-period="sleep"] .window-light,
.scroll-app[data-period="night"] .window-light,
.scroll-app[data-period="meal"] .window-light,
.scroll-app[data-period="meditation"] .window-light {
  opacity: 1;
}

.scroll-app[data-period="sleep"] .glow,
.scroll-app[data-period="night"] .glow,
.scroll-app[data-period="meditation"] .glow,
.scroll-app[data-period="reading"] .glow {
  opacity: 1;
}

.scroll-app[data-period="practice"] .practice-arc,
.scroll-app[data-period="walking"] .walking-path,
.scroll-app[data-period="scripture"] .scripture-lines {
  opacity: 1;
}

.scroll-app[data-period="walking"] .cultivator {
  opacity: 0;
}

.scroll-app[data-period="walking"] .walking-cultivator {
  opacity: 1;
  animation: walkingBreath 4.8s ease-in-out infinite;
}

.scroll-app[data-period="walking"] .walking-landscape {
  opacity: 1;
}

.scroll-app[data-period="walking"] .room,
.scroll-app[data-period="walking"] .objects {
  opacity: 0;
}

.scroll-app[data-period="walking"] .walking-path {
  stroke-width: 7;
  stroke-dasharray: 18 22;
  opacity: 0.45;
}

.scroll-app[data-period="qin"] .guqin,
.scroll-app[data-period="scripture"] .scroll-object,
.scroll-app[data-period="calligraphy"] .scroll-object,
.scroll-app[data-period="reading"] .scroll-object,
.scroll-app[data-period="sweeping"] .broom,
.scroll-app[data-period="discourse"] .visitor,
.scroll-app[data-period="meal"] .tea,
.scroll-app[data-period="settling"] .tea {
  opacity: 1;
}

.scroll-app[data-weather="rain"] .rain-layer {
  opacity: 0.42;
}

.scroll-app[data-weather="rain"] .sky-wash path {
  fill: rgba(70, 97, 103, 0.22);
}

.scroll-app[data-season="winter"] .ink-scene {
  filter: saturate(0.72) brightness(0.95);
}

.scroll-app[data-season="spring"] .ground-wash {
  fill: rgba(72, 114, 74, 0.16);
}

.scroll-app[data-season="autumn"] .screen {
  fill: rgba(225, 198, 151, 0.42);
}

@keyframes cloudDrift {
  from {
    transform: translateX(-18px);
  }
  to {
    transform: translateX(34px);
  }
}

@keyframes rainFall {
  from {
    transform: translateY(-30px);
  }
  to {
    transform: translateY(28px);
  }
}

@keyframes branchSway {
  from {
    transform: rotate(-0.7deg);
  }
  to {
    transform: rotate(0.9deg);
  }
}

@keyframes smokeDrift {
  0%,
  100% {
    transform: translateX(0);
    opacity: 0.18;
  }
  50% {
    transform: translateX(18px);
    opacity: 0.34;
  }
}

@keyframes lampBreath {
  0%,
  100% {
    opacity: 0.32;
  }
  50% {
    opacity: 0.62;
  }
}

@keyframes flameFlicker {
  0%,
  100% {
    transform: scaleY(1);
  }
  45% {
    transform: scaleY(0.94) translateY(2px);
  }
}

@keyframes stringHum {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(2px);
  }
}

@keyframes walkingBreath {
  0%,
  100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(8px, -2px);
  }
}

@media (max-width: 760px) {
  body {
    overflow: hidden;
  }

  .scroll-app {
    min-height: 100svh;
  }

  .stage {
    width: 100%;
    height: 100svh;
    max-height: none;
  }

  .ink-scene {
    width: 100%;
    height: 100%;
    transform: none;
  }

  .info-layer {
    left: 22px;
    top: 74px;
    bottom: auto;
    max-width: calc(100% - 128px);
    padding: 10px 0 10px 14px;
    background: rgba(238, 226, 199, 0.58);
  }

  .info-layer h1 {
    font-size: 29px;
  }

  .season-seal {
    left: 22px;
    bottom: 22px;
    width: 46px;
    min-height: 46px;
    font-size: 15px;
  }

  .inscription {
    right: 18px;
    bottom: 28px;
    width: 22ch;
    font-size: 15px;
  }

  .controls {
    top: 18px;
    right: 18px;
    gap: 8px;
  }

  .controls button {
    width: 38px;
    height: 38px;
  }
}

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