/* ============================================================
   雨夜咖啡馆 · H5
   竖屏 · 卡通雨夜 · 主色 #FF8A3D
   ============================================================ */
:root {
  --amber: #FF8A3D;
  --amber-deep: #E96F24;
  --amber-soft: #FFB066;
  --cream: #F8EDDA;
  --cream-deep: #EFDCC0;
  --paper: #FBF2E2;
  --ink: #2A1B12;
  --ink-soft: #7C6651;
  --night: #071016;
  --teal: #14302A;
  --line: rgba(90, 58, 32, .16);
}

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

html {
  margin: 0;
  padding: 0;
  background: #070c10;
  color: #f8edda;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: #070c10;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  overscroll-behavior-y: none;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

button:focus-visible {
  outline: 2px solid #ffc98f;
  outline-offset: 3px;
}

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

.app {
  position: relative;
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  background: #08111a;
  box-shadow: 0 0 90px rgba(0, 0, 0, .85);
}

.screen { display: none; }
.screen.is-active { display: block; animation: screenIn .5s cubic-bezier(.2, .8, .2, 1) both; }
.game.is-active { display: flex; }

@keyframes screenIn {
  from { opacity: 0; transform: scale(1.015); }
  to { opacity: 1; transform: scale(1); }
}

/* ============================================================
   门廊
   ============================================================ */
.home {
  position: relative;
  min-height: 100dvh;
  overflow: hidden;
  background: #08111a;
}

.home-art {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.home-art .art,
.stage .art {
  display: block;
  width: 100%;
  height: 100%;
}

.home-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 75% at 50% 38%, transparent 48%, rgba(2, 7, 10, .5) 100%),
    linear-gradient(180deg, rgba(3, 8, 13, .36) 0%, transparent 22%, transparent 46%, rgba(4, 8, 10, .76) 75%, #050a0d 100%);
}

.home-ui {
  position: relative;
  z-index: 5;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 20px calc(22px + env(safe-area-inset-bottom));
}

.home-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.night-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  background: rgba(9, 16, 20, .46);
  border: 1px solid rgba(255, 214, 170, .18);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-size: 11px;
  letter-spacing: .14em;
  color: #ffe4c2;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}

.chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(255, 138, 61, .16), 0 0 10px rgba(255, 138, 61, .7);
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ffe2be;
  background: rgba(9, 16, 20, .46);
  border: 1px solid rgba(255, 214, 170, .18);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .22);
  transition: transform .16s ease, background .16s ease;
}

.icon-btn .mp-icon { width: 20px; height: 20px; }

.icon-btn:active {
  transform: scale(.92);
  background: rgba(255, 138, 61, .24);
}

.home-copy {
  padding-bottom: 2px;
}

.kicker {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 9px;
  line-height: 1;
  letter-spacing: .34em;
  color: #ffc08a;
  text-transform: uppercase;
  text-shadow: 0 0 16px rgba(255, 138, 61, .45);
}

.home-title {
  margin: 14px 0 0;
  font-family: "Songti SC", "Noto Serif SC", "STSong", "SimSun", Georgia, serif;
  font-size: clamp(42px, 12.4vw, 56px);
  line-height: 1.04;
  font-weight: 700;
  letter-spacing: .055em;
  color: #fdf0dc;
  text-shadow: 0 4px 30px rgba(0, 0, 0, .7), 0 0 40px rgba(255, 138, 61, .16);
}

.home-title span {
  color: #ffd0a0;
  position: relative;
}

.home-title span::after {
  content: "";
  position: absolute;
  left: .06em;
  right: .06em;
  bottom: .04em;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(255, 138, 61, .9), rgba(255, 138, 61, 0));
  transform: scaleX(.28);
  transform-origin: left;
  animation: titleLine 1.3s .45s cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes titleLine {
  to { transform: scaleX(1); }
}

.home-sub {
  margin: 16px 0 24px;
  max-width: 310px;
  font-size: 13.5px;
  line-height: 1.9;
  color: #cdbbaa;
  letter-spacing: .03em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .55);
}

