#dice-area {
  position: fixed;
  top: 24px; right: 28px;
  z-index: 300;
  display: none;
  align-items: center;
  gap: 14px;
}

#dice-area.visible { display: flex; }

@keyframes dice-roll-in {
  from { transform: translateX(200px) rotateZ(540deg); opacity: 0; }
  to   { transform: translateX(0) rotateZ(0deg); opacity: 1; }
}

@keyframes nyoki-once {
  0%  { transform: scaleX(0) scaleY(0.06); }
  4%  { transform: scaleX(0) scaleY(0.06); animation-timing-function: cubic-bezier(0.2, 0, 0.35, 1); }
  70% { transform: scaleX(1) scaleY(0.06); animation-timing-function: cubic-bezier(0.08, 0, 0.18, 1.35); }
  100%{ transform: scaleX(1) scaleY(1); }
}

#change-label {
  font-size: 13px;
  letter-spacing: 3px;
  color: rgba(255,255,255,0.4);
  white-space: nowrap;
  user-select: none;
  line-height: 1.8;
  transform-origin: right center;
  animation: nyoki-once 2.2s 4.2s 1 both;
  will-change: transform;
}

#dice-scene {
  width: 60px; height: 60px;
  perspective: 280px;
  cursor: grab;
  flex-shrink: 0;
  animation: dice-roll-in 2.2s 2s 1 ease-out both;
}

#dice-scene:active { cursor: grabbing; }

#dice-3d {
  width: 60px; height: 60px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform: rotateX(0deg) rotateY(0deg);
}

.face {
  position: absolute;
  width: 60px; height: 60px;
  background: #f5f5f5;
  border: 0.5px solid rgba(0,0,0,0.12);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  backface-visibility: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.6);
}

.face::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: 9px;
  background: linear-gradient(135deg, rgba(255,255,255,0.6) 0%, transparent 60%);
  pointer-events: none;
}

.face-1 { transform: translateZ(30px); }
.face-6 { transform: rotateY(180deg) translateZ(30px); }
.face-2 { transform: rotateY(90deg) translateZ(30px); }
.face-5 { transform: rotateY(-90deg) translateZ(30px); }
.face-3 { transform: rotateX(-90deg) translateZ(30px); }
.face-4 { transform: rotateX(90deg) translateZ(30px); }

.pips {
  display: grid;
  width: 42px; height: 42px;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

.pip {
  width: 8px; height: 8px;
  background: #1a1a1a;
  border-radius: 50%;
  margin: auto;
}

.face-1 .pip { background: #d63030; width: 11px; height: 11px; }

#dice-scene:hover .face { border-color: rgba(0,0,0,0.25); }

@media (max-width: 600px) {
  #dice-area { top: 16px; right: 16px; gap: 10px; }
  #change-label { font-size: 9px; }
  #dice-scene { width: 48px; height: 48px; }
  #dice-3d { width: 48px; height: 48px; }
  .face { width: 48px; height: 48px; border-radius: 7px; }
  .face-1 { transform: translateZ(24px); }
  .face-6 { transform: rotateY(180deg) translateZ(24px); }
  .face-2 { transform: rotateY(90deg) translateZ(24px); }
  .face-5 { transform: rotateY(-90deg) translateZ(24px); }
  .face-3 { transform: rotateX(-90deg) translateZ(24px); }
  .face-4 { transform: rotateX(90deg) translateZ(24px); }
  .pips { width: 34px; height: 34px; }
  .pip { width: 6px; height: 6px; }
  .face-1 .pip { width: 9px; height: 9px; }
}
