/* --- 全局：梦幻蓝紫星空 --- */
: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;
}

.ghost-btn {
  background: rgba(138, 99, 255, 0.12);
  border: 1px solid rgba(138, 99, 255, 0.4);
  color: #e0d5ff;
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.3s;
}

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

/* 浅色底按钮（登录 / 注册） */
.light-btn {
  background: rgba(224, 213, 255, 0.18);
  border: 1px solid rgba(191, 163, 255, 0.5);
  color: #e0d5ff;
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.3s;
}
.light-btn:hover {
  background: rgba(224, 213, 255, 0.35);
  border-color: rgba(191, 163, 255, 0.75);
}

/* 密码输入框 + 眼睛图标 */
.pw-field {
  position: relative;
}
.pw-field input {
  width: 100%;
  padding-right: 40px;
  box-sizing: border-box;
}
.pw-eye {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  color: #a291c9;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  user-select: none;
  transition: color 0.2s;
}
.pw-eye:hover {
  color: #e0d5ff;
}

/* --- 主体 --- */
.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;
  height: 270px;
  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: 15px;
  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;
}

.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: space-between;
}

.card-front .pos {
  font-size: 0.78rem;
  color: #a585ff;
}

.card-front .icon {
  font-size: 2.2rem;
  line-height: 1.2;
  filter: drop-shadow(0 0 8px rgba(0, 210, 255, 0.6));
}

.card-front .img-placeholder {
  width: 85%;
  height: 42%;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background:
    radial-gradient(circle at 30% 30%, rgba(138, 99, 255, 0.35), transparent 60%),
    radial-gradient(circle at 70% 70%, rgba(0, 210, 255, 0.25), transparent 60%),
    #11081c;
}

.card-front .card-img {
  width: 88%;
  flex: 1;
  min-height: 0;
  margin: 4px 0;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #11081c;
  box-shadow: 0 0 14px rgba(138, 99, 255, 0.35);
}

.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;
}

.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;
}

/* 升级会员：浅粉色，与其他按钮区分 */
.pink-btn {
  background: rgba(244, 192, 209, 0.14);
  border: 1px solid #ed93b1;
  color: #f4c0d1;
  padding: 12px 26px;
  font-size: 1rem;
  border-radius: 30px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.3s ease;
}

.pink-btn:hover {
  background: rgba(244, 192, 209, 0.3);
  box-shadow: 0 4px 18px rgba(237, 147, 177, 0.45);
  transform: translateY(-2px);
}

/* AI 直达按钮区 */
.ai-grid {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}

/* --- 弹窗 --- */
.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;
}

.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;
}

.modal-card.wide {
  max-width: 560px;
  text-align: left;
}

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

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

.modal-card input {
  width: 100%;
  background: rgba(26, 13, 50, 0.7);
  border: 1px solid rgba(165, 133, 255, 0.4);
  border-radius: 12px;
  padding: 12px 14px;
  color: #fff;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  margin-bottom: 4px;
}

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

#codeArea input {
  margin-top: 14px;
  letter-spacing: 6px;
  text-align: center;
  font-size: 1.2rem;
}

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

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

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

.modal-switch {
  text-align: center;
  margin: 12px 0 0;
  font-size: 0.85rem;
}

.modal-switch a {
  color: #00d2ff;
  text-decoration: none;
  cursor: pointer;
}

.modal-switch a:hover {
  text-decoration: underline;
}

/* --- 历史记录 --- */
.history-list {
  max-height: 55vh;
  overflow-y: auto;
  margin-top: 16px;
}

.history-item {
  background: rgba(138, 99, 255, 0.08);
  border: 1px solid rgba(138, 99, 255, 0.2);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.history-item .q {
  font-size: 0.95rem;
  color: #e0d5ff;
  margin-bottom: 6px;
}

.history-item .c {
  font-size: 0.8rem;
  color: #a585ff;
  line-height: 1.6;
}

.history-item .t {
  font-size: 0.72rem;
  color: #6f6390;
  margin-top: 6px;
}

.history-empty {
  text-align: center;
  color: #6f6390;
  padding: 30px 0;
}

/* --- 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; }
  .card { width: 110px; height: 190px; }
  .card-front .icon { font-size: 1.5rem; }
  .card-front .name { font-size: 0.72rem; }
  .card-front .pos { font-size: 0.62rem; }
  .card-front .status { font-size: 0.6rem; }
  .card-container { gap: 12px; }
  .topbar { padding: 12px 14px; }
  .logo { font-size: 0.95rem; }
}
