:root {
  color-scheme: dark;
  --night: #182233;
  --night-deep: #111a29;
  --slate: #3c4656;
  --white: #f6f7fa;
  --muted: #aeb8c8;
  --line: #344054;
  --yellow: #fff05a;
  --green: #41c46b;
  --red: #ee3e36;
  --digit-1: #d81b60;
  --digit-2: #0876c9;
  --digit-3: #00a9bd;
  --digit-4: #f58200;
  --digit-5: #38a64a;
  --digit-6: #9025a3;
  --digit-7: #d92f2f;
  --digit-8: #0a9fce;
  --digit-9: #ffc400;
  font-family: "Avenir Next", "Century Gothic", "Trebuchet MS", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  color: var(--white);
  background-color: var(--night);
  background-image: radial-gradient(#ffffff0a 0.7px, transparent 0.7px);
  background-size: 16px 16px;
}

button {
  color: inherit;
  font: inherit;
}

.game-shell {
  display: flex;
  width: min(100%, 560px);
  min-height: 100vh;
  min-height: 100svh;
  flex-direction: column;
  margin-inline: auto;
  padding: 0 20px 24px;
}

.topbar {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--white);
  text-decoration: none;
}

.wordmark-mark {
  display: grid;
  width: 26px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--night-deep);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  letter-spacing: 0;
}

.wordmark-divider {
  padding: 0 4px;
  color: var(--yellow);
}

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

.challenge {
  display: flex;
  width: 100%;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 24px;
  padding: 28px 0;
}

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

.timer-panel {
  display: grid;
  justify-items: center;
  gap: 4px;
}

.panel-label {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.timer {
  color: var(--white);
  font-size: 68px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.timer > span:last-child {
  margin-left: 4px;
  color: var(--muted);
  font-size: 24px;
}

.sequence-panel {
  width: 100%;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.sequence-count {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.sequence-strip {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sequence-digit {
  display: grid;
  min-width: 0;
  aspect-ratio: 0.88;
  place-items: center;
  border: 2px solid var(--night-deep);
  border-radius: 9px;
  background: var(--slate);
  color: var(--white);
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.sequence-digit.is-current {
  border-color: var(--yellow);
  background: var(--yellow);
  color: var(--night-deep);
}

.sequence-digit.is-complete {
  border-color: var(--green);
  background: var(--green);
  color: var(--night-deep);
}

body[data-phase="results"] .sequence-panel,
body[data-phase="results"] .keypad-panel {
  display: none;
}

.keypad-panel {
  width: 100%;
}

.keypad {
  display: grid;
  width: min(100%, 368px);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-inline: auto;
}

.key {
  position: relative;
  display: grid;
  min-width: 0;
  aspect-ratio: 1;
  place-items: center;
  border: 3px solid var(--night-deep);
  border-radius: 15px;
  background: var(--slate);
  box-shadow: 0 5px 0 var(--night-deep);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-size: 38px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  transition: transform 160ms cubic-bezier(0.2, 0.75, 0.25, 1), box-shadow 110ms ease-out;
}

.key:hover {
  filter: brightness(1.08);
  box-shadow: 0 7px 0 var(--night-deep);
}

.key:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--night-deep);
}

.key:focus-visible,
.play-again:focus-visible {
  outline: 3px solid var(--white);
  outline-offset: 3px;
}

.key[data-digit="1"] { background: var(--digit-1); }
.key[data-digit="2"] { background: var(--digit-2); }
.key[data-digit="3"] { background: var(--digit-3); color: var(--night-deep); }
.key[data-digit="4"] { background: var(--digit-4); color: var(--night-deep); }
.key[data-digit="5"] { background: var(--digit-5); color: var(--night-deep); }
.key[data-digit="6"] { background: var(--digit-6); }
.key[data-digit="7"] { background: var(--digit-7); }
.key[data-digit="8"] { background: var(--digit-8); color: var(--night-deep); }
.key[data-digit="9"] { background: var(--digit-9); color: var(--night-deep); }

.penalty-indicator {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  color: #ff655b;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 1px 3px var(--night-deep);
  animation: penalty-float 650ms ease-out forwards;
}

@keyframes penalty-float {
  from {
    opacity: 1;
    transform: translate(-50%, 0);
  }

  to {
    opacity: 0;
    transform: translate(-50%, -34px);
  }
}

.status {
  min-height: 16px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-align: center;
}

.status[hidden] {
  display: none;
}

.results {
  display: grid;
  width: 100%;
  justify-items: center;
  gap: 12px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--night-deep);
}

.results[hidden] {
  display: none;
}

.result-time {
  font-size: 38px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.play-again {
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 7px;
  background: var(--yellow);
  color: var(--night-deep);
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

@media (max-height: 760px) {
  .challenge {
    gap: 16px;
    padding-block: 20px;
  }

  .timer {
    font-size: 56px;
  }

  .keypad {
    width: min(100%, 320px);
    gap: 8px;
  }

  .key {
    border-radius: 12px;
    font-size: 32px;
  }
}

@media (max-width: 340px) {
  .topbar-note {
    display: none;
  }
}

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