:root {
  --navy: #092f4f;
  --navy-soft: #174e69;
  --cyan: #09aec2;
  --pink: #ff165d;
  --yellow: #ffb000;
  --paper: #fffaf4;
  --card: #ffffff;
  --ink: #0b2c3f;
  --muted: #637783;
  --line: #c9d9dc;
  --shadow: 0 12px 30px rgb(9 47 79 / 14%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }

body {
  min-width: 280px;
  margin: 0;
  background:
    linear-gradient(125deg, transparent 72%, rgb(255 176 0 / 12%) 72% 84%, rgb(9 174 194 / 10%) 84%),
    var(--paper);
}

button { font: inherit; }

.hero {
  color: #fff;
  background: var(--navy);
  border-bottom: .45rem solid var(--pink);
}

.hero__inner,
.page,
footer p {
  width: min(1180px, calc(100% - 2rem));
  margin-inline: auto;
}

.hero__inner { padding: clamp(2rem, 6vw, 4.5rem) 0; }
.hero h1 { margin: .15rem 0 .5rem; font-size: clamp(2.4rem, 8vw, 5.8rem); line-height: .95; letter-spacing: -.055em; }
.eyebrow { margin: 0; color: var(--yellow); font-size: .82rem; font-weight: 900; letter-spacing: .2em; text-transform: uppercase; }
.intro { margin: 1rem 0 0; font-size: clamp(1rem, 2vw, 1.35rem); color: #d8ecf1; }

.page { padding: clamp(1.2rem, 4vw, 3rem) 0 4rem; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.stats { display: flex; gap: .55rem; flex-wrap: wrap; }
.stats p { min-width: 6.7rem; margin: 0; padding: .7rem 1rem; background: #fff; border: 1px solid var(--line); box-shadow: 4px 4px 0 rgb(9 174 194 / 18%); }
.stats span { display: block; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.stats strong { display: block; margin-top: .1rem; font-size: 1.35rem; }
.stats strong span { display: inline; color: inherit; font-size: inherit; letter-spacing: inherit; }
.actions { display: flex; gap: .65rem; }
.button { min-height: 2.9rem; padding: .7rem 1.1rem; border: 2px solid var(--navy); cursor: pointer; font-weight: 850; }
.button--primary { color: #fff; background: var(--navy); box-shadow: 5px 5px 0 var(--cyan); }
.button--quiet { color: var(--navy); background: #fff; }
.button:hover { transform: translateY(-1px); }
.button:focus-visible, .memory-card:focus-visible, summary:focus-visible, .replay:focus-visible { outline: 4px solid var(--yellow); outline-offset: 3px; }
.instructions { max-width: 52rem; margin: 1.6rem 0; color: var(--muted); font-size: 1.05rem; }

.game {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(9.5rem, 42vw), 1fr));
  gap: clamp(.55rem, 1.7vw, 1rem);
}

.memory-card {
  position: relative;
  min-height: clamp(12rem, 22vw, 17rem);
  padding: 0;
  border: 0;
  border-radius: .2rem;
  background: transparent;
  cursor: pointer;
  perspective: 900px;
  -webkit-tap-highlight-color: transparent;
}

.memory-card__inner {
  position: absolute;
  inset: 0;
  transition: transform .42s ease;
  transform-style: preserve-3d;
}

.memory-card[aria-pressed="true"] .memory-card__inner,
.memory-card.is-matched .memory-card__inner { transform: rotateY(180deg); }

.memory-card__face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 2px solid var(--navy);
  border-radius: .2rem;
  box-shadow: var(--shadow);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.memory-card__back {
  background:
    linear-gradient(135deg, transparent 48%, rgb(255 255 255 / 10%) 48% 52%, transparent 52%),
    var(--navy);
  background-size: 18px 18px;
  color: #fff;
}
.memory-card__back::before { content: "♪"; font-size: clamp(3rem, 8vw, 5.4rem); color: var(--yellow); }
.memory-card__back::after { content: "PERCUSSION"; position: absolute; bottom: 1rem; font-size: .62rem; font-weight: 900; letter-spacing: .16em; }
.memory-card__front { transform: rotateY(180deg); background: var(--card); }
.memory-card__front img { width: 100%; height: 100%; object-fit: contain; background: #edf3f2; }
.memory-card__front--audio { align-content: center; gap: .75rem; padding: 1rem; background: linear-gradient(145deg, #fff 55%, #dff6f6); }
.audio-symbol { display: grid; place-items: center; width: 5rem; height: 5rem; border-radius: 50%; color: #fff; background: var(--pink); font-size: 2.2rem; box-shadow: 7px 7px 0 var(--yellow); }
.audio-label { font-weight: 900; }
.replay { position: relative; z-index: 3; padding: .55rem .75rem; border: 2px solid var(--navy); color: var(--navy); background: #fff; cursor: pointer; font-weight: 800; }
.memory-card.is-matched .memory-card__face { border-color: var(--cyan); box-shadow: 0 0 0 4px rgb(9 174 194 / 22%); }
.memory-card.is-matched::after { content: "✓"; position: absolute; z-index: 4; top: .55rem; right: .55rem; display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; color: #fff; background: var(--cyan); font-weight: 900; }

.success { margin-top: 2rem; padding: clamp(1.3rem, 4vw, 2.4rem); background: #fff; border: 2px solid var(--cyan); box-shadow: 9px 9px 0 rgb(9 174 194 / 20%); }
.success h2 { margin: .35rem 0; font-size: clamp(1.8rem, 5vw, 3rem); }
.success .eyebrow { color: var(--pink); }
.help { margin-top: 2.5rem; padding: 1rem; border-top: 2px solid var(--navy); background: rgb(255 255 255 / 65%); }
.help summary { cursor: pointer; font-size: 1.1rem; font-weight: 900; }
.help__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 1rem; margin-top: 1.2rem; }
.help-card { padding: .7rem; background: #fff; border: 1px solid var(--line); }
.help-card img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: contain; background: #edf3f2; }
.help-card audio { width: 100%; margin-top: .6rem; }
footer { padding: 1rem 0; color: #dcecf0; background: var(--navy); font-size: .82rem; }

@media (max-width: 560px) {
  .hero__inner, .page, footer p { width: min(100% - 1rem, 1180px); }
  .toolbar, .actions { align-items: stretch; }
  .actions { width: 100%; }
  .actions .button { flex: 1; }
  .stats { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; }
  .stats p { min-width: 0; padding: .6rem; }
  .game { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .memory-card { min-height: 9.5rem; }
  .memory-card__back::after { display: none; }
  .audio-symbol { width: 3.8rem; height: 3.8rem; font-size: 1.65rem; }
  .audio-label { font-size: .78rem; }
  .replay { padding: .4rem; font-size: .72rem; }
}

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

@media (forced-colors: active) {
  .memory-card__face, .button, .replay { border: 2px solid ButtonText; }
}
