:root {
  --navy1: #0a0a1a;
  --navy2: #1e3a8a;
  --cyan:  #38bdf8;
  --dice-size: 150px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, var(--navy1), var(--navy2));
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

#game {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 24px 18px 32px;
  box-shadow: 0 0 18px rgba(56,189,248,0.3);
  width: 90vw;
  max-width: 380px;
  text-align: center;
  position: relative;
}

input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.2);
  color: #fff;
  backdrop-filter: blur(4px);
}

button {
  padding: 10px 24px;
  font-size: 1rem;
  margin-top: 10px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg,#38bdf8,#1e40af);
  color: #fff;
  box-shadow: 0 0 10px rgba(56,189,248,0.5);
  transition: transform 0.2s;
}
button:active {
  transform: scale(0.97);
}

#dice {
  width: var(--dice-size);
  height: var(--dice-size);
  margin: 20px auto;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 1s;
}
#dice.rolling {
  animation: roll 1s ease-in-out;
}
@keyframes roll {
  0% { transform: rotateX(0deg) rotateY(0deg); }
  25% { transform: rotateX(180deg) rotateY(90deg); }
  50% { transform: rotateX(360deg) rotateY(180deg); }
  75% { transform: rotateX(540deg) rotateY(270deg); }
  100% { transform: rotateX(720deg) rotateY(360deg); }
}
.face {
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg,#fff,#cbd5e1);
  border-radius: 20px;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.3), 0 0 20px rgba(56,189,248,0.4);
  font-size: 3.5rem;
  color: #111;
}
.face1 { transform: rotateY(0deg) translateZ(calc(var(--dice-size)/2)); }
.face2 { transform: rotateY(90deg) translateZ(calc(var(--dice-size)/2)); }
.face3 { transform: rotateY(180deg) translateZ(calc(var(--dice-size)/2)); }
.face4 { transform: rotateY(-90deg) translateZ(calc(var(--dice-size)/2)); }
.face5 { transform: rotateX(90deg) translateZ(calc(var(--dice-size)/2)); }
.face6 { transform: rotateX(-90deg) translateZ(calc(var(--dice-size)/2)); }

#result {
  margin-top: 20px;
  min-height: 40px;
}

.pop {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  background: rgba(0,0,0,0.8);
  color: #fff;
  padding: 20px 30px;
  border-radius: 12px;
  box-shadow: 0 0 12px rgba(56,189,248,0.5);
  opacity: 0;
  animation: pop 0.5s forwards;
}
@keyframes pop {
  from { transform: translate(-50%,-60%); opacity:0; }
  to { transform: translate(-50%,-50%); opacity:1; }
}

#confetti {
  position: absolute;
  left:0;top:0;right:0;bottom:0;
  pointer-events:none;
  overflow:visible;
}
.confetti-piece {
  position:absolute;
  width:8px;
  height:12px;
  background:var(--c);
  animation: fall 1.2s forwards;
}
@keyframes fall {
  0% { opacity:1; transform:translate(var(--x),var(--y)) rotate(0deg); }
  100% { opacity:0; transform:translate(var(--x),calc(var(--y)+150px)) rotate(360deg); }
}

@media (max-width:500px){
  #game { padding:20px 14px 28px; }
  :root{ --dice-size: 120px; }
}
