/* 3D dice overlay: a transparent WebGL canvas above the board and side panel,
   below floating windows (z-index 100+), plus small total readouts. */

.dice3d-canvas {
  position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 40;
  pointer-events: none; background: transparent;
}
.dice3d-layer { position: fixed; inset: 0; z-index: 41; pointer-events: none; overflow: hidden; contain: strict; }
.dice3d-layer:empty { display: none; }

.dice3d-total { position: absolute; left: 0; top: 0; will-change: transform, opacity; }
.dice3d-plate {
  --c: var(--gold, #dcb35c);
  position: relative; transform: translate(-50%, 6px) scale(.92); opacity: 0;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 74px; max-width: 260px; padding: 7px 16px 8px;
  border: 1px solid var(--rule-2, #38445b); border-radius: 4px;
  background: linear-gradient(145deg, var(--plate-a, rgba(29, 37, 52, .96)), var(--plate-b, rgba(9, 13, 21, .98)));
  box-shadow: 0 14px 34px rgba(0, 0, 0, .55), 0 0 0 1px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .04);
  transition: opacity .28s var(--ease, ease), transform .34s var(--ease, ease), border-color .3s, box-shadow .3s;
  text-align: center; white-space: nowrap;
}
.dice3d-plate::before {
  content: ""; position: absolute; left: 0; top: 0; right: 0; height: 2px; border-radius: 4px 4px 0 0;
  background: linear-gradient(90deg, var(--c), color-mix(in srgb, var(--gold, #dcb35c) 70%, transparent), transparent);
}
.dice3d-total.on .dice3d-plate { opacity: 1; transform: translate(-50%, 0) scale(1); }

.dice3d-kicker {
  max-width: 228px; overflow: hidden; text-overflow: ellipsis;
  font: 700 8.5px/1.3 var(--mono, ui-monospace, monospace); letter-spacing: .2em; text-transform: uppercase; color: var(--dim, #8891a6);
}
.dice3d-num {
  font: 400 30px/1.05 var(--serif, Georgia, serif); letter-spacing: .02em; color: #f1ead9;
  text-shadow: 0 0 18px color-mix(in srgb, var(--gold, #dcb35c) 28%, transparent), 0 2px 0 rgba(0, 0, 0, .5);
  font-variant-numeric: lining-nums tabular-nums;
}
.dice3d-tag { font: 700 8px var(--mono, monospace); letter-spacing: .26em; text-transform: uppercase; margin-top: 1px; }

.dice3d-plate.crit { border-color: color-mix(in srgb, var(--ok, #5bbf5b) 70%, #000); box-shadow: 0 14px 34px rgba(0, 0, 0, .55), 0 0 26px rgba(80, 230, 120, .28); }
.dice3d-plate.crit::before { background: linear-gradient(90deg, #6fe08a, color-mix(in srgb, #6fe08a 40%, transparent), transparent); }
.dice3d-plate.crit .dice3d-num { color: #a6f0b4; text-shadow: 0 0 20px rgba(90, 240, 130, .55), 0 2px 0 rgba(0, 0, 0, .5); }
.dice3d-plate.crit .dice3d-tag { color: #8fe6a0; }
.dice3d-plate.fumble { border-color: color-mix(in srgb, var(--blood, #bf4340) 75%, #000); box-shadow: 0 14px 34px rgba(0, 0, 0, .55), 0 0 26px rgba(230, 70, 60, .3); }
.dice3d-plate.fumble::before { background: linear-gradient(90deg, #ef5a52, color-mix(in srgb, #ef5a52 40%, transparent), transparent); }
.dice3d-plate.fumble .dice3d-num { color: #f5a29c; text-shadow: 0 0 20px rgba(240, 80, 70, .55), 0 2px 0 rgba(0, 0, 0, .5); }
.dice3d-plate.fumble .dice3d-tag { color: #f08a84; }

/* Many-dice summary (more than one wave). */
.dice3d-plate.multi { align-items: stretch; min-width: 150px; }
.dice3d-plate.multi .dice3d-kicker { text-align: center; margin-bottom: 3px; }
.dice3d-row { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.dice3d-row span { font: 11px var(--sans, system-ui, sans-serif); color: var(--ink-2, #c9c3b4); overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.dice3d-row b { font: 400 19px/1.15 var(--serif, Georgia, serif); color: #f1ead9; font-variant-numeric: lining-nums tabular-nums; }
.dice3d-row.crit b { color: #a6f0b4; }
.dice3d-row.fumble b { color: #f5a29c; }
.dice3d-more { margin-top: 3px; font: 600 8px var(--mono, monospace); letter-spacing: .14em; text-transform: uppercase; color: var(--dim-2, #5f687c); text-align: center; }

@media (max-width: 560px) {
  .dice3d-plate { padding: 6px 12px 7px; min-width: 64px; }
  .dice3d-num { font-size: 25px; }
}
@media (prefers-reduced-motion: reduce) {
  .dice3d-plate { transition: opacity .2s linear; transform: translate(-50%, 0); }
}
