/* Wild magic surge roller */
.wm-stage { text-align: center; margin-bottom: 8px; }

.wm-result {
    position: relative; overflow: hidden;
    border: 1px solid var(--border); border-radius: 16px; background: var(--surface);
    padding: 22px 20px 24px; margin-bottom: 18px; min-height: 150px;
    display: flex; flex-direction: column; justify-content: center; gap: 6px;
}
.wm-result[aria-hidden="true"] .wm-range,
.wm-result[aria-hidden="true"] .wm-effect { visibility: hidden; }

/* The text sits above the chaos layers. */
.wm-roll, .wm-range, .wm-effect { position: relative; z-index: 1; }

.wm-roll {
    font-family: "Fraunces", Georgia, serif; font-weight: 600;
    font-size: clamp(52px, 14vw, 88px); line-height: 1; color: var(--accent);
    font-variant-numeric: tabular-nums;
}
.wm-range { color: var(--faint); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
.wm-effect { color: var(--text); font-size: 18px; line-height: 1.5; max-width: 52ch; margin: 4px auto 0; }

/* --- Chaos animation: procedural lightning bolts drawn behind the number. --- */
.wm-bolts {
    position: absolute; inset: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 0; overflow: visible;
}
.wm-bolt {
    fill: none; stroke: var(--accent); stroke-width: var(--wm-w, 2);
    stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke;
    filter: drop-shadow(0 0 2px var(--accent-weak)); opacity: 0;
}

@media (prefers-reduced-motion: no-preference) {
    .wm-bolt { animation: wm-flash .42s ease-out forwards; }
    .wm-bolt--faint { animation: wm-flash-faint 1.1s ease-out forwards; }
}

/* Double-peaked opacity gives the brief flickering strike of a real bolt. */
@keyframes wm-flash {
    0% { opacity: 0; }
    10% { opacity: 1; }
    28% { opacity: .35; }
    42% { opacity: .9; }
    100% { opacity: 0; }
}
@keyframes wm-flash-faint {
    0% { opacity: 0; }
    18% { opacity: .3; }
    38% { opacity: .1; }
    55% { opacity: .25; }
    100% { opacity: 0; }
}

.wm-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: center; }
.wm-roll-btn { gap: 8px; padding: 12px 24px; font-size: 16px; }
.wm-lookup { display: flex; }
.wm-lookup-input { width: 150px; text-align: center; font-variant-numeric: tabular-nums; }
.wm-hint { margin: 12px 0 0; text-align: center; color: var(--faint); font-size: 13px; }

.wm-history { list-style: none; margin: 24px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.wm-history li {
    display: flex; gap: 12px; align-items: baseline;
    padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
    font-size: 14px; color: var(--muted);
}
.wm-history b {
    flex: none; min-width: 2.4em; text-align: center; color: var(--accent-strong);
    font-variant-numeric: tabular-nums; font-size: 16px;
}
