:root {
  --ink: #140c0a;
  --ink-2: #1f1410;
  --blood: #8b1a1a;
  --cinnabar: #c43c2c;
  --gold: #c4a574;
  --gold-dim: #8a7048;
  --paper: #e8d5b0;
  --paper-2: #d4bc8e;
  --ash: #6b5a4a;
  --mist: #2a2018;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  height: 100%;
  background: #070504;
  color: var(--paper);
  font-family: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC",
    "SimSun", "PingFang SC", "Noto Sans SC", serif;
}

body {
  display: flex;
  justify-content: center;
  align-items: stretch;
}

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

.phone {
  position: relative;
  width: min(100vw, 430px);
  height: 100dvh;
  max-height: 100svh;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 0%, #3a1812 0%, transparent 55%),
    linear-gradient(180deg, #1a0e0c 0%, #0d0806 100%);
  box-shadow: 0 0 0 1px #2a1810, 0 0 80px rgba(120, 20, 10, 0.25);
}

.grain,
.vignette {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 1;
}

.grain {
  opacity: 0.14;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.vignette {
  box-shadow: inset 0 0 80px 20px rgba(0, 0, 0, 0.55);
}

.topbar {
  position: relative;
  z-index: 3;
  padding: calc(14px + var(--safe-t)) 20px 8px;
  text-align: center;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.42em;
  font-size: 11px;
  color: var(--gold);
  opacity: 0.85;
}

.topbar h1 {
  margin: 6px 0 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
}

.stage {
  position: relative;
  z-index: 2;
  height: calc(100dvh - 168px - var(--safe-t) - var(--safe-b));
  margin: 0 14px;
}

.dock[hidden] {
  display: none !important;
}

.dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  padding: 8px 14px calc(12px + var(--safe-b));
  background: linear-gradient(180deg, transparent, rgba(10, 6, 4, 0.92) 28%);
}

.clue-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 10px;
  min-height: 36px;
}

.chip {
  flex: 0 0 auto;
  padding: 6px 12px;
  border: 1px solid var(--gold-dim);
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--paper-2);
  background: rgba(40, 22, 16, 0.7);
}

.dock-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ghost-btn,
.primary-btn {
  min-height: 48px;
  border-radius: 8px;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
}

.ghost-btn {
  border: 1px solid #5a4030;
  background: rgba(30, 18, 14, 0.85);
}

.primary-btn {
  width: 100%;
  background: linear-gradient(180deg, #9a2a22, #6a1410);
  border: 1px solid #d4a070;
  box-shadow: 0 8px 20px rgba(80, 10, 8, 0.35);
}

.primary-btn:disabled {
  opacity: 0.45;
}

.sheet[hidden] {
  display: none !important;
}

.sheet:not([hidden]) {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: flex-end;
  background: rgba(6, 3, 2, 0.55);
}

.sheet-inner {
  width: 100%;
  max-height: 78%;
  overflow: auto;
  padding: 22px 20px calc(22px + var(--safe-b));
  background:
    linear-gradient(180deg, rgba(56, 28, 20, 0.2), transparent 40%),
    #1a100c;
  border-top: 1px solid var(--gold-dim);
  box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.45);
}

.sheet-kicker {
  margin: 0 0 10px;
  color: var(--gold);
  letter-spacing: 0.32em;
  font-size: 12px;
}

.sheet-body {
  font-size: 16px;
  line-height: 1.85;
  letter-spacing: 0.04em;
}

.sheet-body p {
  margin: 0 0 0.9em;
}

.sheet-body p:last-child {
  margin-bottom: 0;
}

.sheet-actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 12px 6px 8px;
}

.title-art,
.scene-art {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 1px solid #3d2a1c;
  border-radius: 6px;
  background: #120c09;
  pointer-events: none;
}

.corner {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 1px solid var(--gold-dim);
  z-index: 2;
}

.corner.tl { top: 8px; left: 8px; border-right: 0; border-bottom: 0; }
.corner.tr { top: 8px; right: 8px; border-left: 0; border-bottom: 0; }
.corner.bl { bottom: 8px; left: 8px; border-right: 0; border-top: 0; }
.corner.br { bottom: 8px; right: 8px; border-left: 0; border-top: 0; }

.title-copy {
  position: relative;
  z-index: 3;
  text-align: center;
  padding: 0 12px 8px;
}

.title-copy .mark {
  font-size: 13px;
  letter-spacing: 0.5em;
  color: var(--gold);
}

