:root {
  --bg: #f4f1ea;          /* 暖白紙感 */
  --bg-2: #faf8f3;
  --panel: #ffffff;
  --ink: #322c38;         /* 近黑墨色 */
  --ink-soft: #5a5360;
  --ink-dim: #948d9c;
  --accent: #b0894a;      /* 沉金 */
  --accent-deep: #8a6a34;
  --accent-soft: #c9a974;
  --line: rgba(50, 44, 56, 0.14);
  --line-soft: rgba(50, 44, 56, 0.08);
  --radius: 16px;
  --card-ratio: 0.573;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Serif TC", "Songti TC", serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overflow-x: hidden;
}

#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; position: relative; }

/* ---------- view 切換 ---------- */
.view {
  display: none;
  padding: clamp(28px, 7vw, 56px) 22px calc(40px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}
.view--active { display: block; animation: fade 1s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 進場引子 veil ---------- */
#intro-veil {
  position: fixed; inset: 0; z-index: 100; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px;
  background:
    radial-gradient(900px 600px at 50% 38%, #ffffff 0%, transparent 70%),
    var(--bg);
  transition: opacity 1s ease, visibility 1s ease;
}
#intro-veil.is-hidden { opacity: 0; visibility: hidden; }
.veil-mark {
  margin-bottom: 16px;
  opacity: 0; animation: veilUp 1.6s ease .2s forwards;
}
.veil-title {
  font-family: "Noto Serif TC", serif; font-weight: 900;
  font-size: clamp(44px, 14vw, 64px); letter-spacing: .14em; text-indent: .14em;
  color: var(--ink); line-height: 1;
  opacity: 0; animation: veilUp 1.8s ease .55s forwards;
}
.veil-logo { width: min(40vw, 150px); max-width: 100%; height: auto; display: block; }
.veil-rule {
  width: 0; height: 1px; background: var(--accent); margin: 26px 0 22px; opacity: .6;
  animation: ruleGrow 1.6s ease 1s forwards;
}
.veil-sub {
  font-family: "Cormorant Garamond", serif; font-style: italic; font-size: 18px; color: var(--ink-dim);
  letter-spacing: .05em; opacity: 0; animation: veilUp 1.8s ease 1.1s forwards;
}
.veil-enter {
  margin-top: 54px; font-size: 14px; letter-spacing: .32em; text-indent: .32em; color: var(--accent-deep);
  opacity: 0; animation: veilUp 1.6s ease 2s forwards, breathe 3.2s ease-in-out 2.8s infinite;
}
@keyframes veilUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes ruleGrow { from { width: 0; opacity: 0; } to { width: 64px; opacity: .55; } }
@keyframes breathe { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }

/* ---------- 首頁 ---------- */
.intro { text-align: center; display: flex; flex-direction: column; align-items: center; }
.deck-mark { margin-bottom: 12px; }
.deck-logo { width: min(36vw, 132px); max-width: 100%; height: auto; display: block; }
.deck-title {
  font-family: "Noto Serif TC", serif; font-weight: 900;
  font-size: clamp(30px, 11vw, 52px); letter-spacing: .12em; text-indent: .12em;
  line-height: 1; color: var(--ink);
}
.deck-en { font-family: "Cormorant Garamond", serif; font-style: italic; font-size: 18px; color: var(--ink-dim); margin-top: 10px; letter-spacing: .04em; }
.intro-lead { margin-top: 22px; color: var(--ink-soft); line-height: 2; font-size: 16px; }

/* 進場後由上而下逐一浮現，最後慢慢浮出牌 */
/* 浮現前不可點，避免使用者誤觸看不見的牌/按鈕就抽牌 */
.intro > * { opacity: 0; pointer-events: none; }
/* 標題群 → 停頓 → 提示句/輸入/按鈕同一節奏連續浮出 → 最後牌緩緩浮出 */
.intro--reveal .deck-mark    { animation: riseIn .9s ease .2s both; }
.intro--reveal .deck-title   { animation: riseIn 1s ease .65s both; }
.intro--reveal .deck-en      { animation: riseIn 1s ease 1.1s both; }
.intro--reveal .intro-lead   { animation: riseIn 1s ease 2.5s both; }    /* 停頓後，與下面同節奏 */
.intro--reveal .question     { animation: riseIn 1s ease 2.9s both; }
.intro--reveal .btn--primary { animation: riseIn 1s ease 3.3s both; }
.intro--reveal .daily-status { animation: riseIn 1s ease 3.7s both; }
.intro--reveal .share-app-link { animation: riseIn 1s ease 4s both; }
.intro--reveal .about-link    { animation: riseIn 1s ease 4.25s both; }
.intro--reveal .card-back    { animation: cardRise 5.5s cubic-bezier(.22, .68, .24, 1) 5.7s both; }   /* 控制項就定位後空一拍，牌再緩緩浮出 */
@keyframes riseIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes cardRise { from { opacity: 0; transform: translateY(30px) scale(.94); } to { opacity: 1; transform: none; } }

/* 牌背 */
.card-back {
  width: min(62vw, 230px); aspect-ratio: var(--card-ratio);
  margin: 30px 0 8px; cursor: pointer; overflow: hidden;
  border-radius: var(--radius); padding: 0;
  background: #efe8d8 center / cover no-repeat url('../public/back.png');
  box-shadow: 0 16px 40px rgba(120, 100, 60, .18), 0 0 0 1px var(--line) inset;
  transition: transform .35s ease, box-shadow .35s ease;
}
.card-back:hover, .card-back:focus-visible { transform: translateY(-4px); box-shadow: 0 24px 50px rgba(120, 100, 60, .26), 0 0 0 1px var(--accent) inset; outline: none; }
.card-back__inner { display: none; } /* 改用整張牌背圖 */

.question {
  width: 100%; max-width: 340px; margin: 20px 0 16px;
  background: var(--bg-2); border: 1px solid var(--line);
  color: var(--ink); border-radius: 999px; padding: 13px 20px;
  font-family: inherit; font-size: 15px; text-align: center;
}
.question::placeholder { color: var(--ink-dim); }
.question:focus { outline: none; border-color: var(--accent); background: #fff; }

/* ---------- 按鈕 ---------- */
.btn {
  font-family: inherit; font-size: 16px; letter-spacing: .14em; text-indent: .14em;
  border: none; border-radius: 999px; cursor: pointer; transition: all .25s ease; padding: 14px 34px;
}
.btn--primary {
  background: linear-gradient(180deg, var(--accent-soft), var(--accent));
  color: #fff; font-weight: 700;
  box-shadow: 0 10px 26px rgba(176, 137, 74, .32);
}
.btn--primary:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(176, 137, 74, .42); }
.btn--ghost {
  background: #fff; color: var(--ink-soft); border: 1px solid var(--line);
  font-size: 14px; padding: 11px 22px; letter-spacing: .08em;
}
.btn--ghost:hover { border-color: var(--accent); color: var(--accent-deep); }

.btn-back { background: none; border: none; color: var(--ink-dim); font-family: inherit; font-size: 15px; cursor: pointer; padding: 4px 0; margin-top: calc(40px + env(safe-area-inset-top)); margin-bottom: 8px; letter-spacing: .05em; }
.btn-back:hover { color: var(--accent-deep); }

/* ---------- 角落單一選單鈕（⋯）：點開才有語言/音樂/分享 ---------- */
.menu { position: fixed; top: calc(14px + env(safe-area-inset-top)); right: 16px; z-index: 60; }
.menu-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255, 255, 255, .5); border: 1px solid var(--line-soft);
  color: var(--accent-deep); cursor: pointer; backdrop-filter: blur(8px);
  font-size: 22px; line-height: 1; display: grid; place-items: center; transition: all .25s ease;
}
.menu-btn:hover, .menu-btn[aria-expanded="true"] { background: rgba(255, 255, 255, .85); border-color: var(--accent); }
.menu-panel {
  position: absolute; top: 48px; right: 0; min-width: 168px;
  background: rgba(255, 255, 255, .97); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 14px 40px rgba(90, 74, 44, .18); backdrop-filter: blur(10px);
  padding: 6px; display: flex; flex-direction: column; gap: 2px; animation: menuIn .2s ease;
}
.menu-panel[hidden] { display: none; }
@keyframes menuIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: none; border: none; cursor: pointer; padding: 11px 14px; border-radius: 9px;
  font-family: inherit; font-size: 15px; letter-spacing: .04em; color: var(--ink-soft); text-align: left;
  transition: background .15s ease, color .15s ease;
}
.menu-item:hover { background: rgba(176, 137, 74, .1); color: var(--accent-deep); }
.mi-ic { width: 20px; display: inline-flex; justify-content: center; color: var(--accent); font-size: 17px; line-height: 1; position: relative; }
.mi-ic svg { width: 17px; height: 17px; }
.menu-item.is-muted { color: var(--ink-dim); }
.menu-item.is-muted .sound-icon { color: var(--ink-dim); }
.menu-item.is-muted .sound-icon::after { content: ""; position: absolute; left: -2px; right: -2px; top: 50%; height: 1.5px; background: currentColor; transform: rotate(-45deg); }

