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

body {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a0a2e 0%, #2d1b4e 50%, #1a2a4e 100%);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  overflow-x: hidden;
}

#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 16px;
}

#header {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  margin-bottom: 20px;
  width: 100%;
  max-width: 600px;
}

.stat {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 8px 20px;
  text-align: center;
  flex: 1;
}

.stat-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #ff8bbd;
  text-transform: uppercase;
}

.stat-value {
  display: block;
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 10px rgba(255, 139, 189, 0.4);
}

#board {
  display: grid;
  gap: 8px;
  justify-content: center;
  padding: 10px;
  max-width: 100%;
  --card-size: 72px;
}

.card {
  width: var(--card-size);
  height: var(--card-size);
  perspective: 600px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.4s ease;
  transform-style: preserve-3d;
}

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

.card-front, .card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-back {
  background: linear-gradient(135deg, #ff6bcb, #c44dff);
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 15px rgba(255, 107, 203, 0.3);
}

.card-back::after {
  content: '?';
  font-size: calc(var(--card-size) * 0.4);
  font-weight: 800;
  color: rgba(255, 255, 255, 0.6);
}

.card-front {
  background: linear-gradient(135deg, #fff8fc, #ffe8f4);
  border: 2px solid #ffb6d9;
  transform: rotateY(180deg);
  font-size: calc(var(--card-size) * 0.5);
  box-shadow: 0 4px 15px rgba(255, 182, 217, 0.3);
}

.card.matched .card-front {
  background: linear-gradient(135deg, #e8ffe8, #c8ffc8);
  border-color: #7dff7d;
  box-shadow: 0 4px 20px rgba(125, 255, 125, 0.4);
  animation: matchPop 0.4s ease;
}

.card.matched {
  cursor: default;
}

@keyframes matchPop {
  0% { transform: rotateY(180deg) scale(1); }
  50% { transform: rotateY(180deg) scale(1.15); }
  100% { transform: rotateY(180deg) scale(1); }
}

.card:not(.flipped):not(.matched):hover .card-back {
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 6px 25px rgba(255, 107, 203, 0.5);
}

.card:not(.flipped):not(.matched):active .card-inner {
  transform: scale(0.95);
}

.screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 10, 46, 0.92);
  backdrop-filter: blur(10px);
  z-index: 100;
}

.screen-content {
  text-align: center;
  color: #fff;
  padding: 40px 30px;
  max-width: 400px;
}

.screen-content h1 {
  font-size: 42px;
  font-weight: 800;
  background: linear-gradient(135deg, #ff6bcb, #ffb347, #87ceeb, #98fb98);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}

.screen-content .icon {
  font-size: 72px;
  margin: 16px 0;
  animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.screen-content p {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 6px;
}

.screen-content .sub {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 24px;
}

button {
  background: linear-gradient(135deg, #ff6bcb, #ff8ed4);
  color: #fff;
  border: none;
  padding: 14px 44px;
  font-size: 18px;
  font-weight: 700;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 2px;
  box-shadow: 0 8px 30px rgba(255, 107, 203, 0.4);
  margin-top: 8px;
}

button:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(255, 107, 203, 0.6);
}

button:active {
  transform: translateY(0);
}

.sound-btn {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 22px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: none;
  text-transform: none;
  letter-spacing: 0;
  margin-top: 0;
  line-height: 1;
}

.sound-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 107, 203, 0.3);
}

.sound-btn:active {
  transform: translateY(0);
}

#level-msg {
  font-size: 20px;
  font-weight: 700;
  color: #ffb347;
}

#next-info, #final-stats {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.65);
}

@media (max-width: 600px) {
  #header {
    gap: 12px;
  }

  .stat {
    padding: 6px 12px;
  }

  .stat-value {
    font-size: 22px;
  }

  .sound-btn {
    font-size: 18px;
    padding: 6px 10px;
  }

  .screen-content h1 {
    font-size: 32px;
  }

  .screen-content .icon {
    font-size: 56px;
  }

  button {
    padding: 12px 36px;
    font-size: 16px;
  }
}
