/**
 * Slot-Machine 抽奖动画 - 豪华老虎机
 * 设计理念：经典赌场风格 + 现代霓虹灯 + 强烈期待感
 */

/* ========== CSS变量定义 ========== */
:root {
  /* 老虎机颜色 */
  --slot-frame: #2c3e50;
  --slot-gold: #f39c12;
  --slot-red: #e74c3c;
  --slot-green: #2ecc71;
  --slot-bg: #34495e;

  /* 霓虹灯颜色 */
  --neon-red: #ff0844;
  --neon-blue: #00d9ff;
  --neon-yellow: #ffea00;
  --neon-pink: #ff006e;
}

/* ========== 容器布局 ========== */
.slot-machine-container {
  width: 100%;
  max-width: 600px;
  margin: 40px auto;
  padding: 40px 20px;
  perspective: 1200px;
  position: relative;
  min-height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ========== 老虎机主体 ========== */
.slot-machine {
  position: relative;
  width: 100%;
  max-width: 500px;
  background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
  border-radius: 32px;
  padding: 40px 30px;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.5),
    0 0 0 12px rgba(255, 255, 255, 0.05),
    inset 0 4px 0 rgba(255, 255, 255, 0.1),
    inset 0 -4px 0 rgba(0, 0, 0, 0.3);
  transform-style: preserve-3d;
}

/* 顶部装饰灯带 */
.slot-machine::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 8px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--neon-red) 20%,
    var(--neon-yellow) 40%,
    var(--neon-blue) 60%,
    var(--neon-pink) 80%,
    transparent
  );
  border-radius: 0 0 8px 8px;
  animation: lightFlow 2s linear infinite;
}

@keyframes lightFlow {
  0% { opacity: 0.5; }
  50% { opacity: 1; }
  100% { opacity: 0.5; }
}

/* ========== 标题区域 ========== */
.slot-title {
  text-align: center;
  margin-bottom: 30px;
}

.slot-title h2 {
  font-size: 36px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--slot-gold) 0%, var(--neon-yellow) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 40px rgba(243, 156, 18, 0.5);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 4px;
}

.slot-title p {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 2px;
}

/* ========== 滚轴区域 ========== */
.slot-reels-wrapper {
  position: relative;
  background: linear-gradient(135deg, #1a252f 0%, #2c3440 100%);
  border-radius: 20px;
  padding: 30px 20px;
  margin-bottom: 30px;
  box-shadow:
    inset 0 8px 16px rgba(0, 0, 0, 0.5),
    inset 0 0 60px rgba(0, 0, 0, 0.3);
}

/* 中奖线 */
.win-line {
  position: absolute;
  top: 50%;
  left: 10%;
  right: 10%;
  height: 4px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--neon-red) 20%,
    var(--neon-red) 80%,
    transparent
  );
  transform: translateY(-50%);
  opacity: 0;
  z-index: 10;
  transition: opacity 0.3s ease;
}

.win-line.active {
  opacity: 1;
  animation: lineGlow 0.5s ease-in-out infinite;
}

@keyframes lineGlow {
  0%, 100% { box-shadow: 0 0 10px var(--neon-red); }
  50% { box-shadow: 0 0 30px var(--neon-red), 0 0 60px var(--neon-red); }
}

/* 滚轴容器 */
.slot-reels {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  position: relative;
  z-index: 5;
}

/* 单个滚轴 */
.reel {
  flex: 1;
  height: 300px;
  position: relative;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    inset 0 4px 12px rgba(0, 0, 0, 0.5),
    0 4px 12px rgba(0, 0, 0, 0.3);
}

/* 滚轴条纹（遮罩效果）*/
.reel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.8) 0%,
    transparent 20%,
    transparent 80%,
    rgba(0, 0, 0, 0.8) 100%
  );
  pointer-events: none;
  z-index: 10;
}