.enter-btn {
  width: 100%;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: 18px;
  background: linear-gradient(135deg, #ffad63 0%, #ff8a3d 48%, #f5762b 100%);
  color: #2b1406;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .14em;
  border: 1px solid rgba(255, 224, 190, .5);
  box-shadow: 0 14px 30px rgba(214, 97, 30, .35), inset 0 1px 0 rgba(255, 255, 255, .4);
  position: relative;
  overflow: hidden;
  transition: transform .16s ease, box-shadow .16s ease;
}

.enter-btn::after {
  content: "";
  position: absolute;
  top: -60%;
  left: -30%;
  width: 40%;
  height: 220%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .34), transparent);
  transform: rotate(18deg);
  animation: btnShine 4.3s 2s ease-in-out infinite;
}

@keyframes btnShine {
  0%, 72% { left: -40%; }
  88%, 100% { left: 140%; }
}

.enter-btn:active {
  transform: translateY(2px) scale(.99);
  box-shadow: 0 6px 16px rgba(214, 97, 30, .3), inset 0 1px 0 rgba(255, 255, 255, .3);
}

.enter-btn .mp-icon { width: 20px; height: 20px; opacity: .8; }

.home-foot {
  margin-top: 13px;
  text-align: center;
  font-size: 10px;
  letter-spacing: .18em;
  color: #a99480;
}

/* 雨 */
.rain {
  position: absolute;
  inset: -18% -12%;
  pointer-events: none;
  will-change: transform;
  opacity: .55;
  background-repeat: repeat;
}

.rain-a {
  background-image: repeating-linear-gradient(103deg, transparent 0 21px, rgba(190, 220, 255, .17) 21px 22px, transparent 22px 47px);
  animation: rainFall 1.15s linear infinite;
}

.rain-b {
  background-image: repeating-linear-gradient(99deg, transparent 0 38px, rgba(255, 255, 255, .08) 38px 39px, transparent 39px 76px);
  opacity: .35;
  animation: rainFall 1.75s linear infinite;
}

@keyframes rainFall {
  from { transform: translate3d(0, -7%, 0); }
  to { transform: translate3d(-2.4%, 7%, 0); }
}

.lightning {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: #d7e9ff;
  opacity: 0;
  mix-blend-mode: screen;
  animation: lightning 12s 3s infinite;
}

@keyframes lightning {
  0%, 88.4%, 89.6%, 100% { opacity: 0; }
  89% { opacity: .16; }
  89.2% { opacity: 0; }
  89.45% { opacity: .1; }
}

/* ============================================================
   店内 · 场景
   ============================================================ */
.game {
  flex-direction: column;
  min-height: 100dvh;
  background: #0b1514;
  overflow-x: hidden;
}

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 390 / 450;
  flex: 0 0 auto;
  overflow: hidden;
  background: #0d1a17;
}

.stage-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(115% 80% at 50% 42%, transparent 55%, rgba(2, 6, 6, .42) 100%),
    linear-gradient(180deg, rgba(3, 8, 8, .34) 0%, transparent 16%, transparent 78%, rgba(3, 8, 8, .34) 100%);
}

.stage-top {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.stage-top > * { pointer-events: auto; }

.stage-top-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.time-chip {
  height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 999px;
  font-family: Georgia, serif;
  font-size: 11px;
  letter-spacing: .16em;
  color: #ffe2be;
  background: rgba(9, 16, 20, .44);
  border: 1px solid rgba(255, 214, 170, .16);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* 场景里的点击点 */
.hotspots { position: absolute; inset: 0; z-index: 4; }

.hotspot {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  border-radius: 50%;
}

.hotspot::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 50%;
  border: 1px solid rgba(255, 176, 102, .62);
  animation: hotspotPulse 2.9s var(--d, 0s) ease-out infinite;
}

@keyframes hotspotPulse {
  0% { transform: scale(.82); opacity: .85; }
  65% { transform: scale(1.6); opacity: 0; }
  100% { transform: scale(1.6); opacity: 0; }
}

.hotspot-dot {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ffd6a3;
  background: radial-gradient(circle at 35% 28%, rgba(255, 190, 120, .34), rgba(24, 14, 9, .8) 72%);
  border: 1px solid rgba(255, 190, 130, .62);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .45), inset 0 0 12px rgba(255, 140, 60, .16);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: transform .16s ease, background .2s ease;
}

.hotspot-dot .mp-icon { width: 18px; height: 18px; }

