/* 星盘塔罗 · 华丽金箔风 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;700;900&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --gold: #d4af37;
  --gold-light: #f4e4a8;
  --gold-dark: #8a6d1f;
  --bg: #0a0912;
  --bg2: #14101f;
  --text: #e8dcc0;
  --text-dim: #a8946a;
}

html, body {
  min-height: 100vh;
}

body {
  font-family: 'Noto Serif SC', 'Songti SC', serif;
  background: radial-gradient(ellipse at 50% -20%, #2a1e3f 0%, var(--bg) 55%, #05040a 100%);
  color: var(--text);
  overflow-x: hidden;
  position: relative;
}

/* 星空背景 */
.bg-stars {
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(1px 1px at 8% 15%, rgba(255,255,255,.5), transparent),
    radial-gradient(1px 1px at 22% 70%, rgba(255,255,255,.35), transparent),
    radial-gradient(1.5px 1.5px at 35% 30%, rgba(255,255,255,.45), transparent),
    radial-gradient(1px 1px at 48% 85%, rgba(255,255,255,.3), transparent),
    radial-gradient(1.5px 1.5px at 60% 12%, rgba(255,255,255,.5), transparent),
    radial-gradient(1px 1px at 72% 55%, rgba(255,255,255,.4), transparent),
    radial-gradient(1.5px 1.5px at 85% 25%, rgba(255,255,255,.45), transparent),
    radial-gradient(1px 1px at 93% 75%, rgba(255,255,255,.35), transparent);
  animation: twinkle 4s ease-in-out infinite alternate;
}
@keyframes twinkle {
  0% { opacity: .6; }
  100% { opacity: 1; }
}

/* 金色光晕 */
.bg-glow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(212,175,55,.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(120,80,200,.06) 0%, transparent 50%);
}

/* 头部 */
.header {
  text-align: center;
  padding: 3rem 1rem 1.5rem;
}
.title {
  font-size: 2.6rem;
  font-weight: 900;
  letter-spacing: .4em;
  text-indent: .4em;
  background: linear-gradient(180deg, #fff7d6 0%, var(--gold) 45%, #8a6d1f 80%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 30px rgba(212,175,55,.25);
  animation: titleGlow 3s ease-in-out infinite alternate;
}
@keyframes titleGlow {
  0% { filter: drop-shadow(0 0 8px rgba(212,175,55,.3)); }
  100% { filter: drop-shadow(0 0 22px rgba(212,175,55,.6)); }
}
.subtitle {
  margin-top: .8rem;
  color: var(--text-dim);
  font-size: .95rem;
  letter-spacing: .2em;
}

/* 面板 */
.main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}
.panel {
  display: none;
  background: linear-gradient(160deg, rgba(30,24,48,.9), rgba(16,12,28,.95));
  border: 1px solid rgba(212,175,55,.35);
  border-radius: 18px;
  padding: 2.2rem;
  box-shadow:
    0 0 0 1px rgba(212,175,55,.08),
    0 20px 60px rgba(0,0,0,.55),
    inset 0 0 60px rgba(212,175,55,.04);
  position: relative;
}
.panel.active { display: block; animation: fadeUp .6s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}
.panel::before {
  content: '';
  position: absolute; inset: 8px;
  border: 1px solid rgba(212,175,55,.15);
  border-radius: 12px;
  pointer-events: none;
}
.panel-inner { position: relative; }

/* 表单 */
.field-label {
  display: block;
  margin: 1.2rem 0 .6rem;
  color: var(--gold-light);
  font-weight: 700;
  letter-spacing: .15em;
  font-size: .95rem;
}
textarea {
  width: 100%;
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(212,175,55,.3);
  border-radius: 10px;
  color: var(--text);
  padding: .9rem 1rem;
  font-family: inherit;
  font-size: 1rem;
  resize: vertical;
  transition: border-color .3s, box-shadow .3s;
}
textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212,175,55,.15);
}
textarea::placeholder { color: rgba(232,220,192,.3); }

/* 牌阵选择 */
.spread-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .8rem;
  margin-bottom: .4rem;
}
.spread-item {
  background: rgba(0,0,0,.3);
  border: 1px solid rgba(212,175,55,.25);
  border-radius: 12px;
  padding: .9rem 1rem;
  cursor: pointer;
  transition: all .25s;
  position: relative;
  overflow: hidden;
}
.spread-item:hover {
  border-color: var(--gold);
  background: rgba(212,175,55,.08);
  transform: translateY(-2px);
}
.spread-item.selected {
  border-color: var(--gold);
  background: rgba(212,175,55,.15);
  box-shadow: 0 0 18px rgba(212,175,55,.2), inset 0 0 20px rgba(212,175,55,.06);
}
.spread-item.selected::after {
  content: '✦';
  position: absolute; top: .4rem; right: .7rem;
  color: var(--gold); font-size: .9rem;
}
.spread-item .s-name {
  font-weight: 700;
  color: var(--gold-light);
  margin-bottom: .25rem;
}
.spread-item .s-count {
  font-size: .75rem;
  color: var(--text-dim);
}

