/* General styles */
*, *::after, *::before {
  box-sizing: border-box;
}

:root {
  --cell-size: 100px;
  --mark-size: calc(var(--cell-size) * .9);
}

/* General styles for light mode */
body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  margin: 0;
  background: #ffffff; /* Solid white background for light mode */
  color: black;
  transition: background 0.3s, color 0.3s;
  padding-top: 60px; /* Prevent overlap with header */
}

/* General styles for dark mode */
body.dark-mode {
  background: #2e2e2e; /* Grayish background for dark mode */
  color: #e0e0e0; /* Light gray text for dark mode */
}

/* Header styles */
.header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: #f0f0f0; /* Solid light gray for light mode */
  border-bottom: 2px solid #000;
  z-index: 1000;
  color: black;
}

body.dark-mode .header {
  background: #3a3a3a; /* Dark gray for dark mode */
  border-bottom: 2px solid #e0e0e0;
  color: #e0e0e0;
}

/* Footer styles */
.footer {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  background: #f0f0f0; /* Solid light gray for light mode */
  border-top: 2px solid #000;
  color: black;
  position: fixed;
  bottom: 0;
  width: 100%;
  z-index: 1000;
}

body.dark-mode .footer {
  background: #3a3a3a; /* Dark gray for dark mode */
  border-top: 2px solid #e0e0e0;
  color: #e0e0e0;
}

.footer-links {
  display: flex;
  gap: 20px;
}

/* Footer links */
.footer-links a {
  color: black;
  text-decoration: none;
  font-size: 1rem;
  transition: color 0.3s;
}

.footer-links a:hover {
  color: gray;
}

body.dark-mode .footer-links a {
  color: #e0e0e0;
}

body.dark-mode .footer-links a:hover {
  color: lightgray;
}

/* Dark mode toggle button */
.dark-mode-toggle {
  font-size: 1.5rem; /* Adjust font size for text */
  background: none; /* Remove background color */
  border: none;
  cursor: pointer;
  color: inherit; /* Match the text color to the current mode */
  transition: none; /* Remove hover transition */
  padding: 5px 10px; /* Add some padding for better appearance */
  text-transform: uppercase; /* Make the text uppercase for consistency */
}

/* Remove hover effect */
.dark-mode-toggle:hover {
  transform: none; /* Disable scaling effect */
  background: none; /* Ensure no background change */
  color: inherit; /* Ensure no color change */
}

/* Score container */
.score-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 50px;
}

/* Score container */
.score {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 150px;
  padding: 20px;
  border: 2px solid #000;
  border-radius: 5px;
  background: #f0f0f0; /* Solid light gray for light mode */
}

body.dark-mode .score {
  background: #3a3a3a; /* Dark gray for dark mode */
  border-color: #e0e0e0;
}

/* Board styles */
.board {
  display: grid;
  grid-template-columns: repeat(3, var(--cell-size));
  grid-template-rows: repeat(3, var(--cell-size));
  gap: 5px;
}

/* Styles for X and O marks */
.cell.x::before {
  content: 'X';
  font-size: var(--mark-size);
  color: black; /* Black color for X in light mode */
  font-weight: bold;
}

body.dark-mode .cell.x::before {
  color: #e0e0e0; /* Light gray color for X in dark mode */
}

.cell.circle::before {
  content: 'O';
  font-size: var(--mark-size);
  color: black; /* Black color for O in light mode */
  font-weight: bold;
}

body.dark-mode .cell.circle::before {
  color: #e0e0e0; /* Light gray color for O in dark mode */
}

/* Center the marks inside the cells */
.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 1px solid #000;
  font-size: 2rem;
  cursor: pointer;
  transition: background-color 0.3s;
}

body.dark-mode .cell {
  border-color: #e0e0e0;
}

/* Highlight winning cells */
.cell.winning {
  background-color: #4caf50; /* Green background for winning cells */
  animation: pulse 1s infinite;
}

