/* ===========================
   CSS 变量 & 全局重置
   =========================== */
:root {
  --bg-primary:    #0B1020;
  --bg-secondary:  #141A2E;
  --bg-card:       #1C2440;
  --gold:          #D4AF37;
  --gold-light:    #F0D070;
  --gold-dim:      #8A7020;
  --text-primary:  #F5F1E8;
  --text-secondary:#B8B3A7;
  --text-muted:    #6B6660;
  --border-subtle: rgba(212, 175, 55, 0.18);
  --border-card:   rgba(212, 175, 55, 0.35);
  --shadow-glow:   0 0 24px rgba(212, 175, 55, 0.12);
  --shadow-card:   0 8px 32px rgba(0, 0, 0, 0.5);
  --radius-card:   18px;
  --radius-btn:    12px;
  --max-width:     480px;
}

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

html, body {
  height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ===========================
   屏幕切换
   =========================== */
.screen {
  display: none;
  min-height: 100dvh;
  width: 100%;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.screen-inner {
  width: 100%;
  max-width: var(--max-width);
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ===========================
   首页
   =========================== */
.home-header {
  text-align: center;
  padding: 56px 0 32px;
}

.title-glow {
  font-size: 28px;
  color: var(--gold);
  margin-bottom: 12px;
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.6; text-shadow: 0 0 8px var(--gold); }
  50%       { opacity: 1;   text-shadow: 0 0 20px var(--gold), 0 0 40px rgba(212,175,55,0.4); }
}

.app-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.app-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

.spread-section {
  flex: 1;
  padding: 8px 0 24px;
}

.spread-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding-left: 2px;
}

.spread-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.spread-card {
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  position: relative;
  overflow: hidden;
}

.spread-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(212,175,55,0.04) 0%, transparent 60%);
  pointer-events: none;
}

.spread-card:active {
  transform: scale(0.98);
}

.spread-card.selected {
  border-color: var(--gold);
  box-shadow: var(--shadow-glow), inset 0 0 0 1px rgba(212,175,55,0.12);
}

.spread-card-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.spread-card.selected .spread-card-name {
  color: var(--gold-light);
}

.spread-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.spread-card-count {
  position: absolute;
  top: 18px;
  right: 18px;
  font-size: 11px;
  color: var(--gold-dim);
  letter-spacing: 0.08em;
}

.spread-card.selected .spread-card-count {
  color: var(--gold);
}

.home-footer {
  padding: 16px 0 40px;
}

/* ===========================
   按钮
   =========================== */
.btn-primary {
  display: block;
  width: 100%;
  height: 52px;
  background: linear-gradient(135deg, #D4AF37 0%, #B8961E 100%);
  color: #0B1020;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(212, 175, 55, 0.3);
}

.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(212, 175, 55, 0.2);
}

.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  display: block;
  width: 100%;
  height: 52px;
  background: transparent;
  color: var(--gold);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  border: 1.5px solid var(--gold);
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.btn-secondary:active {
  background: rgba(212, 175, 55, 0.08);
  transform: scale(0.97);
}

.btn-ghost {
  display: block;
  width: 100%;
  height: 48px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, transform 0.15s;
}

.btn-ghost:active {
  color: var(--text-primary);
  border-color: rgba(212,175,55,0.3);
  transform: scale(0.97);
}

.btn-back {
  display: flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  padding: 8px 0;
  transition: color 0.2s;
  min-width: 60px;
}

.btn-back:active { color: var(--text-primary); }

.hidden { display: none !important; }

/* ===========================
   抽牌页
   =========================== */
.draw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 12px;
  gap: 8px;
}

.draw-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  flex: 1;
  letter-spacing: 0.04em;
}

.draw-header-spacer {
  min-width: 60px;
}

.draw-hint {
  text-align: center;
  padding: 12px 0 20px;
}

.draw-hint p {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.hint-sub {
  font-size: 13px;
  color: var(--text-muted) !important;
}

/* 卡牌区域 */
.card-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 8px 0 24px;
  flex: 1;
}

