/**
 * Pattern Memory Pro - Gaming Styles
 * Purple/Pink gradient theme for memory game
 */

/* ============================================
   VARIABLES & RESET
   ============================================ */

:root {
  /* Color Palette - Purple/Pink Memory Theme */
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --accent-gradient: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
  --success-gradient: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
  
  /* Background */
  --bg-dark: #1a1a2e;
  --bg-card: rgba(255, 255, 255, 0.05);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  
  /* Text Colors */
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.8);
  --text-tertiary: rgba(255, 255, 255, 0.6);
  
  /* Tile Colors */
  --tile-red: #ff4757;
  --tile-red-active: #ff6b81;
  --tile-yellow: #feca57;
  --tile-yellow-active: #fee189;
  --tile-blue: #48dbfb;
  --tile-blue-active: #81ecff;
  --tile-green: #1dd1a1;
  --tile-green-active: #5fe4c3;
  
  /* UI Elements */
  --border-radius: 16px;
  --border-radius-sm: 8px;
  --transition-speed: 0.3s;
  --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 10px 25px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.3);
  
  /* Spacing */
  --spacing-xs: 8px;
  --spacing-sm: 16px;
  --spacing-md: 24px;
  --spacing-lg: 32px;
  --spacing-xl: 48px;
}

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

/* ============================================
   BODY & LAYOUT
   ============================================ */

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-sm);
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--primary-gradient);
  opacity: 0.1;
  z-index: 0;
  pointer-events: none;
}

/* Screen Reader Only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================
   SCREEN MANAGEMENT
   ============================================ */

.screen {
  display: none;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  animation: fadeIn 0.4s ease;
  position: relative;
  z-index: 1;
}

.screen.active {
  display: block;
}

.screen-content {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border-radius: var(--border-radius);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

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

/* ============================================
   GAME HEADER
   ============================================ */

.game-header {
  text-align: center;
  margin-bottom: var(--spacing-lg);
}

.game-title {
  font-size: 2.5rem;
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--spacing-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
}

.title-icon {
  font-size: 3rem;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

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

/* ============================================
   MENU SECTIONS
   ============================================ */

.menu-section {
  margin-bottom: var(--spacing-lg);
}

.section-title {
  font-size: 1.3rem;
  margin-bottom: var(--spacing-sm);
  color: var(--text-secondary);
  font-weight: 600;
  text-align: center;
}

/* Mode Selection Grid */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.mode-btn {
  background: var(--bg-card);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius-sm);
  padding: var(--spacing-md) var(--spacing-sm);
  cursor: pointer;
  transition: all var(--transition-speed);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-xs);
  color: var(--text-primary);
  font-family: inherit;
}

.mode-btn:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.mode-btn.active {
  background: var(--primary-gradient);
  border-color: transparent;
  box-shadow: 0 0 20px rgba(102, 126, 234, 0.5);
}

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

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

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

.mode-btn.active .mode-desc {
  color: var(--text-secondary);
}

/* Speed Selection Grid */
.speed-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-sm);
}

.speed-btn {
  background: var(--bg-card);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius-sm);
  padding: var(--spacing-md);
  cursor: pointer;
  transition: all var(--transition-speed);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-xs);
  color: var(--text-primary);
  font-family: inherit;
}

.speed-btn:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.speed-btn.active {
  background: var(--secondary-gradient);
  border-color: transparent;
  box-shadow: 0 0 20px rgba(240, 147, 251, 0.5);
}

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

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

