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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.game-container {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  padding: 30px;
  max-width: 1200px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.game-header {
  text-align: center;
  margin-bottom: 30px;
}

.game-title {
  font-size: 2.5rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.title-icon {
  display: inline-block;
  animation: bounce 2s infinite;
}

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

.game-controls {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 20px;
}

.difficulty-selector,
.theme-selector {
  display: flex;
  align-items: center;
  gap: 15px;
}

.difficulty-selector label,
.theme-selector label {
  font-weight: bold;
  color: #333;
}

.difficulty-buttons,
.theme-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.difficulty-btn,
.theme-btn {
  padding: 8px 16px;
  border: 2px solid #667eea;
  background: white;
  color: #667eea;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
}

.difficulty-btn:hover,
.theme-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.difficulty-btn.active,
.theme-btn.active {
  background: #667eea;
  color: white;
}

.stats-bar {
  display: flex;
  justify-content: space-around;
  padding: 15px;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  border-radius: 15px;
  margin-bottom: 20px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-icon {
  font-size: 1.5rem;
}

.stat-label {
  color: #666;
  font-size: 0.9rem;
}

.stat-value {
  font-weight: bold;
  color: #667eea;
  font-size: 1.1rem;
}

.power-ups {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 20px;
}

.power-up-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 15px;
  background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
  border: none;
  border-radius: 15px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.power-up-btn:hover:not(.disabled) {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 10px 25px rgba(252, 182, 159, 0.4);
}

.power-up-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.power-icon {
  font-size: 2rem;
}

.power-name {
  font-size: 0.9rem;
  font-weight: bold;
  color: #333;
}

.power-count {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ff6b6b;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
}

.game-board {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
  min-height: 400px;
}

.grid {
  display: grid;
  gap: 10px;
  padding: 20px;
  background: white;
  border-radius: 15px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.grid.easy {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

.grid.medium {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
}

.grid.hard {
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(4, 1fr);
}

.grid.expert {
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
}

.card {
  width: 100px;
  height: 100px;
  position: relative;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.6s;
}

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

.card.matched {
  animation: matchPulse 0.6s ease;
}

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

.card.hint {
  animation: hintShake 0.5s ease;
}

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

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.card-front {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  transform: rotateY(0deg);
}

.card-back {
  background: white;
  transform: rotateY(180deg);
  font-size: 3rem;
}

.card-front::before {
  content: '?';
  font-size: 3rem;
  color: white;
  font-weight: bold;
}

.combo-indicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
  padding: 15px 30px;
  border-radius: 25px;
  font-size: 1.5rem;
  font-weight: bold;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.combo-indicator.show {
  opacity: 1;
  animation: comboPop 0.5s ease;
}

@keyframes comboPop {
  0% {
    transform: translate(-50%, -50%) scale(0);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.2);
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
  }
}

.game-controls-bottom {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.control-btn {
  padding: 12px 25px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.achievements-bar {
  background: linear-gradient(135deg, #e0f7fa 0%, #b2ebf2 100%);
  padding: 15px;
  border-radius: 15px;
}

.achievements-bar h3 {
  color: #333;
  margin-bottom: 10px;
}

.achievements-list {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 40px;
}

.achievement-item {
  background: white;
  padding: 8px 15px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: achievementSlide 0.5s ease;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

@keyframes achievementSlide {
  from {
    transform: translateX(-50px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.achievement-icon {
  font-size: 1.2rem;
}

.achievement-text {
  font-size: 0.9rem;
  color: #333;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 20px;
  max-width: 500px;
  width: 90%;
  text-align: center;
  animation: modalPop 0.3s ease;
  position: relative;
}

@keyframes modalPop {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.close-modal {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 2rem;
  cursor: pointer;
  color: #999;
  transition: color 0.3s ease;
}

.close-modal:hover {
  color: #333;
}

.modal-title {
  color: #667eea;
  margin-bottom: 20px;
  font-size: 2rem;
}

.modal-stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 20px;
}

.final-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.final-stat-label {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 5px;
}

.final-stat-value {
  font-size: 1.5rem;
  font-weight: bold;
  color: #667eea;
}

.star-rating {
  font-size: 2rem;
  margin-bottom: 20px;
}

.star {
  display: inline-block;
  color: #ffd700;
  animation: starPop 0.3s ease;
}

.star.empty {
  color: #ddd;
}

@keyframes starPop {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

.modal-buttons {
  display: flex;
  justify-content: center;
  gap: 15px;
}

.modal-btn {
  padding: 12px 25px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1rem;
}

.modal-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.leaderboard-tabs {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}

.tab-btn {
  padding: 8px 16px;
  border: 2px solid #667eea;
  background: white;
  color: #667eea;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.tab-btn.active {
  background: #667eea;
  color: white;
}

.leaderboard-list {
  text-align: left;
  max-height: 300px;
  overflow-y: auto;
}

.leaderboard-list li {
  padding: 10px;
  margin-bottom: 5px;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
}

.leaderboard-list li:nth-child(1) {
  background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
}

.leaderboard-list li:nth-child(2) {
  background: linear-gradient(135deg, #c0c0c0 0%, #e8e8e8 100%);
}

.leaderboard-list li:nth-child(3) {
  background: linear-gradient(135deg, #cd7f32 0%, #e6a468 100%);
}

#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
}

@media (max-width: 768px) {
  .game-title {
    font-size: 1.8rem;
  }

  .card {
    width: 70px;
    height: 70px;
  }

  .card-front::before,
  .card-back {
    font-size: 2rem;
  }

  .stats-bar {
    flex-wrap: wrap;
  }

  .game-controls {
    flex-direction: column;
  }
}
