:root {
  color-scheme: light;
  --paper: #f4f0e8;
  --ink: #20231f;
  --muted: #77796f;
  --line: #d8d4c9;
  --red: #d34d35;
  --teal: #317d73;
  --lime: #d9e65b;
  --white: #fffdf7;
  font-family: "Avenir Next", Avenir, "Trebuchet MS", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(#bcb8ab 0.7px, transparent 0.7px);
  background-size: 18px 18px;
}

button {
  color: inherit;
  font: inherit;
}

.game-shell {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  padding: 0 clamp(20px, 5vw, 76px);
}

.topbar,
.footer-note {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.wordmark-mark {
  display: grid;
  width: 26px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: var(--red);
  color: var(--white);
  font-family: Georgia, serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
}

.wordmark-divider {
  padding: 0 5px;
  color: var(--red);
}

.topbar-note,
.footer-note {
  color: var(--muted);
}

.game {
  width: min(100%, 900px);
  margin: auto;
  padding: 52px 0 44px;
}

.game-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
}

.eyebrow,
.stat-label,
.answer-head,
.answer-hint,
.progress-caption {
  margin: 0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--teal);
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(32px, 6vw, 54px);
  font-weight: 500;
  line-height: 1;
}

.run-stats {
  display: flex;
  gap: 30px;
}

.stat {
  display: grid;
  gap: 5px;
  min-width: 54px;
}

.stat-label {
  color: var(--muted);
}

.stat-value {
  font-variant-numeric: tabular-nums;
  font-size: 21px;
  font-weight: 800;
}

.stat-value span {
  color: var(--muted);
  font-size: 13px;
}

.stat-time .stat-value {
  color: var(--red);
}

.play-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 30px;
}

.dice-board {
  display: grid;
  width: min(100%, 440px);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(10px, 2vw, 18px);
  justify-self: center;
}

.die {
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid #cbc6b9;
  border-radius: 4px;
  background: var(--white);
  box-shadow: 0 5px 0 #d7d2c6;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(52px, 10vw, 90px);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.die.is-rolling {
  animation: die-rattle 160ms ease-in-out infinite alternate;
}

@keyframes die-rattle {
  from {
    transform: rotate(-2deg) translateY(1px);
  }

  to {
    transform: rotate(2deg) translateY(-2px);
  }
}

.die:nth-child(2) {
  background: var(--lime);
}

.die:nth-child(3) {
  background: #e8a58e;
}

.die:nth-child(4) {
  background: #a8d2c9;
}

.answer-panel {
  display: flex;
  width: min(100%, 360px);
  flex-direction: column;
  align-items: stretch;
  justify-self: center;
}

.answer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 18px;
}

.answer-hint {
  color: var(--muted);
  font-size: 8px;
}

.answer-display {
  display: flex;
  height: 54px;
  align-items: center;
  justify-content: center;
  margin: 8px 0 12px;
  border-bottom: 2px solid var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.key {
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgb(255 253 247 / 75%);
  cursor: pointer;
  font-size: 17px;
  font-weight: 700;
  transition: background-color 120ms ease, transform 120ms ease;
}

.key:hover {
  transform: translateY(-1px);
  background: white;
}

.key:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.key:disabled:hover {
  transform: none;
}

.key-utility {
  color: var(--muted);
}

.key-submit {
  border-color: var(--teal);
  background: var(--teal);
  color: white;
  font-size: 23px;
}

.start-button {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding: 0 16px;
  border: 0;
  border-radius: 3px;
  background: var(--ink);
  color: white;
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.start-button span {
  font-size: 20px;
}

.feedback {
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.feedback.is-wrong {
  color: var(--red);
}

.feedback.is-success {
  color: var(--teal);
  font-weight: 800;
}

.feedback.is-timeout {
  color: var(--red);
  font-weight: 800;
}

.progress-track {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 34px;
}

.progress-segment {
  width: 42px;
  height: 4px;
  background: var(--line);
}

.progress-segment.is-current {
  background: var(--red);
}

.progress-caption {
  margin-left: auto;
  color: var(--muted);
  font-size: 8px;
}

.footer-note {
  min-height: 52px;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  font-size: 8px;
}

[hidden] {
  display: none !important;
}

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

@media (max-width: 700px) {
  .game-shell {
    padding: 0 20px;
  }

  .topbar {
    min-height: 60px;
  }

  .topbar-note {
    display: none;
  }

  .game {
    width: min(100%, 460px);
    padding: 30px 0 26px;
  }

  .game-heading {
    align-items: start;
    margin-bottom: 20px;
  }

  .run-stats {
    gap: 16px;
  }

  .stat {
    min-width: 42px;
  }

  .stat-value {
    font-size: 17px;
  }

  .play-area {
    grid-template-columns: minmax(0, 1fr);
    gap: 26px;
  }

  .dice-board {
    width: min(100%, 360px);
    gap: 12px;
  }

  .die {
    font-size: clamp(60px, 18vw, 84px);
  }

  .answer-panel {
    width: min(100%, 360px);
    justify-self: center;
  }

  .key {
    min-height: 44px;
  }

  .progress-track {
    margin-top: 24px;
  }
}

@media (max-width: 390px) {
  .game-shell {
    padding: 0 15px;
  }

  .game-heading {
    gap: 12px;
  }

  .eyebrow {
    font-size: 8px;
  }

  h1 {
    font-size: 31px;
  }

  .run-stats {
    gap: 10px;
  }
}
