:root {
  --ink: #e8f1ff;
  --dim: rgba(232, 241, 255, .58);
  --dim2: rgba(232, 241, 255, .34);
  --warm: #ffb45e;
  --line: rgba(200, 224, 255, .16);
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --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; padding: 0;
  height: 100%;
  background: #05070d;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--serif);
  color: var(--ink);
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 12%, #16203a 0%, #0a0f1c 44%, #05070d 100%);
}

/* 桌面端：让画面像一间暗房里亮着的一扇窗 */
@media (min-aspect-ratio: 3/4) {
  #app::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(46% 62% at 50% 46%, rgba(110, 160, 220, .10), transparent 70%);
  }
}

#stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#scene {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, .045),
    0 0 60px rgba(110, 160, 220, .14),
    0 0 160px rgba(60, 100, 170, .10);
  background: #070a14;
}

/* ---------- 覆盖特效 ---------- */
.fx { position: absolute; inset: 0; pointer-events: none; }

.vignette {
  background:
    radial-gradient(120% 78% at 50% 44%, transparent 42%, rgba(2, 5, 12, .34) 76%, rgba(2, 5, 12, .62) 100%);
}

.grain {
  opacity: .06;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  top: calc(10px + var(--safe-t));
  right: 12px;
  z-index: 30;
  display: flex;
  gap: 8px;
}

.pill {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(10, 16, 30, .45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--dim);
  font-size: 14px;
  font-family: var(--serif);
  cursor: pointer;
  transition: color .25s, border-color .25s, background .25s;
}
.pill[aria-pressed="true"] {
  color: var(--warm);
  border-color: rgba(255, 180, 94, .45);
  background: rgba(60, 38, 14, .38);
  box-shadow: 0 0 24px -8px rgba(255, 180, 94, .6);
}
.pill:active { transform: scale(.94); }

/* ---------- 字幕 ---------- */
.subtitle {
  position: absolute;
  left: 50%;
  bottom: calc(30px + var(--safe-b));
  transform: translate(-50%, 8px);
  z-index: 20;
  max-width: 82vw;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 14px;
  letter-spacing: .05em;
  line-height: 1.5;
  text-align: center;
  color: rgba(240, 247, 255, .94);
  background: rgba(8, 13, 24, .52);
  border: 1px solid rgba(200, 224, 255, .10);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .45s ease, transform .45s cubic-bezier(.2, .8, .3, 1);
}
.subtitle.show { opacity: 1; transform: translate(-50%, 0); }

.hint {
  position: absolute;
  left: 50%;
  bottom: calc(96px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 15;
  font-size: 11px;
  letter-spacing: .34em;
  color: var(--dim2);
  white-space: nowrap;
  animation: hintFloat 2.6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes hintFloat {
  0%, 100% { opacity: .28; transform: translate(-50%, 0); }
  50% { opacity: .62; transform: translate(-50%, -3px); }
}

.cta {
  position: absolute;
  left: 50%;
  bottom: calc(26px + var(--safe-b));
  transform: translateX(-50%) translateY(10px);
  z-index: 25;
  padding: 12px 30px;
  border-radius: 999px;
  border: 1px solid rgba(255, 190, 120, .5);
  background: linear-gradient(180deg, rgba(255, 200, 130, .16), rgba(255, 150, 70, .06));
  color: #ffd9a8;
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: .22em;
  box-shadow: 0 0 34px -10px rgba(255, 170, 90, .75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  cursor: pointer;
  transition: opacity .6s ease, transform .6s cubic-bezier(.2, .8, .3, 1);
}
.cta.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.cta:active { transform: translateX(-50%) scale(.96); }

/* ---------- 开场 ---------- */
.intro {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(130% 90% at 50% 42%, rgba(6, 10, 20, .56) 0%, rgba(6, 10, 20, .86) 52%, rgba(4, 7, 14, .97) 100%);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  transition: opacity .85s ease, transform .85s cubic-bezier(.4, 0, .2, 1), filter .85s ease;
}
.intro.is-out {
  opacity: 0;
  transform: scale(1.045);
  filter: blur(7px);
  pointer-events: none;
}

.intro-card {
  width: min(320px, 88vw);
  text-align: center;
  animation: introIn 1.4s cubic-bezier(.2, .8, .3, 1) both;
}
@keyframes introIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.eyebrow {
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: .46em;
  text-indent: .46em;
  color: var(--dim2);
  margin-bottom: 20px;
}

.title {
  margin: 0;
  font-size: clamp(42px, 12.5vw, 62px);
  font-weight: 400;
  letter-spacing: .22em;
  text-indent: .22em;
  line-height: 1.1;
  color: #f2f7ff;
  text-shadow: 0 0 46px rgba(170, 210, 255, .28), 0 2px 0 rgba(0, 0, 0, .25);
}

.byline {
  margin-top: 12px;
  font-size: 12px;
  font-style: italic;
  letter-spacing: .18em;
  color: rgba(215, 232, 255, .62);
}

.rule {
  width: 44px;
  height: 1px;
  margin: 30px auto 28px;
  background: linear-gradient(90deg, transparent, rgba(210, 232, 255, .4), transparent);
}

.label {
  display: block;
  font-size: 11px;
  letter-spacing: .34em;
  text-indent: .34em;
  color: var(--dim2);
  margin-bottom: 6px;
}

#enter-form { display: block; }

#name-input {
  display: block;
  width: 100%;
  margin: 0 auto;
  padding: 12px 4px 11px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(200, 224, 255, .26);
  border-radius: 0;
  outline: none;
  color: #fff;
  font-family: var(--serif);
  font-size: 18px; /* 16px 以上，避免 iOS 自动放大 */
  letter-spacing: .14em;
  text-align: center;
  text-indent: .14em;
  transition: border-color .35s ease, box-shadow .35s ease;
  appearance: none;
  -webkit-appearance: none;
}
#name-input::placeholder {
  color: rgba(200, 224, 255, .22);
  letter-spacing: .2em;
}
#name-input:focus {
  border-bottom-color: rgba(255, 190, 120, .75);
  box-shadow: 0 14px 26px -22px rgba(255, 180, 94, .9);
}

