.dice-shell {
    max-width: 1120px;
    margin: 0 auto;
}

.dice-stage-card {
    background: transparent;
    overflow: hidden;
}

[data-bs-theme="dark"] .dice-stage-card {
    background: transparent;
}

.dice-scene {
    --dice-size: 75px;
    position: relative;
    min-height: 380px;
    border-radius: 1.5rem;
    overflow: hidden;
    perspective: 1400px;
    background: transparent;
}

[data-bs-theme="dark"] .dice-scene {
    background: transparent;
}

.dice-stage-glow,
.dice-floor {
    display: none;
}

.dice-cluster {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: auto auto;
    align-content: center;
    justify-items: center;
    row-gap: 1rem;
    padding: 0.5rem 0.75rem;
}

.dice-cluster.two-rows {
    --dice-size: 60px;
    row-gap: 0.4rem;
    padding-top: 0.95rem;
    padding-bottom: 0.55rem;
}

.dice-unit {
    position: relative;
    width: var(--dice-size);
    height: calc(var(--dice-size) + 62px);
}

.dice-thrower {
    --view-angle: rotateX(-26deg) rotateY(32deg);
    position: absolute;
    left: 50%;
    bottom: 2.6rem;
    width: var(--dice-size);
    height: var(--dice-size);
    transform: translateX(-50%) var(--view-angle);
    transform-style: preserve-3d;
    z-index: 3;
    box-shadow: 0 10px 14px rgba(0, 0, 0, 0.08);
}

.dice-thrower.is-rolling {
    animation: dice-throw var(--throw-duration, 1450ms) cubic-bezier(0.2, 0.86, 0.24, 1);
}

.dice-shadow {
    position: absolute;
    left: 50%;
    bottom: 1.55rem;
    width: 90px;
    height: 30px;
    transform: translateX(-50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(15, 23, 42, 0.36), rgba(15, 23, 42, 0) 72%);
    filter: blur(8px);
    opacity: 0.76;
    z-index: 2;
}

.dice-shadow.is-rolling {
    animation: dice-shadow-throw var(--throw-duration, 1450ms) cubic-bezier(0.2, 0.86, 0.24, 1);
}

.dice-cube {
    --face-depth: calc((var(--dice-size) / 2) + 0.2px);
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
    transition: transform var(--roll-duration, 1450ms) cubic-bezier(0.16, 0.86, 0.18, 1);
    will-change: transform;
}

.dice-face {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    padding: clamp(6px, calc(var(--dice-size) * 0.13), 16px);
    border-radius: 0;
    border: 1px solid rgba(205, 212, 223, 0.95);
    background: #f7f8fb;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

[data-bs-theme="dark"] .dice-face {
    border-color: rgba(191, 200, 214, 0.9);
    background: #f3f5f8;
}

.face-1 { transform: rotateY(0deg) translateZ(var(--face-depth)); }
.face-2 { transform: rotateY(90deg) translateZ(var(--face-depth)); }
.face-3 { transform: rotateX(90deg) translateZ(var(--face-depth)); }
.face-4 { transform: rotateX(-90deg) translateZ(var(--face-depth)); }
.face-5 { transform: rotateY(-90deg) translateZ(var(--face-depth)); }
.face-6 { transform: rotateY(180deg) translateZ(var(--face-depth)); }

.pip {
    width: clamp(10px, calc(var(--dice-size) * 0.16), 20px);
    height: clamp(10px, calc(var(--dice-size) * 0.16), 20px);
    align-self: center;
    justify-self: center;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #f87171, #991b1b 72%);
    box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.42), inset 0 -3px 4px rgba(0, 0, 0, 0.18);
}

.pip-top-left { grid-area: 1 / 1; }
.pip-top-right { grid-area: 1 / 3; }
.pip-mid-left { grid-area: 2 / 1; }
.pip-center { grid-area: 2 / 2; }
.pip-mid-right { grid-area: 2 / 3; }
.pip-bottom-left { grid-area: 3 / 1; }
.pip-bottom-right { grid-area: 3 / 3; }

.result-panel {
    border-radius: 1.4rem;
    padding: 1.25rem;
    background: linear-gradient(180deg, rgba(255, 243, 240, 0.9), rgba(255, 255, 255, 0.7));
}

[data-bs-theme="dark"] .result-panel {
    background: linear-gradient(180deg, rgba(127, 29, 29, 0.22), rgba(255, 255, 255, 0.04));
}

.result-kicker {
    letter-spacing: 0.12em;
    color: var(--bs-danger-text-emphasis, #b91c1c);
}

.result-number {
    font-size: clamp(4.5rem, 10vw, 6rem);
    line-height: 1;
    font-weight: 800;
    color: var(--bs-emphasis-color);
}

.result-text {
    font-size: 1.05rem;
}

.dice-control-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.dice-count-select {
    width: 86px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-list.is-empty {
    display: block;
    color: var(--bs-secondary-color);
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 1rem;
    background: var(--bs-secondary-bg);
}

.history-item-label {
    font-size: 0.92rem;
    color: var(--bs-secondary-color);
}

.history-item-detail {
    font-size: 0.8rem;
    color: var(--bs-secondary-color);
    margin-top: 0.2rem;
}

.history-item-value {
    min-width: 2.75rem;
    height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(220, 38, 38, 0.12);
    color: #b91c1c;
    font-size: 1.15rem;
    font-weight: 800;
}

@keyframes dice-throw {
    0% {
        transform: translateX(-50%) var(--view-angle) translateY(0) scale(1);
    }
    24% {
        transform: translateX(calc(-50% - 64px)) var(--view-angle) translateY(-104px) scale(1.02);
    }
    52% {
        transform: translateX(calc(-50% + 72px)) var(--view-angle) translateY(-186px) scale(1.04);
    }
    78% {
        transform: translateX(calc(-50% + 18px)) var(--view-angle) translateY(12px) scale(0.98);
    }
    100% {
        transform: translateX(calc(-50% + var(--landing-x, 0px))) var(--view-angle) translateY(0) scale(1);
    }
}

@keyframes dice-shadow-throw {
    0% {
        transform: translateX(-50%) scale(1);
        opacity: 0.72;
    }
    52% {
        transform: translateX(calc(-50% + 12px)) scale(0.46);
        opacity: 0.2;
    }
    78% {
        transform: translateX(calc(-50% + 8px)) scale(1.06);
        opacity: 0.56;
    }
    100% {
        transform: translateX(calc(-50% + var(--landing-x, 0px))) scale(1);
        opacity: 0.74;
    }
}

@media (max-width: 991.98px) {
    .dice-scene {
        min-height: 360px;
        --dice-size: 68px;
    }
}

@media (max-width: 575.98px) {
    .dice-scene {
        min-height: 340px;
        --dice-size: 56px;
    }

    .dice-thrower {
        bottom: 3.3rem;
    }

    .dice-shadow {
        width: 52px;
        height: 18px;
        bottom: 1rem;
    }

    .dice-unit {
        height: calc(var(--dice-size) + 48px);
    }

    .dice-face {
        padding: clamp(5px, calc(var(--dice-size) * 0.13), 12px);
    }
}