@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;700;800&display=swap');

:root {
  --purple: #9b5de5;
  --pink: #ff6fa5;
  --blue: #4d96ff;
  --green: #35c46b;
  --yellow: #ffc93d;
  --ink: #2f2a4a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Baloo 2', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, #fff6e9, #e8f6ff 70%);
  background-attachment: fixed;
  padding-bottom: 40px;
}

header.game-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  color: #fff;
  border-radius: 0 0 24px 24px;
}

header.game-hero h1 {
  margin: 0;
  font-size: 1.3rem;
  flex: 1;
}

.back-link {
  text-decoration: none;
  color: #fff;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 8px 14px;
}

main {
  max-width: 520px;
  margin: 0 auto;
  padding: 18px 16px;
  text-align: center;
}

.game-stats {
  display: flex;
  justify-content: center;
  gap: 14px;
  font-weight: 700;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.game-stats span {
  background: #fff;
  border-radius: 999px;
  padding: 6px 14px;
  box-shadow: 0 4px 10px rgba(47, 42, 74, 0.08);
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 12px 24px;
  font-family: inherit;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--green), #21a05a);
  box-shadow: 0 6px 0 rgba(33, 160, 90, 0.35);
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 3px 0 rgba(33, 160, 90, 0.35);
}

/* Memory Match */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 0 auto;
}

.memory-card {
  aspect-ratio: 1;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.9rem;
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s;
  box-shadow: 0 4px 0 rgba(47, 42, 74, 0.15);
}

.memory-card.flipped,
.memory-card.matched {
  background: #fff;
  box-shadow: 0 4px 0 rgba(47, 42, 74, 0.08) inset;
}

.memory-card.matched {
  background: #e4faec;
  opacity: 0.85;
}

.win-banner {
  display: none;
  background: #fff;
  border-radius: 18px;
  padding: 20px;
  margin-top: 18px;
  box-shadow: 0 6px 18px rgba(47, 42, 74, 0.1);
}

.win-banner.show {
  display: block;
}

/* Bubble Pop */
.bubble-field {
  position: relative;
  width: 100%;
  height: 60vh;
  max-height: 480px;
  background: linear-gradient(180deg, #d5efff, #f4fbff);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(47, 42, 74, 0.1);
}

.bubble {
  position: absolute;
  bottom: -60px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.9), rgba(77, 150, 255, 0.55));
  border: 2px solid rgba(255, 255, 255, 0.8);
  cursor: pointer;
  animation-name: float-up;
  animation-timing-function: linear;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  user-select: none;
}

.bubble-bomb {
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.9), rgba(90, 90, 100, 0.65));
  border-color: rgba(255, 255, 255, 0.6);
}

.bubble-fast {
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.95), rgba(255, 201, 61, 0.65));
}

@keyframes float-up {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-70vh);
  }
}

.bubble-field.shake {
  animation: shake 0.3s;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-8px);
  }
  75% {
    transform: translateX(8px);
  }
}

.pop-text {
  position: absolute;
  font-weight: 800;
  color: var(--pink);
  animation: pop-fade 0.6s forwards;
  pointer-events: none;
}

.pop-text.bonus {
  color: #ffb703;
}

.pop-text.bad {
  color: #d43f3f;
}

@keyframes pop-fade {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-30px) scale(1.4);
  }
}
