/* ============================================================
   人生故事会 · 视觉基调
   深夜蓝底 + 柔金细线 + 宋体标题。克制、安静，让卡牌本身成为主角。
   ============================================================ */
:root {
  --bg-0: #0b1526;          /* 最深底色 */
  --bg-1: #13223b;          /* 卡片/面板底色 */
  --ink: #eef2f8;           /* 主文字 */
  --ink-2: rgba(238, 242, 248, 0.62); /* 次文字 */
  --ink-3: rgba(238, 242, 248, 0.38); /* 弱提示 */
  --gold: #d8c39a;          /* 唯一强调色：柔金 */
  --gold-soft: rgba(216, 195, 154, 0.35);
  --sky: #9fd3f5;           /* 呼应卡牌的浅蓝，用于光晕 */
  --line: rgba(216, 195, 154, 0.22);

  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  --sans: -apple-system, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;

  --card-ratio: 1240 / 2209; /* 卡牌原图比例 */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out-back: cubic-bezier(0.34, 1.4, 0.64, 1);

  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; background: var(--bg-0); }
body {
  color: var(--ink);
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { display: block; max-width: 100%; -webkit-user-drag: none; }
[hidden] { display: none !important; }

/* ---------- 背景 ---------- */
.sky { position: fixed; inset: 0; z-index: 0; pointer-events: none;
  overflow: hidden;
  background: radial-gradient(120% 80% at 50% 0%, #1a2d4d 0%, var(--bg-0) 60%); }
.sky canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.halo { position: absolute; left: 50%; top: 42%; width: 140vw; height: 140vw; transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(159, 211, 245, 0.10) 0%, transparent 60%);
  animation: breathe 8s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.45; transform: translate(-50%, -50%) scale(1.08); } }

/* ---------- 视图切换 ---------- */
#app { position: relative; z-index: 1; height: 100%; }
.view { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  padding: 48px 24px calc(28px + var(--safe-b)); overflow-y: auto; -webkit-overflow-scrolling: touch;
  opacity: 0; visibility: hidden; transform: translateY(12px);
  transition: opacity .6s var(--ease), transform .6s var(--ease), visibility 0s .6s; }
.view.is-active { opacity: 1; visibility: visible; transform: none;
  transition: opacity .6s var(--ease), transform .6s var(--ease); }

/* ---------- 通用排版 ---------- */
.brand { text-align: center; margin-bottom: 32px; }
.brand-en { font-size: 11px; letter-spacing: .42em; color: var(--gold); opacity: .8; }
.brand-title { font: 600 34px/1.3 var(--serif); letter-spacing: .18em; margin: 10px 0 8px; text-indent: .18em; }
.brand-sub { font-size: 13px; color: var(--ink-2); letter-spacing: .08em; }
.rule { display: block; width: 72px; height: 1px; margin: 20px auto 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent); position: relative; }
.rule::after { content: ""; position: absolute; left: 50%; top: 50%; width: 5px; height: 5px;
  border: 1px solid var(--gold); background: var(--bg-0); transform: translate(-50%, -50%) rotate(45deg); }

.btn { display: inline-flex; align-items: center; justify-content: center; min-width: 200px; height: 48px;
  padding: 0 28px; border-radius: 24px; font-size: 15px; letter-spacing: .2em; text-indent: .2em;
  transition: transform .2s var(--ease), opacity .3s; }
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(180deg, #e6d3ad, #c9b083); color: #1b2436; font-weight: 600;
  box-shadow: 0 8px 24px -8px rgba(216, 195, 154, .55); }
.btn-ghost { border: 1px solid var(--line); color: var(--ink-2); }
.is-hidden { opacity: 0; pointer-events: none; }

.back { position: absolute; left: 12px; top: 12px; width: 40px; height: 40px; font-size: 28px; line-height: 1;
  color: var(--ink-3); }

/* ---------- 1. 首页玩法列表 ---------- */
.spread-list { list-style: none; width: 100%; max-width: 420px; display: grid; gap: 12px; }
.spread-list > li { animation: rise .7s var(--ease) both; }
.spread-item { display: flex; width: 100%; text-align: left; align-items: center; gap: 16px; padding: 16px 18px; border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.06);
  transition: border-color .3s, background .3s; }
