:root {
  --bg-deep: #070514;
  --bg-nebula: #180e36;
  --gold: #e6c35c;
  --gold-dim: rgba(230, 195, 92, 0.25);
  --glass-bg: rgba(22, 16, 46, 0.65);
  --glass-border: rgba(230, 195, 92, 0.22);
  --text-main: #f4f1ea;
  --text-muted: #9b94b8;
  --font-zh: 'Noto Serif SC', serif;
  --font-en: 'Cinzel Decorative', cursive;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(circle at 50% 15%, var(--bg-nebula) 0%, var(--bg-deep) 75%);
  color: var(--text-main);
  font-family: var(--font-zh);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 80px;
  overflow-x: hidden;
}

.stars-bg {
  position: fixed;
  inset: -50%;
  background: url('https://www.transparenttextures.com/patterns/stardust.png');
  opacity: 0.22;
  animation: spin 200s linear infinite;
  pointer-events: none;
  z-index: -1;
}
@keyframes spin { to { transform: rotate(360deg); } }

.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.hero { text-align: center; margin-bottom: 20px; }
.badge {
  display: inline-block;
  font-family: var(--font-en);
  font-size: 0.65rem;
  letter-spacing: 2px;
  color: var(--gold);
  border: 1px solid var(--gold-dim);
  padding: 2px 10px;
  border-radius: 99px;
  margin-bottom: 8px;
}
h1 { margin: 0; font-size: 1.9rem; letter-spacing: 8px; color: var(--gold); font-weight: 900; }
.subtitle { margin: 4px 0 0; font-family: var(--font-en); font-size: 0.72rem; letter-spacing: 3px; color: var(--text-muted); }

.container { width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 18px; }

/* 意图与问题区 */
.query-card { border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.intent-pills { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pill {
  background: rgba(255,255,255,0.04);
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 7px 4px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-family: var(--font-zh);
  cursor: pointer;
  transition: 0.25s;
}
.pill.active {
  background: rgba(230, 195, 92, 0.16);
  border-color: var(--gold);
  color: var(--gold);
  font-weight: 600;
}
#question-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text-main);
  font-size: 0.88rem;
  font-family: var(--font-zh);
  outline: none;
}
#question-input:focus { border-color: var(--gold); }

/* 3D 牌阵 */
.spread-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.slot { display: flex; flex-direction: column; align-items: center; perspective: 900px; }
.slot-meta { text-align: center; margin-bottom: 8px; }
.slot-meta span { display: block; font-size: 0.85rem; color: var(--gold); font-weight: 600; }
.slot-meta small { font-family: var(--font-en); font-size: 0.55rem; color: var(--text-muted); letter-spacing: 1px; }

.card-3d {
  width: 100%;
  aspect-ratio: 2 / 3.1;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.65s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s;
  opacity: 0.35;
  pointer-events: none;
  cursor: pointer;
}
.card-3d.is-ready { opacity: 1; pointer-events: auto; }
.card-3d.is-flipped { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
}
.card-back {
  background: linear-gradient(145deg, #23144d, #110929);
  border: 1px solid var(--gold-dim);
  box-shadow: inset 0 0 18px rgba(230, 195, 92, 0.08);
}
.sigil { font-size: 1.6rem; color: var(--gold); opacity: 0.75; }

.card-front {
  background: linear-gradient(160deg, #2d1b5e 0%, #140a2e 100%);
  border: 1.5px solid var(--gold);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  transform: rotateY(180deg);
}
.card-emoji { font-size: 2.1rem; margin-bottom: 6px; transition: transform 0.3s; }
.card-emoji.reversed { transform: rotate(180deg); }
.card-name { font-size: 0.9rem; font-weight: 600; color: var(--gold); text-align: center; }
.card-pos {
  margin-top: 6px;
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  color: #ddd;
}
.card-pos.rev { color: #ff9e9e; background: rgba(255, 100, 100, 0.14); }

.hint-text { text-align: center; font-size: 0.82rem; color: var(--text-muted); margin: 0; }

/* 按钮 */
.action-bar { display: flex; justify-content: center; }
.btn-primary, .btn-gold {
  width: 100%;
  padding: 13px 24px;
  border-radius: 14px;
  font-size: 0.95rem;
  font-family: var(--font-zh);
  letter-spacing: 2px;
  cursor: pointer;
  transition: 0.25s;
}
.btn-primary {
  background: rgba(230, 195, 92, 0.12);
  border: 1px solid var(--gold);
  color: var(--gold);
  font-weight: 600;
}
.btn-gold {
  background: linear-gradient(135deg, #f0d278, #cfa63c);
  border: none;
  color: #140c00;
  font-weight: 900;
  box-shadow: 0 4px 20px rgba(230, 195, 92, 0.3);
}
.btn-gold:disabled { opacity: 0.6; cursor: wait; }

/* AI 解读面板 */
.insight-box { border-radius: 18px; padding: 20px; }
.insight-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--gold);
  font-weight: 600;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gold-dim);
  margin-bottom: 14px;
}
.insight-body { font-size: 0.95rem; line-height: 1.85; color: #ece8f5; white-space: pre-wrap; }

.btn-text { background: none; border: none; color: var(--text-muted); font-size: 0.82rem; cursor: pointer; font-family: var(--font-zh); }
.btn-outline { background: rgba(230, 195, 92, 0.12); border: 1px solid var(--gold); color: var(--gold); padding: 8px 16px; border-radius: 10px; font-size: 0.82rem; cursor: pointer; font-family: var(--font-zh); }

/* 悬浮按钮与牌库 */
.fab-lib {
  position: fixed;
  right: 18px;
  bottom: 22px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(22, 16, 46, 0.85);
  border: 1px solid var(--gold);
  color: var(--gold);
  font-family: var(--font-zh);
  font-size: 0.78rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
  z-index: 50;
}
.overlay { position: fixed; inset: 0; background: var(--bg-deep); z-index: 100; overflow-y: auto; padding: 18px; }
.lib-top { position: sticky; top: 0; background: var(--bg-deep); padding-bottom: 12px; z-index: 10; }
.lib-title-row { display: flex; justify-content: space-between; align-items: center; color: var(--gold); font-weight: 600; margin-bottom: 10px; }
#lib-search { width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--gold-dim); background: rgba(255,255,255,0.05); color: #fff; font-family: var(--font-zh); }
.lib-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.lib-item { background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; padding: 12px 6px; text-align: center; cursor: pointer; }

/* 弹窗 */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-card { width: 100%; max-width: 340px; border-radius: 20px; padding: 24px 20px; text-align: center; }
.modal-emoji { font-size: 2.6rem; margin-bottom: 6px; }
.modal-title { margin: 0 0 12px; color: var(--gold); font-size: 1.15rem; }
.modal-desc { font-size: 0.92rem; line-height: 1.65; color: #e2dff0; text-align: left; }
.modal-advice { margin-top: 14px; padding: 12px; background: rgba(230, 195, 92, 0.1); border-left: 3px solid var(--gold); border-radius: 0 8px 8px 0; text-align: left; font-size: 0.88rem; line-height: 1.6; }
.modal-actions { margin-top: 18px; display: flex; justify-content: space-between; align-items: center; }

.hidden { display: none !important; }
