:root {
  --yellow: #FFD93D;
  --yellow-dark: #F7BE00;
  --orange: #FF8C42;
  --orange-dark: #E67835;
  --blue: #4A90D9;
  --cream: #FFF8E7;
  --text-dark: #2D2D2D;
  --card-bg: #FFFFFF;
}

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

html, body {
  height: 100%;
  font-family: 'Nunito', sans-serif;
  background: linear-gradient(160deg, #FFE066 0%, var(--yellow) 30%, #FFC107 60%, #FFB347 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.18) 2px, transparent 2px);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: 0;
}

.app-wrapper {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  padding: 0 0 24px;
}

/* ── HEADER ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 10px;
}

.app-title {
  font-family: 'Fredoka One', cursive;
  font-size: 22px;
  color: var(--text-dark);
  text-shadow: 0 2px 0 rgba(255,255,255,0.6);
  letter-spacing: 0.5px;
}

.fav-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--orange);
  color: white;
  font-family: 'Fredoka One', cursive;
  font-size: 14px;
  padding: 6px 14px;
  border-radius: 50px;
  box-shadow: 0 3px 10px rgba(255,140,66,0.4);
}
.fav-badge .star { font-size: 16px; }

/* ── MASCOT CARD ── */
.mascot-card {
  margin: 0 16px 0;
  background: linear-gradient(160deg, #FFFDF5 0%, var(--cream) 60%, #FFF3D0 100%);
  border-radius: 28px;
  padding: 18px 20px 0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.10), inset 0 1px 0 rgba(255,255,255,0.9);
  position: relative;
  overflow: hidden;
  min-height: 210px;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: space-between;
  border: 2px solid rgba(255,220,100,0.4);
}

.mascot-card::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 200px;
  height: 200px;
  background: radial-gradient(ellipse at 40% 100%, rgba(255,200,80,0.22) 0%, transparent 70%);
  pointer-events: none;
}

.mascot-card::after {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,140,66,0.15) 0%, transparent 70%);
  pointer-events: none;
}

.speech-bubble {
  position: relative;
  z-index: 3;
  background: white;
  border-radius: 18px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 800;
  color: var(--orange-dark);
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  max-width: 160px;
  line-height: 1.4;
  margin-bottom: 28px;
  border: 1.5px solid rgba(255,200,100,0.3);
  animation: bubblePop 0.4s cubic-bezier(0.175,0.885,0.32,1.275) both;
}

.speech-bubble::after {
  content: '';
  position: absolute;
  right: -10px;
  bottom: 18px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 12px solid white;
}

@keyframes bubblePop {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.dad-figure {
  position: relative;
  z-index: 2;
  width: 155px;
  height: 190px;
  object-fit: contain;
  object-position: bottom center;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.12));
}

/* ── JOKE CARD ── */
.joke-card {
  margin: 14px 16px 0;
  background: var(--card-bg);
  border-radius: 26px;
  padding: 22px 22px 18px;
  box-shadow: 0 6px 28px rgba(0,0,0,0.1);
  position: relative;
  overflow: hidden;
}

.joke-card::before {
  content: '"';
  position: absolute;
  top: -10px; left: 14px;
  font-family: 'Fredoka One', cursive;
  font-size: 80px;
  color: var(--yellow);
  opacity: 0.4;
  line-height: 1;
  pointer-events: none;
}

.joke-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 8px;
}

.joke-setup {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-dark);
  line-height: 1.45;
  min-height: 52px;
  transition: opacity 0.3s;
}

.divider {
  height: 2px;
  background: linear-gradient(90deg, var(--yellow), var(--orange), transparent);
  border-radius: 4px;
  margin: 14px 0;
}

.punchline-area { min-height: 48px; display: flex; align-items: center; }

.punchline-hidden { display: flex; align-items: center; gap: 10px; }
.lock-dots { display: flex; gap: 5px; }
.lock-dots span {
  width: 10px; height: 10px;
  background: var(--yellow-dark);
  border-radius: 50%;
  animation: dotPulse 1.4s ease-in-out infinite;
}
.lock-dots span:nth-child(2) { animation-delay: 0.2s; }
.lock-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse { 0%,100%{opacity:0.4;transform:scale(1)} 50%{opacity:1;transform:scale(1.2)} }
.lock-hint { font-size: 13px; font-weight: 700; color: #aaa; }

.punchline-text {
  font-size: 16px;
  font-weight: 800;
  color: var(--orange-dark);
  line-height: 1.4;
  animation: punchReveal 0.5s cubic-bezier(0.175,0.885,0.32,1.275) both;
}
@keyframes punchReveal {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.ai-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #aaa;
  font-size: 14px;
  font-weight: 700;
}
.ai-spinner {
  width: 20px; height: 20px;
  border: 3px solid #eee;
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── BUTTONS ── */
.btn-row {
  margin: 14px 16px 0;
  display: flex;
  gap: 10px;
}

.btn {
  flex: 1;
  border: none;
  border-radius: 18px;
  padding: 14px 10px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, opacity 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.btn:active { transform: scale(0.95); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-icon { font-size: 20px; line-height: 1; }

.btn-reveal {
  background: linear-gradient(135deg, var(--orange), #FF6B1A);
  color: white;
  box-shadow: 0 5px 16px rgba(255,107,26,0.35);
  flex: 1.2;
}
.btn-next {
  background: linear-gradient(135deg, var(--blue), #2D6EAA);
  color: white;
  box-shadow: 0 5px 16px rgba(45,110,170,0.3);
}
.btn-fav {
  background: linear-gradient(135deg, var(--yellow), var(--yellow-dark));
  color: var(--text-dark);
  box-shadow: 0 5px 16px rgba(255,190,0,0.35);
}
.btn-fav.saved {
  background: linear-gradient(135deg, #FF6B9D, #E8447A);
  color: white;
  box-shadow: 0 5px 16px rgba(232,68,122,0.35);
}

/* ── FAVORITES PANEL ── */
.fav-toggle-btn {
  margin: 14px 16px 0;
  width: calc(100% - 32px);
  background: rgba(255,255,255,0.5);
  border: 2.5px solid rgba(255,255,255,0.7);
  border-radius: 16px;
  padding: 12px 18px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 14px;
  color: var(--text-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s;
}
.fav-toggle-btn:hover { background: rgba(255,255,255,0.7); }

.fav-panel {
  margin: 8px 16px 0;
  background: white;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0,0,0,0.09);
  max-height: 0;
  transition: max-height 0.4s ease;
}
.fav-panel.open { max-height: 400px; overflow-y: auto; }

.fav-panel-inner { padding: 16px; }
.fav-empty { text-align: center; color: #ccc; font-size: 14px; font-weight: 700; padding: 16px 0; }

.fav-item {
  background: var(--cream);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
  position: relative;
}
.fav-setup { font-size: 13px; font-weight: 800; color: var(--text-dark); margin-bottom: 4px; }
.fav-punch { font-size: 12px; font-weight: 700; color: var(--orange-dark); }
.fav-remove {
  position: absolute;
  top: 8px; right: 10px;
  background: none; border: none;
  font-size: 16px; cursor: pointer;
  opacity: 0.4; transition: opacity 0.2s;
}
.fav-remove:hover { opacity: 0.9; }

/* Toast */
.toast {
  position: fixed;
  bottom: 30px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text-dark);
  color: white;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 14px;
  padding: 12px 24px;
  border-radius: 50px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  transition: transform 0.3s cubic-bezier(0.175,0.885,0.32,1.275);
  z-index: 999;
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }