:root {
  --sage: #7DA9A1;
  --sage-dark: #5A8880;
  --slate: #3D5A6B;
  --mist: #F0F4F6;
  --lavender: #9B8BB4;
  --teal: #5E9EA0;
  --dusty-rose: #C08B8B;
  --soft-green: #7BAF8A;
  --bg-stripe-light: #EEF2F5;
  --bg-stripe-dark: #E4EBF0;
  --text-muted: #7A95A3;
  --punchline-border: #C8D8E0;
  --pip-inactive: #D0DDE4;
  --lavender-dark: #6A5A8A;
  --reveal-shadow: rgba(155, 139, 180, 0.35);
  --reveal-shadow-hover: rgba(155, 139, 180, 0.55);
  --card-shadow: rgba(61, 90, 107, 0.12);
  --sage-shadow: rgba(125, 169, 161, 0.4);
  --sage-shadow-hover: rgba(125, 169, 161, 0.55);
  --sage-hover: #8DBDB5;
  --lavender-gradient-end: #7A6FA0;
  --muted-placeholder: #9ABAC8;
}

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

body {
  font-family: 'Nunito', sans-serif;
  background: var(--mist);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 50%; left: 50%;
  width: 200vmax; height: 200vmax;
  transform: translate(-50%, -50%);
  background: repeating-conic-gradient(
    var(--bg-stripe-light) 0deg 10deg,
    var(--bg-stripe-dark) 10deg 20deg
  );
  z-index: 0;
  animation: slowSpin 120s linear infinite;
}

@keyframes slowSpin { to { transform: translate(-50%, -50%) rotate(360deg); } }

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

.badge {
  display: inline-block;
  background: var(--slate);
  color: #B8D4DB;
  font-family: 'Lilita One', cursive;
  font-size: 0.75rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  padding: 6px 18px;
  border-radius: 20px;
  margin-bottom: 14px;
  animation: fadeDown 0.6s ease-out;
}

h1 {
  font-family: 'Lilita One', cursive;
  font-size: clamp(2.4rem, 7vw, 3.6rem);
  color: var(--slate);
  line-height: 1.1;
  margin-bottom: 6px;
  animation: fadeDown 0.6s ease-out 0.1s both;
}
h1 span { color: var(--teal); }

.subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 28px;
  animation: fadeDown 0.6s ease-out 0.2s both;
}

/* ---- JOKE CARD ---- */
.joke-card {
  background: white;
  border-radius: 24px;
  padding: 36px 28px 28px;
  box-shadow:
    0 1px 0 var(--sage),
    0 4px 0 var(--sage-dark),
    0 8px 30px var(--card-shadow);
  position: relative;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: fadeUp 0.5s ease-out 0.3s both;
}

.joke-card::before {
  content: '😄';
  position: absolute;
  top: -22px; left: 50%;
  transform: translateX(-50%);
  font-size: 2.6rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.joke-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.joke-text {
  font-size: 1.3rem;
  color: var(--slate);
  line-height: 1.55;
  font-weight: 700;
  max-width: 440px;
  width: 100%;
}

.setup-block {
  margin-bottom: 18px;
}

.punchline-zone {
  width: 100%;
  border-top: 2px dashed var(--punchline-border);
  margin-top: 4px;
  padding-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.punchline-text {
  font-size: 1.4rem;
  color: var(--teal);
  font-weight: 800;
  line-height: 1.5;
  max-width: 420px;
}

.reveal-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: 'Lilita One', cursive;
  font-size: 1.2rem;
  background: linear-gradient(135deg, var(--lavender), var(--lavender-gradient-end));
  color: white;
  border: none;
  border-radius: 16px;
  padding: 18px 40px;
  cursor: pointer;
  position: relative;
  top: 0;
  box-shadow:
    0 4px 0 var(--lavender-dark),
    0 6px 20px var(--reveal-shadow);
  transition: all 0.15s;
  animation: pulse 1.5s ease-in-out infinite;
}

.reveal-btn:hover {
  box-shadow:
    0 4px 0 var(--lavender-dark),
    0 6px 28px var(--reveal-shadow-hover);
  transform: scale(1.03);
}

.reveal-btn:active {
  top: 3px;
  box-shadow: 0 1px 0 var(--lavender-dark);
  animation: none;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.reveal-btn .eye-icon { font-size: 1.5rem; }

.placeholder-text {
  font-size: 1.15rem;
  color: var(--muted-placeholder);
  font-weight: 600;
  font-style: italic;
}

/* ---- BOTTOM CONTROLS ---- */
.bottom-controls {
  margin-top: 24px;
  animation: fadeUp 0.5s ease-out 0.4s both;
}

.btn-generate {
  font-family: 'Lilita One', cursive;
  font-size: 1.15rem;
  letter-spacing: 0.5px;
  border: none;
  border-radius: 16px;
  padding: 16px 40px;
  cursor: pointer;
  background: var(--sage);
  color: white;
  position: relative;
  top: 0;
  box-shadow:
    0 4px 0 var(--sage-dark),
    0 6px 20px var(--sage-shadow);
  transition: all 0.15s;
}

.btn-generate:hover {
  background: var(--sage-hover);
  box-shadow:
    0 4px 0 var(--sage-dark),
    0 6px 24px var(--sage-shadow-hover);
}

.btn-generate:active {
  top: 3px;
  box-shadow: 0 1px 0 var(--sage-dark);
}

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

/* Groan meter */
.groan-meter {
  margin-top: 18px;
  display: none;
  gap: 8px;
  justify-content: center;
  align-items: center;
  animation: fadeUp 0.3s ease-out;
}
.groan-meter.visible { display: flex; }

.groan-meter span {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.groan-bar { display: flex; gap: 3px; }

.groan-pip {
  width: 16px; height: 8px;
  border-radius: 4px;
  background: var(--pip-inactive);
  transition: background 0.2s;
}
.groan-pip.active:nth-child(-n+3) { background: var(--soft-green); }
.groan-pip.active:nth-child(n+4):nth-child(-n+6) { background: var(--sage); }
.groan-pip.active:nth-child(n+7):nth-child(-n+8) { background: var(--lavender); }
.groan-pip.active:nth-child(n+9) { background: var(--dusty-rose); }

.groan-label { min-width: 70px; text-align: left; }

.counter {
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 1px;
}

/* Loading */
.loading { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 20px 0; }
.loading span {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--sage);
  animation: bounce 0.6s ease-in-out infinite alternate;
}
.loading span:nth-child(2) { animation-delay: 0.15s; background: var(--lavender); }
.loading span:nth-child(3) { animation-delay: 0.3s; background: var(--teal); }

@keyframes bounce { to { transform: translateY(-12px); opacity: 0.5; } }

/* Floating emojis */
.float-emoji {
  position: fixed;
  font-size: 2rem;
  z-index: 10;
  pointer-events: none;
  animation: floatUp 2s ease-out forwards;
}
@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0) rotate(0deg); }
  100% { opacity: 0; transform: translateY(-300px) rotate(30deg); }
}

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

@keyframes punchSlam {
  0% { opacity: 0; transform: scale(0.7) rotate(-2deg); }
  60% { opacity: 1; transform: scale(1.06) rotate(1deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}
.punchline-text.revealed {
  animation: punchSlam 0.4s ease-out forwards;
}