/* Memory Pro - Professional Edition */
:root {
  /* Color Palette */
  --primary-gradient: linear-gradient(135deg, #8b5cf6 0%, #a855f7 50%, #c084fc 100%);
  --secondary-gradient: linear-gradient(135deg, #06b6d4 0%, #0891b2 50%, #0e7490 100%);
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
  
  /* Game Colors */
  --player-1: #8b5cf6;
  --player-1-glow: rgba(139, 92, 246, 0.3);
  --player-2: #06b6d4;
  --player-2-glow: rgba(6, 182, 212, 0.3);
  
  /* Card Colors */
  --card-back: linear-gradient(145deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  --card-front: #ffffff;
  --card-shadow: rgba(139, 92, 246, 0.2);
  --card-hover: rgba(139, 92, 246, 0.1);
  --card-matched: linear-gradient(145deg, #10b981 0%, #059669 100%);
  
  /* UI Colors */
  --bg-primary: #0f0f23;
  --bg-secondary: #1a1a2e;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-hover: rgba(255, 255, 255, 0.1);
  --text-primary: #ffffff;
  --text-secondary: #a8a8b3;
  --border: rgba(255, 255, 255, 0.1);
  --shadow: rgba(0, 0, 0, 0.3);
  
  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  /* Animations */
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --flip-duration: 0.6s;
}

/* Reset & Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 25% 25%, #8b5cf620 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, #06b6d420 0%, transparent 50%);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-x: hidden;
}

/* App Container */
.app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  max-width: 900px;
  width: 100%;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 20px;
}

.header h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.header .subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  font-weight: 400;
}

/* Game Card */
.game-card {
  background: var(--surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: 
    0 20px 25px -5px var(--shadow),
    0 10px 10px -5px var(--shadow);
  width: 100%;
  transition: var(--transition);
}

.game-card:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 25px 50px -12px var(--shadow),
    0 20px 25px -5px var(--shadow);
}

/* Settings Panel */
.settings-panel {
  text-align: center;
}

.settings-panel h2 {
  margin-bottom: 32px;
  font-size: 1.5rem;
  color: var(--text-primary);
}

.setting-group {
  margin-bottom: 24px;
}

.setting-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.setting-group select {
  width: 100%;
  max-width: 300px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1rem;
  transition: var(--transition);
}

.setting-group select:focus {
  outline: none;
  border-color: var(--player-1);
  box-shadow: 0 0 0 2px var(--player-1-glow);
}

.player-names {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.player-name-input input {
  width: 100%;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1rem;
  transition: var(--transition);
}

.player-name-input input:focus {
  outline: none;
  border-color: var(--player-1);
  box-shadow: 0 0 0 2px var(--player-1-glow);
}

/* Score Board */
.score-board {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 20px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.player-score {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.player-score.active {
  transform: scale(1.05);
  filter: brightness(1.2);
}

.score-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: bold;
  color: white;
}

.score-avatar.p1 {
  background: var(--player-1);
  box-shadow: 0 0 20px var(--player-1-glow);
}

.score-avatar.p2 {
  background: var(--player-2);
  box-shadow: 0 0 20px var(--player-2-glow);
}

.score-info h3 {
  font-size: 1.2rem;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.score-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pairs-found, .percentage {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.pairs-value, .percentage-value {
  font-weight: bold;
  color: var(--text-primary);
}

.vs-separator {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--text-secondary);
  margin: 0 20px;
}

/* Game Status */
.game-status {
  text-align: center;
  margin-bottom: 24px;
}

.status-text {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.player-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-block;
}

.player-dot.p1 {
  background: var(--player-1);
  box-shadow: 0 0 8px var(--player-1-glow);
}

.player-dot.p2 {
  background: var(--player-2);
  box-shadow: 0 0 8px var(--player-2-glow);
}

.game-info {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
}

.game-info > div {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.game-info span {
  font-weight: bold;
  color: var(--text-primary);
}

/* Memory Board */
.memory-board-container {
  margin: 24px 0;
}

.memory-board {
  display: grid;
  gap: 12px;
  justify-content: center;
  max-width: 600px;
  margin: 0 auto;
}

/* Different grid sizes for different difficulties */
.memory-board.easy {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

.memory-board.medium {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
}

.memory-board.hard {
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(4, 1fr);
}

.memory-board.expert {
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
}

/* Memory Cards */
.memory-card {
  aspect-ratio: 1;
  background: var(--card-back);
  border-radius: var(--radius-md);
  cursor: pointer;
  position: relative;
  transition: var(--transition);
  transform-style: preserve-3d;
  min-height: 80px;
  border: 2px solid transparent;
  box-shadow: 0 4px 15px var(--card-shadow);
}

.memory-card:hover:not(.flipped):not(.matched) {
  transform: scale(1.05) rotateY(5deg);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 25px var(--card-shadow);
}

.memory-card.flipped {
  transform: rotateY(180deg);
}

.memory-card.matched {
  background: var(--card-matched);
  animation: matchedPulse 0.6s ease-in-out;
  cursor: default;
  border-color: var(--success-color);
}

.memory-card.hint {
  animation: hintPulse 0.8s ease-in-out;
  border-color: var(--warning-color);
  box-shadow: 0 0 20px var(--warning-color);
}

.memory-card .card-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
}

.memory-card .card-back {
  background: var(--card-back);
  color: white;
  font-weight: bold;
}

.memory-card .card-front {
  background: var(--card-front);
  color: #333;
  transform: rotateY(180deg);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Buttons */
.btn {
  background: var(--primary-gradient);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
  margin: 4px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--primary-gradient);
  font-size: 1.1rem;
  padding: 16px 32px;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn-secondary:hover {
  background: var(--surface-hover);
  box-shadow: 0 4px 15px var(--shadow);
}

/* Game Controls */
.game-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 24px;
}

/* Overlays */
.game-over-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.game-over-overlay.show {
  opacity: 1;
  visibility: visible;
}

.game-over-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  text-align: center;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 25px 50px -12px var(--shadow);
  transform: scale(0.9);
  transition: var(--transition);
}

.game-over-overlay.show .game-over-content {
  transform: scale(1);
}

.game-over-content h2 {
  margin-bottom: 24px;
  font-size: 2rem;
}

/* Final Stats */
.final-stats {
  margin: 24px 0;
  padding: 20px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 12px 0;
}

.stat-label {
  color: var(--text-secondary);
}

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

/* Settings Content */
.settings-content {
  margin: 20px 0;
  text-align: left;
}

.setting-item {
  margin: 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.setting-item label {
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.setting-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-left: auto;
}

/* Animations */
@keyframes matchedPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

@keyframes hintPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 4px 15px var(--card-shadow);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 25px var(--warning-color);
  }
}

@keyframes flipCard {
  0% {
    transform: rotateY(0deg);
  }
  50% {
    transform: rotateY(90deg);
  }
  100% {
    transform: rotateY(180deg);
  }
}

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

/* Animation Controls */
.no-animations *,
.no-animations *::before,
.no-animations *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

.no-animations .memory-card {
  transition: none !important;
  transform: none !important;
}

.no-animations .memory-card:hover {
  transform: none !important;
}

.no-animations .memory-card.matched {
  animation: none !important;
}

.no-animations .btn {
  transition: none !important;
}

.no-animations .btn:hover {
  transform: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
  .app {
    padding: 16px;
    gap: 16px;
  }
  
  .game-card {
    padding: 20px;
  }
  
  .memory-board {
    gap: 8px;
  }
  
  .memory-card {
    min-height: 60px;
  }
  
  .score-board {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }
  
  .vs-separator {
    margin: 0;
  }
  
  .player-names {
    grid-template-columns: 1fr;
  }
  
  .game-info {
    gap: 16px;
  }
  
  .header h1 {
    font-size: 2.5rem;
  }
}

@media (max-width: 480px) {
  .memory-board.hard,
  .memory-board.expert {
    gap: 6px;
  }
  
  .memory-card {
    min-height: 50px;
  }
  
  .memory-card .card-face {
    font-size: 1.2rem;
  }
  
  .game-controls {
    flex-direction: column;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
}

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

/* Focus States */
.memory-card:focus,
.btn:focus {
  outline: 2px solid var(--primary-gradient);
  outline-offset: 2px;
}

/* Loading State */
.loading {
  opacity: 0.7;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top: 2px solid var(--primary-gradient);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  transform: translate(-50%, -50%);
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}
