/**
 * /assets/css/dice-roller.css
 *
 * Purpose:  Dice Roller – Glassmorphism dropdown/floating panel from header button
 *           3D roll animations, result display, history
 *           Floating/detachable window mode, custom SVG icon support
 *           Real 3D CSS cube with pip faces for d6
 * Deps:     app.css (CSS variables)
 * Load:     index.php
 * Version:  5.1.0
 *
 * v5.1.0 – Custom SVG Icon-Picker integration:
 *           - Mode tabs (FA Icons / Custom SVG) to browse all icon sets
 *           - SVG icons from DB searchable by name, keywords, set
 *           - Styles for mode tabs and SVG icon grid items
 * v5.0.0 – Custom Dice Button Icons:
 *           - Customize button in panel header, icon picker inline section
 *           - Category tabs, search, icon grid with gold-themed styling
 *           - Editable indicators on dice type buttons in customize mode
 *           - Focus-visible + reduced-motion for new elements
 * v4.3.1 – Fix corrupted merge: removed unclosed .dice-stage--multi brace
 *           and old duplicate 3D cube CSS (.dice-cube-wrapper, .pip, hardcoded
 *           translateZ) that broke all CSS rules after line 645.
 * v4.3.0 – True 3D Dice: CSS 3D cube for d6 with pip faces, type-specific shaped
 *           outlines (clip-path) for d4/d8/d10/d12/d20/d100, per-type color theming,
 *           bounce/settle landing animation, crit/fail glow effects
 * v4.2.0 – Character Picker: Charakter-Auswahl als klickbare Buttons, Gruppen-Ueberschriften
 * v4.1.0 – Accessibility & Robustness:
 *           - Focus-visible States fuer alle interaktiven Elemente
 *           - !important bei .dice-stat-btn--active durch hoehere Spezifitaet ersetzt
 *           - prefers-reduced-motion deckt nun alle Animationen ab (diceResultFadeIn, dieAppear)
 *           - -webkit-backdrop-filter Vendor-Prefix fuer Safari
 *           - Mobile: Stat-Grid 3 Spalten statt 6 auf kleinen Screens
 * v4.0.0 – Character stat modifier section, attack presets, result stat labels
 * v3.0.0 – Floating/detachable window, custom SVG icons, drag handle
 * v2.0.0 – Header-Button statt FAB, Panel als Dropdown
 * v1.0.0 – Initiale Version mit FAB
 *
 * BEM-Prefix: .dice (dice-roller)
 */

/* ==========================================================================
   Header Button Active State
   ========================================================================== */

#diceHeaderBtn.dice-btn--active {
  color: var(--accent, #5dd6c9) !important;
  opacity: 1 !important;
  text-shadow: 0 0 8px rgba(93, 214, 201, 0.4);
}

/* ==========================================================================
   Overlay Backdrop
   ========================================================================== */

.dice-overlay {
  position: fixed;
  inset: 0;
  z-index: 10040;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.dice-overlay--visible {
  opacity: 1;
  pointer-events: auto;
}

/* ==========================================================================
   Panel (Dropdown from Header)
   ========================================================================== */

.dice-panel {
  position: fixed;
  top: 52px;
  right: 16px;
  z-index: 10050;
  width: 320px;
  max-height: calc(100vh - 70px - var(--tabbarH, 72px));
  overflow-y: auto;
  overscroll-behavior: contain;
  background:
    linear-gradient(135deg, rgba(30, 35, 44, 0.97), rgba(22, 27, 34, 0.98)),
    radial-gradient(circle at top right, rgba(93, 214, 201, 0.06), transparent 60%);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1rem;
  padding: 1rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 1px rgba(255, 255, 255, 0.1);
  transform: translateY(-8px) scale(0.97);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
  transform-origin: top right;
}

.dice-panel--visible {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.dice-panel::-webkit-scrollbar {
  width: 4px;
}

.dice-panel::-webkit-scrollbar-track {
  background: transparent;
}

.dice-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
}

/* ==========================================================================
   Floating Mode (detached window)
   ========================================================================== */

.dice-panel--floating {
  top: auto;
  right: auto;
  transform-origin: center center;
  border: 1px solid rgba(93, 214, 201, 0.2);
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.6),
    0 0 1px rgba(255, 255, 255, 0.1),
    0 0 20px rgba(93, 214, 201, 0.05);
  max-height: calc(100vh - 20px);
  resize: vertical;
}

.dice-panel--floating .dice-panel-header {
  cursor: grab;
}

.dice-panel--floating .dice-panel-header:active {
  cursor: grabbing;
}

.dice-panel--dragging {
  transition: none !important;
  user-select: none;
  opacity: 0.92;
}

/* ==========================================================================
   Panel Header
   ========================================================================== */

.dice-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.dice-title {
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent, #5dd6c9);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-shadow: 0 0 10px rgba(93, 214, 201, 0.25);
}

.dice-header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.dice-detach,
.dice-close {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.4);
  border-radius: 0.4rem;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.7rem;
  transition: all 0.15s ease;
}

.dice-detach:hover {
  background: rgba(93, 214, 201, 0.12);
  border-color: rgba(93, 214, 201, 0.25);
  color: var(--accent, #5dd6c9);
}

.dice-close:hover {
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.25);
  color: var(--danger, #ff6b6b);
}

/* ==========================================================================
   Custom SVG Icons
   ========================================================================== */

.dice-custom-svg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1em;
  height: 1.1em;
}

