@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;800&display=swap");

:root {
  --primary-color: #4a6bff;
  --secondary-color: #ff4a6b;
  --background-color: #f5f7ff;
  --board-color: #ffffff;
  --border-color: #e0e5ff;
  --shadow-color: rgba(74, 107, 255, 0.2);
  --x-color: #4a6bff;
  --o-color: #ff4a6b;
  --win-gradient: linear-gradient(135deg, #ffd700, #ff9500);
}

body {
  font-family: "Poppins", sans-serif;
  background-color: var(--background-color);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
}

.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem;
  background-color: var(--board-color);
  border-radius: 20px;
  box-shadow: 0 10px 30px var(--shadow-color);
}

.game-title {
  color: var(--primary-color);
  margin-bottom: 1.5rem;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  position: relative;
}

.game-title::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 4px;
  background: var(--secondary-color);
  border-radius: 2px;
}

.tabla {
  background-color: var(--border-color);
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.red {
  display: flex;
  margin: 5px;
}

.polje {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 80px;
  height: 80px;
  margin: 5px;
  background-color: var(--board-color);
  border-radius: 10px;
  font-size: 2.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.polje:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
}

.polje:active {
  transform: translateY(0);
}

.game-status {
  margin-top: 1.5rem;
  font-size: 1.2rem;
  color: #555;
}

.current-player {
  font-weight: 600;
  color: var(--primary-color);
}

/* Animations for X and O */
@keyframes draw-x {
  0% {
    stroke-dashoffset: 100;
    opacity: 0;
  }
  100% {
    stroke-dashoffset: 0;
    opacity: 1;
  }
}

@keyframes draw-o {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  70% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes place-mark {
  0% {
    transform: scale(0.5);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

.x-mark {
  animation: place-mark 0.4s ease-out forwards;
  color: var(--x-color);
}

.o-mark {
  animation: place-mark 0.4s ease-out forwards;
  color: var(--o-color);
}

/* Victory animations */
.pobeda {
  animation: yay 1s infinite, sparkle 0.8s infinite, confetti 4s linear infinite;
  transform-origin: center bottom;
  position: relative;
  background-image: linear-gradient(
    135deg,
    rgba(255, 215, 0, 0.2) 25%,
    rgba(255, 105, 180, 0.2) 25%,
    rgba(255, 105, 180, 0.2) 50%,
    rgba(0, 191, 255, 0.2) 50%,
    rgba(0, 191, 255, 0.2) 75%,
    rgba(50, 205, 50, 0.2) 75%
  );
  background-size: 400% 400%;
  border-radius: 10px;
  transition: all 0.3s ease;
  z-index: 10;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

@keyframes yay {
  0%,
  100% {
    transform: translateY(0) scale(1) rotate(0deg);
    filter: brightness(100%);
    animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
  }
  25% {
    transform: translateY(-10px) scale(1.05) rotate(-3deg);
  }
  50% {
    transform: translateY(-15px) scale(1.1) rotate(3deg);
    filter: brightness(120%) drop-shadow(0 0 10px rgba(255, 215, 0, 0.7));
    animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }
  75% {
    transform: translateY(-7px) scale(1.05) rotate(-2deg);
  }
}

@keyframes sparkle {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(255, 223, 0, 0);
  }
  50% {
    box-shadow: 0 0 15px rgba(255, 223, 0, 0.8), 0 0 30px rgba(255, 165, 0, 0.6);
  }
}

@keyframes confetti {
  0% {
    background-position: 0% 0%;
  }
  100% {
    background-position: 100% 100%;
  }
}

.celebrate {
  animation: celebrate-pulse 1.5s infinite;
  animation-delay: calc(var(--i, 0) * 0.1s);
}

@keyframes celebrate-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.7;
  }
  50% {
    transform: scale(1.05);
    opacity: 1;
    box-shadow: 0 0 10px rgba(255, 223, 0, 0.5);
  }
}

/* Empty cell hover effect */
.polje:not(:has(*)):hover::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    circle,
    rgba(74, 107, 255, 0.1) 0%,
    rgba(255, 255, 255, 0) 70%
  );
  opacity: 0.8;
  transition: opacity 0.3s ease;
}

.hidden {
  display: none;
}

.coa {
  object-fit: cover;
  width: 100vw;
}
