/**
 * Tic-Tac-Toe Game Styles
 * Phase B - Modern responsive design
 * @version 2.0.0
 */

/* ========================================
   CSS VARIABLES
   ======================================== */
:root {
  /* Colors */
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #ec4899;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;

  /* Player colors */
  --player-x: #3b82f6; /* Blue */
  --player-o: #ef4444; /* Red */

  /* Neutral colors */
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f1724;
  --text-primary: #ffffff;
  --text-secondary: #a0aec0;
  --border: #2d3748;

  /* Spacing */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;

  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 16px 32px rgba(0, 0, 0, 0.3);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.3s ease;
  --transition-slow: 0.5s ease;
}

/* ========================================
   GLOBAL STYLES
   ======================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(
    135deg,
    var(--bg-primary) 0%,
    var(--bg-tertiary) 100%
  );
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--spacing-md);
  line-height: 1.6;
}

/* ========================================
   GAME CONTAINER
   ======================================== */
.game-container {
  width: 100%;
  max-width: 800px;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  position: relative;
}

/* ========================================
   SCREEN SYSTEM
   ======================================== */
.screen {
  display: none;
  padding: var(--spacing-xl);
  min-height: 600px;
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: block;
}

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

/* ========================================
   WELCOME SCREEN
   ======================================== */
.welcome-content {
  text-align: center;
}

.game-title {
  font-size: 3rem;
  margin-bottom: var(--spacing-md);
  background: linear-gradient(135deg, var(--player-x), var(--player-o));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--spacing-md);
}

.game-title .icon {
  font-size: 2.5rem;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.game-description {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-xl);
}

/* Mode Selection */
.mode-selection {
  margin-bottom: var(--spacing-xl);
}

.mode-selection h2 {
  font-size: 1.5rem;
  margin-bottom: var(--spacing-md);
  color: var(--text-primary);
}

.mode-btn {
  width: 100%;
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition-base);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.mode-btn:hover {
  background: var(--bg-primary);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.mode-btn.primary {
  border-color: var(--primary);
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--primary-dark) 100%
  );
}

.mode-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.mode-info {
  text-align: left;
}

.mode-name {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.mode-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Difficulty Selection */
.difficulty-selection {
  margin-bottom: var(--spacing-xl);
}

.difficulty-selection h2 {
  font-size: 1.5rem;
  margin-bottom: var(--spacing-md);
  color: var(--text-primary);
}

.difficulty-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-sm);
}

.difficulty-btn {
  padding: var(--spacing-md);
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-base);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-xs);
}

.difficulty-btn:hover {
  background: var(--bg-primary);
  transform: scale(1.05);
}

.difficulty-btn.selected {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.difficulty-icon {
  font-size: 2rem;
}

.difficulty-name {
  font-weight: 600;
  font-size: 1rem;
}

.difficulty-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* How to Play */
.how-to-play {
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  text-align: left;
}

.how-to-play h3 {
  font-size: 1.25rem;
  margin-bottom: var(--spacing-sm);
  color: var(--primary);
}

.how-to-play ul {
  list-style: none;
  padding: 0;
}

.how-to-play li {
  padding: var(--spacing-xs) 0;
  color: var(--text-secondary);
}

/* ========================================
   GAME SCREEN
   ======================================== */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-md);
  border-bottom: 2px solid var(--border);
}

.game-info {
  display: flex;
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

.info-item {
  display: flex;
  flex-direction: column;
}

.info-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.info-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.game-controls-top {
  display: flex;
  gap: var(--spacing-sm);
}

.icon-btn {
  width: 44px;
  height: 44px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 1.25rem;
  cursor: pointer;
  transition: all var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: var(--bg-primary);
  border-color: var(--primary);
  transform: scale(1.1);
}

/* AI Thinking */
.ai-thinking {
  text-align: center;
  padding: var(--spacing-sm);
  background: rgba(99, 102, 241, 0.1);
  border-radius: var(--radius-md);
  color: var(--primary);
  font-weight: 600;
  margin-bottom: var(--spacing-md);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Game Message */
.game-message {
  text-align: center;
  padding: var(--spacing-sm);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-md);
  font-weight: 600;
}

.game-message.info {
  background: rgba(59, 130, 246, 0.1);
  color: var(--info);
}

.game-message.error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
}

/* Tic-Tac-Toe Board */
.board-container {
  display: flex;
  justify-content: center;
  margin-bottom: var(--spacing-lg);
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-sm);
  width: 100%;
  background: var(--bg-tertiary);
  padding: var(--spacing-md);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 400px;
}

