/* ============================================
   DICE ROLLER - INPUT BAR INTEGRATION
   ============================================ */

/* Dice Roller Container (replaces input bar during gameplay) */
.dice-roller-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1rem;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--glass-border);
  z-index: 1000;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.dice-roller-container.hidden {
  opacity: 0;
  transform: translateY(100%);
  pointer-events: none;
}

/* Dice Roller Content */
.dice-roller-content {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  transition: opacity 0.3s ease;
}

.dice-roller-content.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Dice Roll Prompt */
.dice-roll-prompt {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary-color);
  text-align: center;
}

.dice-icon {
  font-size: 1.5rem;
  animation: dice-idle-bounce 2s ease-in-out infinite;
}

@keyframes dice-idle-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

/* Roll Dice Button */
.roll-dice-button {
  padding: 1rem 2rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: white;
  background: linear-gradient(
    135deg,
    var(--crimson-accent),
    var(--crimson-damage)
  );
  border: 2px solid var(--crimson-accent);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(248, 113, 113, 0.3);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.roll-dice-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(248, 113, 113, 0.5);
  background: linear-gradient(
    135deg,
    var(--crimson-damage),
    var(--crimson-fire)
  );
}

.roll-dice-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(248, 113, 113, 0.4);
}

/* Pulse Animation (when DM requests roll) */
.roll-dice-button.pulse {
  animation: dice-button-pulse 1.5s ease-in-out infinite;
}

@keyframes dice-button-pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 4px 12px rgba(248, 113, 113, 0.3);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(248, 113, 113, 0.6);
  }
}

/* ============================================
   DICE ANIMATION ZONE
   ============================================ */

.dice-animation-zone {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  background: rgba(20, 10, 10, 0.95);
  z-index: 2000;
  transition: opacity 0.3s ease;
}

.dice-animation-zone.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Individual Dice During Animation */
.dice-animation-zone .dice-3d-container {
  transform: translateX(var(--dice-offset-x, 0)) translateY(0);
  transition: transform 0.3s ease;
}

/* Rolling Animation */
.dice-3d-container.rolling .dice-cube {
  animation: dice-shoot-and-bounce 2s cubic-bezier(0.68, -0.55, 0.265, 1.55)
    forwards;
}

@keyframes dice-shoot-and-bounce {
  0% {
    transform: translateY(0) rotateX(0) rotateY(0) rotateZ(0) scale(1);
  }
  15% {
    transform: translateY(-400px) rotateX(360deg) rotateY(180deg) rotateZ(90deg)
      scale(1.2);
  }
  30% {
    transform: translateY(-300px) rotateX(540deg) rotateY(360deg)
      rotateZ(180deg) scale(1.1);
  }
  50% {
    transform: translateY(50px) rotateX(720deg) rotateY(540deg) rotateZ(270deg)
      scale(1);
  }
  65% {
    transform: translateY(-30px) rotateX(780deg) rotateY(600deg) rotateZ(300deg)
      scale(1);
  }
  80% {
    transform: translateY(10px) rotateX(810deg) rotateY(630deg) rotateZ(315deg)
      scale(1);
  }
  90% {
    transform: translateY(-5px) rotateX(820deg) rotateY(640deg) rotateZ(320deg)
      scale(1);
  }
  100% {
    transform: translateY(0) rotateX(825deg) rotateY(645deg) rotateZ(325deg)
      scale(1);
  }
}

/* Settled State */
.dice-3d-container.settled .dice-cube {
  animation: dice-settle 0.5s ease-out forwards;
}

@keyframes dice-settle {
  0% {
    transform: var(--final-rotation, rotateX(0) rotateY(0)) scale(1.1);
  }
  100% {
    transform: var(--final-rotation, rotateX(0) rotateY(0)) scale(1);
  }
}

/* ============================================
   DICE RESULT DISPLAY
   ============================================ */

.dice-result-display {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--glass-bg);
  backdrop-filter: blur(15px);
  border: 2px solid var(--crimson-accent);
  border-radius: 20px;
  padding: 2rem 3rem;
  text-align: center;
  z-index: 2100;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  min-width: 300px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.dice-result-display.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.8);
}

/* Float Up Animation */
.dice-result-display.float-up .result-number {
  animation: result-float-up 1s ease-out forwards;
}

@keyframes result-float-up {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  50% {
    transform: translateY(-30px) scale(1.2);
    opacity: 1;
  }
  100% {
    transform: translateY(-50px) scale(1.1);
    opacity: 0.9;
  }
}

/* Result Number */
.result-number {
  font-size: 4rem;
  font-weight: 900;
  color: var(--crimson-accent);
  text-shadow: 0 0 20px rgba(248, 113, 113, 0.5);
  margin-bottom: 0.5rem;
  line-height: 1;
}

/* Result Label */
.result-label {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 1.5rem;
  opacity: 0.9;
}