.daily-status { margin-top: 16px; color: var(--accent-deep); font-size: 13px; letter-spacing: .08em; min-height: 1em; }
.share-app-link {
  margin-top: 30px; background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 14px; letter-spacing: .1em; color: var(--ink-dim);
  transition: color .25s ease;
}
.share-app-link:hover { color: var(--accent-deep); }
.about-link {
  display: inline-block; margin-top: 14px; font-family: inherit; font-size: 14px;
  letter-spacing: .1em; color: var(--ink-dim); text-decoration: none; transition: color .25s ease;
}
.about-link:hover { color: var(--accent-deep); }

/* ---------- 解讀頁 ---------- */
.reading { text-align: center; }
.reading-question { color: var(--accent-deep); font-style: italic; font-family: "Cormorant Garamond","Noto Serif TC",serif; min-height: 1.4em; margin-bottom: 6px; font-size: 16px; }
.reading-question:empty { display: none; }
.daily-note { color: var(--accent-deep); font-size: 17px; letter-spacing: .04em; margin-bottom: 12px; }
.daily-note[hidden] { display: none; }

/* ---------- 頁尾版權 ---------- */
.site-footer {
  max-width: 520px; margin: 0 auto;
  padding: 26px 22px calc(30px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line, rgba(0,0,0,.08));
  text-align: center; color: var(--ink-soft);
  font-size: 12px; line-height: 1.7; letter-spacing: .03em;
}
.site-footer__brand { font-size: 11px; letter-spacing: .08em; color: var(--ink-dim); }
.site-footer__rights { margin-top: 4px; color: var(--ink-dim); }

