:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #1e1f22;
  --card-bg: #f2f3f5;
  --border: #d4d6da;
  --accent: #361887;
  --accent-text: #e2ca5b;
  --error: #d83c3e;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #313338;
    --fg: #f2f3f5;
    --card-bg: #2b2d31;
    --border: #1e1f22;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 10px;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

h1 {
  font-size: 15px;
  margin: 0;
}

h2 {
  font-size: 13px;
  margin: 0 0 6px 0;
}

.status {
  margin: 2px 0 0 0;
  min-height: 14px;
  font-size: 12px;
  color: var(--fg);
  opacity: 0.75;
}

.status.error {
  color: var(--error);
  opacity: 1;
}

details {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
}

summary {
  cursor: pointer;
  font-weight: 600;
}

.card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  background: var(--card-bg);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 6px 0;
}

.field label {
  font-size: 11px;
  opacity: 0.8;
}

.row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.row label {
  display: flex;
  flex-direction: column;
  font-size: 11px;
  gap: 2px;
}

input {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  background: var(--bg);
  color: var(--fg);
  width: 64px;
}

/* Native spinner arrows look like unstyled browser chrome next to the rest
   of the themed UI -- hidden in favor of the custom .number-stepper below
   (typing a value directly still works too). */
input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.number-input {
  position: relative;
  display: inline-block;
}

.number-input input[type="number"] {
  padding-right: 16px;
}

.number-stepper {
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  width: 15px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
}

.stepper-btn {
  flex: 1;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  color: var(--fg);
  font-weight: 400;
  font-size: 7px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stepper-btn:hover {
  color: var(--accent);
}

/* Secondary (default): quiet outline style for supporting actions like
   Apply/Set/-1/+1, so they don't compete visually with the roll buttons.
   Uses the same neutral fg/border colors as the rest of the UI chrome
   (rather than --accent) since those are already tuned for legibility in
   both light and dark themes -- --accent is a fixed dark purple that would
   have poor contrast sitting directly on a dark card background. */
button {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 9px;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  border-color: var(--accent);
}

/* Primary: the loud, filled button for the main action in a card (rolling).
   Safe in both themes since the fill is a fixed dark color regardless of
   page theme, so the gold text always has strong contrast against it. */
.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
  padding: 8px 14px;
  font-size: 14px;
}

.btn-primary:hover {
  filter: brightness(1.15);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

.roll-history {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.roll-history:empty::before {
  content: "No rolls yet.";
  opacity: 0.6;
  font-size: 12px;
}

.roll-history li {
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

.roll-history li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.dice-faces {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin: 2px 0;
}

.dice-face-icon {
  width: 36px;
  height: 36px;
}

.roll-time {
  opacity: 0.6;
  font-size: 11px;
  font-weight: 400;
}

.pending {
  font-size: 12px;
  margin: 4px 0 6px 0;
}

.pending-value {
  font-weight: 700;
}

/* Quieter than the default <details> (used for Settings) since this is a
   less-used escape hatch next to the main -1/+1/Apply controls. */
.set-value {
  border: none;
  padding: 0;
  margin-top: 6px;
}

.set-value summary {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.75;
}

.set-value .row {
  margin-top: 6px;
  margin-bottom: 0;
}

.pool-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin: 4px 0;
}

.pool-icon {
  width: 48px;
  height: 48px;
}