/* 按钮 */
.btn-gold {
  display: block;
  width: 100%;
  margin-top: 1.8rem;
  padding: .95rem 1.5rem;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: .3em;
  text-indent: .3em;
  color: #1a1408;
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 40%, #a8832b 100%);
  border: 1px solid #f5e6a8;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(212,175,55,.35), inset 0 1px 0 rgba(255,255,255,.5);
  transition: all .25s;
}
.btn-gold:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(212,175,55,.5), inset 0 1px 0 rgba(255,255,255,.6);
}
.btn-gold:active { transform: translateY(0); }

.btn-ghost {
  display: inline-block;
  padding: .7rem 1.4rem;
  font-family: inherit;
  font-size: .95rem;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid rgba(212,175,55,.3);
  border-radius: 10px;
  cursor: pointer;
  transition: all .25s;
}
.btn-ghost:hover { color: var(--gold-light); border-color: var(--gold); }

.actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.8rem;
  flex-wrap: wrap;
}
.actions .btn-gold { width: auto; margin-top: 0; flex: 1; min-width: 220px; }

/* 牌阵标题 */
.spread-name {
  color: var(--gold-light);
  font-size: 1.5rem;
  letter-spacing: .1em;
  margin-bottom: .4rem;
}
.spread-desc { color: var(--text-dim); font-size: .9rem; margin-bottom: 1.6rem; }

/* 卡牌舞台（翻牌动画） */
.card-stage {
  display: flex;
  justify-content: center;
  gap: 1.2rem;
  flex-wrap: wrap;
  margin: 1.5rem 0 2rem;
  min-height: 320px;
  perspective: 1400px;
}
.stage-card {
  width: 150px;
  height: 260px;
  position: relative;
  transform-style: preserve-3d;
  animation: cardDeal .8s cubic-bezier(.2,.8,.3,1.2) backwards;
  cursor: pointer;
}
@keyframes cardDeal {
  0% { transform: translateY(-120px) rotateX(70deg) rotateZ(15deg); opacity: 0; }
  100% { transform: translateY(0) rotateX(0) rotateZ(0); opacity: 1; }
}
.stage-card .card-face {
  position: absolute; inset: 0;
  border-radius: 12px;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0,0,0,.6), 0 0 0 1px rgba(212,175,55,.4);
}
.stage-card .card-front {
  background:
    radial-gradient(circle at 50% 40%, rgba(212,175,55,.18), transparent 70%),
    linear-gradient(160deg, #241a3a, #120d20);
  transform: rotateY(180deg);
}
.stage-card .card-front img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.stage-card .card-back {
  background:
    radial-gradient(circle at 50% 45%, rgba(212,175,55,.25), transparent 60%),
    repeating-linear-gradient(45deg, #2a1e3f 0 12px, #1d1530 12px 24px);
  border: 3px solid var(--gold);
}
.stage-card .card-back::before {
  content: '✦';
  font-size: 3rem;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(212,175,55,.7);
}
.stage-card.flipped .card-front { transform: rotateY(0); }
.stage-card.flipped .card-back { transform: rotateY(180deg); }
.stage-card .card-face { transition: transform .8s cubic-bezier(.4,.2,.2,1); }

/* 卡片网格（详情） */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.2rem;
  margin-top: 1rem;
}
.card-detail {
  background: rgba(0,0,0,.32);
  border: 1px solid rgba(212,175,55,.25);
  border-radius: 14px;
  padding: 1.1rem 1.2rem;
  transition: all .3s;
}
.card-detail:hover { border-color: rgba(212,175,55,.6); transform: translateY(-3px); }
.card-detail .d-position {
  font-size: .78rem;
  color: var(--gold);
  letter-spacing: .1em;
  margin-bottom: .4rem;
}
.card-detail .d-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gold-light);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.card-detail .d-dir {
  font-size: .72rem;
  padding: .15rem .5rem;
  border-radius: 6px;
  letter-spacing: .08em;
}
.d-dir.upright { background: rgba(212,175,55,.18); color: var(--gold-light); border: 1px solid rgba(212,175,55,.4); }
.d-dir.reversed { background: rgba(180,70,90,.18); color: #e8a0ac; border: 1px solid rgba(180,70,90,.4); }
.card-detail .d-keywords {
  margin-top: .5rem;
  color: var(--text-dim);
  font-size: .85rem;
}
.card-detail .d-thumb {
  margin-top: .7rem;
  text-align: center;
}
.card-detail .d-thumb img {
  height: 110px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.5), 0 0 0 1px rgba(212,175,55,.3);
}
.card-detail .d-text {
  margin-top: .6rem;
  font-size: .85rem;
  line-height: 1.7;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-detail .d-text.more {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}

/* Prompt 输出 */
.prompt-box {
  margin-top: 2rem;
  background: rgba(0,0,0,.45);
  border: 1px solid rgba(212,175,55,.35);
  border-radius: 14px;
  overflow: hidden;
}
.prompt-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .8rem 1.2rem;
  background: rgba(212,175,55,.12);
  border-bottom: 1px solid rgba(212,175,55,.25);
  font-size: .9rem;
  color: var(--gold-light);
}
.btn-copy {
  font-family: inherit;
  font-size: .82rem;
  padding: .35rem .9rem;
  background: var(--gold);
  color: #1a1408;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  transition: all .2s;
}
.btn-copy:hover { background: var(--gold-light); }
#prompt-text {
  padding: 1.2rem;
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: .82rem;
  line-height: 1.65;
  color: #d8d0b8;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow-y: auto;
}

