#dice-roll-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
  pointer-events: none;
  background: radial-gradient(ellipse at center, #040b1070, #030507b5);
}
#dice-roll-overlay[hidden] {
  display: none;
}
.dice-roll-card {
  --dice-accent: #d4bc87;
  position: relative;
  isolation: isolate;
  display: grid;
  justify-items: center;
  width: min(23rem, 92vw);
  padding: 1.6rem 1rem 1.5rem;
  border: 1px solid #bda57060;
  border-radius: 22px;
  background:
    radial-gradient(ellipse at 50% 38%, #23434950, transparent 65%),
    linear-gradient(145deg, #172025f7, #080d13fa 70%);
  box-shadow:
    0 25px 90px #000b,
    inset 0 1px #fff1;
  text-align: center;
  transition:
    border-color 0.4s,
    box-shadow 0.4s;
}
.dice-roll-card::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 7px;
  border: 1px solid #c7ad7318;
  border-radius: 16px;
  pointer-events: none;
}
.dice-roll-card p {
  margin: 0;
}
.dice-eyebrow {
  color: var(--dice-accent);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.23em;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}
#dice-roller-name {
  max-width: 100%;
  overflow-wrap: anywhere;
  color: #eee6d5;
  font-size: 0.95rem;
}
#dice-roll-status {
  color: #a7b8bd;
  font-size: 0.85rem;
  min-height: 1.3em;
  margin-top: 0.55rem;
}
.d20-stage {
  position: relative;
  width: min(19rem, 77vw, 47dvh);
  aspect-ratio: 1;
}
#dice-roll-overlay.rolling .d20-stage::before,
#dice-roll-overlay.rolling .d20-stage::after {
  content: '';
  position: absolute;
  inset: calc(50% - 2.3rem);
  border: 1px solid #d4bc8730;
  border-radius: 50%;
}
#dice-roll-overlay.rolling .d20-stage::before {
  content: attr(data-die);
  display: grid;
  place-items: center;
  color: #d4bc8780;
  font:
    1.4rem Georgia,
    serif;
}
#dice-roll-overlay.rolling .d20-stage::after {
  border-top-color: #d4bc87;
  animation: dice-preparing 1.2s linear infinite;
}
@keyframes dice-preparing {
  to {
    transform: rotate(360deg);
  }
}
.d20-stage canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}
.dice-stages {
  display: flex;
  justify-content: center;
  align-items: center;
}
.dice-body {
  min-width: 0;
}
.dice-component-label {
  display: block;
  color: #a7b8bd;
  font-size: 11px;
  padding-bottom: 12px;
}
#dice-roll-overlay[data-sides='100'] .dice-roll-card {
  width: min(40rem, 94vw);
}
#dice-roll-overlay[data-sides='100'] .d20-stage {
  width: min(18rem, 40vw, 44dvh);
}
.dice-result {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--dice-accent);
}
.dice-result-rule {
  width: 2.4rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--dice-accent));
  opacity: 0.55;
}
.dice-result-rule:last-child {
  transform: rotate(180deg);
}
#dice-roll-value {
  min-width: 2ch;
  font:
    500 2.6rem/1 Georgia,
    serif;
  font-variant-numeric: lining-nums tabular-nums;
}
#dice-roll-overlay.rolling #dice-roll-value,
#dice-roll-overlay.settling #dice-roll-value {
  opacity: 0.35;
}
#dice-roll-overlay.critical .dice-roll-card {
  --dice-accent: #ffe0a0;
  border-color: #ebbc6c;
  box-shadow:
    0 25px 90px #000b,
    0 0 75px #e9af3830,
    inset 0 0 65px #b978171c;
}
#dice-roll-overlay.fumble .dice-roll-card {
  --dice-accent: #f6989d;
  border-color: #a64956;
  box-shadow:
    0 25px 90px #000b,
    0 0 65px #ae233228,
    inset 0 0 65px #8a172322;
}
#dice-roll-overlay[data-sides='2'].fumble .dice-roll-card {
  --dice-accent: #e4ad85;
  border-color: #b47755;
  box-shadow:
    0 25px 90px #000b,
    0 0 65px #9e542c28,
    inset 0 0 65px #6d35191c;
}
#dice-roll-overlay.critical #dice-roll-status,
#dice-roll-overlay.fumble #dice-roll-status {
  color: var(--dice-accent);
  font-weight: 700;
  letter-spacing: 0.035em;
}
#dice-roll-overlay.revealed .dice-result {
  animation: dice-result-reveal 0.45s ease-out both;
}
@keyframes dice-result-reveal {
  from {
    opacity: 0;
    transform: translateY(5px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@media (prefers-reduced-motion: reduce) {
  .dice-roll-card {
    transition: none;
  }
  #dice-roll-overlay.revealed .dice-result,
  #dice-roll-overlay.rolling .d20-stage::after {
    animation: none;
  }
}
