/* Scope styles to avoid conflicts with GeneratePress */
.tic-tac-toe-wrapper {
  font-family: Arial, sans-serif;
  --board-size: 3; /* Default board size, will be updated by JS */
  --base-cell-size: 25vw; /* Base size for cells, adjusted below */
}
.tic-tac-toe-wrapper .bg-white { background-color: #ffffff; }
.tic-tac-toe-wrapper .bg-green-500 { background-color: #22c55e; }
.tic-tac-toe-wrapper .bg-yellow-500 { background-color: #eab308; }
.tic-tac-toe-wrapper .bg-red-500 { background-color: #ef4444; }
.tic-tac-toe-wrapper .bg-blue-500 { background-color: #3b82f6; }
.tic-tac-toe-wrapper .bg-gray-500 { background-color: #6b7280; }
.tic-tac-toe-wrapper .bg-green-600 { background-color: #16a34a; }
.tic-tac-toe-wrapper .bg-yellow-600 { background-color: #ca8a04; }
.tic-tac-toe-wrapper .bg-red-600 { background-color: #dc2626; }
.tic-tac-toe-wrapper .bg-blue-600 { background-color: #2563eb; }
.tic-tac-toe-wrapper .bg-gray-600 { background-color: #4b5563; }
.tic-tac-toe-wrapper .bg-gray-100 { background-color: #f3f4f6; }
.tic-tac-toe-wrapper .text-white { color: #ffffff; }
.tic-tac-toe-wrapper .text-gray-800 { color: #1f2937; }
.tic-tac-toe-wrapper .text-4xl { font-size: 2.25rem; }
.tic-tac-toe-wrapper .text-2xl { font-size: 1.5rem; }
.tic-tac-toe-wrapper .text-lg { font-size: 1.125rem; }
.tic-tac-toe-wrapper .font-bold { font-weight: 700; }
.tic-tac-toe-wrapper .font-semibold { font-weight: 600; }
.tic-tac-toe-wrapper .p-8 { padding: 2rem; }
.tic-tac-toe-wrapper .py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.tic-tac-toe-wrapper .px-4 { padding-left: 1rem; padding-right: 1rem; }
.tic-tac-toe-wrapper .mb-6 { margin-bottom: 1.5rem; }
.tic-tac-toe-wrapper .mb-4 { margin-bottom: 1rem; }
.tic-tac-toe-wrapper .mt-4 { margin-top: 1rem; }
.tic-tac-toe-wrapper .flex { display: flex; }
.tic-tac-toe-wrapper .flex-col { flex-direction: column; }
.tic-tac-toe-wrapper .gap-4 { gap: 1rem; }
.tic-tac-toe-wrapper .items-center { align-items: center; }
.tic-tac-toe-wrapper .justify-center { justify-content: center; }
.tic-tac-toe-wrapper .min-h-screen { min-height: 100vh; }
.tic-tac-toe-wrapper .w-full { width: 100%; }
.tic-tac-toe-wrapper .text-center { text-align: center; }
.tic-tac-toe-wrapper .rounded-lg { border-radius: 0.5rem; }
.tic-tac-toe-wrapper .border { border-width: 1px; }
.tic-tac-toe-wrapper .shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); }
.tic-tac-toe-wrapper .hidden { display: none; }
.tic-tac-toe-wrapper .block { display: block; }

/* Responsive adjustments for UI elements */
.tic-tac-toe-wrapper button,
.tic-tac-toe-wrapper select,
.tic-tac-toe-wrapper input {
  width: 100%;
  max-width: 300px;
  margin: 0.5rem auto;
  padding: 0.5rem;
  font-size: 1rem;
  box-sizing: border-box;
}
.tic-tac-toe-wrapper select {
  font-size: 2rem; /* Larger symbols in dropdowns */
}

/* Board styling */
.tic-tac-toe-wrapper .board {
  display: grid;
  gap: 5px;
  justify-content: center;
  margin: 20px auto;
  width: 100%;
  max-width: 90vw; /* Ensure the board fits within the viewport */
  padding: 20px; /* Add padding to prevent touching screen edges */
}

/* Dynamic cell sizes based on board size */
.tic-tac-toe-wrapper .cell {
  width: calc(90vw / var(--board-size));
  height: calc(90vw / var(--board-size));
  max-width: calc(1200px / var(--board-size));
  max-height: calc(1200px / var(--board-size));
  min-width: 80px;
  min-height: 80px;
  background: #ffffff;
  border: 2px solid #4b5563;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
  touch-action: manipulation;
}
.tic-tac-toe-wrapper .cell svg {
  width: calc((90vw / var(--board-size)) * 0.8);
  height: calc((90vw / var(--board-size)) * 0.8);
  max-width: calc((1200px / var(--board-size)) * 0.8);
  max-height: calc((1200px / var(--board-size)) * 0.8);
  min-width: 60px;
  min-height: 60px;
}
.tic-tac-toe-wrapper .cell:hover {
  background: #f3f4f6;
  transform: scale(1.05);
}
.tic-tac-toe-wrapper .cell.x svg path {
  stroke: #ef4444;
  animation: pop 0.3s;
}
.tic-tac-toe-wrapper .cell.o svg path {
  fill: #3b82f6;
  animation: pop 0.3s;
}
@keyframes pop {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}
.tic-tac-toe-wrapper .modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.tic-tac-toe-wrapper .modal-content {
  background: white;
  padding: 20px;
  border-radius: 10px;
  text-align: center;
}
.tic-tac-toe-wrapper .turn-indicator {
  font-size: 1.5rem;
  font-weight: bold;
  margin-bottom: 10px;
}

/* Ensure the game board section is responsive */
#game-board {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Media query for desktop screens */
@media (min-width: 768px) {
  .tic-tac-toe-wrapper .board {
    max-width: min(80vw, 900px); /* Adjusted for better fit on desktop */
  }
  .tic-tac-toe-wrapper .cell {
    width: calc(70vw / var(--board-size)); /* Smaller base size for desktop */
    height: calc(70vw / var(--board-size));
    max-width: calc(900px / var(--board-size)); /* Adjusted max-width */
    max-height: calc(900px / var(--board-size));
    min-width: 100px; /* Slightly larger min-width for desktop */
    min-height: 100px;
  }
  .tic-tac-toe-wrapper .cell svg {
    width: calc((70vw / var(--board-size)) * 0.8);
    height: calc((70vw / var(--board-size)) * 0.8);
    max-width: calc((900px / var(--board-size)) * 0.8);
    max-height: calc((900px / var(--board-size)) * 0.8);
    min-width: 80px;
    min-height: 80px;
  }
}

/* Media query for mobile screens (unchanged) */
@media (max-width: 767px) {
  .tic-tac-toe-wrapper .cell {
    width: calc(85vw / var(--board-size));
    height: calc(85vw / var(--board-size));
    max-width: calc(90vw / var(--board-size));
    max-height: calc(90vw / var(--board-size));
    min-width: 60px;
    min-height: 60px;
  }
  .tic-tac-toe-wrapper .cell svg {
    width: calc((85vw / var(--board-size)) * 0.8);
    height: calc((85vw / var(--board-size)) * 0.8);
    max-width: calc((90vw / var(--board-size)) * 0.8);
    max-height: calc((90vw / var(--board-size)) * 0.8);
    min-width: 40px;
    min-height: 40px;
  }
}
