@font-face {
  font-family: 'Great Vibes';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/greatvibes/great-vibes-latin-400-normal.woff2') format('woff2');
}

:root {
  --accent: #ff9cc9;
  --ink: #fff3f8;
  --muted: rgba(255, 232, 243, 0.62);
  --faint: rgba(255, 232, 243, 0.38);
  --glass: rgba(26, 10, 22, 0.46);
  --line: rgba(255, 200, 226, 0.16);
  --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%; overflow: hidden; background: #050307; }
body {
  color: var(--ink);
  font-family: 'LXGW WenKai', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}
#gl { position: fixed; top: 0; right: 0; bottom: 0; left: 0; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#gl:active { cursor: grabbing; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 1.5px solid var(--accent); outline-offset: 3px; }

.script {
  font-family: 'Great Vibes', 'Snell Roundhand', 'Brush Script MT', cursive;
  font-weight: 400;
  color: #fff4f9;
  text-shadow: 0 0 4px rgba(255, 210, 230, 0.9), 0 0 18px rgba(255, 140, 195, 0.7), 0 0 46px rgba(255, 120, 180, 0.35);
  text-shadow: 0 0 4px rgba(255, 210, 230, 0.9), 0 0 18px rgba(255, 156, 201, 0.75), 0 0 46px rgba(255, 156, 201, 0.40); text-shadow: 0 0 4px rgba(255, 210, 230, 0.9), 0 0 18px color-mix(in srgb, var(--accent) 75%, transparent), 0 0 46px color-mix(in srgb, var(--accent) 40%, transparent);
  margin: 0;
  letter-spacing: 0.005em;
}

/* ---------- 开场 ---------- */
#intro {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  background: radial-gradient(120% 80% at 50% 46%, rgba(64, 16, 50, 0.5) 0%, rgba(14, 5, 13, 0.82) 55%, rgba(5, 3, 7, 0.96) 100%);
  transition: opacity 1.3s ease, visibility 1.3s;
  padding: 24px;
}
#intro.hide { opacity: 0; visibility: hidden; pointer-events: none; }
#intro h1 { font-size: 11vw; font-size: clamp(58px, 11vw, 136px); line-height: 1.1; padding: 0 0.15em; }
.title-reveal { animation: write 3.2s cubic-bezier(.6,.05,.3,1) .2s both, breathe 5s ease-in-out 3.4s infinite alternate; }
@keyframes write { from { clip-path: inset(-20% 100% -20% 0); } to { clip-path: inset(-20% -5% -20% 0); } }
@keyframes breathe { from { filter: brightness(1); } to { filter: brightness(1.18); } }
.intro-sub {
  margin: 18px 0 40px; font-size: 15px; letter-spacing: 0.32em; color: var(--muted);
  animation: fade 1.6s ease 2.2s both;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.btn-light {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 13px 38px; border-radius: 999px;
  border: 1px solid rgba(255, 170, 210, 0.5);
  border: 1px solid rgba(255, 156, 201, 0.55); border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02));
  color: #fff; font-size: 16px; letter-spacing: 0.38em; text-indent: 0.38em; text-decoration: none;
  box-shadow: 0 0 26px rgba(255, 156, 201, 0.28), inset 0 0 14px rgba(255, 200, 230, 0.1); box-shadow: 0 0 26px color-mix(in srgb, var(--accent) 28%, transparent), inset 0 0 14px rgba(255, 200, 230, 0.1);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: box-shadow .4s, transform .4s, background .4s;
}
.btn-light:hover { box-shadow: 0 0 40px rgba(255, 156, 201, 0.50), inset 0 0 18px rgba(255, 200, 230, 0.2); box-shadow: 0 0 40px color-mix(in srgb, var(--accent) 50%, transparent), inset 0 0 18px rgba(255, 200, 230, 0.2); transform: translateY(-1px); }
.btn-light:active { transform: scale(0.98); }
.btn-light.small { padding: 10px 24px; font-size: 14px; letter-spacing: 0.2em; text-indent: 0.2em; }
#startBtn { animation: fade 1.4s ease 2.8s both; }
.btn-ghost {
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font-size: 14px; letter-spacing: 0.12em;
  transition: color .3s, border-color .3s;
}
.btn-ghost:hover { color: #fff; border-color: rgba(255, 156, 201, 0.50); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }

.cam-opt {
  margin-top: 22px; display: inline-flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--muted); letter-spacing: 0.1em; cursor: pointer;
  animation: fade 1.4s ease 3.1s both;
}
.cam-opt input { position: absolute; opacity: 0; pointer-events: none; }
.cam-opt i {
  width: 30px; height: 17px; border-radius: 9px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06); position: relative; transition: background .3s, border-color .3s;
}
.cam-opt i::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 11px; height: 11px; border-radius: 50%;
  background: rgba(255, 235, 245, 0.7); transition: transform .3s, background .3s;
}
.cam-opt input:checked + i { background: rgba(255, 156, 201, 0.35); background: color-mix(in srgb, var(--accent) 35%, transparent); border-color: rgba(255, 156, 201, 0.60); border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.cam-opt input:checked + i::after { transform: translateX(13px); background: #fff; box-shadow: 0 0 8px var(--accent); }
.cam-opt input:focus-visible + i { outline: 1.5px solid var(--accent); outline-offset: 3px; }
.intro-foot {
  position: absolute; bottom: calc(26px + 0px); bottom: calc(26px + env(safe-area-inset-bottom, 0px)); left: 0; right: 0;
  margin: 0; font-size: 12px; letter-spacing: 0.3em; color: var(--faint);
  animation: fade 1.4s ease 3.4s both;
}

/* ---------- 信 ---------- */
#letter {
  position: fixed; z-index: 5; right: 7vw; top: 13vh; width: 36vw; width: min(440px, 36vw);
  pointer-events: none; opacity: 0;
}
#letter h2 { font-size: 4.8vw; font-size: clamp(44px, 4.8vw, 78px); line-height: 1.15; }
.letter-sub { margin: 6px 0 0 0.4em; font-size: 12px; letter-spacing: 0.42em; color: var(--muted); }
#letterBody { margin-top: 4.2vh; font-size: 1.75vw; font-size: clamp(18px, 1.75vw, 27px); line-height: 2.05; letter-spacing: 0.2em; color: #fff0f6; }
#letterBody .ln { min-height: 1em; white-space: nowrap; }
#letterBody .to { margin-bottom: 0.2em; }
#letterBody .sign { text-align: right; margin-top: 1.1em; font-size: 0.86em; color: var(--muted); }
#letterBody .date { text-align: right; font-size: 0.7em; letter-spacing: 0.16em; color: var(--faint); line-height: 1.6; }
.ch { display: inline-block; opacity: 0; }
.ch.on { text-shadow: 0 0 8px rgba(255, 150, 200, 0.45); text-shadow: 0 0 8px rgba(255, 156, 201, 0.45); text-shadow: 0 0 8px color-mix(in srgb, var(--accent) 45%, transparent); }
#pen {
  position: fixed; left: 0; top: 0; z-index: 6; width: 0; height: 0; pointer-events: none; opacity: 0;
  transition: transform .14s linear, opacity .5s;
}
#pen::before, #pen::after {
  content: ''; position: absolute; left: -11px; top: -1px; width: 22px; height: 2px; border-radius: 2px;
  background: radial-gradient(closest-side, #fff, transparent);
}
#pen::after { transform: rotate(90deg); }
#pen.on { opacity: 1; filter: drop-shadow(0 0 6px #fff) drop-shadow(0 0 12px var(--accent)); }

