/* Tumbling dice (web/js/dice3d.js). On the 2D board and in battles they
   roll on a transparent canvas in the middle of the screen: over the board,
   the card reveal and the combat screen (50), level with the pixel effects
   (56), under the choice dialog (57). */

.dice3d-overlay {
    position: fixed;
    inset: 0;
    z-index: 56;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.dice3d-overlay[hidden] { display: none; }

/* A soft pool of shade under the throw, so the dice read on busy art. */
.dice3d-overlay::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: min(92vw, 700px, 100%);
    height: min(46vh, 360px, 100%);
    transform: translate(-50%, -46%);
    background: radial-gradient(ellipse closest-side, var(--dice-pool, rgba(6, 4, 2, 0.5)), transparent);
    pointer-events: none;
}

.dice3d-canvas {
    position: relative;
    display: block;
}

/* The total once the dice settle. In the 3D view it is placed in the board
   viewport, under the dice; on the overlay, below the throw. */
.dice3d-total {
    position: absolute;
    z-index: 4;
    transform: translate(-50%, 0);
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.2rem 0.75rem;
    border: 1px solid rgba(242, 201, 76, 0.65);
    border-radius: 999px;
    background: rgba(10, 8, 6, 0.86);
    color: #ffe9a8;
    font-family: var(--font-sans);
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.5);
    animation: dice3d-total-in 0.22s ease-out;
}

.dice3d-total[hidden] { display: none; }

.dice3d-overlay .dice3d-total {
    position: fixed;
    top: auto !important;
    left: 50% !important;
    bottom: calc(50% - min(23vh, 180px));
}

.dice3d-total-parts {
    font-size: 0.85rem;
    font-weight: 600;
    color: #d9c79a;
}

.dice3d-total-sum {
    font-size: 1.35rem;
    line-height: 1.1;
}

@keyframes dice3d-total-in {
    from { opacity: 0; transform: translate(-50%, 6px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .dice3d-overlay { --dice-pool: rgba(30, 20, 10, 0.32); }
}
:root[data-theme="light"] .dice3d-overlay { --dice-pool: rgba(30, 20, 10, 0.32); }

@media (prefers-reduced-motion: reduce) {
    .dice3d-total { animation: none; }
}

/* "6 — explodes!" beside a die that throws another (dice3d.js `label`).
   Fixed in window px, placed over the die each frame, lifted above it. */
.dice3d-explode {
    position: fixed;
    z-index: 56;
    transform: translate(-50%, -190%);
    padding: 0.1rem 0.5rem;
    border: 1px solid rgba(242, 201, 76, 0.8);
    border-radius: 999px;
    background: rgba(10, 8, 6, 0.88);
    color: #f2c94c;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    animation: dice3d-explode-in 0.2s ease-out;
}

.dice3d-explode[hidden] { display: none; }

@keyframes dice3d-explode-in {
    from { opacity: 0; transform: translate(-50%, -150%) scale(0.85); }
    to { opacity: 1; transform: translate(-50%, -190%) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .dice3d-explode { animation: none; }
}
