.game-match-three {
  --gem-rose: #e05272;
  --gem-orange: #e89030;
  --gem-gold: #e8cc38;
  --gem-green: #50b860;
  --gem-teal: #38a8a0;
  --gem-blue: #4888e0;

  min-height: 85vh;
  justify-content: center;
  margin: 0;
}

.game-match-three .game-wrapper {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.game-match-three .header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.game-match-three .header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-bright);
}

.game-match-three .stats {
  display: flex;
  gap: 12px;
}

.game-match-three .stat-box {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  text-align: center;
  min-width: 80px;
}

.game-match-three .stat-box .ui-label {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.game-match-three .stat-box .value {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-bright);
}

.game-match-three .stat-box .value.score-val { color: var(--gold); }
.game-match-three .stat-box .value.moves-val { color: var(--teal); }

.game-match-three .board-container {
  background: var(--board-bg);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,0.6);
  position: relative;
}

.game-match-three .board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 4px;
  width: 100%;
  aspect-ratio: 1;
  position: relative;
}

.game-match-three .cell {
  width: 100%;
  aspect-ratio: 1;
  position: relative;
}

.game-match-three .gem {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  position: absolute;
  top: 0; left: 0;
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
  will-change: transform, opacity;
}

.game-match-three .gem::before {
  content: '';
  position: absolute;
  top: 12%; left: 18%;
  width: 35%; height: 25%;
  background: radial-gradient(ellipse, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0) 70%);
  border-radius: 50%;
  pointer-events: none;
}

.game-match-three .gem::after {
  content: '';
  position: absolute;
  bottom: 8%; right: 15%;
  width: 20%; height: 15%;
  background: radial-gradient(ellipse, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 70%);
  border-radius: 50%;
  pointer-events: none;
}

.game-match-three .gem.rose   { background: radial-gradient(circle at 35% 35%, #f47a94, var(--gem-rose) 60%, #b83a56); box-shadow: 0 3px 10px rgba(224,82,114,0.4); }
.game-match-three .gem.orange { background: radial-gradient(circle at 35% 35%, #f5ae5e, var(--gem-orange) 60%, #b86a1a); box-shadow: 0 3px 10px rgba(232,144,48,0.4); }
.game-match-three .gem.gold   { background: radial-gradient(circle at 35% 35%, #f5e070, var(--gem-gold) 60%, #b8a020); box-shadow: 0 3px 10px rgba(232,204,56,0.4); }
.game-match-three .gem.green  { background: radial-gradient(circle at 35% 35%, #78d888, var(--gem-green) 60%, #388840); box-shadow: 0 3px 10px rgba(80,184,96,0.4); }
.game-match-three .gem.teal   { background: radial-gradient(circle at 35% 35%, #60d0c0, var(--gem-teal) 60%, #208078); box-shadow: 0 3px 10px rgba(56,168,160,0.4); }
.game-match-three .gem.blue   { background: radial-gradient(circle at 35% 35%, #70a8f0, var(--gem-blue) 60%, #3060b0); box-shadow: 0 3px 10px rgba(72,136,224,0.4); }

.game-match-three .gem.selected {
  transform: scale(1.12);
  box-shadow: 0 0 0 3px var(--text-bright), 0 4px 16px rgba(0,0,0,0.12);
  z-index: 2;
}

.game-match-three .gem.hint {
  animation: matchThreeHintPulse 0.6s ease-in-out infinite alternate;
}

@keyframes matchThreeHintPulse {
  from { transform: scale(1); }
  to { transform: scale(1.1); }
}

.game-match-three .gem.matched {
  animation: matchThreePop 0.3s ease forwards;
}

@keyframes matchThreePop {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.6; }
  100% { transform: scale(0); opacity: 0; }
}

.game-match-three .gem.falling {
  transition: top 0.25s ease-in;
}

.game-match-three .gem.swapping {
  transition: left 0.2s ease-in-out, top 0.2s ease-in-out;
  z-index: 3;
}

.game-match-three .chain-label {
  position: absolute;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--gold);
  pointer-events: none;
  z-index: 10;
  animation: matchThreeFloatUp 0.8s ease-out forwards;
  text-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

@keyframes matchThreeFloatUp {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-40px) scale(1.3); }
}

.game-match-three .message-bar {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-match-three .message-bar span {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--teal);
  opacity: 0;
  transition: opacity 0.3s;
}

.game-match-three .message-bar span.visible {
  opacity: 1;
}

/* Overlay game-specific tweaks */
.game-match-three .game-overlay-card h2 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 8px;
}

.game-match-three .game-overlay-card .final-score-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  color: var(--muted-light);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.game-match-three .game-overlay-card .final-score {
  font-family: 'Fredoka', sans-serif;
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 20px;
}

.game-match-three .start-overlay .game-overlay-card p {
  color: var(--text);
  font-size: 0.9rem;
  margin-bottom: 20px;
  line-height: 1.5;
}

@media (max-width: 500px) {
  .game-match-three .game-wrapper { max-width: 100%; }
  .game-match-three .header h1 { font-size: 1.2rem; }
  .game-match-three .stat-box { min-width: 64px; padding: 4px 10px; }
  .game-match-three .stat-box .value { font-size: 1.1rem; }
  .game-match-three .board-container { padding: 6px; }
  .game-match-three .board { gap: 3px; }
}
