/* CSS Variables for Theme Colors */
:root {
  /* Dark Theme Colors */
  --background-dark: #0f0c29;
  --background-medium: #302b63;
  --background-light: #24243e;
  
  /* Neon Accent Colors */
  --accent-primary: #00f7ff;
  --accent-secondary: #bd00ff;
  --accent-tertiary: #00ff9d;
  
  /* Cell Colors */
  --cell-bg: rgba(255, 255, 255, 0.05);
  --cell-border: rgba(0, 247, 255, 0.3);
  --cell-hover: rgba(0, 247, 255, 0.1);
  
  /* Text Colors */
  --text-primary: #ffffff;
  --text-secondary: #00f7ff;
  --text-tertiary: #bd00ff;
  
  /* Other Colors */
  --winning-cell: rgba(0, 255, 157, 0.2);
  --modal-bg: rgba(15, 12, 41, 0.95);
}

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

body {
  font-family: 'Poppins', sans-serif;
  background: linear-gradient(135deg, var(--background-dark), var(--background-medium), var(--background-light));
  background-size: 400% 400%;
  animation: gradientBG 15s ease infinite;
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

/* Background Animation */
@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.container {
  max-width: 500px;
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
  padding: 30px;
  text-align: center;
}

/* Header Styles */
header {
  margin-bottom: 25px;
}

h1 {
  font-family: 'Orbitron', sans-serif;
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 3px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 10px rgba(0, 247, 255, 0.3);
  margin-bottom: 20px;
}

/* Scoreboard Styles */
.scoreboard {
  display: flex;
  justify-content: space-around;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 15px;
  padding: 15px;
  margin: 0 auto;
  max-width: 300px;
}

.player-score {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.player-label {
  font-size: 0.8rem;
  font-weight: 300;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.score {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Game Info Styles */
.game-info {
  margin: 25px 0;
}

.turn-indicator {
  display: inline-flex;
  align-items: center;
  background: rgba(0, 247, 255, 0.1);
  border-radius: 50px;
  padding: 10px 25px;
  border: 1px solid var(--cell-border);
}

.current-player {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent-primary);
  text-shadow: 0 0 8px rgba(0, 247, 255, 0.5);
  animation: pulse 2s infinite;
}

.turn-text {
  font-size: 1rem;
  margin-left: 8px;
  font-weight: 300;
  letter-spacing: 1px;
}

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

/* Board Styles */
.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 20px auto;
  max-width: 320px;
}

.cell {
  aspect-ratio: 1;
  background: var(--cell-bg);
  border: 2px solid var(--cell-border);
  border-radius: 10px;
  font-family: 'Orbitron', sans-serif;
  font-size: 2.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
}

.cell::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(0, 247, 255, 0.1), rgba(189, 0, 255, 0.1));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.cell:hover {
  background: var(--cell-hover);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  border-color: var(--accent-primary);
}

.cell:hover::before {
  opacity: 1;
}

.cell.x {
  color: var(--accent-primary);
  text-shadow: 0 0 10px rgba(0, 247, 255, 0.5);
}

.cell.o {
  color: var(--accent-tertiary);
  text-shadow: 0 0 10px rgba(0, 255, 157, 0.5);
}

/* Winning cell highlight */
.cell.win {
  background: var(--winning-cell);
  animation: winGlow 1.5s infinite alternate;
  border-color: var(--accent-tertiary);
}

@keyframes winGlow {
  0% { box-shadow: 0 0 5px var(--accent-tertiary); }
  100% { box-shadow: 0 0 20px var(--accent-tertiary); }
}

/* Controls Styles */
.controls {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 25px;
  flex-wrap: wrap;
}

.control-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--cell-border);
  border-radius: 50px;
  color: var(--text-secondary);
  font-family: 'Poppins', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 12px 25px;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 1px;
}

.control-btn:hover {
  background: rgba(0, 247, 255, 0.2);
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0, 247, 255, 0.2);
  color: var(--text-primary);
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--modal-bg);
  border-radius: 20px;
  border: 1px solid var(--cell-border);
  padding: 40px;
  text-align: center;
  max-width: 90%;
  width: 400px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  animation: modalAppear 0.5s ease-out;
}

@keyframes modalAppear {
  0% { opacity: 0; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1); }
}

#result-message {
  font-family: 'Orbitron', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 30px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.modal-btn {
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  border: none;
  border-radius: 50px;
  color: #0f0c29;
  font-family: 'Poppins', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  padding: 15px 40px;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 1px;
  box-shadow: 0 5px 15px rgba(0, 247, 255, 0.3);
}

.modal-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 247, 255, 0.5);
}

/* Responsive Design */
@media (max-width: 500px) {
  .container {
    padding: 20px;
  }
  
  h1 {
    font-size: 2rem;
  }
  
  .board {
    max-width: 280px;
    gap: 8px;
  }
  
  .cell {
    font-size: 2rem;
  }
  
  .controls {
    flex-direction: column;
    align-items: center;
  }
  
  .control-btn {
    width: 100%;
    max-width: 250px;
  }
  
  .modal-content {
    padding: 30px 20px;
  }
  
  #result-message {
    font-size: 1.5rem;
  }
}