/* ========================================
   GAME BOARD STYLES
   ======================================== */

.game-app-container {
  width: 100%;
  max-width: 1000px;
  margin: 2rem auto;
  padding: 1.5rem;
  background-color: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(71, 85, 105, 0.3);
  border-radius: 1rem;
  backdrop-filter: blur(10px);
}

.game-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3rem 1rem;
  min-height: 400px;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(129, 140, 248, 0.2);
  border-top-color: #818cf8;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.game-loading p {
  color: #cbd5e1;
  font-size: 1rem;
  margin: 0;
}

/* ========================================
   GAME BOARD CONTAINER
   ======================================== */

.game-board-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 1.5rem;
}

.game-board {
  position: relative;
  width: 100%;
  max-width: 1000px;
  height: 70vh;
  min-height: 400px;
  max-height: 1000px;
  background-color: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(71, 85, 105, 0.5);
  border-radius: 1rem;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* ========================================
   PUZZLE PIECES
   ======================================== */

.puzzle-piece {
  position: absolute;
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: filter 150ms ease-in-out;
}

.puzzle-piece:active {
  cursor: grabbing;
}

.puzzle-piece:hover {
  filter: brightness(1.1) drop-shadow(0 0 10px rgba(129, 140, 248, 0.5));
}

.puzzle-piece.solved {
  cursor: default;
  filter: drop-shadow(0 0 5px rgba(16, 185, 129, 0.3));
}

.puzzle-piece svg {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}

/* ========================================
   GAME HUD (HEADS-UP DISPLAY)
   ======================================== */

.game-hud {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  z-index: 50;
}

.timer-display {
  background-color: rgba(15, 23, 42, 0.8);
  color: #cbd5e1;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(71, 85, 105, 0.3);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.timer-icon {
  width: 16px;
  height: 16px;
  color: #818cf8;
}

.reset-button {
  background-color: rgba(71, 85, 105, 0.5);
  color: white;
  border: none;
  padding: 0.5rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 200ms ease-in-out;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.reset-button:hover {
  background-color: rgba(100, 116, 139, 0.7);
  transform: rotate(90deg);
}

.reset-button svg {
  width: 20px;
  height: 20px;
}

/* ========================================
   GAME INSTRUCTIONS
   ======================================== */

.game-instructions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  color: #94a3b8;
  font-size: 0.875rem;
  user-select: none;
}

.instructions-icon {
  width: 16px;
  height: 16px;
}

/* ========================================
   GAME STATE SCREENS
   ======================================== */

/* Input Screen */
.game-input-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  width: 100%;
  max-width: 600px;
  margin: 2rem auto;
  animation: slideInUp 0.5s ease-in-out;
}

.game-input-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.game-input-header h2 {
  font-size: 2rem;
  margin: 0;
  color: #e2e8f0;
}

.game-input-header p {
  margin: 0;
  color: #94a3b8;
  font-size: 1rem;
}

.game-input-form {
  width: 100%;
  background-color: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(71, 85, 105, 0.3);
  border-radius: 1rem;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input {
  padding: 0.75rem 1rem;
  background-color: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(71, 85, 105, 0.5);
  border-radius: 0.75rem;
  color: #e2e8f0;
  font-size: 1rem;
  transition: all 200ms ease-in-out;
}

.form-group input:focus {
  outline: none;
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.1);
}

.form-group input::placeholder {
  color: #64748b;
}

.difficulty-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 0.75rem;
}

.difficulty-button {
  padding: 0.75rem;
  background-color: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(71, 85, 105, 0.5);
  border-radius: 0.75rem;
  color: #94a3b8;
  cursor: pointer;
  transition: all 200ms ease-in-out;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  text-align: center;
}

.difficulty-button:hover {
  border-color: #818cf8;
  background-color: rgba(129, 140, 248, 0.1);
}

.difficulty-button.active {
  background-color: #6366f1;
  border-color: #818cf8;
  color: white;
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
  transform: scale(1.05);
}

.difficulty-label {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.difficulty-size {
  font-size: 1.25rem;
  font-weight: 700;
}

.difficulty-pieces {
  font-size: 0.625rem;
  color: inherit;
  opacity: 0.8;
}

.error-message {
  padding: 0.75rem;
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.5);
  border-radius: 0.75rem;
  color: #fca5a5;
  font-size: 0.875rem;
}

