/* ============================================================
   星盘塔罗 · 样式
   深空星夜 × 鎏金 × 玻璃拟态
   ============================================================ */

:root {
  --bg-0: #0d0a1f;
  --bg-1: #171233;
  --bg-2: #241c47;
  --gold: #d4a853;
  --gold-light: #f0d48a;
  --gold-deep: #b8863b;
  --ink: #f2ead6;
  --ink-dim: #b9aed6;
  --ink-faint: #8a7fb0;
  --glass-bg: rgba(23, 18, 51, 0.55);
  --glass-border: rgba(212, 168, 83, 0.28);
  --card-w: 88px;
  --card-h: 152px;
  --radius: 14px;
  --font-display: 'Cinzel Decorative', 'Noto Serif SC', Georgia, 'Songti SC', 'SimSun', serif;
  --font-body: 'Noto Serif SC', 'Songti SC', 'SimSun', Georgia, serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

.hidden { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: radial-gradient(ellipse at 50% 0%, #241c47 0%, #171233 40%, #0d0a1f 100%);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* ---------- 星空背景 ---------- */
#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
#symbols {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
#symbols .sym {
  position: absolute;
  color: var(--gold);
  opacity: 0;
  animation: floatSym linear infinite;
  will-change: transform;
}

/* ---------- 屏幕容器 ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: none;
  flex-direction: column;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.45s ease, transform 0.45s ease;
  max-width: 520px;
  margin: 0 auto;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
.screen.active {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

#app.hidden { display: none; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 8px;
  flex: 0 0 auto;
}
.topbar-title h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--gold-light);
  font-family: var(--font-display);
}
.title-en {
  font-family: var(--font-display);
  letter-spacing: 0.34em;
  color: var(--gold);
}
.title-en.small { font-size: 0.6rem; letter-spacing: 0.5em; opacity: 0.85; display: block; }
.top-actions { display: flex; gap: 10px; }
.icon-btn {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  color: var(--gold-light);
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.15s ease, border-color 0.2s ease;
}
.icon-btn:active { transform: scale(0.92); border-color: var(--gold); }

.draw-title { text-align: center; flex: 1; }
.draw-title h2 {
  font-size: 1rem;
  color: var(--gold-light);
  letter-spacing: 0.2em;
  font-family: var(--font-display);
}
.draw-title p { font-size: 0.72rem; color: var(--ink-dim); margin-top: 3px; letter-spacing: 0.05em; }

/* ---------- 首页 ---------- */
.home-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overscroll-behavior: contain;
}
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.question-card { padding: 14px 16px; }
.question-card label {
  display: block;
  font-size: 0.78rem;
  color: var(--ink-dim);
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.question-card input {
  width: 100%;
  background: rgba(13, 10, 31, 0.5);
  border: 1px solid rgba(212, 168, 83, 0.22);
  border-radius: 10px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s ease;
}
.question-card input:focus { border-color: var(--gold); }
.question-card input::placeholder { color: var(--ink-faint); }

.section-title {
  font-size: 0.8rem;
  color: var(--ink-dim);
  letter-spacing: 0.3em;
  text-align: center;
  margin-top: 4px;
  position: relative;
}
.section-title::before, .section-title::after {
  content: "";
  display: inline-block;
  width: 24px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold));
  vertical-align: middle;
  margin: 0 10px;
}
.section-title::after { background: linear-gradient(90deg, var(--gold), transparent); }

.spread-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.spread-item {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px 8px 10px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  min-height: 74px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.spread-item .sp-name { font-size: 0.85rem; color: var(--ink); letter-spacing: 0.06em; }
.spread-item .sp-count { font-size: 0.66rem; color: var(--ink-faint); margin-top: 4px; }
.spread-item.selected {
  border-color: var(--gold);
  box-shadow: 0 0 18px rgba(212, 168, 83, 0.28), inset 0 0 12px rgba(212, 168, 83, 0.08);
}
.spread-item:active { transform: scale(0.96); }
.spread-desc {
  font-size: 0.78rem;
  color: var(--ink-dim);
  line-height: 1.6;
  letter-spacing: 0.04em;
  margin: 4px 2px 14px;
  padding: 10px 12px;
  border-left: 2px solid var(--gold);
  background: rgba(13, 10, 31, 0.35);
  border-radius: 0 10px 10px 0;
  min-height: 34px;
}

.free-count {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 6px 0;
}
.free-count-label { font-size: 0.82rem; color: var(--ink-dim); }
.count-stepper {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 4px 6px;
}
.stepper-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--gold-light);
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
}
.count-value {
  min-width: 40px;
  text-align: center;
  font-size: 1.3rem;
  color: var(--gold-light);
  font-family: var(--font-display);
}

