:root {
  --success: rgba(0, 150, 0, 0.2);
  --failure: rgba(150, 0, 0, 0.2);
}

@keyframes spin {
  0% {
    filter: blur(0);
  }
  50% {
    filter: blur(1px);
  }
  100% {
    filter: blur(0);
  }
}

#tray {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;

  .buttons {
    width: 100%;
    justify-content: space-between;
    align-items: center;
  
    div {
      display: flex;
      gap: 3px;
    }
  }
}

#dice {
  display: grid;
  gap: 5px;
  grid-template-columns: repeat(6, 1fr);
  perspective: 600px;
}

#dieSlot {
  padding: 25px;
  opacity: 0.5;
  transition: opacity .5s;
  position: relative;
  border-radius: 50%;
  transition: transform .5s;

  &.rolling {
    transform: translateY(-30px) scale(0.7);
    transition: transform .5s;
  }
}

.die {
  width: 50px;
  height: 50px;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(-45deg) rotateY(-45deg) rotateZ(-90deg);
  transition: transform 0.5s ease;
}

#continue {
  display: none;
  opacity: 0;
  transition: opacity .5s
}

#calc {
  display: none;
  font-size: 16px;
  gap: 10px;
  align-items: center;
  color: var(--body);
  
  span {
    color: var(--dark);
    font-weight: bold;
  }
  
  input {
    display: block;
    border: 2px solid var(--border);
    border-radius: 3px;
    width: 50px;
    height: 30px;
    text-align: right;
  }
}

#tray.panicking {
  #continue {
    display: flex;
  }

  #roll {
    display: none;
  }

  #adjustDice {
    display: none;
  }
  
  #calc {
    display: flex;
  }

  #dieSlot:not(.panic) {
    display: none;
  }
}

#tray.panicked {
  #continue {
    opacity: 1;
  }
}

#tray.total #calc {
  display: flex;
}

#rolled {
  display: none;
  font-size: 16px;
  gap: 20px;

  span {
    color: var(--strong);
    font-weight: bold;
  }

  #warning {
    color: #ccc;
  
    &:before {
      content: " (";
      display: inline;
    }

    &:after {
      content: ")";
    }
  }
}

.halos:not(.panicking) #rolled {
  display: flex;
}

#popup #panic {
  display: none;
  background: #900;

  &:hover {
    color: black;
  }
}

#popup #tray.panic {
  #panic {
    display: flex;
  }
  
  #roll {
    display: none;
  }
}

.face {
  position: absolute;
  width: 50px;
  height: 50px;
  background: linear-gradient(#fff, #eee);
  border: 2px inset rgba(0,0,0, .3);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  
  &.one   {transform: rotateY(0deg)    translateZ(25px);}
  &.two   {transform: rotateX(-90deg)  translateZ(25px);}
  &.three {transform: rotateY(90deg)   translateZ(25px);}
  &.four  {transform: rotateY(-90deg)  translateZ(25px);}
  &.five  {transform: rotateX(90deg)   translateZ(25px);}
  &.six   {transform: rotateY(180deg)  translateZ(25px);}
  
  .dot {
    width: 8px;
    height: 9px;
    background: linear-gradient(#000, #999);
    border-radius: 50%;
    position: absolute;
    visibility: hidden;

    &.center        { top: 21px; left: 21px; }
    &.top-left      { top: 10px; left: 10px; }
    &.top-right     { top: 10px; right: 10px; }
    &.bottom-left   { bottom: 10px; left: 10px; }
    &.bottom-right  { bottom: 10px; right: 10px; }
    &.center-left   { top: 21px; left: 10px; }
    &.center-right  { top: 21px; right: 10px; }
  }
}

#dieSlot:has(.rolled) {
  opacity: 1;
  animation: spin .5s ease;
}
#dieSlot:has(.disabled) {
  opacity: 0.2;
}

.die.rolled .dot {
  visibility: visible;
}

[data-rolled="1"] {transform: rotateX(  45deg) rotateY(      0) rotateZ(-45deg);}
[data-rolled="2"] {transform: rotateX(-225deg) rotateY( 225deg) rotateZ(     0);}
[data-rolled="3"] {transform: rotateX( -45deg) rotateY(-135deg) rotateZ(270deg);}
[data-rolled="4"] {transform: rotateX( -45deg) rotateY( 225deg) rotateZ( 90deg);}
[data-rolled="5"] {transform: rotateX( -45deg) rotateY(-135deg) rotateZ(     0);}
[data-rolled="6"] {transform: rotateX(  45deg) rotateY( 180deg) rotateZ(135deg);}

.halos:not(.panicking) {
  #dieSlot:has([data-rolled="1"]) {
    box-shadow: 0 0 10px 4px #ccc inset;
  }
  
  .success {
    box-shadow: 0 0 10px 4px var(--success) inset !important;
  }

  .failure {
    box-shadow: 0 0 10px 4px var(--failure) inset !important;
  }
}

#tray .strain .face {
  background: linear-gradient(#900, #800);
}

#tray .added .face {
  background: linear-gradient(#090, #080);
}

#tray .keep .face {
  background: linear-gradient(#999, #888);
}

#tray .disabled .face {
  background: linear-gradient(#999, #888);
}

#tray .panic .face {
  background: linear-gradient(#000, #333);
}

.panic .dot,
.keep .dot,
.added .dot,
.strain .dot {
  background: linear-gradient(#fff, #999);
}
