@import url("https://fonts.googleapis.com/css2?family=Noto+Serif+TC:wght@400;600;700;900&display=swap");

:root {
  color-scheme: dark;
  --ink: #07090d;
  --paper: #eadcc0;
  --muted: #b9aa91;
  --gold: #caa66a;
  --gold-bright: #f2d49b;
  --cinnabar: #8d3028;
  --panel: rgba(10, 10, 10, 0.82);
  --safe-top: max(18px, env(safe-area-inset-top));
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  font-family: "Noto Serif TC", "Songti TC", "STSong", serif;
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible {
  outline: 1px solid var(--gold-bright);
  outline-offset: 4px;
}

body.intro-active #game {
  visibility: hidden;
}

.dream-intro {
  position: fixed;
  z-index: 1000;
  inset: 0;
  overflow: hidden;
  background: #07101e;
  opacity: 1;
  transition: opacity .85s ease;
}

.dream-intro.is-leaving {
  pointer-events: none;
  opacity: 0;
}

/* 開場動畫必須等初次載入遮罩完全退場後才開始計時。 */
.dream-intro:not(.is-playing) .dream-city,
.dream-intro:not(.is-playing) .dream-city-glow,
.dream-intro:not(.is-playing) .dream-butterfly,
.dream-intro:not(.is-playing) .dream-butterfly-trail,
.dream-intro:not(.is-playing) .dream-wash,
.dream-intro:not(.is-playing) .dream-wash::before,
.dream-intro:not(.is-playing) .dream-wash::after,
.dream-intro:not(.is-playing) .dream-whisper {
  animation-play-state: paused;
}

.dream-city,
.dream-city-glow,
.dream-butterfly-trail,
.dream-wash {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.dream-city {
  background: url("./assets/images/enter/modern-city-dream.png") center / cover no-repeat;
  filter: saturate(.76) brightness(.72);
  transform: scale(1.08);
  animation: dream-city-breathe 5.8s cubic-bezier(.2,.7,.2,1) both;
}

.dream-city-glow {
  background:
    radial-gradient(circle at 50% 48%, transparent 0 15%, rgba(20, 35, 66, .08) 35%, rgba(2, 5, 12, .62) 100%),
    linear-gradient(180deg, rgba(3, 9, 20, .08), rgba(2, 5, 12, .46));
  animation: dream-focus-shift 5.8s ease-in both;
}

.dream-butterfly {
  position: absolute;
  z-index: 2;
  top: 58%;
  left: -12vw;
  width: clamp(92px, 11vw, 180px);
  aspect-ratio: 1;
  filter: drop-shadow(0 0 9px rgba(255, 209, 102, .9)) drop-shadow(0 0 25px rgba(229, 164, 62, .7));
  animation: butterfly-flight 4.65s cubic-bezier(.38,.08,.58,.96) .35s both;
}

.dream-butterfly img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: rotate(-4deg);
}

.dream-butterfly-trail {
  z-index: 1;
  opacity: 0;
  background-image:
    radial-gradient(circle at 18% 62%, #ffe8a0 0 1px, transparent 2px),
    radial-gradient(circle at 31% 48%, #ffd66f 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 44% 56%, #fff3bd 0 1px, transparent 2px),
    radial-gradient(circle at 58% 35%, #dfaa4b 0 1.5px, transparent 3px),
    radial-gradient(circle at 73% 42%, #ffe39a 0 1px, transparent 2.5px);
  filter: drop-shadow(0 0 5px #e8ad4a);
  animation: dream-trail 4.5s ease .7s both;
}

.dream-wash {
  z-index: 4;
  opacity: 0;
  background:
    radial-gradient(circle at 78% 32%, rgba(255, 255, 247, 1) 0 3%, rgba(255, 244, 207, .98) 7%, rgba(255, 205, 120, .66) 19%, rgba(241, 164, 77, .18) 38%, transparent 62%),
    radial-gradient(ellipse at 68% 40%, rgba(255, 235, 187, .46), transparent 48%),
    linear-gradient(118deg, transparent 18%, rgba(255, 221, 158, .08) 48%, rgba(255, 247, 222, .32) 77%, rgba(255, 225, 166, .12) 100%);
  mix-blend-mode: screen;
  animation: dream-wash 1.8s cubic-bezier(.7,0,.25,1) 4.35s both;
}

.dream-wash::before,
.dream-wash::after {
  position: absolute;
  border-radius: 50%;
  content: "";
  opacity: 0;
  filter: blur(2px);
  animation: dream-lens-flare 1.5s ease-out 4.55s both;
}

.dream-wash::before {
  top: 47%;
  left: 47%;
  width: clamp(48px, 7vw, 110px);
  aspect-ratio: 1;
  border: 1px solid rgba(255, 229, 171, .28);
  box-shadow:
    0 0 26px rgba(255, 210, 125, .12),
    -18vw 13vh 0 -24px rgba(255, 244, 214, .11);
}

.dream-wash::after {
  top: 57%;
  left: 33%;
  width: clamp(22px, 3vw, 48px);
  aspect-ratio: 1;
  background: rgba(255, 222, 156, .12);
  box-shadow: 15vw -10vh 0 5px rgba(255, 244, 213, .08);
}

.dream-whisper {
  position: absolute;
  z-index: 3;
  bottom: max(9vh, 72px);
  width: 100%;
  margin: 0;
  color: rgba(240, 225, 196, .82);
  font-size: clamp(12px, 1.2vw, 16px);
  letter-spacing: .52em;
  text-align: center;
  text-indent: .52em;
  text-shadow: 0 2px 12px #000;
  opacity: 0;
  animation: dream-whisper 3.4s ease 1s both;
}

.dream-skip {
  position: absolute;
  z-index: 6;
  top: max(20px, env(safe-area-inset-top));
  right: max(22px, env(safe-area-inset-right));
  padding: 7px 13px;
  cursor: pointer;
  border: 1px solid rgba(240, 220, 180, .3);
  border-radius: 999px;
  background: rgba(4, 8, 15, .35);
  color: rgba(240, 225, 196, .68);
  font-size: 11px;
  letter-spacing: .18em;
  backdrop-filter: blur(6px);
}

@keyframes dream-city-breathe {
  0% { opacity: 0; transform: scale(1.1); }
  18% { opacity: 1; }
  100% { opacity: 1; transform: scale(1.015); }
}

@keyframes dream-focus-shift {
  0%, 58% { backdrop-filter: blur(0); }
  100% { backdrop-filter: blur(8px); }
}

@keyframes butterfly-flight {
  0% { top: 63%; left: -12vw; transform: scale(.46) rotate(-12deg); }
  24% { top: 43%; left: 22vw; transform: scale(.68) rotate(9deg); }
  48% { top: 51%; left: 47vw; transform: scale(.9) rotate(-7deg); }
  72% { top: 29%; left: 70vw; transform: scale(1.18) rotate(7deg); }
  100% { top: 37%; left: 108vw; transform: scale(1.5) rotate(-5deg); }
}

@keyframes dream-trail {
  0% { opacity: 0; transform: translateX(-8%); }
  25%, 72% { opacity: .8; }
  100% { opacity: 0; transform: translateX(10%); }
}

@keyframes dream-whisper {
  0%, 100% { opacity: 0; transform: translateY(8px); }
  25%, 68% { opacity: 1; transform: translateY(0); }
}

@keyframes dream-wash {
  0% { opacity: 0; filter: blur(18px) brightness(.9); transform: scale(.72); }
  42% { opacity: .82; filter: blur(7px) brightness(1.08); transform: scale(1.18); }
  72% { opacity: 1; filter: blur(2px) brightness(1.28); transform: scale(1.48); }
  100% { opacity: 1; filter: blur(0) brightness(1.12); transform: scale(1.72); }
}

@keyframes dream-lens-flare {
  0% { opacity: 0; transform: translate(12vw, -8vh) scale(.55); }
  45% { opacity: .72; }
  100% { opacity: .18; transform: translate(0, 0) scale(1.15); }
}

/* 命定信物：紙卷文物誌 */
.route-keepsake-modal {
  padding: clamp(10px, 2vh, 24px);
  overflow: hidden;
}

.route-keepsake-panel {
  width: min(1120px, 92vw);
  max-height: 94dvh;
  height: auto;
  padding: clamp(18px, 2.4vh, 28px);
  overflow-y: auto;
  border: 1px solid rgba(151, 118, 76, .65);
  background:
    linear-gradient(rgba(235, 225, 204, .8), rgba(220, 205, 177, .86)),
    url("./assets/images/letter/paper.webp") center / cover;
  box-shadow: inset 0 0 58px rgba(91, 63, 35, .22), 0 18px 70px rgba(0, 0, 0, .62);
  scrollbar-color: rgba(121, 86, 48, .6) transparent;
}

.route-keepsake-heading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: clamp(12px, 1.8vh, 20px);
  color: #80694e;
  font-family: "Noto Serif TC", serif;
  font-size: clamp(13px, 1.4vw, 19px);
  letter-spacing: .2em;
}

.route-keepsake-heading i {
  width: clamp(44px, 9vw, 120px);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(129, 94, 53, .55));
}

.route-keepsake-heading i:last-child { transform: scaleX(-1); }

.route-keepsake-close {
  position: sticky;
  float: right;
  top: 0;
  right: 0;
  z-index: 10;
  width: 42px;
  height: 42px;
  margin: -12px -8px -30px 0;
  border-color: rgba(126, 89, 48, .5);
  background: rgba(235, 222, 194, .86);
  color: #765539;
  box-shadow: 0 3px 12px rgba(71, 48, 27, .2);
  font-size: 28px;
}

.route-keepsake-list {
  display: grid;
  height: auto;
  grid-template-rows: none;
  gap: clamp(18px, 2.4vh, 26px);
}

.route-keepsake-card {
  position: relative;
  display: grid;
  height: auto;
  min-height: clamp(390px, 46vh, 500px);
  max-height: 100%;
  padding: 14px;
  cursor: default;
  overflow: hidden;
  border: 2px solid rgba(150, 115, 72, .56);
  border-radius: 0;
  background:
    linear-gradient(90deg, rgba(247, 242, 227, .44), rgba(223, 208, 180, .2)),
    url("./assets/images/letter/paper.webp") center / cover;
  box-shadow: inset 0 0 32px rgba(93, 65, 37, .14), 0 7px 18px rgba(72, 49, 29, .16);
  grid-template-columns: minmax(0, 51%) minmax(0, 49%);
  gap: 0;
  transform: none;
}

.route-keepsake-card::before {
  position: absolute;
  z-index: 6;
  inset: 8px;
  pointer-events: none;
  content: "";
  border: 1px solid rgba(154, 119, 75, .48);
  box-shadow: inset 0 0 0 3px rgba(249, 243, 225, .32);
}

.route-keepsake-card::after {
  position: absolute;
  z-index: 7;
  top: 4px;
  left: 50%;
  width: 16px;
  height: 16px;
  pointer-events: none;
  content: "";
  border: 1px solid rgba(155, 120, 76, .5);
  background: rgba(226, 211, 181, .82);
  transform: translateX(-50%) rotate(45deg);
}

.route-keepsake-card:hover,
.route-keepsake-card:focus-visible { transform: none; }

.route-keepsake-visual {
  position: relative;
  display: grid;
  min-width: 0;
  width: 100%;
  min-height: 360px;
  place-items: center;
  overflow: hidden;
  background:
    url("./assets/images/letter/ink_circle.webp") 61% 53% / min(82%, 390px) auto no-repeat,
    linear-gradient(90deg, rgba(218, 197, 160, .3), transparent 72%);
    background-size: cover;
}

.route-keepsake-visual::before {
  position: absolute;
  inset: 9% 5%;
  z-index: 0;
  content: "";
  background: url("./assets/images/letter/flower_sketch.webp") left 70% / 48% auto no-repeat;
  opacity: .3;
}

/* .route-keepsake-card.is-ancient .route-keepsake-visual::before {
  background-image: url("./assets/images/letter/mountain_wash.webp");
  background-position: center bottom;
  background-size: 92% auto;
  opacity: .42;
} */

.route-keepsake-visual > img {
  position: relative;
  z-index: 2;
  width: 72%;
  height: clamp(300px, 40vh, 430px);
  margin-left: 12%;
  object-fit: contain;
  filter: drop-shadow(0 18px 12px rgba(51, 36, 23, .3));
}

.route-keepsake-vertical {
  position: absolute;
  z-index: 4;
  inset: 18px auto 18px 10px;
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 9px;
}

.route-keepsake-vertical h3 {
  margin: 0;
  color: #4d3928;
  font-family: "Noto Serif TC", serif;
  max-height: 270px;
  font-size: clamp(17px, 1.9vw, 27px);
  font-weight: 600;
  letter-spacing: .15em;
  line-height: 1.18;
  writing-mode: vertical-rl;
}

.route-keepsake-serial {
  display: grid;
  width: 50px;
  height: 50px;
  background: url("./assets/images/letter/serial_number_badge.webp") center / contain no-repeat;
  font-family: "Noto Serif TC", serif;
  font-size: 1rem;
  color: #e7ddcc;
  place-items: center;
}

.route-keepsake-info {
  display: flex;
  min-width: 0;
  position: relative;
  z-index: 2;
  padding: clamp(32px, 4vw, 56px) clamp(28px, 3.5vw, 50px);
  justify-content: center;
  flex-direction: column;
}

.route-keepsake-info h4 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px;
  color: #70553a;
  font: 600 clamp(17px, 1.8vw, 23px)/1.3 "Noto Serif TC", serif;
  letter-spacing: .18em;
}

.route-keepsake-info h4 i {
  width: 18px;
  height: 1px;
  background: #a58a66;
}

.route-keepsake-info h4 i:last-child { flex: 1; }

.route-keepsake-info p {
  display: -webkit-box;
  margin: 0 0 clamp(18px, 2.5vh, 30px);
  overflow: hidden;
  color: #655443;
  font-size: clamp(12px, 1.2vw, 16px);
  letter-spacing: .08em;
  line-height: 1.85;
  white-space: pre-line;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 7;
}

.route-keepsake-info dl { display: grid; gap: 10px; margin: 0; }
.route-keepsake-info dl > div {
  display: grid;
  min-height: 36px;
  border: 1px solid rgba(150, 115, 75, .32);
  border-radius: 3px;
  grid-template-columns: 104px minmax(0, 1fr);
}
.route-keepsake-info dt {
  display: flex;
  align-items: center;
  padding: 6px 13px;
  color: #f4ead3;
  background: linear-gradient(90deg, rgba(114, 82, 48, .96), rgba(139, 105, 65, .88));
  font-size: 13px;
  letter-spacing: .18em;
}
.route-keepsake-info dd {
  display: flex;
  align-items: center;
  min-width: 0;
  margin: 0;
  padding: 6px 14px;
  color: #64513e;
  font-size: clamp(12px, 1.15vw, 15px);
  letter-spacing: .06em;
}

.route-keepsake-card.is-ancient .route-keepsake-visual { order: 2; }
.route-keepsake-card.is-ancient .route-keepsake-info { order: 1; }
.route-keepsake-card.is-ancient .route-keepsake-vertical { inset: 18px 10px 18px auto; }
.route-keepsake-card.is-ancient .route-keepsake-visual > img { margin-right: 12%; margin-left: 0; }
.route-keepsake-card.is-ancient .route-keepsake-visual {
  background-position: 39% 53%, center;
  background-image:
    url("./assets/images/letter/ink_circle.webp"),
    linear-gradient(270deg, rgba(218, 197, 160, .3), transparent 72%);
    background-size: cover;
}

@media (max-width: 600px) and (orientation: portrait) {
  .route-keepsake-modal { padding: 7px; }
  .route-keepsake-panel { width: 100%; max-height: calc(100dvh - 14px); padding: 20px 10px 14px; }
  .route-keepsake-heading { padding-inline: 34px; font-size: 11px; letter-spacing: .08em; }
  .route-keepsake-card { min-height: 0; grid-template-columns: 1fr; }
  .route-keepsake-visual { min-height: 100%; order: 1 !important; }
  .route-keepsake-info { padding: 24px 16px; order: 2 !important; }
  .route-keepsake-vertical h3 { font-size: 20px; }
  .route-keepsake-info p { -webkit-line-clamp: initial; }
  .route-keepsake-info dl > div { grid-template-columns: 94px minmax(0, 1fr); }
  .route-keepsake-info dt, .route-keepsake-info dd { padding-inline: 9px; }
}

@media (orientation: landscape) and (max-height: 600px) and (pointer: coarse) {
  .route-keepsake-panel { width: 96vw; max-height: 96dvh; padding: 16px 18px; }
  .route-keepsake-heading { margin-bottom: 12px; font-size: 11px; }
  .route-keepsake-card { min-height: 300px; grid-template-columns: 1fr; }
  .route-keepsake-visual { order: 1 !important; }
  .route-keepsake-info { order: 2 !important; }
  .route-keepsake-visual { min-height: 300px; }
  .route-keepsake-visual > img { height: 250px; }
  .route-keepsake-info { padding: 20px 28px; }
  .route-keepsake-info h4 { margin-bottom: 10px; font-size: 17px; }
  .route-keepsake-info p { margin-bottom: 12px; font-size: 11px; line-height: 1.55; -webkit-line-clamp: 4; }
  .route-keepsake-info dl { gap: 5px; }
  .route-keepsake-info dl > div { min-height: 29px; grid-template-columns: 92px 1fr; }
  .route-keepsake-info dt, .route-keepsake-info dd { padding-block: 3px; font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .dream-city { animation-duration: 1.2s; }
  .dream-butterfly { animation-duration: 1.2s; animation-delay: 0s; }
  .dream-butterfly-trail,
  .dream-whisper { display: none; }
  .dream-wash { animation-duration: .7s; animation-delay: .8s; }
}

#game,
.scene,
.screen {
  position: relative;
  width: 100%;
  height: 100%;
}

.scene {
  isolation: isolate;
  background: #07090d;
}

.scene-bg,
.vignette,
.story-effects,
.story-items,
.embers,
.transition {
  position: absolute;
  inset: 0;
}

.scene-bg {
  z-index: -3;
  background-color: #000;
  background-image: url("./assets/images/title-city.webp");
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: saturate(0.72) contrast(1.08);
  transform: scale(1);
  transition: opacity 1.4s ease, transform 8s ease;
}

.dialogue-active .scene-bg.is-story-transitioning {
  animation: story-background-arrive 1.15s ease-out both;
}

@keyframes story-background-arrive {
  from {
    opacity: .36;
    filter: saturate(.55) contrast(1.12) brightness(.66);
    transform: scale(1.035);
  }
  to {
    opacity: 1;
    filter: saturate(.72) contrast(1.08) brightness(1);
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dialogue-active .scene-bg.is-story-transitioning { animation: none; }
}

.scene-title .scene-bg {
  background-image: url("./assets/images/enter/bg_loading.webp");
  background-position: center;
  background-size: cover;
  filter: saturate(0.9) contrast(1.12) brightness(0.9);
  transform: scale(1);
  animation: none;
}

.scene-shop .scene-bg {
  background-image: url("./assets/images/scroll-shop.webp");
  background-position: center;
  transform: scale(1);
  animation: none;
}

.scene-home .scene-bg {
  background-image: url("./assets/images/index/bg_index.webp");
  background-position: center;
  transform: scale(1);
  animation: none;
}

.vignette {
  z-index: -2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.56), transparent 30%, transparent 62%, rgba(0, 0, 0, 0.84)),
    radial-gradient(circle at 50% 44%, transparent 22%, rgba(0, 0, 0, 0.64) 110%);
}

.scene-title .vignette {
  background:
    radial-gradient(circle at 50% 32%, rgba(255, 239, 192, 0.08), transparent 16%),
    radial-gradient(circle at 50% 52%, transparent 16%, rgba(0, 0, 0, 0.28) 48%, rgba(0, 0, 0, 0.72) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.2), transparent 42%, rgba(0, 0, 0, 0.78));
}

.scene-shop .vignette {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.35), transparent 42%, rgba(0, 0, 0, 0.82)),
    linear-gradient(90deg, rgba(0, 0, 0, 0.45), transparent 28%, transparent 70%, rgba(0, 0, 0, 0.4));
}