/* ---------- 工具栏 ---------- */
#toolbar {
  position: fixed; z-index: 8; left: 50%; bottom: calc(18px + 0px); bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  display: flex; gap: 2px; padding: 6px 8px; border-radius: 22px;
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2);
  transition: opacity 1s ease, transform 1s ease;
  max-width: calc(100vw - 20px); overflow-x: auto; scrollbar-width: none;
}
#toolbar::-webkit-scrollbar { display: none; }
body.ui-on #toolbar { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toolbar button {
  flex: 0 0 auto; width: 58px; padding: 7px 0 5px; border: 0; border-radius: 14px; background: transparent;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: rgba(255, 232, 243, 0.66); transition: color .3s, background .3s;
}
#toolbar button:hover { color: #fff; background: rgba(255, 255, 255, 0.05); }
#toolbar button.on { color: var(--accent); }
#toolbar svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; transition: filter .3s; }
#toolbar button:hover svg, #toolbar button.on svg { filter: drop-shadow(0 0 5px currentColor); }
#toolbar .lbl { font-size: 11px; letter-spacing: 0.08em; white-space: nowrap; }

#hint {
  position: fixed; z-index: 7; left: 0; right: 0; bottom: calc(92px + 0px); bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  text-align: center; font-size: 12px; letter-spacing: 0.2em; color: var(--faint);
  opacity: 0; transition: opacity 1.4s ease 1s; pointer-events: none;
}
body.ui-on #hint { opacity: 1; animation: hintOut 1s ease 12s forwards; }
@keyframes hintOut { to { opacity: 0; } }

