* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Montserrat', sans-serif; }

body {
  background-image: url('background-cube.png');
  background-size: cover;
  background-position: center;
  background-attachment: scroll;
  width: 100%;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(0,150,170,0.15) 0%, transparent 65%),
    radial-gradient(ellipse 50% 40% at 0% 100%, rgba(0,110,130,0.10) 0%, transparent 60%);
  pointer-events: none;
}

.page {
  position: relative; z-index: 1;
  min-height: 85vh;
  display: flex; 
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 16px 12px;
  margin-top: 8vh;
}

/* Dice */
.dice-wrap { 
  position: relative; 
  width: 85vw; 
  max-width: 460px; 
  height: auto; 
  aspect-ratio: 1; 
  margin-bottom: 20px; 
  animation: fadeUp .7s ease .2s both; 
  cursor: grab; 
}
.dice-wrap:active { cursor: grabbing; }

#threeCanvas { 
  width: 100% !important; 
  height: 100% !important; 
  filter: drop-shadow(0 14px 50px rgba(0,160,180,0.6)) drop-shadow(0 0 80px rgba(0,160,180,0.18)); 
}

.stage-glow { 
  position: absolute; 
  bottom: -14px; 
  left: 50%; 
  transform: translateX(-50%); 
  width: 80%; 
  height: 32px; 
  background: radial-gradient(ellipse, rgba(0,160,180,0.42) 0%, transparent 70%); 
  border-radius: 50%; 
  animation: breathe 3s ease-in-out infinite; 
  pointer-events: none; 
}

/* Popup Result styles */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 10, 20, 0.85);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  justify-content: center;
  align-items: center;
  animation: fadeIn .3s ease forwards;
}

.popup-box {
  background: linear-gradient(135deg, #06384e, #0a5f74);
  border: 2px solid #0dd8f0;
  border-radius: 16px;
  padding: 32px 24px;
  width: 90%;
  max-width: 320px;
  text-align: center;
  box-shadow: 0 0 40px rgba(0,200,220,0.35), inset 0 0 20px rgba(0,200,220,0.15);
  animation: popUp .5s cubic-bezier(0.175,0.885,0.32,1.275) forwards;
}

.r-eye { font-size: 20px; font-weight: 700; letter-spacing: 4px; text-transform: uppercase; color: rgba(0,190,210); margin-bottom: 10px; }
.r-top { font-size: 18px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: #fff; margin-top: 12px; min-height: 20px; }
.r-sub { font-size: 18px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: #fff; margin-top: 12px; min-height: 20px; }
.r-name { font-size: 18px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: #fff; margin-top: 12px; min-height: 20px; }
.r-flavor { font-size: 18px; color: rgba(0,190,210,0.45); margin-top: 6px; font-style: italic; letter-spacing: 1px; min-height: 16px; }

.popup-close-btn {
  margin-top: 24px;
  background: linear-gradient(135deg, #0885a0, #0ab8d2);
  border: 1px solid #0dd8f0;
  color: #fff;
  padding: 10px 24px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 4px;
  transition: all .3s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.popup-close-btn:hover {
  background: linear-gradient(135deg, #0ab8d2, #12f0ff);
  box-shadow: 0 0 20px rgba(0,200,220,0.5);
  transform: translateY(-2px);
}
.popup-close-btn:active {
  transform: translateY(0);
}

/* Button */
.roll-btn { background: none; border: none; cursor: pointer; padding: 0; margin-bottom: 24px; animation: fadeUp .7s ease .4s both; }
.btn-body { padding: 12px 36px; background: linear-gradient(135deg, #0885a0, #0ab8d2); border: 2px solid #0dd8f0; clip-path: polygon(16px 0%,calc(100% - 16px) 0%,100% 50%,calc(100% - 16px) 100%,16px 100%,0% 50%); transition: all .3s; position: relative; overflow: hidden; }
.btn-body::before { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg,#0ab8d2,#12f0ff); opacity: 0; transition: opacity .3s; }
.roll-btn:hover .btn-body::before { opacity: 1; }
.roll-btn:hover .btn-body { box-shadow: 0 0 40px rgba(0,200,220,0.5); transform: scale(1.04); }
.roll-btn:active .btn-body { transform: scale(.96); }
.roll-btn:disabled .btn-body { opacity: .38; cursor: not-allowed; transform: none !important; }
.btn-text { font-size: 14px; font-weight: 800; letter-spacing: 5px; text-transform: uppercase; color: #fff; position: relative; z-index: 1; }

/* History */
.history { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; animation: fadeUp .7s ease .5s both; }
.hl { font-size: 8px; font-weight: 700; letter-spacing: 4px; text-transform: uppercase; color: rgba(0,150,170,0.38); }
#histList { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
.hc { font-size: 12px; font-weight: 800; color: rgba(0,160,180,0.42); border: 1px solid rgba(0,150,170,0.16); padding: 3px 10px; transition: all .3s; }
.hc.new { color: #10d8f0; border-color: rgba(0,200,220,0.5); }

/* Sparks */
#sparks { position: fixed; inset: 0; pointer-events: none; z-index: 99; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popUp { 0% { transform: scale(.7); opacity: 0; } 65% { transform: scale(1.05); } 100% { transform: scale(1); opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: translateY(0); } }
@keyframes breathe { 0%,100% { opacity:.4; transform:translateX(-50%) scaleX(1); } 50% { opacity:.85; transform:translateX(-50%) scaleX(1.25); } }
@keyframes popNum { 0% { transform:scale(.25); opacity:0; } 65% { transform:scale(1.18); opacity:1; } 100% { transform:scale(1); opacity:1; } }
/* Mobile */
@media (max-width: 768px) {
body {
  background-image: url('background-cube-mb.png');
  background-size: cover;
  background-position: center;
  background-attachment: scroll;
  width: 100%;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
} 
}