/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh; /* Fixed: was 100vw, should be 100vh */
  flex-direction: column;
  font-family: "Arial", sans-serif;
  background: linear-gradient(135deg, #f5f5dc, #e6d7b8);
  padding: 20px;
}

/* Game board container */
.game-board {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  border: 3px solid #8b4513;
  border-radius: 8px;
  background-color: #faf8f3;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 8px;
}

/* Main game grid */
.game-grid {
  position: relative;
}

@keyframes dotAppear {
  0% {
    opacity: 0;
    transform: scale(0) rotate(180deg);
  }
  60% {
    opacity: 0.8;
    transform: scale(1.1) rotate(45deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

@keyframes lineSlide {
  0% {
    opacity: 0;
    transform: scaleX(0);
  }
  100% {
    opacity: 1;
    transform: scaleX(1);
  }
}

@keyframes lineSlideVertical {
  0% {
    opacity: 0;
    transform: scaleY(0);
  }
  100% {
    opacity: 1;
    transform: scaleY(1);
  }
}

/* Dot styles */
.dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  position: absolute;
  background-color: #dc2626;
  border: 2px solid #7f1d1d;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
  z-index: 2; /* Ensure dots appear above lines */
  opacity: 0;
}

.dot.animate {
  animation: dotAppear 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Line styles */
.line {
  position: absolute;
  transition: all 0.2s ease;
  z-index: 1; /* Lines appear below dots */
  opacity: 0;
}

.line.horizontal.animate {
  animation: lineSlide 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  transform-origin: left center;
}

.line.vertical.animate {
  animation: lineSlideVertical 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94)
    forwards;
  transform-origin: center top;
}

.valid {
  background-color: #e5e7eb; /* Light gray background to show it's selectable */
  border: 2px dashed #6b7280; /* Dashed border for better visibility */
  box-shadow: 0 2px 8px rgba(107, 114, 128, 0.2);
  border-radius: 4px;
  animation: pulse-valid 2s infinite; /* Subtle pulsing animation */
  cursor: pointer;
}

@keyframes pulse-valid {
  0% {
    box-shadow: 0 2px 8px rgba(107, 114, 128, 0.2);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 3px 12px rgba(107, 114, 128, 0.4);
    transform: scale(1.02);
  }
  100% {
    box-shadow: 0 2px 8px rgba(107, 114, 128, 0.2);
    transform: scale(1);
  }
}

.valid:hover {
  background-color: #9ca3af; /* Darker gray on hover */
  border-color: #4b5563;
  transform: scaleY(1.5) scaleX(1.05); /* More pronounced scaling */
  box-shadow: 0 4px 16px rgba(75, 85, 99, 0.4);
  transition: all 0.2s ease;
}

.reset-container {
  margin-top: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 8px;
  border: 3px solid #8b4513;
  border-radius: 8px;
  background-color: #faf8f3;
}

.reset-button {
  width: 300px;
  height: 50px;
  border-style: solid;
  border-radius: 3px;
  border-color: transparent;
  background-color: #dc2626;
  color: white;
  font-size: large;
  cursor: pointer;
}

.title {
  margin-bottom: 100px;
  color: #dc2626;
  font-size: xx-large;
  font-weight: bolder;
}

.score-container {
  display: flex;
  justify-content: space-around;
  margin-bottom: 50px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 8px;
  border: 3px solid #8b4513;
  border-radius: 8px;
  background-color: #faf8f3;
  width: fit-content;
  /* gap: 20px; */
}

.score {
  align-items: center;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  text-align: center;
  padding: 8px;
  width: 40%;
  min-width: 100px;
}

.selected-P1 {
  background-color: #ff4444;
}

.selected-P2 {
  background-color: #4444ff;
}

.square {
  width: 42px;
  height: 42px;
  position: absolute;
  opacity: 0.9;
  z-index: 1;
}

.Current {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-style: solid;
  border-radius: 3px;
}

#player1-container {
  border-color: #ff4444;
}

#player2-container {
  border-color: #4444ff;
}

.options-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  z-index: 10;
}

.options-overlay.hidden {
  display: none;
}

.options-overlay.show {
  display: flex;
  animation: fadeIn 0.4s ease;
}