.btn {
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  color: var(--ink);
  border-radius: 999px;
  letter-spacing: 0.12em;
  transition: transform 0.15s ease, box-shadow 0.25s ease, opacity 0.2s ease;
  position: relative;
  overflow: hidden;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-gold {
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 45%, var(--gold-deep) 100%);
  color: #1c1430;
  font-weight: 700;
  box-shadow: 0 6px 22px rgba(212, 168, 83, 0.35);
}
.btn-gold::after {
  content: "";
  position: absolute;
  top: 0; left: -80%;
  width: 60%; height: 100%;
  background: linear-gradient(105deg, transparent, rgba(255,255,255,0.55), transparent);
  transform: skewX(-20deg);
  transition: left 0.6s ease;
}
.btn-gold:not(:disabled):hover::after { left: 130%; }
.btn-lg { width: 100%; padding: 16px; font-size: 1rem; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--gold-light);
  padding: 10px 18px;
  font-size: 0.82rem;
}
.btn-ghost.small { padding: 8px 14px; font-size: 0.74rem; }
.btn-ghost.danger { color: #e08a8a; border-color: rgba(224, 138, 138, 0.35); }

.footnote {
  text-align: center;
  font-size: 0.68rem;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  margin-top: 2px;
}

/* ---------- 抽牌页：桌布 ---------- */
#tableWrap {
  flex: 1;
  padding: 8px 14px 10px;
  min-height: 0;
}
#tablecloth {
  position: relative;
  height: 100%;
  min-height: 330px;
  border-radius: 20px;
  border: 1px solid rgba(212, 168, 83, 0.2);
  box-shadow: inset 0 0 60px rgba(0,0,0,0.55), 0 10px 40px rgba(0,0,0,0.45);
  overflow: hidden;
  background-image: var(--cloth-bg, radial-gradient(ellipse at 50% 0%, #2b2350 0%, #171233 45%, #0d0a1f 100%));
  transition: background-image 0.4s ease;
}
#tablecloth::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.014) 0 2px, transparent 2px 6px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,0.014) 0 2px, transparent 2px 6px);
  pointer-events: none;
}
#tablecloth.cloth-img::after { display: none; }
/* 大牌阵使用紧凑卡牌尺寸，保证手机宽度放得下 */
#tablecloth.compact { --card-w: 66px; --card-h: 114px; }
#tablecloth.micro { --card-w: 58px; --card-h: 100px; }

/* 牌位区：虚线牌位框，可点击落牌 */
#positions { position: absolute; inset: 0; pointer-events: auto; }
.pos-label {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 0.66rem;
  color: rgba(242, 234, 214, 0.75);
  letter-spacing: 0.2em;
  text-align: center;
  padding: 3px 8px;
  border: 1px dashed rgba(212, 168, 83, 0.35);
  border-radius: 999px;
  background: rgba(13, 10, 31, 0.35);
  white-space: nowrap;
  pointer-events: none;
  z-index: 1;
}

/* 牌位（可点击落牌） */
.slot {
  position: absolute;
  transform: translate(-50%, -50%);
  width: var(--card-w);
  height: var(--card-h);
  border: 1.5px dashed rgba(212, 168, 83, 0.42);
  border-radius: 10px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  cursor: pointer;
  background: rgba(13, 10, 31, 0.16);
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
  z-index: 1;
}
.slot .slot-name {
  font-size: 0.6rem;
  color: rgba(242, 234, 214, 0.8);
  letter-spacing: 0.12em;
  line-height: 1.35;
  text-align: center;
  padding: 4px 6px 5px;
  pointer-events: none;
}
.slot:active { transform: translate(-50%, -50%) scale(0.96); }
.slot.target {
  border-color: var(--gold-light);
  background: rgba(212, 168, 83, 0.18);
  box-shadow: 0 0 20px rgba(240, 212, 138, 0.4) inset, 0 0 14px rgba(240, 212, 138, 0.35);
}
.slot.filled {
  border-color: transparent;
  background: transparent;
  cursor: default;
  pointer-events: none;
}

#cardArea {
  position: absolute;
  inset: 0;
  z-index: 2;
}

