:root {
  --tg-blue: #0088cc;
  --tg-blue-dark: #006699;
  --bg-dark: #0a0a0f;
  --bg-card: rgba(20, 25, 45, 0.8);
  --bg-card-hover: rgba(30, 35, 55, 0.9);
  --text-primary: #f0f2f5;
  --text-secondary: #8b95a5;
  --glass-border: rgba(255, 255, 255, 0.1);
  --success: #4ECDC4;
  --warning: #FFD93D;
  --danger: #FF6B6B;
}

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

body {
  font-family: 'Space Grotesk', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  background-image: 
    radial-gradient(ellipse at 20% 20%, rgba(0, 136, 204, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(166, 108, 255, 0.1) 0%, transparent 50%),
    linear-gradient(180deg, #0a0a0f 0%, #0d1020 100%);
  background-attachment: fixed;
}

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

/* Header */
.app-header {
  text-align: center;
  padding: 30px 20px;
  background: linear-gradient(135deg, rgba(0, 136, 204, 0.2) 0%, rgba(166, 108, 255, 0.1) 100%);
  border-radius: 24px;
  margin-bottom: 24px;
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
}

.app-title {
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  font-weight: 800;
  background: linear-gradient(135deg, var(--tg-blue) 0%, #a66cff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.app-tagline {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 16px;
}

.stats-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 136, 204, 0.2);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid rgba(0, 136, 204, 0.3);
}

.stat-icon {
  font-size: 1.1rem;
}

/* Tab Navigation */
.tab-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  color: var(--text-secondary);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.tab-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--tg-blue) 0%, var(--tg-blue-dark) 100%);
  color: white;
  border-color: var(--tg-blue);
}

/* Main Content */
.main-content, .favorites-content {
  flex: 1;
}

.generator-section {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Idea Display */
.idea-display {
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.idea-display.spinning .idea-card {
  animation: spin-blur 0.8s ease-out;
}

@keyframes spin-blur {
  0% { transform: rotateY(0deg) scale(1); filter: blur(0); }
  50% { transform: rotateY(180deg) scale(0.9); filter: blur(4px); }
  100% { transform: rotateY(360deg) scale(1); filter: blur(0); }
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-card);
  border-radius: 24px;
  border: 1px dashed var(--glass-border);
  width: 100%;
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

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

.empty-state p {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

/* Idea Card */
.idea-card {
  background: var(--bg-card);
  border-radius: 24px;
  padding: 24px;
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  width: 100%;
  transition: all 0.3s ease;
}

.idea-card.card-enter {
  animation: card-pop 0.5s ease-out;
}

@keyframes card-pop {
  0% { transform: scale(0.8) rotateX(20deg); opacity: 0; }
  100% { transform: scale(1) rotateX(0deg); opacity: 1; }
}

.idea-card.card-glow {
  box-shadow: 0 0 40px rgba(0, 136, 204, 0.3), 0 0 80px rgba(166, 108, 255, 0.2);
  border-color: rgba(0, 136, 204, 0.5);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.category-badge {
  background: linear-gradient(135deg, var(--cat-color), color-mix(in srgb, var(--cat-color) 70%, black));
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

.rarity-badge {
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: 'JetBrains Mono', monospace;
}

.rarity-common { background: rgba(139, 149, 165, 0.3); color: #8b95a5; }
.rarity-uncommon { background: rgba(78, 205, 196, 0.3); color: #4ECDC4; }
.rarity-rare { 
  background: linear-gradient(135deg, rgba(0, 136, 204, 0.4), rgba(166, 108, 255, 0.4)); 
  color: white;
  animation: shimmer 2s ease-in-out infinite;
}
.rarity-legendary { 
  background: linear-gradient(135deg, #FFD93D, #FF6B6B); 
  color: #1a1a2e;
  animation: pulse-glow 1.5s ease-in-out infinite;
}

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

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 10px rgba(255, 217, 61, 0.5); }
  50% { box-shadow: 0 0 20px rgba(255, 217, 61, 0.8); }
}

.fav-btn {
  margin-left: auto;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  padding: 4px;
}

.fav-btn:hover { transform: scale(1.2); }
.fav-btn.active { color: #FFD93D; }

.idea-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1.3;
}

.idea-description {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
  font-size: 1rem;
}

.idea-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.difficulty-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
}

.monetization-rating {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rating-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.coins {
  display: flex;
  gap: 2px;
}

.coin {
  font-size: 0.9rem;
  opacity: 0.3;
  transition: opacity 0.2s;
}

.coin.active { opacity: 1; }

.idea-features {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.feature-tag {
  background: rgba(0, 136, 204, 0.2);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--tg-blue);
  border: 1px solid rgba(0, 136, 204, 0.3);
}

.card-actions {
  display: flex;
  gap: 12px;
}

.action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

/* Generate Button */
.generate-btn {
  width: 100%;
  padding: 20px 32px;
  background: linear-gradient(135deg, var(--tg-blue) 0%, #0066aa 100%);
  border: none;
  border-radius: 20px;
  color: white;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.4rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 136, 204, 0.4);
}

.generate-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: shine 2s ease-in-out infinite;
}

@keyframes shine {
  0% { left: -100%; }
  50%, 100% { left: 100%; }
}

.generate-btn:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0, 136, 204, 0.5);
}

.generate-btn:active:not(:disabled) {
  transform: translateY(-1px);
}

.generate-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.generate-btn.generating {
  pointer-events: none;
}

.btn-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.btn-icon {
  font-size: 1.6rem;
}

.spinner {
  font-size: 2rem;
  animation: slot-spin 0.2s linear infinite;
}

@keyframes slot-spin {
  0% { transform: rotateX(0deg); }
  100% { transform: rotateX(360deg); }
}

/* Category Filters */
.filters-section {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 20px;
  border: 1px solid var(--glass-border);
}

.section-title {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.category-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-toggle {
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.category-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

.category-toggle.enabled {
  background: linear-gradient(135deg, var(--cat-color), color-mix(in srgb, var(--cat-color) 60%, black));
  color: white;
  border-color: var(--cat-color);
}

/* History Section */
.history-section {
  background: var(--bg-card);
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  overflow: hidden;
}

.history-toggle {
  width: 100%;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.chevron {
  transition: transform 0.3s ease;
  font-size: 0.8rem;
}

.chevron.open { transform: rotate(180deg); }

.history-list {
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.empty-history {
  text-align: center;
  color: var(--text-secondary);
  padding: 20px;
}

/* Mini Card */
.idea-card-mini {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  transition: all 0.2s ease;
}

.idea-card-mini:hover {
  background: rgba(255, 255, 255, 0.08);
}

.mini-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.mini-icon { font-size: 1.2rem; }

.mini-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-actions .fav-btn {
  font-size: 1.2rem;
}

/* Favorites Grid */
.favorites-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--success);
  color: #1a1a2e;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  animation: toast-in 0.3s ease;
  z-index: 1000;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 24px;
  margin-top: auto;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.remix-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--tg-blue);
  text-decoration: none;
  font-weight: 600;
}

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

/* Confetti */
#confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 9999;
}

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

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

/* Responsive */
@media (max-width: 480px) {
  .app-container { padding: 12px; }
  .app-header { padding: 20px 16px; }
  .idea-card { padding: 20px; }
  .idea-title { font-size: 1.3rem; }
  .generate-btn { padding: 16px 24px; font-size: 1.2rem; }
  .card-actions { flex-direction: column; }
}