* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  background: #0a0e27;
  color: #e0e0e0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

.back-link {
  align-self: flex-start;
  color: #94a3b8;
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 16px;
}
.back-link:hover {
  color: #ff8fab;
}

.game-wrap {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #ff6b9d 0%, #ffd93d 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hud {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-bottom: 16px;
}

.stat {
  flex: 1;
  background: #1a1f3a;
  border: 1px solid #2d3548;
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.stat .label {
  font-size: 11px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat span:last-child {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}

.board-wrap {
  position: relative;
  width: 100%;
  max-width: 400px;
}

.board {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
}

.card {
  perspective: 600px;
  cursor: pointer;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  backface-visibility: hidden;
  font-size: clamp(24px, 7vw, 36px);
}

.card-back {
  background: #1a1f3a;
  border: 1px solid #2d3548;
  color: #ff6b9d;
  font-weight: 700;
}

.card-front {
  background: linear-gradient(135deg, #ff6b9d 0%, #ffd93d 100%);
  transform: rotateY(180deg);
}

.card.matched .card-front {
  background: linear-gradient(135deg, #6bffb8 0%, #8bd3ff 100%);
}

.card.matched .card-inner {
  opacity: 0.85;
}

.reset-btn {
  margin-top: 20px;
  padding: 10px 22px;
  border: 1px solid #2d3548;
  background: #1a1f3a;
  color: #e0e0e0;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
}
.reset-btn:hover {
  border-color: #ff6b9d;
  color: #ff8fab;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  background: rgba(10, 14, 39, 0.92);
  border-radius: 16px;
  padding: 24px;
}

.overlay.hidden {
  display: none;
}

#overlay-title {
  font-size: 24px;
  font-weight: 700;
  color: #ffffff;
}

#overlay-message {
  font-size: 14px;
  color: #94a3b8;
  margin-bottom: 8px;
}

#overlay-btn {
  padding: 12px 28px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #ff6b9d 0%, #ff8fab 100%);
  color: #ffffff;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(255, 107, 157, 0.35);
}