/* 滚轴内容 */
.reel-strip {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  transition: top 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.reel-strip.spinning {
  transition: none;
}

/* 滚轴项目 */
.reel-item {
  width: 100%;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.reel-item:nth-child(odd) {
  background: rgba(255, 255, 255, 0.04);
}

/* 滚轴图片 */
.reel-item img {
  max-width: 70%;
  max-height: 70%;
  object-fit: contain;
  filter: brightness(0.8) blur(0.5px);
  transition: all 0.3s ease;
}

.reel-item.winner img {
  filter: brightness(1.2) blur(0);
  transform: scale(1.1);
}

/* ========== 控制按钮 ========== */
.slot-controls {
  text-align: center;
}

.start-button {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--neon-red) 0%, #c0392b 100%);
  color: #ffffff;
  font-size: 20px;
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
  position: relative;
  box-shadow:
    0 8px 24px rgba(231, 76, 60, 0.5),
    0 0 0 8px rgba(255, 255, 255, 0.1),
    inset 0 4px 0 rgba(255, 255, 255, 0.3),
    inset 0 -4px 0 rgba(0, 0, 0, 0.3);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.start-button::before {
  content: '';
  position: absolute;
  top: -12px;
  left: -12px;
  right: -12px;
  bottom: -12px;
  border-radius: 50%;
  background: linear-gradient(
    45deg,
    transparent,
    rgba(255, 8, 68, 0.5),
    transparent
  );
  opacity: 0;
  transition: opacity 0.3s ease;
}

.start-button:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow:
    0 12px 32px rgba(231, 76, 60, 0.7),
    0 0 0 8px rgba(255, 255, 255, 0.15),
    inset 0 4px 0 rgba(255, 255, 255, 0.4);
}

.start-button:hover::before {
  opacity: 1;
  animation: buttonPulse 1.5s ease-in-out infinite;
}

@keyframes buttonPulse {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.1) rotate(180deg); }
}

.start-button:active {
  transform: translateY(0) scale(0.98);
}

.start-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.start-button:disabled::before {
  opacity: 0;
}

/* ========== 装饰灯光 ========== */
.decorative-lights {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  bottom: 20px;
  pointer-events: none;
  z-index: 1;
}

.light-bulb {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--neon-yellow);
  box-shadow: 0 0 20px var(--neon-yellow);
  animation: bulbBlink 1s ease-in-out infinite;
}

@keyframes bulbBlink {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.light-bulb:nth-child(1) { top: 10%; left: 5%; animation-delay: 0s; }
.light-bulb:nth-child(2) { top: 10%; right: 5%; animation-delay: 0.2s; }
.light-bulb:nth-child(3) { bottom: 10%; left: 5%; animation-delay: 0.4s; }
.light-bulb:nth-child(4) { bottom: 10%; right: 5%; animation-delay: 0.6s; }
.light-bulb:nth-child(5) { top: 50%; left: 2%; animation-delay: 0.8s; }
.light-bulb:nth-child(6) { top: 50%; right: 2%; animation-delay: 1s; }

/* ========== 中奖特效 ========== */
.slot-machine.winning {
  animation: machineShake 0.5s ease-in-out 3;
}

@keyframes machineShake {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-2deg); }
  75% { transform: rotate(2deg); }
}

/* 金币雨 */
.coins-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 100;
}

.coin {
  position: absolute;
  width: 40px;
  height: 40px;
  background: radial-gradient(
    circle at 30% 30%,
    var(--slot-gold),
    #d68910
  );
  border-radius: 50%;
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.3),
    inset 2px 2px 4px rgba(255, 255, 255, 0.5),
    inset -2px -2px 4px rgba(0, 0, 0, 0.3);
  opacity: 0;
}

.coin::before {
  content: '¥';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 20px;
  font-weight: 900;
  color: #2c3e50;
}

