/* ===== 变量 ===== */
:root {
  --warm-orange: #F4A460;
  --warm-orange-deep: #E8923E;
  --cream: #FFF8F0;
  --soft-pink: #FFD1D1;
  --soft-pink-deep: #FAB8B8;
  --warm-brown: #C4A882;
  --mint: #A8D8B9;
  --gold-light: #FDE8C8;
  --card-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
  --text-main: #F5F0E8;
  --text-muted: rgba(245, 240, 232, 0.65);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

/* ===== 基础 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-height: 100vh;
  color: var(--text-main);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #1a1520;
  overflow-x: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== 背景图片 ===== */
.bg-image {
  position: fixed;
  inset: 0;
  z-index: 0;
}
.bg-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.bg-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

/* ===== 主容器 ===== */
.app-shell {
  position: relative;
  z-index: 1;
  width: min(480px, 92vw);
  padding: 40px 28px;
  text-align: center;
}

/* ===== 标题 ===== */
.header { margin-bottom: 32px; }

.title {
  font-size: 2rem;
  font-weight: 700;
  color: #FDE8C8;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}
.subtitle {
  margin-top: 6px;
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* ===== 卡牌展示区 ===== */
.card-stage { position: relative; margin-bottom: 28px; }

.card-slot {
  position: relative;
  width: 260px;
  aspect-ratio: 941 / 1672;
  margin: 0 auto;
  perspective: 1000px;
}

/* 卡背 */
.card-back {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(255, 248, 240, 0.15), rgba(253, 232, 200, 0.12), rgba(255, 243, 224, 0.1));
  box-shadow: var(--card-shadow), inset 0 0 0 2px rgba(244, 164, 96, 0.25);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease, transform 0.5s ease;
  overflow: hidden;
}
.card-back::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: calc(var(--radius-lg) - 4px);
  border: 2px dashed rgba(244, 164, 96, 0.3);
}
.card-back__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.card-back__star {
  font-size: 2.4rem;
  color: var(--warm-orange);
  animation: starPulse 2s ease-in-out infinite;
}
.card-back__text {
  font-size: 2rem;
  font-weight: 700;
  color: var(--warm-brown);
}
@keyframes starPulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; }
}

/* 卡面 */
.card-front {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  box-shadow: var(--card-shadow);
  transition: opacity 0.4s ease;
}
.card-front.show {
  opacity: 1;
  pointer-events: auto;
}
.card-front__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-front__glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.15) 0%, transparent 70%);
  pointer-events: none;
}

/* 卡牌名称 */
.card-name {
  margin-top: 16px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  text-shadow: 0 1px 8px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.card-name.show {
  opacity: 1;
  transform: translateY(0);
}

/* ===== 旋转动画 ===== */
.card-slot.spinning .card-back {
  animation: cardFloat 1.5s ease-in-out forwards;
}
.card-slot.revealing .card-back {
  animation: cardRevealOut 0.5s ease-in forwards;
}
.card-slot.revealing .card-front {
  animation: cardRevealIn 0.5s ease-out 0.1s forwards;
}

@keyframes cardFloat {
  0% { transform: rotateY(0deg) translateY(0) scale(1); }
  20% { transform: rotateY(60deg) translateY(-16px) scale(1.04); }
  40% { transform: rotateY(180deg) translateY(-10px) scale(1.06); }
  60% { transform: rotateY(300deg) translateY(-14px) scale(1.04); }
  80% { transform: rotateY(340deg) translateY(-6px) scale(1.02); }
  100% { transform: rotateY(360deg) translateY(0) scale(1); }
}
@keyframes cardRevealOut {
  0% { transform: rotateY(0deg); opacity: 1; }
  100% { transform: rotateY(90deg); opacity: 0; }
}
@keyframes cardRevealIn {
  0% { transform: rotateY(-90deg) scale(0.92); opacity: 0; }
  100% { transform: rotateY(0deg) scale(1); opacity: 1; }
}

/* ===== 按钮区 ===== */
.button-area { display: flex; flex-direction: column; align-items: center; gap: 16px; }

.draw-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 16px 48px;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, #F4A460, #E8923E);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(244, 164, 96, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  user-select: none;
}
.draw-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(244, 164, 96, 0.55);
}
.draw-btn:active:not(:disabled) {
  transform: scale(0.96);
}
.draw-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.draw-btn.pulse {
  animation: btnPulse 0.3s ease-out;
}
@keyframes btnPulse {
  0% { transform: scale(1); }
  40% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

/* 操作栏 */
.action-bar {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease 0.2s, transform 0.5s ease 0.2s;
  pointer-events: none;
}
.action-bar.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 28px;
  border: 2px solid rgba(244, 164, 96, 0.6);
  border-radius: 50px;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  color: #FDE8C8;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  user-select: none;
}
.action-btn:hover {
  background: rgba(244, 164, 96, 0.2);
  transform: translateY(-1px);
}
.action-btn:active {
  transform: scale(0.96);
}

/* 卡牌计数 */
.card-count {
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.5s ease;
}
.card-count.show {
  opacity: 1;
}

/* ===== 静音按钮 ===== */
.mute-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 20;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
}
.mute-btn img {
  width: 100%;
  height: 100%;
  display: block;
  transition: opacity 0.2s ease;
}
.mute-btn.muted img {
  opacity: 0.35;
}
.mute-btn:hover {
  background: rgba(0, 0, 0, 0.5);
  transform: scale(1.1);
}

/* ===== 加载画面 ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #1a1520;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
.loading-overlay.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-card {
  text-align: center;
  width: min(320px, 80vw);
}

.loading-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: #FDE8C8;
  margin-bottom: 28px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  margin-bottom: 14px;
}

.progress-bar__fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #F4A460, #E8923E);
  width: 0%;
  transition: width 0.3s ease;
}

.loading-text {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
}

/* ===== 粒子 ===== */
.particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warm-orange);
  opacity: 0;
}
.particle.burst {
  animation: particleFly 0.9s ease-out forwards;
}
@keyframes particleFly {
  0% { opacity: 0.9; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0); }
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  padding: 12px 28px;
  border-radius: 50px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 100;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== 空状态 ===== */
.card-slot.empty .card-back__star { opacity: 0.4; }
.card-slot.empty .card-back__text { font-size: 0.9rem; color: var(--text-muted); }

/* ===== 大图灯箱 ===== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  cursor: pointer;
}
.lightbox.show {
  opacity: 1;
  visibility: visible;
}
.lightbox__image {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 64px rgba(0, 0, 0, 0.5);
  cursor: default;
  animation: lightboxIn 0.35s ease-out;
}
@keyframes lightboxIn {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.lightbox__hint {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.85rem;
  pointer-events: none;
}

.lightbox__close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  z-index: 1;
}
.lightbox__close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ===== 响应式 ===== */
@media (max-width: 480px) {
  .app-shell { padding: 28px 16px; }
  .title { font-size: 1.5rem; }
  .card-slot { width: 220px; }
  .draw-btn { padding: 14px 36px; font-size: 1.05rem; }
}
