/* --- 全局：梦幻蓝紫星空 --- */
:root {
  /* 高级编辑感：英文 Times New Roman，中文宋体 */
  --font-base: "Times New Roman", Times, Georgia, "Songti SC", "Noto Serif SC",
    "STSong", "SimSun", serif;
}

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

body {
  font-family: var(--font-base);
  font-weight: 300;
  background: radial-gradient(circle at center, #1a0b2e 0%, #05021a 100%);
  color: #e0d5ff;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background-image:
    radial-gradient(white, rgba(255,255,255,.2) 2px, transparent 40px),
    radial-gradient(white, rgba(255,255,255,.15) 1px, transparent 30px);
  background-size: 550px 550px, 350px 350px;
  background-position: 0 0, 40px 60px;
  opacity: 0.2;
  pointer-events: none;
  z-index: 0;
}

/* --- 顶部导航 --- */
.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(138, 99, 255, 0.15);
}

.logo {
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: 1px;
  color: #bfa3ff;
  text-shadow: 0 0 12px rgba(138, 99, 255, 0.5);
}

.user-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quota-tip {
  font-size: 0.8rem;
  color: #a291c9;
}

/* 右上角图标按钮 */
.icon-btn {
  background: rgba(138, 99, 255, 0.12);
  border: 1px solid rgba(138, 99, 255, 0.4);
  color: #e0d5ff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  padding: 0;
}

.icon-btn:hover {
  background: rgba(138, 99, 255, 0.28);
  box-shadow: 0 0 10px rgba(138, 99, 255, 0.35);
  transform: translateY(-1px);
}

/* --- 主体 --- */
.container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  text-align: center;
}

h1 {
  font-family: var(--font-base);
  font-size: 2.6rem;
  font-weight: 300;
  color: #d9ccff;
  text-shadow: 0 0 10px rgba(138, 99, 255, 0.35);
  margin: 24px 0 30px;
  letter-spacing: 6px;
}

.magic-btn {
  background: linear-gradient(135deg, #6d31ed 0%, #b341f3 100%);
  border: none;
  color: #fff;
  padding: 12px 35px;
  font-size: 1.05rem;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(109, 49, 237, 0.4);
  transition: all 0.3s ease;
  font-family: inherit;
  font-weight: 500;
}

.magic-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(179, 65, 243, 0.6);
  filter: brightness(1.1);
}

.magic-btn.full {
  width: 100%;
  margin-top: 12px;
}

.page {
  display: none;
  animation: fadeIn 0.6s ease forwards;
}

.page.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- 阶段 1 --- */
.hint {
  margin-bottom: 20px;
  color: #a585ff;
}

.input-box {
  width: 100%;
  max-width: 500px;
  height: 120px;
  background: rgba(26, 13, 50, 0.6);
  border: 1px solid rgba(165, 133, 255, 0.4);
  border-radius: 16px;
  padding: 15px;
  color: #fff;
  font-size: 1.05rem;
  font-family: inherit;
  resize: none;
  outline: none;
  box-shadow: inset 0 0 10px rgba(138, 99, 255, 0.2), 0 0 20px rgba(0,0,0,0.5);
  margin-bottom: 25px;
  transition: border 0.3s;
}

.input-box:focus {
  border-color: #00d2ff;
}

/* --- 阶段 2：洗牌 --- */
.shuffling {
  color: #00d2ff;
  text-shadow: 0 0 8px rgba(0, 210, 255, 0.4);
  margin-top: 20px;
}

.shuffle-0 { animation: floatY 1.2s ease-in-out infinite alternate; }
.shuffle-1 { animation: floatY 1.2s ease-in-out 0.2s infinite alternate; }
.shuffle-2 { animation: floatY 1.2s ease-in-out 0.4s infinite alternate; }

@keyframes floatY {
  from { transform: translateY(0) rotate(-2deg); }
  to { transform: translateY(-12px) rotate(2deg); }
}

/* --- 卡牌 3D --- */
.card-container {
  display: flex;
  justify-content: center;
  gap: 25px;
  margin: 40px auto;
  flex-wrap: wrap;
  perspective: 1000px;
}

