* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  font-family: "KaiTi", "STKaiti", "楷体", serif;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 25%, #3a2515 0%, #1a0f08 60%, #0a0504 100%);
  min-height: 100vh;
  height: 100dvh;
  color: #f5e6c8;
}

/* 顶部状态栏 */
.top-bar {
  position: absolute; top: 0; left: 0; right: 0;
  padding: calc(14px + env(safe-area-inset-top)) 16px 8px;
  display: flex; justify-content: space-between; align-items: center;
  z-index: 20;
}
.chip {
  display: flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, rgba(139,90,43,0.7), rgba(90,61,31,0.7));
  padding: 7px 14px; border-radius: 20px;
  border: 1px solid rgba(212,175,55,0.4);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3), inset 0 0 10px rgba(255,215,0,0.1);
  font-size: 13px;
}
.chip .icon { font-size: 16px; }
.chip .val { color: #ffe066; font-weight: bold; letter-spacing: 1px; }

/* 标题 */
.title {
  position: absolute; top: calc(75px + env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%);
  text-align: center; z-index: 10; white-space: nowrap;
}
.title-text {
  font-size: 26px; color: #ffe066; font-weight: bold;
  letter-spacing: 6px;
  text-shadow: 0 0 15px rgba(255,215,0,0.6), 0 2px 4px rgba(0,0,0,0.8);
}
.title-sub {
  font-size: 12px; color: rgba(245,230,200,0.7); letter-spacing: 4px;
  margin-top: 6px;
}

/* ========== 舞台 ========== */
.stage {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  perspective: 1400px;
  z-index: 5;
  width: 100%;
  height: 420px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}

/* 3D 场景 */
.scene {
  position: relative;
  width: 240px; height: 240px;
  perspective: 1400px;
  transform-style: preserve-3d;
}

/* 骰子容器 */
.dice {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transform: rotateX(-25deg) rotateY(-35deg);
  transition: transform 3.5s cubic-bezier(0.15, 0.8, 0.2, 1);
}

/* 骰子6面 */
.face {
  position: absolute;
  width: 180px; height: 180px;
  left: 30px; top: 30px;
  /* 白色质感、半透明 */
  background:
    radial-gradient(ellipse at 30% 25%,
      rgba(255,255,255,0.95) 0%,
      rgba(255,255,255,0.88) 15%,
      rgba(245,240,230,0.85) 35%,
      rgba(230,220,200,0.82) 60%,
      rgba(210,195,175,0.8) 85%,
      rgba(190,175,155,0.78) 100%
    );
  border-radius: 22px;
  border: 2px solid rgba(210,195,175,0.9);
  box-shadow:
    inset 0 0 25px rgba(255,255,255,0.6),
    inset 2px 2px 8px rgba(255,255,255,0.7),
    inset -2px -2px 8px rgba(150,130,110,0.4),
    0 8px 25px rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
}

/* 6个面的位置（每个面相对骰子中心偏移 90px，即面宽的一半） */
.face-front  { transform: translateZ(90px); }
.face-back   { transform: rotateY(180deg) translateZ(90px); }
.face-right  { transform: rotateY(90deg) translateZ(90px); }
.face-left   { transform: rotateY(-90deg) translateZ(90px); }
.face-top    { transform: rotateX(90deg) translateZ(90px); }
.face-bottom { transform: rotateX(-90deg) translateZ(90px); }

/* 各面的叠加阴影——使三个正面可见的面最亮，背面稍暗 */
.face-front {
  box-shadow:
    inset 0 0 30px rgba(255,255,255,0.7),
    inset 3px 3px 10px rgba(255,255,255,0.8),
    inset -3px -3px 10px rgba(150,130,110,0.35),
    0 10px 30px rgba(0,0,0,0.5);
}
.face-right {
  box-shadow:
    inset 0 0 30px rgba(255,255,255,0.45),
    inset 3px 3px 10px rgba(255,255,255,0.6),
    inset -3px -3px 10px rgba(130,110,90,0.4),
    0 8px 25px rgba(0,0,0,0.4);
}
.face-top {
  box-shadow:
    inset 0 0 30px rgba(255,255,255,0.5),
    inset 3px 3px 10px rgba(255,255,255,0.7),
    inset -3px -3px 10px rgba(140,120,100,0.35),
    0 8px 25px rgba(0,0,0,0.4);
}
/* 后面三个面：隐隐约约能看到（半透明变暗） */
.face-back, .face-left, .face-bottom {
  background:
    radial-gradient(ellipse at 70% 75%,
      rgba(230,220,200,0.55) 0%,
      rgba(210,195,175,0.5) 30%,
      rgba(180,165,145,0.45) 70%,
      rgba(160,145,130,0.4) 100%
    );
  filter: brightness(0.7) saturate(0.8);
}

/* 点数（圆点）布局 —— 使用 grid 的 3x3 排布 */
.pip-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  width: 100%; height: 100%;
  gap: 4px;
}
.pip {
  width: 28px; height: 28px;
  border-radius: 50%;
  align-self: center;
  justify-self: center;
  /* 默认黑点：真实骰子黑点 */
  background: radial-gradient(circle at 35% 30%, #3a3a3a 0%, #1a1a1a 40%, #000 80%);
  box-shadow:
    inset 1px 1px 2px rgba(0,0,0,0.8),
    inset -1px -1px 2px rgba(80,80,80,0.6),
    0 1px 2px rgba(255,255,255,0.3);
}

/* 一点（1点）为红色 —— 真实骰子惯例 */
.face-1 .pip {
  background: radial-gradient(circle at 35% 30%, #ff6b6b 0%, #e53935 40%, #8b0000 90%);
  box-shadow:
    inset 1px 1px 2px rgba(80,0,0,0.7),
    inset -1px -1px 2px rgba(255,150,150,0.3),
    0 1px 3px rgba(255,180,180,0.4);
}
/* 一点居中放大 */
.face-1 .pip { width: 48px; height: 48px; }

/* 1点：中心 */
.face-1 .pip { grid-column: 2; grid-row: 2; }
/* 2点：左上、右下 */
.face-2 .pip:nth-child(1) { grid-column: 1; grid-row: 1; }
.face-2 .pip:nth-child(2) { grid-column: 3; grid-row: 3; }
/* 3点：左上、中心、右下 */
.face-3 .pip:nth-child(1) { grid-column: 1; grid-row: 1; }
.face-3 .pip:nth-child(2) { grid-column: 2; grid-row: 2; }
.face-3 .pip:nth-child(3) { grid-column: 3; grid-row: 3; }
/* 4点：四个角 */
.face-4 .pip:nth-child(1) { grid-column: 1; grid-row: 1; }
.face-4 .pip:nth-child(2) { grid-column: 3; grid-row: 1; }
.face-4 .pip:nth-child(3) { grid-column: 1; grid-row: 3; }
.face-4 .pip:nth-child(4) { grid-column: 3; grid-row: 3; }
/* 5点：四个角+中心 */
.face-5 .pip:nth-child(1) { grid-column: 1; grid-row: 1; }
.face-5 .pip:nth-child(2) { grid-column: 3; grid-row: 1; }
.face-5 .pip:nth-child(3) { grid-column: 2; grid-row: 2; }
.face-5 .pip:nth-child(4) { grid-column: 1; grid-row: 3; }
.face-5 .pip:nth-child(5) { grid-column: 3; grid-row: 3; }
/* 6点：上下两行，各三个 */
.face-6 .pip:nth-child(1) { grid-column: 1; grid-row: 1; }
.face-6 .pip:nth-child(2) { grid-column: 2; grid-row: 1; }
.face-6 .pip:nth-child(3) { grid-column: 3; grid-row: 1; }
.face-6 .pip:nth-child(4) { grid-column: 1; grid-row: 3; }
.face-6 .pip:nth-child(5) { grid-column: 2; grid-row: 3; }
.face-6 .pip:nth-child(6) { grid-column: 3; grid-row: 3; }

/* 后面三个面上的点数：暗淡 */
.face-back .pip, .face-left .pip, .face-bottom .pip {
  background: radial-gradient(circle at 35% 30%, #555 0%, #333 50%, #222 100%);
  filter: brightness(0.6);
  opacity: 0.6;
}

/* 投掷中动画（旋转翻滚）- 由 JS 通过内联 transform 控制 */

/* ===== 骰子从右上角小筛子跳动（中筛子）滚到屏幕中间（大骰子） ===== */
.scene.rolling {
  animation: diceRollIn 2.5s cubic-bezier(.34,1.56,.64,1) forwards;
}
@keyframes diceRollIn {
  0%   { transform: translate(180px, -200px) rotate(-60deg) scale(0.2); opacity: 0; }
  15%  { transform: translate(60px, -80px) rotate(30deg) scale(0.55); opacity: 1; }
  30%  { transform: translate(-30px, 30px) rotate(-20deg) scale(0.8); }
  50%  { transform: translate(20px, -50px) rotate(15deg) scale(0.95); }
  70%  { transform: translate(-10px, 15px) rotate(-8deg) scale(1.08); }
  85%  { transform: translate(5px, -15px) rotate(4deg) scale(1.02); }
  100% { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
}

/* 骰子停止后——中奖面不透明，其他面保持原有透明度 */
.dice.settled .face.winning {
  background:
    radial-gradient(ellipse at 30% 25%,
      rgba(255,255,255,1) 0%,
      rgba(255,255,255,1) 15%,
      rgba(248,242,232,1) 35%,
      rgba(235,225,210,1) 60%,
      rgba(215,200,180,1) 85%,
      rgba(195,175,155,1) 100%
    );
  filter: none !important;
  opacity: 1 !important;
  box-shadow:
    inset 0 0 35px rgba(255,255,255,0.8),
    inset 3px 3px 12px rgba(255,255,255,0.9),
    inset -3px -3px 10px rgba(140,120,100,0.3),
    0 12px 35px rgba(0,0,0,0.5);
}
.dice.settled .face.winning .pip {
  opacity: 1 !important;
  filter: none !important;
}

/* 中奖发光效果 —— 用scene伪元素实现，避免filter破坏dice的3D结构 */
.scene.winner::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 260px;
  height: 260px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;
  animation: winnerGlow 1s ease-in-out infinite;
}
@keyframes winnerGlow {
  0%, 100% { box-shadow: 0 0 35px 15px rgba(255,215,0,0.6), 0 0 70px 30px rgba(255,180,50,0.35); }
  50% { box-shadow: 0 0 55px 25px rgba(255,215,0,0.85), 0 0 100px 50px rgba(255,200,80,0.5); }
}

/* 中奖时只有中奖面的点数（黑点）闪金光边框 —— 强化边光 + 停稳后黑色加深 */
.dice.winner .face.winning .pip {
  animation: pipGoldGlow 0.9s ease-in-out infinite;
  position: relative;
  background: radial-gradient(circle at 35% 30%, #1a1a1a 0%, #000 80%);
  box-shadow: 0 1px 3px rgba(0,0,0,0.9);
}
.dice.winner .face.winning .pip::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  box-shadow:
    0 0 14px rgba(255,215,0,1),
    0 0 28px rgba(255,180,50,0.9),
    0 0 48px rgba(255,220,100,0.7);
  pointer-events: none;
  animation: pipOuterGlow 0.9s ease-in-out infinite;
}
@keyframes pipGoldGlow {
  0%, 100% {
    box-shadow:
      0 0 10px rgba(255,220,100,1),
      0 0 22px rgba(255,190,60,0.95),
      0 0 36px rgba(255,215,0,0.8),
      inset 0 0 6px rgba(255,255,200,0.9);
    outline: 3px solid rgba(255,230,120,1);
    outline-offset: 2px;
  }
  50% {
    box-shadow:
      0 0 18px rgba(255,255,200,1),
      0 0 36px rgba(255,230,100,1),
      0 0 60px rgba(255,200,80,0.9),
      inset 0 0 10px rgba(255,255,255,1);
    outline: 5px solid rgba(255,255,220,1);
    outline-offset: 3px;
  }
}
@keyframes pipOuterGlow {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.15); }
}

/* 中奖时 1 点（红）的金光也覆盖红色，同时颜色加深到接近深金 */
.dice.winner .face-1 .pip {
  background: radial-gradient(circle at 35% 30%, #7a0000 0%, #220000 80%);
  box-shadow:
    0 0 16px rgba(255,100,100,1),
    0 0 32px rgba(255,60,60,1),
    0 0 52px rgba(200,40,40,0.9),
    inset 0 0 8px rgba(255,180,180,1);
}

/* ========== 结果展示 ========== */
.result-panel {
  margin-top: 30px;
  text-align: center;
  opacity: 0;
  transform: translateY(20px) scale(0.8);
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.result-panel.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.result-big-num {
  font-size: 48px; font-weight: bold; color: #ffe066;
  text-shadow: 0 0 20px rgba(255,215,0,0.8), 0 2px 6px rgba(0,0,0,0.7);
  letter-spacing: 4px;
}
.result-label {
  font-size: 16px; color: #f5e6c8; letter-spacing: 4px; margin-top: 8px;
}
.result-reward {
  font-size: 20px; color: #ff6b6b; font-weight: bold; margin-top: 6px;
  text-shadow: 0 0 10px rgba(255,107,107,0.5);
  letter-spacing: 3px;
}

/* ========== 按钮 ========== */
.btn-area {
  position: absolute;
  bottom: calc(55px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  z-index: 20; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.throw-btn {
  width: 110px; height: 110px; border-radius: 50%;
  border: 3px solid #d4af37;
  background: radial-gradient(circle at 30% 30%, #d4a877 0%, #a67c52 40%, #6b4423 80%);
  color: #ffe066;
  font-size: 15px; font-weight: bold; letter-spacing: 2px;
  cursor: pointer; position: relative; overflow: hidden;
  box-shadow:
    0 0 30px rgba(255,215,0,0.4),
    0 0 60px rgba(255,180,100,0.2),
    inset 0 0 20px rgba(139,90,43,0.5),
    inset 2px 2px 6px rgba(255,220,150,0.3);
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex; align-items: center; justify-content: center;
  font-family: "KaiTi", "STKaiti", serif;
}
.throw-btn:active:not(:disabled) { transform: scale(0.93); }
.throw-btn::before {
  content: ''; position: absolute; inset: -50%;
  background: conic-gradient(from 0deg, transparent 0deg, rgba(255,215,0,0.15) 60deg, transparent 120deg, rgba(255,215,0,0.15) 240deg, transparent 360deg);
  animation: rotateGlow 4s linear infinite;
}
@keyframes rotateGlow { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.throw-btn span { position: relative; z-index: 1; text-shadow: 0 0 10px rgba(255,215,0,0.8); }
.throw-btn:disabled { filter: brightness(0.5); cursor: not-allowed; }

.throw-cost { font-size: 12px; color: rgba(245,230,200,0.6); letter-spacing: 2px; font-family: "KaiTi", serif; }

/* ========== 粒子 ========== */
.particles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }
.gold-particle {
  position: absolute; width: 8px; height: 8px; border-radius: 50%;
  background: radial-gradient(circle, #fff8a0, #ffd700 50%, transparent);
  animation: particleFall linear forwards;
  box-shadow: 0 0 10px #ffd700, 0 0 20px rgba(255,215,0,0.5);
}
@keyframes particleFall {
  0%   { transform: translateY(-20px) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg) scale(0.3); opacity: 0; }
}
/* 炸出的星星（6点特效） */
.star-piece {
  position: absolute; font-size: 22px; color: #fff8a0;
  text-shadow: 0 0 10px #ffd700, 0 0 20px rgba(255,215,0,0.8);
  animation: starFly 1.5s ease-out forwards;
}
@keyframes starFly {
  0% { transform: translate(0,0) scale(0.3); opacity: 0; }
  15% { opacity: 1; transform: translate(calc(var(--sx)/3), calc(var(--sy)/3)) scale(1.2); }
  100% { transform: translate(var(--sx), var(--sy)) scale(0.2); opacity: 0; }
}

/* ========== 弹窗 ========== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.5s; padding: 20px;
}
.modal-overlay.show { opacity: 1; pointer-events: all; }

.modal {
  background: linear-gradient(160deg,
    rgba(255,248,220,0.96) 0%,
    rgba(245,230,200,0.94) 40%,
    rgba(232,213,168,0.95) 80%,
    rgba(212,175,55,0.9) 100%
  );
  border: 3px solid #d4af37;
  border-radius: 22px;
  padding: 32px 25px;
  text-align: center;
  max-width: 320px;
  width: 90%;
  transform: scale(0.6) rotate(-5deg);
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow:
    0 20px 60px rgba(0,0,0,0.6),
    0 0 40px rgba(255,215,0,0.4),
    inset 0 0 20px rgba(255,255,255,0.3),
    inset 0 0 60px rgba(255,215,0,0.1);
  position: relative;
  overflow: visible;
}
.modal-overlay.show .modal { transform: scale(1) rotate(0deg); }

.modal-close {
  position: absolute; top: 10px; right: 12px;
  background: rgba(139,90,43,0.15);
  border: 2px solid rgba(139,90,43,0.4);
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 18px; color: #6b4423; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 10; transition: transform 0.2s;
}
.modal-close:active { transform: scale(0.9); }

.modal-emoji { font-size: 60px; margin-bottom: 8px; }
.modal-title { font-size: 24px; color: #6b4423; font-weight: bold; margin-bottom: 8px; letter-spacing: 4px; }
.modal-desc { font-size: 14px; color: #8b5a2b; margin-bottom: 12px; letter-spacing: 2px; }
.modal-value { font-size: 22px; color: #e53935; font-weight: bold; margin-bottom: 20px; }
.modal-value .val-num {
  color: #d4af37; font-size: 44px;
  text-shadow: 0 0 10px rgba(255,215,0,0.7), 0 2px 4px rgba(139,90,43,0.4);
  margin: 0 6px;
}

.modal-share-btn {
  background: linear-gradient(135deg, #d4af37 0%, #b8860b 100%);
  color: #3a2410; border: none;
  padding: 14px 35px; border-radius: 28px;
  font-size: 16px; font-weight: bold; cursor: pointer;
  box-shadow: 0 5px 18px rgba(139,90,43,0.5), inset 0 1px 3px rgba(255,255,255,0.4);
  transition: transform 0.15s; letter-spacing: 3px;
  font-family: "KaiTi", "STKaiti", serif;
}
.modal-share-btn:active { transform: scale(0.95); }

/* Toast */
.toast-hint {
  position: fixed; top: 35%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(90,61,31,0.92);
  color: #ffe066;
  padding: 11px 26px; border-radius: 26px;
  font-size: 14px; letter-spacing: 2px; z-index: 250;
  border: 1px solid #d4af37;
  animation: toastFade 1.8s ease-out forwards; pointer-events: none;
  text-shadow: 0 0 10px rgba(255,215,0,0.6);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5), 0 0 30px rgba(255,215,0,0.2);
  font-family: "KaiTi", "STKaiti", serif;
}
@keyframes toastFade {
  0%   { opacity: 0; transform: translate(-50%, -30%) scale(0.85); }
  15%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -70%); }
}

.reward-popup {
  position: fixed; top: 40%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 32px; font-weight: bold; color: #ffe066;
  text-shadow: 0 0 20px #ffd700, 0 2px 4px rgba(0,0,0,0.8);
  z-index: 260; pointer-events: none;
  animation: rewardPop 2s ease-out forwards;
  letter-spacing: 3px;
  font-family: "KaiTi", serif;
}
@keyframes rewardPop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  30%  { opacity: 1; transform: translate(-50%, -50%) scale(1.4); }
  100% { opacity: 0; transform: translate(-50%, -120%); }
}

/* 金色光晕特效层（1点） */
.halo-effect {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 20px; height: 20px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,240,160,0.9) 0%, rgba(255,215,0,0.5) 30%, transparent 70%);
  z-index: 499; pointer-events: none;
  animation: haloBurst 1.5s ease-out forwards;
}
@keyframes haloBurst {
  0% { width: 20px; height: 20px; opacity: 1; }
  50% { width: 600px; height: 600px; opacity: 0.8; }
  100% { width: 900px; height: 900px; opacity: 0; }
}

.back-btn {
  position: fixed;
  top: 48px;
  left: 12px;
  width: 36px;
  height: 36px;
  background: rgba(139,90,43,0.7);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  z-index: 100;
  border: 1.5px solid rgba(212,175,55,0.3);
  color: #FFD700;
}