.generate-button {
  width: 100%;
  padding: 1rem;
  background-color: #6366f1;
  color: white;
  border: none;
  border-radius: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 200ms ease-in-out;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.generate-button:hover:not(:disabled) {
  background-color: #4f46e5;
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.5);
  transform: translateY(-2px);
}

.generate-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Generating Screen */
.game-generating-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  min-height: 400px;
  animation: fadeIn 0.5s ease-in-out;
}

.generating-spinner {
  position: relative;
  width: 100px;
  height: 100px;
}

.generating-spinner::before {
  content: '';
  position: absolute;
  inset: 0;
  background-color: rgba(99, 102, 241, 0.2);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

.generating-spinner::after {
  content: '';
  position: absolute;
  inset: 1.5rem;
  background-color: rgba(30, 41, 59, 0.8);
  border: 3px solid rgba(71, 85, 105, 0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.generating-icon {
  position: absolute;
  inset: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: spin 1s linear infinite;
}

.generating-icon svg {
  width: 40px;
  height: 40px;
  color: #818cf8;
}

.generating-text {
  font-size: 1.125rem;
  color: #cbd5e1;
  text-align: center;
}

/* Victory Screen */
.game-victory-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  text-align: center;
  animation: zoomIn 0.5s ease-in-out;
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.trophy-icon {
  width: 100px;
  height: 100px;
  padding: 1rem;
  background-color: rgba(251, 191, 36, 0.1);
  border: 2px solid rgba(251, 191, 36, 0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 50px rgba(251, 191, 36, 0.2);
}

.trophy-icon svg {
  width: 60px;
  height: 60px;
  color: #fbbf24;
}

.victory-title {
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
  color: #e2e8f0;
}

.victory-time {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 1.25rem;
  font-weight: 600;
  color: #818cf8;
}

.victory-time svg {
  width: 20px;
  height: 20px;
}

.victory-prompt {
  color: #94a3b8;
  font-size: 1rem;
  margin: 0;
}

.victory-image {
  width: 100%;
  max-width: 300px;
  height: 300px;
  border: 4px solid rgba(99, 102, 241, 0.3);
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.victory-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.victory-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}

.victory-button {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 200ms ease-in-out;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.victory-button.share {
  background-color: #10b981;
  color: white;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.victory-button.share:hover {
  background-color: #059669;
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.5);
}

.victory-button.replay {
  background-color: rgba(30, 41, 59, 0.8);
  color: #e2e8f0;
  border: 1px solid rgba(71, 85, 105, 0.5);
}

.victory-button.replay:hover {
  background-color: rgba(51, 65, 85, 0.8);
  border-color: #818cf8;
}

.victory-button.new {
  background-color: #6366f1;
  color: white;
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.victory-button.new:hover {
  background-color: #4f46e5;
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.5);
}

/* ========================================
   ANIMATIONS
   ======================================== */

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

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

/* ========================================
   RESPONSIVE GAME BOARD
   ======================================== */

@media (max-width: 768px) {
  .game-board {
    height: 60vh;
    min-height: 300px;
  }

  .game-input-screen {
    margin: 1rem auto;
  }

  .game-input-form {
    padding: 1rem;
  }

  .difficulty-selector {
    grid-template-columns: repeat(3, 1fr);
  }

  .difficulty-button {
    padding: 0.5rem;
    font-size: 0.75rem;
  }

  .difficulty-size {
    font-size: 1rem;
  }

  .victory-image {
    max-width: 250px;
    height: 250px;
  }

  .victory-actions {
    flex-direction: column;
    width: 100%;
  }

  .victory-button {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .game-app-container {
    padding: 1rem;
    margin: 1rem auto;
  }

  .game-board {
    height: 50vh;
    min-height: 250px;
  }

  .game-input-header h2 {
    font-size: 1.5rem;
  }

  .difficulty-selector {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .difficulty-button {
    padding: 0.5rem;
  }

  .victory-title {
    font-size: 1.5rem;
  }

  .victory-image {
    max-width: 200px;
    height: 200px;
  }

  .timer-display {
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
  }

  .reset-button {
    padding: 0.375rem;
  }

  .reset-button svg {
    width: 16px;
    height: 16px;
  }
}