.spread-item:active { border-color: var(--gold-soft); background: rgba(216,195,154,.06); }
.spread-no { flex: none; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--line); font: 15px var(--serif); color: var(--gold); }
.spread-main { flex: 1; min-width: 0; }
.spread-title { display: block; font: 600 16px/1.4 var(--serif); letter-spacing: .06em; }
.spread-desc { display: block; font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.spread-count { flex: none; font-size: 11px; color: var(--ink-3); letter-spacing: .1em; }
@keyframes rise { to { opacity: 1; transform: none; } }

.foot-note { margin-top: auto; padding-top: 28px; font-size: 11px; color: var(--ink-3); letter-spacing: .1em; text-align: center; }

/* ---------- 2. 静心 ---------- */
.view-calm { justify-content: center; text-align: center; gap: 0; }
.calm-spread { font: 600 20px var(--serif); letter-spacing: .14em; color: var(--gold); }
.calm-guide { margin: 18px 0 56px; color: var(--ink-2); font-size: 14px; line-height: 2; letter-spacing: .1em; }
.hold { position: relative; width: 132px; height: 132px; touch-action: none; }
.hold svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.hold circle { fill: none; stroke-width: 1.5; }
.hold-track { stroke: var(--line); }
.hold-ring { stroke: var(--gold); stroke-linecap: round; stroke-dasharray: 339.3; stroke-dashoffset: 339.3; }
.hold-text { position: absolute; inset: 0; display: grid; place-items: center; font: 16px var(--serif);
  letter-spacing: .3em; text-indent: .3em; color: var(--ink-2); }
.hold::before { content: ""; position: absolute; inset: 18px; border-radius: 50%;
  background: radial-gradient(circle, rgba(216,195,154,.18), transparent 70%); animation: pulse 2.4s ease-in-out infinite; }
.hold.is-holding::before { animation-duration: .9s; }
.hold.is-done .hold-text { color: var(--gold); }
@keyframes pulse { 50% { transform: scale(1.15); opacity: .5; } }
.calm-hint { margin-top: 20px; font-size: 12px; color: var(--ink-3); letter-spacing: .1em; }

/* ---------- 3. 抽牌 ---------- */
.view-draw { padding-top: max(56px, env(safe-area-inset-top, 0px)); }
.draw-tip { font: 15px var(--serif); letter-spacing: .16em; color: var(--ink-2); min-height: 24px;
  transition: opacity .4s; }

/* 已选牌位（顶部） */
.slots { display: flex; justify-content: center; gap: 12px; margin-top: 18px; width: 100%; }
.slot { width: calc((100% - 24px) / 3); max-width: 120px; flex-shrink: 0; text-align: center; }
.slot-frame { position: relative; aspect-ratio: var(--card-ratio); border-radius: 8px;
  border: 1px dashed var(--line); perspective: 900px; }
.slot.is-single { width: min(46vw, 20vh); max-width: 190px; }
.slot-label { margin-top: 8px; font-size: 12px; color: var(--ink-3); letter-spacing: .1em; transition: color .4s; }
.slot.is-filled .slot-label { color: var(--gold); }

/* 翻牌：front/back 两面 */
.flip { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 1s var(--ease); }
.flip.is-open { transform: rotateY(180deg); }
.flip > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 8px;
  backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 10px 30px -10px rgba(0,0,0,.6); }
.flip .face { transform: rotateY(180deg); }
.flip.is-open::after { content: ""; position: absolute; inset: -6px; border-radius: 12px; pointer-events: none;
  box-shadow: 0 0 0 1px var(--gold-soft), 0 0 36px rgba(216,195,154,.35); animation: glow 1.6s var(--ease) forwards; }
@keyframes glow { 0% { opacity: 0; } 40% { opacity: 1; } 100% { opacity: .5; } }