.hotspot-label {
  position: absolute;
  top: 43px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: .08em;
  color: #ffe7c8;
  background: rgba(10, 14, 13, .58);
  border: 1px solid rgba(255, 210, 160, .16);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.hotspot-check {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 16px;
  height: 16px;
  display: none;
  place-items: center;
  border-radius: 50%;
  color: #2a1306;
  background: #ffd9a8;
  border: 1px solid #b96a2f;
}

.hotspot-check .mp-icon { width: 11px; height: 11px; }

.hotspot:active .hotspot-dot { transform: scale(.9); }

.hotspot.is-found .hotspot-dot {
  background: linear-gradient(145deg, #ffb066, #ff8a3d);
  color: #341806;
  border-color: #ffd0a0;
  box-shadow: 0 4px 16px rgba(255, 130, 50, .45);
}

.hotspot.is-found::before { display: none; }
.hotspot.is-found .hotspot-check { display: grid; }
.hotspot.is-found .hotspot-label { color: #ffd9a8; }

.hotspot.is-hint::before {
  border-color: #ffe0a8;
  animation-duration: 1.1s;
}

/* ============================================================
   HUD
   ============================================================ */
.hud {
  position: relative;
  z-index: 5;
  flex: 1 0 auto;
  min-height: 312px;
  margin-top: -26px;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-radius: 28px 28px 0 0;
  color: var(--ink);
  background-image:
    radial-gradient(rgba(120, 80, 40, .05) 1px, transparent 1px),
    linear-gradient(180deg, #fcf3e4 0%, #f5e5ca 100%);
  background-size: 14px 14px, 100% 100%;
  box-shadow: 0 -20px 42px rgba(0, 0, 0, .34), inset 0 1px 0 #fffaf0;
}

.hud::before {
  content: "";
  position: absolute;
  top: 0;
  left: 18%;
  right: 18%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .9), transparent);
}

.hud-grip {
  width: 42px;
  height: 4px;
  margin: 0 auto 2px;
  border-radius: 999px;
  background: #d8c2a2;
  flex: 0 0 auto;
}

.hud-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 9px;
  line-height: 1.4;
  letter-spacing: .24em;
  color: #b27a4b;
  text-transform: uppercase;
}

.hud h2 {
  margin-top: 5px;
  font-family: "Songti SC", "Noto Serif SC", "STSong", "SimSun", Georgia, serif;
  font-size: 24px;
  line-height: 1.28;
  font-weight: 700;
  letter-spacing: .02em;
  color: #2b1a10;
}

.seal {
  position: relative;
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #3c1c08;
  background: radial-gradient(circle at 35% 28%, #ffcb87, #dd8537 55%, #9a4a1b);
  border: 2px solid #f7e1bd;
  box-shadow: 0 0 0 4px rgba(217, 119, 47, .16), 0 10px 20px rgba(90, 50, 20, .24);
  transform: rotate(-6deg);
}

.seal::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 1px dashed rgba(70, 30, 8, .45);
}

.seal .mp-icon { width: 22px; height: 22px; }

.hud-copy {
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--ink-soft);
}

.progress-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
  font-size: 10.5px;
  letter-spacing: .1em;
  color: #94795d;
}

.progress-top strong {
  font-family: Georgia, serif;
  font-size: 12px;
  letter-spacing: .06em;
  color: #b75c1e;
}

.clue-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.clue-token {
  position: relative;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 14px;
  background: #fffaf0;
  border: 1px solid #e2ccad;
  box-shadow: 0 2px 0 #d8bf9c, inset 0 1px 0 #fff;
  color: #bda487;
  transition: transform .16s ease, background .2s ease, box-shadow .2s ease;
}

.clue-token .mp-icon { width: 19px; height: 19px; }

.clue-token .token-q {
  font-family: Georgia, serif;
  font-size: 16px;
  color: #c9b393;
}

