:root {
  --dice-blue: #155ee8;
  --dice-fill: #a9cdf7;
  --dice-fill-selected: #6596d0;
  --dice-axis: #111;
}

.dice-main {
  width: 100%;
  min-height: calc(100vh - 110px);
  display: grid;
  place-items: center;
  padding: clamp(.35rem, 1.4vw, 1.25rem) 0;
  overflow: hidden;
}

.dice-chart-wrap {
  width: 100%;
  max-width: none;
  display: grid;
  grid-template-rows: auto auto auto;
  justify-items: stretch;
  align-items: center;
  overflow: hidden;
  position: relative;
}

.dice-chart {
  display: block;
  width: 100%;
  max-width: none;
  height: auto;

  overflow: visible;
  user-select: none;
  touch-action: none;
}

.dice-bars {
  fill: var(--dice-fill);
  stroke: var(--dice-blue);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  shape-rendering: geometricPrecision;
}

.dice-bars-selected {
  fill: var(--dice-fill-selected);
  stroke: var(--dice-blue);
  pointer-events: none;
}

.dice-selection {
  visibility: hidden;
  fill: none;
  stroke: #155ee8;
  stroke-width: 1.4;
  stroke-dasharray: 7 6;
  stroke-linecap: butt;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.dice-selection.visible {
  visibility: visible !important;
}

.dice-axis {
  stroke: var(--dice-axis);
  stroke-width: 2.2;
  vector-effect: non-scaling-stroke;
}

.dice-tick {
  stroke: var(--dice-axis);
  stroke-width: 1.8;
  vector-effect: non-scaling-stroke;
}

.dice-tick-label {
  fill: #111;
  font: 23px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
}


.dice-hit-area {
  fill: transparent;
  cursor: crosshair;
}

.dice-hit-area:focus-visible {
  outline: none;
}


.dice-stats {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: baseline;
  gap: clamp(.8rem, 2.4vw, 2.6rem);
  padding: 0 clamp(2rem, 5.5vw, 6rem);
  margin-bottom: -.28em;
  transform: translateY(2.25em);
  color: var(--dice-blue);
  user-select: none;
}

.dice-stat {
  min-width: 0;
  font: 650 clamp(1.15rem, 2.05vw, 1.8rem)/1.1 system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dice-stat-mu {
  text-align: left;
  transform: translateY(-.82rem);
}

.dice-stat-sigma {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: .02rem;
  text-align: right;
  transform: translateY(1.22rem);
}

.dice-sigma-formula {
  width: clamp(10.5rem, 18vw, 15rem);
  height: auto;
  flex: 0 0 auto;
  overflow: visible;
}

.dice-sigma-formula .formula-text,
.dice-sigma-formula .formula-number {
  fill: currentColor;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-weight: 650;
}

.dice-sigma-formula .formula-text {
  font-size: 32px;
}

.dice-sigma-formula .formula-number {
  font-size: 31px;
}

.dice-sigma-formula .formula-stroke {
  stroke: currentColor;
  stroke-width: 2.6;
  fill: none;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.dice-sigma-approx {
  flex: 0 0 6.1ch;
  width: 6.1ch;
  margin-left: -.02rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  text-align: left;
}


.dice-count {
  display: block;
  transform: translateY(.08rem);
  min-height: 1.1em;
  color: var(--dice-blue);
  font: 800 clamp(2.2rem, 4.6vw, 4.8rem)/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.035em;
  text-align: center;
  white-space: nowrap;
}

.dice-count.is-editing::after {
  content: "";
  display: inline-block;
  width: 0;
  height: .82em;
  margin-left: .08em;
  border-left: .045em solid currentColor;
  vertical-align: -.06em;
  animation: dice-caret-blink .9s steps(1, end) infinite;
}

@keyframes dice-caret-blink {
  0%, 52% { opacity: 1; }
  53%, 100% { opacity: 0; }
}

.dice-percentage {
  display: block;
  min-height: 1.1em;
  margin-top: -3.15em;
  visibility: hidden;
  color: var(--dice-blue);
  font: 800 clamp(2.2rem, 4.6vw, 4.8rem)/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.035em;
  text-align: center;
  user-select: none;
}

.dice-percentage.visible {
  visibility: visible;
}

@media (max-width: 700px) {
  .dice-main {
    min-height: calc(100vh - 80px);
    padding: .15rem .15rem .5rem;
  }

  .dice-tick-label {
    font-size: 28px;
  }

  .dice-stats {
    grid-template-columns: 1fr auto 1fr;
    gap: .5rem;
    padding: 0 .8rem;
    transform: translateY(1.95em);
  }

  .dice-stat {
    font-size: clamp(.8rem, 2.9vw, 1.08rem);
  }

  .dice-stat-mu {
    transform: translateY(-.52rem);
  }

  .dice-stat-sigma {
    gap: .02rem;
    transform: translateY(.82rem);
  }

  .dice-sigma-formula {
    width: clamp(7.2rem, 27vw, 10rem);
  }

  .dice-sigma-formula .formula-text {
    font-size: 34px;
  }

  .dice-sigma-formula .formula-number {
    font-size: 33px;
  }

  .dice-count {
    transform: translateY(.05rem);
    font-size: clamp(2rem, 9vw, 3.4rem);
  }

  .dice-percentage {
    font-size: clamp(2.2rem, 10vw, 3.8rem);
  }
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

.bar {
  flex: 0 0 auto;
}

.dice-main {
  flex: 1 1 auto;
  min-height: 0;
}

/* Houd de complete dobbelsteengrafiek binnen de werkelijk beschikbare
   hoogte onder de blauwe balk. Dit is dezelfde aanpak als bij de
   Normale verdeling: de statistiekregel en kansregel houden hun eigen
   hoogte; alleen de grafiek gebruikt de resterende ruimte. */
.dice-chart-wrap {
  height: 100%;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.dice-chart {
  min-height: 0;
  height: 100%;
  width: 100%;
}


.dice-probability-tooltip {
  position: absolute;
  z-index: 8;
  display: none;
  min-width: 7.2rem;
  padding: .38rem .55rem;
  border-radius: .45rem;
  background: rgba(20, 25, 32, .92);
  color: #fff;
  font: 600 .95rem/1.2 system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 3px 12px rgba(0, 0, 0, .18);
}

.dice-probability-tooltip.visible {
  display: block;
}

.dice-main {
  position: relative;
}

/* Help bij de interactieve grafiek: los van de menubalk. */
.chart-help {
  position: absolute;
  top: .55rem;
  right: .75rem;
  z-index: 20;
  margin: 0;
}

.chart-help summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(30, 45, 77, .30);
  background: rgba(255, 255, 255, .94);
  color: var(--blue);
  font: 800 1.65rem/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  box-shadow: 0 2px 8px rgba(16, 33, 68, .10);
  user-select: none;
}

.chart-help summary::-webkit-details-marker {
  display: none;
}

.chart-help summary::marker {
  content: "";
}

.chart-help summary:hover,
.chart-help[open] summary {
  background: #fff;
}

.chart-help summary:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.chart-help-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(390px, calc(100vw - 24px));
  max-height: calc(100dvh - 8rem);
  overflow-y: auto;
  padding: 14px 16px 15px;
  border: 1.5px solid var(--blue);
  border-radius: 12px;
  background: #fff;
  color: var(--blue);
  box-shadow: 0 12px 30px rgba(16, 33, 68, .18);
  z-index: 30;
}

.chart-help-panel h2 {
  margin: 0 0 9px;
  font-size: 1.12rem;
}

.chart-help-panel dl {
  margin: 0;
}

.chart-help-panel dl > div {
  display: grid;
  grid-template-columns: minmax(7.3rem, auto) 1fr;
  gap: .7rem;
  padding: .32rem 0;
  border-top: 1px solid #dfe3ea;
}

.chart-help-panel dl > div:first-child {
  border-top: 0;
}

.chart-help-panel dt {
  font-weight: 800;
  white-space: nowrap;
}

.chart-help-panel dd {
  margin: 0;
}

.chart-help-panel p {
  margin: .7rem 0 0;
  padding-top: .65rem;
  border-top: 1px solid #dfe3ea;
}

@media (max-width: 560px) {
  .chart-help {
    top: .35rem;
    right: .4rem;
  }

  .chart-help-panel {
    width: min(360px, calc(100vw - 16px));
    padding: 12px 14px;
  }

  .chart-help-panel dl > div {
    grid-template-columns: 1fr;
    gap: .05rem;
  }
}
