:root {
  --primary-color: #4a6bfd;
  --x-color: #ff6b6b;
  --o-color: #4ecdc4;
  --light-bg: #f8f9fa;
  --dark-bg: #343a40;
  --winner-bg: rgba(74, 107, 253, 0.15);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}

body {
  font-family: "Poppins", sans-serif;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e7eb 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  color: var(--dark-bg);
}

.ttt-container {
  text-align: center;
  background: white;
  padding: 2.5rem;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  max-width: 500px;
  width: 90%;
}

h1 {
  color: var(--primary-color);
  margin-bottom: 1rem;
  font-size: 2.5rem;
  letter-spacing: -0.5px;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-gap: 12px;
  margin: 25px auto;
  max-width: 400px;
}

.cell {
  aspect-ratio: 1;
  font-size: 2.5rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--light-bg);
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  user-select: none;
}

.cell:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.cell.x {
  color: var(--x-color);
}

.cell.o {
  color: var(--o-color);
}

.cell.win {
  background-color: var(--winner-bg);
  animation: pulse 0.5s ease-in-out infinite alternate;
}

.status {
  margin: 1.5rem 0;
  font-size: 1.2rem;
  font-weight: 500;
  min-height: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.player-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-weight: bold;
}

.player-x {
  background-color: rgba(255, 107, 107, 0.2);
  color: var(--x-color);
}

.player-o {
  background-color: rgba(78, 205, 196, 0.2);
  color: var(--o-color);
}

.button-container {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

#restartBtn,
#resetScoresBtn {
  padding: 0.8rem 1.5rem;
  font-size: 1rem;
  cursor: pointer;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50px;
  font-weight: 600;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(74, 107, 253, 0.25);
}

#resetScoresBtn {
  background-color: #6c757d;
  box-shadow: 0 4px 12px rgba(108, 117, 125, 0.25);
}

#restartBtn:hover,
#resetScoresBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(74, 107, 253, 0.35);
}

#resetScoresBtn:hover {
  box-shadow: 0 6px 20px rgba(108, 117, 125, 0.35);
}

#restartBtn:active,
#resetScoresBtn:active {
  transform: translateY(0px);
}

.result-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.result-modal.active {
  opacity: 1;
  pointer-events: all;
}

.modal-content {
  background: white;
  padding: 2rem;
  border-radius: 16px;
  text-align: center;
  transform: translateY(20px);
  transition: transform 0.3s ease;
  max-width: 400px;
  width: 90%;
}

.result-modal.active .modal-content {
  transform: translateY(0);
}

.result-title {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: var(--primary-color);
}

.winner-message {
  font-size: 1.5rem;
  margin-bottom: 2rem;
  font-weight: 600;
}

.modal-btn {
  padding: 0.8rem 2rem;
  font-size: 1rem;
  cursor: pointer;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.modal-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(74, 107, 253, 0.35);
}

.winner-animation {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  background-color: var(--primary-color);
  opacity: 0.8;
  animation: confetti-fall 3s linear forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(-100px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(calc(100vh + 100px)) rotate(720deg);
    opacity: 0;
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  100% {
    transform: scale(1.05);
  }
}

.scoreboard {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
}

.score-card {
  padding: 0.6rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  background: var(--light-bg);
}

.score-title {
  font-size: 0.85rem;
  opacity: 0.7;
  margin-bottom: 2px;
}

.score-value {
  font-size: 1.25rem;
  font-weight: bold;
}

.x-score {
  color: var(--x-color);
}

.o-score {
  color: var(--o-color);
}

.draw-score {
  color: var(--primary-color);
}

/* Make the game responsive on smaller screens */
@media (max-width: 500px) {
  .ttt-container {
    padding: 1.5rem;
  }

  h1 {
    font-size: 2rem;
  }

  .cell {
    font-size: 2rem;
  }
}
