:root {
  --bg: #14082e;
  --ink: #1a1530;
  --ink-soft: #564a78;
  --muted: #8c84a8;
  --line: #ece7f6;
  --card: #ffffff;
  --accent: #6927d8;
  --accent-soft: #efe6ff;
  --accent-deep: #4a18a6;
  --gold: #ffc857;
  --err: #d6315b;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --pop: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
  min-height: 100dvh;
  overflow-x: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Mesh background — desaturated, no neon */
.bg {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.bg .blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  will-change: transform;
}
.bg .blob-1 { width: 60vmin; height: 60vmin; background: #4a18a6; top: -10vmin; left: -10vmin; animation: float1 18s ease-in-out infinite; }
.bg .blob-2 { width: 50vmin; height: 50vmin; background: #813bea; bottom: -10vmin; right: -8vmin; animation: float2 22s ease-in-out infinite; }
.bg .blob-3 { width: 40vmin; height: 40vmin; background: #2a0d5e; top: 35%; right: 35%; animation: float3 26s ease-in-out infinite; opacity: 0.4; }
@keyframes float1 { 0%,100% { transform: translate3d(0,0,0); } 50% { transform: translate3d(8vmin, 6vmin, 0); } }
@keyframes float2 { 0%,100% { transform: translate3d(0,0,0); } 50% { transform: translate3d(-6vmin, -8vmin, 0); } }
@keyframes float3 { 0%,100% { transform: translate3d(0,0,0); } 50% { transform: translate3d(4vmin, -4vmin, 0); } }

#app {
  position: relative;
  z-index: 1;
  max-width: 460px;
  margin: 0 auto;
  padding: 28px 16px 48px;
}

/* === Hero === */
.hero { text-align: center; color: #fff; padding: 8px 0 22px; }
.hero .crown {
  font-size: 56px;
  line-height: 1;
  display: inline-block;
  filter: drop-shadow(0 6px 20px rgba(255, 200, 87, 0.35));
  animation: crownFloat 4s var(--ease) infinite;
  will-change: transform;
}
@keyframes crownFloat {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-2deg); }
  50% { transform: translate3d(0, -6px, 0) rotate(2deg); }
}
.hero .kicker {
  display: inline-block;
  margin: 12px 0 10px;
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(255, 200, 87, 0.12);
  border: 1px solid rgba(255, 200, 87, 0.25);
  border-radius: 999px;
}
.hero h1 {
  font-size: 30px;
  font-weight: 700;
  margin: 4px 0 8px;
  letter-spacing: -0.6px;
  line-height: 1.1;
}
.hero .sub {
  margin: 0 auto;
  max-width: 28ch;
  font-size: 14.5px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 400;
}

/* === Form card === */
form, #thanks {
  position: relative;
  background: var(--card);
  border-radius: 28px;
  padding: 8px 18px 22px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 30px 60px -20px rgba(20, 8, 46, 0.5),
    0 8px 24px -10px rgba(20, 8, 46, 0.3);
}

/* Stagger reveal */
.reveal {
  opacity: 0;
  transform: translate3d(0, 12px, 0);
  animation: rise 0.5s var(--ease) forwards;
  animation-delay: calc(80ms + var(--i, 0) * 70ms);
  will-change: transform, opacity;
}
@keyframes rise {
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

/* Form-out transition before thanks */
form.out {
  opacity: 0;
  transform: translate3d(0, -8px, 0) scale(0.98);
  transition: opacity 0.22s var(--ease), transform 0.22s var(--ease);
}

.block { padding: 14px 0; border-top: 1px solid var(--line); }
.block:first-of-type { border-top: 0; padding-top: 16px; }

.label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--ink);
  letter-spacing: -0.1px;
}

/* === Rating — the centerpiece === */
.ratings {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.rating {
  position: relative;
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 64px;
  padding: 0;
  background: #f6f3fc;
  border: 2px solid transparent;
  border-radius: 18px;
  cursor: pointer;
  transition: transform 0.18s var(--pop), background 0.2s var(--ease), border-color 0.2s var(--ease);
  will-change: transform;
}
.rating .emoji {
  font-size: 32px;
  line-height: 1;
  display: inline-block;
  transition: transform 0.25s var(--pop);
  filter: grayscale(0.25);
}
.rating:hover .emoji { transform: scale(1.08); }
.rating:active { transform: scale(0.94); }
.rating.on {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.rating.on .emoji {
  transform: scale(1.18);
  filter: grayscale(0);
  animation: pop 0.45s var(--pop);
}
@keyframes pop {
  0% { transform: scale(0.85); }
  60% { transform: scale(1.28); }
  100% { transform: scale(1.18); }
}

/* === Chips === */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  appearance: none;
  padding: 10px 16px;
  min-height: 40px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  color: var(--ink-soft);
  background: #f6f3fc;
  border: 1.5px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s var(--pop), background 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease);
}
.chip:active { transform: scale(0.96); }
.chip.on {
  background: var(--accent-soft);
  color: var(--accent-deep);
  border-color: var(--accent);
  font-weight: 600;
}