.enter {
  display: block;
  margin: 26px auto 0;
  padding: 12px 40px;
  border-radius: 999px;
  border: 1px solid rgba(205, 228, 255, .22);
  background: linear-gradient(180deg, rgba(255, 255, 255, .10), rgba(255, 255, 255, .02));
  color: rgba(240, 247, 255, .92);
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: .34em;
  text-indent: .34em;
  cursor: pointer;
  transition: border-color .3s, background .3s, transform .15s;
}
.enter:hover { border-color: rgba(255, 190, 120, .5); background: rgba(255, 180, 94, .08); }
.enter:active { transform: scale(.97); }

.footnote {
  margin: 26px 0 0;
  font-size: 10px;
  letter-spacing: .16em;
  color: rgba(200, 224, 255, .26);
}

@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  45% { transform: translateX(5px); }
  70% { transform: translateX(-3px); }
}
.shake { animation: shakeX .42s ease; }

/* ---------- 弹层 ---------- */
.sheet {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(3, 6, 13, .62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fadeIn .35s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.sheet[hidden] { display: none; }

.sheet-card {
  width: min(340px, 90vw);
  max-height: 86vh;
  overflow-y: auto;
  padding: 26px 22px 22px;
  border-radius: 20px;
  border: 1px solid rgba(200, 224, 255, .12);
  background:
    radial-gradient(120% 80% at 50% 0%, #17203a 0%, #101728 46%, #0a0f1c 100%);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .9), inset 0 1px 0 rgba(255, 255, 255, .06);
  animation: sheetIn .45s cubic-bezier(.2, .8, .3, 1) both;
}
@keyframes sheetIn {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.sheet-title {
  font-size: 15px;
  letter-spacing: .16em;
  color: #f4f8ff;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(200, 224, 255, .10);
}

.sheet-body {
  font-size: 14px;
  line-height: 2.05;
  letter-spacing: .04em;
  color: rgba(226, 238, 255, .82);
  white-space: pre-wrap;
  word-break: break-word;
}
.sheet-body em { color: var(--warm); font-style: normal; }
.sheet-body .sig {
  display: block;
  margin-top: 14px;
  text-align: right;
  font-size: 12px;
  font-style: italic;
  color: rgba(255, 190, 120, .78);
  letter-spacing: .1em;
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}
.sheet-actions button {
  flex: 1;
  padding: 12px 8px;
  border-radius: 12px;
  border: 1px solid rgba(200, 224, 255, .16);
  background: rgba(255, 255, 255, .045);
  color: rgba(226, 238, 255, .9);
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: .1em;
  cursor: pointer;
  transition: background .25s, border-color .25s;
}
.sheet-actions button:hover { background: rgba(255, 255, 255, .08); }
.sheet-actions button.primary {
  border: 0;
  background: linear-gradient(180deg, #ffc97f, #ff9d52);
  color: #2a1707;
  font-weight: 600;
  box-shadow: 0 14px 30px -14px rgba(255, 160, 80, .9);
}
.sheet-actions button.primary:active { transform: scale(.98); }

.sheet-img {
  display: block;
  width: 100%;
  border-radius: 8px;
  margin-bottom: 16px;
  box-shadow: 0 18px 40px -22px rgba(0, 0, 0, .9);
}

@media (prefers-reduced-motion: reduce) {
  .intro-card, .sheet-card { animation: none; }
  .hint { animation: none; opacity: .4; }
  .intro, .subtitle, .cta { transition-duration: .01ms; }
}
/* ---------- 进入后移除遮罩、工坊名片与细节 ---------- */
.intro[hidden] { display: none; }

#stage { cursor: grab; }
#stage:active { cursor: grabbing; }

.sheet-body p { margin: 0 0 14px; }
.sheet-body p:last-of-type { margin-bottom: 0; }

.maker-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 2px 0 20px;
  padding: 12px;
  border: 1px solid rgba(204, 226, 246, .12);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255, 190, 116, .09), rgba(255, 255, 255, .025));
}

.maker-crest {
  width: 42px;
  height: 42px;
  image-rendering: pixelated;
  border-radius: 5px;
  box-shadow: 0 0 20px -6px rgba(255, 188, 108, .55);
}

.maker-name {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .28em;
  color: #ffd39a;
}

.maker-sub {
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: .12em;
  color: rgba(218, 234, 248, .40);
}

button:focus-visible,
.enter:focus-visible {
  outline: 1px solid rgba(255, 197, 129, .85);
  outline-offset: 3px;
}