.clue-token.is-found {
  background: linear-gradient(160deg, #352218, #24150f);
  border-color: #4d2e1c;
  box-shadow: 0 2px 0 #1b0f09, inset 0 1px 0 rgba(255, 200, 140, .2);
  color: #ffcf95;
}

.clue-token.is-found .token-eq {
  font-size: 11px;
  color: #a87b53;
}

.clue-token.is-found b {
  font-family: Georgia, serif;
  font-size: 19px;
  line-height: 1;
  color: #ffb066;
}

.clue-token:active { transform: translateY(1px) scale(.97); }

.clue-token.is-new { animation: tokenPop .55s cubic-bezier(.2, 1.6, .4, 1); }

@keyframes tokenPop {
  0% { transform: scale(.72); }
  55% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.hud-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hud-note {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 10.5px;
  line-height: 1.55;
  color: #987d62;
}

.hud-note .mp-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  margin-top: 1px;
  color: #c98c4f;
}

.open-btn {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 13px;
  border-radius: 18px;
  background: linear-gradient(135deg, #ffa45b 0%, #ff8a3d 50%, #f3762a 100%);
  color: #2b1406;
  border: 1px solid #e9762b;
  box-shadow: 0 10px 20px rgba(220, 105, 35, .28), inset 0 1px 0 rgba(255, 230, 200, .55);
  text-align: left;
  transition: transform .16s ease, box-shadow .16s ease;
}

.open-btn:active {
  transform: translateY(2px);
  box-shadow: 0 4px 10px rgba(220, 105, 35, .24), inset 0 1px 0 rgba(255, 230, 200, .4);
}

.open-btn-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #3a1a06;
  background: rgba(255, 250, 240, .34);
  border: 1px solid rgba(255, 255, 255, .32);
}

.open-btn-icon .mp-icon { width: 20px; height: 20px; }

.open-btn-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.2;
}

.open-btn-text strong { font-size: 16px; letter-spacing: .08em; }
.open-btn-text small { font-size: 9.5px; letter-spacing: .04em; opacity: .68; }
.open-btn-arrow { width: 20px; height: 20px; opacity: .65; }