.options-container {
  border: 3px solid #8b4513;
  font-weight: bolder;
  border-radius: 12px;
  background: linear-gradient(135deg, #f5f5dc, #e6d7b8);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  display: flex;
  padding: 30px;
  flex-direction: column;
  align-items: center;
  width: 90%;
  gap: 20px;
}

@media (min-width: 450px) {
  .options-container {
    min-width: 400px;
    width: auto;
  }
}

.options-container h2 {
  color: #dc2626;
  text-align: center;
  margin-bottom: 10px;
  font-size: 1.8em;
}

.gamemode-container,
.gamestyle-container {
  display: flex;
  gap: 10px;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.gamemode-container > div:first-child,
.gamestyle-container > div:first-child {
  color: #8b4513;
  font-size: 1.1em;
  margin-bottom: 5px;
  align-self: flex-start;
}

.buttons {
  display: flex;
  gap: 10px;
  width: 100%;
}

.btn {
  flex: 1;
  padding: 12px 20px;
  border: 2px solid #8b4513;
  background-color: #faf8f3;
  color: #8b4513;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  text-align: center;
  font-family: inherit;
  font-size: 1em;
  transition: all 0.3s ease;
}

.btn.active {
  background-color: #dc2626;
  color: white;
  border-color: #dc2626;
}

.btn.active:hover {
  background-color: #dc2626;
  transform: translateY(0px);
}

.btn:hover {
  background-color: #e6d7b8;
  transform: translateY(-2px);
}

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

.btn:disabled:hover {
  background-color: #faf8f3;
  transform: none;
}

.grid-option-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  position: relative;
}

.slider-label {
  align-self: flex-start;
  color: #8b4513;
  font-size: 1.1em;
  margin-bottom: 5px;
}

.slider {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #e6d7b8, #d1c4a0);
  outline: none;
  cursor: pointer;
  border: 1px solid #8b4513;
}

.slider::-webkit-slider-thumb {
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #dc2626;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  border: 2px solid white;
}

.slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #dc2626;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.start-button {
  width: 100%;
  height: 50px;
  background-color: #dc2626;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1.2em;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}

.start-button:hover {
  background-color: #b91c1c;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
  transform: translateY(-2px);
}

.option-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 10px;
  border: none;
  color: white;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  background: #dc2626;
}

.winner-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: none;
  justify-content: center;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 1000;
}

.winner-overlay.hidden {
  display: none;
}

.winner-overlay.show {
  display: flex;
  animation: fadeIn 0.4s ease;
}

.winner-container {
  background: linear-gradient(135deg, #faf8f3, #f0ede5);
  border: 4px solid #8b4513;
  border-radius: 16px;
  padding: 40px 30px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  text-align: center;
  min-width: 350px;
  max-width: 90%;
}

#winner-title {
  color: #dc2626;
  font-size: 2.2em;
  margin-bottom: 20px;
  font-weight: bold;
}

.winner-content {
  margin-bottom: 30px;
}

.winner-player {
  font-size: 1.8em;
  font-weight: bold;
  margin-bottom: 20px;
  padding: 15px;
  border-radius: 8px;
  border: 2px solid;
}

.winner-player.player1 {
  color: #ff4444;
  background-color: rgba(255, 68, 68, 0.1);
  border-color: #ff4444;
}

.winner-player.player2 {
  color: #4444ff;
  background-color: rgba(68, 68, 255, 0.1);
  border-color: #4444ff;
}

.winner-player.tie {
  color: #8b4513;
  background-color: rgba(139, 69, 19, 0.1);
  border-color: #8b4513;
}

.final-scores {
  display: flex;
  justify-content: space-around;
  gap: 20px;
  margin-top: 20px;
}

.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 15px;
  border-radius: 8px;
  background-color: rgba(139, 69, 19, 0.1);
  border: 2px solid #8b4513;
  min-width: 120px;
}

.player-name {
  font-size: 1.1em;
  font-weight: bold;
  color: #8b4513;
  margin-bottom: 8px;
}

.player-score {
  font-size: 2em;
  font-weight: bold;
  color: #dc2626;
}

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

.play-again-btn,
.new-game-btn {
  padding: 12px 25px;
  border: none;
  border-radius: 8px;
  font-size: 1.1em;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 120px;
  background-color: #dc2626;
  color: white;
}

.play-again-btn:hover,
.new-game-btn:hover {
  background-color: #b91c1c;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(185, 28, 28, 0.4);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 449px) {
  .options-container {
    margin: 20px;
    padding: 20px;
    width: calc(100% - 40px);
  }

  .buttons {
    flex-direction: column;
  }

  #button {
    width: 100%;
  }

  .winner-container {
    margin: 20px;
    padding: 30px 20px;
    min-width: auto;
  }

  .final-scores {
    flex-direction: column;
    gap: 10px;
  }

  .winner-buttons {
    flex-direction: column;
    gap: 10px;
  }

  .play-again-btn,
  .new-game-btn {
    width: 100%;
  }
}

@media (max-width: 200px) {
  .score-container {
    flex-direction: column;
  }
}
