/* ============================================================
   REROLL EXPERIENCE — Cinematic overlay for NFT re-roll
   ============================================================ */

/* -- Overlay backdrop ---------------------------------------- */
.reroll-overlay {
  position: fixed;
  inset: 0;
  z-index: 350;
  background: rgba(6, 3, 14, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.35s ease;
  overflow-y: auto;
  padding: 24px 16px;
}
.reroll-overlay.visible { opacity: 1; }

.reroll-overlay::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(124,58,237,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(124,58,237,0.04) 0%, transparent 40%);
  pointer-events: none;
}

/* -- Scene container ----------------------------------------- */
.rr-scene {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 460px;
  width: 100%;
  background: linear-gradient(160deg, rgba(20,12,35,0.97), rgba(12,8,24,0.97));
  border: 1px solid rgba(124,58,237,0.2);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: 0 0 60px rgba(124,58,237,0.12), 0 20px 60px rgba(0,0,0,0.5);
}

/* -- Close button -------------------------------------------- */
.rr-close-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(124,58,237,0.15);
  border: 1px solid rgba(124,58,237,0.3);
  color: rgba(200,180,230,0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.2s;
  z-index: 5;
}
.rr-close-btn:hover { background: rgba(124,58,237,0.3); color: #fff; }

/* -- Sound toggle -------------------------------------------- */
.rr-sound-btn {
  position: absolute;
  top: -8px;
  left: -8px;
  z-index: 5;
  background: rgba(124,58,237,0.12);
  border: 1px solid rgba(124,58,237,0.25);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: rgba(180,140,255,0.7);
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.3s;
}
.rr-sound-btn:hover { background: rgba(124,58,237,0.25); color: #d4b0ff; }
.rr-sound-btn .rr-snd-icon { font-size: 15px; }

/* -- Title --------------------------------------------------- */
.rr-title {
  font-size: 22px;
  font-weight: 800;
  color: #d4b0ff;
  text-transform: uppercase;
  letter-spacing: 4px;
  text-shadow: 0 0 20px rgba(124,58,237,0.5), 0 0 60px rgba(124,58,237,0.2);
  text-align: center;
  animation: rrTitlePulse 3s ease-in-out infinite;
}
@keyframes rrTitlePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

/* -- NFT Card Preview ---------------------------------------- */
.rr-nft-card {
  position: relative;
  width: 240px;
  height: 240px;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid rgba(124,58,237,0.3);
  box-shadow: 0 0 30px rgba(124,58,237,0.12), 0 10px 40px rgba(0,0,0,0.5);
  background: #120a1e;
  flex-shrink: 0;
}
.rr-nft-card img,
.rr-nft-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.4s ease;
}
.rr-nft-card.rolling img,
.rr-nft-card.rolling video { animation: rrCharShake 0.15s ease-in-out infinite; }
.rr-nft-card.reveal img { animation: rrNftReveal 0.7s cubic-bezier(0.34,1.56,0.64,1); }

@keyframes rrCharShake {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  25% { transform: translateX(-4px) rotate(-1.5deg); }
  75% { transform: translateX(4px) rotate(1.5deg); }
}
@keyframes rrNftReveal {
  0% { transform: scale(0.85); opacity: 0; filter: brightness(2) saturate(0); }
  50% { transform: scale(1.05); filter: brightness(1.4) saturate(1.2); }
  100% { transform: scale(1); opacity: 1; filter: brightness(1) saturate(1); }
}

.rr-nft-card .rr-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(124,58,237,0.12) 50%, transparent 70%);
  background-size: 200% 100%;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}