body.dark-mode .cell.winning {
  background-color: #e0e0e0; /* Light gray for winning cells in dark mode */
  color: #2e2e2e; /* Dark text for X and O in dark mode */
}

body:not(.dark-mode) .cell.winning {
  background-color: black; /* Black background for winning cells in light mode */
  color: white; /* White text for X and O in light mode */
}

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

/* Timer */
.timer {
  font-size: 1.5rem;
  margin-top: 10px;
  color: #ff5722;
}

body.dark-mode .timer {
  color: #ffcc00; /* Yellowish color for dark mode */
}

/* Winning message */
.winning-message {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  background-color: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 20px;
  border-radius: 10px;
}

.winning-message button {
  font-size: 3rem;
  background-color: white;
  border: 1px solid black;
  padding: 0.25em 0.5em;
  cursor: pointer;
}

.winning-message button:hover {
  background-color: black;
  color: white;
  border-color: white;
}

.winning-message.show {
  display: flex;
}

/* Winning message text styling */
.winning-message div[data-winning-message-text] {
  font-size: 3rem; /* Increase font size for the message */
  font-weight: bold;
  color: white; /* White text for all modes */
}

body.dark-mode .winning-message div[data-winning-message-text] {
  color: white; /* Ensure white text in dark mode */
}

/* Buttons styling */
button {
  font-size: 1.5rem;
  padding: 10px 20px;
  border: 2px solid black;
  background-color: black;
  color: white;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s, color 0.3s;
}

body.dark-mode button {
  background-color: #3a3a3a; /* Dark gray for dark mode */
  color: #e0e0e0; /* Light gray text for dark mode */
  border-color: #e0e0e0;
}

body.dark-mode button:hover {
  background-color: #4a4a4a; /* Slightly lighter gray on hover */
  color: #ffffff; /* White text on hover */
}

/* Restart Button Container */
.restart-container {
  display: flex;
  justify-content: center; /* Center the button horizontally */
  margin-top: 20px; /* Add spacing above the button */
  margin-bottom: 20px; /* Add spacing below the button */
}

/* Restart Button Styling */
#restartButton {
  font-size: 2rem; /* Increase font size */
  padding: 15px 30px; /* Increase padding for a larger button */
  border: 2px solid black;
  background-color: black; /* Solid black background */
  color: white; /* White text */
  border-radius: 10px; /* Slightly rounder corners */
  cursor: pointer;
  transition: background-color 0.3s, color 0.3s;
}

#restartButton:hover {
  background-color: white; /* White background on hover */
  color: black; /* Black text on hover */
}

body.dark-mode #restartButton {
  background-color: white; /* White background in dark mode */
  color: black; /* Black text in dark mode */
  border-color: white;
}

body.dark-mode #restartButton:hover {
  background-color: black; /* Black background on hover in dark mode */
  color: white; /* White text on hover in dark mode */
}

/* Reset Button Container */
.reset-container {
  display: flex;
  justify-content: center;
  margin-top: 40px; /* Add spacing above the button to move it down */
  margin-bottom: 40px; /* Keep spacing below the button */
}

/* Reset Button Styling */
#resetScoreButton {
  font-size: 1.5rem;
  padding: 10px 20px;
  border: 2px solid black;
  background-color: black; /* Solid black background */
  color: white; /* White text */
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s, color 0.3s;
}

#resetScoreButton:hover {
  background-color: white; /* White background on hover */
  color: black; /* Black text on hover */
}

body.dark-mode #resetScoreButton {
  background-color: white; /* White background in dark mode */
  color: black; /* Black text in dark mode */
  border-color: white;
}

body.dark-mode #resetScoreButton:hover {
  background-color: black; /* Black background on hover in dark mode */
  color: white; /* White text on hover in dark mode */
}

/* Responsive design */
@media (max-width: 600px) {
  :root {
    --cell-size: 60px;
  }

  .score {
    width: 100px;
    padding: 10px;
  }

  .dark-mode-toggle {
    font-size: 2rem;
  }
}