.title-copy h2 {
  margin: 10px 0 8px;
  font-size: 40px;
  letter-spacing: 0.36em;
  text-indent: 0.36em;
}

.title-copy .sub {
  margin: 0 0 22px;
  color: var(--paper-2);
  letter-spacing: 0.22em;
}

.lantern {
  position: absolute;
  width: 28px;
  height: 40px;
  border-radius: 14px 14px 8px 8px;
  background: radial-gradient(circle at 40% 30%, #ffb070, #c43c2c 55%, #6a1410);
  box-shadow: 0 0 24px 6px rgba(220, 70, 30, 0.45);
  animation: flicker 2.8s ease-in-out infinite;
}

.lantern::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -10px;
  width: 2px;
  height: 12px;
  background: #6b5a4a;
  transform: translateX(-50%);
}

.lantern.l1 { top: 18px; left: 22%; animation-delay: 0s; }
.lantern.l2 { top: 28px; right: 18%; animation-delay: 0.7s; width: 22px; height: 32px; }

@keyframes flicker {
  0%, 100% { filter: brightness(1); }
  40% { filter: brightness(1.15); }
  70% { filter: brightness(0.82); }
}

.moon {
  position: absolute;
  top: 36px;
  right: 36px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f3e6c4, #c4a574 70%, #6a5030);
  box-shadow: 0 0 40px rgba(220, 180, 110, 0.25);
  opacity: 0.55;
}