.story-effects {
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.story-items {
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.story-items:not(:empty)::before {
  position: absolute;
  inset: 8% 4% 25%;
  background: radial-gradient(circle at center, rgba(6, 7, 8, .16), rgba(4, 5, 6, .46) 68%, transparent 86%);
  content: "";
}

.story-item {
  position: absolute;
  top: 44%;
  z-index: 1;
  width: min(32vw, 430px);
  max-height: 58vh;
  object-fit: contain;
  opacity: 0;
  filter: drop-shadow(0 20px 30px rgba(0, 0, 0, .84));
  transform: translate(-50%, -50%) rotate(var(--item-rotate, 0deg));
  animation: story-item-reveal .65s ease-out forwards;
}

.story-item.is-left { left: 27%; }
.story-item.is-center { left: 50%; }
.story-item.is-right { left: 73%; }
.story-item.is-small { width: min(23vw, 300px); }
.story-item.is-medium { width: min(32vw, 430px); }
.story-item.is-wide { width: min(48vw, 650px); }
.story-item.is-tall { width: min(27vw, 360px); max-height: 64vh; }

.story-effect {
  position: absolute;
  inset: -6%;
  display: block;
  pointer-events: none;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.story-effect.is-rain {
  background-image: url("./assets/images/storyline/effect_rain.webp");
  opacity: .58;
  animation: story-rain-sheet .48s linear infinite;
}

.story-effect.is-heavy-rain {
  background-image: url("./assets/images/storyline/effect_heavy_rain.webp");
  opacity: .76;
  animation: story-rain-sheet .32s linear infinite;
}

.story-effect:is(.is-flash,.is-lightning) {
  background-image: url("./assets/images/storyline/effect_lightning.webp");
  mix-blend-mode: screen;
  animation: story-lightning .72s ease-out both;
}

.story-effect.is-fog {
  inset: 0 -12%;
  background-image: url("./assets/images/storyline/effect_fog.webp");
  opacity: .48;
  animation: story-fog-drift 9s ease-in-out infinite alternate;
}

.story-effect:is(.is-smoke,.is-dust) {
  inset: 5% -14% -12%;
  background-image: url("./assets/images/storyline/effect_smoke.webp");
  opacity: .64;
  animation: story-smoke-drift 7s ease-in-out infinite alternate;
}

.story-effect.is-dust {
  filter: sepia(.62) saturate(.72) brightness(.82);
}

.story-effect.is-fire-sparks {
  inset: 0;
  background-image:
    url("./assets/images/storyline/effect_fire_sparks01.webp"),
    url("./assets/images/storyline/effect_fire_sparks02.webp"),
    url("./assets/images/storyline/effect_fire_sparks03.webp");
  background-position: 18% 76%, 82% 42%, 54% 82%;
  background-size: 42% auto, 48% auto, 34% auto;
  opacity: .76;
  animation: story-sparks-rise 2.8s ease-in-out infinite alternate;
}

.story-effect.is-blood-splash {
  inset: 8% 12%;
  background-image: url("./assets/images/storyline/effect_blood_splash.webp");
  background-size: min(58vh, 520px) auto;
  mix-blend-mode: multiply;
  transform-origin: center;
  animation: story-blood-hit .7s ease-out both;
}

.story-effect.is-sword-flash {
  background-image: url("./assets/images/storyline/effect_sword_flash.webp");
  mix-blend-mode: screen;
  animation: story-sword-flash .55s ease-out both;
}

.story-effect:is(.is-screen-vignette,.is-vignette) {
  inset: 0;
  background-image: url("./assets/images/storyline/effect_screen_vignette.webp");
  opacity: .76;
  animation: story-vignette-in .75s ease-out both;
}

.effect-rain .vignette::after,
.effect-flash .vignette::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
}

.effect-rain .vignette::after {
  opacity: 0.42;
  background-image: repeating-linear-gradient(
    105deg,
    rgba(226, 236, 255, 0.22) 0 1px,
    transparent 1px 12px
  );
  background-size: 140px 140px;
  animation: rain-fall 0.42s linear infinite;
}

.effect-flash .vignette::before {
  background: rgba(255, 246, 214, 0.72);
  animation: flash-out 0.48s ease-out both;
}

.shake-soft {
  animation: scene-shake-soft 0.45s ease both;
}

.shake-medium {
  animation: scene-shake-medium 0.5s ease both;
}

.shake-strong {
  animation: scene-shake-strong 0.52s ease both;
}

.game-hud {
  position: absolute;
  z-index: 20;
  display: flex;
  top: var(--safe-top);
  right: max(20px, env(safe-area-inset-right));
  gap: 10px;
}

.scene-title .game-hud {
  display: none;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  cursor: pointer;
  border: 1px solid rgba(202, 166, 106, 0.45);
  border-radius: 50%;
  background: rgba(5, 6, 8, 0.5);
  box-shadow: inset 0 0 0 rgba(242, 212, 155, 0);
  place-items: center;
  backdrop-filter: blur(8px);
  transition:
    color 0.25s ease,
    border-color 0.25s ease,
    background 0.25s ease,
    box-shadow 0.25s ease,
    filter 0.25s ease,
    transform 0.18s ease;
}

.icon-button span {
  grid-area: 1 / 1;
  font-size: 12px;
  letter-spacing: 0.12em;
}

.music-toggle,
.home-exit-button {
  display: flex;
  width: auto;
  height: 46px;
  padding: 0 7px 0 3px;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  gap: 2px;
}

.music-toggle img,
.home-exit-button img {
  display: block;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  object-fit: contain;
  filter: drop-shadow(0 5px 7px rgba(0, 0, 0, 0.72));
}

.music-toggle .music-label,
.home-exit-button .home-exit-label {
  display: block;
  grid-area: auto;
  font-size: 9px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.music-toggle.music-muted img {
  filter: grayscale(0.72) brightness(0.52) drop-shadow(0 4px 6px rgba(0, 0, 0, 0.7));
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: rgba(242, 212, 155, 0.95);
  background: rgba(83, 55, 28, 0.66);
  color: #ffe6b5;
  box-shadow:
    inset 0 0 14px rgba(242, 212, 155, 0.22),
    0 0 10px rgba(225, 173, 86, 0.72),
    0 0 26px rgba(225, 173, 86, 0.42);
  filter: brightness(1.18);
  transform: translateY(-1px);
}

.icon-button:active {
  background: rgba(122, 78, 35, 0.78);
  box-shadow:
    inset 0 0 18px rgba(255, 224, 164, 0.4),
    0 0 14px rgba(239, 189, 102, 0.9),
    0 0 34px rgba(225, 173, 86, 0.58);
  transform: translateY(1px) scale(0.96);
}

.music-toggle.music-started:not(.music-muted) {
  border-color: rgba(202, 166, 106, 0.7);
  box-shadow:
    inset 0 0 10px rgba(202, 166, 106, 0.12),
    0 0 10px rgba(202, 166, 106, 0.22);
}

.music-toggle:hover,
.music-toggle:focus-visible,
.music-toggle:active,
.music-toggle.music-started:not(.music-muted) {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.sound-off,
.music-off,
.is-muted .sound-on,
.music-muted .music-on {
  display: none;
}

.is-muted .sound-off,
.music-muted .music-off {
  display: block;
}

.music-toggle:not(.music-started) {
  opacity: 0.58;
}

.title-screen {
  display: flex;
  z-index: 1;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  padding: 16vh 24px var(--safe-bottom);
  text-align: center;
  animation: reveal 1.7s ease both;
}

.eyebrow {
  display: none;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: clamp(11px, 1.1vw, 14px);
  letter-spacing: 0.58em;
  text-indent: 0.58em;
}

.game-title {
  display: block;
  width: min(660px, 46vw);
  margin: 0;
  line-height: 0;
  filter:
    drop-shadow(0 0 12px rgba(250, 214, 148, 0.28))
    drop-shadow(0 12px 28px rgba(0, 0, 0, 0.95));
}

.game-title img {
  display: block;
  width: 100%;
  height: auto;
}

.title-rule {
  display: none;
  width: min(620px, 76vw);
  margin-top: 24px;
  filter: drop-shadow(0 5px 16px rgba(0, 0, 0, 0.9));
  line-height: 0;
}

.title-rule img {
  display: block;
  width: 100%;
  height: auto;
}

.title-copy {
  display: none;
  margin: 18px 0 26px;
  color: rgba(234, 220, 192, 0.75);
  font-size: clamp(13px, 1.2vw, 17px);
  letter-spacing: 0.28em;
}

.enter-button {
  position: relative;
  width: min(360px, 34vw);
  min-width: 260px;
  min-height: 74px;
  margin-top: clamp(38px, 7vh, 82px);
  padding: 0 42px;
  cursor: pointer;
  border: 0;
  background: url("./assets/images/enter/btn.webp") center / 100% 100% no-repeat;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.54);
  transition: filter 0.25s ease, transform 0.25s ease;
}

.enter-button::before,
.enter-button::after {
  display: none;
}

.enter-button::before {
  right: calc(100% + 15px);
}

.enter-button::after {
  left: calc(100% + 15px);
  transform: rotate(180deg);
}

.enter-button:hover,
.enter-button:focus-visible,
.enter-button:active {
  background-image: url("./assets/images/enter/btn_hover.webp");
  filter:
    brightness(1.18)
    drop-shadow(0 0 14px rgba(229, 174, 91, 0.5));
  transform: translateY(-2px);
}

.enter-button span,
.enter-button small {
  display: block;
}

.enter-button span {
  color: #f4e8cf;
  font-size: clamp(22px, 2vw, 32px);
  line-height: 1;
  letter-spacing: 0.72em;
  text-indent: 0.72em;
  text-shadow:
    0 0 12px rgba(238, 206, 154, 0.55),
    0 2px 8px rgba(0, 0, 0, 0.88);
}

.enter-button small {
  display: none;
}

.enter-user-icon {
  display: block;
  width: clamp(44px, 4.8vw, 72px);
  height: auto;
  margin-top: clamp(14px, 2.3vh, 28px);
  opacity: 0.86;
  filter:
    drop-shadow(0 0 10px rgba(232, 194, 137, 0.22))
    drop-shadow(0 8px 18px rgba(0, 0, 0, 0.72));
  pointer-events: none;
}

.headphone-note {
  position: absolute;
  bottom: var(--safe-bottom);
  margin: 0;
  color: rgba(234, 220, 192, 0.44);
  font-size: 10px;
  letter-spacing: 0.22em;
}

.passcode-modal {
  position: fixed;
  z-index: 40;
  inset: 0;
  display: grid;
  padding: 24px;
  background: rgba(4, 3, 2, 0.76);
  backdrop-filter: blur(5px);
  place-items: center;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.passcode-modal[hidden] {
  display: none;
}

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

.passcode-scroll {
  position: relative;
  width: min(470px, 92vw);
  padding: 52px 58px 46px;
  border: 1px solid rgba(113, 65, 32, 0.72);
  background:
    linear-gradient(90deg, rgba(91, 47, 22, 0.12), transparent 14%, transparent 86%, rgba(91, 47, 22, 0.12)),
    repeating-linear-gradient(0deg, rgba(102, 65, 35, 0.035) 0 1px, transparent 1px 5px),
    #d7c199;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.78), inset 0 0 42px rgba(92, 48, 20, 0.26);
  color: #3c2619;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.25s ease;
}

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

.passcode-scroll::before,
.passcode-scroll::after {
  position: absolute;
  right: 22px;
  left: 22px;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, #6e3c22 18%, #6e3c22 82%, transparent);
}

.passcode-scroll::before { top: 20px; }
.passcode-scroll::after { bottom: 20px; }

.passcode-close {
  position: absolute;
  z-index: 1;
  top: 24px;
  right: 24px;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(77, 41, 22, 0.45);
  border-radius: 50%;
  background: rgba(105, 59, 31, 0.08);
  color: #59331f;
  font-size: 24px;
  line-height: 1;
}

.passcode-kicker {
  margin: 0 0 12px;
  color: #7d261f;
  font-size: 12px;
  letter-spacing: 0.55em;
  text-indent: 0.55em;
}

.passcode-scroll h2 {
  margin: 0;
  font-family: "Noto Serif TC", "Songti TC", serif;
  font-size: clamp(27px, 4vw, 36px);
  font-weight: 600;
  letter-spacing: 0.15em;
}

#passcode-instruction {
  margin: 14px 0 28px;
  color: rgba(60, 38, 25, 0.72);
  font-size: 14px;
  letter-spacing: 0.08em;
}

#passcode-form label,
#nickname-form label {
  display: block;
  margin-bottom: 9px;
  font-size: 13px;
  letter-spacing: 0.28em;
}

.passcode-input-wrap {
  position: relative;
}

#passcode-input {
  width: 100%;
  height: 52px;
  padding: 4px 52px 9px 16px;
  border: 0;
  border-bottom: 1px solid #70442c;
  border-radius: 0;
  outline: none;
  background: rgba(255, 249, 225, 0.28);
  color: #352015;
  font-family: Georgia, serif;
  font-size: 30px;
  letter-spacing: 0.55em;
  text-align: center;
}

.passcode-visibility {
  position: absolute;
  top: 50%;
  right: 8px;
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(70, 42, 27, 0.66);
  cursor: pointer;
  transform: translateY(-50%);
  place-items: center;
}

.passcode-visibility:hover,
.passcode-visibility:focus-visible {
  background: rgba(91, 54, 31, 0.1);
  color: #4b2d1e;
  outline: none;
}

.passcode-eye {
  position: relative;
  display: block;
  width: 21px;
  height: 14px;
  border: 1.5px solid currentColor;
  border-radius: 70% 20% 70% 20%;
  transform: rotate(45deg);
}

.passcode-eye::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  content: "";
  transform: translate(-50%, -50%);
}

.passcode-visibility[aria-pressed="true"] .passcode-eye::after {
  position: absolute;
  top: 50%;
  left: -3px;
  width: 27px;
  height: 1.5px;
  background: currentColor;
  content: "";
  transform: rotate(-45deg);
  transform-origin: center;
}

#nickname-input {
  width: 100%;
  height: 52px;
  padding: 4px 16px 8px;
  border: 0;
  border-bottom: 1px solid #70442c;
  border-radius: 0;
  outline: none;
  background: rgba(255, 249, 225, 0.28);
  color: #352015;
  font-family: "Noto Serif TC", "Songti TC", serif;
  font-size: 24px;
  letter-spacing: 0.12em;
  text-align: center;
}

#passcode-input:focus,
#nickname-input:focus {
  box-shadow: 0 7px 12px -10px #70271f;
}