.hidden { display: none !important; }

/* 引导提示 */
.guide {
  text-align: center;
  color: var(--gold-light);
  font-size: .95rem;
  letter-spacing: .1em;
  margin: .4rem 0 1.2rem;
  min-height: 1.6rem;
  transition: all .3s;
}
.guide.hint-glow { animation: hintPulse 1.6s ease-in-out infinite; }
@keyframes hintPulse {
  0%, 100% { opacity: .7; }
  50% { opacity: 1; text-shadow: 0 0 14px rgba(212,175,55,.8); }
}

/* 牌堆（牌背） */
.deck-wrap {
  position: relative;
  width: 190px;
  height: 290px;
  margin: .5rem auto 1.8rem;
  cursor: pointer;
  user-select: none;
  transition: transform .25s;
}
.deck-wrap:hover { transform: translateY(-6px); }
.deck-wrap:active { transform: scale(.97); }
.deck-wrap.disabled { pointer-events: none; opacity: .35; }
.deck {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 50% 45%, rgba(212,175,55,.3), transparent 62%),
    repeating-linear-gradient(45deg, #2a1e3f 0 14px, #1d1530 14px 28px);
  border: 3px solid var(--gold);
  border-radius: 14px;
  box-shadow: 0 14px 40px rgba(0,0,0,.65), 0 0 0 1px rgba(212,175,55,.3), inset 0 0 30px rgba(212,175,55,.12);
  display: flex;
  align-items: center;
  justify-content: center;
}
.deck::before {
  content: '✦';
  font-size: 3.6rem;
  color: var(--gold);
  text-shadow: 0 0 22px rgba(212,175,55,.8);
  transition: transform .3s;
}
.deck-wrap:hover .deck::before { transform: scale(1.15) rotate(15deg); }
/* 叠牌厚度感 */
.deck::after {
  content: '';
  position: absolute; inset: 6px;
  border: 1px solid rgba(212,175,55,.28);
  border-radius: 10px;
}
.deck-shadow {
  position: absolute; inset: 12px -6px -8px;
  background: rgba(0,0,0,.5);
  border-radius: 20px;
  filter: blur(14px);
  z-index: -1;
}
/* 洗牌动画 */
.deck-wrap.shuffling .deck {
  animation: shuffleSpin 1.1s cubic-bezier(.4,.2,.2,1) 2;
}
@keyframes shuffleSpin {
  0% { transform: rotate(0) scale(1); }
  25% { transform: rotate(-8deg) scale(.96); }
  50% { transform: rotate(6deg) scale(1.04); }
  75% { transform: rotate(-5deg) scale(.97); }
  100% { transform: rotate(0) scale(1); }
}

/* 牌阵位置槽位 */
.slots {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin: .5rem 0 1.5rem;
  perspective: 1400px;
}
.slot {
  width: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .45rem;
}
.slot .slot-pos {
  font-size: .72rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.4;
  min-height: 2.4rem;
  letter-spacing: .04em;
}
.slot .slot-pos b {
  display: block;
  color: var(--gold);
  font-size: .8rem;
  margin-bottom: .15rem;
}
.slot-placeholder {
  width: 120px;
  height: 200px;
  border: 2px dashed rgba(212,175,55,.3);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(212,175,55,.35);
  font-size: 1.4rem;
  transition: all .3s;
}
.slot.fill .slot-placeholder { display: none; }

