.memory-page {
  max-width: 760px;
  margin-inline: auto;
  padding-block: 4px 38px;
}

.memory-intro {
  margin-bottom: 8px;
}

.memory-intro h1 {
  margin-bottom: 3px;
  font-size: clamp(32px, 8vw, 42px);
  letter-spacing: -2px;
  line-height: 1.1;
}

.memory-intro p,
.memory-how-to-play p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.memory-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
  box-shadow: 0 12px 30px #29234a0a;
}

.memory-metrics {
  width: min(100%, 380px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.memory-metric {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px;
  border: 1px solid #ece7ff;
  border-radius: 10px;
  background: #f7f5ff;
  color: var(--ink);
  font-size: 13px;
}

.memory-metric dt {
  color: var(--muted);
  font-weight: 600;
}

.memory-metric dd {
  margin: 0;
  color: var(--purple-dark);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.memory-board {
  width: min(100%, 42svh, 380px);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 7px;
  border: 1px solid #ece7ff;
  border-radius: 14px;
  background: #f4f0ff;
}

.memory-card {
  min-width: 0;
  min-height: 44px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #e6e1f4;
  border-radius: 10px;
  background: white;
  color: var(--purple-dark);
  cursor: pointer;
  font-family: "Manrope", sans-serif;
  font-size: clamp(22px, 8vw, 36px);
  font-weight: 800;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.memory-card.is-hidden {
  background: #e9e3ff;
  color: var(--purple);
}

.memory-card.is-matched {
  border-color: #bdeedb;
  background: #edfaf4;
  color: #398b68;
}

.memory-card:focus-visible,
.restart-button:focus-visible {
  outline: 3px solid #a391ff;
  outline-offset: 2px;
}

.memory-card:disabled {
  cursor: default;
}

.memory-status {
  width: min(100%, 380px);
  min-height: 21px;
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}

.restart-button {
  min-width: 160px;
  min-height: 44px;
  border: 0;
  cursor: pointer;
  font: inherit;
}

.memory-how-to-play {
  margin-top: 20px;
}

.memory-how-to-play h2 {
  margin-bottom: 6px;
  font-size: 20px;
  letter-spacing: -0.5px;
}

.related-games {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.related-games a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--purple-dark);
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (min-width: 600px) {
  .memory-page {
    padding-block: 8px 48px;
  }

  .memory-panel {
    gap: 9px;
    padding: 12px;
  }

  .memory-board {
    gap: 8px;
    padding: 9px;
    border-radius: 16px;
  }

  .memory-card {
    border-radius: 12px;
  }
}

@media (max-height: 700px) {
  .memory-page {
    padding-top: 2px;
  }

  .memory-intro {
    margin-bottom: 5px;
  }

  .memory-panel {
    gap: 5px;
    padding: 6px;
  }

  .memory-board {
    width: min(100%, 38svh, 300px);
    gap: 5px;
    padding: 6px;
  }

  .memory-card {
    min-height: 40px;
    border-radius: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .memory-card {
    transition: none;
  }
}