#passcode-input.is-invalid,
#nickname-input.is-invalid {
  border-color: #8e241c;
  animation: passcode-shake 0.28s ease;
}

.passcode-error {
  min-height: 22px;
  margin: 9px 0 12px;
  color: #8e241c;
  font-size: 13px;
  letter-spacing: 0.05em;
}

.passcode-submit {
  width: 100%;
  min-height: 48px;
  border: 1px solid #6f3d25;
  background: #4b2d1e;
  color: #ead8af;
  font-family: "Noto Serif TC", "Songti TC", serif;
  font-size: 16px;
  letter-spacing: 0.38em;
  text-indent: 0.38em;
  transition: background 0.2s ease, transform 0.2s ease;
}

.passcode-submit:hover,
.passcode-submit:focus-visible {
  background: #6b3b25;
  transform: translateY(-1px);
}

@keyframes passcode-shake {
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@media (max-width: 560px) and (orientation: portrait) {
  .passcode-scroll { padding: 48px 28px 38px; }
  .passcode-close { top: 22px; right: 18px; }
}

.home-screen {
  z-index: 2;
  padding: var(--safe-top) max(24px, env(safe-area-inset-right)) var(--safe-bottom) max(24px, env(safe-area-inset-left));
  overflow: hidden;
  animation: reveal 0.8s ease both;
}

.home-screen::before,
.home-screen::after {
  position: absolute;
  pointer-events: none;
  content: "";
}

.home-screen::before {
  inset: 0;
  /* background:
    radial-gradient(circle at 50% 44%, rgba(158, 91, 39, 0.18), transparent 34%),
    linear-gradient(180deg, rgba(3, 4, 6, 0.24), rgba(3, 4, 6, 0.72)); */
}

.home-screen::after {
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.12), transparent 25%, transparent 72%, rgba(0, 0, 0, 0.36));
}

.home-topbar,
.home-centerpiece,
.home-actions {
  position: relative;
  z-index: 2;
}

.home-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  /* padding-right: 64px; */
}

.profile-card,
.home-resources,
.lantern-pill {
  display: flex;
  align-items: center;
}

.profile-card {
  min-width: min(310px, 48vw);
  padding: 4px 14px 4px 4px;
  border: 0;
  background: linear-gradient(90deg, rgba(2, 2, 2, 0.68), rgba(2, 2, 2, 0.18) 84%, transparent);
  gap: 14px;
}

.profile-avatar {
  position: relative;
  width: 86px;
  height: 86px;
  flex: 0 0 86px;
  padding: 5px;
  border: 1px solid rgba(235, 203, 143, 0.8);
  border-radius: 50%;
  background: rgba(12, 9, 7, 0.8);
  box-shadow: inset 0 0 0 2px #18120c, inset 0 0 0 3px rgba(235, 203, 143, 0.42), 0 0 14px rgba(219, 163, 76, 0.18);
}

.profile-avatar::after {
  position: absolute;
  inset: -5px;
  border: 1px solid rgba(171, 126, 65, 0.42);
  border-radius: 50%;
  content: "";
}

.profile-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.profile-info {
  width: 168px;
}

.profile-card p,
.home-centerpiece p,
.modal-kicker {
  margin: 0;
  color: rgba(234, 220, 192, 0.56);
  font-size: 11px;
  letter-spacing: 0.3em;
}

.profile-card strong {
  display: block;
  margin: 0 0 5px;
  color: #f1dfbd;
  font-size: clamp(18px, 1.8vw, 25px);
  font-weight: 600;
  letter-spacing: 0.18em;
}

.profile-card p {
  color: rgba(241, 223, 189, 0.82);
  font-size: 13px;
  letter-spacing: 0.16em;
}

.profile-progress {
  display: block;
  width: 100%;
  height: 4px;
  margin-top: 7px;
  background: rgba(227, 210, 178, 0.2);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.72);
}

.profile-progress b {
  display: block;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, #c9973f, #f0c86e);
  box-shadow: 0 0 5px rgba(230, 177, 76, 0.48);
  transition: width 0.5s ease;
}

.home-resources {
  gap: 10px;
}

.reward-button,
.lantern-pill {
  min-height: 44px;
  border: 1px solid rgba(202, 166, 106, 0.46);
  border-radius: 999px;
  background: rgba(5, 6, 8, 0.52);
  color: #e9d2a8;
  box-shadow: inset 0 0 18px rgba(202, 166, 106, 0.08);
  backdrop-filter: blur(10px);
}

.reward-button {
  display: flex;
  align-items: center;
  padding: 0 14px 0 7px;
  cursor: pointer;
  border: 0;
  font-size: 12px;
  letter-spacing: 0.2em;
  gap: 5px;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.2s ease;
}

.reward-button img {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  object-fit: contain;
  filter: drop-shadow(0 5px 7px rgba(0, 0, 0, 0.6));
}

.reward-button span {
  white-space: nowrap;
}

.reward-button:hover,
.reward-button:focus-visible {
  border-color: transparent;
  box-shadow: inset 0 0 18px rgba(242, 212, 155, 0.16), 0 0 18px rgba(225, 173, 86, 0.38);
  transform: translateY(-1px);
}

.home-exit-button:hover,
.home-exit-button:focus-visible {
  border-color: transparent;
  background: rgba(5, 6, 8, 0.52);
  color: inherit;
  box-shadow: inset 0 0 18px rgba(242, 212, 155, 0.16), 0 0 18px rgba(225, 173, 86, 0.38);
  filter: none;
  transform: translateY(-1px);
}

.reward-button.is-claimed {
  opacity: 1;
}

.lantern-pill {
  min-width: 108px;
  padding: 0 14px 0 11px;
  border-color: transparent;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(4, 4, 4, 0.72), rgba(4, 4, 4, 0.24), transparent);
  gap: 11px;
}

.lantern-hud-icon {
  display: block;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  object-fit: contain;
  filter: drop-shadow(0 0 5px rgba(235, 137, 47, 0.56)) drop-shadow(0 5px 6px rgba(0, 0, 0, 0.68));
}

.lantern-pill strong {
  color: #f1dfbd;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 6px #000;
}

/* 首頁右上角資源列：燈盞、登入獎勵與音樂使用同一尺寸系統。 */
.home-resources {
  gap: 10px;
}

.home-resources .lantern-pill,
.home-resources .reward-button,
.home-resources .music-toggle,
.home-resources .home-exit-button {
  min-width: 0;
  height: 46px;
  min-height: 46px;
  padding: 0 7px;
  gap: 5px;
}

.home-resources .lantern-hud-icon,
.home-resources .reward-button img,
.home-resources .music-toggle img,
.home-resources .home-exit-button img {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
}

.home-resources .lantern-pill strong,
.home-resources .reward-button span,
.home-resources .music-label,
.home-resources .home-exit-label {
  font-family: "Noto Serif TC", "Songti TC", "STSong", serif;
  font-size: 11px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.home-action-button.is-access-locked {
  cursor: not-allowed;
  filter: grayscale(0.88) brightness(0.42);
  opacity: 0.62;
}

.home-action-button.is-access-locked::after {
  content: "此密令未開放";
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%);
  padding: 5px 12px;
  border: 1px solid rgba(185, 143, 76, 0.58);
  color: #c6a674;
  background: rgba(8, 7, 6, 0.88);
  font-family: "Noto Serif TC", "Songti TC", serif;
  font-size: 12px;
  letter-spacing: 0.12em;
  white-space: nowrap;
  pointer-events: none;
}

.home-action-button.is-access-locked:hover,
.home-action-button.is-access-locked:focus-visible {
  transform: none;
  filter: grayscale(0.88) brightness(0.42);
}

.home-centerpiece {
  position: absolute;
  top: 42%;
  left: 50%;
  width: min(620px, 82vw);
  padding: clamp(22px, 4vw, 38px);
  border: 1px solid rgba(202, 166, 106, 0.3);
  background:
    linear-gradient(135deg, rgba(9, 8, 7, 0.72), rgba(30, 20, 13, 0.48)),
    rgba(5, 6, 8, 0.32);
  box-shadow: inset 0 0 34px rgba(202, 166, 106, 0.08), 0 22px 60px rgba(0, 0, 0, 0.34);
  text-align: center;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(8px);
}

.home-centerpiece h2 {
  margin: 12px 0 14px;
  color: #f1dfbd;
  font-size: clamp(32px, 5vw, 62px);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
}

.home-centerpiece span {
  color: rgba(234, 220, 192, 0.72);
  font-size: clamp(12px, 1.4vw, 16px);
  letter-spacing: 0.12em;
  line-height: 1.9;
}

.home-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-direction: row;
    height: calc(90vh - 90px);
    width: 100%;
    padding: 5% 0;
}

.home-actions-left,.home-actions-right{
    display: inline-flex;
    width: 30%;
}

.home-action-button {
  position: relative;
  align-self: stretch;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: visible;
  cursor: pointer;
  border: 0;
  background: transparent;
  filter: brightness(0.94) drop-shadow(0 13px 18px rgba(0, 0, 0, 0.52));
  transition: filter 0.28s ease, transform 0.24s ease;
  height: auto;
  display: flex;
  align-self: center;
}

.home-action-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  pointer-events: none;
}

.home-action-button:hover,
.home-action-button:focus,
.home-action-button:focus-visible,
.home-action-button:active,
.home-action-button.is-active {
  filter: brightness(1.12) saturate(1.05) drop-shadow(0 0 9px rgba(226, 161, 70, 0.5)) drop-shadow(0 16px 20px rgba(0, 0, 0, 0.62));
  transform: translateY(-5px) scale(1.018);
}

.home-action-button.is-primary {
  border-color: transparent;
}

.home-swipe-hint {
  display: none;
}

.home-modal {
  position: fixed;
  z-index: 40;
  inset: 0;
  display: grid;
  padding: 28px;
  background: rgba(3, 4, 6, 0.72);
  backdrop-filter: blur(8px);
  place-items: center;
  animation: reveal 0.35s ease both;
}

.home-modal-card {
  position: relative;
  width: min(720px, 92vw);
  max-height: min(760px, 86dvh);
  overflow: auto;
  padding: clamp(26px, 5vw, 46px);
  border: 1px solid rgba(202, 166, 106, 0.42);
  background:
    radial-gradient(circle at 76% 16%, rgba(202, 166, 106, 0.14), transparent 34%),
    linear-gradient(135deg, rgba(29, 20, 14, 0.96), rgba(7, 8, 10, 0.96));
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.66);
}

.home-modal-close {
  position: absolute;
  z-index: 20;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  border: 1px solid rgba(202, 166, 106, 0.42);
  border-radius: 50%;
  background: rgba(5, 6, 8, 0.45);
  color: #f2d49b;
  font-size: 24px;
  line-height: 1;
  pointer-events: auto;
  touch-action: manipulation;
}

.story-map-card > #close-story-menu-button {
  z-index: 30;
}

.login-calendar-card {
  position: relative;
  width: min(720px, 94vw);
  max-height: min(840px, 92dvh);
  padding: clamp(24px, 4vw, 42px);
  overflow: auto;
  border: 1px solid rgba(213, 165, 87, 0.58);
  background:
    radial-gradient(circle at 50% 0, rgba(198, 125, 43, 0.2), transparent 34%),
    linear-gradient(145deg, rgba(31, 20, 13, 0.98), rgba(7, 8, 10, 0.98));
  box-shadow: inset 0 0 0 1px rgba(255, 225, 168, 0.08), inset 0 0 60px rgba(184, 108, 37, 0.08), 0 30px 90px rgba(0, 0, 0, 0.72);
}

.login-calendar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 22px;
  text-align: left;
  gap: 14px;
}

.login-calendar-header img {
  width: 68px;
  height: 68px;
  object-fit: contain;
  filter: drop-shadow(0 7px 10px rgba(0, 0, 0, 0.58));
}

.login-calendar-header p,
.login-calendar-header h2 {
  margin: 0;
}

.login-calendar-header p {
  color: rgba(232, 207, 165, 0.58);
  font-size: 11px;
  letter-spacing: 0.3em;
}

.login-calendar-header h2 {
  margin-top: 4px;
  padding-right: 31px;
  color: #f4d79e;
  font-size: clamp(22px, 3.6vw, 34px);
  font-weight: 600;
  letter-spacing: 0.12em;
}

.login-calendar-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
}

.login-day {
  min-height: 76px;
}

.login-day {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 6px 3px;
  cursor: pointer;
  border: 1px solid rgba(202, 166, 106, 0.25);
  background: rgba(7, 7, 7, 0.48);
  color: #d7c29d;
  gap: 2px;
}

.login-day span {
  position: absolute;
  top: 4px;
  left: 6px;
  color: rgba(234, 220, 192, 0.48);
  font-family: Georgia, serif;
  font-size: 10px;
}

.login-day b {
  display: flex;
  align-items: center;
  color: #f1d39a;
  font-family: Georgia, serif;
  font-size: 16px;
  font-weight: 400;
  gap: 2px;
}

.login-day b img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.login-day em {
  color: #f0a95c;
  font-family: Georgia, serif;
  font-size: 9px;
  font-style: normal;
}

.login-day small {
  color: rgba(234, 220, 192, 0.46);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.login-day.is-today {
  border-color: #e6b86f;
  background: radial-gradient(circle, rgba(161, 88, 30, 0.42), rgba(14, 10, 8, 0.72));
  box-shadow: inset 0 0 16px rgba(242, 190, 98, 0.13), 0 0 12px rgba(222, 150, 62, 0.25);
}

.login-day.is-bonus::after {
  position: absolute;
  top: -4px;
  right: -3px;
  padding: 2px 4px;
  border-radius: 2px;
  background: #7d321f;
  color: #ffd89b;
  font-size: 7px;
  content: "加倍";
}

.login-day.is-claimed {
  border-color: rgba(198, 155, 82, 0.42);
  background: rgba(63, 43, 24, 0.5);
}

.login-day.is-claimed small {
  color: #d8ae6a;
}

.login-day.is-missed,
.login-day.is-future {
  cursor: default;
  filter: grayscale(0.62) brightness(0.58);
}

.login-calendar-footer {
  display: grid;
  justify-items: center;
  margin-top: 22px;
  gap: 14px;
}

.login-calendar-footer p {
  margin: 0;
  color: rgba(234, 220, 192, 0.58);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-align: center;
}

.login-calendar-footer button {
  min-width: 220px;
  min-height: 48px;
  padding: 0 24px;
  cursor: pointer;
  border: 1px solid rgba(235, 194, 119, 0.68);
  background: linear-gradient(180deg, rgba(126, 73, 29, 0.92), rgba(51, 28, 17, 0.94));
  color: #ffe0a8;
  box-shadow: inset 0 0 18px rgba(255, 218, 148, 0.13), 0 8px 18px rgba(0, 0, 0, 0.4);
  letter-spacing: 0.16em;
}

.login-calendar-footer button:disabled {
  cursor: default;
  opacity: 0.46;
}

.home-exit-card {
  position: relative;
  width: min(520px, calc(100vw - 32px));
  padding: clamp(34px, 6vw, 54px) clamp(24px, 6vw, 48px) clamp(28px, 5vw, 42px);
  overflow: hidden;
  border: 1px solid rgba(211, 165, 90, 0.58);
  background:
    radial-gradient(circle at 50% 0, rgba(195, 119, 39, 0.18), transparent 38%),
    linear-gradient(145deg, rgba(34, 22, 14, 0.98), rgba(7, 8, 10, 0.98));
  box-shadow: inset 0 0 0 1px rgba(255, 228, 172, 0.08), inset 0 0 52px rgba(156, 89, 31, 0.08), 0 28px 80px rgba(0, 0, 0, 0.76);
  text-align: center;
}

.home-exit-card::before,
.home-exit-card::after {
  position: absolute;
  right: 18px;
  left: 18px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(224, 176, 98, 0.54), transparent);
  content: "";
}

.home-exit-card::before { top: 18px; }
.home-exit-card::after { bottom: 18px; }

.home-exit-kicker {
  margin: 0 0 8px;
  color: rgba(231, 204, 160, 0.55);
  font-size: 10px;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
}

.home-exit-card h2 {
  margin: 0;
  color: #f1d49b;
  font-size: clamp(26px, 5vw, 38px);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.72);
}

#home-exit-copy {
  margin: 14px auto 24px;
  color: rgba(235, 218, 187, 0.68);
  font-size: 12px;
  letter-spacing: 0.08em;
  line-height: 1.8;
}

