.dice-window {
  position: fixed; right: 18px; bottom: 64px; z-index: 140; width: min(420px, calc(100vw - 32px)); max-height: calc(100vh - 84px);
  display: flex; flex-direction: column; color: var(--text); background: linear-gradient(180deg, rgba(14, 26, 48, .97), rgba(6, 11, 22, .97));
  border: 1px solid rgba(79, 210, 255, .45); border-radius: 6px; box-shadow: 0 14px 40px rgba(0, 0, 0, .6), 0 0 0 1px rgba(79, 210, 255, .08);
  font-family: Rajdhani, sans-serif; animation: calc-in .16s ease-out;
}
.dice-body { display: grid; gap: .55rem; overflow-y: auto; padding: .2rem .9rem .9rem; }
.dice-stage {
  display: block; width: 100%; height: 190px; border: 1px solid var(--panel-edge); border-radius: 5px; box-sizing: border-box;
  background: radial-gradient(ellipse at 50% 40%, rgba(40, 80, 130, .35), rgba(4, 7, 15, .9) 75%), #050a15;
}
.dice-readout { display: flex; align-items: center; gap: .8rem; min-height: 4.2rem; padding: .35rem .6rem; border: 1px solid var(--panel-edge); border-radius: 5px; background: rgba(4, 7, 15, .7); }
.dice-readout.revealed .dice-total b { animation: dice-pop .3s ease-out; }
@keyframes dice-pop { from { transform: scale(1.5); color: var(--warn); } }
.dice-hint { color: var(--muted); font-size: .98rem; font-weight: 600; }
.dice-failure { color: var(--bad); }
.dice-total { flex: none; min-width: 3.6rem; text-align: center; }
.dice-total small, .dice-label, .dice-result small { font: 700 .56rem Orbitron, sans-serif; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.dice-total small { display: block; }
.dice-total b { display: block; font: 700 1.55rem Orbitron, sans-serif; color: #fff; }
.dice-breakdown { display: flex; flex-wrap: wrap; gap: .25rem; min-width: 0; }
.dice-result { display: inline-flex; align-items: baseline; gap: .25rem; padding: .05rem .35rem; border-radius: 3px; background: rgba(79, 210, 255, .1); font-size: .9rem; font-weight: 600; }
.dice-result b { font: 700 .78rem Orbitron, sans-serif; }
.dice-result.high b { color: var(--warn); }
.dice-result.low b { color: var(--bad); }
.dice-label { display: flex; justify-content: space-between; align-items: center; }
.dice-count { color: var(--text); }
.dice-link { padding: 0; font: 600 .85rem Rajdhani, sans-serif; color: var(--accent); background: none; border: 0; cursor: pointer; }
.dice-link:disabled { color: var(--muted); cursor: default; }
.dice-pool { display: flex; flex-wrap: wrap; gap: .3rem; min-height: 1.7rem; }
.dice-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .05rem .4rem; font: 700 .72rem Orbitron, sans-serif; color: var(--text); background: rgba(79, 210, 255, .12); border: 1px solid rgba(79, 210, 255, .4); border-radius: 3px; cursor: pointer; }
.dice-chip span { color: var(--muted); font-size: .95rem; line-height: 1; }
.dice-chip.custom { background: rgba(214, 90, 220, .14); border-color: rgba(214, 90, 220, .55); }
.dice-chip:hover:not(:disabled) { border-color: var(--bad); }
.dice-chip:hover:not(:disabled) span { color: var(--bad); }
.dice-picks { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .25rem; }
.dice-pick { display: grid; justify-items: center; gap: .05rem; padding: .3rem 0 .2rem; color: var(--text); background: rgba(4, 7, 15, .6); border: 1px solid var(--panel-edge); border-radius: 4px; cursor: pointer; font: 700 .64rem Orbitron, sans-serif; }
.dice-pick canvas { width: 36px; height: 36px; max-width: 100%; transition: transform .15s ease; }
.dice-pick:hover:not(:disabled) { border-color: var(--accent); }
.dice-pick:hover:not(:disabled) canvas { transform: scale(1.12) rotate(-6deg); }
.dice-pick:disabled, .dice-small:disabled { opacity: .45; cursor: default; }
.dice-tuning { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .4rem .8rem; }
.dice-field { display: flex; align-items: center; gap: .3rem; }
.dice-field .dice-label { margin-right: .15rem; }
.dice-prefix { font: 700 .75rem Orbitron, sans-serif; color: var(--muted); }
.dice-field input { width: 3.4rem; padding: .2rem .3rem; text-align: center; border: 1px solid var(--panel-edge); border-radius: 4px; background: #070d1b; color: var(--text); font: 700 .78rem Orbitron, sans-serif; appearance: textfield; -moz-appearance: textfield; }
.dice-field input::-webkit-inner-spin-button, .dice-field input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.dice-field input[aria-invalid] { border-color: var(--bad); }
.dice-small { min-width: 1.7rem; padding: .15rem .4rem; font: 700 .82rem Rajdhani, sans-serif; color: var(--text); background: rgba(79, 210, 255, .12); border: 1px solid var(--panel-edge); border-radius: 4px; cursor: pointer; }
.dice-small:hover:not(:disabled) { border-color: var(--accent); }
.dice-roll { padding: .5rem; font: 700 .95rem Orbitron, sans-serif; letter-spacing: .14em; text-transform: uppercase; color: #04101f; background: var(--accent); border: 0; border-radius: 4px; cursor: pointer; }
.dice-roll:hover:not(:disabled) { filter: brightness(1.15); }
.dice-roll:disabled { color: var(--muted); background: rgba(79, 210, 255, .14); cursor: default; }
.dice-history-wrap { display: grid; gap: .25rem; }
.dice-history-wrap[hidden] { display: none; }
.dice-history { display: grid; gap: .15rem; max-height: 6.2rem; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.dice-history li { display: grid; grid-template-columns: 3rem minmax(0, 1fr) auto; align-items: baseline; gap: .5rem; padding: .08rem .35rem; border-radius: 3px; background: rgba(4, 7, 15, .6); font-size: .92rem; font-weight: 600; }
.dice-history li:first-child { background: rgba(79, 210, 255, .1); }
.dice-history b { font: 700 .8rem Orbitron, sans-serif; color: #fff; }
.dice-history span { overflow: hidden; color: #cbd8ea; text-overflow: ellipsis; white-space: nowrap; }
.dice-history small { max-width: 8.5rem; overflow: hidden; color: var(--muted); font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 520px) {
  .dice-window { right: 16px; bottom: 16px; max-height: calc(100vh - 32px); }
  .dice-stage { height: 160px; }
}
