:root {
  --page-background: #ffffff;
  --ink: #171717;
  --muted-ink: #606773;
  --control-border: #aeb4bc;
  --group-border: #202020;
  --button-color: #0863a3;
  --button-hover: #064f82;
}

* {
  box-sizing: border-box;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

html {
  min-width: 320px;
  background: var(--page-background);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--page-background);
  font-family: Arial, Helvetica, sans-serif;
}

button,
select {
  font: inherit;
}

.dice-page {
  min-height: 100vh;
  padding: clamp(48px, 7vw, 96px) 24px;
}

.dice-panel {
  display: flex;
  width: min(100%, 1180px);
  margin-inline: auto;
  flex-direction: column;
  align-items: center;
}

.eyebrow,
.intro {
  display: none;
}

h1 {
  margin: 0;
  font-size: clamp(2.25rem, 5vw, 3.25rem);
  letter-spacing: -0.035em;
  line-height: 1.05;
  text-align: center;
}

.dice-groups {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(320px, 0.95fr);
  width: 100%;
  gap: 36px;
  align-items: start;
  margin-top: clamp(48px, 7vw, 76px);
}

.dice-group {
  display: grid;
  min-width: 0;
  padding: clamp(28px, 4vw, 48px);
  border: 2px solid var(--group-border);
  justify-items: center;
}

.dice-group-title {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.35rem);
  font-weight: 400;
  letter-spacing: -0.025em;
  text-align: center;
}

.dice-stage {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  width: 100%;
  gap: 40px 28px;
  align-items: start;
  margin: 40px 0;
}

.die-container {
  display: grid;
  min-width: 0;
  gap: 18px;
  justify-items: center;
}

.maneuver-control {
  display: grid;
  width: 100%;
  gap: 12px;
  text-align: left;
}

.maneuver-control h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0;
}

.rating-field,
.operator-field {
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 700;
}

.rating-field {
  display: grid;
  gap: 6px;
}

.rating-field select {
  width: 100%;
  min-height: 44px;
  padding: 8px 36px 8px 12px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--control-border);
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
}

.rating-field select:focus-visible,
.segmented-control input:focus-visible + span,
.roll-button:focus-visible {
  outline: 3px solid rgb(8 99 163 / 35%);
  outline-offset: 3px;
}

.operator-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.operator-field legend {
  margin-bottom: 6px;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
  width: 100%;
  border: 1px solid var(--ink);
  border-radius: 5px;
}

.segmented-control label {
  position: relative;
  display: grid;
}

.segmented-control label + label {
  border-left: 1px solid var(--ink);
}

.segmented-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.segmented-control span {
  display: grid;
  min-height: 42px;
  place-items: center;
  color: var(--ink);
  background: #ffffff;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 800;
}

.segmented-control input:checked + span {
  color: #ffffff;
  background: #172033;
}

.die {
  position: relative;
  display: grid;
  width: clamp(100px, 10vw, 124px);
  aspect-ratio: 1;
  place-items: center;
  color: var(--die-symbol-color, #ffffff);
  background: #111111;
  clip-path: polygon(50% 0%, 97% 35%, 79% 100%, 21% 100%, 3% 35%);
}

.die::before {
  position: absolute;
  z-index: 0;
  inset: 3px;
  background: var(--die-color);
  clip-path: polygon(50% 0%, 97% 35%, 79% 100%, 21% 100%, 3% 35%);
  content: '';
}

.die.is-rolling {
  animation: dice-roll var(--roll-duration, 600ms) ease-in-out 1;
}

@keyframes dice-roll {
  0%,
  100% {
    transform: translate(0, 0) rotate(0deg);
  }

  30% {
    transform: translate(-2px, -1px) rotate(-2deg);
  }

  70% {
    transform: translate(2px, -2px) rotate(2deg);
  }
}

.die-face {
  position: relative;
  z-index: 1;
  display: flex;
  min-width: 1em;
  align-items: center;
  justify-content: center;
  gap: 0.06em;
  font-size: clamp(1.35rem, 2.6vw, 1.85rem);
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1;
}

.die-symbol {
  position: relative;
  display: inline-block;
}

.die-circle {
  display: inline-grid;
  width: 0.76em;
  height: 0.76em;
  overflow: hidden;
  place-items: center;
  background: transparent;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.die-circle.is-filling {
  overflow: hidden;
}

.die-circle.is-filling::after {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 500px;
  height: 0;
  transform: translateX(-50%);
  background: currentColor;
  content: '';
  animation: circle-gas-fill var(--fill-duration, 220ms) ease-in
    var(--fill-delay, 0ms) both;
}

@keyframes circle-gas-fill {
  100% {
    height: 100%;
  }
}

.die-glyph {
  position: relative;
  z-index: 2;
}

.result {
  color: var(--muted-ink);
  font-size: 0.95rem;
}

.die-log-section {
  width: 100%;
  text-align: left;
}

.die-log {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 13px;
  color: var(--muted-ink);
  background: #f3f4f6;
  border-radius: 7px;
  font-size: 0.8rem;
  line-height: 1.4;
}

.die-log-line {
  margin: 0;
}

.die-log-result {
  margin-top: 4px;
  padding-top: 8px;
  color: var(--ink);
  border-top: 1px solid rgb(23 23 23 / 14%);
  font-size: 0.9rem;
}

.roll-button {
  min-width: 170px;
  padding: 12px 20px;
  color: #ffffff;
  background: var(--button-color);
  border: 0;
  border-radius: 0;
  cursor: pointer;
  font-weight: 400;
}

.roll-button:hover {
  background: var(--button-hover);
}

.roll-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.general-actions {
  display: flex;
  width: 100%;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 32px;
}

.general-action-button {
  min-height: 44px;
  padding: 11px 18px;
  color: var(--button-color);
  background: #ffffff;
  border: 1px solid var(--button-color);
  cursor: pointer;
  font-weight: 700;
}

.general-action-button:hover {
  color: #ffffff;
  background: var(--button-color);
}

.general-action-button:focus-visible {
  outline: 3px solid rgb(8 99 163 / 35%);
  outline-offset: 3px;
}

.general-actions-status {
  width: 100%;
  min-height: 1.4em;
  margin: 2px 0 0;
  color: var(--muted-ink);
  font-size: 0.85rem;
  text-align: center;
}

.general-actions-status.is-error {
  color: #a51d1d;
}

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

  .dice-group[data-dice-count='1'] {
    width: min(100%, 440px);
  }
}

@media (max-width: 720px) {
  .dice-page {
    padding: 32px 18px;
  }

  h1 {
    font-size: clamp(2rem, 8vw, 2.25rem);
  }

  .dice-groups {
    gap: 56px;
    margin-top: 36px;
  }

  .dice-group,
  .dice-group[data-dice-count='1'] {
    width: 100%;
    padding: 0;
    border: 0;
  }

  .dice-stage {
    grid-template-columns: minmax(0, 340px);
    justify-content: center;
    gap: 40px;
    margin: 32px 0;
  }

  .die {
    width: 104px;
  }

  .general-actions {
    display: grid;
    grid-template-columns: minmax(0, 340px);
  }

  .general-actions-status {
    max-width: 340px;
  }
}