.gate {
  position: absolute;
  left: 16%;
  right: 16%;
  bottom: 8%;
  height: 58%;
  background:
    linear-gradient(#4a2018, #2a100c) 0 0 / 100% 18% no-repeat,
    repeating-linear-gradient(90deg, #2a1610 0 18px, #1a0e0a 18px 22px);
  border: 2px solid #5a3820;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.45);
}

.gate::before {
  content: "纸扎铺";
  position: absolute;
  left: 50%;
  top: 8%;
  transform: translateX(-50%);
  padding: 4px 8px;
  writing-mode: vertical-rl;
  letter-spacing: 0.4em;
  font-size: 13px;
  color: var(--gold);
  border: 1px solid var(--gold-dim);
  background: #3a1810;
}

.paper-horse {
  position: absolute;
  left: 8%;
  bottom: 18%;
  width: 38%;
  height: 36%;
}

.horse-body {
  position: absolute;
  left: 10%;
  bottom: 18%;
  width: 70%;
  height: 42%;
  background: linear-gradient(180deg, #d8c49a, #8a7048);
  clip-path: polygon(8% 40%, 30% 10%, 78% 18%, 100% 48%, 86% 100%, 12% 92%);
  opacity: 0.85;
}

.horse-neck {
  position: absolute;
  left: 62%;
  bottom: 48%;
  width: 18%;
  height: 38%;
  background: #c4a574;
  transform: rotate(18deg);
  border-radius: 8px 8px 2px 2px;
}

.horse-head {
  position: absolute;
  left: 72%;
  bottom: 70%;
  width: 22%;
  height: 16%;
  background: #d4bc8e;
  border-radius: 40% 20% 30% 50%;
}

.sash {
  position: absolute;
  left: 40%;
  bottom: 46%;
  width: 36%;
  height: 6px;
  background: #8b1a1a;
  transform: rotate(-12deg);
  box-shadow: 0 8px 0 #6a1410;
}

.altar {
  position: absolute;
  left: 28%;
  right: 18%;
  bottom: 14%;
  height: 22%;
  background: linear-gradient(180deg, #4a2a18, #22140c);
  border: 1px solid #6a4830;
}

.tablets {
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 100%;
  height: 70%;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
}

.tablet {
  width: 22%;
  height: 100%;
  background: #2a1810;
  border: 1px solid #8a7048;
}

.tablet.fresh {
  border-color: #c43c2c;
  box-shadow: 0 0 12px rgba(180, 30, 20, 0.35);
}

.candles {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 100%;
  height: 28px;
  display: flex;
  justify-content: space-between;
}

.candle {
  width: 6px;
  height: 18px;
  background: #e8d5b0;
  box-shadow: 0 -8px 10px rgba(255, 140, 40, 0.7);
}

.mirror {
  position: absolute;
  right: 8%;
  top: 28%;
  width: 16%;
  height: 22%;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #d8e0e4, #6a8088 60%, #2a3030);
  border: 4px solid #8a7048;
  box-shadow: 0 0 16px rgba(180, 200, 210, 0.2);
}

.invite {
  position: absolute;
  left: 36%;
  bottom: 28%;
  width: 18%;
  height: 10%;
  background: #8b1a1a;
  transform: rotate(-8deg);
  box-shadow: 2px 2px 0 #4a1010;
}

.drawer {
  position: absolute;
  left: 34%;
  right: 24%;
  bottom: 8%;
  height: 8%;
  background: #3a2418;
  border: 1px solid #6a4830;
}

.drawer::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  border: 2px solid #c4a574;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.inner-door {
  position: absolute;
  right: 6%;
  bottom: 16%;
  width: 16%;
  height: 42%;
  background: repeating-linear-gradient(#2a1610, #2a1610 10px, #1a0e0a 10px 12px);
  border: 1px solid #5a3820;
}

.bride {
  position: absolute;
  left: 34%;
  bottom: 16%;
  width: 28%;
  height: 48%;
}

.bride-body {
  position: absolute;
  inset: 28% 12% 0;
  background: linear-gradient(180deg, #9a1c1c, #4a0c0c);
  border-radius: 40% 40% 8% 8%;
}

.veil {
  position: absolute;
  left: 18%;
  right: 18%;
  top: 8%;
  height: 36%;
  background: linear-gradient(180deg, #c43c2c, #6a1410);
  border-radius: 40% 40% 0 0;
}

.bed {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 8%;
  height: 16%;
  background: #3a1814;
  border-top: 8px solid #8b1a1a;
}

.window-paper {
  position: absolute;
  left: 8%;
  top: 16%;
  width: 28%;
  height: 26%;
  background: #c4a574;
  opacity: 0.35;
  box-shadow: inset 0 0 0 2px #8a7048;
}

.lamps {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 12%;
  height: 30%;
}

.hotspot {
  position: absolute;
  z-index: 4;
  pointer-events: auto;
  min-width: 56px;
  min-height: 56px;
  border: 1px dashed rgba(196, 165, 116, 0.35);
  border-radius: 8px;
  background: rgba(196, 165, 116, 0.06);
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.16em;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
}

.hotspot.done {
  border-style: solid;
  border-color: rgba(196, 165, 116, 0.18);
  color: var(--ash);
  background: transparent;
}

.hotspot.lock {
  border-color: rgba(196, 60, 44, 0.45);
}

.hotspot.pulse {
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  50% { box-shadow: 0 0 0 6px rgba(196, 165, 116, 0.08); }
}

.puzzle {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  padding: 10px 4px;
}

.puzzle h3 {
  margin: 0 0 8px;
  text-align: center;
  letter-spacing: 0.28em;
  font-size: 18px;
}

.puzzle .hint {
  margin: 0 0 14px;
  text-align: center;
  color: var(--paper-2);
  font-size: 13px;
  line-height: 1.7;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.tile {
  min-height: 72px;
  background: #7a1c18;
  border: 1px solid #d4a070;
  color: #f3e6c4;
  letter-spacing: 0.2em;
  font-size: 18px;
  box-shadow: 0 6px 0 #4a1010;
}

.tile.sel {
  outline: 2px solid var(--paper);
  transform: translateY(-2px);
}

.lamp-board {
  position: relative;
  height: 230px;
  margin: 8px 10px 16px;
}

.lamp-btn {
  position: absolute;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid #8a7048;
  background: #2a1810;
  letter-spacing: 0.12em;
  font-size: 14px;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.5);
}

.lamp-btn.lit {
  background: radial-gradient(circle at 40% 35%, #ffd090, #c43c2c 60%, #4a1010);
  box-shadow: 0 0 22px rgba(220, 80, 30, 0.55);
  color: #fff6e4;
}

.lamp-btn[data-id="n"] { left: 50%; top: 0; transform: translateX(-50%); }
.lamp-btn[data-id="s"] { left: 50%; bottom: 0; transform: translateX(-50%); }
.lamp-btn[data-id="w"] { left: 0; top: 50%; transform: translateY(-50%); }
.lamp-btn[data-id="e"] { right: 0; top: 50%; transform: translateY(-50%); }
.lamp-btn[data-id="c"] { left: 50%; top: 50%; transform: translate(-50%, -50%); }

.ending {
  position: relative;
  z-index: 3;
  height: 100%;
  overflow: auto;
  padding: 8px 8px 4px;
}

.ending article {
  font-size: 15px;
  line-height: 1.9;
}

.ending h3 {
  text-align: center;
  letter-spacing: 0.4em;
  color: var(--gold);
}

.shake {
  animation: shake 0.35s linear;
}

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

.hidden { display: none !important; }