.coin.falling {
  animation: coinFall 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes coinFall {
  0% {
    top: -50px;
    opacity: 0;
    transform: translateX(var(--start-x)) rotate(0deg);
  }
  10% {
    opacity: 1;
  }
  100% {
    top: 120%;
    opacity: 0.5;
    transform: translateX(var(--end-x)) rotate(720deg);
  }
}

/* ========== 商品展示 ========== */
.product-result-slot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 400px;
  background: linear-gradient(135deg, rgba(44, 62, 80, 0.98) 0%, rgba(52, 73, 94, 0.98) 100%);
  border-radius: 24px;
  padding: 40px 30px;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0);
  z-index: 200;
  box-shadow:
    0 0 100px rgba(0, 0, 0, 0.8),
    0 0 0 8px rgba(255, 255, 255, 0.1);
}

.product-result-slot.show {
  animation: resultPopup 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes resultPopup {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0) rotate(-180deg);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
}

.product-result-slot h3 {
  font-size: 24px;
  color: var(--slot-gold);
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 3px;
}

.product-result-slot .product-image-slot {
  width: 160px;
  height: 160px;
  margin: 0 auto 20px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.product-result-slot .product-image-slot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.product-result-slot .product-name-slot {
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 12px;
}

.product-result-slot .product-rarity-slot {
  display: inline-block;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.product-rarity-slot.sp {
  background: linear-gradient(135deg,
    var(--color-rarity-sp, #b967ff) 0%,
    var(--color-rarity-sp, #b967ff) 100%);
  color: #ffffff;
}

.product-rarity-slot.sss {
  background: linear-gradient(135deg,
    var(--color-rarity-sss, #ff0844) 0%,
    var(--color-rarity-sss, #ff0844) 100%);
  color: #ffffff;
}

.product-rarity-slot.ss {
  background: linear-gradient(135deg,
    var(--color-rarity-ss, #ff8c00) 0%,
    var(--color-rarity-ss, #ff8c00) 100%);
  color: #1a1a2e;
}

.product-rarity-slot.s {
  background: linear-gradient(135deg,
    var(--color-rarity-s, #ffea00) 0%,
    var(--color-rarity-s, #ffea00) 100%);
  color: #1a1a2e;
}

.product-rarity-slot.sr {
  background: linear-gradient(135deg,
    var(--color-rarity-sr, #00f5ff) 0%,
    var(--color-rarity-sr, #00f5ff) 100%);
  color: #ffffff;
}

.product-rarity-slot.r {
  background: linear-gradient(135deg,
    var(--color-rarity-r, #ff69b4) 0%,
    var(--color-rarity-r, #ff69b4) 100%);
  color: #ffffff;
}

/* ========== 响应式设计 ========== */
@media (max-width: 768px) {
  .slot-machine {
    padding: 30px 20px;
  }

  .slot-title h2 {
    font-size: 28px;
  }

  .reel {
    height: 240px;
  }

  .reel-item {
    height: 80px;
  }

  .start-button {
    width: 120px;
    height: 120px;
    font-size: 18px;
  }
}

@media (max-width: 480px) {
  .slot-machine-container {
    padding: 20px 10px;
    min-height: 500px;
  }

  .slot-machine {
    padding: 20px 15px;
    border-radius: 24px;
  }

  .slot-title h2 {
    font-size: 24px;
    letter-spacing: 2px;
  }

  .slot-reels-wrapper {
    padding: 20px 10px;
  }

  .slot-reels {
    gap: 8px;
  }

  .reel {
    height: 200px;
    border-radius: 12px;
  }

  .reel-item {
    height: 66px;
  }

  .start-button {
    width: 100px;
    height: 100px;
    font-size: 16px;
  }

  .product-result-slot {
    padding: 30px 20px;
  }

  .product-result-slot h3 {
    font-size: 20px;
  }

  .product-result-slot .product-image-slot {
    width: 120px;
    height: 120px;
  }

  .product-result-slot .product-name-slot {
    font-size: 18px;
  }

  .decorative-lights {
    display: none; /* 移动端隐藏装饰灯 */
  }
}

/* ========== 性能优化 ========== */
.slot-machine,
.reel,
.reel-strip,
.coin,
.product-result-slot {
  will-change: transform, opacity;
  backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
}
