.dice-config { min-width: 0; }
.dice-config summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 30px; color: var(--deep); font-size: 14px; font-weight: 600; cursor: pointer; list-style: none; }
.dice-config summary::-webkit-details-marker { display: none; }
.dice-config summary:hover { background: var(--soft); }
.dice-config summary:focus-visible { outline: 2px solid var(--green); outline-offset: -4px; }
.dice-config summary small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; font-weight: 400; }
.dice-config-toggle { font-size: 22px; transition: transform .15s ease; }
.dice-config[open] .dice-config-toggle { transform: rotate(180deg); }
.dice-config[open] summary { border-bottom: 1px solid var(--line); }
.dice-tool.is-config-collapsed .generator-grid { grid-template-columns: 1fr; min-height: 0; }
.dice-tool.is-config-collapsed .dice-result { border-left: 0; border-top: 1px solid var(--line); }
.dice-custom { margin-top: 24px; }
#diceFaces { min-height: 180px; padding: 12px 13px; border: 1px solid var(--control-line); border-radius: 9px; background: #fff; color: var(--ink); font: 14px/1.7 var(--sans); }
.dice-custom .math-help { margin: 10px 0 14px; }
.dice-presets, .dice-preview, .dice-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dice-note { margin: 12px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.dice-preview-heading { margin: 24px 0 10px; color: var(--muted); font-size: 12px; }
.dice-preview { max-height: 160px; overflow: auto; }
.dice-preview span { max-width: 100%; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); color: var(--deep); font-size: 13px; overflow-wrap: anywhere; }
.dice-randomness { margin-top: 24px; }
.dice-randomness .check-option { align-items: flex-start; color: var(--deep); font-size: 13px; line-height: 1.5; }
.dice-randomness .check-option input { flex-shrink: 0; margin-top: 3px; }
.dice-result { min-width: 0; }
.dice-result-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dice-result-heading .tool-overline { margin: 0; }
#diceEnterFullscreen { display: inline-flex; align-items: center; gap: 8px; }
.dice-fullscreen-dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0; background: var(--paper); color: var(--ink); }
body:has(#diceFullscreenDialog[open]) { overflow: hidden; }
.dice-stage.is-fullscreen { display: flex; align-items: center; justify-content: center; box-sizing: border-box; width: 100%; height: 100dvh; padding: 64px 24px 32px; overflow: auto; background: var(--paper); }
.dice-stage.is-fullscreen #diceOutcome { width: 100%; max-width: 1440px; max-height: 100%; }
.dice-stage.is-fullscreen .dice-note, .dice-stage.is-fullscreen .dice-face small, .dice-stage.is-fullscreen .dice-full-value { display: none; }
.dice-stage.is-fullscreen .dice-roll { gap: 16px; margin: 0; }
.dice-stage.is-fullscreen .dice-face { --dice-size: clamp(100px, min(18vw, 24dvh), 200px); --dice-depth: calc(var(--dice-size) / 2); width: calc(var(--dice-size) * 1.6); min-height: calc(var(--dice-size) * 1.7); gap: 0; padding: calc(var(--dice-size) * .3); perspective: 1000px; }
.dice-stage.is-fullscreen[data-dice-count="1"] .dice-face { --dice-size: clamp(120px, min(38vw, 42dvh), 320px); }
.dice-stage.is-fullscreen .dice-pips { grid-template-columns: repeat(3, calc(var(--dice-size) * .15)); grid-template-rows: repeat(3, calc(var(--dice-size) * .15)); gap: calc(var(--dice-size) / 12); }
.dice-stage.is-fullscreen .dice-face-value { font-size: calc(var(--dice-size) * .32); }
.dice-stage.is-fullscreen .dice-face-value.is-text { font-size: calc(var(--dice-size) * .18); }
.dice-stage.is-fullscreen .dice-total { margin: 16px 0 0; text-align: center; font-size: clamp(24px, 4vw, 44px); }
.dice-fullscreen-exit { position: fixed; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); z-index: 1; display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: var(--soft); color: var(--deep); cursor: pointer; }
.dice-fullscreen-exit:hover { background: var(--mint); }
.dice-empty { margin-top: 30px; }
.dice-roll { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 20px; margin: 24px 0 12px; }
.dice-face { --dice-size: 120px; --dice-depth: 60px; display: flex; flex-direction: column; align-items: center; gap: 36px; width: 190px; max-width: 100%; min-height: 218px; padding: 32px 30px 16px; border: 0; border-radius: 18px; background: transparent; perspective: 700px; cursor: pointer; }
.dice-face:hover { background: var(--mint); }
.dice-cube { position: relative; display: block; flex-shrink: 0; width: var(--dice-size); height: var(--dice-size); transform-style: preserve-3d; transform: rotateX(-18deg) rotateY(-24deg) rotateZ(-6deg); transition: transform .2s ease; animation: dice-tumble .4s ease-out; }
.dice-face:hover .dice-cube { transform: translateY(-4px) rotateX(-22deg) rotateY(-30deg) rotateZ(-3deg); }
.dice-face:active .dice-cube { transform: rotateX(-12deg) rotateY(-16deg) rotateZ(3deg); }
.dice-cube-front, .dice-cube-top, .dice-cube-side { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 12px; backface-visibility: hidden; }
.dice-cube-front { padding: 12px; background: linear-gradient(135deg, #fff, var(--paper)); transform: translateZ(var(--dice-depth)); box-shadow: inset 0 0 0 3px #fff, 8px 16px 24px hsl(var(--hue), 30%, 25%, .14); }
.dice-cube-top { background: linear-gradient(135deg, #fff, var(--mint)); transform: rotateX(90deg) translateZ(var(--dice-depth)); }
.dice-cube-side { background: linear-gradient(120deg, var(--mint), var(--line)); transform: rotateY(90deg) translateZ(var(--dice-depth)); }
.dice-face-value { max-width: 100%; color: var(--deep); font-size: 38px; font-weight: 600; text-align: center; overflow-wrap: anywhere; white-space: pre-wrap; }
.dice-face-value.is-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden; font-size: 22px; line-height: 1.1; }
.dice-face small { color: var(--muted); font-size: 12px; }
.dice-full-value { max-width: 100%; margin-top: -24px; color: var(--deep); font-size: 12px; overflow-wrap: anywhere; }
.dice-pips { display: grid; grid-template-columns: repeat(3, 18px); grid-template-rows: repeat(3, 18px); gap: 10px; }
.dice-pip { border-radius: 50%; background: radial-gradient(circle at 65% 70%, var(--green), var(--deep)); box-shadow: inset 1px 2px 3px rgb(0 0 0 / .2); }
.dice-reroll-hint { text-align: center; }
.dice-total { margin: 16px 0; color: var(--deep); font-size: 22px; font-weight: 600; }
.dice-history { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.dice-history-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.dice-history h3 { margin: 0; color: var(--deep); font-size: 14px; }
.dice-history ol { display: grid; gap: 10px; padding: 0; list-style: none; }
.dice-history li { padding: 10px 12px; border-radius: 9px; background: var(--mint); overflow-wrap: anywhere; }
.dice-history li strong { display: block; margin-bottom: 5px; color: var(--deep); font-size: 12px; }
.dice-history li span { color: var(--ink); font-size: 14px; }
@keyframes dice-tumble { from { transform: rotateX(-48deg) rotateY(35deg) rotateZ(-25deg); } to { transform: rotateX(-18deg) rotateY(-24deg) rotateZ(-6deg); } }
@media (max-width: 650px) { .dice-config summary { padding: 18px; } }
@media (prefers-reduced-motion: reduce) { .dice-cube { animation: none; transition: none; } .dice-config-toggle { transition: none; } }
