:root {
  --bg: #0a0e0d;
  --card: #131a17;
  --accent: #4ade80;
  --accent-hover: #5ce992;
  --accent-dim: #22633d;
  --text: #e8ede9;
  --text-dim: #7a8f80;
  --glow: rgba(74, 222, 128, 0.15);
  --orb-1: #166534;
  --orb-2: #065f46;
  --orb-3: #14532d;
  --btn-text: #0a0e0d;
  --border-subtle: rgba(74, 222, 128, 0.1);
  --border-active: rgba(74, 222, 128, 0.25);
  --shadow-btn: rgba(74, 222, 128, 0.25);
  --shadow-btn-hover: rgba(74, 222, 128, 0.35);
  --card-inner-glow: rgba(74, 222, 128, 0.03);
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  overflow: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

.app-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
}

.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.3;
  z-index: 0;
  animation: drift 12s ease-in-out infinite alternate;
}

.orb-1 {
  width: 300px;
  height: 300px;
  background: var(--orb-1);
  top: -100px;
  left: -80px;
}

.orb-2 {
  width: 200px;
  height: 200px;
  background: var(--orb-2);
  bottom: -60px;
  right: -40px;
  animation-delay: -4s;
}

.orb-3 {
  width: 150px;
  height: 150px;
  background: var(--orb-3);
  top: 40%;
  right: 10%;
  animation-delay: -8s;
}

@keyframes drift {
  to {
    transform: translate(40px, 30px) scale(1.1);
  }
}

.container {
  position: relative;
  z-index: 1;
  max-width: 560px;
  width: 100%;
  text-align: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 1.5rem;
}

h1 {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  line-height: 1.1;
  margin-bottom: 0.6rem;
  background: linear-gradient(135deg, var(--text) 40%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-dim);
  font-size: 1.05rem;
  margin-bottom: 2.5rem;
  line-height: 1.5;
}

.fact-card {
  background: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 2.4rem 2rem;
  margin-bottom: 2rem;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: border-color 0.4s, box-shadow 0.4s;
  position: relative;
  overflow: hidden;
}

.fact-card.active {
  border-color: var(--border-active);
  box-shadow: 0 0 40px var(--glow), inset 0 0 30px var(--card-inner-glow);
}

.fact-emoji {
  font-size: 3rem;
  margin-bottom: 1rem;
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  from {
    transform: scale(0) rotate(-20deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

.fact-text {
  font-family: 'Fraunces', serif;
  font-weight: 300;
  font-style: normal;
  font-size: 1.2rem;
  line-height: 1.6;
  color: var(--text);
  max-width: 440px;
  animation: fadeUp 0.5s ease-out;
}

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

.placeholder-text {
  color: var(--text-dim);
  font-size: 1rem;
  font-style: italic;
}

.loader {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.loader span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: bounce 1.2s ease-in-out infinite;
}

.loader span:nth-child(2) {
  animation-delay: 0.15s;
}

.loader span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.3;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.gen-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  color: var(--btn-text);
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
  border: none;
  border-radius: 14px;
  padding: 16px 36px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
  box-shadow: 0 4px 20px var(--shadow-btn);
}

.gen-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px var(--shadow-btn-hover);
  background: var(--accent-hover);
}

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

.gen-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.gen-btn svg {
  transition: transform 0.3s;
}

.gen-btn:hover svg {
  transform: rotate(15deg);
}

.counter {
  margin-top: 1.5rem;
  color: var(--text-dim);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

.fact-generator {
  display: flex;
  flex-direction: column;
  align-items: center;
}

@media (max-width: 500px) {
  .fact-card {
    padding: 1.8rem 1.4rem;
  }
  .gen-btn {
    padding: 14px 28px;
    font-size: 1rem;
  }
}