/* 卡牌 */
.tarot-card {
  position: absolute;
  width: var(--card-w);
  height: var(--card-h);
  perspective: 900px;
  cursor: pointer;
  transition: opacity 0.3s ease;
  touch-action: none;
  z-index: 3;
}
.tarot-card.dragging { z-index: 20; transition: none; }
/* 待放置的牌：脉动光晕提示 */
.tarot-card.placing { z-index: 10; }
.tarot-card.placing .card-inner { box-shadow: 0 0 0 2px rgba(240, 212, 138, 0.75), 0 0 26px rgba(240, 212, 138, 0.5); animation: placingPulse 1.2s ease-in-out infinite; border-radius: 10px; }
@keyframes placingPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(240, 212, 138, 0.75), 0 0 26px rgba(240, 212, 138, 0.5); }
  50% { box-shadow: 0 0 0 2px rgba(240, 212, 138, 0.35), 0 0 8px rgba(240, 212, 138, 0.2); }
}
.tarot-card.dealing {
  animation: dealIn 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
@keyframes dealIn {
  from { opacity: 0; transform: translateY(-30px) scale(0.8) rotate(-8deg); }
  to { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}
.tarot-card .card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.4, 0.1, 0.2, 1);
}
.tarot-card.flipped .card-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0,0,0,0.55);
  border: 1px solid rgba(212, 168, 83, 0.35);
}
.card-back {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.28s ease;
}
.card-back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card-front {
  transform: rotateY(180deg);
  background: #f5ecd8;
  opacity: 0;
  transition: opacity 0.28s ease 0.36s;
}
.tarot-card.flipped .card-back { opacity: 0; transition: opacity 0.28s ease; }
.tarot-card.flipped .card-front { opacity: 1; }
.card-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.tarot-card.reversed .card-front img { transform: rotate(180deg); }
.tarot-card.flipped .card-front { box-shadow: 0 0 24px rgba(212, 168, 83, 0.45), 0 6px 18px rgba(0,0,0,0.55); }

/* 翻面时的金光脉冲 */
.tarot-card.glow-flip .card-front::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 14px;
  border: 2px solid var(--gold-light);
  animation: glowPulse 0.8s ease-out both;
  pointer-events: none;
}
@keyframes glowPulse {
  0% { opacity: 0.9; transform: scale(0.96); box-shadow: 0 0 30px 8px rgba(240, 212, 138, 0.7); }
  100% { opacity: 0; transform: scale(1.06); box-shadow: 0 0 0 0 rgba(240, 212, 138, 0); }
}

/* 牌序角标 */
.card-seq {
  position: absolute;
  top: -9px; left: -9px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-light), var(--gold-deep));
  color: #1c1430;
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  border: 2px solid rgba(255,255,255,0.35);
}

/* ---------- 牌堆区（桌布下方） ---------- */
#deckArea {
  flex: 0 0 auto;
  padding: 6px 14px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
#deck {
  position: relative;
  width: calc(var(--card-w) - 14px);
  height: calc(var(--card-h) - 14px);
  cursor: pointer;
  transition: opacity 0.3s ease;
}
.deck-card {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(212, 168, 83, 0.42);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  background: #0f0c22;
}
.deck-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.deck-card.d1 { transform: translate(0, 0); z-index: 3; }
.deck-card.d2 { transform: translate(5px, 5px); opacity: 0.72; z-index: 2; }
.deck-card.d3 { transform: translate(-5px, 4px); opacity: 0.5; z-index: 1; }
.deck-glow {
  position: absolute;
  inset: -7px;
  border-radius: 14px;
  border: 1px dashed rgba(240, 212, 138, 0.55);
  animation: deckPulse 2.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes deckPulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}
#deck.empty { opacity: 0.45; cursor: default; }
#deck.empty .deck-glow { display: none; }
#deck.shuffling .deck-card {
  animation: deckShake 0.55s ease-in-out;
}
@keyframes deckShake {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  20% { transform: translate(-6px, 3px) rotate(-2.5deg); }
  45% { transform: translate(6px, -3px) rotate(2.5deg); }
  70% { transform: translate(-4px, -2px) rotate(-1.5deg); }
  85% { transform: translate(4px, 2px) rotate(1.5deg); }
}
#deckCount {
  font-size: 0.68rem;
  color: var(--ink-faint);
  letter-spacing: 0.14em;
}

.draw-actions {
  flex: 0 0 auto;
  padding: 8px 18px calc(14px + var(--safe-bottom));
  display: flex;
  justify-content: center;
  gap: 12px;
}
}
.draw-actions .btn { flex: 1; max-width: 260px; padding: 13px; font-size: 0.92rem; }