/* === Comment textarea === */
textarea {
  width: 100%;
  padding: 14px 16px;
  font: inherit;
  font-size: 16px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  resize: vertical;
  min-height: 100px;
  background: #fbfaff;
  color: var(--ink);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}
textarea::placeholder { color: #b4abce; }

/* === Whoami / anonymous toggle === */
.whoami {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.whoami .who { font-size: 14px; color: var(--muted); }
.whoami .who b { color: var(--ink); font-weight: 600; }
.anon {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink-soft);
  font-weight: 500;
}
.anon input { position: absolute; opacity: 0; pointer-events: none; }
.anon .track {
  position: relative;
  width: 40px; height: 24px;
  background: #e3dcf3;
  border-radius: 999px;
  transition: background 0.22s var(--ease);
}
.anon .track .thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(20, 8, 46, 0.2);
  transition: transform 0.25s var(--pop);
  will-change: transform;
}
.anon input:checked + .track { background: var(--accent); }
.anon input:checked + .track .thumb { transform: translate3d(16px, 0, 0); }

/* === Submit === */
.submit {
  position: relative;
  width: 100%;
  margin-top: 18px;
  padding: 18px 16px;
  min-height: 56px;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.1px;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 18px;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.18s var(--pop), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.15) inset,
    0 8px 24px -6px rgba(105, 39, 216, 0.45);
}
.submit:hover { background: #5b1fc2; }
.submit:active { transform: scale(0.98); }
.submit:disabled { cursor: progress; }
.submit-text { display: inline-block; transition: opacity 0.18s var(--ease), transform 0.18s var(--ease); }
.submit-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s var(--ease);
}
.submit-spinner::before {
  content: '';
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.submit.loading .submit-text { opacity: 0; transform: translate3d(0, 4px, 0); }
.submit.loading .submit-spinner { opacity: 1; }

/* === Error === */
.err {
  margin: 12px 4px 0;
  min-height: 1.2em;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--err);
}
.err.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  25% { transform: translate3d(-4px, 0, 0); }
  50% { transform: translate3d(4px, 0, 0); }
  75% { transform: translate3d(-2px, 0, 0); }
}

/* === Thanks === */
#thanks {
  text-align: center;
  padding: 48px 24px 36px;
  animation: thanksIn 0.5s var(--pop);
}
@keyframes thanksIn {
  0% { opacity: 0; transform: translate3d(0, 16px, 0) scale(0.95); }
  100% { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}
.thanks-crown {
  font-size: 80px;
  line-height: 1;
  display: inline-block;
  filter: drop-shadow(0 10px 30px rgba(255, 200, 87, 0.5));
  animation: thanksCrown 1.2s var(--pop), crownFloat 4s var(--ease) 1.2s infinite;
  will-change: transform;
}
@keyframes thanksCrown {
  0% { transform: scale(0.4) rotate(-15deg); }
  60% { transform: scale(1.18) rotate(8deg); }
  100% { transform: scale(1) rotate(0deg); }
}
#thanks h2 {
  margin: 18px 0 8px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.6px;
  color: var(--ink);
}
#thanks p {
  margin: 0 auto 24px;
  max-width: 26ch;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-soft);
}
.ghost {
  appearance: none;
  padding: 12px 22px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.18s var(--pop), background 0.2s var(--ease);
}
.ghost:hover { background: #e6d9ff; }
.ghost:active { transform: scale(0.97); }

/* === Confetti canvas === */
#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .hero .crown, .thanks-crown, .bg .blob { animation: none !important; }
}

/* === Small screens === */
@media (max-width: 360px) {
  .hero h1 { font-size: 26px; }
  .rating { height: 58px; }
  .rating .emoji { font-size: 28px; }
  .chip { padding: 9px 14px; font-size: 13.5px; }
}
