.dice-game__viewport {
  height: auto;
  min-height: 620px;
  overflow: auto;
  background: #0e0f13;
}

/* The shared slot preview adds a dimming layer until an iframe is loaded.
   Dice is interactive immediately, so it must not inherit that overlay. */
.dice-game__viewport::after {
  content: none;
}

.dice-game__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  min-height: 430px;
}

.dice-game__stage {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 38%, rgba(242, 7, 74, 0.12), transparent 36%),
    #111217;
}

.dice-game__summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.dice-stat {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #32343b;
  border-radius: 5px;
  background: #191b21;
}

.dice-stat > span,
.dice-stat > strong {
  display: block;
}

.dice-stat > span {
  color: #9a9ba1;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dice-stat > strong {
  overflow: hidden;
  margin-top: 4px;
  color: #fff;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dice-game__result-zone {
  display: grid;
  flex: 1;
  min-height: 220px;
  place-items: center;
  padding: 18px 0;
}

.dice-game__result {
  position: relative;
  display: grid;
  width: 176px;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid #4b4e57;
  border-radius: 50%;
  background: linear-gradient(145deg, #232630, #111217);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

.dice-game__result::before {
  position: absolute;
  inset: 12px;
  border: 1px dashed #454852;
  border-radius: 50%;
  content: "";
}

.dice-game__result-value {
  position: relative;
  color: #fff;
  font-size: 52px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1;
}

.dice-game__result.is-win {
  border-color: #69c42d;
  box-shadow: 0 0 30px rgba(105, 196, 45, 0.22);
}

.dice-game__result.is-loss {
  border-color: var(--game-demo-accent);
  box-shadow: 0 0 30px rgba(242, 7, 74, 0.2);
}

.dice-game__result.is-rolling {
  animation: dice-roll 0.45s ease-in-out infinite alternate;
}

.dice-game__message {
  min-height: 22px;
  margin: 0 0 15px;
  color: #c9cad0;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.dice-game__message.is-win {
  color: #8cdb58;
}

.dice-game__message.is-loss {
  color: #ff738f;
}

.dice-game__track-wrap {
  padding-top: 5px;
}

.dice-game__track-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
  color: #8f9096;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.dice-game__track {
  position: relative;
  height: 11px;
  border-radius: 999px;
  background: linear-gradient(90deg, #69c42d 0 var(--marker, 50%), rgba(242, 7, 74, 0.72) var(--marker, 50%) 100%);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.45);
}

.dice-game__track[data-direction="over"] {
  background: linear-gradient(90deg, rgba(242, 7, 74, 0.72) 0 var(--marker, 50%), #69c42d var(--marker, 50%) 100%);
}

.dice-game__marker {
  position: absolute;
  top: 50%;
  left: var(--marker, 50%);
  width: 20px;
  height: 20px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #191b21;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  transform: translate(-50%, -50%);
}

.dice-game__roll-marker {
  position: absolute;
  top: -6px;
  left: var(--roll, 50%);
  width: 3px;
  height: 23px;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 0 8px #fff;
  opacity: 0;
  transform: translateX(-50%);
}

.dice-game__roll-marker.is-visible {
  opacity: 1;
}

.dice-game__controls {
  padding: 22px;
  border-left: 1px solid #32343b;
  background: #191b21;
}

.dice-control {
  margin: 0 0 17px;
  padding: 0;
  border: 0;
}

.dice-control__label,
.dice-control legend {
  display: block;
  width: 100%;
  margin-bottom: 7px;
  color: #f4f4f5;
  font-size: 12px;
  font-weight: 700;
}

.dice-control__input-wrap {
  display: flex;
  min-height: 42px;
  overflow: hidden;
  border: 1px solid #4a4c54;
  border-radius: 4px;
  background: #111217;
}

.dice-control__input-wrap:focus-within {
  border-color: var(--game-demo-accent-light);
  box-shadow: 0 0 0 2px rgba(242, 7, 74, 0.18);
}

.dice-control__input-wrap input[type="number"] {
  min-width: 0;
  flex: 1;
  padding: 0 12px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.dice-control__input-suffix {
  display: grid;
  padding: 0 12px;
  place-items: center;
  color: #9a9ba1;
  font-size: 10px;
  font-weight: 800;
}

.dice-control__quick {
  display: flex;
  gap: 5px;
  margin-top: 6px;
}

.dice-control__quick button {
  min-height: 29px;
  flex: 1;
  border: 1px solid #4a4c54;
  border-radius: 4px;
  background: #22242b;
  color: #d4d5d9;
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.dice-control__quick button:hover {
  border-color: var(--game-demo-accent-light);
  color: #fff;
}

.dice-control__range-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 9px;
  align-items: center;
}

.dice-control input[type="range"] {
  width: 100%;
  accent-color: var(--game-demo-accent);
  cursor: pointer;
}

.dice-control__chance-value {
  min-height: 38px;
  padding: 0 7px;
  border: 1px solid #4a4c54;
  border-radius: 4px;
  outline: 0;
  background: #111217;
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.dice-control__chance-value:focus {
  border-color: var(--game-demo-accent-light);
}

.dice-control__direction {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.dice-control__direction label {
  position: relative;
  display: grid;
  min-height: 39px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #4a4c54;
  border-radius: 4px;
  background: #22242b;
  color: #c7c8cd;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.dice-control__direction input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.dice-control__direction label:has(input:checked) {
  border-color: var(--game-demo-accent-light);
  background: rgba(242, 7, 74, 0.16);
  color: #fff;
}

.dice-control__direction label:has(input:focus-visible) {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.dice-game__calculation {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin: 2px 0 15px;
}

.dice-game__calculation div {
  padding: 9px 10px;
  border: 1px solid #3d3f47;
  border-radius: 4px;
  background: #111217;
}

.dice-game__calculation span,
.dice-game__calculation strong {
  display: block;
}

.dice-game__calculation span {
  color: #8f9096;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.dice-game__calculation strong {
  margin-top: 3px;
  color: #fff;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.dice-game__roll {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--game-demo-accent-light), var(--game-demo-accent) 55%, var(--game-demo-accent-dark));
  box-shadow: 0 8px 18px rgba(242, 7, 74, 0.25);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

.dice-game__roll:hover:not(:disabled) {
  filter: brightness(1.08);
}

.dice-game__roll:disabled {
  cursor: wait;
  opacity: 0.65;
}

.dice-game__hint {
  margin: 8px 0 0;
  color: #8f9096;
  font-size: 9px;
  line-height: 1.4;
  text-align: center;
}

.dice-game__history {
  padding: 18px 22px 22px;
  border-top: 1px solid #32343b;
  background: #111217;
}

.dice-game__history h3 {
  margin: 0 0 9px;
  color: #fff;
  font-size: 14px;
}

.dice-history__scroller {
  overflow-x: auto;
  border: 1px solid #32343b;
  border-radius: 4px;
}

.dice-history__table {
  width: 100%;
  min-width: 580px;
  border-collapse: collapse;
  color: #e7e7ea;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.dice-history__table th,
.dice-history__table td {
  padding: 8px 10px;
  border-bottom: 1px solid #30323a;
  text-align: left;
}

.dice-history__table th {
  color: #8f9096;
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.dice-history__table tr:last-child td {
  border-bottom: 0;
}

.dice-history__empty {
  color: #8f9096;
  text-align: center !important;
}

.dice-history__result--win {
  color: #8cdb58;
  font-weight: 700;
}

.dice-history__result--loss {
  color: #ff738f;
  font-weight: 700;
}

.dice-game__reset {
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid #666871;
  border-radius: 4px;
  background: #111217;
  color: #fff;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.dice-game__reset:hover {
  border-color: var(--game-demo-accent-light);
  color: var(--game-demo-accent-light);
}

.dice-game__reset:disabled {
  cursor: wait;
  opacity: 0.55;
}

.dice-game .game-demo__footer {
  justify-content: space-between;
}

.dice-game:fullscreen .dice-game__viewport {
  flex: 1 1 auto;
  overflow: auto;
}

.dice-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.dice-game :where(button, input):focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

@keyframes dice-roll {
  from { transform: rotate(-2deg) scale(0.98); }
  to { transform: rotate(2deg) scale(1.02); }
}

@media (max-width: 760px) {
  .dice-game__viewport {
    min-height: 0;
  }

  .dice-game__layout {
    grid-template-columns: 1fr;
  }

  .dice-game__stage {
    padding: 18px;
  }

  .dice-game__controls {
    padding: 18px;
    border-top: 1px solid #32343b;
    border-left: 0;
  }

  .dice-game__history {
    padding: 16px 18px 19px;
  }
}

@media (max-width: 480px) {
  .dice-game__summary {
    grid-template-columns: 1fr 1fr;
  }

  .dice-stat:first-child {
    grid-column: 1 / -1;
  }

  .dice-game__result-zone {
    min-height: 190px;
  }

  .dice-game__result {
    width: 150px;
  }

  .dice-game__result-value {
    font-size: 44px;
  }

  .dice-game__track-labels span:nth-child(even) {
    display: none;
  }

  .dice-game__calculation {
    grid-template-columns: 1fr;
  }

  .dice-game .game-demo__footer {
    gap: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dice-game *,
  .dice-game *::before,
  .dice-game *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