.card {
  position: relative;
  width: 160px;
  aspect-ratio: 7 / 12;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 12px;
  border: 2px solid rgba(165, 133, 255, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  text-align: center;
  overflow: hidden;
}

.card-back {
  background: linear-gradient(135deg, #2e114d 0%, #0b0320 100%);
  background-image:
    radial-gradient(rgba(138, 99, 255, 0.2) 1px, transparent 0),
    linear-gradient(45deg, transparent 45%, rgba(138, 99, 255, 0.1) 50%, transparent 55%),
    linear-gradient(-45deg, transparent 45%, rgba(138, 99, 255, 0.1) 50%, transparent 55%);
  background-size: 20px 20px, 40px 40px, 40px 40px;
  aspect-ratio: 7 / 12;
}

.card-back::after {
  content: '✨';
  font-size: 2rem;
  text-shadow: 0 0 10px #8a63ff;
  animation: pulse 2s infinite alternate;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.6; }
  100% { transform: scale(1.1); opacity: 1; }
}

.card-front {
  background: linear-gradient(135deg, #150a21 0%, #251b45 100%);
  transform: rotateY(180deg);
  color: #fff;
  justify-content: flex-start;
  gap: 2px;
  padding: 8px;
}

.card-front .pos {
  font-size: 0.72rem;
  color: #a585ff;
  flex-shrink: 0;
}

/* 图片容器占满剩余空间，contain 完整显示不裁切 */
.card-img-wrap {
  width: 100%;
  flex: 1;
  min-height: 0;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #11081c;
  box-shadow: 0 0 14px rgba(138, 99, 255, 0.35);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-front .card-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center;
  display: block;
}

.card-front .name {
  font-size: 0.95rem;
  font-weight: bold;
  color: #00d2ff;
  line-height: 1.3;
}

.card-front .status {
  font-size: 0.72rem;
  background: rgba(165, 133, 255, 0.2);
  padding: 2px 8px;
  border-radius: 10px;
  color: #a585ff;
}

.reversed-style {
  transform: rotate(180deg);
}

/* --- 阶段 3：功能区 --- */
.question-echo {
  font-style: italic;
  color: #a291c9;
  margin-bottom: 10px;
}

.ai-zone {
  margin-top: 35px;
  background: rgba(20, 10, 40, 0.4);
  padding: 20px;
  border-radius: 16px;
  border: 1px solid rgba(138, 99, 255, 0.2);
}

.ai-tips {
  font-size: 0.9rem;
  color: #a291c9;
  margin-bottom: 15px;
  line-height: 1.7;
}

.btn-group {
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
  margin-top: 15px;
}

.secondary-btn {
  background: rgba(138, 99, 255, 0.15);
  border: 1px solid #8a63ff;
  color: #e0d5ff;
  padding: 10px 20px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.3s;
  text-decoration: none;
  display: inline-block;
}

.secondary-btn:hover {
  background: rgba(138, 99, 255, 0.3);
  box-shadow: 0 0 10px rgba(138, 99, 255, 0.4);
}

/* 复制按钮行 */
.copy-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* AI 直达按钮区（logo 圆形小图标，一排排列） */
.ai-grid {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  margin-top: 14px;
}

.ai-logo-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(165, 133, 255, 0.3);
  background: rgba(20, 10, 40, 0.5);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  flex-shrink: 0;
}

.ai-logo-btn:hover {
  transform: translateY(-3px);
  border-color: rgba(0, 210, 255, 0.6);
  box-shadow: 0 0 12px rgba(0, 210, 255, 0.35);
}

.ai-logo-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 重新占卜：放大 + 非常浅的浅蓝 */
.again-btn {
  background: rgba(186, 230, 253, 0.12);
  border: 1px solid rgba(186, 230, 253, 0.5);
  color: #e0f2fe;
  padding: 14px 44px;
  font-size: 1.05rem;
  border-radius: 30px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.3s ease;
  letter-spacing: 1px;
}

.again-btn:hover {
  background: rgba(186, 230, 253, 0.22);
  border-color: rgba(186, 230, 253, 0.75);
  box-shadow: 0 0 18px rgba(186, 230, 253, 0.4);
  transform: translateY(-2px);
}

/* --- 弹窗 --- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 2, 26, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  animation: fadeIn 0.3s ease;
  padding: 20px;
}

.modal-card {
  position: relative;
  width: 90%;
  max-width: 380px;
  background: linear-gradient(160deg, #1d0f38 0%, #0b0320 100%);
  border: 1px solid rgba(165, 133, 255, 0.35);
  border-radius: 20px;
  padding: 30px 26px;
  box-shadow: 0 0 40px rgba(109, 49, 237, 0.35);
  text-align: center;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-card h2 {
  color: #bfa3ff;
  font-size: 1.3rem;
  margin-bottom: 8px;
  text-align: center;
  font-weight: 500;
}

.modal-tip {
  font-size: 0.85rem;
  color: #a291c9;
  margin-bottom: 18px;
  text-align: center;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: #a291c9;
  font-size: 1.1rem;
  cursor: pointer;
  transition: color 0.2s;
}

.modal-close:hover {
  color: #fff;
}

.modal-msg {
  margin-top: 12px;
  font-size: 0.85rem;
  color: #00d2ff;
  min-height: 1.2em;
  text-align: center;
}

/* --- 赞赏码弹窗 --- */
.donate-card {
  max-width: 420px;
}

.donate-thanks {
  font-size: 0.95rem;
  color: #f4c0d1;
  margin-bottom: 16px;
  text-align: center;
}

.donate-qr {
  width: 100%;
  max-width: 340px;
  border-radius: 12px;
  border: 1px solid rgba(165, 133, 255, 0.3);
  display: block;
  margin: 0 auto;
  box-shadow: 0 0 20px rgba(138, 99, 255, 0.25);
}

/* --- 邮箱弹窗 --- */
.mail-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 6px;
}

