/* ==========================================================================
   Memory Match Game Styles
   ========================================================================== */

:root {
  --primary-color: #8b5cf6;
  --secondary-color: #06b6d4;
  --background-color: #0f172a;
  --surface-color: #1e293b;
  --card-back-color: #3b82f6;
  --card-front-color: #ffffff;
  --text-color: #f8fafc;
  --text-muted: #94a3b8;
  --success-color: #22c55e;
  --gold-color: #fbbf24;
  --matched-color: #22c55e;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--background-color);
  color: var(--text-color);
}

#game-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* ==========================================================================
   Screens
   ========================================================================== */

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.screen.active {
  display: flex;
  opacity: 1;
}

/* ==========================================================================
   Title Screen
   ========================================================================== */

.title-content {
  text-align: center;
  max-width: 400px;
}

.title-content h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}

.title-content p {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

.difficulty-select {
  margin-bottom: 1.5rem;
}

.difficulty-select span {
  display: block;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.difficulty-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.difficulty-btn {
  background: var(--surface-color);
  color: var(--text-color);
  border: 2px solid transparent;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.difficulty-btn:hover {
  border-color: var(--primary-color);
}

.difficulty-btn.active {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  border-color: transparent;
}

.prize-info {
  background: var(--surface-color);
  padding: 12px 20px;
  border-radius: 10px;
  margin-bottom: 1.5rem;
  color: var(--gold-color);
}

/* ==========================================================================
   Game Screen
   ========================================================================== */

#game-screen {
  justify-content: space-between;
  padding: 15px;
}

.game-header {
  display: flex;
  justify-content: center;
  gap: 20px;
  width: 100%;
  max-width: 500px;
  margin-bottom: 10px;
}

.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface-color);
  padding: 8px 20px;
  border-radius: 10px;
  min-width: 80px;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-color);
}

/* ==========================================================================
   Game Board
   ========================================================================== */

.game-board {
  display: grid;
  gap: 8px;
  padding: 10px;
  max-width: 500px;
  width: 100%;
  flex: 1;
  align-content: center;
}

.game-board.easy {
  grid-template-columns: repeat(4, 1fr);
}

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

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

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  aspect-ratio: 1;
  perspective: 1000px;
  cursor: pointer;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s;
  transform-style: preserve-3d;
  border-radius: 12px;
}

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

.card.matched .card-inner {
  transform: rotateY(180deg);
  box-shadow: 0 0 20px var(--matched-color);
}

.card.matched .card-back {
  background: var(--matched-color);
}

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.card-back {
  background: linear-gradient(135deg, var(--card-back-color), var(--primary-color));
  color: white;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.card-back::before {
  content: '?';
  font-size: 2rem;
  font-weight: bold;
  opacity: 0.8;
}

.card-front {
  background: var(--card-front-color);
  transform: rotateY(180deg);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.card-front img {
  width: 70%;
  height: 70%;
  object-fit: contain;
}

.card-front .card-emoji {
  font-size: 2.5rem;
}

.card:active:not(.matched):not(.flipped) .card-inner {
  transform: scale(0.95);
}

.game-footer {
  text-align: center;
  margin-top: 10px;
}

#game-hint {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ==========================================================================
   Result Screen
   ========================================================================== */

.result-content {
  text-align: center;
  max-width: 400px;
}

.result-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: bounce 0.6s ease;
}

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

.result-content h2 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
  color: var(--gold-color);
}

.stats-summary {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 1.5rem;
}

.final-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface-color);
  padding: 15px 20px;
  border-radius: 12px;
  min-width: 80px;
}

.final-stat span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.final-stat strong {
  font-size: 1.5rem;
  color: var(--text-color);
}

.prize-section {
  background: var(--surface-color);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.prize-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 1rem;
}

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

.prize-name {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold-color), #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.prize-code span {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.discount-code {
  font-size: 1.25rem;
  font-weight: 700;
  font-family: monospace;
  letter-spacing: 2px;
  margin: 0.5rem 0;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  border: none;
  padding: 14px 32px;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 30px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  width: 100%;
  max-width: 280px;
}

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

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 2px solid var(--surface-color);
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 0.5rem;
}

.btn-secondary:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* ==========================================================================
   Overlay
   ========================================================================== */

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.overlay.hidden {
  display: none;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--surface-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Animations
   ========================================================================== */

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

.card.wrong .card-inner {
  animation: shake 0.3s ease;
}

@keyframes match-pulse {
  0% { transform: rotateY(180deg) scale(1); }
  50% { transform: rotateY(180deg) scale(1.1); }
  100% { transform: rotateY(180deg) scale(1); }
}

.card.matched .card-inner {
  animation: match-pulse 0.3s ease;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 400px) {
  .game-board {
    gap: 6px;
  }
  
  .card-face {
    font-size: 1.5rem;
  }
  
  .card-front .card-emoji {
    font-size: 2rem;
  }
  
  .stat-box {
    padding: 6px 12px;
    min-width: 60px;
  }
  
  .title-content h1 {
    font-size: 2rem;
  }
}

@media (min-height: 800px) {
  .game-board {
    max-width: 550px;
    gap: 10px;
  }
}