.card-area.multi {
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

/* 单张牌卡 */
.card-slot {
  width: 180px;
  flex-shrink: 0;
}

.card-area.multi .card-slot {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* 翻牌容器：3D 透视 */
.card-flip {
  perspective: 900px;
  width: 180px;
  aspect-ratio: 2/3;
  flex-shrink: 0;
}

.card-area.multi .card-flip {
  width: 120px;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: var(--radius-card);
}

.card-inner.flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-card);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

/* 牌背 */
.card-back {
  background: var(--bg-card);
  border: 1.5px solid var(--border-card);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-card);
  animation: float 4s ease-in-out infinite;
}

.card-back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(var(--radius-card) - 1px);
  opacity: 0.9;
}

/* 牌正面 */
.card-front {
  transform: rotateY(180deg);
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

.card-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: calc(var(--radius-card) - 1px);
}

.card-front img.reversed {
  transform: rotate(180deg);
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

/* 卡牌旁边的位置信息（三张牌排列时） */
.card-slot-info {
  flex: 1;
  min-width: 0;
}

.card-slot-position {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 3px;
}

.card-slot-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.card-slot-orientation {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.orientation-upright {
  background: rgba(212, 175, 55, 0.12);
  color: var(--gold);
  border: 1px solid rgba(212, 175, 55, 0.3);
}

.orientation-reversed {
  background: rgba(139, 92, 246, 0.12);
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.draw-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 0 40px;
}

/* ===========================
   解读页
   =========================== */
.reading-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 12px;
  gap: 8px;
}

.reading-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  flex: 1;
}

.reading-spread-name {
  text-align: center;
  font-size: 13px;
  color: var(--gold-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 20px;
}

.reading-cards {
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
  padding-bottom: 12px;
}

/* 解读卡片 */
.reading-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.reading-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.reading-card-header {
  display: flex;
  align-items: stretch;
  gap: 0;
}

.reading-card-img {
  width: 90px;
  flex-shrink: 0;
  background: var(--bg-primary);
  overflow: hidden;
}

.reading-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.reading-card-img img.reversed {
  transform: rotate(180deg);
}

.reading-card-meta {
  flex: 1;
  padding: 14px 14px 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}

.reading-position-tag {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-dim);
}

.reading-card-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.reading-card-name-en {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.reading-card-body {
  padding: 14px 16px 18px;
  border-top: 1px solid var(--border-subtle);
}

.reading-position-template {
  font-size: 13px;
  color: var(--gold-dim);
  font-style: italic;
  margin-bottom: 8px;
  line-height: 1.5;
}

.reading-card-meaning {
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.7;
}

/* 解读页底部 */
.reading-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 0 40px;
}

/* ===========================
   骨架背景装饰
   =========================== */
body::before {
  content: '';
  position: fixed;
  top: -200px;
  right: -150px;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(212, 175, 55, 0.04) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  bottom: -150px;
  left: -100px;
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, rgba(80, 40, 140, 0.06) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.screen-inner {
  position: relative;
  z-index: 1;
}

/* ===========================
   滚动条美化
   =========================== */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 2px;
}

/* ===========================
   响应式：较大屏幕居中
   =========================== */
@media (min-width: 520px) {
  .screen.active {
    padding: 0 20px;
    background-image: linear-gradient(to bottom, rgba(20,26,46,0.5) 0%, transparent 100%);
  }
}

/* ===========================
   首页 → 所有牌按钮间距
   =========================== */
.home-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ===========================
   分步抽牌 — 步骤信息区
   =========================== */
.draw-step-info {
  text-align: center;
  padding: 4px 0 16px;
}

.draw-progress-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.pdot {
  height: 8px;
  border-radius: 4px;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.pdot-pending {
  width: 8px;
  background: rgba(212, 175, 55, 0.18);
}

.pdot-active {
  width: 22px;
  background: var(--gold);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.55);
}