.dice-custom-svg svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
  color: inherit;
}

/* ==========================================================================
   Dice Type Selector
   ========================================================================== */

.dice-types {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.3rem;
  margin-bottom: 0.75rem;
}

.dice-type-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.55rem;
  padding: 0.4rem 0.2rem;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.dice-type-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.8);
  transform: translateY(-1px);
}

.dice-type-btn--active {
  background: rgba(93, 214, 201, 0.12);
  border-color: rgba(93, 214, 201, 0.35);
  color: var(--accent, #5dd6c9);
  box-shadow: 0 0 10px rgba(93, 214, 201, 0.1);
}

.dice-type-btn--active:hover {
  background: rgba(93, 214, 201, 0.2);
  border-color: rgba(93, 214, 201, 0.5);
}

.dice-type-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.dice-type-label {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   Quick Presets
   ========================================================================== */

.dice-presets {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.dice-preset {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.4rem;
  padding: 0.22rem 0.5rem;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.68rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dice-preset:hover {
  background: rgba(93, 214, 201, 0.1);
  border-color: rgba(93, 214, 201, 0.25);
  color: var(--accent, #5dd6c9);
  transform: translateY(-1px);
}

/* ==========================================================================
   Controls Row (Count + Modifier)
   ========================================================================== */

.dice-controls {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
  align-items: stretch;
}

.dice-ctrl-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.dice-ctrl-label {
  font-size: 0.62rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.35);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dice-ctrl-row {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.5rem;
  overflow: hidden;
  height: 34px;
}

.dice-ctrl-btn {
  background: rgba(255, 255, 255, 0.04);
  border: none;
  color: rgba(255, 255, 255, 0.4);
  width: 30px;
  height: 100%;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

.dice-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.75);
}

.dice-ctrl-input {
  background: transparent;
  border: none;
  color: #fff;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  width: 100%;
  padding: 0 0.15rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  -moz-appearance: textfield;
}

.dice-ctrl-input::-webkit-outer-spin-button,
.dice-ctrl-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.dice-ctrl-input:focus {
  outline: none;
}

/* ==========================================================================
   Formula Display
   ========================================================================== */

.dice-formula {
  text-align: center;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent, #5dd6c9);
  margin-bottom: 0.6rem;
  padding: 0.3rem;
  background: rgba(93, 214, 201, 0.05);
  border: 1px solid rgba(93, 214, 201, 0.12);
  border-radius: 0.4rem;
  text-shadow: 0 0 8px rgba(93, 214, 201, 0.15);
  letter-spacing: 0.05em;
}

/* ==========================================================================
   Roll Button
   ========================================================================== */

.dice-roll-btn {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid rgba(93, 214, 201, 0.3);
  border-radius: 0.6rem;
  background: linear-gradient(135deg, rgba(93, 214, 201, 0.15), rgba(93, 214, 201, 0.06));
  color: var(--accent, #5dd6c9);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.dice-roll-btn:hover {
  background: linear-gradient(135deg, rgba(93, 214, 201, 0.25), rgba(93, 214, 201, 0.12));
  border-color: rgba(93, 214, 201, 0.5);
  transform: translateY(-1px);
  box-shadow: 0 3px 12px rgba(93, 214, 201, 0.15);
}

.dice-roll-btn:active {
  transform: scale(0.97);
}

.dice-roll-btn--rolling {
  pointer-events: none;
  animation: diceRollBtnPulse 0.6s ease;
}

@keyframes diceRollBtnPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.96); }
}

/* ==========================================================================
   3D Dice Animation Area
   ========================================================================== */

.dice-stage {
  height: 90px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
  perspective: 400px;
  overflow: visible;
}

/* --- Flat dice (non-d6 types) + 3D Cube (d6) --- */

/* Multiple dice */
.dice-stage--multi {
  gap: 0.5rem;
  flex-wrap: wrap;
  height: auto;
  min-height: 80px;
  padding: 0.4rem 0;
}

/* --------------------------------------------------------------------------
   3D Cube (d6) — true CSS 3D with 6 faces + dot patterns
   -------------------------------------------------------------------------- */

.dice-cube {
  --cube-size: 48px;
  --cube-half: 24px;
  --cube-color: rgba(93, 214, 201, 0.35);
  --cube-bg: linear-gradient(135deg, rgba(30, 40, 50, 0.95), rgba(20, 28, 38, 0.98));
  width: var(--cube-size);
  height: var(--cube-size);
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(-20deg) rotateY(25deg);
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.dice-cube--small {
  --cube-size: 38px;
  --cube-half: 19px;
}

/* Cube faces — positioned to form a 3D box */
.dice-cube__face {
  position: absolute;
  width: var(--cube-size);
  height: var(--cube-size);
  background: var(--cube-bg);
  border: 2px solid var(--cube-color);
  border-radius: 4px;
  display: grid;
  padding: 15%;
  box-sizing: border-box;
  backface-visibility: visible;
  box-shadow: inset 0 0 12px rgba(93, 214, 201, 0.06);
}

/* Face positions (opposite faces sum to 7: 1↔6, 2↔5, 3↔4) */
.dice-cube__face--1 { transform: rotateY(0deg)   translateZ(var(--cube-half)); }
.dice-cube__face--6 { transform: rotateY(180deg) translateZ(var(--cube-half)); }
.dice-cube__face--2 { transform: rotateY(90deg)  translateZ(var(--cube-half)); }
.dice-cube__face--5 { transform: rotateY(-90deg) translateZ(var(--cube-half)); }
.dice-cube__face--3 { transform: rotateX(90deg)  translateZ(var(--cube-half)); }
.dice-cube__face--4 { transform: rotateX(-90deg) translateZ(var(--cube-half)); }

/* Dot patterns — CSS grid based */
.dice-cube__face--1 { grid-template: 1fr / 1fr; place-items: center; }
.dice-cube__face--2 { grid-template: 1fr 1fr / 1fr; }
.dice-cube__face--3 { grid-template: 1fr 1fr 1fr / 1fr; }
.dice-cube__face--4 { grid-template: 1fr 1fr / 1fr 1fr; }
.dice-cube__face--5 { grid-template: 1fr 1fr 1fr / 1fr 1fr; }
.dice-cube__face--6 { grid-template: 1fr 1fr 1fr / 1fr 1fr; }

/* Dots (pips) */
.dice-pip {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, rgba(200, 220, 240, 0.85));
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.3), inset 0 1px 1px rgba(0, 0, 0, 0.15);
  justify-self: center;
  align-self: center;
}

.dice-cube--small .dice-pip {
  width: 5px;
  height: 5px;
}

/* Face 2: top-right + bottom-left diagonal */
.dice-cube__face--2 .dice-pip:nth-child(1) { justify-self: end; align-self: start; }
.dice-cube__face--2 .dice-pip:nth-child(2) { justify-self: start; align-self: end; }

/* Face 3: top-right, center, bottom-left diagonal */
.dice-cube__face--3 .dice-pip:nth-child(1) { justify-self: end; align-self: start; }
.dice-cube__face--3 .dice-pip:nth-child(2) { justify-self: center; align-self: center; }
.dice-cube__face--3 .dice-pip:nth-child(3) { justify-self: start; align-self: end; }

/* Face 5: 4 corners + center */
.dice-cube__face--5 .dice-pip:nth-child(5) { grid-column: 1 / -1; justify-self: center; }

/* Roll animation for cube */
.dice-cube--rolling {
  animation: diceCubeRoll 0.9s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes diceCubeRoll {
  0%   { transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scale(0.7); opacity: 0.6; }
  12%  { transform: rotateX(180deg) rotateY(90deg) rotateZ(45deg) scale(1.08); opacity: 1; }
  28%  { transform: rotateX(400deg) rotateY(220deg) rotateZ(120deg) scale(1); }
  48%  { transform: rotateX(640deg) rotateY(380deg) rotateZ(200deg) scale(1.04); }
  68%  { transform: rotateX(860deg) rotateY(540deg) rotateZ(280deg) scale(1); }
  82%  { transform: rotateX(1000deg) rotateY(640deg) rotateZ(330deg) scale(1.02); }
  100% { transform: rotateX(1080deg) rotateY(720deg) rotateZ(360deg) scale(1); }
}

/* Landing: rotate to show the result face */
.dice-cube--landed {
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Landing transforms — each shows the correct face toward the viewer */
.dice-cube--show-1 { transform: rotateX(0deg) rotateY(0deg); }
.dice-cube--show-2 { transform: rotateX(0deg) rotateY(-90deg); }
.dice-cube--show-3 { transform: rotateX(-90deg) rotateY(0deg); }
.dice-cube--show-4 { transform: rotateX(90deg) rotateY(0deg); }
.dice-cube--show-5 { transform: rotateX(0deg) rotateY(90deg); }
.dice-cube--show-6 { transform: rotateX(0deg) rotateY(180deg); }

/* Crit/Fail glow on cube */
.dice-cube--crit .dice-cube__face {
  border-color: rgba(255, 211, 107, 0.6);
  box-shadow: inset 0 0 16px rgba(255, 211, 107, 0.1);
}

.dice-cube--fail .dice-cube__face {
  border-color: rgba(255, 107, 107, 0.6);
  box-shadow: inset 0 0 16px rgba(255, 107, 107, 0.1);
}

/* --------------------------------------------------------------------------
   Flat Dice (d4, d8, d10, d12, d20, d100) — shaped containers with 3D roll
   -------------------------------------------------------------------------- */

.dice-3d {
  --dice-color: rgba(93, 214, 201, 0.35);
  --dice-glow: rgba(93, 214, 201, 0.15);
  width: 50px;
  height: 50px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dice-3d--small {
  width: 40px;
  height: 40px;
}

/* Type-specific colors */
.dice-3d--d4  { --dice-color: rgba(77, 209, 133, 0.45); --dice-glow: rgba(77, 209, 133, 0.2); }
.dice-3d--d8  { --dice-color: rgba(77, 163, 255, 0.45); --dice-glow: rgba(77, 163, 255, 0.2); }
.dice-3d--d10 { --dice-color: rgba(183, 148, 246, 0.45); --dice-glow: rgba(183, 148, 246, 0.2); }
.dice-3d--d12 { --dice-color: rgba(255, 211, 107, 0.45); --dice-glow: rgba(255, 211, 107, 0.2); }
.dice-3d--d20 { --dice-color: rgba(255, 107, 107, 0.45); --dice-glow: rgba(255, 107, 107, 0.2); }
.dice-3d--d100 { --dice-color: rgba(255, 159, 67, 0.45); --dice-glow: rgba(255, 159, 67, 0.2); }

.dice-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 1.4rem;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, rgba(30, 40, 50, 0.95), rgba(20, 28, 38, 0.98));
  border: 2px solid var(--dice-color);
  backface-visibility: hidden;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.dice-3d--small .dice-face {
  font-size: 1rem;
}

/* Die shapes via clip-path */
.dice-3d--d4 .dice-face {
  clip-path: polygon(50% 5%, 5% 95%, 95% 95%);
  padding-top: 10px;
}

.dice-3d--d8 .dice-face {
  clip-path: polygon(50% 2%, 98% 50%, 50% 98%, 2% 50%);
}

.dice-3d--d10 .dice-face {
  clip-path: polygon(50% 0%, 95% 38%, 82% 95%, 18% 95%, 5% 38%);
  padding-top: 4px;
}

.dice-3d--d12 .dice-face {
  clip-path: polygon(50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
}

.dice-3d--d20 .dice-face {
  clip-path: polygon(50% 0%, 100% 35%, 82% 100%, 18% 100%, 0% 35%);
  padding-top: 3px;
}

.dice-3d--d100 .dice-face {
  border-radius: 50%;
  font-size: 1.1rem;
}

.dice-3d--small.dice-3d--d100 .dice-face {
  font-size: 0.85rem;
}

/* Roll animation for flat dice */
.dice-3d--rolling {
  animation: diceRoll3D 0.85s cubic-bezier(0.2, 0.85, 0.3, 1);
}

@keyframes diceRoll3D {
  0%   { transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scale(0.7); opacity: 0.5; }
  10%  { transform: rotateX(150deg) rotateY(80deg) rotateZ(40deg) scale(1.1); opacity: 1; }
  25%  { transform: rotateX(380deg) rotateY(200deg) rotateZ(120deg) scale(0.98); }
  45%  { transform: rotateX(620deg) rotateY(360deg) rotateZ(200deg) scale(1.06); }
  65%  { transform: rotateX(840deg) rotateY(500deg) rotateZ(280deg) scale(1); }
  80%  { transform: rotateX(980deg) rotateY(620deg) rotateZ(330deg) scale(1.02); }
  100% { transform: rotateX(1080deg) rotateY(720deg) rotateZ(360deg) scale(1); }
}

/* Landing animation — settle with bounce */
.dice-3d--landed {
  animation: diceLand 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes diceLand {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.08) translateY(-3px); }
  70%  { transform: scale(0.97); }
  100% { transform: scale(1) translateY(0); }
}

/* Glow effect on landed dice */
.dice-3d--landed .dice-face {
  box-shadow: 0 0 12px var(--dice-glow), inset 0 0 8px var(--dice-glow);
  transition: box-shadow 0.3s ease;
}

/* Crit/Fail on flat dice */
.dice-3d--crit .dice-face {
  border-color: rgba(255, 211, 107, 0.7);
  box-shadow: 0 0 16px rgba(255, 211, 107, 0.3), inset 0 0 10px rgba(255, 211, 107, 0.1);
  color: var(--gold, #ffd36b);
}

.dice-3d--fail .dice-face {
  border-color: rgba(255, 107, 107, 0.7);
  box-shadow: 0 0 16px rgba(255, 107, 107, 0.3), inset 0 0 10px rgba(255, 107, 107, 0.1);
  color: var(--danger, #ff6b6b);
}

/* ==========================================================================
   Result Area
   ========================================================================== */

.dice-result {
  margin-top: 0.75rem;
  display: none;
}

.dice-result--visible {
  display: block;
  animation: diceResultFadeIn 0.3s ease;
}

@keyframes diceResultFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.dice-result-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid rgba(93, 214, 201, 0.45);
  border-radius: 0.6rem;
  padding: 0.75rem;
  text-align: center;
}

.dice-result-card--crit {
  border-left-color: rgba(255, 211, 107, 0.65);
  background: rgba(255, 211, 107, 0.05);
  animation: diceCritGlow 1.5s ease infinite;
}

.dice-result-card--fail {
  border-left-color: rgba(255, 107, 107, 0.65);
  background: rgba(255, 107, 107, 0.05);
}

@keyframes diceCritGlow {
  0%, 100% { box-shadow: 0 0 6px rgba(255, 211, 107, 0.08); }
  50% { box-shadow: 0 0 16px rgba(255, 211, 107, 0.2); }
}

.dice-result-label {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.35);
  margin-bottom: 0.2rem;
}

.dice-result-total {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 2.4rem;
  font-weight: 900;
  line-height: 1;
  color: #fff;
  margin-bottom: 0.1rem;
  animation: diceResultPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes diceResultPop {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); opacity: 1; }
}

.dice-result-total--crit {
  color: var(--gold, #ffd36b);
  text-shadow: 0 0 18px rgba(255, 211, 107, 0.45);
}

.dice-result-total--fail {
  color: var(--danger, #ff6b6b);
  text-shadow: 0 0 18px rgba(255, 107, 107, 0.35);
}

.dice-result-crit-text {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.3rem;
}

.dice-result-crit-text--nat20 {
  color: var(--gold, #ffd36b);
  text-shadow: 0 0 6px rgba(255, 211, 107, 0.25);
}

.dice-result-crit-text--nat1 {
  color: var(--danger, #ff6b6b);
  text-shadow: 0 0 6px rgba(255, 107, 107, 0.25);
}

.dice-result-formula {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 0.4rem;
}

/* Individual dice results */
.dice-result-dice {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: center;
  margin-top: 0.4rem;
}

.dice-result-die {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.35rem;
  padding: 0.15rem 0.4rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.65);
  min-width: 28px;
  text-align: center;
  animation: dieAppear 0.3s ease backwards;
}

.dice-result-die--max {
  color: var(--gold, #ffd36b);
  border-color: rgba(255, 211, 107, 0.25);
  background: rgba(255, 211, 107, 0.07);
}

.dice-result-die--min {
  color: var(--danger, #ff6b6b);
  border-color: rgba(255, 107, 107, 0.25);
  background: rgba(255, 107, 107, 0.07);
}

@keyframes dieAppear {
  from { opacity: 0; transform: scale(0.5) rotate(-15deg); }
  to { opacity: 1; transform: scale(1) rotate(0deg); }
}

.dice-result-modifier {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  color: rgba(77, 163, 255, 0.75);
  padding: 0.15rem 0.4rem;
}

/* ==========================================================================
   History Section
   ========================================================================== */

.dice-history {
  margin-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 0.6rem;
}

.dice-history-title {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.3);
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dice-history-clear {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.25);
  font-size: 0.6rem;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  border-radius: 0.25rem;
  transition: all 0.15s ease;
}

.dice-history-clear:hover {
  background: rgba(255, 107, 107, 0.1);
  color: var(--danger, #ff6b6b);
}

.dice-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  max-height: 140px;
  overflow-y: auto;
}

.dice-history-list::-webkit-scrollbar {
  width: 3px;
}

.dice-history-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
}

.dice-history-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0.4rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 0.35rem;
  transition: background 0.15s ease;
  cursor: pointer;
}

.dice-history-entry:hover {
  background: rgba(255, 255, 255, 0.05);
}

.dice-history-formula {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.45);
}

.dice-history-total {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--accent, #5dd6c9);
}

.dice-history-entry--crit .dice-history-total {
  color: var(--gold, #ffd36b);
}

.dice-history-entry--fail .dice-history-total {
  color: var(--danger, #ff6b6b);
}

.dice-history-dice {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.25);
  margin-left: 0.4rem;
}

/* ==========================================================================
   Admin: Dice Icon Assignment
   ========================================================================== */

.dice-icon-assign {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
}

.dice-icon-assign__item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.6rem;
  padding: 0.6rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dice-icon-assign__item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

.dice-icon-assign__item--active {
  border-color: rgba(93, 214, 201, 0.35);
  background: rgba(93, 214, 201, 0.08);
}

.dice-icon-assign__preview {
  width: 32px;
  height: 32px;
  margin: 0 auto 0.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.6);
  font-size: 1.4rem;
}

.dice-icon-assign__preview svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.dice-icon-assign__label {
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.dice-icon-assign__name {
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.3);
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   Character Stat Modifier Section
   ========================================================================== */

.dice-char-section {
  margin-bottom: 0.6rem;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-left: 3px solid rgba(77, 163, 255, 0.35);
  border-radius: 0.5rem;
}

.dice-char-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.dice-char-name {
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 85%;
}

.dice-char-name i {
  color: rgba(77, 163, 255, 0.6);
  font-size: 0.6rem;
}

.dice-char-clear {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.3);
  border-radius: 0.3rem;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.55rem;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.dice-char-clear:hover {
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.25);
  color: var(--danger, #ff6b6b);
}

.dice-char-loading {
  text-align: center;
  padding: 0.5rem;
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.35);
}

.dice-char-sublabel {
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.3);
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.dice-char-sublabel i {
  font-size: 0.55rem;
  color: rgba(255, 107, 107, 0.5);
}

/* Stat Button Grid */
.dice-stat-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.2rem;
  margin-bottom: 0.3rem;
}

.dice-stat-grid--combat {
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 0.4rem;
}

.dice-stat-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 0.35rem;
  padding: 0.25rem 0.1rem;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.08rem;
}

.dice-stat-btn:hover {
  background: rgba(77, 163, 255, 0.08);
  border-color: rgba(77, 163, 255, 0.2);
  transform: translateY(-1px);
}

/* Active state — higher specificity via .dice-char-section avoids !important */
.dice-char-section .dice-stat-btn--active {
  background: rgba(77, 163, 255, 0.15);
  border-color: rgba(77, 163, 255, 0.4);
  box-shadow: 0 0 8px rgba(77, 163, 255, 0.12);
}

.dice-stat-btn--active .dice-stat-abbr {
  color: var(--exp, #4da3ff);
}

.dice-stat-btn--active .dice-stat-mod {
  color: #fff;
}

.dice-stat-btn--combat {
  border-color: rgba(255, 211, 107, 0.1);
}

.dice-stat-btn--combat:hover {
  background: rgba(255, 211, 107, 0.08);
  border-color: rgba(255, 211, 107, 0.2);
}

.dice-char-section .dice-stat-btn--combat.dice-stat-btn--active {
  background: rgba(255, 211, 107, 0.15);
  border-color: rgba(255, 211, 107, 0.4);
  box-shadow: 0 0 8px rgba(255, 211, 107, 0.12);
}

.dice-stat-btn--combat.dice-stat-btn--active .dice-stat-abbr {
  color: var(--gold, #ffd36b);
}

.dice-stat-abbr {
  font-size: 0.52rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
}

.dice-stat-mod {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.68rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.65);
}

/* Attack Quick-Roll Presets */
.dice-attack-presets {
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.dice-attack-list {
  display: flex;
  gap: 0.2rem;
  flex-wrap: wrap;
}

.dice-attack-btn {
  background: rgba(255, 107, 107, 0.06);
  border: 1px solid rgba(255, 107, 107, 0.12);
  border-radius: 0.3rem;
  padding: 0.2rem 0.4rem;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.dice-attack-btn:hover {
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.25);
  transform: translateY(-1px);
}

.dice-attack-name {
  font-size: 0.6rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dice-attack-val {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.62rem;
  font-weight: 800;
  color: rgba(255, 107, 107, 0.8);
}

/* Result: Stat Label */
.dice-result-stat {
  font-size: 0.62rem;
  font-weight: 600;
  color: rgba(77, 163, 255, 0.7);
  margin-top: 0.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.dice-result-stat i {
  font-size: 0.55rem;
}

/* History: Stat Badge */
.dice-history-stat {
  font-size: 0.55rem;
  font-weight: 700;
  color: rgba(77, 163, 255, 0.6);
  background: rgba(77, 163, 255, 0.08);
  border: 1px solid rgba(77, 163, 255, 0.15);
  border-radius: 0.2rem;
  padding: 0 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

/* ==========================================================================
   Character Picker (select character for dice rolls)
   ========================================================================== */

.dice-char-picker {
  margin-bottom: 0.5rem;
}

/* "Charakter waehlen" Button */
.dice-picker-select {
  width: 100%;
  padding: 0.4rem 0.6rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 0.5rem;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.dice-picker-select:hover {
  background: rgba(77, 163, 255, 0.08);
  border-color: rgba(77, 163, 255, 0.25);
  color: rgba(255, 255, 255, 0.7);
}

/* Currently selected character indicator */
.dice-picker-current {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.5rem;
  background: rgba(77, 163, 255, 0.06);
  border: 1px solid rgba(77, 163, 255, 0.15);
  border-radius: 0.4rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
}

.dice-picker-current i {
  color: rgba(77, 163, 255, 0.6);
  font-size: 0.6rem;
}

.dice-picker-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(255, 255, 255, 0.7);
}

.dice-picker-badge {
  font-size: 0.5rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(93, 214, 201, 0.6);
  background: rgba(93, 214, 201, 0.08);
  border: 1px solid rgba(93, 214, 201, 0.15);
  border-radius: 0.2rem;
  padding: 0 0.2rem;
  flex-shrink: 0;
}

.dice-picker-change,
.dice-picker-clear {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.3);
  border-radius: 0.25rem;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.5rem;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.dice-picker-change:hover {
  background: rgba(77, 163, 255, 0.12);
  border-color: rgba(77, 163, 255, 0.25);
  color: var(--exp, #4da3ff);
}

.dice-picker-clear:hover {
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.25);
  color: var(--danger, #ff6b6b);
}

/* Character list dropdown */
.dice-picker-list {
  margin-top: 0.3rem;
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0.4rem;
  padding: 0.3rem;
}

.dice-picker-list::-webkit-scrollbar {
  width: 3px;
}

.dice-picker-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
}

.dice-picker-group {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.25);
  padding: 0.25rem 0.3rem 0.1rem;
  margin-top: 0.15rem;
}

.dice-picker-group:first-child {
  margin-top: 0;
}

.dice-picker-char {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0.4rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 0.3rem;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.dice-picker-char:hover {
  background: rgba(77, 163, 255, 0.08);
  border-color: rgba(77, 163, 255, 0.2);
}

.dice-picker-char--active {
  background: rgba(77, 163, 255, 0.12);
  border-color: rgba(77, 163, 255, 0.3);
}

.dice-picker-char-name {
  font-size: 0.68rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.dice-picker-char-info {
  font-size: 0.58rem;
  color: rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
  margin-left: 0.3rem;
}

.dice-picker-loading,
.dice-picker-empty {
  text-align: center;
  padding: 0.5rem;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   Customize Button (Icon Picker Toggle)
   ========================================================================== */

.dice-customize {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.4);
  border-radius: 0.4rem;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.7rem;
  transition: all 0.15s ease;
}

.dice-customize:hover {
  background: rgba(255, 211, 107, 0.12);
  border-color: rgba(255, 211, 107, 0.25);
  color: var(--gold, #ffd36b);
}

.dice-customize--active {
  background: rgba(255, 211, 107, 0.2);
  border-color: rgba(255, 211, 107, 0.4);
  color: var(--gold, #ffd36b);
  box-shadow: 0 0 8px rgba(255, 211, 107, 0.15);
}

/* Dice type buttons in customize mode */
.dice-type-btn--editable {
  position: relative;
  cursor: pointer;
}

.dice-type-btn--editable::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold, #ffd36b);
  opacity: 0.5;
  transition: opacity 0.15s ease;
}

.dice-type-btn--editable:hover::after {
  opacity: 1;
}

.dice-type-btn--editing {
  border-color: rgba(255, 211, 107, 0.5);
  background: rgba(255, 211, 107, 0.12);
  box-shadow: 0 0 10px rgba(255, 211, 107, 0.12);
}

.dice-type-btn--editing::after {
  opacity: 1;
  background: var(--gold, #ffd36b);
  box-shadow: 0 0 4px rgba(255, 211, 107, 0.4);
}

/* ==========================================================================
   Dice Icon Picker (inline in panel)
   ========================================================================== */

.dice-icon-picker {
  margin-bottom: 0.75rem;
  border: 1px solid rgba(255, 211, 107, 0.15);
  border-radius: 0.6rem;
  padding: 0.6rem;
  background: rgba(0, 0, 0, 0.2);
}

.dice-icon-picker-hint {
  text-align: center;
  padding: 0.4rem;
  font-size: 0.68rem;
  color: rgba(255, 211, 107, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.dice-icon-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.dice-icon-picker-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold, #ffd36b);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.dice-icon-picker-actions {
  display: flex;
  gap: 0.25rem;
}

.dice-icon-picker-reset {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.4);
  border-radius: 0.35rem;
  padding: 0.15rem 0.4rem;
  font-size: 0.6rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dice-icon-picker-reset:hover {
  background: rgba(255, 107, 107, 0.15);
  border-color: rgba(255, 107, 107, 0.3);
  color: var(--danger, #ff6b6b);
}

.dice-icon-picker-search {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.4rem;
  padding: 0.35rem 0.6rem;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.9);
  outline: none;
  margin-bottom: 0.4rem;
  transition: border-color 0.2s ease;
  box-sizing: border-box;
}

.dice-icon-picker-search:focus {
  border-color: rgba(255, 211, 107, 0.4);
  box-shadow: 0 0 0 2px rgba(255, 211, 107, 0.1);
}

.dice-icon-picker-search::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

.dice-icon-picker-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  margin-bottom: 0.5rem;
}

.dice-icon-picker-cat {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.35rem;
  padding: 0.15rem 0.4rem;
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.dice-icon-picker-cat:hover {
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.75);
}

.dice-icon-picker-cat--active {
  background: rgba(255, 211, 107, 0.15);
  border-color: rgba(255, 211, 107, 0.35);
  color: var(--gold, #ffd36b);
}

.dice-icon-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 0.25rem;
  max-height: 180px;
  overflow-y: auto;
  padding: 0.25rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0.4rem;
}

.dice-icon-picker-grid::-webkit-scrollbar {
  width: 4px;
}

.dice-icon-picker-grid::-webkit-scrollbar-track {
  background: transparent;
}

.dice-icon-picker-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 211, 107, 0.2);
  border-radius: 2px;
}

.dice-icon-picker-item {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.4rem;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.55);
  transition: all 0.15s ease;
}

.dice-icon-picker-item:hover {
  background: rgba(255, 211, 107, 0.12);
  border-color: rgba(255, 211, 107, 0.35);
  color: rgba(255, 255, 255, 0.95);
  transform: scale(1.08);
}

.dice-icon-picker-item--selected {
  background: rgba(255, 211, 107, 0.2);
  border-color: rgba(255, 211, 107, 0.5);
  color: var(--gold, #ffd36b);
  box-shadow: 0 0 8px rgba(255, 211, 107, 0.15);
}

.dice-icon-picker-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 1rem;
  color: rgba(255, 255, 255, 0.25);
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.dice-icon-picker-more {
  grid-column: 1 / -1;
  text-align: center;
  padding: 0.35rem;
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.6rem;
}

/* Mode tabs (FA / Custom SVG) */
.dice-icon-picker-modes {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.4rem;
}

.dice-icon-picker-mode {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.4rem;
  padding: 0.3rem 0.5rem;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}

.dice-icon-picker-mode:hover {
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.75);
}

.dice-icon-picker-mode--active {
  background: rgba(255, 211, 107, 0.12);
  border-color: rgba(255, 211, 107, 0.3);
  color: var(--gold, #ffd36b);
}

/* SVG icon items */
.dice-icon-picker-item--svg {
  padding: 3px;
  color: var(--accent, #5dd6c9);
}

.dice-icon-picker-item--svg svg {
  width: 100%;
  height: 100%;
}

/* ==========================================================================
   Focus-Visible States (Keyboard Accessibility)
   ========================================================================== */

.dice-type-btn:focus-visible,
.dice-preset:focus-visible,
.dice-ctrl-btn:focus-visible,
.dice-roll-btn:focus-visible,
.dice-stat-btn:focus-visible,
.dice-attack-btn:focus-visible,
.dice-history-entry:focus-visible,
.dice-detach:focus-visible,
.dice-close:focus-visible,
.dice-char-clear:focus-visible,
.dice-history-clear:focus-visible,
.dice-picker-select:focus-visible,
.dice-picker-change:focus-visible,
.dice-picker-clear:focus-visible,
.dice-picker-char:focus-visible,
.dice-customize:focus-visible,
.dice-icon-picker-item:focus-visible,
.dice-icon-picker-cat:focus-visible,
.dice-icon-picker-reset:focus-visible,
.dice-icon-picker-mode:focus-visible {
  outline: 2px solid var(--accent, #5dd6c9);
  outline-offset: 2px;
}

.dice-ctrl-input:focus-visible {
  outline: 2px solid var(--accent, #5dd6c9);
  outline-offset: -2px;
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .dice-3d--rolling,
  .dice-cube--rolling {
    animation: none;
  }

  .dice-3d--landed {
    animation: none;
  }

  .dice-cube--rolling {
    animation: none;
  }

  .dice-cube {
    transition: transform 0.1s ease;
  }

  .dice-cube--landed {
    transition: none;
  }

  .dice-result-total {
    animation: none;
  }

  .dice-result-die {
    animation: none;
  }

  .dice-result-card--crit {
    animation: none;
  }

  .dice-roll-btn--rolling {
    animation: none;
  }

  .dice-result--visible {
    animation: none;
  }

  .dice-panel {
    transition: opacity 0.15s ease;
    transform: none;
  }

  .dice-panel--visible {
    transform: none;
  }

  .dice-overlay {
    transition: none;
  }

  .dice-type-btn,
  .dice-preset,
  .dice-ctrl-btn,
  .dice-stat-btn,
  .dice-attack-btn,
  .dice-history-entry,
  .dice-detach,
  .dice-close,
  .dice-char-clear,
  .dice-history-clear,
  .dice-picker-select,
  .dice-picker-change,
  .dice-picker-clear,
  .dice-picker-char,
  .dice-customize,
  .dice-icon-picker-item,
  .dice-icon-picker-cat,
  .dice-icon-picker-reset,
  .dice-icon-picker-mode {
    transition: none;
  }
}

/* ==========================================================================
   Mobile
   ========================================================================== */

@media (max-width: 576px) {
  .dice-panel {
    right: 6px;
    left: 6px;
    width: auto;
    top: 50px;
    max-height: calc(100vh - 60px - var(--tabbarH, 72px));
    padding: 0.85rem;
    border-radius: 0.85rem;
  }

  .dice-panel--floating {
    left: 4px;
    right: auto;
    width: calc(100vw - 8px);
  }

  .dice-types {
    gap: 0.25rem;
  }

  .dice-type-btn {
    padding: 0.35rem 0.15rem;
  }

  .dice-type-icon {
    font-size: 1rem;
  }

  .dice-result-total {
    font-size: 2rem;
  }

  .dice-stage {
    height: 72px;
    height: 68px;
  }

  .dice-cube {
    --cube-size: 40px;
    --cube-half: 20px;
  }

  .dice-cube--small {
    --cube-size: 32px;
    --cube-half: 16px;
  }

  .dice-cube--small .dice-pip {
    width: 4px;
    height: 4px;
  }

  .dice-3d {
    width: 42px;
    height: 42px;
  }

  .dice-3d--small {
    width: 34px;
    height: 34px;
  }

  .dice-3d--small .dice-face {
    font-size: 0.85rem;
  }

  .dice-cube-wrapper {
    width: 46px;
    height: 46px;
  }

  .dice-stage--multi .dice-cube-wrapper {
    width: 36px;
    height: 36px;
  }

  /* Smaller translateZ for mobile cubes */
  .dice-cube__face--1 { transform: rotateY(  0deg) translateZ(23px); }
  .dice-cube__face--2 { transform: rotateY( 90deg) translateZ(23px); }
  .dice-cube__face--3 { transform: rotateX(-90deg) translateZ(23px); }
  .dice-cube__face--4 { transform: rotateX( 90deg) translateZ(23px); }
  .dice-cube__face--5 { transform: rotateY(-90deg) translateZ(23px); }
  .dice-cube__face--6 { transform: rotateY(180deg) translateZ(23px); }

  .dice-stage--multi .dice-cube__face--1 { transform: rotateY(  0deg) translateZ(18px); }
  .dice-stage--multi .dice-cube__face--2 { transform: rotateY( 90deg) translateZ(18px); }
  .dice-stage--multi .dice-cube__face--3 { transform: rotateX(-90deg) translateZ(18px); }
  .dice-stage--multi .dice-cube__face--4 { transform: rotateX( 90deg) translateZ(18px); }
  .dice-stage--multi .dice-cube__face--5 { transform: rotateY(-90deg) translateZ(18px); }
  .dice-stage--multi .dice-cube__face--6 { transform: rotateY(180deg) translateZ(18px); }
  .dice-3d--d100 .dice-face {
    font-size: 0.9rem;
  }

  /* Stat grid: 3 columns on mobile for better tap targets */
  .dice-stat-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Icon picker: larger items for touch targets */
  .dice-icon-picker-grid {
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    max-height: 160px;
  }

  .dice-icon-picker-item {
    font-size: 1.1rem;
  }

  .dice-icon-picker-cats {
    gap: 0.15rem;
  }

  .dice-icon-picker-cat {
    font-size: 0.55rem;
    padding: 0.12rem 0.3rem;
  }
}