/* ============================================================
   遮罩与卡片
   ============================================================ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity .28s ease, visibility .28s;
}

.overlay.is-open { opacity: 1; visibility: visible; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 9, 10, .68);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.sheet-close {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #6f4e32;
  background: rgba(70, 42, 22, .08);
  border: 1px solid rgba(90, 55, 28, .12);
  transition: transform .15s ease, background .15s ease;
}

.sheet-close .mp-icon { width: 18px; height: 18px; }
.sheet-close:active { transform: scale(.9); background: rgba(70, 42, 22, .14); }

.primary-btn {
  width: 100%;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: linear-gradient(135deg, #ffa45b, #ff7f2e);
  color: #2b1406;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .12em;
  border: 1px solid #e9762b;
  box-shadow: 0 8px 18px rgba(210, 96, 30, .25), inset 0 1px 0 rgba(255, 235, 210, .55);
  transition: transform .15s ease, box-shadow .15s ease;
}

.primary-btn:active {
  transform: translateY(2px);
  box-shadow: 0 3px 9px rgba(210, 96, 30, .22);
}

/* 线索卡 */
.clue-sheet {
  position: relative;
  width: min(338px, calc(100% - 40px));
  margin: auto;
  padding: 30px 22px 20px;
  border-radius: 26px;
  text-align: center;
  color: var(--ink);
  background: linear-gradient(180deg, #fff9ed 0%, #f4e2c5 100%);
  box-shadow: 0 30px 70px rgba(0, 0, 0, .55), inset 0 1px 0 #fff;
  transform: translateY(18px) scale(.96);
  transition: transform .34s cubic-bezier(.2, .85, .25, 1);
  max-height: 90dvh;
  overflow-y: auto;
}

.overlay.is-open .clue-sheet { transform: translateY(0) scale(1); }

.clue-sheet .sheet-close {
  position: absolute;
  top: 14px;
  right: 14px;
}

.clue-emblem {
  position: relative;
  width: 86px;
  height: 86px;
  margin: 4px auto 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ffcf95;
  background: radial-gradient(circle at 35% 26%, #3d2618, #1d0f08 72%);
  border: 1px solid #6b4226;
  box-shadow: 0 0 0 8px rgba(255, 138, 61, .08), 0 14px 26px rgba(70, 35, 15, .25);
}

.clue-emblem .mp-icon { width: 38px; height: 38px; }

.clue-emblem::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 1px dashed rgba(255, 190, 120, .38);
  animation: spin 20s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.clue-sheet h3 {
  margin: 5px 0 0;
  font-family: "Songti SC", "Noto Serif SC", "STSong", "SimSun", Georgia, serif;
  font-size: 24px;
  letter-spacing: .04em;
  color: #2b1a10;
}

.clue-text {
  margin: 12px auto 0;
  max-width: 262px;
  font-size: 13px;
  line-height: 1.9;
  color: #6f573f;
}

.clue-formula {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 20px;
  padding: 7px 20px;
  border-radius: 999px;
  color: #ffd7a5;
  background: #2a1911;
  border: 1px solid #4d2e1b;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, .35);
}

.clue-formula .mp-icon { width: 22px; height: 22px; color: #ffb066; }
.clue-formula .eq { font-family: Georgia, serif; font-size: 14px; color: #a87b53; }
.clue-formula strong { font-family: Georgia, serif; font-size: 24px; line-height: 1; color: #ffb066; }

/* 密码板 */
.lock-sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 94dvh;
  overflow-y: auto;
  padding: 10px 20px calc(18px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0;
  color: var(--ink);
  background-image:
    radial-gradient(rgba(120, 80, 40, .05) 1px, transparent 1px),
    linear-gradient(180deg, #fcf3e4 0%, #f2dfc2 100%);
  background-size: 14px 14px, 100% 100%;
  box-shadow: 0 -30px 70px rgba(0, 0, 0, .52), inset 0 1px 0 #fffaf0;
  transform: translateY(100%);
  transition: transform .36s cubic-bezier(.2, .85, .25, 1);
}

.overlay.is-open .lock-sheet { transform: translateY(0); }

.lock-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-top: 8px;
}

.lock-head h3 {
  margin-top: 4px;
  font-family: "Songti SC", "Noto Serif SC", "STSong", "SimSun", Georgia, serif;
  font-size: 26px;
  letter-spacing: .05em;
  color: #2b1a10;
}

.lock-copy {
  margin-top: 5px;
  font-size: 11.5px;
  line-height: 1.65;
  color: #8a6e53;
}

.lock-slots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  margin: 15px 0 16px;
}

.lock-slot {
  position: relative;
  height: 82px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 15px;
  color: #b58251;
  background: linear-gradient(180deg, #322017, #24130c);
  border: 1px solid #4b2c1b;
  box-shadow: inset 0 3px 9px rgba(0, 0, 0, .38), 0 2px 0 #fff8ec;
  overflow: hidden;
}

.lock-slot .mp-icon { width: 19px; height: 19px; opacity: .8; }

.lock-slot .slot-digit {
  font-family: Georgia, serif;
  font-size: 25px;
  line-height: 1;
  color: #6f4c2f;
  transition: color .15s ease, text-shadow .15s ease;
}

.lock-slot.is-filled {
  border-color: #ff9a50;
  box-shadow: 0 0 0 2px rgba(255, 138, 61, .16), inset 0 3px 9px rgba(0, 0, 0, .32);
}

.lock-slot.is-filled .slot-digit {
  color: #ffd9a8;
  text-shadow: 0 0 14px rgba(255, 160, 80, .55);
}

.lock-slot.is-error {
  border-color: #d54b3f;
  box-shadow: 0 0 0 2px rgba(213, 75, 63, .16), inset 0 3px 9px rgba(0, 0, 0, .32);
}

.lock-slots.is-error { animation: slotsShake .4s ease; }

@keyframes slotsShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.key {
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  color: #3a2618;
  background: linear-gradient(180deg, #fffaf0, #f4e6d1);
  border: 1px solid #dcc6a7;
  box-shadow: 0 3px 0 #cfb591, inset 0 1px 0 #fff;
  transition: transform .1s ease, box-shadow .1s ease, background .1s ease;
}

.key:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #cfb591;
  background: #fdeed8;
}

.key--clear {
  font-family: inherit;
  font-size: 12px;
  letter-spacing: .1em;
  color: #8a6a4d;
}

.key--del .mp-icon { width: 21px; height: 21px; color: #8a6a4d; }

.lock-tip {
  margin-top: 12px;
  text-align: center;
  font-size: 10px;
  letter-spacing: .14em;
  color: #a2896f;
}

/* 成功闪光 */
.lock-sheet.is-success::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(80% 60% at 50% 35%, rgba(255, 210, 150, .4), transparent 70%);
  animation: successFlash .9s ease-out both;
}

@keyframes successFlash {
  0% { opacity: 0; }
  30% { opacity: 1; }
  100% { opacity: 0; }
}

/* ============================================================
   结局
   ============================================================ */
#endOverlay {
  align-items: center;
  background: rgba(4, 8, 9, .76);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.ending {
  position: relative;
  width: min(342px, calc(100% - 38px));
  margin: auto;
  padding: calc(16px + env(safe-area-inset-top)) 0 calc(18px + env(safe-area-inset-bottom));
  text-align: center;
  transform: translateY(18px) scale(.97);
  transition: transform .4s cubic-bezier(.2, .85, .25, 1);
  max-height: 100dvh;
  overflow-y: auto;
}

.overlay.is-open .ending { transform: translateY(0) scale(1); }

.ending-kicker {
  margin-bottom: 14px;
  font-family: Georgia, serif;
  font-size: 9px;
  letter-spacing: .3em;
  color: #ffc08a;
  text-shadow: 0 0 18px rgba(255, 138, 61, .5);
}

.letter {
  position: relative;
  padding: 32px 24px 22px;
  text-align: left;
  color: #3a281a;
  background:
    radial-gradient(rgba(140, 95, 50, .05) 1px, transparent 1px),
    linear-gradient(160deg, #fdf4e1 0%, #f0dab9 100%);
  background-size: 12px 12px, 100% 100%;
  border: 1px solid #e8d2ae;
  border-radius: 6px 18px 8px 20px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, .55), inset 0 1px 0 #fffdf5;
  transform: rotate(-1.1deg);
}

.letter::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(140, 95, 50, .18);
  border-radius: 2px 12px 4px 14px;
  pointer-events: none;
}

.wax {
  position: absolute;
  top: -15px;
  right: 20px;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: "Songti SC", "STSong", serif;
  font-size: 18px;
  color: #ffe6c8;
  background: radial-gradient(circle at 35% 30%, #ff9a5a, #b23f22 72%);
  box-shadow: 0 7px 16px rgba(80, 20, 5, .4), inset 0 0 0 3px rgba(255, 180, 120, .22);
  transform: rotate(8deg);
}

.letter-to,
.letter p {
  position: relative;
  font-family: "Songti SC", "Noto Serif SC", "STSong", "SimSun", Georgia, serif;
  font-size: 14px;
  line-height: 1.95;
  color: #4a3422;
  letter-spacing: .02em;
}

.letter-to {
  margin-bottom: 12px;
  color: #3a281a;
  font-weight: 700;
}

.letter p + p { margin-top: 5px; }

.letter .sign {
  margin-top: 14px;
  text-align: right;
  color: #6b4a2e;
}

.letter-date {
  display: inline-block;
  margin-top: 12px;
  padding-top: 9px;
  border-top: 1px solid rgba(140, 95, 50, .25);
  font-size: 9px;
  letter-spacing: .28em;
  color: #9a7857;
}

.ending .primary-btn { margin-top: 18px; }

.ending-foot {
  margin-top: 12px;
  font-size: 10px;
  letter-spacing: .28em;
  color: #a89480;
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 90;
  max-width: calc(100% - 42px);
  padding: 10px 17px;
  border-radius: 999px;
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
  color: #ffe6c8;
  background: rgba(22, 14, 10, .94);
  border: 1px solid rgba(255, 180, 120, .25);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .44);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 18px);
  transition: opacity .24s ease, transform .24s ease, visibility .24s;
  pointer-events: none;
}

.toast.is-show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

/* ============================================================
   小屏适配
   ============================================================ */
@media (max-height: 730px) {
  .hud { min-height: 296px; gap: 10px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .hud h2 { font-size: 21px; }
  .hud-copy { font-size: 12px; line-height: 1.6; }
  .clue-token { height: 48px; }
  .open-btn { min-height: 54px; }
  .home-sub { margin: 12px 0 18px; font-size: 12.5px; }
  .home-title { font-size: clamp(38px, 11.6vw, 50px); }
  .key { height: 48px; }
  .lock-slot { height: 70px; }
  .lock-slots { margin: 11px 0 13px; }
}

@media (min-width: 481px) {
  .app { min-height: 100dvh; }
  .overlay .clue-sheet, .overlay .ending { margin: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .rain { display: none; }
}