.pdot-done {
  width: 8px;
  background: var(--gold-dim);
}

.draw-step-counter {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.draw-position-label {
  font-size: 26px;
  font-weight: 700;
  color: var(--gold-light);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}

.draw-position-template {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 300px;
  margin: 0 auto;
}

/* 分步模式 card-area */
.card-area.step-mode {
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.card-area.fade-in {
  animation: fade-in 0.35s ease;
}

/* 翻牌后卡牌信息 */
.card-drawn-info {
  text-align: center;
  animation: fade-in-up 0.3s ease;
}

.card-drawn-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.card-drawn-en {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===========================
   已抽出的牌缩略条
   =========================== */
.drawn-strip {
  display: flex;
  gap: 12px;
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0 0 4px;
}

.drawn-stub {
  text-align: center;
  width: 60px;
  flex-shrink: 0;
}

.drawn-stub-img {
  width: 60px;
  height: 90px;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--border-card);
  margin-bottom: 5px;
  background: var(--bg-primary);
}

.drawn-stub-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.drawn-stub-img img.reversed {
  transform: rotate(180deg);
}

.drawn-stub-pos {
  font-size: 10px;
  color: var(--gold-dim);
  letter-spacing: 0.06em;
  margin-bottom: 1px;
}

.drawn-stub-name {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.drawn-stub-ori {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 10px;
}

/* ===========================
   所有牌页
   =========================== */
.cards-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 12px;
  gap: 8px;
}

.cards-page-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  flex: 1;
}

.cards-search-wrap {
  padding: 4px 0 10px;
}

.cards-search-wrap input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 15px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

.cards-search-wrap input::placeholder {
  color: var(--text-muted);
}

.cards-search-wrap input:focus {
  border-color: rgba(212, 175, 55, 0.5);
}

.cards-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 0 14px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.cards-tabs::-webkit-scrollbar { display: none; }

.cards-tab {
  flex-shrink: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.cards-tab.active {
  background: rgba(212, 175, 55, 0.1);
  border-color: var(--gold);
  color: var(--gold);
}

.cards-tab:active {
  transform: scale(0.96);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding-bottom: 48px;
}

.cards-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  padding: 48px 0;
  font-size: 14px;
}

.card-item {
  cursor: pointer;
  text-align: center;
  transition: transform 0.15s;
}

.card-item:active {
  transform: scale(0.95);
}

.card-item-img {
  aspect-ratio: 2/3;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
  margin-bottom: 5px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.card-item:hover .card-item-img,
.card-item:focus .card-item-img {
  border-color: rgba(212, 175, 55, 0.45);
  box-shadow: 0 4px 14px rgba(0,0,0,0.45);
}

.card-item-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-item-name {
  font-size: 11px;
  color: var(--text-primary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}

.card-item-en {
  font-size: 10px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===========================
   卡牌详情模态框
   =========================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-card);
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: var(--max-width);
  max-height: 88dvh;
  overflow-y: auto;
  position: relative;
  padding: 28px 20px 48px;
  animation: slide-up 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-overflow-scrolling: touch;
}

@keyframes slide-up {
  from { transform: translateY(100%); opacity: 0.6; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1;
  transition: color 0.2s, border-color 0.2s;
}

.modal-close:hover { color: var(--text-primary); border-color: rgba(212,175,55,0.4); }

.modal-card-layout {
  display: flex;
  gap: 18px;
  margin-bottom: 22px;
  align-items: flex-start;
}

.modal-card-img {
  width: 100px;
  aspect-ratio: 2/3;
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-card);
}

.modal-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.modal-card-info {
  flex: 1;
  padding-top: 2px;
}

.modal-arcana-tag {
  font-size: 11px;
  color: var(--gold-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.modal-card-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.3;
}

.modal-card-en {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.modal-meanings {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-meaning-block {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 14px;
}

.modal-meaning-label {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.modal-meaning-text {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.75;
}
