:root {
  --bg: #FFF8F3;
  --primary: #FF6B9D;
  --primary-light: #FF8FB3;
  --primary-dark: #E85585;
  --accent: #FFD93D;
  --secondary: #5EC9F2;
  --success: #6BCB77;
  --card: #FFFFFF;
  --text: #2D3142;
  --text-light: #6C7293;
  --border: #F0E6DD;
  --board-bg: #FFE8DD;
  --shadow: 0 8px 24px rgba(45, 49, 66, 0.12);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#game-container {
  position: relative;
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 64px 12px 12px;
}

#ui-overlay {
  position: absolute;
  top: 12px; left: 12px; right: 12px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 6px;
  z-index: 5;
}
.ui-row { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.ui-pill {
  background: rgba(255,255,255,0.92);
  padding: 5px 11px;
  border-radius: 999px;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(45,49,66,0.08);
  font-size: 0.82rem;
  white-space: nowrap;
}
.ui-label { font-weight: 600; color: var(--text-light); margin-right: 4px; font-size: 0.74rem; }

#pause-btn, #mute-btn {
  background: rgba(255,255,255,0.92);
  border: 0;
  width: 38px; height: 38px;
  border-radius: 50%;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(45,49,66,0.08);
}

#board {
  width: 100%;
  max-width: 360px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
  aspect-ratio: 1 / 1;
  background: var(--board-bg);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.card {
  width: 100%;
  aspect-ratio: 1 / 1;
  perspective: 800px;
  cursor: pointer;
}
.card__inner {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.36s cubic-bezier(.34,1.2,.64,1);
}
.card.flipped .card__inner { transform: rotateY(180deg); }
.card.matched .card__inner { transform: rotateY(180deg); }
.card.matched .card__face--front {
  background: linear-gradient(135deg, #B7EFC1, #6BCB77);
  box-shadow: 0 4px 12px rgba(107, 203, 119, 0.35);
}

.card__face {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  font-weight: 800;
  user-select: none;
}
.card__face--back {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 10px rgba(255, 107, 157, 0.35);
}
.card__face--back::after {
  content: '?';
  font-size: 1.6rem;
  opacity: 0.85;
}
.card__face--front {
  background: var(--card);
  color: var(--text);
  transform: rotateY(180deg);
  box-shadow: 0 4px 10px rgba(45,49,66,0.1);
}
.card__symbol {
  width: 60%;
  height: 60%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* SVG-style symbol colors via classes */
.sym {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  position: absolute; inset: 0;
  background: rgba(45, 49, 66, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 10; padding: 20px;
}
.modal.hidden { display: none; }
.modal__inner {
  background: var(--card);
  border-radius: 24px;
  padding: 28px 24px;
  text-align: center;
  max-width: 320px; width: 100%;
  box-shadow: var(--shadow);
}
.modal__inner h2 { margin: 0 0 8px; font-size: 1.6rem; }
.modal__inner p { margin: 0 0 16px; color: var(--text-light); }
.big-score { font-size: 1.4rem !important; color: var(--text) !important; font-weight: 800; margin: 4px 0 !important; }
.sub-score { font-size: 0.95rem; }

.btn {
  background: var(--primary); color: #fff;
  border: 0;
  padding: 12px 28px;
  border-radius: 999px;
  font-size: 1rem; font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(255,107,157,0.4);
  font-family: inherit;
}
.btn:hover { background: var(--primary-dark); }

.ad-slot {
  margin-top: 16px;
  min-height: 100px;
}