/* 翻牌卡片 */
.flip-card {
  width: 120px;
  height: 200px;
  position: relative;
  transform-style: preserve-3d;
  cursor: pointer;
  animation: cardDeal .6s cubic-bezier(.2,.8,.3,1.2) backwards;
}
@keyframes cardDeal {
  0% { transform: translateY(-90px) rotateX(60deg) rotateZ(10deg); opacity: 0; }
  100% { transform: translateY(0) rotateX(0) rotateZ(0); opacity: 1; }
}
.flip-card .card-face {
  position: absolute; inset: 0;
  border-radius: 10px;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 6px 22px rgba(0,0,0,.55), 0 0 0 1px rgba(212,175,55,.35);
  transition: transform .75s cubic-bezier(.4,.2,.2,1);
}
.flip-card .card-face img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.flip-card .card-back {
  background:
    radial-gradient(circle at 50% 45%, rgba(212,175,55,.28), transparent 62%),
    repeating-linear-gradient(45deg, #2a1e3f 0 14px, #1d1530 14px 28px);
  border: 3px solid var(--gold);
}
.flip-card .card-back::before {
  content: '✦';
  font-size: 2.2rem;
  color: var(--gold);
  text-shadow: 0 0 16px rgba(212,175,55,.7);
}
.flip-card .card-front { transform: rotateY(180deg); }
.flip-card.flipped .card-front { transform: rotateY(0); }
.flip-card.flipped .card-back { transform: rotateY(180deg); }
.flip-card .dir-tag {
  position: absolute;
  top: -1.1rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: .68rem;
  padding: .12rem .6rem;
  border-radius: 6px;
  letter-spacing: .1em;
  white-space: nowrap;
  z-index: 3;
}
.flip-card .dir-tag.up { background: rgba(212,175,55,.85); color: #1a1408; }
.flip-card .dir-tag.rev { background: rgba(180,70,90,.85); color: #ffe0e6; }

/* ◈◈ 78张牌背网格（手动翻牌） ◈◈ */
.grid-area {
  margin: .6rem 0 1.4rem;
}
.grid-tip {
  text-align: center;
  color: var(--gold-light);
  font-size: .9rem;
  letter-spacing: .08em;
  margin: 0 0 .5rem;
}
.fan-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  perspective: 1000px;
  max-height: 420px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid rgba(212,175,55,.18);
  border-radius: 14px;
  background: rgba(10,6,20,.35);
}
.fan-card {
  width: 58px;
  height: 88px;
  perspective: 800px;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  transition: transform .2s, opacity .3s;
}
.fan-card:hover { transform: translateY(-4px); }
.fan-card .fc-inner {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform .7s cubic-bezier(.4,.2,.2,1);
}
.fan-card .fc-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  border-radius: 7px;
  overflow: hidden;
  box-shadow: 0 3px 10px rgba(0,0,0,.5), 0 0 0 1px rgba(212,175,55,.3);
}
.fan-card .fc-face img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.fan-card .fc-back {
  background:
    radial-gradient(circle at 50% 45%, rgba(212,175,55,.3), transparent 62%),
    repeating-linear-gradient(45deg, #2a1e3f 0 12px, #1d1530 12px 24px);
  border: 2px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
}
.fan-card .fc-back::before {
  content: '✦';
  font-size: 1.4rem;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(212,175,55,.7);
}
.fan-card .fc-front { transform: rotateY(180deg); }
.fan-card.flipped .fc-inner { transform: rotateY(180deg); }
.fan-card.flipped { pointer-events: none; }
.fan-card.used {
  opacity: .3;
  filter: grayscale(.7);
  transform: scale(.9);
}
.fan-card .fc-dir {
  position: absolute;
  bottom: 2px; right: 2px;
  font-size: .5rem;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(0,0,0,.6);
  color: #ffd;
  z-index: 3;
}
.fan-card .fc-dir.rev { background: rgba(180,70,90,.8); }

/* 牌堆消失后的状态 */
.deck-wrap.done { opacity: 0; pointer-events: none; transform: scale(.6); transition: all .6s; }

/* 响应式 */
@media (max-width: 640px) {
  .deck-wrap { width: 150px; height: 230px; }
  .slot { width: 120px; }
  .slot-placeholder { width: 100px; height: 170px; }
  .flip-card { width: 100px; height: 170px; }
  .fan-card { width: 52px; height: 78px; }
}

/* 页脚 */
.footer {
  text-align: center;
  padding: 2rem 1rem 2.5rem;
  color: rgba(168,148,106,.4);
  font-size: .8rem;
  letter-spacing: .15em;
}

/* 响应式 */
@media (max-width: 640px) {
  .title { font-size: 1.9rem; }
  .panel { padding: 1.4rem; }
  .card-stage { min-height: 260px; }
  .stage-card { width: 110px; height: 190px; }
  .actions { flex-direction: column; }
  .actions .btn-gold { min-width: 100%; }
}
