@font-face {
  font-family: "LXGW WenKai";
  src: url("../assets/fonts/lxgw-wenkai-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Noto Sans TC";
  src: url("../assets/fonts/noto-sans-tc-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #f7f4ee;
  --gold: rgba(214, 184, 122, 0.88);
  --gold-soft: rgba(214, 184, 122, 0.55);
  --cream: #f4efe6;
  --mat: #f7f3ea;
  --night: #07060f;
  --kai: "LXGW WenKai", "Songti TC", "PMingLiU", serif;
  --sans: "Noto Sans TC", "PingFang HK", "Noto Sans CJK TC", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--night);
  color: var(--ink);
  color-scheme: dark;
}

body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

button, p, h1, h2, ol, figure { margin: 0; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
}

img { user-select: none; -webkit-user-drag: none; }

::selection { background: rgba(214, 184, 122, 0.35); }

.stage {
  width: min(100vw, calc(100vh * 16 / 9));
  aspect-ratio: 16 / 9;
  position: relative;
  overflow: hidden;
  background: #120e22;
  container-type: size;
  cursor: pointer;
}

.stage.is-title,
.stage.is-ending { cursor: default; }

.bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  pointer-events: none;
}

.vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(to top, rgba(6, 5, 16, 0.62) 0%, rgba(6, 5, 16, 0.18) 26%, rgba(6, 5, 16, 0) 52%);
}

.stage.is-title .vignette {
  background:
    linear-gradient(to top, rgba(6, 5, 16, 0.38), rgba(6, 5, 16, 0) 28%),
    linear-gradient(to right, rgba(6, 5, 16, 0.18), rgba(6, 5, 16, 0) 36%);
}

.stage.is-memory .vignette {
  background: linear-gradient(to top, rgba(40, 16, 36, 0.42) 0%, rgba(40, 16, 36, 0) 24%);
}

.stage.is-memory::after {
  content: "";
  position: absolute;
  z-index: 1;
  top: 0;
  right: 0;
  bottom: 0;
  width: 16%;
  pointer-events: none;
  background: linear-gradient(to left, rgba(42, 18, 40, 0.28), transparent);
}

.demo-badge,
.scene-head,
#scene-title,
.zodiac,
.frame,
.frame-hint,
.dialogue,
.choices,
.ending,
.advance-hint,
.astrolabe,
#debug {
  z-index: 2;
}

.demo-badge {
  position: absolute;
  top: 4.2%;
  right: 3.6%;
  font-family: var(--sans);
  font-size: 0.72cqw;
  letter-spacing: 0.22em;
  color: rgba(247, 244, 238, 0.82);
  border: 1px solid var(--gold-soft);
  padding: 0.45em 0.85em;
  background: rgba(10, 8, 22, 0.28);
}

#scene-title {
  position: absolute;
  top: 7.2%;
  left: 5.6%;
  color: var(--ink);
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.45);
}

#scene-title h1,
#scene-title h2 {
  font-family: var(--kai);
  font-weight: 400;
  letter-spacing: 0.28em;
}

#scene-title h1 { font-size: 4.5cqw; }

#scene-title h2 { font-size: 3.35cqw; }

#scene-title .series,
#scene-title .sub {
  font-family: var(--kai);
  font-size: 1.25cqw;
  letter-spacing: 0.42em;
  opacity: 0.9;
  margin-top: 0.45em;
}

#scene-title .kicker {
  font-family: var(--sans);
  font-size: 0.78cqw;
  letter-spacing: 0.42em;
  opacity: 0.78;
  margin-bottom: 0.35em;
}

.zodiac {
  position: absolute;
  top: 11%;
  right: 4%;
  list-style: none;
  padding: 0;
  font-family: var(--sans);
  font-size: 0.78cqw;
  letter-spacing: 0.28em;
  line-height: 1.95;
  color: rgba(255, 250, 246, 0.9);
  text-shadow: 0 1px 2px rgba(40, 12, 28, 0.65), 0 0 12px rgba(40, 12, 28, 0.45);
}

.zodiac .num {
  display: inline-block;
  min-width: 2.1em;
  opacity: 0.78;
}

.frame {
  position: absolute;
  left: 50%;
  top: 12%;
  transform: translateX(-50%);
  width: 28%;
  height: 58%;
  background: var(--cream);
  border: 1px solid rgba(186, 150, 92, 0.95);
  box-shadow: inset 0 0 0 1px rgba(186, 150, 92, 0.45);
  padding: 0.55cqw;
}

.frame-mat {
  position: relative;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(186, 150, 92, 0.72);
  background: var(--mat);
  overflow: hidden;
  display: grid;
  place-items: center;
}

.frame img {
  width: 92%;
  height: 78%;
  object-fit: cover;
  object-position: 40% 72%;
  opacity: 0;
  transform: scale(1.02);
  transition: opacity 700ms ease;
}

.frame.is-filled img { opacity: 1; }