/* 牌台 + 醞釀光暈 */
.card-stage { position: relative; perspective: 1500px; display: flex; justify-content: center; margin: 12px 0 26px; }
.card-stage::before {
  content: ""; position: absolute; top: 50%; left: 50%; width: 78%; aspect-ratio: 1;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(circle, rgba(176,137,74,.32), transparent 66%);
  opacity: 0; transition: opacity .9s ease; pointer-events: none; filter: blur(6px);
}
.card-stage.is-drawing::before { opacity: 1; }

.card3d {
  width: min(64vw, 250px); aspect-ratio: var(--card-ratio); position: relative;
  transform-style: preserve-3d;
  transition: transform 4.4s cubic-bezier(.22, .68, .24, 1);
  transform: rotateY(180deg);
}
.card3d.is-revealed { transform: rotateY(0deg); }
.card-stage.is-drawing .card3d { animation: cardBob 1s ease-in-out; }
@keyframes cardBob { 0% { transform: rotateY(180deg) translateY(0); } 50% { transform: rotateY(180deg) translateY(-12px); } 100% { transform: rotateY(180deg) translateY(0); } }

.card3d__face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: var(--radius); overflow: hidden; box-shadow: 0 18px 46px rgba(90, 74, 44, .28); }
/* 牌面：深色外框（像牌背），圖內縮、外圍黑邊 */
.card3d__front { background: #15120c; padding: 4%; display: grid; }
.card3d__front img { grid-area: 1 / 1; width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 7px; box-shadow: 0 0 0 1px rgba(200, 164, 92, .4); }
.card3d__front.is-reversed img { transform: rotate(180deg); }
/* 未完成牌面：圖面創作中 */
.card-soon {
  grid-area: 1 / 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 16px;
  background: linear-gradient(160deg, #fdfbf6, #efe8d8); color: var(--accent-deep);
  border-radius: 7px; box-shadow: 0 0 0 1px rgba(200, 164, 92, .4);
}
.card-soon[hidden] { display: none; }
.card-soon__glyph { font-size: 30px; color: var(--accent); opacity: .7; }
.card-soon__t { font-size: 17px; letter-spacing: .14em; }
.card-soon__s { font-size: 13px; color: var(--ink-dim); letter-spacing: .14em; }
.card3d__back { transform: rotateY(180deg); padding: 0; background: #efe8d8 center / cover no-repeat url('../public/back.png'); }
/* 牌背微光掃過 */
.card3d__back::after {
  content: ""; position: absolute; inset: 0; border-radius: 11px;
  background: linear-gradient(115deg, transparent 35%, rgba(255,255,255,.55) 50%, transparent 65%);
  transform: translateX(-120%); opacity: 0;
}
.card-stage.is-drawing .card3d__back::after { animation: shimmer 1.1s ease .15s; }
@keyframes shimmer { 0% { transform: translateX(-120%); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateX(120%); opacity: 0; } }

.reading-body { opacity: 0; transition: opacity .7s ease .15s; }
.reading-body.is-shown { opacity: 1; }

.card-head { margin-bottom: 14px; }
.orientation { display: inline-block; font-size: 12px; letter-spacing: .3em; text-indent: .3em; color: var(--accent-deep); border: 1px solid var(--line); border-radius: 999px; padding: 4px 14px; margin-bottom: 12px; }
.card-name { font-size: 30px; font-weight: 700; letter-spacing: .08em; color: var(--ink); }
.card-en { font-family: "Cormorant Garamond", serif; font-style: italic; color: var(--ink-dim); margin-top: 4px; font-size: 16px; }

.essence { font-size: 19px; line-height: 1.8; color: var(--accent-deep); margin: 18px auto 24px; max-width: 360px; font-weight: 500; }

.meaning { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; text-align: left; max-width: 400px; margin: 0 auto 22px; box-shadow: 0 6px 22px rgba(90, 74, 44, .07); }
.meaning-label { font-size: 14px; color: var(--accent-deep); letter-spacing: .2em; margin-bottom: 10px; }
.meaning-text { line-height: 2; font-size: 16px; color: var(--ink-soft); }

.symbols { text-align: left; max-width: 400px; margin: 0 auto 26px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.symbols summary { cursor: pointer; padding: 16px 4px; font-size: 15px; color: var(--accent-deep); letter-spacing: .1em; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.symbols summary::-webkit-details-marker { display: none; }
.symbols summary::after { content: "＋"; color: var(--accent); }
.symbols[open] summary::after { content: "－"; }
.symbols ul { list-style: none; padding: 0 4px 6px; }
.symbols li { padding: 9px 0; border-top: 1px dashed var(--line-soft); line-height: 1.7; font-size: 15px; color: var(--ink-soft); }
.symbols li b { color: var(--accent-deep); font-weight: 600; }
.visual { padding: 12px 4px 18px; color: var(--ink-dim); font-size: 14px; line-height: 1.9; font-style: italic; }

.actions { display: flex; gap: 12px; justify-content: center; margin-bottom: 26px; flex-wrap: wrap; }

.promo { display: flex; flex-direction: column; gap: 4px; text-decoration: none;
  background: linear-gradient(120deg, rgba(176,137,74,.12), rgba(176,137,74,.03));
  border: 1px solid var(--accent); border-radius: var(--radius); padding: 18px 22px; max-width: 400px; margin: 0 auto; transition: all .25s ease; }
.promo:hover { background: linear-gradient(120deg, rgba(176,137,74,.2), rgba(176,137,74,.06)); transform: translateY(-2px); }
.promo__kicker { color: var(--ink-dim); font-size: 13px; letter-spacing: .1em; }
.promo__title { color: var(--accent-deep); font-size: 18px; font-weight: 700; letter-spacing: .04em; }

@media (prefers-reduced-motion: reduce) {
  .card3d { transition: none; }
  .view--active, .reading-body, .card-stage .card3d, .card3d__back::after { animation: none; transition: none; }
  .veil-mark, .veil-title, .veil-rule, .veil-sub, .veil-enter { animation-duration: .01ms; opacity: 1; }
  .intro > * { opacity: 1; pointer-events: auto; }
  .intro--reveal .deck-mark, .intro--reveal .deck-title, .intro--reveal .deck-en,
  .intro--reveal .intro-lead, .intro--reveal .question, .intro--reveal .btn--primary,
  .intro--reveal .daily-status, .intro--reveal .share-app-link, .intro--reveal .about-link, .intro--reveal .card-back { animation: none; }
}
