.dicewrap {
  width: min(100%, 660px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px;
  border-radius: var(--r-lg);
  background: var(--panel);
}

/* ---------- result readout ---------- */

.result { text-align: center; margin-bottom: 6px; }
.result b {
  display: block;
  font-size: clamp(46px, 8vw, 82px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  transition: color .2s var(--ease);
}
.result span { display: block; margin-top: 8px; font-size: 13.5px; color: var(--faint); }
.result.win  b { color: var(--green); }
.result.win  span { color: var(--green); }
.result.lose b { color: var(--red); }
.result.lose span { color: var(--red); }

/* ---------- the track ---------- */

.track {
  position: relative;
  height: 14px;
  border-radius: 100px;
  background: var(--bg);
  margin: 34px 6px 0;
}
.track .fill { position: absolute; top: 0; bottom: 0; }
.track .fill.lose { left: 0;  background: var(--red);   border-radius: 100px 0 0 100px; }
.track .fill.win  { right: 0; background: var(--green); border-radius: 0 100px 100px 0; }

/* the draggable line */
.track .knob {
  position: absolute;
  top: 50%;
  width: 14px; height: 34px;
  margin-left: -7px;
  border-radius: 4px;
  background: #fff;
  transform: translateY(-50%);
  box-shadow: 0 2px 6px rgba(0,0,0,.5);
  pointer-events: none;
  transition: left .06s linear;
}

/* where the roll landed */
.track .marker {
  position: absolute;
  top: -30px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  transition: left .5s var(--ease), opacity .2s var(--ease);
  pointer-events: none;
}
.track .marker.show { opacity: 1; }
.track .marker span {
  padding: 3px 8px;
  border-radius: 3px;
  background: var(--panel-3);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.track .marker i {
  order: 2;
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--panel-3);
}
.track .marker.win  span { background: var(--green); color: #04160B; }
.track .marker.win  i { border-top-color: var(--green); }
.track .marker.lose span { background: var(--red); color: #fff; }
.track .marker.lose i { border-top-color: var(--red); }

/* the real input sits invisibly over the track */
.track input[type=range] {
  position: absolute;
  inset: -10px 0;
  width: 100%;
  margin: 0;
  opacity: 0;
  cursor: grab;
  -webkit-appearance: none;
  appearance: none;
  background: none;
}
.track input[type=range]:active { cursor: grabbing; }
.track input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 34px; }
.track input[type=range]:focus-visible { outline: 2px solid var(--green); outline-offset: 4px; }

.scale {
  display: flex;
  justify-content: space-between;
  padding: 0 4px;
  font-size: 11.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.target-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--panel-2);
}
.target-row b { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- over / under toggle ---------- */

.seg { display: flex; gap: 3px; padding: 3px; border-radius: var(--r-sm); background: var(--panel-2); }
.seg button {
  flex: 1;
  padding: 9px 0;
  border-radius: 3px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  transition: background .14s var(--ease), color .14s var(--ease);
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--panel-3); color: var(--text); }

#roll { width: 100%; }