/* Result Actions */
.result-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.result-action-btn {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: white;
  background: var(--glass-bg);
  border: 2px solid var(--crimson-accent);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.result-action-btn:hover {
  background: var(--crimson-accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(248, 113, 113, 0.4);
}

.result-action-btn:active {
  transform: translateY(0);
}

/* ============================================
   DICE ROLLER UI - CENTERED FLOATING DESIGN
   ============================================ */

/* Backdrop overlay */
.dice-roller-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.dice-roller-backdrop.show {
  opacity: 1;
  visibility: visible;
}

.dice-roller-ui {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2000; /* Above everything */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.dice-roller-ui.show {
  opacity: 1;
  visibility: visible;
  animation: floatIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes floatIn {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

.dice-roller-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 25%, transparent) 0%,
    color-mix(in srgb, var(--dice) 15%, transparent) 100%
  );
  border: 2px solid color-mix(in srgb, var(--dice) 50%, transparent);
  border-radius: 20px;
  padding: 24px 32px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5),
    0 0 40px color-mix(in srgb, var(--dice) 40%, transparent);
  animation: gentleFloat 3s ease-in-out infinite;
}

@keyframes gentleFloat {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

.dice-roller-button:hover {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 35%, transparent) 0%,
    color-mix(in srgb, var(--dice) 25%, transparent) 100%
  );
  border-color: color-mix(in srgb, var(--dice) 70%, transparent);
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6),
    0 0 60px color-mix(in srgb, var(--dice) 60%, transparent);
  animation: none; /* Stop floating when hovering */
}

.dice-roller-button:active {
  transform: translateY(-2px) scale(1.02);
}

/* D20 Container */
.d20-container {
  width: 80px;
  height: 80px;
  position: relative;
  perspective: 1000px;
}

.d20-die {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s ease-out;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* D20 Number Display */
.d20-number {
  font-size: 3rem;
  font-weight: 900;
  color: var(--dice);
  text-shadow: 0 0 10px color-mix(in srgb, var(--dice) 50%, transparent),
    0 2px 4px rgba(0, 0, 0, 0.5);
  font-family: "Cinzel", serif;
  user-select: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
}

/* Spinning Animation */
.d20-die.spinning {
  animation: d20-spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes d20-spin {
  0% {
    transform: rotateX(0) rotateY(0) rotateZ(0);
  }
  25% {
    transform: rotateX(360deg) rotateY(180deg) rotateZ(90deg);
  }
  50% {
    transform: rotateX(720deg) rotateY(360deg) rotateZ(180deg);
  }
  75% {
    transform: rotateX(1080deg) rotateY(540deg) rotateZ(270deg);
  }
  100% {
    transform: rotateX(1440deg) rotateY(720deg) rotateZ(360deg);
  }
}

/* Result Pulse Animation */
.d20-number.result-pulse {
  animation: result-pulse 0.5s ease-out;
}

@keyframes result-pulse {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.3);
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

/* Critical Success (Natural 20) */
.d20-number.critical-success {
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 0 0 40px rgba(255, 215, 0, 0.5);
  animation: critical-glow 1s ease-in-out infinite alternate;
}

@keyframes critical-glow {
  from {
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8),
      0 0 40px rgba(255, 215, 0, 0.5);
  }
  to {
    text-shadow: 0 0 30px rgba(255, 215, 0, 1), 0 0 60px rgba(255, 215, 0, 0.7),
      0 0 80px rgba(255, 215, 0, 0.4);
  }
}

/* Critical Failure (Natural 1) */
.d20-number.critical-failure {
  color: #dc2626;
  text-shadow: 0 0 20px rgba(220, 38, 38, 0.8), 0 0 40px rgba(220, 38, 38, 0.5);
}

/* Dice Roller Label */
.dice-roller-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: "Georgia", serif;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .dice-roller-container {
    padding: 0.75rem;
  }

  .dice-roll-prompt {
    font-size: 1rem;
    gap: 0.5rem;
  }

  .dice-icon {
    font-size: 1.2rem;
  }

  .roll-dice-button {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
  }

  .dice-animation-zone {
    gap: 1rem;
  }

  /* Scale down dice on mobile */
  .dice-animation-zone .dice-3d-container {
    transform: translateX(var(--dice-offset-x, 0)) scale(0.8);
  }

  .result-number {
    font-size: 3rem;
  }

  .result-label {
    font-size: 1rem;
  }

  .dice-result-display {
    min-width: 250px;
    padding: 1.5rem 2rem;
  }

  .result-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .result-action-btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .dice-roll-prompt {
    font-size: 0.9rem;
    flex-wrap: wrap;
  }

  .roll-dice-button {
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
  }

  .dice-animation-zone .dice-3d-container {
    transform: translateX(var(--dice-offset-x, 0)) scale(0.6);
  }

  .result-number {
    font-size: 2.5rem;
  }
}
