:root {
  color-scheme: light;
  --ink: #191715;
  --muted: #766f66;
  --paper: #fffaf1;
  --panel: #ffffff;
  --line: #ded4c6;
  --shadow: 0 24px 70px rgba(46, 38, 28, 0.18);
  --red: #d84735;
  --teal: #0f766e;
  --gold: #efb241;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(239, 178, 65, 0.24), transparent 42%),
    linear-gradient(315deg, rgba(15, 118, 110, 0.18), transparent 38%),
    var(--paper);
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 18px;
}

.roller-panel {
  width: min(100%, 460px);
  background: var(--panel);
  border: 1px solid rgba(25, 23, 21, 0.12);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(22px, 5vw, 34px);
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.kicker {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 6px rgba(239, 178, 65, 0.18);
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 3rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.intro {
  margin: 14px 0 26px;
  color: var(--muted);
  line-height: 1.55;
  max-width: 31rem;
}

.roll-stage {
  display: grid;
  grid-template-columns: minmax(128px, 168px) 1fr;
  align-items: stretch;
  gap: 18px;
  margin-bottom: 20px;
}

.die {
  aspect-ratio: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 0;
  padding: 18%;
  border-radius: 8px;
  background:
    linear-gradient(145deg, #ffffff, #f3eadc);
  border: 2px solid #221c18;
  box-shadow:
    inset 0 -8px 0 rgba(25, 23, 21, 0.08),
    0 16px 24px rgba(25, 23, 21, 0.14);
}

.die.is-rolling {
  animation: tumble 420ms cubic-bezier(0.22, 0.8, 0.28, 1);
}

.pip {
  width: 58%;
  aspect-ratio: 1;
  place-self: center;
  border-radius: 50%;
  background: var(--ink);
  opacity: 0;
  transform: scale(0.7);
  transition:
    opacity 120ms ease,
    transform 120ms ease;
}

.top-left {
  grid-column: 1;
  grid-row: 1;
}

.top-right {
  grid-column: 3;
  grid-row: 1;
}

.middle-left {
  grid-column: 1;
  grid-row: 2;
}

.center {
  grid-column: 2;
  grid-row: 2;
}

.middle-right {
  grid-column: 3;
  grid-row: 2;
}

.bottom-left {
  grid-column: 1;
  grid-row: 3;
}

.bottom-right {
  grid-column: 3;
  grid-row: 3;
}

.face-1 .center,
.face-2 .top-left,
.face-2 .bottom-right,
.face-3 .top-left,
.face-3 .center,
.face-3 .bottom-right,
.face-4 .top-left,
.face-4 .top-right,
.face-4 .bottom-left,
.face-4 .bottom-right,
.face-5 .top-left,
.face-5 .top-right,
.face-5 .center,
.face-5 .bottom-left,
.face-5 .bottom-right,
.face-6 .top-left,
.face-6 .top-right,
.face-6 .middle-left,
.face-6 .middle-right,
.face-6 .bottom-left,
.face-6 .bottom-right {
  opacity: 1;
  transform: scale(1);
}

.result-card {
  min-width: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbf6ec;
  padding: 16px 12px;
}

.result-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#resultValue {
  display: block;
  color: var(--red);
  font-size: clamp(4rem, 19vw, 6.6rem);
  line-height: 0.9;
  letter-spacing: 0;
  margin-top: 10px;
}

.roll-button {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: var(--ink);
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 12px 22px rgba(25, 23, 21, 0.22);
  transition:
    transform 120ms ease,
    background-color 120ms ease,
    box-shadow 120ms ease;
}

.roll-button:hover {
  background: #2e2923;
  transform: translateY(-1px);
  box-shadow: 0 15px 26px rgba(25, 23, 21, 0.24);
}

.roll-button:active {
  transform: translateY(1px);
  box-shadow: 0 8px 16px rgba(25, 23, 21, 0.18);
}

.roll-button:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.35);
  outline-offset: 3px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 20px 0;
}

.summary-grid div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 10px;
  background: #fffdf8;
  text-align: center;
}

.summary-grid span {
  display: block;
  font-size: 1.35rem;
  font-weight: 850;
  line-height: 1;
}

.summary-grid small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.history-block {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.history-block h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  letter-spacing: 0;
}

.history-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 37px;
  margin: 0;
  padding: 0;
}

.history-list li {
  display: inline-grid;
  place-items: center;
  width: 37px;
  height: 37px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #ffffff;
  font-weight: 850;
}

.history-list .empty {
  width: auto;
  min-width: 100%;
  justify-content: start;
  border-color: transparent;
  color: var(--muted);
  background: transparent;
  font-weight: 650;
}

@keyframes tumble {
  0% {
    transform: rotate(0deg) scale(1);
  }
  45% {
    transform: rotate(10deg) scale(0.94);
  }
  100% {
    transform: rotate(0deg) scale(1);
  }
}

@media (max-width: 430px) {
  .roll-stage {
    grid-template-columns: 1fr;
  }

  .die {
    width: min(100%, 210px);
    justify-self: center;
  }

  .result-card {
    min-height: 132px;
  }
}
