.dice-controls {
  display: grid;
  gap: 18px;
}

.dice-options {
  display: grid;
  gap: 18px;
}

@media (min-width: 640px) {
  .dice-options {
    grid-template-columns: auto 1fr;
    gap: 24px;
  }
}

.field {
  display: grid;
  align-content: start;
  gap: 8px;
}

.field-label {
  font-size: 0.9375rem;
  font-weight: 600;
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.stepper button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 9px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 1.375rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.stepper button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.stepper output {
  min-width: 3ch;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: center;
}

/* Six kinds of dice: three per row on phones, one row from 420px. */
.dice-sides {
  grid-auto-flow: row;
  grid-template-columns: repeat(3, 1fr);
}

@media (min-width: 420px) {
  .dice-sides {
    grid-template-columns: repeat(6, 1fr);
  }
}

.roll-button {
  width: 100%;
  min-height: 56px;
  font-size: 1.125rem;
}

/* Result */

.dice-result {
  text-align: center;
}

.dice-tray {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 96px;
  padding: 8px 0;
}

.dice-placeholder {
  color: var(--muted);
}

.die {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: inset 0 -3px 0 var(--surface-2), var(--shadow-md);
}

@media (min-width: 480px) {
  .die {
    width: 72px;
    height: 72px;
  }
}

.die-pips {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 11px;
}

.pip {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--text);
}

@media (min-width: 480px) {
  .pip {
    width: 12px;
    height: 12px;
  }
}

.die-number {
  font-size: 1.625rem;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.die.rolling {
  animation: die-roll 0.45s ease-out;
}

@keyframes die-roll {
  0% {
    opacity: 0.3;
    transform: rotate(-30deg) scale(0.8);
  }
  60% {
    opacity: 1;
    transform: rotate(8deg) scale(1.06);
  }
  100% {
    transform: none;
  }
}

.dice-sum {
  margin-top: 8px;
  color: var(--muted);
  font-size: 1.0625rem;
}

.dice-sum strong {
  margin-left: 6px;
  color: var(--text);
  font-size: 1.75rem;
  font-variant-numeric: tabular-nums;
  vertical-align: -2px;
}

/* History */

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  margin-bottom: 4px;
}

.history-head h2 {
  font-size: 1.0625rem;
}

.history-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.history-list li:first-child {
  border-top: 0;
}

.history-roll {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
}

.history-values {
  min-width: 0;
  overflow-wrap: anywhere;
}

.history-total {
  font-weight: 700;
}

.history-empty {
  padding: 4px 0;
  color: var(--muted);
}
