/* ============================================
   Tablo — Memory Match Game Styles
   GAME-SPECIFIC STYLES ONLY
   ============================================ */

/* ===== GAME WRAPPER ===== */
/* No overflow override — let central CSS handle it */
/* Just add centering for game content */
.game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px 20px;
  gap: 24px;
}

/* Small spacer from header */
.game-wrapper::before {
  content: '';
  display: block;
  height: 12px;
  flex-shrink: 0;
}

/* ===== GAME STATS ===== */
.game-stats {
  flex-shrink: 0;
  display: flex;
  gap: 24px;
  padding: 16px 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  max-width: 500px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 80px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  font-family: 'Nunito', monospace;
}

/* ===== MEMORY GAME BOARD ===== */
.memory-game {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  max-width: 500px;
  width: 100%;
  perspective: 1000px;
}

@media (max-width: 600px) {
  .memory-game {
    gap: 8px;
  }
}

.memory-card {
  aspect-ratio: 1;
  position: relative;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
  border-radius: var(--radius-md);
}

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

.memory-card.matched {
  transform: rotateY(180deg);
  animation: pulse-match 0.6s ease;
}

@keyframes pulse-match {
  0%, 100% { transform: rotateY(180deg) scale(1); }
  50% { transform: rotateY(180deg) scale(1.05); }
}

.card-front,
.card-back {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-color);
}

.card-front {
  background: var(--bg-secondary);
  transform: rotateY(180deg);
  font-size: clamp(28px, 8vw, 48px);
}

.card-back {
  background: var(--accent);
  border-color: var(--accent);
}

.card-back svg {
  width: 32px;
  height: 32px;
}

.memory-card:hover .card-back {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.3);
}

/* ===== GAME CONTROLS ===== */
.game-controls {
  flex-shrink: 0;
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  z-index: 10;
  position: relative;
}

.game-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.game-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
}

.game-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1a2e;
}

.game-btn.primary:hover {
  background: var(--accent);
  filter: brightness(1.1);
}

/* ===== CONGRATS MODAL ===== */
.congrats-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
}

.congrats-modal.open {
  display: flex;
}

.congrats-content {
  position: relative;
  z-index: 1;
  background: var(--bg-secondary);
  border: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.5);
}

.congrats-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.congrats-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 24px;
}

.congrats-stats {
  margin-bottom: 24px;
}

.congrats-stat-row {
  display: flex;
  gap: 24px;
  justify-content: center;
}

.congrats-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.congrats-stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.congrats-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'Nunito', monospace;
}

/* ===== TOAST ===== */
.tablo-toast {
  pointer-events: none;
  z-index: 9999;
}

/* ===== RESPONSIVE ===== */

@media (min-width: 1200px) {
  .memory-game {
    max-width: 480px;
  }
}

@media (min-width: 768px) and (max-width: 1199px) {
  .memory-game {
    max-width: 440px;
  }
}

@media (max-width: 767px) {
  .game-wrapper {
    padding: 0 12px 16px;
    gap: 20px;
  }

  .game-stats {
    gap: 16px;
    padding: 12px 16px;
  }

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

  .memory-game {
    max-width: 400px;
  }

  .game-controls {
    flex-direction: column;
    width: 100%;
  }

  .game-btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 479px) {
  .game-wrapper {
    padding: 0 12px 12px;
    gap: 16px;
  }

  .stat-item {
    min-width: 60px;
  }

  .stat-label {
    font-size: 10px;
  }

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

  .congrats-stat-row {
    flex-direction: column;
    gap: 16px;
  }

  #best-score {
    font-size: 14px;
    white-space: nowrap;
  }
}