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

:root {
  --bg: #fdf2ff;
  --bg-card: #ffffff;
  --accent: #ec4899;
  --accent-soft: #fbcfe8;
  --accent-dark: #be185d;
  --text-main: #111827;
  --text-muted: #6b7280;
  --radius-lg: 20px;
  --shadow-soft: 0 14px 40px rgba(15, 23, 42, 0.12);
}

/* Body layout */
body {
  min-height: 100vh;
  background: radial-gradient(circle at top left, #e0f2fe 0, transparent 55%),
              radial-gradient(circle at bottom right, #fee2e2 0, transparent 55%),
              var(--bg);
  font-family: "Nunito", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  color: var(--text-main);
}

/* App container */
.app {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  border-radius: 30px;
  padding: 22px 18px 20px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  z-index: 2; /* ensures app is above blobs, below FX if needed */
}

/* Soft background blobs */
.background-blob {
  position: fixed;
  width: 220px;
  height: 220px;
  border-radius: 999px;
  opacity: 0.3;
  filter: blur(40px);
  z-index: -1;
}

.blob-1 {
  background: #bfdbfe;
  top: -40px;
  left: -40px;
}

.blob-2 {
  background: #fecaca;
  bottom: -40px;
  right: -40px;
}

/* Header */
.header {
  margin-bottom: 16px;
}

h1 {
  font-size: 1.8rem;
  line-height: 1.15;
  margin-bottom: 5px;
}

.subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.highlight {
  background: linear-gradient(120deg, #f97316, #ec4899);
  -webkit-background-clip: text;
  color: transparent;
}

/* Controls */
.controls {
  margin: 16px 0 10px;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.select-wrapper {
  position: relative;
  margin-bottom: 12px;
}

select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  font-size: 0.95rem;
  appearance: none;
  background: #f9fafb;
  color: var(--text-main);
}

/* Cute primary button */
.primary-btn {
  width: 100%;
  border: none;
  padding: 12px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #f97316);
  color: #ffffff;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(236, 72, 153, 0.35);
  transform: translateY(0);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.primary-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 14px 30px rgba(236, 72, 153, 0.4);
}

.primary-btn:active {
  transform: translateY(0);
  box-shadow: 0 8px 18px rgba(236, 72, 153, 0.3);
}

/* Rule card */
.rule-card {
  margin-top: 14px;
  padding: 14px 14px 12px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #eef2ff, #fef9c3);
  border: 1px solid #e0e7ff;
  opacity: 0;
  transform: translateY(8px);
  animation: fadeInUp 0.25s ease forwards;
}

.rule-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #4b5563;
  margin-bottom: 4px;
}

.rule-text {
  font-size: 1rem;
  margin-bottom: 10px;
}

/* Buttons under rule */
.rule-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.secondary-btn,
.ghost-btn {
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 8px 12px;
}

.secondary-btn {
  background: #facc15;
  color: #713f12;
}

.secondary-btn:hover {
  filter: brightness(1.05);
}

.ghost-btn {
  background: transparent;
  color: #4b5563;
  border: 1px dashed #d1d5db;
}

.ghost-btn:hover {
  background: #f9fafb;
}

/* Saved section */
.saved-section {
  margin-top: 18px;
  padding-top: 8px;
  border-top: 1px dashed #e5e7eb;
}

.saved-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.saved-header h2 {
  font-size: 1rem;
}

/* container for Clear all + badge */
.saved-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Clear all button */
.clear-btn {
  border: 1px dashed #fbcfe8;
  background: #ffffff;
  color: #be185d;
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.clear-btn:hover {
  filter: brightness(1.03);
  transform: translateY(-1px);
}

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

.clear-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.saved-count {
  font-size: 0.85rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fee2e2;
  color: #b91c1c;
}

.saved-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.saved-list {
  list-style: none;
  max-height: 150px;
  overflow-y: auto;
  padding-right: 2px;
}

.saved-list li {
  font-size: 0.85rem;
  padding: 7px 8px;
  margin-bottom: 5px;
  border-radius: 999px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}

.saved-list li::before {
  content: "⭐";
  font-size: 0.8rem;
}

/* saved rule text */
.saved-text {
  flex: 1;
  padding-right: 8px;
}

/* delete button */
.delete-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 999px;
  color: #ef4444;
  flex-shrink: 0;
}

.delete-btn:hover {
  background: #fee2e2;
}

/* Utility */
.hidden {
  display: none;
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* gentle wiggle you can apply by adding class via JS */
@keyframes softWiggle {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-1px) scale(1.02); }
  60% { transform: translateY(0) scale(0.99); }
  100% { transform: translateY(0) scale(1); }
}

.wiggle {
  animation: softWiggle 0.28s ease;
}

/* Mobile tweaks */
@media (max-width: 400px) {
  .app {
    border-radius: 24px;
    padding: 18px 14px 18px;
  }

  h1 {
    font-size: 1.5rem;
  }

  .subtitle {
    font-size: 0.9rem;
  }
}

/* -----------------------------------------
   FX LAYER + CONFETTI CANVAS
   (added for sparkles + confetti animations)
------------------------------------------ */

/* Layer that holds sparkle DOM elements */
.fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none; /* never blocks clicks */
  z-index: 60; /* above app */
  overflow: hidden;
}

/* Confetti canvas overlays everything */
.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 61; /* above fx-layer if needed */
}

/* Sparkle particle */
.sparkle {
  position: absolute;
  width: 10px;
  height: 10px;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.6);
  animation: sparklePop 700ms ease forwards;
  filter: drop-shadow(0 6px 10px rgba(236, 72, 153, 0.25));
}

/* Sparkle look: 4-point star-ish using gradients */
.sparkle::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background:
    radial-gradient(circle at 50% 50%, #ffffff 0 25%, transparent 26%),
    linear-gradient(45deg, rgba(236,72,153,0.0) 0 40%, rgba(236,72,153,0.9) 40% 60%, rgba(236,72,153,0.0) 60% 100%),
    linear-gradient(-45deg, rgba(249,115,22,0.0) 0 40%, rgba(249,115,22,0.9) 40% 60%, rgba(249,115,22,0.0) 60% 100%);
}

/* Animation for sparkles */
@keyframes sparklePop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5) rotate(0deg);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.05) rotate(12deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -75%) scale(0.7) rotate(30deg);
  }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .sparkle {
    animation: none;
    opacity: 0;
  }
  .wiggle {
    animation: none;
  }
}
