/* Phoenix-served stylesheet. Mirrors apps/web/src/layouts/Base.astro
 * so the static Astro pillars and the Phoenix dynamic routes share
 * one visual vocabulary. Plain CSS for now — when the design grows
 * beyond ~500 lines, swap in the same Bun + Tailwind pipeline scsipub
 * uses. */

:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-border: #262a33;
  --text: #e3e6ec;
  --muted: #858b99;
  --accent: #7cc4ff;
  --accent-strong: #4e8fd1;
  --good: #7fd7a5;
  --error: #ff9191;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  padding: 0;
}
html { min-height: 100%; }
body { min-height: 100dvh; }

/* LiveView injects a wrapper <div data-phx-main> around the @inner_content
 * before the layout's <main> takes over. Force it transparent + full-width
 * so it can't accidentally narrow or offset the centred main below it. */
[data-phx-main] {
  display: block;
  width: 100%;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: underline; }

.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
}
.brand {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}
nav a { margin-left: 16px; }
nav a[aria-current="page"] {
  color: var(--text);
  border-bottom: 1px solid var(--accent);
}

.kicker {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
}
.kicker code {
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 12px;
  font-size: 13px;
}

h1 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: -0.01em;
}
h2 {
  font-size: 16px;
  margin: 24px 0 8px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tagline {
  color: var(--muted);
  margin: 0 0 24px;
  max-width: 65ch;
}

code {
  background: var(--panel);
  padding: 0 4px;
  border-radius: 3px;
  font-size: 0.9em;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.target-row {
  margin-bottom: 20px;
}
.target-row label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

input[type="text"],
input[type="number"] {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
input[type="text"] { width: 100%; box-sizing: border-box; }
input[type="number"] { width: 90px; }
input:focus { outline: none; border-color: var(--accent-strong); }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
}

.strike {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 16px;
}
.strike-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  /* Flex so the optional Roll button on the right side stays in the
     header row instead of floating into the next element (the
     expression input). align-items: center vertically centers the
     button against the smaller-cap text label. */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.strike-expr {
  display: block;
  font-size: 18px;
  margin-bottom: 12px;
  background: transparent;
  padding: 0;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  margin-bottom: 10px;
  font-size: 13px;
}
.stats strong { color: var(--text); font-weight: 600; }

.exact {
  color: var(--muted);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  margin-left: 4px;
}

/* Standard deviation displayed inline next to the mean ("12 ± 2.4"). Same
   visual weight as `.exact` so both feel like secondary annotations on the
   primary statistic. */
.spread {
  color: var(--muted);
  font-size: 11px;
  margin-left: 4px;
}

.kill {
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  margin: 10px 0 14px;
  color: var(--muted);
}
.kill strong { color: var(--good); }

/* Per-type breakdown — only renders for actually-typed expressions
   (length(by_type) > 1). Single-line stack of pills, each showing the
   type tag plus its per-type mean and range. The color scheme mirrors
   the damage-type vocabulary readers know from D&D 5e + ARPG sheets:
   physical types stay neutral, magical types get accent color, fire/
   cold/lightning each get their canonical hue. */
.type-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 12px;
}
.type-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}
.type-pill strong {
  text-transform: capitalize;
  font-weight: 600;
  color: var(--text);
}
.type-pill .type-mean {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--text);
}
.type-pill .type-range {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
}

/* Per-type accents — keep these subtle; the pill is information, not
   a visual centerpiece. Light tint on the border + matching strong color. */
