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

:root {
  --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --canvas-bg: #f0f4f8;
  --text-dark: #2d3748;
  --text-light: #ffffff;
  --primary-color: #667eea;
  --secondary-color: #764ba2;
  --success-color: #48bb78;
  --danger-color: #f56565;
  --card-bg: #ffffff;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.2);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg-gradient);
  color: var(--text-dark);
  min-height: 100vh;
  padding: 20px;
}

.game-wrapper {
  max-width: 1200px;
  margin: 0 auto;
}

.page-title {
  text-align: center;
  color: var(--text-light);
  font-size: 48px;
  font-weight: 700;
  margin-bottom: 30px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Game Container */
.game-container {
  position: relative;
  background: var(--card-bg);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  margin-bottom: 40px;
}

/* HUD */
.hud {
  display: flex;
  justify-content: space-between;
  padding: 20px 30px;
  background: linear-gradient(180deg, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.8) 100%);
  border-bottom: 2px solid #e2e8f0;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.hud-item .label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: #718096;
  letter-spacing: 0.5px;
}

.hud-item .value {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary-color);
}

/* Canvas */
#game-canvas {
  display: block;
  width: 100%;
  height: 400px;
  background: var(--canvas-bg);
  cursor: pointer;
}

/* Game Info Overlay */
.game-info {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  background: rgba(255, 255, 255, 0.95);
  padding: 40px 50px;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  z-index: 10;
}

.game-info.hidden {
  display: none;
}

.game-info h1 {
  font-size: 36px;
  margin-bottom: 20px;
  color: var(--primary-color);
}

.game-info .instructions {
  margin: 10px 0;
  font-size: 16px;
  color: var(--text-dark);
}

.game-info kbd {
  background: #e2e8f0;
  padding: 4px 8px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 14px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.game-info .next-unlock {
  margin-top: 20px;
  font-size: 14px;
  color: #718096;
}

.game-info .next-unlock span {
  font-weight: 700;
  color: var(--success-color);
}

.start-btn {
  margin-top: 25px;
  padding: 15px 40px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-light);
  background: var(--primary-color);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

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

/* Game Over Overlay */
.game-over {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  background: rgba(255, 255, 255, 0.98);
  padding: 40px 50px;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  z-index: 10;
  min-width: 350px;
}

.game-over.hidden {
  display: none;
}

.game-over h2 {
  font-size: 32px;
  color: var(--danger-color);
  margin-bottom: 25px;
}

.stats {
  margin: 20px 0;
}

.stat {
  font-size: 18px;
  margin: 12px 0;
  color: var(--text-dark);
}

.stat span {
  font-weight: 700;
  color: var(--primary-color);
}

.game-over-buttons {
  display: flex;
  gap: 15px;
  margin-top: 25px;
  justify-content: center;
}

.btn {
  padding: 12px 30px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn.primary {
  color: var(--text-light);
  background: var(--primary-color);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn.secondary {
  color: var(--primary-color);
  background: #e2e8f0;
}

.btn.secondary:hover {
  background: #cbd5e0;
}

/* Gallery Container */
.gallery-container {
  background: var(--card-bg);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 30px;
}

.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  flex-wrap: wrap;
  gap: 15px;
}

.gallery-header h2 {
  font-size: 28px;
  color: var(--text-dark);
}

.gallery-progress {
  font-size: 18px;
  color: #718096;
}

.gallery-progress span {
  font-weight: 700;
  color: var(--primary-color);
}

.gallery-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.cheat-btn {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--danger-color);
  background: transparent;
  border: 2px solid var(--danger-color);
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.cheat-btn:hover {
  background: var(--danger-color);
  color: var(--text-light);
}

.reset-btn {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--danger-color);
  background: transparent;
  border: 2px solid var(--danger-color);
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.reset-btn:hover {
  background: var(--danger-color);
  color: var(--text-light);
}

/* Gallery Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: var(--shadow);
}

.gallery-item:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-item.locked img {
  filter: blur(10px) grayscale(100%);
}

.gallery-item .lock-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
}

.gallery-item .lock-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.gallery-item .lock-text {
  font-size: 14px;
  font-weight: 600;
}

.gallery-item .unlock-badge {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: var(--success-color);
  color: var(--text-light);
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.gallery-item.new-unlock {
  animation: glowPulse 2s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% {
    box-shadow: 0 0 20px rgba(72, 187, 120, 0.6);
  }
  50% {
    box-shadow: 0 0 40px rgba(72, 187, 120, 1);
  }
}

/* Photo Modal */
.photo-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.photo-modal.hidden {
  display: none;
}

.modal-image {
  max-width: 90%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
}

.close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: var(--text-light);
  font-size: 36px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: var(--text-light);
  font-size: 36px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.nav-btn.prev {
  left: 20px;
}

.nav-btn.next {
  right: 20px;
}

.photo-info {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.9);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dark);
}

/* Responsive Design */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .hud {
    padding: 15px 20px;
  }

  .hud-item .value {
    font-size: 20px;
  }

  #game-canvas {
    height: 300px;
  }

  .game-info,
  .game-over {
    padding: 30px 25px;
    min-width: auto;
    max-width: 90%;
  }

  .game-info h1 {
    font-size: 28px;
  }

  .gallery-container {
    padding: 20px;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
  }

  .gallery-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .unlock-preview {
    width: 150px;
    height: 150px;
  }

  .nav-btn {
    width: 40px;
    height: 40px;
    font-size: 24px;
  }
}

@media (max-width: 480px) {
  .hud {
    padding: 10px 15px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .hud-item .label {
    font-size: 10px;
  }

  .hud-item .value {
    font-size: 18px;
  }

  #game-canvas {
    height: 250px;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
  }

  .game-over-buttons {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
