:root {
  --bg-1: #0f0c29;
  --bg-2: #302b63;
  --bg-3: #24243e;
  --card-bg: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.18);
  --text: #f5f3ff;
  --text-dim: rgba(245, 243, 255, 0.7);
  --accent: #ff6f91;
  --accent-2: #7ee8fa;
  --radius: 20px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2) 55%, var(--bg-3));
  background-size: 200% 200%;
  animation: gradientShift 18s ease infinite;
  overflow-x: hidden;
  position: relative;
  padding: 2rem 1rem;
  transition: background 0.6s ease;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.blobs {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  mix-blend-mode: screen;
  animation: float 16s ease-in-out infinite;
}

.b1 {
  width: 340px;
  height: 340px;
  background: var(--accent);
  top: -60px;
  left: -60px;
  animation-duration: 14s;
}

.b2 {
  width: 420px;
  height: 420px;
  background: var(--accent-2);
  bottom: -100px;
  right: -80px;
  animation-duration: 20s;
  animation-delay: 2s;
}

.b3 {
  width: 260px;
  height: 260px;
  background: #ffd76f;
  top: 40%;
  right: 10%;
  animation-duration: 17s;
  animation-delay: 1s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -40px) scale(1.08); }
  66% { transform: translate(-20px, 20px) scale(0.94); }
}

.stage {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.75rem;
  text-align: center;
}

.header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  letter-spacing: -0.02em;
}

.dice {
  display: inline-block;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dice.spin {
  transform: rotate(360deg) scale(1.2);
}

.tagline {
  margin: 0.35rem 0 0;
  color: var(--text-dim);
  font-size: 1rem;
}

.card {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  transition: transform 0.25s ease;
}

.card.pulse {
  animation: pulse 0.5s ease;
}

@keyframes pulse {
  0% { transform: scale(0.97); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.palette {
  display: flex;
  width: 100%;
  height: 84px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15);
}

.swatch {
  flex: 1;
  height: 100%;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  cursor: pointer;
  transition: flex-grow 0.3s ease;
}

.swatch:hover {
  flex-grow: 1.4;
}

.swatch span {
  font-size: 0.65rem;
  font-family: "Consolas", monospace;
  background: rgba(0,0,0,0.35);
  color: #fff;
  padding: 2px 5px;
  border-radius: 6px;
  margin-bottom: 5px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.swatch:hover span {
  opacity: 1;
}

.mood {
  margin: 0.25rem 0 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.quote {
  margin: 0;
  color: var(--text-dim);
  font-style: italic;
  line-height: 1.5;
  max-width: 40ch;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.tag {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.controls {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
  justify-content: center;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 999px;
  padding: 0.85rem 1.9rem;
  font-weight: 600;
  font-size: 1rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

button:active {
  transform: scale(0.96);
}

.roll-btn {
  background: linear-gradient(135deg, var(--accent), #ff9a7b);
  color: #2b0f18;
  box-shadow: 0 10px 30px rgba(255, 111, 145, 0.4);
}

.roll-btn:hover {
  box-shadow: 0 14px 34px rgba(255, 111, 145, 0.55);
  transform: translateY(-2px);
}

.copy-btn {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.counter {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin: 0;
}

.footer {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

.footer strong {
  color: var(--text);
}

.toast {
  position: fixed;
  bottom: 1.75rem;
  left: 50%;
  transform: translate(-50%, 20px);
  background: rgba(20, 20, 30, 0.95);
  color: #fff;
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 5;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 480px) {
  .card {
    padding: 1.5rem 1.1rem;
  }
  .palette {
    height: 64px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