.mail-addr {
  font-family: "Times New Roman", serif;
  font-size: 1.05rem;
  color: #00d2ff;
  letter-spacing: 0.5px;
  word-break: break-all;
}

.mail-row .magic-btn {
  padding: 8px 20px;
  font-size: 0.9rem;
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 10, 40, 0.95);
  border: 1px solid rgba(138, 99, 255, 0.5);
  color: #e0d5ff;
  padding: 10px 22px;
  border-radius: 20px;
  font-size: 0.9rem;
  z-index: 20;
  box-shadow: 0 0 20px rgba(109, 49, 237, 0.4);
  animation: fadeIn 0.3s ease;
}

.hidden {
  display: none !important;
}

/* --- 手机适配 --- */
@media (max-width: 600px) {
  h1 { font-size: 1.7rem; margin: 16px 0 20px; }
  .card { width: 100px; }
  .card-front { padding: 6px; gap: 1px; }
  .card-front .name { font-size: 0.68rem; }
  .card-front .pos { font-size: 0.58rem; }
  .card-front .status { font-size: 0.56rem; }
  .card-container { gap: 8px; margin: 20px auto; }
  .topbar { padding: 12px 14px; }
  .logo { font-size: 0.95rem; }
  /* 结果页功能区压缩 */
  .ai-zone { margin-top: 20px; padding: 14px; }
  .ai-tips { font-size: 0.8rem; margin-bottom: 10px; }
  .copy-row .magic-btn { padding: 10px 24px; font-size: 0.95rem; }
  .ai-grid { gap: 8px; }
  .ai-logo-btn { width: 34px; height: 34px; }
  .again-btn { padding: 12px 32px; font-size: 0.95rem; }
  .question-echo { font-size: 0.85rem; margin-bottom: 6px; }
  .btn-group { margin-top: 12px; }
}

/* 超窄屏（≤380px，如 iPhone SE）进一步压缩 */
@media (max-width: 380px) {
  .card { width: 88px; }
  .card-container { gap: 6px; }
  .ai-logo-btn { width: 30px; height: 30px; }
}
