/* Play page: color memory game. Loaded on /play/ only, after styles.css. */

.play {
  padding-top: clamp(2rem, 1rem + 3vw, 4rem);
  padding-bottom: var(--section);
}

.play-back {
  display: flex;
  justify-content: center;
  margin-bottom: 32px;
}

/* --- Game card ------------------------------------------------------------- */

.game {
  --target: var(--panel);
  --target-ink: var(--ink);
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: clamp(600px, 74vh, 800px);
  background: var(--panel);
}

.game[data-screen="memorize"] {
  background: var(--target);
  color: var(--target-ink);
}

.game-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
  padding: 16px 24px 0;
}

.game-round {
  font-variant-numeric: tabular-nums;
}

.game-bar-end {
  display: flex;
  gap: var(--btn-gap);
  margin-left: auto;
}

.game[data-screen="memorize"] .game-bar .pill {
  background: rgb(255 255 255 / 0.9);
  color: var(--ink);
}

.game-screen {
  display: grid;
  padding: 24px;
}

.game-note {
  font-size: var(--text-sm);
  line-height: 18px;
  color: var(--ink-muted);
}

.game-step {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: clamp(1.75rem, 1.2rem + 1.4vw, 2.5rem);
  line-height: 1.05;
  letter-spacing: var(--tracking-serif);
}

.game-noscript {
  padding: 24px;
  background: var(--panel);
  text-align: center;
}

/* --- Intro ----------------------------------------------------------------- */

.game-intro {
  justify-items: center;
  align-content: center;
  gap: 24px;
  text-align: center;
}

.game-intro .section-title {
  max-width: 12em;
}

.game-lede {
  max-width: 32rem;
}

.swatches {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}

.swatches li {
  width: 56px;
  height: 56px;
  background: var(--c);
}

.swatches li:nth-child(odd) {
  transform: rotate(-4deg);
}

.swatches li:nth-child(even) {
  transform: rotate(3deg);
}

.game-levels {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--btn-gap);
  margin: 8px 0 0;
  padding: 0;
  border: 0;
}

.game-levels legend {
  width: 100%;
  margin-bottom: 12px;
  padding: 0;
  font-size: var(--text-sm);
  line-height: 18px;
  color: var(--ink-muted);
}

.choice {
  position: relative;
  cursor: pointer;
}

.choice input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.choice span {
  display: inline-flex;
  align-items: center;
  min-height: var(--btn-h);
  padding: var(--btn-pad-y) var(--btn-pad-x);
  border-radius: var(--pill);
  font-size: var(--btn-text);
  line-height: 24px;
  box-shadow: inset 0 0 0 1px rgb(2 2 2 / 0.1);
  background: var(--bg);
  white-space: nowrap;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.choice input:checked + span {
  background: var(--ink);
  color: var(--bg);
}

.choice input:focus-visible + span {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.game-start {
  min-height: 72px;
  padding-inline: 36px;
  margin-top: 8px;
}

/* --- Countdown and memorize ------------------------------------------------ */

.game-countdown {
  place-items: center;
}

.game-word {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: clamp(4.5rem, 2rem + 9vw, 10rem);
  line-height: 1;
  letter-spacing: var(--tracking-serif);
}

.game-word.is-go {
  font-style: italic;
}

.game-memorize {
  align-content: start;
  justify-items: end;
}

.game-timer {
  display: grid;
  justify-items: end;
  font-size: clamp(4rem, 2.4rem + 7vw, 8.5rem);
  line-height: 1;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
}

.game-timer-label {
  margin-top: 8px;
  font-size: var(--text-sm);
  line-height: 18px;
  letter-spacing: var(--tracking-sans);
  opacity: 0.8;
}

/* --- Recreate -------------------------------------------------------------- */

.game-recreate,
.game-result {
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: 24px 48px;
}

.game-preview {
  min-height: 320px;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.06);
}

.game-mix {
  display: grid;
  align-content: center;
  gap: 20px;
  max-width: 30rem;
}

.game-mix .button {
  justify-self: start;
  margin-top: 4px;
}

.slider {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  align-items: baseline;
}

.slider label {
  font-weight: 500;
}

.slider output {
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.slider input {
  grid-column: 1 / -1;
  width: 100%;
  height: 44px;
  margin: 0;
  border-radius: var(--pill);
  background: var(--track, var(--line));
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  touch-action: none;
}

.slider input::-webkit-slider-thumb {
  width: 32px;
  height: 32px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.25);
  -webkit-appearance: none;
  appearance: none;
}

.slider input::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.25);
}

.slider input::-moz-range-track {
  background: transparent;
}

.slider input:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* --- Result ---------------------------------------------------------------- */

.game-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.game-pair figure {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.game-swatch {
  flex: 1;
  min-height: 280px;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.06);
}

.game-pair figcaption {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  font-size: var(--text-sm);
  line-height: 18px;
}

.game-pair figcaption span:first-child {
  font-weight: 500;
}

.game-pair figcaption span:last-child {
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.game-outcome {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 16px;
}

.game-score {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: clamp(4rem, 2rem + 6vw, 7.5rem);
  line-height: 0.95;
  letter-spacing: var(--tracking-serif);
  font-variant-numeric: tabular-nums lining-nums;
  white-space: nowrap;
}

.game-of {
  font-family: var(--font-sans);
  font-size: 0.3em;
  letter-spacing: var(--tracking-sans);
  color: var(--ink-muted);
}

.game-verdict {
  min-height: 24px;
}

.game-outcome .button {
  margin-top: 8px;
}

/* --- Final ----------------------------------------------------------------- */

.game-final {
  justify-items: center;
  align-content: center;
  gap: 16px;
  text-align: center;
}

.game-score-total {
  font-size: clamp(4.5rem, 2rem + 8vw, 9rem);
}

.game-recap {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 88px));
  gap: 12px;
  margin-top: 8px;
}

.game-recap li {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.recap-swatch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  aspect-ratio: 1;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.06);
}

.recap-score {
  font-size: var(--text-sm);
  line-height: 18px;
  font-variant-numeric: tabular-nums;
}

.game-final .actions {
  justify-content: center;
  margin-top: 8px;
}

/* --- Small screens --------------------------------------------------------- */

@media (max-width: 52rem) {
  .game {
    min-height: 560px;
  }

  .game-recreate,
  .game-result {
    grid-template-columns: 1fr;
    align-content: start;
  }

  .game-preview {
    min-height: 0;
    aspect-ratio: 16 / 9;
  }

  .game-swatch {
    flex: none;
    width: 100%;
    min-height: 0;
    aspect-ratio: 1;
  }

  .game-pair figcaption {
    display: grid;
  }

  .game-mix {
    max-width: none;
  }
}

@media (max-width: 36rem) {
  .game-bar {
    padding-inline: 16px;
  }

  .game-screen {
    padding: 16px;
  }

  .swatches li {
    width: 40px;
    height: 40px;
  }

  .game-recap {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: 100%;
  }
}
