/* Dice tray V4: independent scattering and real transforms without flex rows. */
#dice #diceSet.tray-dice{
  position:relative;display:block;min-width:0;width:100%;min-height:250px;
  perspective:850px;perspective-origin:50% 37%;touch-action:manipulation;
  overflow:visible;isolation:isolate;padding:0!important;gap:0!important;
}
#dice .tray-dice[data-motion="v4"] .die-box{
  position:absolute!important;display:block!important;inset:auto;width:var(--die-size,72px);
  height:calc(var(--die-size,72px) + 21px);min-width:0;min-height:0;
  contain:none!important;transform-origin:50% 50%;will-change:transform;
}
#dice .tray-dice[data-motion="v4"] .die-box::before{
  content:"";position:absolute;left:15%;right:15%;top:calc(var(--die-size,72px) * .78);
  height:13px;bottom:auto;background:#001c1588;border-radius:100%;
  filter:blur(7px);opacity:.7;pointer-events:none
}
#dice .tray-dice[data-motion="v4"] .dice-piece{
  position:relative;width:var(--die-size,72px)!important;height:var(--die-size,72px)!important;
  min-height:0;margin:0!important;display:grid;place-items:center;touch-action:manipulation;
  will-change:auto;transition:box-shadow .16s,filter .16s;border-radius:14px;
}
#dice .tray-dice[data-motion="v4"] .dice-piece.d6{
  perspective:none!important;overflow:visible!important;transform:none!important;
}
#dice .tray-dice[data-motion="v4"] .tgr-cube{
  --cube-face:clamp(40px,calc(var(--die-size,72px) * .79),61px);
  position:relative;width:var(--cube-face);height:var(--cube-face);display:block;
  transform-style:preserve-3d;transform:rotateX(var(--face-x,0deg)) rotateY(var(--face-y,0deg));
  will-change:transform;
}
#dice .tray-dice[data-motion="v4"] .tgr-d6-face{
  width:var(--cube-face);height:var(--cube-face);border-radius:clamp(6px,1vw,11px);
  padding:clamp(6px,1.5vw,10px);backface-visibility:visible;
}
#dice .tray-dice[data-motion="v4"] .tgr-d6-face.face-1{transform:translateZ(calc(var(--cube-face) / 2))}
#dice .tray-dice[data-motion="v4"] .tgr-d6-face.face-6{transform:rotateY(180deg) translateZ(calc(var(--cube-face) / 2))}
#dice .tray-dice[data-motion="v4"] .tgr-d6-face.face-2{transform:rotateY(90deg) translateZ(calc(var(--cube-face) / 2))}
#dice .tray-dice[data-motion="v4"] .tgr-d6-face.face-5{transform:rotateY(-90deg) translateZ(calc(var(--cube-face) / 2))}
#dice .tray-dice[data-motion="v4"] .tgr-d6-face.face-3{transform:rotateX(90deg) translateZ(calc(var(--cube-face) / 2))}
#dice .tray-dice[data-motion="v4"] .tgr-d6-face.face-4{transform:rotateX(-90deg) translateZ(calc(var(--cube-face) / 2))}
#dice .tray-dice[data-motion="v4"] .tgr-d6-face .pip{width:clamp(6px,1vw,9px);height:clamp(6px,1vw,9px)}
#dice .tray-dice[data-motion="v4"] .hold-label{
  position:absolute;top:calc(var(--die-size,72px) + 3px);left:-8px;right:-8px;
  text-align:center;min-height:16px;line-height:16px;margin:0;font-size:10px;
  pointer-events:none;color:#d4cdb3;white-space:nowrap;text-shadow:0 1px 3px #00140e;
}
#dice .tray-dice[data-motion="v4"] .hold-label.yes{color:#ffdf87;font-weight:800}
#dice .tray-dice[data-motion="v4"] .die-box.is-held{z-index:3}
#dice .tray-dice[data-motion="v4"] .dice-piece.held{
  outline:2px solid #ffdf88;outline-offset:2px;
  box-shadow:0 0 0 5px #ffdc7b4d,0 0 22px #ffd16d75!important;
}
#dice .tray-dice[data-motion="v4"] .dice-piece.rolling,
#dice .tray-dice[data-motion="v4"] .dice-piece.rolling .tgr-cube,
#dice .tray-dice[data-motion="v4"] .dice-piece.rolling .tgr-poly,
#dice .tray-dice[data-motion="v4"] .dice-piece.landed,
#dice .tray-dice[data-motion="v4"] .dice-piece.landed .tgr-cube{
  animation:none!important;
}
#dice .tray-dice[data-motion="v4"] .dice-piece:not(.d6):not(.custom) .tgr-poly{width:100%;height:100%}
#dice .tray[data-material="ivory"] .tray-dice[data-motion="v4"] .die-box:not(.is-held) .dice-piece:hover{filter:brightness(1.07)}
#dice .tray-dice[data-motion="v4"] .die-box:focus-within{z-index:5}
#dice .tray-dice[data-motion="v4"] .die-box button:focus-visible{outline:3px solid #e8ba6f;outline-offset:3px}
@media(max-width:450px){
 #dice .tray{padding:14px 9px 16px!important}
 #dice .tray-dice[data-motion="v4"] .tgr-d6-face .pip{width:7px;height:7px}
 #dice .tray-dice[data-motion="v4"] .hold-label{font-size:9px}
}
@media(prefers-reduced-motion:reduce){#dice .tray-dice[data-motion="v4"] .die-box,
 #dice .tray-dice[data-motion="v4"] .tgr-cube,
 #dice .tray-dice[data-motion="v4"] .tgr-poly{animation:none!important;transition:none!important;will-change:auto}}

/* Older browsers without Web Animations get a visible lightweight toss. */
#dice .tray-dice.motion-fallback .die-box:not(.is-held){animation:tgrDiceFallback .92s cubic-bezier(.17,.63,.2,1) both}
#dice .tray-dice.motion-fallback .die-box:not(.is-held) .tgr-cube{animation:tgrCubeFallback .92s ease-out both}
@keyframes tgrDiceFallback{0%{transform:translate(-18px,-22px) rotate(-28deg)}40%{transform:translate(11px,-36px) rotate(35deg)}75%{transform:translate(-4px,-10px) rotate(-8deg)}100%{transform:none}}
@keyframes tgrCubeFallback{0%{transform:rotateX(calc(var(--face-x) + 720deg)) rotateY(calc(var(--face-y) + 720deg))}100%{transform:rotateX(var(--face-x)) rotateY(var(--face-y))}}
@media(prefers-reduced-motion:reduce){#dice .tray-dice.motion-fallback .die-box,#dice .tray-dice.motion-fallback .tgr-cube{animation:none!important}}
