/**
 * MindGrid Memory Challenge - Styles
 * 
 * Professional, pastel-themed design with smooth animations
 * matching the website's green color scheme with indigo accents.
 */

/* ============================================
   Container & Layout
   ============================================ */

.mindgrid-container {
  min-height: calc(100vh - 80px);
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  position: relative;
  overflow: hidden;
}

.mindgrid-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%236366f1' fill-opacity='0.03'%3E%3Crect x='0' y='0' width='20' height='20' rx='4'/%3E%3Crect x='40' y='40' width='20' height='20' rx='4'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

/* ============================================
   Screen Management
   ============================================ */

.screen {
  display: none;
  height: 100%;
  min-height: calc(100vh - 80px);
}

.screen.active {
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   Setup Screen
   ============================================ */

#setup-screen {
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.setup-content {
  text-align: center;
  max-width: 450px;
  position: relative;
  z-index: 1;
}

.setup-icon-wrapper {
  width: 120px;
  height: 120px;
  margin: 0 auto 1.5rem;
  background: linear-gradient(135deg, #c7d2fe 0%, #e0e7ff 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 40px rgba(99, 102, 241, 0.2);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.setup-icon {
  font-size: 4rem;
}

.setup-title {
  font-size: 3.5rem;
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

.setup-description {
  font-size: 1.15rem;
  color: #64748b;
  line-height: 1.7;
  margin-bottom: 2.5rem;
}

/* Duration Selector */
.duration-selector {
  margin-bottom: 2.5rem;
}

.duration-label {
  display: block;
  color: #475569;
  font-weight: 600;
  margin-bottom: 1rem;
  font-size: 1rem;
}

.duration-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.duration-btn {
  padding: 1rem 1.5rem;
  font-size: 1.1rem;
  font-weight: 700;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  background: white;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s ease;
}

.duration-btn:hover {
  border-color: #c7d2fe;
  color: #6366f1;
  transform: translateY(-2px);
}

.duration-btn.active {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
  transform: scale(1.05);
}

/* Start Button */
.start-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.25rem 3rem;
  font-size: 1.3rem;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  border: none;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 10px 40px rgba(99, 102, 241, 0.4);
}

.start-btn:hover {
  transform: translateY(-4px);
  box-shadow: 0 15px 50px rgba(99, 102, 241, 0.5);
}

.start-btn:active {
  transform: translateY(-2px);
}

.play-icon {
  width: 24px;
  height: 24px;
}

/* ============================================
   Game Screen - HUD
   ============================================ */

#game-screen {
  background: #f8fafc;
}

.game-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: white;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.hud-item {
  display: flex;
  flex-direction: column;
}

.hud-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.25rem;
}

.hud-value {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 1.25rem;
  font-weight: 700;
  font-family: 'SF Mono', 'Roboto Mono', monospace;
}

.hud-value.timer {
  color: #334155;
}

.hud-value.timer.warning {
  color: #ef4444;
  animation: timerPulse 0.5s ease-in-out infinite;
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.timer-icon, .level-icon {
  width: 16px;
  height: 16px;
}

.hud-value.level {
  color: #6366f1;
}

.hud-divider {
  width: 1px;
  height: 32px;
  background: #e2e8f0;
}

.hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.score-display {
  font-size: 1.75rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
}

/* ============================================
   Game Board
   ============================================ */

.game-board-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.phase-badge {
  padding: 0.5rem 1.25rem;
  border-radius: 100px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 1.5rem;
  min-height: 32px;
}

.phase-badge.memorize {
  background: #e0e7ff;
  color: #4338ca;
  animation: phasePulse 1s ease-in-out infinite;
}

.phase-badge.recall {
  background: #d1fae5;
  color: #047857;
}

@keyframes phasePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.02); }
}

.game-grid {
  display: grid;
  gap: 0.75rem;
  width: 100%;
  max-width: 450px;
  aspect-ratio: 1;
  padding: 1.5rem;
  background: white;
  border-radius: 24px;
  box-shadow: 
    0 25px 50px -12px rgba(99, 102, 241, 0.15),
    0 0 0 1px rgba(226, 232, 240, 0.8);
}

/* Grid Cells */
.grid-cell {
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  transform-origin: center;
}

.grid-cell.idle {
  background: #e2e8f0;
}

.grid-cell.idle:hover {
  background: #cbd5e1;
  transform: scale(1.02);
}

.grid-cell.idle:active {
  transform: scale(0.95);
}

.grid-cell.highlight {
  background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
  animation: cellGlow 0.8s ease-in-out infinite alternate;
}

@keyframes cellGlow {
  from {
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
  }
  to {
    box-shadow: 0 0 25px rgba(99, 102, 241, 0.7);
  }
}