.type-pill.type-fire    { border-color: rgba(217, 119, 87, 0.4); }
.type-pill.type-fire strong { color: #d97757; }
.type-pill.type-cold    { border-color: rgba(124, 196, 255, 0.4); }
.type-pill.type-cold strong { color: var(--accent); }
.type-pill.type-lightning { border-color: rgba(255, 215, 100, 0.4); }
.type-pill.type-lightning strong { color: #ffd764; }
.type-pill.type-poison  { border-color: rgba(127, 215, 165, 0.4); }
.type-pill.type-poison strong { color: var(--good); }
.type-pill.type-acid    { border-color: rgba(176, 215, 100, 0.4); }
.type-pill.type-acid strong { color: #b0d764; }
.type-pill.type-radiant { border-color: rgba(255, 230, 180, 0.4); }
.type-pill.type-radiant strong { color: #ffe6b4; }
.type-pill.type-necrotic { border-color: rgba(140, 100, 180, 0.4); }
.type-pill.type-necrotic strong { color: #8c64b4; }
.type-pill.type-thunder { border-color: rgba(180, 180, 220, 0.4); }
.type-pill.type-thunder strong { color: #b4b4dc; }
.type-pill.type-force   { border-color: rgba(220, 200, 255, 0.4); }
.type-pill.type-force strong { color: #dcc8ff; }
.type-pill.type-psychic { border-color: rgba(220, 140, 220, 0.4); }
.type-pill.type-psychic strong { color: #dc8cdc; }
/* Physical types share a neutral cream/slashing tint. */
.type-pill.type-slashing,
.type-pill.type-piercing,
.type-pill.type-bludgeoning,
.type-pill.type-physical { border-color: rgba(227, 230, 236, 0.3); }
/* Untyped (fallback) — muted, no hue. */
.type-pill.type-untyped { opacity: 0.7; }

.outcomes {
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
}
.outcomes li {
  display: grid;
  grid-template-columns: 44px 1fr 60px;
  align-items: center;
  gap: 8px;
  padding: 1px 0;
}
.outcome-value { color: var(--muted); text-align: right; }

/* Natural-language decode of the user's expression — sits between the
   input and the analysis bars so the meaning is visible without
   leaving the panel. */
.expression-decode {
  margin: 6px 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  font-style: italic;
}

/* CSS-driven tooltip on `.has-tooltip` elements that carry a
   `data-tooltip="..."` attribute. Replaces the previous reliance on the
   browser-native `title` tooltip, which on macOS Safari is slow/unreliable
   and on iOS doesn't fire at all without a hover gesture. The
   pseudo-element renders instantly on hover and on keyboard focus. */
.has-tooltip {
  cursor: help;
  position: relative;
}
.has-tooltip:hover::after,
.has-tooltip:focus-visible::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
/* Tooltips on right-edge elements (e.g., the per-strike probability
   column) would overflow the viewport at left:50%; pin them to the
   right edge instead. */
.strikes-prob.has-tooltip:hover::after,
.strikes-prob.has-tooltip:focus-visible::after {
  left: auto;
  right: 0;
  transform: none;
}
/* Zero-probability rows (e.g., outcome 6 on 1d6! — exploded to 7+) stay
   visible at reduced opacity so the "gap" structure of exploding-dice
   distributions reads correctly. */
.outcomes li.zero { opacity: 0.45; }
.outcome-prob  { color: var(--muted); text-align: right; }

/* Explicit bar element so width: <pct>% resolves against the middle
 * grid column (the .bar wrapper) rather than the whole <li>. The
 * earlier ::after-pseudo-element approach made the bar overflow the
 * column into the probability number. */
.outcomes .bar {
  position: relative;
  height: 10px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
}
.outcomes .bar .fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--accent);
  opacity: 0.75;
  border-radius: 2px;
  transition: width 0.15s ease-out;
}

.hp-label {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 13px;
}
.hp-label strong {
  color: var(--good);
  font-variant-numeric: tabular-nums;
  min-width: 32px;
  display: inline-block;
}
.hp-label input[type="range"] {
  flex: 1;
  max-width: 320px;
}

.strike-edit {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 18px;
  margin-bottom: 12px;
}
.strike-edit:focus {
  outline: none;
  border-color: var(--accent-strong);
}

.kill-headline {
  font-size: 32px;
  font-weight: 600;
  color: var(--good);
  margin: 16px 0;
}
.kill-headline .exact {
  font-size: 16px;
  color: var(--muted);
  font-weight: 400;
}

.strikes-to-kill {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}
.strikes-to-kill > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  font-size: 13px;
}
.strikes-to-kill > header strong { color: var(--text); font-weight: 600; }
.strikes-expected { color: var(--muted); }
.strikes-expected .exact {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
}
.strikes-bars {
  list-style: none;
  padding: 0;
  margin: 0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
}
.strikes-bars li {
  display: grid;
  grid-template-columns: 44px 1fr 60px;
  align-items: center;
  gap: 8px;
  padding: 1px 0;
}
.strikes-n { color: var(--muted); text-align: right; }
.strikes-prob { color: var(--muted); text-align: right; }
.strikes-bars .bar {
  position: relative;
  height: 10px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
}
.strikes-bars .bar .fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--good);
  opacity: 0.75;
}
.strikes-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-style: italic;
}

.vs-strikes-callout {
  margin: 16px 0;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  text-align: center;
}

.error-page h1 { color: var(--error); }
.error {
  color: var(--error);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

footer {
  margin-top: 40px;
  color: var(--muted);
  font-size: 12px;
}

/* ---------------------------------------------------------------------- */
/* /vs view-mode toggle + diff panel.                                     */
/* The toggle flips between the default side-by-side layout and a single  */
/* merged chart that shows per-outcome probability deltas — diverging     */
/* bars from a centerline make "where does B win?" instantly obvious.     */
/* ---------------------------------------------------------------------- */

.view-toggle {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 2px;
  margin-bottom: 16px;
  font-size: 13px;
}
.view-toggle-btn {
  background: none;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  font-family: inherit;
  font-size: inherit;
  font-weight: 500;
}
.view-toggle-btn:hover { color: var(--text); }
.view-toggle-btn.active,
.view-toggle-btn:disabled {
  background: var(--bg);
  color: var(--text);
  cursor: default;
}

.diff-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 14px 16px;
}

.diff-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 13px;
  flex-wrap: wrap;
}
.diff-side { color: var(--muted); }
.diff-side code { color: var(--text); font-weight: 600; }
.diff-side.a code, .diff-swatch.a { color: var(--diff-a, #d97757); }
.diff-side.b code, .diff-swatch.b { color: var(--diff-b, #4eb085); }
.diff-vs { color: var(--muted); font-style: italic; }

.diff-kill-callout {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
}
.diff-kill-callout strong.b-more { color: var(--diff-b, #4eb085); }
.diff-kill-callout strong.a-more { color: var(--diff-a, #d97757); }
.diff-kill-callout strong.tied { color: var(--muted); }

.diff-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.diff-row {
  display: grid;
  grid-template-columns: 32px 1fr 64px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.diff-value { color: var(--muted); text-align: right; }

/* The track is split down the middle: the left half is reserved for
   "A more" bars (anchored to the right edge, growing leftward); the
   right half for "B more" (anchored to the left edge, growing right).
   The center column line itself is just the boundary between the two. */
.diff-track {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 14px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
}
.diff-track::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: var(--panel-border);
}
.diff-bar {
  height: 100%;
  border-radius: 2px;
}
.diff-bar.a {
  background: var(--diff-a, #d97757);
  margin-left: auto;  /* anchor right edge of left column */
}
.diff-bar.b {
  background: var(--diff-b, #4eb085);
  /* anchored to the left edge naturally */
}

.diff-delta { text-align: right; font-size: 12px; }
.diff-row.a-more .diff-delta { color: var(--diff-a, #d97757); }
.diff-row.b-more .diff-delta { color: var(--diff-b, #4eb085); }
.diff-row.tied .diff-delta { color: var(--muted); }

.diff-legend {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 14px;
  align-items: center;
}
.diff-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 4px;
}
.diff-swatch.a { background: var(--diff-a, #d97757); }
.diff-swatch.b { background: var(--diff-b, #4eb085); }

/* Cumulative-difference rows reuse the per-outcome diff layout — same
   diverging-bar track, same per-side colour treatment — but the right
   column carries an absolute pair (P(A ≥ x) / P(B ≥ x)) instead of a
   signed delta. The pair is wider than the delta because cumulative
   readouts are hard to back out of a delta alone, and the legend
   wording differs ("more likely to clear ≥x"). The value column also
   widens slightly to host the ≥ glyph + multi-digit cutoff. */
.cum-diff-rows .diff-row {
  grid-template-columns: 44px 1fr 110px;
}
.cum-diff-pair {
  text-align: right;
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.cum-diff-pa { color: var(--diff-a, #d97757); }
.cum-diff-pb { color: var(--diff-b, #4eb085); }
.cum-diff-sep { color: var(--muted); }

.diff-empty {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 24px 0;
}

/* Overlay view — one bar per outcome with a shared neutral base and a
   red/green tip showing who's dominant at that value. Reads as the
   "real" curve (max(A, B)) overlaid with the dominant-side highlight,
   so the shape of the distribution is preserved. */

.overlay-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 14px 16px;
}

.overlay-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.overlay-row {
  display: grid;
  grid-template-columns: 32px 1fr 110px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.overlay-value { color: var(--muted); text-align: right; }

.overlay-track {
  position: relative;
  display: flex;
  height: 14px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
}
.overlay-shared {
  height: 100%;
  /* Mix of A's red and B's green — visually says "both sides contribute
     to this base". `color-mix` is widely supported (Safari 16.2+,
     Chrome 111+, Firefox 113+); fallback below for ancient browsers. */
  background: #93936e;  /* fallback: arithmetic average of the two */
  background: color-mix(in srgb, var(--diff-a, #d97757), var(--diff-b, #4eb085));
}
.overlay-tip { height: 100%; }
.overlay-tip.tip-a { background: var(--diff-a, #d97757); }
.overlay-tip.tip-b { background: var(--diff-b, #4eb085); }
.overlay-tip.tip-tied { background: transparent; }

.overlay-percents {
  font-size: 11px;
  text-align: right;
  display: flex;
  justify-content: flex-end;
  gap: 3px;
}
.overlay-pct.a { color: var(--diff-a, #d97757); }
.overlay-pct.b { color: var(--diff-b, #4eb085); }
.overlay-pct-sep { color: var(--muted); }

.diff-swatch.shared {
  background: #93936e;
  background: color-mix(in srgb, var(--diff-a, #d97757), var(--diff-b, #4eb085));
}


/* ---------------------------------------------------------------------- */
/* "Roll" button + result modal — the in-game single-roll surface.        */
/* Designed mobile-first: full-screen takeover on small viewports, big    */
/* tap targets, dismissable via backdrop click or Escape.                 */
/* ---------------------------------------------------------------------- */

/* Outlined-tertiary style — accent-colored text on a subtle alpha-tinted
   background, with a clear border. Reads as "secondary action" so it
   doesn't fight with the inline distribution numbers, while still being
   a clear button affordance. White-on-bright-blue was abandoned for being
   visually loud on the dark theme. */
.strike-label .roll-btn {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.strike-label .roll-btn:hover {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}
.strike-label .roll-btn:active { transform: translateY(1px); }

.roll-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: roll-fade-in 0.15s ease-out;
}

.roll-modal {
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 24px 20px;
  min-width: 280px;
  max-width: min(420px, calc(100vw - 32px));
  position: relative;
  animation: roll-slide-up 0.2s ease-out;
}

.roll-modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
}
.roll-modal-close:hover { color: var(--text); }

.roll-modal-expr {
  text-align: center;
  color: var(--muted);
  margin: 0 0 8px;
  font-size: 14px;
}
.roll-modal-expr code {
  font-size: 16px;
  color: var(--text);
}

.roll-modal-total {
  font-size: 72px;
  font-weight: 700;
  text-align: center;
  margin: 4px 0 16px;
  color: var(--good);
  font-variant-numeric: tabular-nums;
  animation: roll-pop-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.roll-dice-list {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rolled-die {
  display: grid;
  grid-template-columns: minmax(60px, auto) 1fr auto;
  align-items: baseline;
  gap: 8px;
  padding: 6px 10px;
  background: var(--panel);
  border-radius: 6px;
  font-size: 14px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  animation: roll-die-in 0.25s ease-out backwards;
}
/* Stagger each die's reveal so they appear sequentially. Keeps the
   modal feeling like dice settling rather than a flat data dump. */
.rolled-die:nth-child(1) { animation-delay: 0.05s; }
.rolled-die:nth-child(2) { animation-delay: 0.1s; }
.rolled-die:nth-child(3) { animation-delay: 0.15s; }
.rolled-die:nth-child(4) { animation-delay: 0.2s; }
.rolled-die:nth-child(5) { animation-delay: 0.25s; }
.rolled-die:nth-child(n+6) { animation-delay: 0.3s; }

.rolled-die.discarded {
  opacity: 0.45;
  text-decoration: line-through;
}

.rolled-die-label { color: var(--muted); }
.rolled-die-rerolled { color: var(--muted); font-size: 12px; }
/* The `+` after an exploded die's value tells the reader "this rolled
   max and triggered the next row." Subtle but legible — same color as
   the die's label rather than as loud as the value. */
.rolled-die-explode-marker {
  color: var(--accent);
  font-weight: 600;
  margin-left: 1px;
}
.rolled-die-value {
  font-weight: 600;
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Primary action in the modal — bigger and slightly more saturated than
   the panel-header Roll button, but still tinted rather than full-fill
   white-on-blue to match the rest of the dark-theme palette. */
.roll-again {
  display: block;
  width: 100%;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
  border-radius: 8px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.roll-again:hover {
  background: color-mix(in srgb, var(--accent) 32%, transparent);
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
}
.roll-again:active { transform: translateY(1px); }

@keyframes roll-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes roll-slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes roll-pop-in {
  0% { opacity: 0; transform: scale(0.4); }
  60% { opacity: 1; transform: scale(1.15); }
  100% { transform: scale(1); }
}
@keyframes roll-die-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mobile: full-screen takeover. Anything narrower than ~480px gets the
   bottom-sheet style — the modal pinned to the bottom edge so the
   "Roll again" button is in the natural thumb zone. */
@media (max-width: 480px) {
  .roll-modal-backdrop { align-items: flex-end; }
  .roll-modal {
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: none;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    animation: roll-bottom-sheet-in 0.25s ease-out;
  }
  .roll-modal-total { font-size: 64px; }
}
@keyframes roll-bottom-sheet-in {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* ---------------------------------------------------------------------- */
/* Pillar pages — concept articles and game-cluster pages.                */
/* Classes intentionally scoped via .concept / .game / .concept-index     */
/* ancestor so they don't leak into the LiveView surfaces.                */
/* ---------------------------------------------------------------------- */

.concept h1, .game h1 {
  line-height: 1.25;
  max-width: 32ch;
  font-size: 32px;
}
.concept h2, .game h2 {
  font-size: 16px;
  margin: 32px 0 8px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.game h3 {
  font-size: 14px;
  margin: 20px 0 6px;
  color: var(--text);
  font-weight: 600;
}
.concept p, .concept ul,
.game p, .game ul {
  max-width: 65ch;
  line-height: 1.6;
}
.concept ul, .game ul { padding-left: 20px; }
.concept ul li, .game ul li { margin-bottom: 8px; }

.concept .links, .game .links {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
}

/* The static panel embed inside a pillar uses tighter padding than the
   LiveView panel chrome — the pillar already sets context with prose. */
.strike.static { padding: 16px; }

.concept .grid.one-up,
.game .grid.one-up { grid-template-columns: 1fr; }

.concept-footer, .game-footer {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--panel-border);
  color: var(--muted);
  font-size: 12px;
}

/* /concepts/ index — the directory of pillars. */
.concept-index h1 { font-size: 32px; }
.concept-index .tagline { max-width: 65ch; }
.pillars {
  list-style: none;
  padding: 0;
  margin: 32px 0;
  display: grid;
  gap: 16px;
}
.pillars li {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 16px 20px;
}
.pillars li a {
  font-size: 18px;
  font-weight: 600;
  text-decoration: none;
}
.pillars li p {
  margin: 6px 0 0;
  color: var(--muted);
  max-width: 65ch;
}

/* Reliability tables — used in concept pillars to show per-AC or per-HP
   breakdowns. Tabular-numeric figures keep the columns aligned. */
.reliability-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 13px;
}
.reliability-table th,
.reliability-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--panel-border);
  text-align: left;
}
.reliability-table th {
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.06em;
}
.reliability-table strong { color: var(--good); }

/* BG3 weapons table — denser than the reliability table, right-aligned
   numerics for at-a-glance damage comparison. */
.weapons {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 13px;
}
.weapons th, .weapons td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--panel-border);
  text-align: left;
}
.weapons th {
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.06em;
}
.weapons .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Embedded LiveView widgets inside concept pillars. */
.pillar-widget {
  margin: 16px 0 24px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}
.pillar-widget .hp-label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}
.pillar-widget .hp-label strong {
  color: var(--text);
  min-width: 24px;
  display: inline-block;
  text-align: center;
}
.pillar-widget input[type="range"] { flex: 1; }
/* Split-damage widget has three sliders; stack them tighter so the panel
   doesn't sprawl. Same .hp-label markup, just less vertical padding when
   inside this form variant. */
.split-damage-form { display: flex; flex-direction: column; gap: 6px; }
.split-damage-form .hp-label { margin-bottom: 0; }
.pillar-widget-callout {
  margin: 0 0 14px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  font-size: 13px;
  text-align: center;
}
.pillar-widget-callout:empty { display: none; }
.pillar-widget-intro {
  margin: 16px 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}
.pillar-widget .reliability-table .peak-row { background: rgba(127, 215, 165, 0.08); }
.pillar-widget .reliability-table .peak-row strong,
.pillar-widget .reliability-table .peak-row span { color: var(--good); }

/* Home-page preset gallery — one-click swap into the comparison widget. */
.presets {
  margin-top: 40px;
}
.presets h2 {
  font-size: 16px;
  margin: 0 0 4px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.presets-tagline {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  max-width: 65ch;
}
.preset-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.preset {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  text-align: left;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 12px 14px;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.1s ease;
}
.preset:hover { border-color: var(--accent); }
.preset.selected {
  border-color: var(--accent);
  background: rgba(124, 196, 255, 0.05);
}
.preset-label {
  font-weight: 600;
  font-size: 13px;
}
.preset-pair {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--muted);
}
.preset-hp { margin-left: 8px; }
.preset-lesson {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

/* Home-page "go deeper" card grid — cross-link to concept pillars,
   game clusters, and syntax docs. */
.cards {
  margin-top: 40px;
}
.cards h2 {
  font-size: 16px;
  margin: 0 0 12px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.card-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.card-grid li a {
  display: block;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 16px 18px;
  text-decoration: none;
  transition: border-color 0.1s ease;
}
.card-grid li a:hover { border-color: var(--accent); }
.card-grid li a strong {
  display: block;
  font-size: 16px;
  margin-bottom: 6px;
  color: var(--accent);
}
.card-grid li a span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* Compact "see the syntax docs" link tucked into the home page tagline. */
.syntax-help {
  margin-left: 8px;
  white-space: nowrap;
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

/* Syntax reference table — denser than the reliability tables, monospace
   first column for the grammar form. */
.syntax-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 13px;
}
.syntax-table th,
.syntax-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--panel-border);
  text-align: left;
  vertical-align: top;
}
.syntax-table th {
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.06em;
}
.syntax-table td:first-child,
.syntax-table td:last-child {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  white-space: nowrap;
}

/* Affiliate block at the foot of a pillar — disclosed sponsored links. */
.affiliate-block {
  margin-top: 32px;
  padding: 16px 18px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel);
}
.affiliate-block h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 6px;
  font-weight: 500;
}
.affiliate-block .disclosure {
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 12px;
  max-width: none;
  line-height: 1.5;
}
.affiliate-block ul { list-style: none; padding: 0; margin: 0; }
.affiliate-block li { margin: 6px 0; font-size: 13px; }
.affiliate-block .blurb { color: var(--muted); }