/* ---------- 解读页 ---------- */
.result-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overscroll-behavior: contain;
}
.result-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 12px;
}
.result-card {
  cursor: pointer;
  text-align: center;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 8px;
  transition: transform 0.15s ease, border-color 0.2s ease;
}
.result-card:active { transform: scale(0.97); }
.result-card .rc-img {
  width: 100%;
  aspect-ratio: 2 / 3.4;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(212, 168, 83, 0.3);
  background: #f5ecd8;
  position: relative;
}
.result-card .rc-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.result-card.reversed .rc-img img { transform: rotate(180deg); }
.rc-pos { font-size: 0.62rem; color: var(--gold-light); margin-top: 6px; letter-spacing: 0.1em; }
.rc-name { font-size: 0.8rem; color: var(--ink); margin-top: 2px; }
.rc-ori { font-size: 0.62rem; margin-top: 2px; color: var(--ink-faint); }

.reading { padding: 18px 18px 20px; }
.reading h3 {
  color: var(--gold-light);
  font-size: 1rem;
  letter-spacing: 0.3em;
  text-align: center;
  margin-bottom: 14px;
  font-family: var(--font-display);
}
.reading .reading-block { margin-bottom: 12px; }
.reading .rb-title {
  color: var(--gold);
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  margin-bottom: 6px;
}
.reading .rb-text {
  font-size: 0.86rem;
  line-height: 1.75;
  color: var(--ink);
  text-align: justify;
}
.reading .divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-border), transparent);
  margin: 14px 0;
}
.reading .q-note { font-size: 0.74rem; color: var(--ink-faint); font-style: italic; text-align: center; margin-top: 12px; }

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 4px 0 10px;
}
.result-actions .btn { flex: 1; max-width: 200px; padding: 13px; font-size: 0.88rem; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(6, 4, 16, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 18px;
}
.modal.show { display: flex; animation: modalIn 0.3s ease both; }
@keyframes modalIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  position: relative;
  background: linear-gradient(160deg, #221b45 0%, #171233 60%, #120e28 100%);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  max-width: 400px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 18px;
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 16px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.modal-card-img {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(212, 168, 83, 0.4);
  background: #f5ecd8;
  height: max-content;
}
.modal-card-img img { width: 100%; display: block; object-fit: cover; }
.modal-card-info { padding-right: 4px; }
.modal-close {
  position: absolute;
  top: 10px; right: 10px;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(13, 10, 31, 0.6);
  color: var(--gold-light);
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 5;
}
#modalCardName { font-size: 1.15rem; color: var(--gold-light); letter-spacing: 0.1em; }
.card-name-en { font-family: var(--font-display); font-size: 0.72rem; color: var(--ink-dim); letter-spacing: 0.12em; margin-top: 2px; }
.card-meta { font-size: 0.72rem; color: var(--ink-faint); margin-top: 6px; letter-spacing: 0.08em; }
.keyword-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.keyword-tags span {
  font-size: 0.68rem;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(212, 168, 83, 0.4);
  color: var(--gold-light);
  background: rgba(212, 168, 83, 0.08);
  letter-spacing: 0.06em;
}
.orientation-toggle {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  background: rgba(13, 10, 31, 0.5);
  border-radius: 999px;
  padding: 3px;
  width: fit-content;
}
.ori-btn {
  border: none;
  background: transparent;
  color: var(--ink-dim);
  font-family: var(--font-body);
  font-size: 0.78rem;
  padding: 6px 16px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.15em;
  transition: all 0.2s ease;
}
.ori-btn.active {
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  color: #1c1430;
  font-weight: 700;
}
.modal-position {
  margin-top: 10px;
  font-size: 0.72rem;
  color: var(--gold);
  letter-spacing: 0.1em;
}
.modal-meaning {
  margin-top: 8px;
  font-size: 0.86rem;
  line-height: 1.7;
  color: var(--ink);
  text-align: justify;
  transition: opacity 0.2s ease;
}
.modal-desc {
  margin-top: 10px;
  font-size: 0.74rem;
  line-height: 1.6;
  color: var(--ink-dim);
  border-top: 1px dashed rgba(212, 168, 83, 0.25);
  padding-top: 10px;
}

.modal-panel {
  background: linear-gradient(160deg, #221b45 0%, #171233 60%, #120e28 100%);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  max-width: 420px;
  width: 100%;
  max-height: 86vh;
  overflow-y: auto;
  padding: 22px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.modal-title {
  color: var(--gold-light);
  font-size: 1.05rem;
  letter-spacing: 0.3em;
  text-align: center;
  margin-bottom: 18px;
  font-family: var(--font-display);
}
.setting-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(212, 168, 83, 0.12);
}
.setting-row label { flex: 1; font-size: 0.85rem; color: var(--ink); letter-spacing: 0.06em; }
.setting-row.col { flex-direction: column; align-items: stretch; }
.setting-row.col label { margin-bottom: 4px; }
.setting-row input[type="range"] {
  flex: 2;
  accent-color: var(--gold);
  height: 4px;
}
.cloth-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.cloth-swatch {
  width: 46px; height: 34px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.4);
  transition: border-color 0.2s ease, transform 0.15s ease;
}
.cloth-swatch.active { border-color: var(--gold-light); transform: scale(1.06); }
.cloth-swatch.custom { background: conic-gradient(#e0a15a, #7a5cc0, #3fa08a, #c25a7a, #e0a15a); position: relative; }
.cloth-swatch.custom::after {
  content: "自";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.66rem;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}
#settingsClose, #historyClose { width: 100%; margin-top: 18px; padding: 13px; }

.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  background: rgba(13, 10, 31, 0.45);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
}
.history-item:active { background: rgba(212, 168, 83, 0.08); }
.history-item .hi-head { display: flex; justify-content: space-between; align-items: baseline; }
.history-item .hi-spread { font-size: 0.8rem; color: var(--gold-light); letter-spacing: 0.08em; }
.history-item .hi-time { font-size: 0.64rem; color: var(--ink-faint); }
.history-item .hi-q { font-size: 0.7rem; color: var(--ink-dim); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item .hi-cards { display: flex; gap: 4px; margin-top: 8px; }
.history-item .hi-cards .mini {
  width: 26px; height: 42px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(212, 168, 83, 0.3);
  background: #f5ecd8;
  position: relative;
}
.history-item .hi-cards .mini img { width: 100%; height: 100%; object-fit: cover; }
.history-item .hi-cards .mini.rev img { transform: rotate(180deg); }
.history-empty { text-align: center; color: var(--ink-faint); font-size: 0.82rem; padding: 30px 0; letter-spacing: 0.1em; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(23, 18, 51, 0.92);
  border: 1px solid var(--glass-border);
  color: var(--ink);
  font-size: 0.82rem;
  padding: 10px 20px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 300;
  letter-spacing: 0.05em;
  max-width: 84vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 加载页 ---------- */
#screen-preload {
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 500;
  background: radial-gradient(ellipse at 50% 30%, #241c47 0%, #171233 45%, #0d0a1f 100%);
}
.preload-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 20px; }
.preload-mark { filter: drop-shadow(0 0 18px rgba(212, 168, 83, 0.5)); animation: starPulse 2.2s ease-in-out infinite; }
@keyframes starPulse {
  0%, 100% { transform: scale(1) rotate(0deg); filter: drop-shadow(0 0 12px rgba(212,168,83,0.4)); }
  50% { transform: scale(1.08) rotate(8deg); filter: drop-shadow(0 0 26px rgba(240,212,138,0.8)); }
}
.preload-inner .title-en { font-size: 2.2rem; letter-spacing: 0.5em; margin-left: 0.5em; }
.preload-inner .title-zh { font-size: 1rem; color: var(--ink-dim); letter-spacing: 0.6em; margin-left: 0.6em; font-weight: 400; }
.preload-bar {
  width: 76%;
  max-width: 300px;
  height: 4px;
  background: rgba(212, 168, 83, 0.18);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 10px;
}
#preloadBar {
  width: 0%;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold-light));
  transition: width 0.3s ease;
}
#preloadText { font-size: 0.78rem; color: var(--ink-faint); letter-spacing: 0.15em; }
#enterBtn { margin-top: 18px; padding: 14px 46px; font-size: 0.95rem; }

/* ---------- 粒子爆散（翻牌特效） ---------- */
#burstCanvas {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
}

/* ---------- 响应式 ---------- */
@media (min-width: 720px) {
  :root { --card-w: 104px; --card-h: 180px; }
  #tablecloth.compact { --card-w: 78px; --card-h: 135px; }
  #tablecloth.micro { --card-w: 66px; --card-h: 114px; }
  .spread-list { grid-template-columns: repeat(3, 1fr); }
  #tablecloth { min-height: 480px; }
  .modal-card { grid-template-columns: 160px 1fr; }
}

@media (max-width: 380px) {
  :root { --card-w: 78px; --card-h: 135px; }
  .spread-list { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .spread-item { padding: 10px 6px; min-height: 68px; }
  .modal-card { grid-template-columns: 108px 1fr; padding: 14px; gap: 12px; }
}

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

/* ---------- 浮动符号 ---------- */
@keyframes floatSym {
  0% { transform: translateY(10vh) rotate(0deg); opacity: 0; }
  12% { opacity: 0.5; }
  88% { opacity: 0.5; }
  100% { transform: translateY(-90vh) rotate(340deg); opacity: 0; }
}