.grid-cell.correct {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.5);
  animation: correctPop 0.3s ease;
}

@keyframes correctPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.grid-cell.wrong {
  background: linear-gradient(135deg, #fb7185 0%, #f43f5e 100%);
  box-shadow: 0 0 20px rgba(244, 63, 94, 0.5);
  animation: wrongShake 0.4s ease;
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-5px); }
}

/* ============================================
   Game Over Screen
   ============================================ */

#gameover-screen {
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.gameover-content {
  text-align: center;
  max-width: 400px;
  position: relative;
  z-index: 1;
}

.trophy-icon {
  font-size: 6rem;
  margin-bottom: 1rem;
  filter: drop-shadow(0 8px 16px rgba(250, 204, 21, 0.3));
  animation: trophyBounce 0.6s ease;
}

@keyframes trophyBounce {
  0% { transform: scale(0) rotate(-10deg); }
  50% { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1) rotate(0); }
}

.gameover-title {
  font-size: 2.5rem;
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 2rem;
}

.results-card {
  background: white;
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 20px 50px rgba(99, 102, 241, 0.15);
  margin-bottom: 1.5rem;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
}

.result-label {
  font-size: 1.1rem;
  color: #64748b;
}

.result-value {
  font-weight: 800;
}

.result-value.score {
  font-size: 2.5rem;
  color: #6366f1;
}

.result-value.level {
  font-size: 1.75rem;
  color: #10b981;
}

.result-divider {
  height: 1px;
  background: #e2e8f0;
  margin: 0.5rem 0;
}

/* Save Status */
.save-status {
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  min-height: 24px;
}

.save-status .saving {
  color: #6366f1;
}

.save-status .saved {
  color: #10b981;
  font-weight: 600;
}

.save-status .not-saved {
  color: #94a3b8;
}

/* Action Buttons */
.gameover-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.play-again-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem 2.5rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
  background: #0f172a;
  border: none;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.3);
}

.play-again-btn:hover {
  background: #1e293b;
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.4);
}

.refresh-icon {
  width: 20px;
  height: 20px;
}

.progress-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  border: none;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.3);
}

/* ==========================================================================
   MINDGRID DARK MODE
   ========================================================================== */
html[data-theme="dark"] #game-screen {
  background: #13131f;
}

html[data-theme="dark"] .game-hud {
  background: #1e1e32;
  border-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .game-grid {
  background: #1e1e32;
  border-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .duration-btn {
  background: #1f1f35;
  color: #f1f5f9;
  border-color: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .duration-btn:hover,
html[data-theme="dark"] .duration-btn.active {
  background: rgba(99, 102, 241, 0.2);
  border-color: #6366f1;
}

html[data-theme="dark"] .results-card {
  background: #1e1e32;
  border-color: rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
}

html[data-theme="dark"] .results-card h2,
html[data-theme="dark"] .results-card h3 {
  color: #f1f5f9;
}

html[data-theme="dark"] .results-card p {
  color: #cbd5e1;
}

html[data-theme="dark"] .stat-box {
  background: #1f1f35;
  border-color: rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .stat-box .label {
  color: #94a3b8;
}

html[data-theme="dark"] .stat-box .value {
  color: #f1f5f9;
}

.progress-btn:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(99, 102, 241, 0.4);
  color: white;
}

.progress-btn svg {
  width: 18px;
  height: 18px;
}

.back-btn {
  color: #64748b;
  font-size: 0.95rem;
  text-decoration: none;
  transition: color 0.2s ease;
}

.back-btn:hover {
  color: #6366f1;
}

/* ============================================
   Responsive Styles
   ============================================ */

@media (max-width: 640px) {
  .setup-title {
    font-size: 2.5rem;
  }
  
  .setup-icon-wrapper {
    width: 100px;
    height: 100px;
  }
  
  .setup-icon {
    font-size: 3rem;
  }
  
  .game-grid {
    max-width: 350px;
    padding: 1rem;
    gap: 0.5rem;
  }
  
  .grid-cell {
    border-radius: 12px;
  }
  
  .game-hud {
    padding: 0.75rem 1rem;
  }
  
  .hud-value {
    font-size: 1.1rem;
  }
  
  .score-display {
    font-size: 1.4rem;
  }
  
  .gameover-title {
    font-size: 2rem;
  }
  
  .trophy-icon {
    font-size: 4rem;
  }
  
  .result-value.score {
    font-size: 2rem;
  }
}

@media (max-width: 400px) {
  .duration-options {
    grid-template-columns: 1fr;
  }
  
  .game-grid {
    max-width: 300px;
  }
}
