* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  padding: 30px 16px;
  font-family: Arial, Helvetica, sans-serif;
  color: #ffffff;
  background:
    radial-gradient(circle at top, #283f7d, #080d1b 58%);
}

button,
a {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.game-container {
  width: min(820px, 100%);
  margin: auto;
}

.back-button {
  display: inline-block;
  margin-bottom: 18px;
  color: #bdc9f6;
}

.back-button:hover {
  color: #ffffff;
}

.game-panel {
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(12px);
}

.game-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.small-heading {
  margin-bottom: 6px;
  color: #67efff;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1.8px;
}

.game-heading h1 {
  font-size: clamp(2rem, 7vw, 3.4rem);
}

.icon-button {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  font-size: 1.25rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.stats div {
  padding: 14px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  text-align: center;
}

.stats span {
  display: block;
  margin-bottom: 5px;
  color: #bdc9ef;
  font-size: 0.85rem;
}

.stats strong {
  font-size: 1.3rem;
}

.status {
  margin-bottom: 18px;
  color: #ccd5f7;
  text-align: center;
}

.game-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  max-width: 620px;
  margin: auto;
  perspective: 1000px;
}

.memory-card {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 16px;
  background: transparent;
  transform-style: preserve-3d;
  transition: transform 0.45s ease;
}

.memory-card.flipped,
.memory-card.matched {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;

  display: grid;
  place-items: center;

  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 16px;

  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.card-front {
  color: #07101d;
  background: linear-gradient(135deg, #5deeff, #82ffad);
  font-size: clamp(1.5rem, 6vw, 2.6rem);
  font-weight: bold;
}

.card-back {
  background:
    linear-gradient(145deg, #243b77, #101a37);
  box-shadow:
    inset 0 0 20px rgba(255, 255, 255, 0.05),
    0 9px 22px rgba(0, 0, 0, 0.22);

  transform: rotateY(180deg);
  font-size: clamp(1.8rem, 7vw, 3rem);
}

.memory-card:hover:not(.flipped):not(.matched) {
  transform: translateY(-5px);
}

.memory-card.matched {
  animation: matchedPulse 0.55s ease;
}

.restart-button,
.modal-card button {
  display: block;
  padding: 13px 22px;
  border-radius: 12px;
  color: #06101c;
  background: linear-gradient(135deg, #5deeff, #82ffad);
  font-weight: bold;
}

.restart-button {
  margin: 22px auto 0;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;

  display: grid;
  place-items: center;

  padding: 20px;
  background: rgba(3, 7, 16, 0.82);
  backdrop-filter: blur(8px);
}

.modal-card {
  width: min(420px, 100%);
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 22px;

  background:
    radial-gradient(circle at top, #263f7b, #10172c);

  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.trophy {
  margin-bottom: 12px;
  font-size: 4rem;
}

.modal-card h2 {
  margin-bottom: 10px;
  font-size: 2.2rem;
}

.modal-card p {
  margin-bottom: 22px;
  color: #c8d2f4;
  line-height: 1.6;
}

.modal-card button {
  width: 100%;
  margin-bottom: 14px;
}

.modal-card a {
  color: #77efff;
}

.hidden {
  display: none;
}

@keyframes matchedPulse {
  50% {
    transform: rotateY(180deg) scale(1.08);
  }
}

@media (max-width: 650px) {
  .game-panel {
    padding: 20px;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .game-board {
    gap: 9px;
  }

  .card-face {
    border-radius: 12px;
  }
}