/* ---------- 摄像头 ---------- */
#cam {
  position: fixed; z-index: 9; left: 22px; bottom: calc(100px + 0px); bottom: calc(100px + env(safe-area-inset-bottom, 0px)); width: 176px;
  opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .6s, transform .6s;
}
#cam.show { opacity: 1; transform: none; pointer-events: auto; }
.cam-view {
  position: relative; aspect-ratio: 4 / 3; border-radius: 16px; overflow: hidden;
  border: 1px solid rgba(255, 156, 201, 0.40); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  box-shadow: 0 0 24px rgba(255, 156, 201, 0.22); box-shadow: 0 0 24px color-mix(in srgb, var(--accent) 22%, transparent);
  background: rgba(10, 4, 10, 0.6);
}
.cam-view video { position: absolute; top: 0; right: 0; bottom: 0; left: 0; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); opacity: 0.5; filter: saturate(0.5) brightness(0.9); }
.cam-view canvas { position: absolute; top: 0; right: 0; bottom: 0; left: 0; inset: 0; width: 100%; height: 100%; }
.cam-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--muted); }
#camStatus { overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.06em; }
#camGuideBtn { flex: 0 0 auto; border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 999px; padding: 3px 9px; font-size: 11px; }
#gbadge {
  position: fixed; z-index: 9; left: 50%; top: calc(7vh + 0px); top: calc(7vh + env(safe-area-inset-top, 0px)); transform: translate(-50%, -8px);
  padding: 8px 20px; border-radius: 999px; background: var(--glass); border: 1px solid rgba(255, 156, 201, 0.45); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  font-size: 15px; letter-spacing: 0.3em; text-indent: 0.3em; color: #fff;
  box-shadow: 0 0 22px rgba(255, 156, 201, 0.30); box-shadow: 0 0 22px color-mix(in srgb, var(--accent) 30%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  opacity: 0; transition: opacity .35s, transform .35s; pointer-events: none;
}
#gbadge.show { opacity: 1; transform: translate(-50%, 0); }
#toast {
  position: fixed; z-index: 30; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(.96);
  padding: 10px 24px; border-radius: 999px; background: rgba(20, 8, 18, 0.62); border: 1px solid var(--line);
  font-size: 14px; letter-spacing: 0.2em; text-indent: 0.2em; color: #fff;
  max-width: 86vw; width: max-content; text-align: center; line-height: 1.6;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  opacity: 0; transition: opacity .35s, transform .35s; pointer-events: none;
}
#toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 18px;
  background: rgba(5, 2, 6, 0.5); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; visibility: hidden; transition: opacity .4s, visibility .4s;
  user-select: text; -webkit-user-select: text;
}
.modal.show { opacity: 1; visibility: visible; }
.card {
  position: relative; width: 100%; width: min(460px, 100%); max-height: calc(100vh - 36px); overflow: auto;
  padding: 28px 26px 24px; border-radius: 22px;
  background: linear-gradient(180deg, rgba(48, 18, 40, 0.86), rgba(22, 8, 20, 0.92));
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5), 0 0 40px rgba(255, 156, 201, 0.12); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5), 0 0 40px color-mix(in srgb, var(--accent) 12%, transparent);
  transform: translateY(10px); transition: transform .4s;
}
.modal.show .card { transform: none; }
.card h3 { margin: 0 0 6px; font-weight: 400; font-size: 20px; letter-spacing: 0.16em; }
.note { margin: 6px 0 16px; font-size: 13px; line-height: 1.7; color: var(--muted); letter-spacing: 0.04em; }
.gestures { list-style: none; margin: 18px 0 10px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.gestures li { display: flex; gap: 10px; align-items: flex-start; }
.gestures b { font-size: 22px; line-height: 1; width: 28px; text-align: center; font-weight: 400; }
.gestures strong { display: block; font-weight: 400; font-size: 14px; letter-spacing: 0.08em; color: #fff; }
.gestures span { display: block; margin-top: 2px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 6px; font-size: 12px; letter-spacing: 0.12em; color: var(--muted); }
.field input, .field textarea, .link {
  width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05); color: #fff; font-size: 15px; letter-spacing: 0.06em; outline: none; resize: none;
  transition: border-color .3s;
}
.field input:focus, .field textarea:focus { border-color: rgba(255, 156, 201, 0.60); border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 6px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 12px; }
.sw i { width: 16px; height: 16px; border-radius: 50%; background: conic-gradient(var(--a) 0 60%, var(--b) 60% 100%); box-shadow: 0 0 8px var(--a); }
.sw.on { color: #fff; border-color: rgba(255, 156, 201, 0.60); border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.link { margin: 4px 0 14px; font-size: 12px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.close { position: absolute; right: 14px; top: 12px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; }
.shot-card { width: 100%; width: min(720px, 100%); }
.shot-card img { width: 100%; border-radius: 12px; display: block; user-select: auto; -webkit-user-select: auto; -webkit-touch-callout: default; }

/* ---------- 竖屏 / 手机 ---------- */
@media (max-aspect-ratio: 23/20) {
  #letter { left: 50%; right: auto; top: calc(5vh + 0px); top: calc(5vh + env(safe-area-inset-top, 0px)); transform: translateX(-50%); width: 88vw; text-align: center; }
  #letter { top: calc(3.5vh + 0px); top: calc(3.5vh + env(safe-area-inset-top, 0px)); }
  #letter h2 { font-size: 10vw; font-size: clamp(36px, 10vw, 60px); }
  .letter-sub { margin-left: 0.42em; }
  #letterBody { margin-top: 1.2vh; font-size: 3.9vw; font-size: clamp(14px, 3.9vw, 19px); line-height: 1.72; letter-spacing: 0.14em; }
  #letterBody .sign, #letterBody .date { text-align: center; }
  #letterBody .sign { margin-top: 0.5em; }
  #cam { left: 12px; width: 112px; bottom: calc(96px + 0px); bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
  .cam-row { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 560px) {
  #toolbar { gap: 0; padding: 4px 6px; bottom: calc(12px + 0px); bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  #toolbar button { width: 46px; padding: 6px 0 4px; }
  #toolbar .lbl { font-size: 10px; letter-spacing: 0; }
  #hint { bottom: calc(80px + 0px); bottom: calc(80px + env(safe-area-inset-bottom, 0px)); font-size: 11px; letter-spacing: 0.1em; }
  .gestures { grid-template-columns: 1fr; gap: 10px; }
  .card { padding: 24px 20px 20px; }
  .intro-sub { letter-spacing: 0.2em; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .title-reveal { animation: none; }
}

/* ---------- 星尘之旅 ---------- */
.story-link {
  margin-top: 16px; padding: 6px 10px; border: 0; background: transparent;
  color: var(--muted); font-size: 13px; letter-spacing: 0.16em;
  text-decoration: underline; text-underline-offset: 5px; text-decoration-color: rgba(255, 200, 226, 0.35);
  animation: fade 1.4s ease 3s both;
}
.story-link:hover { color: #fff; }
#caption {
  position: fixed; z-index: 6; left: 50%; bottom: 9vh; transform: translate(-50%, 0);
  width: 90vw; text-align: center; pointer-events: none; opacity: 0;
  font-size: 22px; letter-spacing: 0.32em; text-indent: 0.32em; line-height: 1.6; color: #fff6ec;
  text-shadow: 0 0 6px rgba(255, 220, 170, 0.9), 0 0 22px rgba(255, 190, 120, 0.55), 0 0 48px rgba(255, 170, 110, 0.3);
}
#skipBtn {
  position: fixed; z-index: 9; right: 16px; top: 16px; top: calc(14px + 0px); top: calc(14px + env(safe-area-inset-top, 0px));
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: rgba(20, 8, 18, 0.35); color: var(--muted); font-size: 12px; letter-spacing: 0.2em;
  opacity: 0; pointer-events: none; transition: opacity .6s;
}
body.story-on #skipBtn { opacity: 1; pointer-events: auto; }
body.story-on #hint { display: none; }
.nojs {
  position: fixed; z-index: 50; left: 0; right: 0; bottom: 22%; text-align: center;
  color: #ffe9f3; font-size: 15px; line-height: 1.9; letter-spacing: 0.1em;
}
body.render #toolbar, body.render #hint, body.render #skipBtn, body.render #toast, body.render #gbadge, body.render #cam { display: none !important; }
body.render *, body.render *::before, body.render *::after { transition: none !important; animation: none !important; }
@media (max-aspect-ratio: 23/20) {
  #caption { bottom: 20vh; font-size: 19px; letter-spacing: 0.24em; text-indent: 0.24em; }
}
@media (max-width: 420px) {
  #toolbar button { width: 41px; }
}

.open-tip { margin: 22px 0 0; max-width: 86vw; font-size: 13px; line-height: 1.7; letter-spacing: 0.08em; color: #ffd9ea; }
.js .open-tip { display: none; }
