* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #171944;
  color: #fff;
  font-family: Arial, "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  animation: fadeIn .6s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0
  }
}

header {
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
}

header img {
  display: block;
  height: 40px;
  border-radius: 8px;
}

.back {
  padding: 8px 18px;
  border: 2px solid #fff;
  border-radius: 999px;
  color: #fff;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  transition: background .3s, color .3s;
}

.back:hover {
  background: #fff;
  color: #171944;
}

h1 {
  margin: 10px 0 4px;
  font-size: 24px;
  font-weight: 900;
}

.stats {
  margin: 0 0 18px;
  font-size: 13px;
  opacity: .8;
  letter-spacing: .08em;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: min(92vw, 420px);
  padding-bottom: 30px;
}

.card {
  aspect-ratio: 3 / 4;
  perspective: 600px;
  cursor: pointer;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .45s cubic-bezier(.4, 1.4, .6, 1);
}

.card.open .card-inner,
.card.done .card-inner {
  transform: rotateY(180deg);
}

.face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  backface-visibility: hidden;
}

.face-back {
  background: #fff;
  color: #171944;
  font-weight: 900;
  font-size: 18px;
  border: 2px solid #171944;
  border-bottom-width: 5px;
}

.face-front {
  background: var(--c, #fff);
  transform: rotateY(180deg);
  font-size: clamp(28px, 8vw, 40px);
  border: 2px solid #171944;
}

.card.done {
  pointer-events: none;
  animation: matched .5s ease;
}

@keyframes matched {
  30% {
    transform: scale(1.12) rotate(3deg);
  }

  60% {
    transform: scale(.95) rotate(-2deg);
  }
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  place-items: center;
  background: rgba(23, 25, 68, .82);
}

.overlay.show {
  display: grid;
}

.panel {
  background: #fff;
  color: #171944;
  border-radius: 20px;
  padding: 40px 46px;
  text-align: center;
  animation: pop .5s cubic-bezier(.22, 1.5, .36, 1);
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(.6);
  }
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 30px;
}

.panel p {
  margin: 0 0 22px;
  font-size: 14px;
  color: #555;
}

.panel button {
  padding: 12px 30px;
  border: none;
  border-radius: 999px;
  background: #DA0710;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .1em;
  cursor: pointer;
}

.panel button:hover {
  opacity: .85;
}