.cell {
  aspect-ratio: 1;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  font-weight: bold;
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
}

.cell:hover:not(.filled) {
  background: var(--bg-primary);
  border-color: var(--primary);
  transform: scale(1.05);
}

.cell.filled {
  cursor: not-allowed;
}

.cell.x {
  color: var(--player-x);
  animation: cellAppear 0.3s ease;
}

.cell.o {
  color: var(--player-o);
  animation: cellAppear 0.3s ease;
}

.cell.winning {
  background: linear-gradient(
    135deg,
    rgba(16, 185, 129, 0.2) 0%,
    rgba(16, 185, 129, 0.4) 100%
  );
  border-color: var(--success);
  animation: winningPulse 0.8s ease infinite;
}

@keyframes cellAppear {
  from {
    transform: scale(0) rotate(-180deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes winningPulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(16, 185, 129, 0.7);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.7);
  }
}

/* Scores */
.scores {
  display: flex;
  justify-content: center;
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
  padding: var(--spacing-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
}

.score-item {
  text-align: center;
}

.score-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  display: block;
  margin-bottom: var(--spacing-xs);
}

.score-value {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--text-primary);
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: var(--spacing-sm);
  justify-content: center;
}

.action-btn {
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.action-btn:hover {
  background: var(--bg-primary);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-icon {
  font-size: 1.25rem;
}

/* ========================================
   RESULTS SCREEN
   ======================================== */
.results-content {
  text-align: center;
}

.result-title {
  font-size: 2.5rem;
  margin-bottom: var(--spacing-xl);
  background: linear-gradient(135deg, var(--success), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Stats Section */
.stats-section,
.badges-section,
.skills-section {
  margin-bottom: var(--spacing-xl);
}

.stats-section h3,
.badges-section h3,
.skills-section h3 {
  font-size: 1.5rem;
  margin-bottom: var(--spacing-md);
  color: var(--primary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--spacing-sm);
}

.stat-card {
  background: var(--bg-tertiary);
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  display: block;
  margin-bottom: var(--spacing-xs);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: bold;
  color: var(--text-primary);
}

/* Badges */
.badges-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--spacing-sm);
}

.badge-item {
  background: var(--bg-tertiary);
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  text-align: left;
  animation: badgeAppear 0.5s ease;
}

@keyframes badgeAppear {
  from {
    transform: scale(0) rotate(-180deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

.badge-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.badge-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.badge-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.no-badges,
.no-skills {
  color: var(--text-secondary);
  font-style: italic;
}

/* Skills */
.skills-container {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.skill-item {
  background: var(--bg-tertiary);
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
}

.skill-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  margin-bottom: var(--spacing-xs);
}

.skill-icon {
  font-size: 1.25rem;
}

.skill-name {
  flex: 1;
  font-weight: 600;
  color: var(--text-primary);
}

.skill-level {
  font-size: 0.875rem;
  color: var(--primary);
  font-weight: 600;
}

.skill-progress {
  width: 100%;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: var(--spacing-xs);
}

.skill-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 4px;
  transition: width var(--transition-slow);
}

.skill-points {
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-align: right;
}

/* Results Buttons */
.results-buttons {
  display: flex;
  gap: var(--spacing-sm);
  justify-content: center;
}

.result-btn {
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.result-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.result-btn.primary {
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--primary-dark) 100%
  );
  border-color: var(--primary);
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Tablet */
@media (max-width: 768px) {
  .game-container {
    max-width: 600px;
  }

  .screen {
    padding: var(--spacing-lg);
    min-height: 500px;
  }

  .game-title {
    font-size: 2.5rem;
  }

  .difficulty-buttons {
    grid-template-columns: 1fr;
  }

  .board {
    max-width: 350px;
  }

  .cell {
    font-size: 3rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .game-info {
    flex-direction: column;
    gap: var(--spacing-xs);
  }
}

/* Mobile */
@media (max-width: 480px) {
  .game-container {
    max-width: 100%;
  }

  .screen {
    padding: var(--spacing-md);
    min-height: auto;
  }

  .game-title {
    font-size: 2rem;
  }

  .game-title .icon {
    font-size: 1.75rem;
  }

  .board {
    max-width: 300px;
    padding: var(--spacing-sm);
    gap: var(--spacing-xs);
  }

  .cell {
    font-size: 2.5rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .results-buttons {
    flex-direction: column;
  }

  .result-btn {
    width: 100%;
  }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */
button:focus,
.cell:focus {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
  :root {
    --border: #ffffff;
  }

  .cell {
    border-width: 3px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