/* 牌桌：扇形牌堆 */
.table { position: relative; flex: 1 0 230px; width: 100%; max-width: 420px; min-height: 230px; }
.deck-card { position: absolute; left: 50%; bottom: 10px; width: min(20vw, 82px); aspect-ratio: var(--card-ratio);
  border-radius: 6px; overflow: hidden;
  background: center / cover url(../cards/back-thumb.webp);
  box-shadow: 0 6px 18px -6px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.06);
  transform-origin: 50% 160%; transition: transform .7s var(--ease), opacity .4s; will-change: transform; }
.deck-card.is-picked { opacity: 0; pointer-events: none; }

.draw-actions { padding-top: 12px; min-height: 60px; }

/* ---------- 4. 结果页 ---------- */
.result-head { text-align: center; margin-bottom: 24px; }
.result-title { font: 600 24px/1.4 var(--serif); letter-spacing: .14em; margin-top: 8px; }
.result-cards { display: flex; justify-content: center; gap: 10px; width: 100%; max-width: 420px; }
.result-card { flex: 1; max-width: 200px; text-align: center; opacity: 0; animation: rise .8s var(--ease) forwards; }
.result-cards.is-single .result-card { max-width: 62vw; }
.result-card img { width: 100%; aspect-ratio: var(--card-ratio); object-fit: cover; border-radius: 8px;
  box-shadow: 0 0 0 1px var(--gold-soft), 0 14px 32px -12px rgba(0,0,0,.7); }
.result-pos { margin-top: 10px; font: 13px var(--serif); color: var(--gold); letter-spacing: .08em; }
.result-pos { display: block; }
.result-card { min-width: 0; align-self: flex-start; }
.result-cards.is-single .result-card { max-width: 220px; }
.result-note { margin: 24px 0; font-size: 12px; line-height: 1.9; color: var(--ink-3); text-align: center; letter-spacing: .08em; }
.result-actions { display: grid; gap: 12px; margin-top: auto; }

/* ---------- 浮层 ---------- */
.lightbox, .poster { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 16px; padding: 24px; background: rgba(6, 11, 20, .92);
  animation: fade .35s var(--ease); }
.lightbox img { max-height: 80vh; width: auto; border-radius: 10px; }
.lightbox-pos { font: 14px var(--serif); color: var(--gold); letter-spacing: .12em; }
.poster img { max-height: 72vh; width: auto; border-radius: 6px; -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto; }
.poster p { font-size: 13px; color: var(--ink-2); letter-spacing: .1em; }
.share-cover { position: absolute; width: 1px; height: 1px; opacity: .001; pointer-events: none; }
.status { position: fixed; z-index: 30; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px); padding: 12px 18px; border: 1px solid var(--line);
  border-radius: 12px; background: #1a2d4d; color: var(--ink); text-align: center; font-size: 13px; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 5px; }
button:disabled { cursor: default; }
.result-actions { padding-top: 12px; }
.view-home > *, .view-result > *, .view-calm > * { flex-shrink: 0; }
.lightbox img { max-width: 100%; max-height: 70vh; object-fit: contain; }
.poster img { object-fit: contain; }
@media (max-width: 350px) {
  .view { padding-left: 18px; padding-right: 18px; }
  .spread-item { gap: 10px; padding: 14px 12px; }
  .spread-title { font-size: 15px; }
  .slot-label { font-size: 11px; letter-spacing: 0; }
}
@media (orientation: landscape) and (max-height: 600px) {
  .view-draw { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 24px minmax(210px, 1fr) 48px;
    gap: 8px 16px; padding: 40px 24px 12px; }
  .draw-tip { grid-column: 1 / -1; text-align: center; }
  .view-draw .slots { width: 100%; max-width: 260px; margin: 0; justify-self: center; align-self: center; }
  .view-draw .table { min-height: 210px; height: 100%; }
  .draw-actions { grid-column: 1 / -1; padding: 0; min-height: 48px; display: flex; justify-content: center; }
  .view-calm { justify-content: flex-start; padding-top: 32px; }
  .calm-guide { margin: 12px 0 20px; }
  .hold { width: 110px; height: 110px; }
  .slots { max-width: 330px; }
  .slot.is-single { width: 100px; }
  .table { flex-basis: 240px; }
  .lightbox, .poster { flex-direction: row; padding: 16px; }
  .lightbox img, .poster img { max-height: 85vh; max-width: 65vw; }
}
@keyframes fade { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