.home-exit-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.home-exit-choice {
  display: grid;
  min-height: 78px;
  padding: 12px 10px;
  cursor: pointer;
  border: 1px solid rgba(218, 174, 98, 0.48);
  background: linear-gradient(180deg, rgba(105, 65, 30, 0.56), rgba(25, 17, 12, 0.84));
  color: #f2d6a0;
  place-content: center;
  gap: 6px;
  transition: filter 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.home-exit-choice.is-danger {
  border-color: rgba(170, 91, 63, 0.62);
  background: linear-gradient(180deg, rgba(105, 45, 32, 0.62), rgba(29, 14, 12, 0.88));
}

.home-exit-choice:hover,
.home-exit-choice:focus-visible {
  border-color: #f0cf91;
  filter: brightness(1.14);
  transform: translateY(-2px);
}

.home-exit-choice span {
  font-size: 16px;
  letter-spacing: 0.14em;
}

.home-exit-choice small {
  color: rgba(235, 218, 187, 0.56);
  font-size: 9px;
  letter-spacing: 0.05em;
}

.close-window-status {
  min-height: 1.6em;
  margin: 14px 0 0;
  color: #d9b677;
  font-size: 10px;
  letter-spacing: 0.08em;
}

.home-modal-card h2 {
  margin: 9px 0 24px;
  color: #f1dfbd;
  font-size: clamp(28px, 4vw, 46px);
  font-weight: 600;
  letter-spacing: 0.16em;
}

.chapter-list {
  display: grid;
  gap: 14px;
}

.chapter-entry,
.minigame-entry {
  padding: 18px 20px;
  cursor: pointer;
  border: 1px solid rgba(202, 166, 106, 0.34);
  background: rgba(5, 6, 8, 0.42);
  color: #eadcc0;
  text-align: left;
  transition: border-color 0.25s ease, background 0.25s ease, transform 0.2s ease;
}

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

.chapter-entry:not(:disabled):hover,
.chapter-entry:not(:disabled):focus-visible,
.minigame-entry:not(:disabled):hover,
.minigame-entry:not(:disabled):focus-visible {
  border-color: #f2d49b;
  background: rgba(92, 59, 29, 0.38);
  transform: translateY(-2px);
}

.chapter-entry:disabled,
.chapter-entry.is-locked,
.minigame-entry:disabled,
.minigame-entry.is-locked {
  cursor: not-allowed;
  border-color: rgba(132, 121, 104, 0.24);
  background:
    linear-gradient(135deg, rgba(5, 6, 8, 0.62), rgba(27, 27, 28, 0.48));
  color: rgba(234, 220, 192, 0.38);
  filter: grayscale(0.72);
}

.chapter-entry.is-locked b,
.chapter-entry.is-locked span,
.minigame-entry.is-locked b,
.minigame-entry.is-locked span {
  color: rgba(234, 220, 192, 0.38);
}

.chapter-entry.is-locked::after {
  float: right;
  margin-top: -8px;
  content: "未解鎖";
  color: rgba(202, 166, 106, 0.58);
  font-size: 11px;
  letter-spacing: 0.18em;
}

.chapter-entry.is-cleared:not(.is-locked)::after {
  float: right;
  margin-top: -8px;
  content: "已讀";
  color: #caa66a;
  font-size: 11px;
  letter-spacing: 0.18em;
}

.chapter-entry span,
.chapter-entry b,
.chapter-entry small,
.minigame-entry span,
.minigame-entry b,
.minigame-entry small {
  display: block;
}

.chapter-entry span,
.minigame-entry span {
  color: #caa66a;
  font-size: 11px;
  letter-spacing: 0.28em;
}

.chapter-entry b,
.minigame-entry b {
  margin-top: 6px;
  color: #f1dfbd;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.16em;
}

.chapter-entry small,
.minigame-entry small {
  margin-top: 8px;
  color: rgba(234, 220, 192, 0.56);
  font-size: 12px;
  letter-spacing: 0.08em;
  line-height: 1.7;
}

/* Story chapter map */
.story-map-card {
  box-sizing: border-box;
  width: min(1440px, calc(100vw - 56px));
  min-height: min(760px, 92dvh);
  max-height: 94dvh;
  overflow: hidden;
  padding: clamp(24px, 3.2vw, 42px);
  background: url("./assets/images/storyline/story_map_background.webp") center / cover no-repeat;
}

.story-map-card::before {
  position: absolute;
  inset: 10px;
  pointer-events: none;
  content: "";
  border: 1px solid rgba(210, 164, 85, 0.27);
  box-shadow: inset 0 0 70px rgba(0, 0, 0, 0.78);
}

.story-map-heading { position: relative; z-index: 1; }
.story-map-heading h2 { margin-bottom: 7px; }
.story-map-heading > p:last-child,
.story-map-hint { margin: 0; color: rgba(235, 216, 181, 0.62); font-size: 12px; letter-spacing: .1em; }

.story-map-progress {
  position: absolute;
  z-index: 2;
  top: 46px;
  right: 70px;
  display: grid;
  width: 190px;
  grid-template-columns: 1fr auto;
  gap: 7px 12px;
  color: #d7b77b;
  font-size: 11px;
  letter-spacing: .14em;
}
.story-map-progress strong { color: #ffe2a7; font-family: Georgia, serif; font-size: 16px; }
.story-map-progress i { grid-column: 1 / -1; height: 3px; overflow: hidden; background: rgba(220, 183, 112, .16); }
.story-map-progress i b { display: block; width: 0; height: 100%; background: #e6b75f; box-shadow: 0 0 12px #f2b84f; transition: width .5s ease; }

.story-map-card .chapter-list {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 440px;
  margin: 24px 14px 12px;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  align-items: center;
  gap: 0;
}
.chapter-route {
  position: absolute;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.chapter-route path {
  fill: none;
  vector-effect: non-scaling-stroke;
}
.chapter-route-glow {
  stroke: rgba(230, 167, 69, .2);
  stroke-width: 9;
  filter: blur(4px);
}
.chapter-route-line {
  stroke: rgba(245, 207, 137, .78);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 8 11;
  filter: drop-shadow(0 0 4px rgba(232, 167, 61, .9));
  animation: chapter-route-flow 18s linear infinite;
}
@keyframes chapter-route-flow {
  to { stroke-dashoffset: -190; }
}
.chapter-horse {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 0;
  width: 112px;
  height: 112px;
  pointer-events: none;
  background: url("./assets/images/storyline/horse/idle_01.webp") center / contain no-repeat;
  filter: drop-shadow(0 5px 5px rgba(0, 0, 0, .8)) drop-shadow(0 0 9px rgba(241, 177, 72, .55));
  transform: translate(calc(var(--horse-x, 0px) - 56px), calc(var(--horse-y, 0px) - 90px));
  transition: transform 1s cubic-bezier(.36, .08, .24, 1);
  animation: horse-idle .8s steps(1) infinite;
}
.chapter-horse.is-travelling { animation: horse-run .6s steps(1) infinite; }
@keyframes horse-idle {
  0%, 100% { background-image: url("./assets/images/storyline/horse/idle_01.webp"); }
  25% { background-image: url("./assets/images/storyline/horse/idle_02.webp"); }
  50% { background-image: url("./assets/images/storyline/horse/idle_03.webp"); }
  75% { background-image: url("./assets/images/storyline/horse/idle_04.webp"); }
}
@keyframes horse-run {
  0%, 100% { background-image: url("./assets/images/storyline/horse/run_01.webp"); }
  16.67% { background-image: url("./assets/images/storyline/horse/run_02.webp"); }
  33.33% { background-image: url("./assets/images/storyline/horse/run_03.webp"); }
  50% { background-image: url("./assets/images/storyline/horse/run_04.webp"); }
  66.67% { background-image: url("./assets/images/storyline/horse/run_05.webp"); }
  83.33% { background-image: url("./assets/images/storyline/horse/run_06.webp"); }
}
.story-map-card .chapter-entry {
  --chapter-offset-y: -42px;
  position: relative;
  align-self: center;
  min-width: 0;
  padding: 0 7px;
  border: 0;
  background: none;
  text-align: center;
  filter: none;
  transform: translateY(var(--chapter-offset-y));
}
.story-map-card .chapter-entry:nth-of-type(2) { --chapter-offset-y: 68px; }
.story-map-card .chapter-entry:nth-of-type(3) { --chapter-offset-y: -76px; }
.story-map-card .chapter-entry:nth-of-type(4) { --chapter-offset-y: 34px; }
.story-map-card .chapter-entry:nth-of-type(5) { --chapter-offset-y: -48px; }
.story-map-card .chapter-entry:nth-of-type(6) { --chapter-offset-y: 62px; }
.story-map-card .chapter-entry:not(:disabled):hover,
.story-map-card .chapter-entry:not(:disabled):focus-visible {
  border: 0;
  background: none;
  transform: translateY(var(--chapter-offset-y));
}
.chapter-node {
  position: relative;
  display: grid !important;
  width: 72px;
  height: 72px;
  margin: 0 auto 15px;
  border: 1px solid #b88948;
  background: radial-gradient(circle, #573515 0, #17100a 68%);
  box-shadow: 0 0 0 6px rgba(24, 15, 8, .85), 0 0 0 7px rgba(208, 158, 78, .5), 0 0 22px rgba(229, 166, 65, .36);
  place-items: center;
  transform: rotate(45deg);
  transition: filter .2s ease, box-shadow .2s ease, transform .2s ease;
}
.story-map-card .chapter-entry:not(:disabled):hover .chapter-node,
.story-map-card .chapter-entry:not(:disabled):focus-visible .chapter-node {
  filter: brightness(1.12);
  box-shadow: 0 0 0 6px rgba(24, 15, 8, .85), 0 0 0 7px rgba(229, 177, 92, .72), 0 0 30px rgba(240, 180, 77, .58);
  transform: rotate(45deg) scale(1.055);
}
.chapter-node::after { position: absolute; inset: 7px; content: ""; border: 1px solid rgba(245, 205, 132, .45); }
.chapter-node i { color: #ffe0a1; font-family: Georgia, serif; font-size: 23px; font-style: normal; transform: rotate(-45deg); }
.story-map-card .chapter-number { color: #d2a75f; font-size: 10px; letter-spacing: .22em; }
.story-map-card .chapter-entry b { margin-top: 5px; font-size: clamp(15px, 1.5vw, 20px); white-space: nowrap; }
.story-map-card .chapter-entry small { margin-top: 4px; font-size: 10px; }
.chapter-status { display: block; margin-top: 7px; color: #e6bd72; font-size: 10px; font-style: normal; letter-spacing: .12em; }
.story-map-card .chapter-entry.has-progress .chapter-status { color: #ffe0a1; text-shadow: 0 0 9px rgba(230, 183, 95, .65); }
.story-map-card .chapter-entry.is-locked { opacity: .46; }
.story-map-card .chapter-entry.is-locked .chapter-node { border-color: #766b5c; background: #151515; box-shadow: 0 0 0 6px rgba(12, 12, 12, .9), 0 0 0 7px rgba(123, 112, 94, .35); }
.story-map-card .chapter-entry.is-locked .chapter-node i { font-size: 0; }
.story-map-card .chapter-entry.is-locked .chapter-node i::after { content: "◆"; color: #a59a86; font-size: 18px; }
.story-map-card .chapter-entry.is-cleared .chapter-node::before { position: absolute; z-index: 1; right: -8px; bottom: -8px; display: grid; width: 22px; height: 22px; content: "✓"; border: 1px solid #f3d18f; border-radius: 50%; background: #493016; color: #ffe0a1; font-size: 13px; place-items: center; transform: rotate(-45deg); }
.story-map-card .chapter-entry::after { content: none !important; }
.story-map-hint { position: relative; z-index: 1; text-align: center; }

@media (max-width: 820px) and (orientation: portrait) {
  .story-map-card {
    width: calc(100vw - 36px);
    min-height: auto;
    max-height: 94dvh;
    overflow-x: hidden;
    overflow-y: auto;
    padding-right: clamp(18px, 5vw, 28px);
    padding-left: clamp(18px, 5vw, 28px);
  }
  .story-map-progress { position: relative; top: auto; right: auto; width: 100%; margin-top: 18px; }
  .story-map-card .chapter-list { min-height: 0; margin: 28px 4px 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 38px 12px; }
  .chapter-route-line { stroke-width: 1.6; stroke-dasharray: 7 10; }
  .chapter-route-glow { stroke-width: 7; }
  .story-map-card .chapter-entry,
  .story-map-card .chapter-entry:nth-of-type(n),
  .story-map-card .chapter-entry:not(:disabled):hover,
  .story-map-card .chapter-entry:nth-of-type(n):not(:disabled):hover { transform: none; }
  .chapter-node { width: 58px; height: 58px; }
  .chapter-horse { width: 84px; height: 84px; transform: translate(calc(var(--horse-x, 0px) - 42px), calc(var(--horse-y, 0px) - 68px)); }
}

.shop-copy {
  margin: 0 0 20px;
  color: rgba(234, 220, 192, 0.68);
  font-size: 14px;
  letter-spacing: 0.08em;
  line-height: 1.9;
}

.shop-copy strong {
  color: #ffe1a7;
}

.gallery-placeholder {
  display: grid;
  min-height: 180px;
  border: 1px dashed rgba(202, 166, 106, 0.38);
  background: rgba(5, 6, 8, 0.34);
  color: rgba(234, 220, 192, 0.58);
  place-content: center;
  text-align: center;
}

.gallery-placeholder span,
.gallery-placeholder b {
  display: block;
}

.gallery-placeholder span {
  font-size: 11px;
  letter-spacing: 0.3em;
}

.gallery-placeholder b {
  margin-top: 10px;
  color: #f1dfbd;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.16em;
}

.ember {
  position: absolute;
  z-index: 1;
  bottom: -20px;
  width: var(--size, 2px);
  height: var(--size, 2px);
  border-radius: 50%;
  background: radial-gradient(circle, #fff2bb 0 12%, #f2a03d 42%, rgba(207, 65, 25, 0.2) 74%, transparent 100%);
  box-shadow:
    0 0 8px rgba(246, 158, 56, 0.88),
    0 0 18px rgba(196, 64, 24, 0.46);
  opacity: 0;
  animation:
    float-ember var(--duration) linear var(--delay) infinite,
    ember-flicker 1.35s ease-in-out var(--delay) infinite alternate;
}

.embers {
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.story-screen {
  z-index: 2;
}

.dialogue-active .story-screen::after {
  position: absolute;
  z-index: 4;
  inset: 0;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(180deg, #000 0, #000 clamp(24px, 4.6vh, 52px), transparent clamp(24px, 4.6vh, 52px)),
    linear-gradient(0deg, #000 0, #000 clamp(18px, 3.2vh, 38px), transparent clamp(18px, 3.2vh, 38px));
  box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.42);
}

.chapter-card {
  position: absolute;
  z-index: 4;
  top: 50%;
  left: 50%;
  width: min(500px, 86vw);
  padding: 34px;
  border: 1px solid rgba(202, 166, 106, 0.45);
  background: rgba(4, 5, 6, 0.68);
  text-align: center;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(7px);
  animation: chapter-in-out 3.8s ease both;
}

.chapter-card::before,
.chapter-card::after {
  position: absolute;
  width: 24px;
  height: 24px;
  content: "";
  border-color: var(--gold);
}

.chapter-card::before {
  top: 8px;
  left: 8px;
  border-top: 1px solid;
  border-left: 1px solid;
}

.chapter-card::after {
  right: 8px;
  bottom: 8px;
  border-right: 1px solid;
  border-bottom: 1px solid;
}

.chapter-card span,
.chapter-card p {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.42em;
}

.chapter-card h2 {
  margin: 11px 0 16px;
  color: var(--paper);
  font-size: clamp(28px, 4vw, 48px);
  font-weight: 600;
  letter-spacing: 0.25em;
  text-indent: 0.25em;
}

.shopkeepers {
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
}

.shopkeeper {
  position: absolute;
  bottom: 128px;
  width: min(39vw, 500px);
  aspect-ratio: 871 / 862;
  opacity: 0;
  filter: drop-shadow(0 15px 20px rgba(0, 0, 0, 0.75));
  transition: opacity 0.65s ease, filter 0.65s ease, transform 0.65s ease;
}

.shopkeeper-mian {
  right: clamp(-5vw, 0vw, 20px);
  transform: translateX(28px) scale(0.96);
}

.shopkeeper-mu {
  left: clamp(-5vw, 0vw, 20px);
  transform: translateX(-28px) scale(0.96);
}

.dialogue-active.narrators-visible .shopkeeper {
  opacity: 0.4;
}

.dialogue-active.narrators-visible.speaker-mian .shopkeeper-mian,
.dialogue-active.narrators-visible.speaker-mu .shopkeeper-mu {
  z-index: 3;
  opacity: 1;
  filter: brightness(1.06) drop-shadow(0 18px 26px rgba(0, 0, 0, 0.82));
  transform: translateX(0) scale(1.02);
}

.scroll-select-active .shopkeeper {
  opacity: 0.14;
  filter: grayscale(0.35) brightness(0.62) drop-shadow(0 15px 20px rgba(0, 0, 0, 0.75));
  transform: translateX(0) scale(0.98);
}

.portrait-halo {
  position: absolute;
  z-index: -1;
  top: 13%;
  left: 8%;
  width: 84%;
  height: 64%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(194, 134, 65, 0.17), transparent 67%);
}

.shopkeeper img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
}

.shopkeeper p {
  position: absolute;
  bottom: 18%;
  margin: 0;
  padding: 12px 7px;
  border-top: 1px solid rgba(202, 166, 106, 0.65);
  border-bottom: 1px solid rgba(202, 166, 106, 0.65);
  color: #cfb98f;
  font-size: 12px;
  letter-spacing: 0.28em;
  line-height: 1.6;
  writing-mode: vertical-rl;
}

.character-stage {
  position: absolute;
  z-index: 4;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.story-character {
  position: absolute;
  bottom: 14vh;
  width: min(38vw, 430px);
  max-height: 76vh;
  object-fit: contain;
  object-position: center bottom;
  opacity: 0.38;
  filter: brightness(0.78) drop-shadow(0 18px 26px rgba(0, 0, 0, 0.82));
  transition: opacity 0.45s ease, filter 0.45s ease, transform 0.45s ease;
}

.story-character-left {
  left: max(2vw, 18px);
  transform: translateX(-14px) scale(0.98);
}

.story-character-right {
  right: max(2vw, 18px);
  transform: translateX(14px) scale(0.98);
}

.story-character-center {
  left: 50%;
  transform: translateX(-50%) scale(1);
}

.story-character.is-speaking {
  z-index: 2;
  opacity: 1;
  filter: brightness(1.05) drop-shadow(0 18px 28px rgba(0, 0, 0, 0.86));
}

.shopkeeper-mian p {
  right: 5%;
}

.shopkeeper-mu p {
  left: 5%;
}

.dialogue-panel {
  position: absolute;
  z-index: 5;
  right: 0;
  bottom: 0;
  left: 0;
  min-height: clamp(150px, 22vh, 205px);
  padding: 27px clamp(120px, 14vw, 230px) max(38px, calc(25px + var(--safe-bottom)));
  border: 0;
  border-top: 1px solid rgba(224, 192, 137, 0.28);
  background:
    linear-gradient(180deg, rgba(2, 3, 5, 0.76), rgba(0, 0, 0, 0.96)),
    rgba(0, 0, 0, 0.88);
  box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(12px) saturate(0.72);
  animation: dialogue-up 0.7s ease both;
}

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

.speaker-row {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.speaker-row strong {
  padding: 4px 18px;
  border-right: 1px solid rgba(226, 196, 143, 0.35);
  border-left: 1px solid rgba(226, 196, 143, 0.35);
  color: rgba(238, 207, 153, 0.9);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-shadow: 0 2px 8px #000;
}

#dialogue-text {
  min-height: 2em;
  margin: 0;
  color: rgba(250, 247, 239, 0.96);
  font-size: clamp(16px, 1.35vw, 21px);
  letter-spacing: 0.1em;
  line-height: 1.85;
  text-align: center;
  text-shadow: 0 2px 8px #000, 0 0 18px rgba(0, 0, 0, 0.8);
}

#dialogue-text.is-revealing {
  animation: dialogue-text-fade 0.22s ease-out both;
}

.dialogue-next {
  padding: 10px;
  cursor: pointer;
  border: 0;
  background: none;
  color: #b99b6c;
  font-size: 11px;
  letter-spacing: 0.2em;
}

.dialogue-actions {
  position: absolute;
  z-index: 2;
  right: max(28px, env(safe-area-inset-right));
  bottom: max(18px, var(--safe-bottom));
  display: grid;
  justify-items: center;
  gap: 4px;
}

.dialogue-shortcut {
  display: flex;
  align-items: center;
  gap: 5px;
  color: rgba(224, 207, 178, .36);
  font-size: 8px;
  letter-spacing: .08em;
  white-space: nowrap;
}

.dialogue-shortcut b { font-weight: 400; }

.dialogue-shortcut kbd {
  padding: 2px 5px;
  border: 1px solid rgba(202, 166, 106, .22);
  border-radius: 3px;
  background: rgba(5, 6, 8, .25);
  color: rgba(242, 212, 155, .52);
  font-family: inherit;
  font-size: 7px;
}

.exit-story-button {
  position: absolute;
  z-index: 3;
  top: 18px;
  right: max(24px, env(safe-area-inset-right));
  padding: 7px 12px;
  cursor: pointer;
  border: 1px solid rgba(202, 166, 106, .28);
  background: rgba(0, 0, 0, .36);
  color: rgba(234, 220, 192, .68);
  font-size: 10px;
  letter-spacing: .14em;
  transition: border-color .2s ease, color .2s ease, background .2s ease;
}

.exit-story-button:hover,
.exit-story-button:focus-visible {
  border-color: rgba(242, 212, 155, .75);
  background: rgba(82, 53, 28, .55);
  color: #f2d49b;
}

.dialogue-next i {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 8px;
  border-right: 1px solid;
  border-bottom: 1px solid;
  transform: rotate(45deg) translateY(-3px);
  animation: next-bob 1.2s ease infinite;
}

.ask-history-button {
  position: absolute;
  z-index: 2;
  right: 30px;
  bottom: 22px;
  padding: 10px 18px;
  cursor: pointer;
  border: 1px solid rgba(220, 183, 116, 0.68);
  background: linear-gradient(135deg, rgba(103, 69, 35, 0.74), rgba(25, 19, 14, 0.76));
  color: #f0d9ae;
  box-shadow: inset 0 0 18px rgba(202, 166, 106, 0.12);
  font-size: 11px;
  letter-spacing: 0.24em;
  animation: reveal 0.5s ease both;
}

.ask-history-button:hover {
  border-color: #f2d49b;
  filter: brightness(1.15);
}

.scroll-select {
  position: absolute;
  z-index: 7;
  inset: 0;
  overflow: auto;
  padding: clamp(36px, 7vh, 76px) 4vw max(36px, var(--safe-bottom));
  background: radial-gradient(circle at 50% 28%, rgba(72, 49, 29, 0.25), rgba(4, 5, 6, 0.89) 76%);
  text-align: center;
  animation: reveal 0.8s ease both;
}

.scroll-select header p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.36em;
}

.scroll-select header h2 {
  margin: 11px 0 clamp(28px, 5vh, 52px);
  color: var(--paper);
  font-size: clamp(26px, 4vw, 46px);
  letter-spacing: 0.35em;
  text-indent: 0.35em;
}

.books-swipe-hint {
  display: none;
}

.overlay-close {
  position: fixed;
  z-index: 30;
  top: var(--safe-top);
  left: max(22px, env(safe-area-inset-left));
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  cursor: pointer;
  border: 1px solid rgba(220, 183, 116, 0.62);
  border-radius: 50%;
  background: rgba(18, 13, 9, 0.72);
  color: #f2d49b;
  box-shadow:
    inset 0 0 12px rgba(202, 166, 106, 0.12),
    0 0 14px rgba(0, 0, 0, 0.42);
  font-size: 22px;
  line-height: 1;
  place-items: center;
  backdrop-filter: blur(8px);
}

.overlay-close:hover,
.overlay-close:focus-visible {
  border-color: #f2d49b;
  box-shadow:
    inset 0 0 14px rgba(242, 212, 155, 0.18),
    0 0 18px rgba(225, 173, 86, 0.42);
}

.scroll-select > #close-books-button {
  right: max(22px, env(safe-area-inset-right));
  left: auto;
}

.scroll-grid {
  display: grid;
  max-width: 1180px;
  margin: auto;
  grid-template-columns: repeat(5, 1fr);
  gap: clamp(14px, 1.8vw, 26px);
  perspective: 1500px;
}

.scroll-card {
  position: relative;
  min-height: min(52vh, 440px);
  padding: 0;
  overflow: visible;
  cursor: pointer;
  border: 0;
  background: transparent;
  color: #ead7b3;
  isolation: isolate;
  transform: perspective(900px) rotateY(0) translateY(0);
  transform-origin: left center;
  transition: transform .38s cubic-bezier(.2, .72, .2, 1), filter .35s ease;
}

.scroll-card::before {
  position: absolute;
  z-index: -1;
  right: 3%;
  bottom: -12px;
  left: 7%;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .68);
  filter: blur(13px);
  content: "";
  opacity: .78;
  transition: opacity .35s ease, transform .35s ease;
}

.scroll-card:hover,
.scroll-card:focus-visible {
  z-index: 2;
  outline: none;
  filter: brightness(1.1) drop-shadow(0 0 12px rgba(215, 163, 83, .2));
  transform: perspective(900px) rotateY(-4deg) translateY(-10px);
}

.scroll-card:hover::before,
.scroll-card:focus-visible::before {
  opacity: .95;
  transform: translateY(9px) scaleX(1.04);
}

.book-cover {
  position: absolute;
  z-index: 2;
  inset: 0 14px 7px 8px;
  overflow: hidden;
  border: 1px solid rgba(209, 161, 84, .42);
  border-radius: 3px 7px 7px 3px;
  background-color: var(--book-cover);
  background-image:
    linear-gradient(90deg, rgba(0, 0, 0, .52), transparent 21%, transparent 76%, rgba(0, 0, 0, .34)),
    linear-gradient(180deg, rgba(255, 223, 161, .12), transparent 18%, rgba(0, 0, 0, .28)),
    url("./assets/images/letter/book_leather_texture.webp");
  background-position: center;
  background-size: cover;
  background-blend-mode: multiply, soft-light, soft-light;
  box-shadow:
    inset 0 0 0 5px rgba(20, 12, 7, .38),
    inset 0 0 34px rgba(0, 0, 0, .64),
    7px 8px 14px rgba(0, 0, 0, .56);
}

.book-cover::after {
  position: absolute;
  inset: 9px;
  border: 1px solid color-mix(in srgb, var(--book-accent) 44%, transparent);
  content: "";
  box-shadow: inset 0 0 14px rgba(0, 0, 0, .36);
}

.book-paper-edge {
  position: absolute;
  z-index: 1;
  top: 18px;
  right: 0;
  bottom: 0;
  width: 18px;
  border: 1px solid rgba(94, 58, 27, .7);
  border-radius: 0 5px 5px 0;
  background: url("./assets/images/letter/book_paper_edge.webp") center / 100% 100% no-repeat;
  box-shadow: 4px 5px 10px rgba(0, 0, 0, .62);
  filter: sepia(.12) brightness(.82);
  transform: perspective(180px) rotateY(8deg);
  transform-origin: left center;
}

.book-spine {
  position: absolute;
  z-index: 5;
  top: -2px;
  bottom: 5px;
  left: -3px;
  width: clamp(38px, 24%, 54px);
  background: url("./assets/images/letter/book_spine_pattern.webp") center / 100% 100% no-repeat;
  filter: sepia(.16) saturate(.88) brightness(.78) drop-shadow(4px 2px 5px rgba(0, 0, 0, .64));
  pointer-events: none;
}

.book-corner {
  position: absolute;
  z-index: 7;
  width: clamp(52px, 6vw, 78px);
  aspect-ratio: 1;
  background: url("./assets/images/letter/book_corner.webp") center / contain no-repeat;
  filter: sepia(.12) saturate(.9) brightness(.88) drop-shadow(0 3px 4px rgba(0, 0, 0, .65));
  pointer-events: none;
}

.book-corner.is-top-left { top: -2px; left: -3px; }
.book-corner.is-top-right { top: -2px; right: 12px; transform: scaleX(-1); }
.book-corner.is-bottom-left { bottom: 5px; left: -3px; transform: scaleY(-1); }
.book-corner.is-bottom-right { right: 12px; bottom: 5px; transform: rotate(180deg); }

.book-title-label {
  position: absolute;
  z-index: 6;
  top: 13%;
  bottom: 12%;
  left: calc(50% + 13px);
  display: flex;
  width: min(48%, 102px);
  align-items: center;
  flex-direction: column;
  justify-content: center;
  padding: 15% 11% 13%;
  background: url("./assets/images/letter/book_label.webp") center / 100% 100% no-repeat;
  color: #382311;
  text-align: center;
  filter: sepia(.1) brightness(.91) drop-shadow(0 8px 11px rgba(0, 0, 0, .7));
  transform: translateX(-50%);
  pointer-events: none;
}

.book-title-label::before {
  width: 42%;
  height: 1px;
  margin: 7px 0 8px;
  order: 2;
  background: rgba(104, 59, 20, .46);
  content: "";
}

.scroll-card.is-viewed::after {
  position: absolute;
  z-index: 9;
  top: 16px;
  right: auto;
  left: calc(50% + 13px);
  padding: 4px 6px;
  content: "已閱";
  border: 1px solid rgba(185, 56, 43, .82);
  background: rgba(72, 16, 12, .28);
  color: #d47765;
  font-size: 9px;
  letter-spacing: 0.15em;
  box-shadow: inset 0 0 7px rgba(153, 36, 28, .18);
  text-indent: 0.15em;
  transform: translateX(-50%);
}

.scroll-card.is-viewed .scroll-number {
  opacity: 0;
}

.scroll-number {
  position: absolute;
  z-index: 6;
  top: 19px;
  right: 29px;
  color: color-mix(in srgb, var(--book-accent) 66%, #6e4924);
  font-family: Georgia, serif;
  font-size: 9px;
  letter-spacing: .08em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .7);
  transition: opacity .2s ease;
}

.scroll-glyph {
  display: block;
  margin: 0;
  color: #4b2a10;
  font-family: "Noto Serif TC", "Songti TC", serif;
  font-size: clamp(30px, 3vw, 45px);
  line-height: 1;
  text-shadow: 0 1px rgba(255, 245, 211, .48);
  order: 1;
}

.book-title-label h3 {
  min-height: 4.2em;
  margin: 0;
  color: #3c210e;
  font-size: clamp(15px, 1.45vw, 19px);
  font-weight: 600;
  letter-spacing: .16em;
  line-height: 1.42;
  writing-mode: vertical-rl;
  order: 3;
}

.book-title-label p {
  margin: 8px 0 0;
  color: rgba(76, 43, 18, .72);
  font-size: 9px;
  letter-spacing: .08em;
  line-height: 1.4;
  order: 4;
}

.shelve-books-button {
  margin: clamp(28px, 5vh, 52px) auto 0;
  padding: 12px 34px;
  cursor: pointer;
  border: 1px solid rgba(232, 199, 139, 0.72);
  background: linear-gradient(135deg, rgba(107, 71, 35, 0.72), rgba(25, 19, 14, 0.82));
  color: #f0dfbd;
  box-shadow: inset 0 0 28px rgba(202, 166, 106, 0.12);
  font-size: 13px;
  letter-spacing: 0.38em;
  animation: reveal 0.8s ease both;
}

.begin-route-button:hover {
  border-color: #f2d49b;
  filter: brightness(1.15);
}

.scroll-reader {
  position: absolute;
  z-index: 12;
  inset: 0;
  overflow: hidden;
  background: #080706;
}

.scroll-unroll {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  animation: unroll-layer 1.45s ease both;
}

.scroll-paper {
  width: 0;
  height: 72vh;
  background:
    linear-gradient(90deg, rgba(94, 62, 31, 0.24), rgba(240, 222, 181, 0.08) 8% 92%, rgba(94, 62, 31, 0.24)),
    url("./assets/images/paper.webp") center / cover;
  box-shadow: 0 0 80px rgba(209, 166, 92, 0.28);
  animation: unroll-paper 1.15s cubic-bezier(0.58, 0.02, 0.18, 1) both;
}

.scroll-rod {
  width: 22px;
  height: 78vh;
  flex: 0 0 22px;
  border-radius: 12px;
  background: linear-gradient(90deg, #352012, #bb8a4b 48%, #3b2516);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.7);
}

.scroll-rod-left {
  animation: rod-left 1.15s cubic-bezier(0.58, 0.02, 0.18, 1) both;
}

.scroll-rod-right {
  animation: rod-right 1.15s cubic-bezier(0.58, 0.02, 0.18, 1) both;
}

.scroll-page {
  position: absolute;
  inset: 0;
  display: grid;
  overflow: auto;
  padding: clamp(48px, 7vh, 76px) clamp(34px, 6vw, 92px);
  background:
    linear-gradient(90deg, rgba(65, 38, 19, 0.13), rgba(239, 222, 184, 0.22) 10% 90%, rgba(65, 38, 19, 0.14)),
    radial-gradient(circle at 70% 38%, rgba(255, 248, 218, 0.34), transparent 43%),
    url("./assets/images/paper.webp") center / cover fixed;
  color: #332419;
  grid-template-columns: minmax(280px, 0.85fr) minmax(360px, 1.15fr);
  gap: clamp(28px, 6vw, 90px);
  opacity: 0;
  animation: scroll-page-in 0.65s ease 1.05s both;
}

.scroll-page::before,
.scroll-page::after {
  position: fixed;
  z-index: 2;
  top: 0;
  bottom: 0;
  width: 24px;
  content: "";
  background: linear-gradient(90deg, #3d2515, #aa7941 45%, #432a18);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.46);
}

.scroll-page::before {
  left: 0;
}

.scroll-page::after {
  right: 0;
}

.scroll-close {
  position: fixed;
  z-index: 4;
  top: 0;
  right: max(42px, env(safe-area-inset-left));
  display: grid;
  width: clamp(70px, 6.4vw, 94px);
  aspect-ratio: 250 / 455;
  padding: clamp(15px, 3.2vh, 30px) 0 clamp(20px, 4.5vh, 42px);
  place-items: center;
  cursor: pointer;
  border: 0;
  background: url("./assets/images/letter/btn_goback.webp") top center / 100% 100% no-repeat;
  color: #ead2a2;
  font-family: "Noto Serif TC", "Songti TC", serif;
  font-size: clamp(13px, 1.2vw, 17px);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: .14em;
  text-align: center;
  text-indent: .22em;
  text-orientation: upright;
  text-shadow: 0 2px 5px rgba(20, 8, 3, .95), 0 0 7px rgba(237, 190, 110, .2);
  writing-mode: vertical-rl;
  white-space: nowrap;
  word-break: keep-all;
  filter: drop-shadow(0 9px 10px rgba(0, 0, 0, .42));
  transition: filter .2s ease, transform .2s ease;
}

.scroll-close:hover,
.scroll-close:focus-visible {
  filter: brightness(1.13) drop-shadow(0 10px 13px rgba(0, 0, 0, .48));
  transform: translateY(2px);
}

.scroll-close:focus-visible {
  outline: 2px solid rgba(244, 218, 166, .85);
  outline-offset: -4px;
}

.ink-portrait {
  position: relative;
  align-self: center;
  min-height: min(72vh, 720px);
  overflow: hidden;
  cursor: crosshair;
  outline: 0;
  isolation: isolate;
}

.ink-wash {
  position: absolute;
  z-index: -1;
  inset: 4% 2% 2%;
  background:
    radial-gradient(ellipse at 49% 43%, rgba(53, 43, 34, 0.2) 0 42%, transparent 72%),
    radial-gradient(circle at 16% 31%, rgba(53, 43, 34, 0.11) 0 3%, transparent 7%),
    radial-gradient(circle at 84% 24%, rgba(53, 43, 34, 0.09) 0 2%, transparent 6%),
    radial-gradient(circle at 9% 68%, rgba(53, 43, 34, 0.08) 0 2%, transparent 5%),
    radial-gradient(circle at 91% 61%, rgba(53, 43, 34, 0.08) 0 3%, transparent 7%);
  filter: blur(9px);
  transform: scale(1.035);
}

.ink-portrait.uses-photo-assets .portrait-fallback {
  display: none;
}

.ink-portrait.uses-photo-assets .ink-wash {
  display: none;
}

.portrait-fallback,
.route-portrait {
  position: absolute;
  inset: 3% 0 4%;
  width: 100%;
  height: 93%;
  transition: opacity 0.75s ease, filter 0.75s ease, transform 1s cubic-bezier(0.2, 0.7, 0.15, 1);
}

.route-portrait {
  z-index: 2;
  top: 1.5%;
  bottom: auto;
  object-fit: cover;
  object-position: center top;
  filter: saturate(0.88) contrast(1.03);
  mask-image: var(--portrait-mask);
  mask-mode: luminance;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: 100% 100%;
}

.portrait-modern {
  animation: portrait-ink-reveal 1.15s cubic-bezier(0.2, 0.72, 0.2, 1) both;
}

.portrait-ancient,
.portrait-ancient-fallback {
  opacity: 0;
  transform: scale(1.04);
}

.ink-portrait.show-ancient .portrait-modern,
.ink-portrait.show-ancient .portrait-modern-fallback {
  opacity: 0;
  transform: scale(0.97);
}

.ink-portrait.show-ancient .portrait-ancient,
.ink-portrait.show-ancient .portrait-ancient-fallback {
  opacity: 1;
  transform: scale(1);
}

.ink-portrait.show-ancient .portrait-ancient {
  animation: portrait-ink-reveal 1.05s cubic-bezier(0.2, 0.72, 0.2, 1) both;
}

.route-portrait.is-missing {
  display: none;
}

.portrait-fallback {
  display: grid;
  place-content: center;
  border-radius: 48% 52% 22% 28%;
  background:
    linear-gradient(145deg, transparent 22%, var(--portrait-tone, #33404a) 23% 75%, transparent 76%),
    radial-gradient(circle at 50% 26%, #1c2025 0 13%, transparent 14%);
  text-align: center;
  filter: drop-shadow(0 15px 12px rgba(43, 27, 17, 0.3));
  mask-image: radial-gradient(ellipse at center, #000 45%, transparent 76%);
}

.portrait-ancient-fallback {
  background:
    linear-gradient(160deg, transparent 18%, #27221d 19% 79%, transparent 80%),
    radial-gradient(circle at 50% 24%, #141313 0 13%, transparent 14%);
}

.portrait-fallback b {
  color: rgba(239, 221, 180, 0.78);
  font-size: clamp(90px, 14vw, 180px);
  font-weight: 400;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
}

.portrait-fallback span {
  color: rgba(236, 220, 188, 0.68);
  font-size: 12px;
  letter-spacing: 0.5em;
}

.portrait-hint {
  position: absolute;
  z-index: 5;
  right: 10%;
  bottom: 7%;
  left: 10%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  color: #694b31;
  font-size: 10px;
  letter-spacing: 0.16em;
}

.portrait-hint b {
  font-weight: 600;
}

.portrait-hint span {
  padding: 4px 7px;
  border: 1px solid rgba(86, 49, 28, 0.28);
}

.scroll-copy {
  align-self: center;
  max-width: 640px;
  padding: 40px 0;
}

.reader-era {
  margin: 0;
  color: #7d5635;
  font-size: 12px;
  letter-spacing: 0.5em;
}

.scroll-copy h2 {
  margin: 13px 0 19px;
  color: #352217;
  font-size: clamp(50px, 8vw, 96px);
  font-weight: 700;
  letter-spacing: 0.14em;
}

.reader-divider {
  display: flex;
  width: min(420px, 100%);
  align-items: center;
  gap: 15px;
}

.reader-divider i {
  height: 1px;
  flex: 1;
  background: rgba(93, 57, 30, 0.36);
}

.reader-seal {
  display: block;
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  object-fit: contain;
  filter: saturate(0.9) contrast(1.08);
  transform: none;
}

.character-identities {
  display: grid;
  max-width: 520px;
  margin: 24px 0 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.character-identities div {
  padding: 12px 14px;
  border-top: 1px solid rgba(103, 65, 36, 0.35);
  border-bottom: 1px solid rgba(103, 65, 36, 0.2);
  text-align: left;
}

.character-identities dt {
  color: #9a3d32;
  font-size: 10px;
  letter-spacing: 0.35em;
}

.character-identities dd {
  margin: 6px 0 0;
  color: #513623;
  font-size: 14px;
  letter-spacing: 0.16em;
}

.scroll-copy blockquote {
  margin: 25px 0 18px;
  padding-left: 20px;
  border-left: 2px solid rgba(116, 58, 35, 0.48);
  color: #3c2b20;
  font-size: clamp(17px, 1.8vw, 23px);
  letter-spacing: 0.12em;
  line-height: 1.9;
}

.reader-prologue {
  max-width: 560px;
  color: #68513c;
  font-size: 13px;
  letter-spacing: 0.1em;
  line-height: 2;
}

.begin-route-button {
  margin-top: 18px;
  padding: 11px 30px;
  cursor: pointer;
  border: 1px solid rgba(99, 55, 29, 0.65);
  background: rgba(98, 57, 31, 0.1);
  color: #50311f;
  font-size: 12px;
  letter-spacing: 0.35em;
}

.reader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.route-keepsake-button {
  background: rgba(125, 74, 35, 0.18);
}

.route-keepsake-modal {
  position: fixed;
  z-index: 32;
  inset: 0;
  display: grid;
  height: 100dvh;
  padding: clamp(16px, 2.5vh, 30px) clamp(18px, 5vw, 70px);
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 18%, rgba(145, 101, 48, 0.16), transparent 32%),
    linear-gradient(rgba(12, 9, 7, 0.87), rgba(18, 13, 9, 0.92)),
    url("./assets/images/scroll-shop.webp") center / cover;
  backdrop-filter: blur(6px);
  place-items: center;
  animation: reveal 0.35s ease both;
}

.route-keepsake-panel {
  position: relative;
  width: min(1120px, 92vw);
  height: auto;
  max-height: calc(100dvh - clamp(32px, 5vh, 60px));
  padding: clamp(18px, 2.4vh, 28px);
  overflow-y: auto;
  border: 1px solid rgba(151, 118, 76, .65);
  background:
    linear-gradient(rgba(235, 225, 204, .8), rgba(220, 205, 177, .86)),
    url("./assets/images/letter/paper.webp") center / cover;
  color: #493121;
  box-shadow: inset 0 0 58px rgba(91, 63, 35, .22), 0 18px 70px rgba(0, 0, 0, .62);
}

.route-keepsake-close {
  position: fixed;
  z-index: 4;
  top: max(24px, env(safe-area-inset-top));
  right: max(28px, env(safe-area-inset-right));
  width: 58px;
  height: 58px;
  cursor: pointer;
  border: 1px solid rgba(224, 190, 124, 0.7);
  border-radius: 50%;
  background: rgba(64, 47, 29, 0.84);
  color: #f0d59d;
  box-shadow: inset 0 0 0 4px rgba(224, 190, 124, 0.1), 0 5px 20px #000;
  font-size: 35px;
  font-weight: 200;
  line-height: 1;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.route-keepsake-close:hover,
.route-keepsake-close:focus-visible {
  border-color: #f7dca2;
  transform: rotate(7deg) scale(1.04);
}

.route-keepsake-list {
  display: grid;
  width: 100%;
  height: auto;
  min-height: 0;
  grid-template-rows: none;
  gap: clamp(18px, 2.4vh, 26px);
}

.route-keepsake-card {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: clamp(390px, 46vh, 500px);
  max-height: 100%;
  height: auto;
  padding: 14px;
  overflow: hidden;
  cursor: default;
  border: 2px solid rgba(150, 115, 72, .56);
  border-radius: 0;
  background:
    linear-gradient(90deg, rgba(247, 242, 227, .44), rgba(223, 208, 180, .2)),
    url("./assets/images/letter/paper.webp") center / cover;
  color: #4b3424;
  box-shadow: inset 0 0 32px rgba(93, 65, 37, .14), 0 7px 18px rgba(72, 49, 29, .16);
  grid-template-columns: minmax(0, 51%) minmax(0, 49%);
  align-items: center;
  gap: 0;
  text-align: left;
  transform: none;
}
.route-keepsake-card:nth-of-type(1){
  padding-left: 14px;
}
.route-keepsake-card:nth-of-type(2){
  padding-right: 14px;
}

.route-keepsake-card::before,
.route-keepsake-card::after {
  position: absolute;
  z-index: 6;
  pointer-events: none;
  content: "";
}

.route-keepsake-card::before {
  inset: 8px;
  border: 1px solid rgba(154, 119, 75, .48);
  box-shadow: inset 0 0 0 3px rgba(249, 243, 225, .32);
}

.route-keepsake-card::after {
  top: 4px;
  left: 50%;
  width: 16px;
  height: 16px;
  border: 1px solid rgba(155, 120, 76, .5);
  background: rgba(226, 211, 181, .82);
  transform: translateX(-50%) rotate(45deg);
}

.route-keepsake-card:hover,
.route-keepsake-card:focus-visible,
.route-keepsake-card[aria-expanded="true"] {
  border-color: rgba(150, 115, 72, .56);
  box-shadow: inset 0 0 32px rgba(93, 65, 37, .14), 0 7px 18px rgba(72, 49, 29, .16);
  transform: none;
}
.route-keepsake-card,.route-keepsake-card::before{
  border-radius: 13px;
}

.route-keepsake-card img {
  width: 72%;
  height: clamp(300px, 40vh, 430px);
  margin-left: 12%;
  object-fit: contain;
  filter: drop-shadow(0 18px 12px rgba(51, 36, 23, .3));
}

.route-keepsake-copy {
  display: grid;
  min-width: 0;
  align-content: center;
}

.route-keepsake-era {
  margin-top: clamp(3px, 0.6vh, 7px);
  color: #8b3f32;
  font-size: clamp(10px, min(1.3vw, 1.5vh), 13px);
  font-weight: 500;
  letter-spacing: 0.2em;
}

.route-keepsake-copy > i {
  display: block;
  width: 100%;
  height: 1px;
  margin: clamp(7px, 1.1vh, 13px) 0;
  background: linear-gradient(90deg, rgba(106, 67, 38, 0.58), rgba(106, 67, 38, 0.08));
}

.route-keepsake-meaning {
  display: block;
  max-height: 0;
  overflow: hidden;
  color: #654a36;
  font-size: clamp(11px, min(1.45vw, 1.65vh), 16px);
  letter-spacing: 0.08em;
  line-height: 1.7;
  opacity: 0;
  white-space: pre-line;
  transition: max-height 0.45s ease, opacity 0.3s ease;
}

.route-keepsake-name {
  color: #503321;
  font-size: clamp(20px, min(2.8vw, 3.2vh), 31px);
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.45;
}

.route-keepsake-card[aria-expanded="true"] .route-keepsake-meaning {
  max-height: min(30vh, 250px);
  overflow-y: auto;
  opacity: 1;
}

.route-keepsake-copy small {
  margin-top: clamp(4px, 0.7vh, 8px);
  color: rgba(91, 62, 42, 0.56);
  font-size: 9px;
  letter-spacing: 0.14em;
}

.route-keepsake-panel > footer {
  margin-top: clamp(7px, 1.2vh, 14px);
  color: rgba(218, 187, 130, 0.75);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-align: center;
  text-shadow: 0 2px 8px #000;
}

.love-letter {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  padding: 30px;
  background: rgba(25, 16, 10, 0.7);
  backdrop-filter: blur(10px);
  place-items: center;
  animation: reveal 0.4s ease both;
}

.history-choice {
  position: absolute;
  z-index: 14;
  inset: 0;
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  padding: 30px;
  background: radial-gradient(circle at 50% 42%, rgba(85, 58, 34, 0.28), rgba(4, 5, 6, 0.88));
  text-align: center;
  animation: reveal 0.7s ease both;
}

.history-choice > p {
  margin: 0;
  color: #c5a873;
  font-size: 12px;
  letter-spacing: 0.45em;
}

.history-choice h2 {
  margin: 18px 0 32px;
  color: #eadcc0;
  font-size: clamp(28px, 5vw, 56px);
  font-weight: 600;
  letter-spacing: 0.16em;
}

.history-choice > div {
  display: flex;
  gap: 14px;
}

.history-choice button {
  min-width: 150px;
  padding: 11px 24px;
  cursor: pointer;
  border: 1px solid rgba(202, 166, 106, 0.58);
  background: rgba(9, 8, 7, 0.56);
  color: #e4cfaa;
  font-size: 12px;
  letter-spacing: 0.28em;
}

.history-choice button:first-child {
  border-color: rgba(239, 205, 141, 0.85);
  background: rgba(99, 65, 33, 0.48);
}

.history-video-screen {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
}

.history-video-screen video {
  display: block;
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  background: #000;
  object-fit: contain;
  object-position: center;
}

.scene-chapter-city .scene-bg {
  background-image: url("./assets/images/title-city.webp");
  background-position: center;
  animation: none;
}

.scene-chapter-shop .scene-bg {
  background-image: url("./assets/images/scroll-shop.webp");
  background-position: center;
}

.letter-sheet {
  position: relative;
  width: min(590px, 92vw);
  min-height: min(630px, 82vh);
  margin: auto;
  padding: clamp(48px, 7vw, 72px) clamp(58px, 8vw, 86px);
  overflow: hidden;
  border: 1px solid rgba(106, 65, 35, 0.38);
  background:
    linear-gradient(90deg, rgba(90, 54, 29, 0.06), transparent 15%, transparent 85%, rgba(90, 54, 29, 0.06)),
    repeating-linear-gradient(90deg, transparent 0 34px, rgba(104, 70, 39, 0.08) 34px 35px),
    #e5d4ae;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.62);
  color: #443022;
  transform-style: preserve-3d;
}

.letter-sheet::before {
  position: absolute;
  inset: 13px;
  pointer-events: none;
  content: "";
  border: 1px solid rgba(112, 73, 42, 0.16);
}

.letter-close {
  position: absolute;
  z-index: 2;
  top: 20px;
  right: 22px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  border: 1px solid rgba(95, 55, 31, 0.4);
  border-radius: 50%;
  background: transparent;
  color: #60412c;
  font-size: 24px;
  line-height: 1;
}

.letter-kicker {
  position: absolute;
  top: 58px;
  right: 38px;
  margin: 0;
  color: #895b38;
  font-size: 11px;
  letter-spacing: 0.45em;
  line-height: 1.8;
  writing-mode: vertical-rl;
}

.letter-sheet h3 {
  position: absolute;
  top: 58px;
  right: 72px;
  margin: 0;
  color: #382319;
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 600;
  letter-spacing: 0.22em;
  line-height: 1.7;
  writing-mode: vertical-rl;
}

#letter-text {
  width: 100%;
  height: min(470px, 60vh);
  margin: 0;
  padding-right: 105px;
  font-size: clamp(16px, 1.6vw, 20px);
  letter-spacing: 0.15em;
  line-height: 2.1;
  text-align: start;
  white-space: pre-line;
  writing-mode: vertical-rl;
  text-orientation: upright;
  overflow: hidden;
}

.letter-closing {
  position: absolute;
  bottom: 42px;
  left: clamp(45px, 8vw, 80px);
  display: flex;
  align-items: flex-end;
  flex-direction: row-reverse;
  gap: 13px;
}

#letter-wish,
.letter-author {
  margin: 0;
  color: #4b3424;
  font-size: 13px;
  letter-spacing: 0.13em;
  line-height: 1.8;
  writing-mode: vertical-rl;
  text-orientation: upright;
}

.letter-author {
  display: flex;
  gap: 8px;
}

.letter-author span {
  color: #7d5a3d;
  font-size: 11px;
}

.letter-author b {
  font-weight: 600;
}

.letter-signature {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: contain;
  filter: saturate(0.9) contrast(1.08);
  transform: rotate(-4deg);
}

.letter-pagination {
  position: absolute;
  z-index: 4;
  right: 50%;
  bottom: 18px;
  display: flex;
  align-items: center;
  padding: 4px 7px;
  border: 1px solid rgba(102, 62, 34, 0.2);
  background: rgba(226, 207, 166, 0.78);
  color: #68472f;
  transform: translateX(50%);
  gap: 8px;
}

.letter-pagination button {
  display: grid;
  width: 28px;
  height: 28px;
  padding: 0;
  cursor: pointer;
  border: 1px solid rgba(95, 55, 31, 0.34);
  border-radius: 50%;
  background: transparent;
  color: #60412c;
  font-family: Georgia, serif;
  font-size: 22px;
  line-height: 1;
  place-items: center;
}

.letter-pagination button:disabled {
  cursor: default;
  opacity: 0.3;
}

.letter-pagination span {
  min-width: 40px;
  font-family: Georgia, serif;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-align: center;
}

.letter-sheet.turn-page-forward {
  animation: letter-turn-forward 0.58s cubic-bezier(0.3, 0.72, 0.2, 1) both;
  transform-origin: left center;
}

.letter-sheet.turn-page-backward {
  animation: letter-turn-backward 0.58s cubic-bezier(0.3, 0.72, 0.2, 1) both;
  transform-origin: right center;
}

.transition {
  z-index: 50;
  display: grid;
  visibility: hidden;
  overflow: hidden;
  background: #050608;
  opacity: 0;
  transition: opacity 0.65s ease, visibility 0.65s;
  place-items: center;
  text-align: center;
}

.transition.active {
  visibility: visible;
  opacity: 1;
}

.transition span {
  position: relative;
  z-index: 2;
  color: #c8ad7d;
  font-size: 13px;
  letter-spacing: 0.7em;
  text-indent: 0.7em;
}

.ink {
  position: absolute;
  width: 70vmax;
  height: 70vmax;
  border-radius: 45% 55% 52% 48%;
  background: #0b0c0e;
  filter: blur(8px);
  animation: ink-turn 8s linear infinite;
}

.ink-b {
  background: #11100f;
  opacity: 0.55;
  animation-direction: reverse;
  animation-duration: 11s;
}

[hidden] {
  display: none !important;
}

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

@keyframes portrait-ink-reveal {
  0% {
    mask-size: 62% 62%;
    filter: blur(12px) saturate(0.42) contrast(1.2);
  }
  45% {
    filter: blur(4px) saturate(0.68) contrast(1.12);
  }
  100% {
    mask-size: 100% 100%;
    filter: blur(0) saturate(0.88) contrast(1.03);
  }
}

@keyframes letter-turn-forward {
  0% { opacity: 0.45; transform: perspective(1100px) rotateY(-14deg) translateX(-10px); }
  55% { opacity: 0.82; transform: perspective(1100px) rotateY(3deg) translateX(2px); }
  100% { opacity: 1; transform: perspective(1100px) rotateY(0) translateX(0); }
}

@keyframes letter-turn-backward {
  0% { opacity: 0.45; transform: perspective(1100px) rotateY(14deg) translateX(10px); }
  55% { opacity: 0.82; transform: perspective(1100px) rotateY(-3deg) translateX(-2px); }
  100% { opacity: 1; transform: perspective(1100px) rotateY(0) translateX(0); }
}

@keyframes unroll-paper {
  from { width: 0; }
  to { width: calc(100vw - 48px); }
}

@keyframes rod-left {
  from { transform: translateX(0); }
  to { transform: translateX(calc(-50vw + 24px)); }
}

@keyframes rod-right {
  from { transform: translateX(0); }
  to { transform: translateX(calc(50vw - 24px)); }
}

@keyframes unroll-layer {
  0%, 80% { opacity: 1; }
  100% { visibility: hidden; opacity: 0; }
}

@keyframes scroll-page-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slow-push {
  from { transform: scale(1.05); }
  to { transform: scale(1.12); }
}

@keyframes rain-fall {
  from { background-position: 0 0; }
  to { background-position: -44px 140px; }
}

@keyframes flash-out {
  0% { opacity: 0; }
  18% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes story-rain-sheet {
  from { transform: translate3d(-1.5%, -4%, 0) scale(1.04); }
  to { transform: translate3d(1.5%, 4%, 0) scale(1.04); }
}

@keyframes story-lightning {
  0%, 14% { opacity: 0; }
  18% { opacity: 1; }
  27% { opacity: .12; }
  35% { opacity: .82; }
  100% { opacity: 0; }
}

@keyframes story-fog-drift {
  from { transform: translate3d(-3%, 1%, 0) scale(1.03); }
  to { transform: translate3d(3%, -1%, 0) scale(1.08); }
}

@keyframes story-smoke-drift {
  from { transform: translate3d(-3%, 3%, 0) scale(1.02); }
  to { transform: translate3d(4%, -3%, 0) scale(1.1); }
}

@keyframes story-sparks-rise {
  from { transform: translate3d(0, 3%, 0) scale(.98); filter: brightness(.86); }
  to { transform: translate3d(1%, -3%, 0) scale(1.04); filter: brightness(1.22); }
}

@keyframes story-blood-hit {
  0% { opacity: 0; transform: scale(.55) rotate(-5deg); }
  28% { opacity: .92; transform: scale(1.05) rotate(0); }
  100% { opacity: .72; transform: scale(1); }
}

@keyframes story-sword-flash {
  0% { opacity: 0; transform: scale(.82) rotate(-3deg); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.08) rotate(1deg); }
}

@keyframes story-vignette-in {
  from { opacity: 0; }
  to { opacity: .76; }
}

@keyframes story-item-reveal {
  from { opacity: 0; transform: translate(-50%, -44%) rotate(var(--item-rotate, 0deg)) scale(.9); filter: blur(5px) drop-shadow(0 20px 30px rgba(0, 0, 0, .84)); }
  to { opacity: .94; transform: translate(-50%, -50%) rotate(var(--item-rotate, 0deg)) scale(1); filter: blur(0) drop-shadow(0 20px 30px rgba(0, 0, 0, .84)); }
}

@keyframes scene-shake-soft {
  0%, 100% { transform: translate3d(0, 0, 0); }
  28% { transform: translate3d(-3px, 1px, 0); }
  58% { transform: translate3d(3px, -1px, 0); }
  78% { transform: translate3d(-1px, 0, 0); }
}

@keyframes scene-shake-medium {
  0%, 100% { transform: translate3d(0, 0, 0); }
  18% { transform: translate3d(-6px, 2px, 0); }
  38% { transform: translate3d(6px, -2px, 0); }
  62% { transform: translate3d(-4px, 1px, 0); }
  82% { transform: translate3d(3px, 0, 0); }
}

@keyframes scene-shake-strong {
  0%, 100% { transform: translate3d(0, 0, 0); }
  14% { transform: translate3d(-10px, 4px, 0); }
  30% { transform: translate3d(10px, -4px, 0); }
  48% { transform: translate3d(-8px, 3px, 0); }
  68% { transform: translate3d(6px, -2px, 0); }
  86% { transform: translate3d(-3px, 1px, 0); }
}

@keyframes float-ember {
  0% { opacity: 0; transform: translate3d(0, 0, 0) scale(0.55); }
  10% { opacity: 0.92; }
  58% { opacity: 0.48; }
  100% { opacity: 0; transform: translate3d(var(--drift), -105vh, 0) scale(1.25); }
}

@keyframes ember-flicker {
  from { filter: brightness(0.78) blur(0); }
  to { filter: brightness(1.45) blur(0.45px); }
}

@keyframes title-fire-push {
  from { transform: scale(1.02); }
  to { transform: scale(1.08); }
}

@keyframes chapter-in-out {
  0%, 100% { opacity: 0; transform: translate(-50%, -45%); }
  16%, 76% { opacity: 1; transform: translate(-50%, -50%); }
}

@keyframes dialogue-up {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes dialogue-text-fade {
  from { opacity: 0.35; }
  to { opacity: 1; }
}

@keyframes next-bob {
  0%, 100% { transform: rotate(45deg) translateY(-3px); }
  50% { transform: rotate(45deg) translate(3px, 0); }
}

@keyframes ink-turn {
  to { transform: rotate(360deg) scale(1.08); }
}

@keyframes home-swipe-hint {
  0%, 100% { opacity: 0.48; transform: translateX(0); }
  50% { opacity: 0.9; transform: translateX(3px); }
}

@media (max-width: 1024px) and (orientation: portrait) {
  .scene-home .scene-bg {
    background-image: url("./assets/images/index/bg_index_mobile.webp");
    background-position: center;
  }

  .login-calendar-days {
    grid-template-columns: repeat(auto-fit, minmax(max(52px, calc((100% - 16px) / 5)), 1fr));
    gap: 4px;
  }

  .home-swipe-hint {
    position: absolute;
    z-index: 4;
    right: 0;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    color: rgba(239, 215, 172, 0.72);
    text-shadow: 0 2px 8px #000;
    pointer-events: none;
    gap: 14px;
  }

  .home-swipe-arrow {
    display: grid;
    width: 34px;
    height: 34px;
    padding: 0;
    cursor: pointer;
    border: 1px solid rgba(239, 201, 130, 0.42);
    border-radius: 50%;
    background: rgba(9, 8, 7, 0.52);
    color: #efc982;
    font-family: Georgia, serif;
    font-size: 25px;
    line-height: 1;
    pointer-events: auto;
    place-items: center;
    box-shadow: inset 0 0 10px rgba(239, 201, 130, 0.08);
    animation: home-swipe-hint 1.6s ease-in-out infinite;
  }

  .home-swipe-arrow.is-prev {
    animation-direction: reverse;
  }

  .home-swipe-arrow:disabled {
    cursor: default;
    opacity: 0.28;
    animation: none;
  }

  .home-swipe-status {
    display: grid;
    justify-items: center;
    gap: 6px;
  }

  .home-swipe-status > span {
    color: rgba(239, 215, 172, 0.72);
    font-size: 10px;
    letter-spacing: 0.2em;
    text-indent: 0.2em;
  }

  .home-swipe-dots {
    display: flex;
    gap: 7px;
  }

  .home-swipe-dots i {
    width: 5px;
    height: 5px;
    border: 1px solid rgba(239, 201, 130, 0.62);
    border-radius: 50%;
    background: transparent;
    transition: background 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
  }

  .home-swipe-dots i.is-active {
    background: #efc982;
    box-shadow: 0 0 8px rgba(239, 201, 130, 0.72);
    transform: scale(1.3);
  }

  .home-actions-left,
  .home-actions-right {
    display: contents;
  }

  .home-actions {
    position: absolute;
    top: 50%;
    right: 0;
    bottom: auto;
    left: 0;
    display: flex;
    height: auto;
    width: 100%;
    gap: clamp(12px, 2.4vw, 22px);
    padding: 0 calc((100% - min(307px, 72vw)) / 2);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scroll-padding-inline: calc((100% - min(307px, 72vw)) / 2);
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    transform: translateY(-50%);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    touch-action: pan-x;
    perspective: 900px;
  }

  .home-actions::-webkit-scrollbar {
    display: none;
  }

  .home-action-button {
    align-self: center;
    width: min(307px, 72vw);
    min-width: min(307px, 72vw);
    height: auto;
    flex: 0 0 auto;
    aspect-ratio: 526 / 941;
    opacity: 0.5;
    scroll-snap-align: center;
    scroll-snap-stop: always;
    transform: scale(0.88) rotateY(5deg);
    transition: opacity 0.32s ease, filter 0.32s ease, transform 0.32s ease;
  }

  .home-action-button.is-selected {
    z-index: 2;
    opacity: 1;
    filter: brightness(1.04) drop-shadow(0 0 12px rgba(242, 212, 155, 0.34)) drop-shadow(0 14px 18px rgba(0, 0, 0, 0.52));
    transform: scale(1) rotateY(0);
  }

  .home-action-button.is-selected ~ .home-action-button {
    transform: scale(0.88) rotateY(-5deg);
  }

  .home-action-button img {
    object-position: center;
  }

  .books-swipe-hint {
    position: relative;
    z-index: 2;
    display: block;
    margin: -18px 0 12px;
    color: rgba(226, 198, 147, .62);
    font-size: 10px;
    letter-spacing: .14em;
    text-shadow: 0 2px 7px #000;
    animation: home-swipe-hint 1.8s ease-in-out infinite;
  }

  .scroll-grid {
    --book-carousel-width: min(340px, 64vw);
    display: flex;
    width: calc(100% + 8vw);
    max-width: none;
    margin-right: -4vw;
    margin-left: -4vw;
    padding: 18px calc((100vw - var(--book-carousel-width)) / 2) 34px;
    overflow-x: auto;
    overflow-y: visible;
    scroll-behavior: smooth;
    scroll-padding-inline: calc((100vw - var(--book-carousel-width)) / 2);
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
    gap: clamp(16px, 3vw, 28px);
  }

  .scroll-grid::-webkit-scrollbar {
    display: none;
  }

  .scroll-grid .scroll-card {
    width: var(--book-carousel-width);
    min-width: var(--book-carousel-width);
    height: min(58vh, 470px);
    min-height: 370px;
    flex: 0 0 var(--book-carousel-width);
    opacity: .4;
    filter: brightness(.66) saturate(.7);
    scroll-snap-align: center;
    scroll-snap-stop: always;
    transform: perspective(900px) rotateY(6deg) scale(.86);
    transform-origin: center;
  }

  .scroll-grid .scroll-card.is-selected,
  .scroll-grid .scroll-card.is-selected:hover,
  .scroll-grid .scroll-card.is-selected:focus-visible {
    z-index: 3;
    opacity: 1;
    filter: brightness(1.08) saturate(1) drop-shadow(0 0 14px rgba(215, 163, 83, .22));
    transform: perspective(900px) rotateY(0) scale(1);
  }

  .scroll-grid .scroll-card.is-selected ~ .scroll-card {
    transform: perspective(900px) rotateY(-6deg) scale(.86);
  }

  .scroll-grid .scroll-card:not(.is-selected):hover,
  .scroll-grid .scroll-card:not(.is-selected):focus-visible {
    opacity: .55;
    filter: brightness(.76) saturate(.78);
  }
}

@media (max-width: 760px) and (orientation: portrait) {
  .scene-bg {
    background-position: center;
  }

  .home-screen {
    padding: var(--safe-top) 10px var(--safe-bottom);
  }

  .home-topbar {
    align-items: flex-start;
    padding-right: 0;
    gap: 8px;
  }

  .profile-card {
    width: min(42vw, 160px);
    min-width: 0;
    padding: 3px 8px 3px 3px;
    gap: 6px;
  }

  .profile-avatar {
    width: 46px;
    height: 46px;
    flex-basis: 46px;
    padding: 3px;
  }

  .profile-info {
    width: calc(100% - 52px);
    min-width: 0;
  }

  .profile-card p {
    font-size: 9px;
    letter-spacing: 0.18em;
  }

  .profile-card strong {
    margin-bottom: 2px;
    font-size: clamp(13px, 3.8vw, 17px);
    letter-spacing: 0.12em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .profile-progress {
    height: 3px;
    margin-top: 4px;
  }

  .home-resources {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: auto;
    max-width: 228px;
    flex: 1 1 auto;
    gap: 7px;
  }

  .home-resources .lantern-pill,
  .home-resources .reward-button,
  .home-resources .music-toggle,
  .home-resources .home-exit-button {
    width: 100%;
    height: 50px;
    min-height: 50px;
    padding: 4px 8px;
    flex-direction: row;
    justify-content: center;
    border: 1px solid rgba(221, 181, 111, .38);
    border-radius: 13px;
    background: linear-gradient(145deg, rgba(24, 18, 12, .88), rgba(5, 7, 9, .84));
    box-shadow: inset 0 0 16px rgba(219, 160, 74, .08), 0 5px 14px rgba(0, 0, 0, .3);
    backdrop-filter: blur(8px);
    gap: 5px;
    touch-action: manipulation;
  }

  .home-resources .lantern-hud-icon,
  .home-resources .reward-button img,
  .home-resources .music-toggle img,
  .home-resources .home-exit-button img {
    width: 29px;
    height: 29px;
    flex-basis: 29px;
  }

  .home-resources .lantern-pill strong,
  .home-resources .reward-button span,
  .home-resources .music-label,
  .home-resources .home-exit-label {
    overflow: hidden;
    font-size: 10px;
    line-height: 1.15;
    letter-spacing: .02em;
    text-overflow: ellipsis;
  }

  .home-resources .lantern-pill strong {
    color: #ffe0a0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 16px;
  }

  .home-resources button:active {
    border-color: rgba(245, 208, 143, .78);
    background: linear-gradient(145deg, rgba(61, 41, 22, .94), rgba(12, 11, 10, .92));
    filter: brightness(1.12);
    transform: scale(.96);
  }

  .home-centerpiece {
    top: 43%;
    width: min(560px, 76vw);
    padding: 18px 20px;
  }

  .home-centerpiece h2 {
    margin: 8px 0 10px;
    font-size: clamp(24px, 6.4vw, 42px);
  }

  .home-centerpiece span {
    font-size: clamp(10px, 2.4vw, 13px);
    line-height: 1.7;
  }

  .home-actions {
    top: 50%;
    right: 0;
    bottom: auto;
    left: 0;
    width: 100%;
    gap: 12px;
    padding-right: calc((100% - min(270px, 68vw)) / 2);
    padding-left: calc((100% - min(270px, 68vw)) / 2);
    scroll-padding-inline: calc((100% - min(270px, 68vw)) / 2);
    transform: translateY(-50%);
  }

  .home-action-button {
    width: min(270px, 68vw);
    min-width: min(270px, 68vw);
    filter: brightness(0.94) drop-shadow(0 8px 10px rgba(0, 0, 0, 0.58));
  }

  .home-modal {
    padding: 18px;
  }

  .login-calendar-card {
    width: 100%;
    max-width: calc(100vw - 28px);
    margin-right: auto;
    margin-left: auto;
    padding: 22px 12px 18px;
  }

  .login-calendar-modal {
    padding-right: 14px;
    padding-left: 14px;
    place-items: center;
  }

  .login-calendar-header {
    margin-bottom: 14px;
  }

  .login-calendar-header img {
    width: 48px;
    height: 48px;
    transform: translateY(10px);
  }

  .login-day {
    min-height: 58px;
  }

  .login-day b {
    font-size: 13px;
  }

  .login-day b img {
    width: 16px;
    height: 16px;
  }

  .minigame-list {
    grid-template-columns: 1fr;
  }

  .title-screen {
    justify-content: center;
    padding: 14vh 18px var(--safe-bottom);
  }

  .eyebrow {
    margin-bottom: 13px;
    letter-spacing: 0.34em;
  }

  .game-title {
    width: min(86vw, 520px);
  }

  .title-rule {
    width: 0;
    margin-top: 16px;
  }

  .title-copy {
    margin-bottom: 22px;
  }

  .enter-button::before,
  .enter-button::after {
    width: 28px;
  }

  .enter-button {
    width: min(74vw, 320px);
    min-width: 230px;
    min-height: 64px;
    margin-top: max(5vh, 32px);
  }

  .enter-button span {
    font-size: clamp(20px, 5vw, 28px);
  }

  .enter-user-icon {
    width: clamp(40px, 11vw, 58px);
    margin-top: max(1.6vh, 12px);
  }

  .headphone-note {
    bottom: var(--safe-bottom);
  }

  .scene-shop .scene-bg {
    background-position: 48% center;
  }

  .shopkeeper {
    bottom: 24vh;
    left: 50%;
    width: min(96vw, 430px);
    opacity: 0 !important;
    transform: translateX(-50%) scale(0.96) !important;
  }

  .shopkeeper-mian {
    right: auto;
  }

  .shopkeeper-mu {
    left: 50%;
  }

  .dialogue-active.narrators-visible.speaker-mian .shopkeeper-mian,
  .dialogue-active.narrators-visible.speaker-mu .shopkeeper-mu,
  .dialogue-active.narrators-visible.speaker-neutral.last-speaker-mian .shopkeeper-mian,
  .dialogue-active.narrators-visible.speaker-neutral.last-speaker-mu .shopkeeper-mu {
    z-index: 3;
    opacity: 1 !important;
    filter: brightness(1.06) drop-shadow(0 18px 26px rgba(0, 0, 0, 0.82));
    transform: translateX(-50%) scale(1.04) !important;
  }

  .scroll-select-active .shopkeeper {
    display: none;
  }

  .story-character {
    right: auto;
    bottom: 23vh;
    left: 50%;
    width: min(92vw, 430px);
    opacity: 0 !important;
    transform: translateX(-50%) scale(0.96) !important;
  }

  .story-character.is-speaking {
    opacity: 1 !important;
    transform: translateX(-50%) scale(1.03) !important;
  }

  .shopkeeper p {
    right: 5%;
    bottom: 10%;
    left: auto;
    font-size: 10px;
  }

  .dialogue-panel {
    right: 0;
    bottom: 0;
    left: 0;
    min-height: 176px;
    padding: 23px 72px max(48px, calc(34px + var(--safe-bottom))) 22px;
  }

  .speaker-row { justify-content: flex-start; }

  #dialogue-text {
    font-size: clamp(14px, 4vw, 17px);
    line-height: 1.75;
    text-align: left;
  }

  .dialogue-next {
    padding: 8px 4px;
  }

  .dialogue-actions { right: 16px; bottom: max(10px, var(--safe-bottom)); gap: 5px; }
  .dialogue-shortcut { font-size: 8px; }
  .dialogue-shortcut kbd { padding: 2px 4px; font-size: 7px; }
  .exit-story-button { top: 12px; right: 14px; padding: 6px 8px; font-size: 9px; }

  .ask-history-button {
    right: 18px;
    bottom: 14px;
  }

  .scroll-select {
    padding: 50px 18px var(--safe-bottom);
  }

  .scroll-select > #close-books-button {
    top: max(10px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
  }

  .scroll-grid {
    --book-carousel-width: min(310px, 72vw);
    width: calc(100% + 36px);
    margin-right: -18px;
    margin-left: -18px;
  }

  .history-choice > div {
    width: min(310px, 90vw);
    flex-direction: column;
  }

  .scroll-page {
    display: block;
    padding: 66px 34px 42px;
  }

  .scroll-page::before,
  .scroll-page::after {
    width: 14px;
  }

  .scroll-close {
    right: 24px;
  }

  .ink-portrait {
    min-height: 64vh;
    margin-top: 8px;
  }

  .scroll-copy {
    position: relative;
    z-index: 5;
    margin-top: -28px;
    padding: 0 0 40px;
    text-align: center;
  }

  .scroll-copy h2 {
    font-size: clamp(44px, 16vw, 68px);
  }

  .reader-divider {
    margin: auto;
  }

  .scroll-copy blockquote {
    padding: 15px 0 0;
    border-top: 1px solid rgba(116, 58, 35, 0.35);
    border-left: 0;
  }

  .character-identities {
    margin-right: auto;
    margin-left: auto;
  }

  .letter-sheet {
    min-height: 70vh;
    padding: 58px 38px 94px;
  }

  .letter-kicker {
    top: 52px;
    right: 24px;
  }

  .letter-sheet h3 {
    top: 52px;
    right: 50px;
  }

  #letter-text {
    width: max-content;
    min-width: 100%;
    height: 52vh;
    padding-right: 80px;
    font-size: 16px;
    line-height: 1.85;
  }

  .letter-closing {
    bottom: 30px;
    left: 35px;
    gap: 8px;
  }

  .letter-signature {
    width: 52px;
    height: 52px;
  }

  #letter-wish,
  .letter-author {
    font-size: 11px;
  }

  .portrait-hint {
    right: 4%;
    left: 4%;
  }

  .scroll-grid .scroll-card {
    display: block;
    min-height: 0;
    height: auto;
    padding: 0;
    aspect-ratio: 3 / 4.18;
    text-align: center;
  }

  .scroll-glyph {
    position: static;
    margin: 0;
    font-size: clamp(28px, 9vw, 40px);
    transform: none;
  }

  .book-title-label {
    top: 12%;
    bottom: 11%;
    left: calc(50% + 10px);
    width: min(48%, 92px);
    padding: 14% 10% 12%;
  }

  .scroll-card.is-viewed::after {
    left: calc(50% + 10px);
  }

  .book-title-label h3 {
    font-size: clamp(14px, 4.2vw, 18px);
  }

  .book-title-label p {
    font-size: 8px;
  }

  .book-spine {
    width: clamp(34px, 23%, 48px);
  }

  .book-corner {
    width: clamp(46px, 16vw, 66px);
  }

  .scroll-number {
    top: 16px;
    right: 24px;
    font-size: 8px;
  }

}

@media (max-width: 600px) and (orientation: portrait) {
  .home-exit-actions {
    grid-template-columns: 1fr;
  }

  .home-exit-choice {
    min-height: 66px;
  }

  .reader-actions {
    justify-content: center;
  }

  .route-keepsake-modal {
    padding: 12px;
  }

  .route-keepsake-panel {
    width: 94vw;
    height: calc(100dvh - 24px);
    max-height: calc(100dvh - 24px);
    padding: 8px 4px 10px;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .route-keepsake-close {
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    width: 44px;
    height: 44px;
    font-size: 27px;
  }

  .route-keepsake-list {
    grid-template-columns: 1fr;
  }

  .route-keepsake-card img {
    width: 68%;
    height: clamp(85px, 17vh, 135px);
  }

  .route-keepsake-card {
    min-height: 0;
    padding: clamp(9px, 1.5vh, 14px) 12px;
    border-radius: 14px;
    grid-template-columns: minmax(105px, 36%) 1fr;
    gap: 15px;
  }

  .route-keepsake-era {
    font-size: clamp(9px, 2.7vw, 12px);
  }

  .route-keepsake-name {
    font-size: clamp(16px, 4.5vw, 23px);
  }

  .route-keepsake-copy > i {
    margin: 10px 0 11px;
  }

  .route-keepsake-meaning {
    font-size: clamp(9px, 1.45vh, 12px);
    line-height: 1.6;
  }

  .route-keepsake-card[aria-expanded="true"] .route-keepsake-meaning {
    max-height: 22vh;
  }

  .route-keepsake-copy small {
    margin-top: 7px;
    font-size: 8px;
  }

  .route-keepsake-panel > footer {
    padding: 0 20px;
    font-size: 9px;
    line-height: 1.8;
  }

  .login-calendar-days {
    grid-template-columns: repeat(auto-fit, minmax(max(68px, calc((100% - 8px) / 3)), 1fr));
  }
}

@media (max-width: 360px) and (orientation: portrait) {
  .profile-card {
    width: 39vw;
  }

  .profile-avatar {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }

  .profile-info {
    width: calc(100% - 48px);
  }
}

/* Shared page and image loading states. */
.site-loading {
  position: fixed;
  z-index: 9999;
  inset: 0;
  display: grid;
  visibility: hidden;
  align-content: center;
  justify-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 50% 42%, rgba(191, 124, 49, .18), transparent 28%),
    linear-gradient(145deg, rgba(8, 9, 11, .97), rgba(20, 13, 9, .98));
  color: #ead3a5;
  opacity: 0;
  pointer-events: none;
  transition: opacity .24s ease, visibility .24s ease;
}

.site-loading.is-visible {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.site-loading-mark {
  position: relative;
  display: grid;
  width: 76px;
  height: 76px;
  border: 1px solid rgba(220, 174, 95, .45);
  border-radius: 50%;
  background: rgba(12, 10, 8, .7);
  box-shadow: inset 0 0 24px rgba(217, 147, 51, .12), 0 0 32px rgba(219, 145, 48, .14);
  place-items: center;
}

/* 「燈」字後方的燈芯暖光與周圍浮火，維持低亮度避免蓋過字形。 */
.site-loading-mark::before {
  position: absolute;
  z-index: 0;
  width: 54px;
  height: 62px;
  border-radius: 48% 48% 44% 44%;
  background:
    radial-gradient(ellipse at 50% 60%, rgba(255, 218, 139, .46) 0 10%, rgba(224, 139, 45, .2) 28%, transparent 66%);
  box-shadow:
    0 0 18px rgba(240, 166, 66, .28),
    0 0 42px rgba(209, 112, 27, .18);
  content: "";
  filter: blur(.3px);
  animation: loading-lantern-breathe 1.8s ease-in-out infinite;
}

.site-loading-mark::after {
  position: absolute;
  z-index: 0;
  top: 18px;
  left: 12px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #f4c77a;
  box-shadow:
    52px 9px rgba(237, 176, 83, .72),
    7px 42px rgba(209, 125, 45, .62),
    45px 48px rgba(247, 202, 116, .52),
    -7px 26px rgba(213, 134, 51, .42);
  content: "";
  animation: loading-fireflies 2.4s ease-in-out infinite alternate;
}

.site-loading-mark i {
  position: absolute;
  inset: -8px;
  border: 1px solid transparent;
  border-top-color: #d6a45d;
  border-right-color: rgba(214, 164, 93, .28);
  border-radius: 50%;
  animation: loading-orbit 1.15s linear infinite;
}

.site-loading-mark span {
  position: relative;
  z-index: 2;
  color: #efd19a;
  font-family: "Noto Serif TC", serif;
  font-size: 29px;
  text-shadow: 0 0 8px rgba(255, 219, 146, .72), 0 0 20px rgba(232, 142, 48, .48);
  animation: loading-character-glow 1.8s ease-in-out infinite;
}

.site-loading p {
  margin: 24px 0 12px;
  font-size: 14px;
  letter-spacing: .34em;
  text-indent: .34em;
}

.site-loading-track {
  width: min(280px, 70vw);
  height: 3px;
  overflow: hidden;
  background: rgba(226, 201, 156, .14);
}

.site-loading-track i {
  display: block;
  width: 8%;
  height: 100%;
  background: linear-gradient(90deg, #8e5e2c, #efc577);
  box-shadow: 0 0 9px rgba(232, 168, 80, .58);
  transition: width .2s ease;
}

.site-loading small {
  margin-top: 9px;
  color: rgba(225, 204, 168, .56);
  font-size: 10px;
  letter-spacing: .18em;
}

img.image-loading {
  background-color: rgba(34, 29, 23, .78);
  background-image: linear-gradient(105deg, transparent 28%, rgba(232, 197, 137, .18) 44%, rgba(255, 226, 171, .28) 50%, rgba(232, 197, 137, .18) 56%, transparent 72%);
  background-position: 180% 0;
  background-size: 220% 100%;
  animation: image-loading-shimmer 1.2s ease-in-out infinite;
}

img.image-loading:not(.route-portrait) {
  opacity: .58;
}

img.image-loaded:not(.route-portrait) {
  animation: image-loading-reveal .28s ease both;
}

/* 逐格動畫會持續替換 src，不可套用一般圖片的矩形載入骨架。 */
.dream-butterfly img[data-frame-animation] {
  background: transparent !important;
  opacity: 1 !important;
  animation: none !important;
}

img.image-load-error {
  min-width: 42px;
  min-height: 42px;
  background:
    linear-gradient(135deg, transparent 47%, rgba(182, 120, 78, .55) 48% 52%, transparent 53%),
    rgba(31, 25, 21, .84);
  opacity: .48;
}

@keyframes loading-orbit { to { transform: rotate(360deg); } }
@keyframes loading-lantern-breathe {
  0%, 100% { opacity: .68; transform: scale(.92); }
  50% { opacity: 1; transform: scale(1.08); }
}
@keyframes loading-character-glow {
  0%, 100% { filter: brightness(.94); }
  50% { filter: brightness(1.12); }
}
@keyframes loading-fireflies {
  from { opacity: .42; transform: translateY(3px) scale(.82); }
  to { opacity: .95; transform: translateY(-4px) scale(1.08); }
}
@keyframes image-loading-shimmer { to { background-position: -120% 0; } }
@keyframes image-loading-reveal { from { opacity: .35; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .site-loading-mark::before,
  .site-loading-mark::after,
  .site-loading-mark span { animation: none; }
}

/* Phones in landscape keep the desktop composition, but use a compact vertical rhythm. */
@media (orientation: landscape) and (max-height: 600px) and (pointer: coarse) {
  .title-screen { padding: max(10px, env(safe-area-inset-top)) 24px max(8px, env(safe-area-inset-bottom)); }
  .game-title { width: min(460px, 42vw); max-height: 42dvh; }
  .enter-button { min-height: 52px; margin-top: clamp(12px, 4dvh, 26px); }
  .enter-button span { font-size: clamp(18px, 4dvh, 25px); }
  .enter-button small { margin-top: 4px; }
  .enter-user-icon, .headphone-note { display: none; }

  .home-screen { padding-block: max(8px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-bottom)); }
  .home-topbar { align-items: center; padding-right: 54px; }
  .profile-card { min-width: 230px; gap: 9px; }
  .profile-avatar { width: 54px; height: 54px; flex-basis: 54px; }
  .profile-card strong { margin-bottom: 2px; font-size: 16px; }
  .profile-card p { font-size: 11px; }
  .profile-progress { margin-top: 4px; }
  .home-resources .lantern-pill,
  .home-resources .reward-button,
  .home-resources .music-toggle,
  .home-resources .home-exit-button { height: 38px; min-height: 38px; }
  .home-resources .lantern-hud-icon,
  .home-resources .reward-button img,
  .home-resources .music-toggle img,
  .home-resources .home-exit-button img { width: 31px; height: 31px; flex-basis: 31px; }
  .home-actions { height: calc(100dvh - 70px); padding: 1.5% 0 0; }

  .home-modal { padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .home-modal-card, .story-map-card, .login-calendar-card,
  .scroll-reader, .love-letter, .passcode-scroll { max-height: calc(100dvh - 16px); overflow-y: auto; }
  .dialogue-panel { max-height: 44dvh; overflow-y: auto; }
  .chapter-card { transform: translate(-50%, -50%) scale(.82); }
}

/* Mobile index resources remain a compact list without repeated card chrome. */
@media (max-width: 760px) and (orientation: portrait),
       (orientation: landscape) and (max-height: 600px) and (pointer: coarse) {
  .home-resources .lantern-pill,
  .home-resources .reward-button,
  .home-resources .music-toggle,
  .home-resources .home-exit-button,
  .home-resources .reward-button:hover,
  .home-resources .reward-button:active,
  .home-resources .music-toggle:hover,
  .home-resources .music-toggle:active,
  .home-resources .music-toggle.music-started:not(.music-muted),
  .home-resources .home-exit-button:hover,
  .home-resources .home-exit-button:active {
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  .home-resources button:focus-visible {
    border: 0;
    border-radius: 3px;
    outline: 1px solid rgba(239, 225, 199, .72);
    outline-offset: 2px;
    background: transparent;
    box-shadow: none;
  }
}

/* Phone-only keepsake layout: artwork above, description below. */
@media (max-width: 600px) and (orientation: portrait),
       (orientation: landscape) and (max-height: 600px) and (pointer: coarse) {
  .route-keepsake-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .route-keepsake-visual,
  .route-keepsake-card.is-ancient .route-keepsake-visual {
    min-height: clamp(210px, 32vh, 300px);
    order: 1;
  }

  .route-keepsake-info,
  .route-keepsake-card.is-ancient .route-keepsake-info {
    padding: 24px 16px;
    order: 2;
  }
}

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