/* High Score Display */
.high-score-display {
  text-align: center;
  padding: var(--spacing-md);
  background: var(--bg-card);
  border-radius: var(--border-radius-sm);
  margin-bottom: var(--spacing-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.high-score-label {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-right: var(--spacing-xs);
}

.high-score-value {
  font-size: 2rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Instructions */
.instructions {
  margin-top: var(--spacing-lg);
  padding: var(--spacing-md);
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--border-radius-sm);
  border-left: 4px solid #667eea;
}

.instructions p {
  margin-bottom: var(--spacing-xs);
  color: var(--text-secondary);
  line-height: 1.6;
}

.instructions p:last-child {
  margin-bottom: 0;
}

.instructions strong {
  color: var(--text-primary);
}

.instructions kbd {
  display: inline-block;
  padding: 4px 8px;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9rem;
  margin: 0 2px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ============================================
   BUTTONS
   ============================================ */

.primary-btn,
.secondary-btn {
  width: 100%;
  padding: var(--spacing-md);
  font-size: 1.2rem;
  font-weight: 600;
  border: none;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all var(--transition-speed);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  font-family: inherit;
  box-shadow: var(--shadow-sm);
}

.primary-btn {
  background: var(--primary-gradient);
  color: var(--text-primary);
}

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

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

.secondary-btn {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.secondary-btn:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-2px);
}

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

.button-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

/* ============================================
   GAME HUD
   ============================================ */

.game-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
  padding: var(--spacing-md);
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--border-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.score-display {
  display: flex;
  align-items: baseline;
  gap: var(--spacing-xs);
}

.score-label {
  font-size: 1rem;
  color: var(--text-secondary);
}

.score-value {
  font-size: 2rem;
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.lives-display {
  display: flex;
  gap: var(--spacing-xs);
}

.life-icon {
  font-size: 1.5rem;
  transition: all var(--transition-speed);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.life-icon.active {
  animation: heartBeat 1.5s ease infinite;
}

@keyframes heartBeat {
  0%, 100% {
    transform: scale(1);
  }
  10% {
    transform: scale(1.1);
  }
  20% {
    transform: scale(1);
  }
}

/* ============================================
   TURN MESSAGE
   ============================================ */

.turn-message-container {
  text-align: center;
  margin-bottom: var(--spacing-lg);
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.turn-message {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
  padding: var(--spacing-md);
  background: var(--bg-card);
  border-radius: var(--border-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: pulse 2s ease infinite;
}

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

/* ============================================
   GAME TILES
   ============================================ */

.tiles-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-md);
  max-width: 500px;
  margin: 0 auto;
}

.game-tile {
  aspect-ratio: 1;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  background: var(--tile-color);
  position: relative;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  overflow: hidden;
}

.game-tile::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.game-tile:hover::before {
  opacity: 1;
}

.game-tile.disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.game-tile.active {
  background: var(--tile-active-color);
  transform: scale(0.95);
  box-shadow: 0 0 30px var(--tile-active-color);
}

.game-tile.success {
  animation: successFlash 0.3s ease;
}

@keyframes successFlash {
  0%, 100% {
    background: var(--tile-color);
  }
  50% {
    background: var(--tile-active-color);
    box-shadow: 0 0 40px var(--tile-active-color);
  }
}

.game-tile.error {
  animation: errorShake 0.5s ease;
  background: #ff4757 !important;
}

@keyframes errorShake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-10px);
  }
  75% {
    transform: translateX(10px);
  }
}

.tile-symbol {
  font-size: 4rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  margin-bottom: var(--spacing-sm);
}

.tile-key {
  position: absolute;
  bottom: var(--spacing-sm);
  right: var(--spacing-sm);
  background: rgba(0, 0, 0, 0.3);
  color: white;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ============================================
   GAME OVER SCREEN
   ============================================ */

.result-card {
  text-align: center;
  padding: var(--spacing-xl);
  background: var(--bg-card);
  border-radius: var(--border-radius);
  margin-bottom: var(--spacing-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.result-label {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-sm);
}

.result-value {
  font-size: 4rem;
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--spacing-md);
}

.high-score-badge {
  display: inline-block;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--accent-gradient);
  color: var(--text-primary);
  border-radius: var(--border-radius-sm);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: var(--spacing-md);
  animation: bounceIn 0.5s ease;
  box-shadow: 0 0 20px rgba(254, 225, 64, 0.5);
}

@keyframes bounceIn {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.encouragement {
  font-size: 1.2rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* ============================================
   REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .game-tile.active {
    border: 3px solid white;
  }
}

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

@media (max-width: 768px) {
  .game-title {
    font-size: 2rem;
  }
  
  .mode-grid {
    grid-template-columns: 1fr;
  }
  
  .speed-grid {
    grid-template-columns: 1fr;
  }
  
  .tiles-container {
    max-width: 100%;
    gap: var(--spacing-sm);
  }
  
  .tile-symbol {
    font-size: 3rem;
  }
  
  .result-value {
    font-size: 3rem;
  }
}

@media (max-width: 480px) {
  .screen-content {
    padding: var(--spacing-md);
  }
  
  .game-title {
    font-size: 1.5rem;
  }
  
  .title-icon {
    font-size: 2rem;
  }
  
  .tiles-container {
    gap: var(--spacing-xs);
  }
  
  .tile-symbol {
    font-size: 2.5rem;
  }
}

/* ============================================
   FOCUS STYLES (Accessibility)
   ============================================ */

button:focus-visible,
.game-tile:focus-visible {
  outline: 3px solid #667eea;
  outline-offset: 4px;
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  body::before {
    display: none;
  }
  
  .screen-content {
    box-shadow: none;
    border: 1px solid #000;
  }
}