.frame figcaption {
  position: absolute;
  z-index: 1;
  left: 6%;
  right: 6%;
  bottom: 2.2%;
  text-align: center;
  color: #6e5a3c;
  font-family: var(--kai);
  font-size: 0.72cqw;
  letter-spacing: 0.14em;
  line-height: 1.4;
  background: linear-gradient(to top, rgba(247, 243, 234, 0.92), rgba(247, 243, 234, 0));
  padding-top: 0.8em;
}

.frame .note {
  display: block;
  margin-top: 0.15em;
  font-family: var(--sans);
  font-size: 0.58cqw;
  letter-spacing: 0.12em;
  color: #8d7760;
}

.frame-hint {
  position: absolute;
  left: 50%;
  top: 72.5%;
  transform: translateX(-50%);
  width: 40%;
  text-align: center;
  font-family: var(--kai);
  font-size: 1.15cqw;
  letter-spacing: 0.32em;
  color: var(--ink);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}

.dialogue {
  position: absolute;
  left: 7%;
  right: 16%;
  bottom: 8%;
  text-align: left;
}

.dialogue::before {
  content: "";
  display: block;
  width: 4.4cqw;
  height: 1px;
  background: var(--gold);
  margin-bottom: 0.7em;
}

.speaker {
  font-family: var(--sans);
  font-size: 0.75cqw;
  letter-spacing: 0.42em;
  color: rgba(240, 216, 164, 0.92);
  margin-bottom: 0.35em;
}

.line {
  font-family: var(--kai);
  font-size: 1.55cqw;
  line-height: 1.75;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.55);
}

.dialogue[data-speaker="蝕月"] .line { color: #f6d5dc; }

.dialogue[data-speaker="Jonathan"] .line { opacity: 0.9; }

.stage.is-memory .dialogue {
  left: 50%;
  right: auto;
  bottom: 13.5%;
  width: min(72%, 78cqw);
  transform: translateX(-50%);
  text-align: center;
}

.stage.is-memory .dialogue::before { margin-inline: auto; }

.stage.is-memory .speaker { letter-spacing: 0.36em; }

.stage.is-memory .line { font-size: 1.22cqw; }

.choices {
  position: absolute;
  left: 50%;
  bottom: 5.4%;
  transform: translateX(-50%);
  display: flex;
  gap: 2.6cqw;
  align-items: center;
}

.choice {
  font-family: var(--kai);
  font-size: 1.12cqw;
  letter-spacing: 0.28em;
  color: rgba(247, 244, 238, 0.94);
  cursor: pointer;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  padding-bottom: 0.18em;
}

.choice:hover,
.choice:focus-visible {
  color: #f8e7c4;
  outline: none;
  box-shadow: inset 0 -1px 0 var(--gold);
}

.choice.is-seen { box-shadow: inset 0 -1px 0 rgba(214, 184, 122, 0.75); }

.choice.start {
  font-size: 1.7cqw;
  letter-spacing: 0.64em;
  padding-left: 0.64em;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.5);
}

.stage.is-title .choices { bottom: 10.5%; }

.ending {
  position: absolute;
  left: 32%;
  top: 28%;
  width: 36%;
  padding-left: 1.3cqw;
  border-left: 1px solid var(--gold);
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.55);
}

.ending p {
  font-family: var(--kai);
  font-size: 1.12cqw;
  line-height: 1.85;
  letter-spacing: 0.05em;
  margin-bottom: 0.7em;
}

.restart {
  margin-top: 0.4em;
  font-family: var(--sans);
  font-size: 0.85cqw;
  letter-spacing: 0.28em;
  cursor: pointer;
  border-bottom: 1px solid var(--gold-soft);
  padding-bottom: 0.15em;
}

.restart:hover,
.restart:focus-visible {
  color: #f8e7c4;
  outline: none;
  border-bottom-color: var(--gold);
}

.advance-hint {
  position: absolute;
  right: 11%;
  bottom: 3.4%;
  font-family: var(--sans);
  font-size: 0.62cqw;
  letter-spacing: 0.24em;
  color: rgba(247, 244, 238, 0.48);
  pointer-events: none;
}

.astrolabe {
  position: absolute;
  right: 2%;
  bottom: 2.4%;
  width: 6.4cqw;
  height: 6.4cqw;
  color: var(--gold-soft);
  pointer-events: none;
}

#debug {
  position: absolute;
  left: 1.2%;
  bottom: 2%;
  max-width: 24%;
  margin: 0;
  padding: 0.6em 0.7em;
  font-family: ui-monospace, monospace;
  font-size: 0.62cqw;
  line-height: 1.45;
  color: #f4efe6;
  background: rgba(8, 6, 18, 0.72);
  border: 1px solid var(--gold-soft);
  white-space: pre-wrap;
  cursor: auto;
}

.noscript {
  position: fixed;
  inset: auto 0 1rem 0;
  text-align: center;
  font-family: var(--sans);
}

.stage.is-wind::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 15%, rgba(255, 255, 255, 0.06) 42%, transparent 68%);
  background-size: 220% 100%;
  animation: sheen 8s linear infinite;
}

@keyframes sheen {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .stage.is-wind::before { animation: none; }
  .frame img { transition: none; }
}
