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

:root {
  --bg-hue: 220;
  --primary: #4ecdc4;
  --secondary: #ff6b6b;
  --accent: #ffe66d;
  --dark: #1a1a2e;
  --darker: #0f0f1a;
  --card-bg: rgba(30, 30, 50, 0.8);
  --text: #e8e8e8;
  --text-muted: #a0a0b0;
}

body {
  font-family: 'Space Grotesk', sans-serif;
  background: var(--darker);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.app-container {
  min-height: 100vh;
  background: 
    radial-gradient(ellipse at 20% 0%, hsla(var(--bg-hue), 60%, 30%, 0.3) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, hsla(calc(var(--bg-hue) + 60), 60%, 30%, 0.3) 0%, transparent 50%),
    linear-gradient(180deg, var(--darker) 0%, var(--dark) 100%);
  position: relative;
  transition: background 0.5s ease;
}

.floating-beans {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.coffee-bean {
  position: absolute;
  font-size: 1.5rem;
  opacity: 0.15;
  animation: float-up linear infinite;
}

@keyframes float-up {
  0% {
    transform: translateY(100vh) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 0.15;
  }
  90% {
    opacity: 0.15;
  }
  100% {
    transform: translateY(-10vh) rotate(360deg);
    opacity: 0;
  }
}

.content-wrapper {
  position: relative;
  z-index: 1;
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.app-header {
  text-align: center;
  margin-bottom: 3rem;
}

.app-title {
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--accent), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
  animation: shimmer 3s ease infinite;
  background-size: 200% 200%;
}

@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.title-icon {
  display: inline-block;
  animation: pulse-glow 2s ease infinite;
}

@keyframes pulse-glow {
  0%, 100% { filter: drop-shadow(0 0 5px rgba(78, 205, 196, 0.5)); }
  50% { filter: drop-shadow(0 0 20px rgba(78, 205, 196, 0.8)); }
}

.app-tagline {
  font-family: 'Crimson Pro', serif;
  font-style: italic;
  color: var(--text-muted);
  font-size: 1.1rem;
}

.main-content {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}

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

.mood-card {
  background: var(--card-bg);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  backdrop-filter: blur(10px);
}

.mood-card:hover {
  transform: translateY(-3px);
  background: rgba(40, 40, 60, 0.9);
}

.mood-card.selected {
  transform: translateY(-3px);
  background: rgba(50, 50, 70, 0.95);
}

.mood-emoji {
  font-size: 2rem;
  transition: transform 0.3s ease;
}

.mood-card:hover .mood-emoji,
.mood-card.selected .mood-emoji {
  transform: scale(1.2);
}

.mood-label {
  font-size: 0.75rem;
  text-align: center;
  color: var(--text-muted);
  line-height: 1.3;
}

.caffeine-container {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 1.5rem;
  backdrop-filter: blur(10px);
}

.caffeine-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.caffeine-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.coffee-cup {
  position: relative;
  width: 40px;
  height: 35px;
  display: flex;
  align-items: flex-end;
}

.coffee-cup.shaking {
  animation: shake 0.1s infinite;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px) rotate(-1deg); }
  75% { transform: translateX(2px) rotate(1deg); }
}

.cup-body {
  width: 30px;
  height: 30px;
  border: 3px solid var(--primary);
  border-radius: 0 0 8px 8px;
  position: relative;
  overflow: hidden;
}

.cup-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, #6b4423, #8b5a2b);
  transition: height 0.3s ease;
}

.cup-handle {
  width: 10px;
  height: 15px;
  border: 3px solid var(--primary);
  border-left: none;
  border-radius: 0 8px 8px 0;
  position: absolute;
  right: -10px;
  top: 8px;
}

.slider-wrapper {
  padding: 0 0.5rem;
}

.caffeine-slider {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(
    to right,
    hsl(var(--slider-hue), 70%, 50%) 0%,
    hsl(var(--slider-hue), 70%, 50%) var(--slider-percentage),
    rgba(255,255,255,0.2) var(--slider-percentage),
    rgba(255,255,255,0.2) 100%
  );
  border-radius: 4px;
  cursor: pointer;
  margin-bottom: 1rem;
}

.caffeine-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  cursor: grab;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  transition: transform 0.2s ease;
}

.caffeine-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.slider-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s ease;
  flex: 1;
  text-align: center;
  min-width: 60px;
}

