* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  background: linear-gradient(160deg, #eef4ff 0%, #f7f9ff 45%, #ffffff 100%);
  color: #17233a;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem 0.9rem 2rem;
}

.card {
  background: #ffffff;
  border: 1px solid #dfe8ff;
  border-radius: 1rem;
  box-shadow: 0 10px 30px rgba(35, 65, 137, 0.12);
  padding: 1rem;
}

h1 {
  margin: 0 0 0.55rem;
  font-size: 1.55rem;
}

p {
  margin: 0 0 1rem;
  color: #33456c;
  line-height: 1.45;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1.1rem;
}

label {
  font-size: 0.95rem;
  font-weight: 600;
}

select,
button {
  font-size: 1rem;
  padding: 0.7rem 0.8rem;
  border-radius: 0.7rem;
}

select {
  width: 100%;
  border: 1px solid #b9c9f8;
  background: #f8faff;
  color: #17233a;
}

button {
  width: 100%;
  border: none;
  background: linear-gradient(135deg, #2b59ff 0%, #4c7bff 100%);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

button:hover,
button:focus-visible {
  filter: brightness(0.96);
  box-shadow: 0 8px 16px rgba(40, 82, 210, 0.3);
}

button:active {
  transform: translateY(1px);
}

.dice-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.8rem;
}

.dice {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  grid-template-areas:
    "tl . tr"
    "ml mc mr"
    "bl . br";
  height: 80px;
  padding: 10px;
  border-radius: 0.7rem;
  background: linear-gradient(160deg, #ffffff 0%, #eff4ff 100%);
  box-shadow: 0 4px 10px rgba(23, 35, 58, 0.12);
  position: relative;
}

.dice--unrolled {
  background: linear-gradient(160deg, #f4f7ff 0%, #e8eeff 100%);
}

.dice-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 700;
  color: rgba(23, 35, 58, 0.18);
  line-height: 1;
}

.pip {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #17233a;
  justify-self: center;
  align-self: center;
}

.pip-tl { grid-area: tl; }
.pip-tr { grid-area: tr; }
.pip-ml { grid-area: ml; }
.pip-mc { grid-area: mc; }
.pip-mr { grid-area: mr; }
.pip-bl { grid-area: bl; }
.pip-br { grid-area: br; }

.back-link-wrap {
  margin-top: 1.1rem;
  margin-bottom: 0;
}

.button-link {
  display: inline-block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  font-weight: 600;
  padding: 0.68rem 0.8rem;
  border-radius: 0.7rem;
  background: #e8eeff;
  color: #233f87;
  border: 1px solid #c9d7ff;
}

.button-link:hover,
.button-link:focus-visible {
  background: #dbe6ff;
}

@media (min-width: 720px) {
  .container {
    padding-top: 2rem;
  }

  .card {
    padding: 1.5rem;
  }

  .controls {
    display: grid;
    grid-template-columns: 1fr 180px 1fr 1fr;
    align-items: end;
  }

  label {
    grid-column: 1 / -1;
  }

  .button-link {
    width: auto;
    min-width: 220px;
  }
}
