/* CSS Custom Properties for Theme Support */
:root {
  /* Light Theme */
  --bg-color: #f0f2f5;
  --card-bg: #ffffff;
  --text-color: #1a1a1a;
  --text-secondary: #666666;
  --border-color: #e1e5e9;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 8px 25px rgba(0, 0, 0, 0.15);
  --primary-color: #4a90e2;
  --primary-hover: #357abd;
  --x-color: #e74c3c;
  --o-color: #3498db;
  --win-color: #27ae60;
  --button-bg: #ffffff;
  --button-hover: #f8f9fa;
  --button-border: #e1e5e9;
}

[data-theme="dark"] {
  /* Dark Theme */
  --bg-color: #1a1a1a;
  --card-bg: #2d2d2d;
  --text-color: #ffffff;
  --text-secondary: #cccccc;
  --border-color: #404040;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 8px 25px rgba(0, 0, 0, 0.4);
  --primary-color: #5aa3f0;
  --primary-hover: #4a90e2;
  --x-color: #ff6b6b;
  --o-color: #4ecdc4;
  --win-color: #51cf66;
  --button-bg: #3d3d3d;
  --button-hover: #4a4a4a;
  --button-border: #555555;
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Header Section */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.game-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
  margin: 0;
}

/* Theme Toggle */
.theme-toggle {
  background: var(--button-bg);
  border: 2px solid var(--button-border);
  border-radius: 50px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-color);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-toggle:hover {
  background: var(--button-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

/* Game Container */
.game-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Game Info */
.game-info {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.game-details {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.game-detail {
  text-align: center;
}

.game-detail-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.game-detail-value {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-color);
}

.next-player {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
}

.next-player-symbol {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: bold;
  background: var(--button-bg);
  border: 2px solid var(--button-border);
}

/* Game Board */
.game-board {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.board-container {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  aspect-ratio: 1;
}

.board-table {
  width: 100%;
  height: 100%;
  border-collapse: separate;
  border-spacing: 8px;
}

.board-cell {
  width: 33.333%;
  height: 33.333%;
  padding: 0;
}

.movementButton {
  width: 100%;
  height: 100%;
  min-height: 100px;
  background: var(--button-bg);
  border: 3px solid var(--button-border);
  border-radius: 15px;
  font-size: 3rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.movementButton:hover:not(:disabled) {
  background: var(--button-hover);
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: var(--primary-color);
}

.movementButton:active {
  transform: translateY(-1px);
}

.movementButton:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.movementButton.x {
  color: var(--x-color);
}

.movementButton.o {
  color: var(--o-color);
}

.movementButton.winner {
  background: var(--win-color);
  color: white;
  animation: winner-pulse 1s ease-in-out infinite alternate;
}

@keyframes winner-pulse {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

/* Debug Panel (Hidden by default) */
.debug-panel {
  background: var(--card-bg);
  border-radius: 15px;
  padding: 1rem;
  box-shadow: var(--shadow);
  margin-top: 1rem;
  display: none; /* Hidden by default */
}

.debug-toggle {
  background: var(--button-bg);
  border: 1px solid var(--button-border);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  transition: all 0.3s ease;
}

.debug-toggle:hover {
  background: var(--button-hover);
}

.debug-content {
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 768px) {
  .header {
    padding: 1rem;
    flex-direction: column;
    gap: 1rem;
  }
  
  .game-title {
    font-size: 1.5rem;
  }
  
  .game-info {
    padding: 1rem;
    flex-direction: column;
    text-align: center;
  }
  
  .game-details {
    justify-content: center;
  }
  
  .game-board {
    padding: 1rem;
  }
  
  .movementButton {
    min-height: 80px;
    font-size: 2rem;
  }
}

@media (max-width: 480px) {
  .game-container {
    padding: 0 0.5rem;
  }
  
  .board-table {
    border-spacing: 4px;
  }
  
  .movementButton {
    min-height: 60px;
    font-size: 1.5rem;
    border-radius: 10px;
  }
}

/* Utility Classes */
.center {
  text-align: center;
}

.hidden {
  display: none !important;
}

.fade-in {
  animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Game Status Messages */
.game-status {
  background: var(--card-bg);
  border-radius: 15px;
  padding: 1rem;
  margin-top: 1rem;
  box-shadow: var(--shadow);
  text-align: center;
  font-weight: 600;
}

.game-status.winner {
  background: var(--win-color);
  color: white;
}

.game-status.draw {
  background: var(--text-secondary);
  color: white;
}