.rr-nft-card.rolling .rr-shimmer {
  opacity: 1;
  animation: rrShimmer 1s linear infinite;
}
@keyframes rrShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* -- Layer Stack (compositing) ------------------------------- */
.rr-layer-stack {
  position: relative;
  width: 240px;
  height: 240px;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid rgba(124,58,237,0.3);
  box-shadow: 0 0 30px rgba(124,58,237,0.12), 0 10px 40px rgba(0,0,0,0.5);
  background: #120a1e;
  flex-shrink: 0;
  display: none;
}
.rr-layer-stack.visible { display: block; }
.rr-layer-stack img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.rr-layer {
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.rr-layer.show {
  opacity: 1;
  transform: scale(1);
  animation: rrLayerGlow 0.6s ease;
}
@keyframes rrLayerGlow {
  0% { filter: brightness(1) drop-shadow(0 0 0 transparent); }
  40% { filter: brightness(1.4) drop-shadow(0 0 12px rgba(124,58,237,0.5)); }
  100% { filter: brightness(1) drop-shadow(0 0 0 transparent); }
}

/* -- 3D Dice ------------------------------------------------- */
.rr-dice-area {
  display: flex;
  gap: 22px;
  perspective: 600px;
  min-height: 68px;
  align-items: center;
}
.rr-dice {
  width: 68px;
  height: 68px;
  position: relative;
  transform-style: preserve-3d;
}
.rr-dice.idle { animation: rrDiceFloat 3s ease-in-out infinite; }
.rr-dice:nth-child(2).idle { animation-delay: 0.5s; }
@keyframes rrDiceFloat {
  0%, 100% { transform: translateY(0) rotateX(5deg) rotateY(5deg); }
  50% { transform: translateY(-6px) rotateX(-5deg) rotateY(-5deg); }
}
.rr-dice.rolling { animation: rrDiceRoll 0.5s ease-in-out infinite; }
@keyframes rrDiceRoll {
  0%   { transform: rotateX(0) rotateY(0) rotateZ(0); }
  25%  { transform: rotateX(90deg) rotateY(45deg) rotateZ(90deg); }
  50%  { transform: rotateX(180deg) rotateY(180deg) rotateZ(180deg); }
  75%  { transform: rotateX(270deg) rotateY(315deg) rotateZ(270deg); }
  100% { transform: rotateX(360deg) rotateY(360deg) rotateZ(360deg); }
}
.rr-dice.result { animation: rrDiceLand 0.5s cubic-bezier(0.34,1.56,0.64,1) forwards; }
@keyframes rrDiceLand {
  0%  { transform: rotateX(720deg) rotateY(720deg) scale(0.5); opacity: 0.5; }
  60% { transform: rotateX(0) rotateY(0) scale(1.15); }
  100%{ transform: rotateX(0) rotateY(0) scale(1); opacity: 1; }
}

.rr-dice-face {
  position: absolute;
  width: 68px;
  height: 68px;
  background: linear-gradient(135deg, #1a1030 0%, #100a1c 100%);
  border: 2px solid rgba(124,58,237,0.35);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
}
.rr-dice-face.front  { transform: translateZ(34px); }
.rr-dice-face.back   { transform: rotateY(180deg) translateZ(34px); }
.rr-dice-face.right  { transform: rotateY(90deg) translateZ(34px); }
.rr-dice-face.left   { transform: rotateY(-90deg) translateZ(34px); }
.rr-dice-face.top    { transform: rotateX(90deg) translateZ(34px); }
.rr-dice-face.bottom { transform: rotateX(-90deg) translateZ(34px); }

.rr-dice-face .rr-qmark {
  font-size: 28px;
  font-weight: 900;
  color: #d4b0ff;
  text-shadow: 0 0 12px rgba(124,58,237,0.6);
}
.rr-dice-face .rr-dice-label {
  font-size: 10px;
  font-weight: 700;
  color: #d4b0ff;
  text-shadow: 0 0 8px rgba(124,58,237,0.5);
  text-align: center;
  line-height: 1.2;
  padding: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* -- Status text --------------------------------------------- */
.rr-status {
  font-size: 14px;
  font-weight: 600;
  color: rgba(124,58,237,0.5);
  letter-spacing: 2px;
  min-height: 20px;
  text-align: center;
  transition: all 0.3s ease;
}
.rr-status.active {
  color: #d4b0ff;
  text-shadow: 0 0 10px rgba(124,58,237,0.4);
  animation: rrFadeIn 0.5s ease;
}
.rr-status.pending { color: #ffd966; }
@keyframes rrFadeIn {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* -- Traits Panel -------------------------------------------- */
.rr-traits-panel {
  width: 100%;
  overflow: hidden;
  transition: opacity 0.4s ease;
  opacity: 0;
}
.rr-traits-panel.visible { opacity: 1; }

.rr-traits-title {
  font-size: 11px;
  font-weight: 700;
  color: rgba(124,58,237,0.5);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 10px;
  text-align: center;
}
.rr-traits-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.rr-trait {
  background: #16102a;
  border: 1px solid rgba(124,58,237,0.15);
  border-radius: 10px;
  padding: 10px 12px;
  opacity: 0;
  transform: translateY(12px) scale(0.95);
  transition: all 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
.rr-trait.show { opacity: 1; transform: translateY(0) scale(1); }
.rr-trait.just-revealed { animation: rrTraitFlash 0.6s ease; }
@keyframes rrTraitFlash {
  0%  { box-shadow: 0 0 0 rgba(124,58,237,0); }
  30% { box-shadow: 0 0 25px rgba(124,58,237,0.4); border-color: #d4b0ff; }
  100%{ box-shadow: 0 0 12px rgba(124,58,237,0.1); }
}

.rr-trait-type {
  font-size: 9px;
  font-weight: 600;
  color: rgba(124,58,237,0.45);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.rr-trait-value {
  font-size: 14px;
  font-weight: 700;
  color: #e8e0f0;
  letter-spacing: 0.5px;
  min-height: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.rr-trait-value .rr-rolling-ph {
  display: inline-block;
  width: 60px;
  height: 14px;
  background: linear-gradient(90deg, #1a1030 25%, #251a40 50%, #1a1030 75%);
  background-size: 200% 100%;
  animation: rrShimmerPh 1.5s ease-in-out infinite;
  border-radius: 4px;
  vertical-align: middle;
}
@keyframes rrShimmerPh {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
/* -- Rarity badges (replaces NEW badge) ---------------------- */
.rr-rarity-badge {
  display: inline-block;
  font-size: 0.55rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
  flex-shrink: 0;
  animation: rrBadgePop 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
.rr-rarity-badge.rarity-mythic { background: rgba(255,69,0,0.2); color: #ff6b6b; }
.rr-rarity-badge.rarity-legendary { background: rgba(245,158,11,0.18); color: #fbbf24; }
.rr-rarity-badge.rarity-epic { background: rgba(168,85,247,0.18); color: #c084fc; }
.rr-rarity-badge.rarity-rare { background: rgba(59,130,246,0.18); color: #60a5fa; }
.rr-rarity-badge.rarity-uncommon { background: rgba(34,197,94,0.15); color: #22c55e; }
.rr-rarity-badge.rarity-common { background: rgba(107,114,128,0.2); color: #9ca3af; }
@keyframes rrBadgePop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

/* -- Action buttons ------------------------------------------ */
.rr-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}
.rr-roll-btn {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  border: none;
  padding: 14px 40px;
  border-radius: 12px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 30px rgba(124,58,237,0.25), 0 4px 20px rgba(0,0,0,0.4);
  transition: all 0.3s ease;
}
.rr-roll-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 0 50px rgba(124,58,237,0.4), 0 8px 30px rgba(0,0,0,0.4);
}
.rr-roll-btn:active:not(:disabled) { transform: translateY(1px); }
.rr-roll-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.rr-roll-btn .rr-cost {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1px;
  opacity: 0.7;
  margin-top: 3px;
}
.rr-roll-btn::after {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.15) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: rrBtnShine 3s ease-in-out infinite;
}
@keyframes rrBtnShine {
  0%, 100% { transform: translateX(-100%); }
  50% { transform: translateX(100%); }
}

.rr-cancel-btn {
  font-size: 13px;
  font-weight: 600;
  color: rgba(200,180,230,0.6);
  background: transparent;
  border: 1px solid rgba(124,58,237,0.2);
  padding: 12px 24px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}
.rr-cancel-btn:hover { color: #fff; border-color: rgba(124,58,237,0.4); }

/* -- Complete state buttons ---------------------------------- */
.rr-done-btn {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  border: none;
  padding: 12px 32px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}
.rr-done-btn:hover { transform: translateY(-1px); box-shadow: 0 0 30px rgba(124,58,237,0.3); }

.rr-explorer-link {
  font-size: 12px;
  font-weight: 600;
  color: rgba(180,140,255,0.7);
  text-decoration: underline;
  cursor: pointer;
  transition: color 0.2s;
}
.rr-explorer-link:hover { color: #d4b0ff; }

.rr-again-btn {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  background: transparent;
  border: 1px solid rgba(124,58,237,0.5);
  color: #d4b0ff;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.rr-again-btn:hover { background: rgba(124,58,237,0.1); border-color: rgba(124,58,237,0.8); }

/* -- Particles ----------------------------------------------- */
.rr-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 351;
}
.rr-particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #d4b0ff;
  opacity: 0;
}
.rr-particle.burst {
  animation: rrParticleBurst 1s ease-out forwards;
}
@keyframes rrParticleBurst {
  0%   { opacity: 1; transform: translate(0,0) scale(1); }
  100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(0); }
}

/* -- Price info ---------------------------------------------- */
.rr-price-info {
  text-align: center;
  font-size: 13px;
  color: rgba(200,180,230,0.7);
}
.rr-price-info strong {
  color: #e8e0f0;
  font-size: 15px;
}
.rr-price-info .rr-fee-breakdown {
  font-size: 11px;
  color: rgba(180,140,255,0.45);
  margin-top: 2px;
}
.rr-price-info .rr-avail {
  font-size: 11px;
  color: rgba(180,140,255,0.5);
  margin-top: 2px;
}

/* -- Responsive ---------------------------------------------- */
@media (max-width: 640px) {
  .rr-scene { gap: 16px; }
  .rr-nft-card,
  .rr-layer-stack { width: 200px; height: 200px; }
  .rr-dice { width: 56px; height: 56px; }
  .rr-dice-face { width: 56px; height: 56px; }
  .rr-dice-face.front  { transform: translateZ(28px); }
  .rr-dice-face.back   { transform: rotateY(180deg) translateZ(28px); }
  .rr-dice-face.right  { transform: rotateY(90deg) translateZ(28px); }
  .rr-dice-face.left   { transform: rotateY(-90deg) translateZ(28px); }
  .rr-dice-face.top    { transform: rotateX(90deg) translateZ(28px); }
  .rr-dice-face.bottom { transform: rotateX(-90deg) translateZ(28px); }
  .rr-title { font-size: 18px; letter-spacing: 3px; }
  .rr-roll-btn { padding: 12px 30px; font-size: 14px; }
  .rr-traits-grid { gap: 6px; }
  .rr-trait { padding: 8px 10px; }
}
