:root {
  --blue-primary: #3B82F6;
  --blue-dark: #2563EB;
  --blue-darker: #1E40AF;
  --orange-accent: #F97316;
  --green-openai: #10a37f;
  --gray-bg: #f5f5f5;
  --gray-darker: #e5e5e5;
}

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

body {
  font-family: 'Space Grotesk', sans-serif;
  background: linear-gradient(135deg, var(--gray-bg) 0%, var(--gray-darker) 100%);
  min-height: 100vh;
  color: #1F2937;
}

.app-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 2rem;
  animation: fadeInDown 0.6s ease-out;
}

.header-icon {
  font-size: 3rem;
  animation: bounce 2s infinite;
}

.title {
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  font-weight: 700;
  background: linear-gradient(135deg, var(--blue-primary), var(--blue-darker));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0.5rem 0;
}

.subtitle {
  font-size: 1.25rem;
  color: #6B7280;
  font-weight: 500;
}

/* Backpack */
.bag-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
}

.backpack-container {
  position: relative;
  width: 200px;
  height: 240px;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.backpack-container:hover {
  transform: scale(1.05);
}

.backpack-container.shaking {
  animation: shake 0.8s ease-in-out;
}

.backpack-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 10px 30px rgba(59, 130, 246, 0.4));
}

.bag-body {
  animation: pulse 3s infinite;
}

.zipper {
  stroke-dasharray: 100;
  animation: zipperGlow 2s infinite;
}

.question-marks {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.question-mark {
  position: absolute;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--orange-accent);
  animation: float 3s infinite ease-in-out;
  opacity: 0.8;
}

.question-mark:nth-child(1) { top: 10%; left: 10%; }
.question-mark:nth-child(2) { top: 20%; right: 5%; }
.question-mark:nth-child(3) { bottom: 30%; left: 5%; }
.question-mark:nth-child(4) { bottom: 20%; right: 10%; }

.shake-btn {
  margin-top: 1rem;
  padding: 0.75rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  background: linear-gradient(135deg, var(--blue-primary), var(--blue-dark));
  color: white;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.shake-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

.shake-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Input Section */
.input-section {
  margin-bottom: 2rem;
}

.guess-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.input-wrapper {
  position: relative;
}

.guess-input {
  width: 100%;
  padding: 1rem 1.25rem;
  padding-right: 4rem;
  font-size: 1rem;
  font-family: 'JetBrains Mono', monospace;
  border: 3px solid var(--blue-primary);
  border-radius: 16px;
  outline: none;
  transition: all 0.3s ease;
  background: white;
}

.guess-input:focus {
  border-color: var(--blue-darker);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

.char-count {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  color: #9CA3AF;
  font-family: 'JetBrains Mono', monospace;
}

.submit-btn {
  padding: 1rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  background: var(--green-openai);
  color: white;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.submit-btn:hover:not(:disabled) {
  background: #0d8a6a;
  transform: translateY(-2px);
}

.submit-btn:disabled {
  background: #9CA3AF;
  cursor: not-allowed;
}

/* Probability Meter */
.probability-meter {
  background: white;
  padding: 1.5rem;
  border-radius: 16px;
  margin-bottom: 2rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.meter-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #374151;
}

.meter-bar {
  height: 12px;
  background: var(--gray-darker);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.meter-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green-openai), var(--blue-primary));
  border-radius: 6px;
  transition: width 0.1s ease-out;
}

.analyzing-text {
  font-size: 0.875rem;
  color: #6B7280;
  font-style: italic;
  margin-bottom: 0.5rem;
}

.result-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--blue-darker);
  margin-bottom: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
}

.analyze-btn {
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  background: linear-gradient(135deg, var(--orange-accent), #EA580C);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.analyze-btn:hover:not(:disabled) {
  transform: translateY(-2px);
}

.analyze-btn:disabled {
  opacity: 0.7;
}

/* Leaderboard */
.leaderboard {
  background: white;
  padding: 1.5rem;
  border-radius: 16px;
  margin-bottom: 2rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: #1F2937;
}

.top-guesses {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.top-guess {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--gray-bg);
  border-radius: 12px;
}

.rank {
  font-weight: 700;
  font-size: 1rem;
  color: var(--orange-accent);
  min-width: 2rem;
}

.top-guess-text {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  color: #374151;
}

.top-guess-votes {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--blue-primary);
}

/* Guess Gallery */
.guess-gallery {
  margin-bottom: 2rem;
}

.guesses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.guess-card {
  background: white;
  padding: 1.25rem;
  border-radius: 16px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  border-left: 4px solid var(--blue-primary);
  transition: transform 0.2s ease;
  animation: fadeInUp 0.4s ease-out;
}

.guess-card:hover {
  transform: translateY(-3px);
}

.guess-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  color: #374151;
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.guess-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.guess-time {
  font-size: 0.75rem;
  color: #9CA3AF;
}

.upvote-btn {
  background: var(--gray-bg);
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Space Grotesk', sans-serif;
}

.upvote-btn:hover {
  background: var(--gray-darker);
  transform: scale(1.1);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  animation: fadeIn 0.3s ease;
}

.modal-content {
  background: white;
  padding: 2.5rem;
  border-radius: 24px;
  max-width: 500px;
  width: 100%;
  text-align: center;
  position: relative;
  overflow: hidden;
  animation: scaleIn 0.4s ease;
}

.reveal-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--blue-primary);
  margin-bottom: 1rem;
}

.reveal-item {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.25rem;
  color: #374151;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.close-btn {
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  background: var(--blue-primary);
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.close-btn:hover {
  background: var(--blue-dark);
}

/* Confetti */
.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  animation: confettiFall 2s ease-out forwards;
}

/* Footer */
.footer {
  margin-top: auto;
  text-align: center;
  padding-top: 2rem;
}

.share-btn {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  background: #1DA1F2;
  color: white;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-bottom: 1rem;
}

.share-btn:hover {
  background: #1a8cd8;
  transform: translateY(-2px);
}

.disclaimer {
  font-size: 0.75rem;
  color: #9CA3AF;
  margin-bottom: 0.5rem;
}

.footer-link {
  font-size: 0.875rem;
  color: var(--blue-primary);
  text-decoration: none;
  font-weight: 500;
}

.footer-link:hover {
  text-decoration: underline;
}

/* Animations */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

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

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-10px); }
  60% { transform: translateY(-5px); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-10px) rotate(-3deg); }
  20%, 40%, 60%, 80% { transform: translateX(10px) rotate(3deg); }
}

@keyframes pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.1); }
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-15px) rotate(10deg); }
}

@keyframes zipperGlow {
  0%, 100% { stroke-opacity: 1; }
  50% { stroke-opacity: 0.5; }
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(400px) rotate(720deg);
    opacity: 0;
  }
}

/* Mobile responsiveness */
@media (max-width: 640px) {
  .app-container {
    padding: 1rem;
  }

  .title {
    font-size: 1.5rem;
  }

  .backpack-container {
    width: 160px;
    height: 192px;
  }

  .guesses-grid {
    grid-template-columns: 1fr;
  }

  .modal-content {
    padding: 1.5rem;
  }

  .reveal-item {
    font-size: 1rem;
  }

  .top-guess {
    flex-wrap: wrap;
  }

  .top-guess-text {
    width: 100%;
    order: 3;
    margin-top: 0.5rem;
  }
}