:root {
  --bg-1: #f9f7f2;
  --bg-2: #e9f2df;
  --ink: #1e2a1a;
  --accent: #e4572e;
  --card: #ffffffd6;
  --border: #1f2f1f;
  --blob-1: #ffe4c7;
  --blob-2: #c8efc2;
  --die-bg: #ffffff;
  --pip: #1f2f1f;
  --held-bg: #1f2f1f;
  --held-fg: #fffefb;
  --gold: #caa53e;
  --gold-soft: #caa53e44;
  --gold-bg: #caa53e22;
  --hair: #1f2f1f11;
  --line-soft: #1f2f1f22;
  /* Contrast-safe variants for white-on-color and color-on-card *text* (AA 1.4.3).
     --accent stays for decorative fills (bars, rings) where contrast doesn't apply. */
  --btn-bg: #c2411c; /* white text on it: 5.2:1 */
  --accent-text: #c2411c; /* accent text on the light card: 5.2:1 */
  --gold-text: #8a6d1f; /* gold-family text on the light card: 4.9:1 */
  --gold-fg: #1f2f1f; /* dark text for the "NEW" badge sitting on gold */
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg-1: #15170f;
    --bg-2: #10140c;
    --ink: #eceadd;
    --accent: #f06a42;
    --card: #22241ddd;
    --border: #4a4d42;
    --blob-1: #2c2a1e;
    --blob-2: #1c2a18;
    --die-bg: #2b2e26;
    --pip: #eceadd;
    --held-bg: #eceadd;
    --held-fg: #1f211b;
    --gold: #d8b75a;
    --gold-soft: #d8b75a55;
    --gold-bg: #d8b75a26;
    --hair: #ffffff12;
    --line-soft: #ffffff1f;
    /* On the dark card the original bright shades already clear AA, so keep them
       for text; --btn-bg inherits the deep orange (white text stays readable). */
    --accent-text: #f06a42;
    --gold-text: #d8b75a;
    --gold-fg: #1f211b;
  }
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 15%, var(--blob-1) 0, transparent 35%),
    radial-gradient(circle at 85% 10%, var(--blob-2) 0, transparent 40%),
    linear-gradient(145deg, var(--bg-1), var(--bg-2));
}
.wrap {
  max-width: 760px;
  margin: 28px auto;
  padding: 16px;
}
h1,
.brand {
  font-family: "Bungee", system-ui, sans-serif;
  letter-spacing: 1px;
  margin: 0 0 6px;
}
.subtitle {
  margin-top: 0;
  opacity: 0.85;
}
.panel {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
}
button {
  font: inherit;
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--btn-bg);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease;
}
button:hover:not(:disabled) {
  transform: translateY(-2px);
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
button.ghost {
  background: var(--die-bg);
  color: var(--ink);
}

/* Visible keyboard focus for every interactive element, including the
   role="button" dice and scorecard rows that aren't native controls.
   --ink contrasts on both the accent buttons and the light surfaces. */
:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
.dice {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 13px;
  flex-wrap: wrap;
  min-height: 80px;
}
.die {
  position: relative;
  width: 56px;
  height: 56px;
  border: 2.5px solid var(--ink);
  background: var(--die-bg);
  border-radius: 10px;
  cursor: pointer;
}
.die .pip {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--pip);
  transform: translate(-50%, -50%);
}
.die.held {
  box-shadow: 0 0 0 3px var(--ink);
}
.die.held::after {
  content: "HELD";
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--held-bg);
  color: var(--held-fg);
}
.die.new {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.die.new::after {
  content: "NEW";
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--gold);
  color: var(--gold-fg);
}
.scorecard {
  display: flex;
  flex-direction: column;
  font-size: 13px;
}
.sc-sec {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
  font-weight: 700;
  opacity: 0.65;
  margin: 8px 0 4px;
}
.scorecard .row {
  display: flex;
  justify-content: space-between;
  padding: 6px 4px;
  border-bottom: 1px solid var(--hair);
}
.scorecard .row .pts {
  font-weight: 700;
}
.scorecard .row.available {
  cursor: pointer;
  border-radius: 8px;
}
.scorecard .row.available:hover {
  background: var(--gold-bg);
}
.scorecard .row.available .pts {
  color: var(--gold-text);
}
.scorecard .row.zero {
  cursor: pointer;
  opacity: 0.45;
}
.scorecard .row.zero:hover {
  opacity: 0.75;
  background: var(--line-soft);
  border-radius: 8px;
}
/* Already scored: strike through the name and mute the row so used categories
   are visually distinct from the ones still in play. */
.scorecard .row.committed {
  opacity: 0.55;
}
.scorecard .row.committed span:first-child {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}
.scorecard .row.committed .pts {
  color: var(--ink);
}
.scorecard .row.sub {
  opacity: 0.85;
  border-bottom: none;
}
.scorecard .row.tot {
  border-top: 2px solid var(--border);
  margin-top: 6px;
  padding-top: 8px;
  font-weight: 700;
  font-size: 15px;
}
.stats {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.stat {
  border: 2px solid var(--line-soft);
  border-radius: 10px;
  padding: 8px 12px;
  text-align: center;
  min-width: 64px;
}
.stat .v {
  font-size: 18px;
  font-weight: 800;
}
.stat .k {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.75;
}
.dist {
  margin-top: 14px;
}
.dist-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 70px;
}
.dist-bar {
  flex: 1;
  background: var(--line-soft);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
}
.dist-bar.you {
  background: var(--accent);
}
.dist-axis {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  opacity: 0.7;
  margin-top: 4px;
}
.dist-cap {
  font-size: 11px;
  opacity: 0.85;
  margin-top: 6px;
  text-align: center;
  font-weight: 600;
}
