.dice-stage{position:fixed;inset:auto 20px 20px auto;margin:0;width:min(580px,calc(100% - 24px));max-height:min(70vh,680px);overflow:auto;box-sizing:border-box;z-index:10000;background:linear-gradient(135deg,#24352b,#111e18);color:#eee6cf;border:1px solid #b29a5b;border-radius:14px;padding:18px;box-shadow:0 12px 60px #0009;font:inherit}
.dice-stage[hidden]{display:none}.dice-stage::backdrop{background:transparent;pointer-events:none}.dice-heading{display:flex;align-items:flex-start;gap:12px;justify-content:space-between}.dice-heading h3{margin:5px 0 14px;font-size:1.15rem}.dice-heading small{color:#d9c78b;letter-spacing:.08em;font-size:.68rem}.dice-heading button{font-size:24px;line-height:1;padding:8px 12px}.dice-stage[data-private=true]{border-color:#b9a0d7}
.dice-tray{padding:4px 4px 18px;perspective:700px}.dice-group+.dice-group{margin-top:14px}.dice-group-label{color:#d5cfb9;font-size:.8rem;margin-bottom:8px}.dice-row{display:flex;gap:10px;flex-wrap:wrap;padding:3px}.roll-die{--die-bg:#eae1c6;--die-ink:#242821;position:relative;display:grid;place-content:center;text-align:center;width:49px;height:53px;color:var(--die-ink);background:linear-gradient(145deg,#ffffff28,transparent 55%),var(--die-bg);border:1px solid #ffffff45;border-radius:9px;box-shadow:inset -3px -4px 0 #0003,inset 2px 2px 0 #ffffff35,3px 6px 0 #0005;transform-origin:center center;flex:none}
.die-face{font:44px/1 'Segoe UI Symbol',sans-serif}.roll-die small{font-size:8px;line-height:1.2;letter-spacing:.08em}.die-skill{--die-bg:#9e343e;--die-ink:#fff1df}.die-gear,.die-armor{--die-bg:#242a30;--die-ink:#f6edda}.die-cover{--die-bg:#3d6459;--die-ink:#eff4e5}.die-artifact{--die-bg:#d7ac4d;--die-ink:#352707}.die-magic{--die-bg:#755393;--die-ink:#fff2ff}.die-table{--die-bg:#326e8a;--die-ink:#f2faff}.die-monster{--die-bg:#a85b28;--die-ink:#fff1d8}.poly-die{clip-path:polygon(50% 0,100% 25%,90% 80%,50% 100%,10% 80%,0 25%);border-radius:0;height:58px}.poly-die .die-face{font:bold 24px/1.2 Georgia,serif}
.dice-stage[data-phase=rolling] .roll-die{animation:dice-tumble .85s cubic-bezier(.2,.6,.3,1) both;animation-delay:calc(var(--i)*.018s)}
@keyframes dice-tumble{0%{transform:translate(70px,-60px) rotateX(180deg) rotateY(160deg) rotateZ(-90deg);opacity:0}15%{opacity:1}45%{transform:translate(-10px,7px) rotateX(-140deg) rotateY(200deg) rotateZ(35deg)}72%{transform:translate(4px,-14px) rotateX(25deg) rotateY(-20deg) rotateZ(-12deg)}88%{transform:translate(-2px,3px) rotateZ(5deg)}100%{transform:none}}
.dice-outcome{border-top:1px solid #b29a5b55;padding-top:12px;display:flex;gap:12px;align-items:baseline;flex-wrap:wrap}.dice-outcome strong{color:#ead69b;font-size:1.2rem}.dice-outcome small{margin-left:auto}.dice-legend{display:flex;gap:8px;flex-wrap:wrap;margin:12px 0}.dice-legend span{padding:5px 9px;border-radius:6px;font-size:.8rem;border:1px solid #ffffff33}.legend-base{background:#eae1c6;color:#242821}.legend-skill{background:#9e343e;color:#fff1df}.legend-gear{background:#242a30;color:#f6edda}.legend-artifact{background:#d7ac4d;color:#352707}.legend-magic{background:#755393;color:white}.legend-table{background:#326e8a;color:white}.legend-monster{background:#a85b28;color:white}.dice-history-entry{display:flex;gap:12px;align-items:center;justify-content:space-between;padding:14px 0;border-bottom:1px solid #b29a5b44}.dice-history-entry p{margin:5px 0}.dice-history-entry small{overflow-wrap:anywhere}.dice-history-entry button{flex-shrink:0}.dice-history{margin-top:24px}.dice-sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.dice-visibility{font-size:.85rem}.dice-visibility select{min-width:170px}
@media(max-width:600px){.dice-stage{right:12px;bottom:12px;padding:14px}.roll-die{width:41px;height:47px}.die-face{font-size:38px}.dice-row{gap:8px}.dice-history-entry{align-items:flex-start;flex-direction:column}.dice-stage h3{font-size:1rem}}
@media(prefers-reduced-motion:reduce){.dice-stage .roll-die{animation:none!important}}

.die-pips{display:grid;grid-template-columns:repeat(3,6px);grid-template-rows:repeat(3,6px);gap:4px;margin:3px auto 4px}.die-pips i{border-radius:50%}.die-pips .pip{background:currentColor;box-shadow:inset 0 1px 1px #0002}.roll-die small{color:inherit;opacity:.85}.dice-heading{position:sticky;top:-18px;background:#1a2b21;z-index:2;padding-top:4px}.dice-outcome{position:sticky;bottom:-18px;background:#1a2b21;z-index:2;padding-bottom:4px}

.dice-stage[data-phase=rolling] .roll-die.die-held{animation:none}

/* Faceted octahedron, pentagonal trapezohedron and dodecahedron. */
.dice-stage .poly-die{width:72px;height:80px;clip-path:none;background:none;border:0;border-radius:0;box-shadow:none;filter:drop-shadow(2px 4px 2px #0008)}
.dice-stage .poly-die::after{display:none}.poly-die .die-face{width:72px;height:72px}.die-solid{display:block;width:100%;height:100%;overflow:visible}.die-solid polygon{stroke:var(--die-ink);stroke-opacity:.36;stroke-width:.7;stroke-linejoin:round}.die-solid text{fill:var(--die-ink);font:bold 21px Georgia,serif;paint-order:stroke;stroke:var(--die-bg);stroke-width:.7px}.poly-die small{position:absolute;bottom:0;left:0;right:0;color:#eadcba}
.dice-risk:empty{display:none}.dice-risk{border-top:1px solid #b29a5b55;padding:8px 0}.dice-risk p{font-size:.85rem;line-height:1.45;margin:6px 0}.dice-risk .toolbar{display:flex;flex-wrap:wrap;gap:8px}.dice-risk button{min-height:42px}.dice-risk [role=alert]{color:#ffc4ad}
.dice-stage[data-phase=rolling] .die-face{filter:blur(1px)}.dice-stage[data-phase=rolling] .die-held .die-face{filter:none}
@media(prefers-reduced-motion:reduce){.dice-stage[data-phase=rolling] .die-face{filter:none}}

.die-penalty{--die-bg:#ef9359;--die-ink:#301807;border:2px dashed #592d16}.legend-penalty{background:#ef9359;color:#301807;border-style:dashed!important}

/* The same worn, engraved material treatment is shared by every dice source. */
.roll-die{background:radial-gradient(ellipse at 26% 20%,#fff5,transparent 65%),repeating-linear-gradient(17deg,#44351c0d 0 1px,transparent 1px 6px),var(--die-bg);border:1px solid #6e593a;border-radius:7px;box-shadow:inset -3px -4px 0 #241a1640,inset 2px 2px 0 #fff5,2px 4px 0 #090e0b88;text-shadow:0 1px 0 #fff2}.roll-die::after{content:'';position:absolute;inset:4px;border:1px solid currentColor;border-radius:4px;opacity:.17;pointer-events:none}.die-skill{--die-bg:#87413c}.die-artifact{--die-bg:#c3a056}.die-magic{--die-bg:#78617f}.die-table{--die-bg:#547581}.die-monster{--die-bg:#99724b}.die-penalty{--die-bg:#c99164;border:2px dashed #593c24}.poly-die{border-radius:0}.poly-die::after{clip-path:polygon(50% 0,100% 25%,90% 80%,50% 100%,10% 80%,0 25%)}.artifact-counts{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}.artifact-counts label{min-width:0}.artifact-counts input{width:100%}.dice-outcome [data-next]{font-size:.85rem;padding:7px 10px}.dice-stage{background:radial-gradient(ellipse at top,#354034,#14221a 75%);border:2px solid #9d8958;border-radius:8px;box-shadow:inset 0 0 0 3px #17251d,0 12px 60px #0009}

.initiative-card{display:inline-grid;gap:4px;min-width:80px;border:1px solid #8e7a48;background:#1b3024;border-radius:7px;padding:8px}.initiative-card strong{font-size:1.5rem;color:#e7d49c}.initiative-card.active{outline:2px solid #e7d49c}.initiative-card small{font-size:.75rem}.combat-options{margin-bottom:18px}.combat-options .toolbar{flex-wrap:wrap;gap:8px}.combat-options details{margin:10px 0}.opposed-checks fieldset{min-width:0}

.campaign-bar .dice-visibility{flex:0 0 190px;min-width:190px;max-width:100%}.campaign-bar .dice-visibility select{min-width:0}

/* Keep the pending decision reachable even when many dice groups overflow. */
.dice-decision{position:sticky;bottom:-18px;background:#1a2b21;z-index:3;padding-bottom:4px;box-shadow:0 -8px 14px #1a2b2188}.dice-decision .dice-outcome{position:static;padding-top:8px;gap:6px}.dice-decision .dice-outcome strong{font-size:1rem}.dice-decision .dice-risk{border-top:0;padding:4px 0}.dice-risk-help{margin:4px 0 8px}.dice-risk-help summary{font-size:.8rem;color:#d9c78b;cursor:pointer}.dice-risk-help[open]>p{max-height:16vh;overflow:auto}.dice-risk [role=alert]:empty{display:none}.dice-decision .toolbar{margin:0}
@media(max-width:600px){.dice-decision{bottom:-14px}.dice-decision .toolbar button{flex:1 1 120px;padding:8px}.dice-decision .dice-outcome strong{font-size:.95rem}}
