/* 骰子样式 */
.dice-container {
  width: 150px;
  height: 150px;
  perspective: 600px;
  margin: 0 auto;
  cursor: pointer;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.dice-3d {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s ease-out;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.dice-3d.rolling {
  animation: rolling 0.5s linear infinite;
}

@keyframes rolling {
  0% {
    transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  }
  100% {
    transform: rotateX(360deg) rotateY(360deg) rotateZ(360deg);
  }
}

/* 骰子面 */
.dice-face {
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: white;
  border: 2px solid #2F4F4F;
  border-radius: 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  align-items: center;
  padding: 10px;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
  backface-visibility: hidden;
}

/* 骰子点 */
.dice-dot {
  width: 20px;
  height: 20px;
  background-color: #2F4F4F;
  border-radius: 50%;
}

/* 骰子面位置 */
.dice-front { transform: rotateY(0deg) translateZ(75px); }
.dice-back { transform: rotateY(180deg) translateZ(75px); }
.dice-right { transform: rotateY(90deg) translateZ(75px); }
.dice-left { transform: rotateY(-90deg) translateZ(75px); }
.dice-top { transform: rotateX(90deg) translateZ(75px); }
.dice-bottom { transform: rotateX(-90deg) translateZ(75px); }

/* 显示特定面 */
.dice-3d.show-1 { transform: rotateY(0deg); }
.dice-3d.show-2 { transform: rotateY(180deg); }
.dice-3d.show-3 { transform: rotateY(-90deg); }
.dice-3d.show-4 { transform: rotateY(90deg); }
.dice-3d.show-5 { transform: rotateX(-90deg); }
.dice-3d.show-6 { transform: rotateX(90deg); }

/* 骰子点的排列 */
.dice-front {
  justify-content: center;
  align-items: center;
}

.dice-back .dice-dot:nth-child(1) { align-self: flex-start; }
.dice-back .dice-dot:nth-child(2) { align-self: flex-end; }

.dice-right .dice-dot:nth-child(1) { align-self: flex-start; }
.dice-right .dice-dot:nth-child(2) { align-self: center; }
.dice-right .dice-dot:nth-child(3) { align-self: flex-end; }

.dice-left {
  flex-wrap: wrap;
  justify-content: space-between;
}
.dice-left .dice-dot:nth-child(1),
.dice-left .dice-dot:nth-child(2) { margin-bottom: 40px; }

.dice-top {
  flex-wrap: wrap;
  justify-content: space-between;
}
.dice-top .dice-dot:nth-child(1),
.dice-top .dice-dot:nth-child(2) { margin-bottom: 40px; }
.dice-top .dice-dot:nth-child(3) {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.dice-bottom {
  flex-wrap: wrap;
  justify-content: space-between;
}
.dice-bottom .dice-dot:nth-child(1),
.dice-bottom .dice-dot:nth-child(2),
.dice-bottom .dice-dot:nth-child(3) { margin-bottom: 20px; }

/* 点的位置 */
.dice-dot.position-0 { align-self: flex-start; margin-right: auto; }
.dice-dot.position-1 { align-self: flex-start; margin-left: auto; margin-right: auto; }
.dice-dot.position-2 { align-self: flex-start; margin-left: auto; }
.dice-dot.position-3 { align-self: center; margin-right: auto; }
.dice-dot.position-4 { align-self: center; margin-left: auto; margin-right: auto; }
.dice-dot.position-5 { align-self: center; margin-left: auto; }
.dice-dot.position-6 { align-self: flex-end; margin-right: auto; }
.dice-dot.position-7 { align-self: flex-end; margin-left: auto; margin-right: auto; }
.dice-dot.position-8 { align-self: flex-end; margin-left: auto; }

/* 骰子高亮动画 */
.dice-container.highlight {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 166, 128, 0.7);
  }
  70% {
    box-shadow: 0 0 0 20px rgba(0, 166, 128, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 166, 128, 0);
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .dice-container {
    width: 120px;
    height: 120px;
  }

  .dice-front { transform: rotateY(0deg) translateZ(60px); }
  .dice-back { transform: rotateY(180deg) translateZ(60px); }
  .dice-right { transform: rotateY(90deg) translateZ(60px); }
  .dice-left { transform: rotateY(-90deg) translateZ(60px); }
  .dice-top { transform: rotateX(90deg) translateZ(60px); }
  .dice-bottom { transform: rotateX(-90deg) translateZ(60px); }

  .dice-dot {
    width: 15px;
    height: 15px;
  }
}

@media (max-width: 480px) {
  .dice-container {
    width: 100px;
    height: 100px;
  }

  .dice-front { transform: rotateY(0deg) translateZ(50px); }
  .dice-back { transform: rotateY(180deg) translateZ(50px); }
  .dice-right { transform: rotateY(90deg) translateZ(50px); }
  .dice-left { transform: rotateY(-90deg) translateZ(50px); }
  .dice-top { transform: rotateX(90deg) translateZ(50px); }
  .dice-bottom { transform: rotateX(-90deg) translateZ(50px); }

  .dice-dot {
    width: 12px;
    height: 12px;
  }
}

/* 骰子长按高亮效果 */
.highlight-pulse {
  animation: highlight-pulse 2s infinite;
}

@keyframes highlight-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7);
  }
  70% {
    box-shadow: 0 0 0 20px rgba(255, 215, 0, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 215, 0, 0);
  }
}