.slider-label.active {
  color: var(--primary);
  font-weight: 600;
}

.slider-label:hover {
  color: var(--text);
}

.chaos-modifiers {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 1.5rem;
  backdrop-filter: blur(10px);
}

.chaos-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--accent);
}

.modifier-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modifier-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  transition: background 0.2s ease;
}

.modifier-item:hover {
  background: rgba(255,255,255,0.05);
}

.modifier-item input {
  display: none;
}

.modifier-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid var(--text-muted);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.modifier-item input:checked + .modifier-checkbox {
  background: var(--primary);
  border-color: var(--primary);
}

.modifier-item input:checked + .modifier-checkbox::after {
  content: '✓';
  color: var(--dark);
  font-size: 0.75rem;
  font-weight: 700;
}

.modifier-label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.modifier-item input:checked ~ .modifier-label {
  color: var(--text);
}

.generate-button {
  background: linear-gradient(135deg, var(--primary), #38a89d);
  border: none;
  border-radius: 16px;
  padding: 1.25rem 2rem;
  font-size: 1.25rem;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--dark);
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.generate-button::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(255,255,255,0.3), transparent);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}

.generate-button:hover:not(:disabled)::before {
  transform: translateX(100%);
}

.generate-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(78, 205, 196, 0.4);
}

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

.generate-button.generating {
  background: linear-gradient(135deg, var(--secondary), #e55a5a);
}

.loading-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.spinner {
  display: inline-block;
  animation: spin 1s linear infinite;
}

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

.tip-card {
  background: linear-gradient(135deg, rgba(40, 40, 60, 0.95), rgba(30, 30, 50, 0.95));
  border-radius: 20px;
  padding: 2rem;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(78, 205, 196, 0.3);
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
  animation: card-appear 0.5s ease;
}

@keyframes card-appear {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.confetti-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

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

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

.tip-time {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.75rem;
}

.tip-action {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.tip-condition {
  font-size: 1.1rem;
  color: var(--accent);
  margin-bottom: 1rem;
  font-style: italic;
}

.tip-justification {
  font-family: 'Crimson Pro', serif;
  font-style: italic;
  color: var(--text-muted);
  font-size: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  line-height: 1.5;
}

.copy-button {
  margin-top: 1.5rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.copy-button:hover {
  background: rgba(255,255,255,0.15);
  transform: translateY(-1px);
}

.copy-button.copied {
  background: rgba(78, 205, 196, 0.2);
  border-color: var(--primary);
  color: var(--primary);
}

.tip-history {
  margin-top: 1rem;
}

.history-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-muted);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.history-list::-webkit-scrollbar {
  width: 4px;
}

.history-list::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.05);
  border-radius: 2px;
}

.history-list::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 2px;
}

.history-item {
  background: rgba(30, 30, 50, 0.6);
  border-radius: 8px;
  padding: 0.75rem;
  border-left: 3px solid var(--primary);
}

.history-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  display: block;
}

.history-tip {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-footer {
  text-align: center;
  margin-top: 4rem;
  padding: 2rem 0;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.footer-tagline {
  font-family: 'Crimson Pro', serif;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.footer-link {
  display: inline-block;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  background: rgba(78, 205, 196, 0.1);
  transition: all 0.2s ease;
  margin-bottom: 0.75rem;
}

.footer-link:hover {
  background: rgba(78, 205, 196, 0.2);
  transform: translateY(-2px);
}

.footer-disclaimer {
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.7;
}

@media (max-width: 600px) {
  .content-wrapper {
    padding: 1rem;
  }

  .mood-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .mood-card {
    padding: 0.75rem;
  }

  .mood-emoji {
    font-size: 1.5rem;
  }

  .mood-label {
    font-size: 0.65rem;
  }

  .slider-labels {
    display: none;
  }

  .caffeine-container::after {
    content: attr(data-label);
    display: block;
    text-align: center;
    margin-top: -0.5rem;
    font-size: 0.85rem;
    color: var(--primary);
  }

  .tip-card {
    padding: 1.5rem;
  }

  .tip-time {
    font-size: 1.25rem;
  }

  .tip-action {
    font-size: 1.1rem;
  }

  .generate-button {
    font-size: 1.1rem;
    padding: 1rem 1.5rem;
  }
}