/* ── Dice roller ──────────────────────────────────────────────── */

#dice-roller-wrap {
  position: fixed;
  bottom: 1rem;
  left: calc(var(--sidebar-w) + 12px);
  z-index: 10;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  transition: left 0.25s ease;
}
body.sidebar-collapsed #dice-roller-wrap { left: 12px; }

#dice-roller {
  background: rgba(31, 41, 55, 0.9);
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 0.5rem 0.85rem 0.6rem;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  display: none; /* shown only in tracker */
}
#dice-roller.visible { display: block; }
#dice-roller:not(.dice-collapsed) { min-width: 180px; }
#dice-roller.dice-collapsed { padding-bottom: 0.5rem; }

#dice-roller-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.dice-roller-title {
  font-size: 0.72rem;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dice-collapse-btn {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: transform 0.15s;
}
.dice-collapse-btn:hover { color: #d1d5db; }
#dice-roller.dice-collapsed .dice-collapse-btn { transform: rotate(-90deg); }

#dice-roller-body {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
#dice-roller.dice-collapsed #dice-roller-body { display: none; }

#dice-prev-row {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  min-height: 1rem;
  font-size: 0.8rem;
  line-height: 1.25;
  color: #9ca3af;
}

.dice-prev-label {
  color: #6b7280;
  font-weight: 700;
}

#dice-prev-text {
  color: #cbd5e1;
  word-break: break-word;
}

.dice-shortcuts-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  justify-content: center;
}

.dice-shortcut-btn {
  background: rgba(55, 65, 81, 0.75);
  border: 1px solid #4b5563;
  color: #cbd5e1;
  border-radius: 999px;
  padding: 0.16rem 0.42rem;
  font-size: 0.8rem;
  line-height: 1.2;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.dice-shortcut-btn:hover {
  background: rgba(75, 85, 99, 0.95);
}
.dice-shortcut-btn.active {
  border-color: #9ca3af;
  color: #f9fafb;
  background: rgba(107, 114, 128, 0.95);
}

.dice-count-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.dice-count-label {
  font-size: 0.8rem;
  color: #9ca3af;
  letter-spacing: 0.02em;
  margin-right: 0.12rem;
}

.dice-adj-btn {
  background: #374151;
  border: 1px solid #4b5563;
  color: #d1d5db;
  border-radius: 5px;
  width: 1.38rem;
  height: 1.38rem;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}
.dice-adj-btn:hover { background: #4b5563; }

.dice-throw-row {
  display: flex;
}

#dice-count-input {
  width: 1.72rem;
  text-align: center;
  background: #111827;
  border: 1px solid #4b5563;
  color: #f9fafb;
  border-radius: 5px;
  font-size: 0.8rem;
  padding: 0.14rem 0;
}

#dice-throw-btn {
  width: 100%;
  background: #4b5563;
  border: 1px solid #6b7280;
  color: #9ca3af;
  border-radius: 5px;
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
#dice-throw-btn:hover { background: #6b7280; }

#dice-result {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  min-height: 0;
}
#dice-result:empty { display: none; }

.die-face {
  position: relative;
  width: 3rem;
  height: 3rem;
  background: #1f2937;
  border: 2px solid #6b7280;
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 0.34rem;
  gap: 0.06rem;
  color: #f9fafb;
  flex-shrink: 0;
  box-sizing: border-box;
  animation: die-pop 0.18s ease-out;
}
.die-face[data-val="1"] { border-color: #dc2626; color: #ef4444; }
.die-face[data-tone="low"] { border-color: #dc2626; color: #ef4444; }
.die-face[data-tone="high"] { border-color: #86efac; color: #86efac; }
.die-face[data-tone="max"] { border-color: #86efac; color: #86efac; }
.die-face--numeric {
  display: flex;
  align-items: center;
  justify-content: center;
  grid-template-columns: none;
  grid-template-rows: none;
  padding: 0;
  gap: 0;
  overflow: hidden;
}
.die-face.no-anim { animation: none; }
.die-face--preview {
  border-color: #4b5563;
  color: rgba(209, 213, 219, 0.55);
  background: rgba(31, 41, 55, 0.72);
}

.die-pip {
  border-radius: 50%;
  width: 0.36rem;
  height: 0.36rem;
  margin: auto;
}
.die-pip.on { background: currentColor; }
.die-pip--preview {
  background: rgba(209, 213, 219, 0.4);
}

.die-shape {
  position: absolute;
  inset: 0.19rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(156, 163, 175, 0.38);
  pointer-events: none;
}
.die-shape svg {
  width: 100%;
  height: 100%;
}
.die-shape path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.die-type {
  position: absolute;
  top: 0.22rem;
  left: 0.34rem;
  font-size: 0.54rem;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(209, 213, 219, 0.8);
}

.die-value {
  position: relative;
  z-index: 1;
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1;
}
.die-value--preview {
  color: rgba(209, 213, 219, 0.48);
  font-size: 1.32rem;
}

.die-face--percentile .die-value {
  font-size: 1.1rem;
}

.die-percent-pair {
  position: absolute;
  right: 0.3rem;
  bottom: 0.22rem;
  font-size: 0.5rem;
  line-height: 1;
  color: rgba(209, 213, 219, 0.68);
  letter-spacing: 0.02em;
}

.dice-op,
.dice-mod {
  color: #9ca3af;
  font-weight: 700;
  font-size: 1.08rem;
  line-height: 1;
}

.dice-sum {
  font-size: 1.26rem;
  font-weight: 700;
  color: #9ca3af;
  padding: 0 0.2rem;
}
.dice-sum-sep {
  color: #6b7280;
  font-size: 0.85rem;
}

@keyframes die-pop {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

