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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #4ac3b5 0%, #fecb56 100%);
  min-height: 100vh;
  color: #333;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  text-align: center;
  padding: 30px 20px;
  color: white;
}

.header h1 {
  font-size: 2rem;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.current-user {
  font-size: 1.1rem;
  opacity: 0.9;
  margin-bottom: 5px;
}

.progress {
  font-size: 1rem;
  opacity: 0.8;
  margin-bottom: 15px;
}

.share-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.5);
  padding: 10px 20px;
  border-radius: 25px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.share-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

/* Social Share Dropdown */
.share-dropdown {
  position: relative;
  display: inline-block;
}

.share-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  padding: 8px 0;
  min-width: 180px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 100;
  margin-top: 8px;
}

.share-dropdown.active .share-menu {
  opacity: 1;
  visibility: visible;
}

.share-menu a,
.share-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  color: #333;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s;
}

.share-menu a:hover,
.share-menu button:hover {
  background: #f5f5f5;
}

.share-icon {
  font-size: 1.2rem;
  width: 24px;
  text-align: center;
}

.header-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.logout-btn {
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 10px 20px;
  border-radius: 25px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.3s ease;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-color: rgba(255, 255, 255, 0.5);
}

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

@media (max-width: 480px) {
  .collection-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 10px;
  }
}

/* Card Styles */
.card {
  perspective: 1000px;
  height: 280px;
  cursor: pointer;
}

@media (max-width: 480px) {
  .card {
    height: 240px;
  }
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

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

.card-front,
.card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Card Front */
.card-front {
  background: white;
  display: flex;
  flex-direction: column;
}

.card-front img {
  width: 100%;
  height: calc(100%);
  object-fit: cover;
}

@media (max-width: 480px) {
  .card-front img {
    height: calc(100%);
  }
}

.card-title {
  padding: 8px 10px;
  text-align: center;
  font-weight: 600;
  font-size: 0.85rem;
  background: white;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}

@media (max-width: 480px) {
  .card-title {
    height: 45px;
    font-size: 0.75rem;
    padding: 6px 8px;
  }
}

/* Card Back */
.card-back {
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
  transform: rotateY(180deg);
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  overflow-y: auto;
}

.card-back h3 {
  font-size: 0.95rem;
  margin-bottom: 6px;
  color: #333;
}

.card-description {
  font-size: 0.75rem;
  color: #666;
  line-height: 1.3;
  margin-bottom: 8px;
}

@media (max-width: 480px) {
  .card-back {
    padding: 10px;
  }

  .card-back h3 {
    font-size: 0.85rem;
    margin-bottom: 4px;
  }

  .card-description {
    font-size: 0.7rem;
    line-height: 1.25;
    margin-bottom: 6px;
  }
}

.card-location {
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 15px;
}

.location-icon {
  font-size: 0.9rem;
}

.card-link {
  display: inline-block;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

@media (max-width: 480px) {
  .card-link {
    padding: 5px 10px;
    font-size: 0.7rem;
  }
}

.card-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Not Collected Cards (Mystery) */
.card.not-collected {
  cursor: default;
}

.card.not-collected .card-front.mystery {
  background: linear-gradient(135deg, #2c3e50 0%, #1a252f 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.mystery-overlay {
  font-size: 5rem;
  color: rgba(255, 255, 255, 0.3);
  font-weight: bold;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.card.not-collected .card-title {
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  position: absolute;
  bottom: 0;
  width: 100%;
}

/* Username Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: white;
  padding: 40px;
  border-radius: 16px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  transform: translateY(-20px);
  transition: transform 0.3s ease;
}

.modal.active .modal-content {
  transform: translateY(0);
}

.modal-content h2 {
  margin-bottom: 10px;
  color: #333;
}

.modal-content p {
  color: #666;
  margin-bottom: 20px;
  font-size: 0.95rem;
}

.modal-content input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 10px;
  transition: border-color 0.2s;
}

.modal-content input:focus {
  outline: none;
  border-color: #667eea;
}

.error-text {
  color: #e74c3c;
  font-size: 0.85rem;
  margin-bottom: 10px;
  display: none;
}

.modal-content button {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.modal-content button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.primary-btn {
  display: block;
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  text-decoration: none;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  margin-bottom: 10px;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  color: white;
}

.secondary-btn {
  display: block;
  width: 100%;
  padding: 12px;
  background: transparent;
  color: #667eea;
  text-decoration: none;
  border: 2px solid #667eea;
  border-radius: 8px;
  font-size: 1rem;
  text-align: center;
  transition: all 0.2s;
  margin-bottom: 10px;
}

.secondary-btn:hover {
  background: #667eea;
  color: white;
}

.text-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 10px;
  width: 100%;
  transition: color 0.2s;
}

.text-btn:hover {
  color: #666;
  background: none;
  transform: none;
  box-shadow: none;
}

.modal-divider {
  height: 1px;
  background: #e0e0e0;
  margin: 20px 0;
}

.login-hint {
  font-size: 0.8rem !important;
  color: #999 !important;
  margin-top: 10px !important;
  margin-bottom: 0 !important;
}

.login-status {
  font-size: 0.85rem;
  color: #e74c3c;
  min-height: 20px;
  margin: 10px 0;
}

.modal-content form {
  margin-bottom: 15px;
}

.modal-content button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.magic-link-container {
  display: flex;
  gap: 8px;
  margin: 15px 0;
}

.magic-link-container input {
  flex: 1;
  font-size: 0.8rem;
  padding: 10px;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 6px;
  color: #666;
}

.copy-btn {
  padding: 5px 5px;
  width: auto !important;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
}

.copy-btn:hover {
  background: #5a6fd6;
}

/* Success Modal */
.success-modal .modal-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.success-icon {
  font-size: 4rem;
  margin-bottom: 15px;
}

.success-modal h2 {
  color: white;
}

.success-modal p {
  color: rgba(255, 255, 255, 0.9);
}

.success-modal .poster-name {
  font-size: 1.3rem;
  font-weight: bold;
  margin: 10px 0;
}

.success-modal button {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.5);
}

.success-modal button:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #333;
  color: white;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 0.9rem;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 2000;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Error Message */
.error-message {
  text-align: center;
  padding: 40px;
  color: white;
  font-size: 1.1rem;
  grid-column: 1 / -1;
}

/* Animation for newly collected cards */
@keyframes cardPop {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.card.collected {
  animation: cardPop 0.5s ease-out;
}
