:root {
  --bg-1: #ff9fb5;
  --bg-2: #ff5a87;
  --bg-3: #a45cd6;
  --bg-4: #6b4ba8;

  --ink:        #2a1340;
  --ink-soft:   #4a2e5c;
  --ink-mute:   #8a6f9c;
  --line:       #ecd9f0;

  --card:       #ffffff;
  --card-soft:  #fbf4ff;

  --accent:     #e91e63;
  --accent-2:   #7b1fa2;
  --good:       #2e7d32;
  --bad:        #c62828;

  --radius:     18px;
  --radius-sm:  12px;
  --shadow-sm:  0 2px 6px rgba(46, 8, 60, 0.08);
  --shadow-md:  0 10px 30px rgba(46, 8, 60, 0.15);
  --shadow-lg:  0 24px 60px rgba(46, 8, 60, 0.22);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
               Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1100px 700px at 10% -10%, var(--bg-1), transparent 60%),
    radial-gradient(900px 700px at 110% 10%, var(--bg-2), transparent 55%),
    radial-gradient(1200px 900px at 50% 110%, var(--bg-3), transparent 60%),
    linear-gradient(180deg, #ffe6f0 0%, #f4e4ff 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 780px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.container-wide {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

header.site {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Respect iOS safe-area insets (notch / Dynamic Island / home indicator)
     while keeping 18/24 as minimums on devices that don't need insets. */
  padding:
    max(18px, env(safe-area-inset-top))
    max(24px, env(safe-area-inset-right))
    18px
    max(24px, env(safe-area-inset-left));
  max-width: 1120px;
  margin: 0 auto;
}

header.site .brand {
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
header.site .brand .dot { color: var(--accent); }

header.site .age-chip {
  font-size: 12px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(0,0,0,0.06);
  padding: 6px 10px;
  border-radius: 999px;
  backdrop-filter: blur(6px);
}

/* ----- Cards ----- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 28px;
}
.card + .card { margin-top: 20px; }
.card.soft { background: var(--card-soft); box-shadow: var(--shadow-sm); }

.card h1 {
  font-size: 32px;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}
.card h2 {
  font-size: 22px;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
/* Use margin-block (top+bottom only) so child paragraphs that set
   `margin: 0 auto ...` for centering don't have their inline (left/right)
   margins clobbered by the shorthand. Previously `margin: 0 0 12px` set
   all four sides, silently defeating `auto` side-margins on descendants. */
.card p { color: var(--ink-soft); line-height: 1.5; margin-block: 0 12px; }
.muted { color: var(--ink-mute); font-size: 14px; }

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
  box-shadow: 0 8px 20px rgba(233,30,99,0.35);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(233,30,99,0.45); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn.secondary {
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.btn.secondary:hover { box-shadow: var(--shadow-md); }

.btn.big {
  padding: 16px 28px;
  font-size: 18px;
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  border: 1px dashed var(--line);
}

/* ----- Hero (landing) ----- */
.hero {
  text-align: center;
  padding: 48px 20px 24px;
}
.hero .emojis {
  font-size: 40px;
  letter-spacing: 4px;
  margin-bottom: 18px;
}
.hero h1 {
  font-size: 44px;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  line-height: 1.05;
}
.hero p.lead {
  font-size: 18px;
  color: var(--ink-soft);
  max-width: 560px;
  margin: 0 auto 28px;
  line-height: 1.5;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 28px;
}
.feature {
  background: rgba(255,255,255,0.85);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.feature .icon { font-size: 32px; margin-bottom: 6px; }
/* h2 is the semantic level (flat hierarchy under the hero h1); visual
   size is set here rather than relying on the default browser h2. */
.feature h2 { margin: 0 0 6px; font-size: 16px; letter-spacing: -0.005em; }
.feature p  { margin: 0; font-size: 14px; color: var(--ink-soft); }

@media (max-width: 720px) {
  .feature-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 34px; }
}

/* ----- Forms ----- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.field input[type="text"],
.field select {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  font-size: 16px;
  font-family: inherit;
  background: white;
  color: var(--ink);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.field input[type="text"]:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(233,30,99,0.18);
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 560px) { .row-2 { grid-template-columns: 1fr; } }

.partner-block {
  background: var(--card-soft);
  border-radius: var(--radius);
  padding: 20px;
}
.partner-block h3 {
  margin: 0 0 16px;
  font-size: 18px;
}

.anatomy-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.anatomy-toggle label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: white;
  cursor: pointer;
  user-select: none;
  transition: all 120ms ease;
}
.anatomy-toggle label .emj { font-size: 34px; line-height: 1; }
.anatomy-toggle input { display: none; }
.anatomy-toggle input:checked + label {
  border-color: var(--accent);
  background: #fff0f6;
  color: var(--accent);
  box-shadow: 0 0 0 3px rgba(233,30,99,0.12);
}

/* Form action row: right-aligned on desktop (original behavior),
   centered on mobile so the button doesn't hug the edge. Add `.centered`
   to force centered alignment on desktop too — useful for primary CTAs
   that shouldn't hug the corner. */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}
.form-actions.centered {
  justify-content: center;
}
@media (max-width: 560px) {
  .form-actions {
    justify-content: center;
  }
}

/* ----- Link share block: input-group pattern (URL field + attached Copy
   button flush on the right). Tighter than a loose flex row with gap. --- */
.linkblock {
  display: flex;
  align-items: stretch;
  padding: 0;
  border: 1px solid var(--line);
  background: white;
  border-radius: var(--radius-sm);
  overflow: hidden;          /* clip children to rounded corners */
}
.linkblock code {
  flex: 1 1 auto;
  min-width: 0;              /* lets flex actually shrink so ellipsis kicks in */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  color: var(--ink-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 12px 14px;
  display: flex;
  align-items: center;
}
.linkblock button {
  flex-shrink: 0;
  margin: 0;
  padding: 0 20px;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: var(--card-soft);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}
.linkblock button:hover  { background: #fff0f6; color: var(--accent); }
.linkblock button:active { background: var(--line); }
.linkblock button.copied { background: #e9f9ed; color: #2e7d32; }
/* Legacy external confirmation — kept for any page still using it, but
   new copy flow flashes the button text instead. */
.copy-status {
  font-size: 12px;
  color: var(--good);
  margin-left: 6px;
  opacity: 0;
  transition: opacity 120ms ease;
}
.copy-status.on { opacity: 1; }

/* ----- Progress ----- */
.progress {
  height: 10px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin: 20px 0 6px;
}
.progress > div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width 240ms ease;
}
.section-meta {
  display: flex;
  justify-content: flex-end;
  font-size: 12px;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  margin: 0 4px 14px;
}

/* ----- Question / intro enter animation ----------------------------------

   A small fade + upward slide on the prompt and choices whenever a new
   question is rendered. Pairs with the existing progress-bar animation
   so the UI feels coordinated rather than having the prompt "snap" in
   place while the bar alone glides.

   The card gets `.anim-in` added every time we (re-)render. The replay
   trick (remove → reflow → re-add) makes the animation fire each time
   even though the class name doesn't change.

   Respects `prefers-reduced-motion`.
*/
@keyframes q-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card.anim-in .prompt,
.card.anim-in .choices,
.card.anim-in .intro-emoji,
.card.anim-in .intro-name,
.card.anim-in .intro-subtitle,
.card.anim-in .intro-description,
.card.anim-in .intro-meta {
  animation: q-fade-in 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.card.anim-in .choices           { animation-delay: 40ms; }
.card.anim-in .intro-name        { animation-delay: 20ms; }
.card.anim-in .intro-subtitle    { animation-delay: 40ms; }
.card.anim-in .intro-description { animation-delay: 60ms; }
.card.anim-in .intro-meta        { animation-delay: 80ms; }

@media (prefers-reduced-motion: reduce) {
  .card.anim-in .prompt,
  .card.anim-in .choices,
  .card.anim-in .intro-emoji,
  .card.anim-in .intro-name,
  .card.anim-in .intro-subtitle,
  .card.anim-in .intro-description,
  .card.anim-in .intro-meta {
    animation: none;
  }
}

/* ----- Category intro card ----- */
.intro-card {
  padding: 40px 28px;
}
.intro-emoji {
  font-size: 72px;
  line-height: 1;
  margin-bottom: 10px;
}
.intro-name {
  font-size: 36px;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}
.intro-subtitle {
  font-size: 18px;
  color: var(--ink-soft);
  font-weight: 500;
  margin: 0 0 18px;
}
/* Needs `.intro-card` prefix (specificity 0,2,0) to beat the generic
   `.card p { margin: 0 0 12px }` rule that would otherwise reset our
   `auto` side-margins to 0 and leave the block left-aligned. */
.intro-card .intro-description {
  max-width: 640px;
  margin: 0 auto 10px;
  line-height: 1.55;
  text-align: center;
}
.intro-meta {
  font-size: 13px;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  margin: 18px 0 0;
}

/* ----- Quiz ----- */
.quiz-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: white;
  padding: 8px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  font-weight: 600;
  font-size: 14px;
}
.category-chip .emoji { font-size: 18px; }
.qcount { font-size: 14px; color: var(--ink-mute); }

.prompt {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin: 24px 0 8px;
  text-align: center;
}
.prompt .hint { display: block; font-size: 14px; color: var(--ink-mute); font-weight: 400; margin-top: 8px; }

.choices {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin: 28px 0 10px;
}
@media (max-width: 560px) { .choices { gap: 6px; } }
.choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px 6px 12px;
  background: white;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}
.choice .emj {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 6px;
  transition: transform 160ms ease;
}
.choice .lbl { font-size: 12px; color: var(--ink-mute); font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
.choice:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.choice:hover .emj { transform: scale(1.08); }
.choice.selected {
  border-color: var(--accent);
  background: #fff0f6;
  box-shadow: 0 0 0 3px rgba(233,30,99,0.15);
}
.choice.selected .lbl { color: var(--accent); }

.quiz-nav {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
}

.quiz-status {
  text-align: center;
  color: var(--ink-mute);
  font-size: 14px;
  margin-top: 8px;
}

/* ----- Waiting card (shown when one partner has finished and the other
   hasn't; used on /results and /s). Two avatars with a heartbeat between
   them, plus a visible poll-interval progress bar so the user can see
   the page is actively checking for updates. --- */
.waiting-card {
  text-align: center;
  padding: 40px 28px;
}
.waiting-title {
  font-size: 30px;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}
.waiting-duo {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 20px;
  margin: 24px 0 12px;
}
.waiting-partner {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 120px;
}
.waiting-partner .avatar {
  position: relative;
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  line-height: 1;
  border-radius: 50%;
  background: var(--card-soft);
  border: 3px solid var(--line);
  margin-bottom: 10px;
  transition: background 240ms ease, border-color 240ms ease;
}
.waiting-partner .name {
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.waiting-partner .status {
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 3px;
}

/* Done: green ring + corner checkmark badge. */
.waiting-partner.done .avatar {
  border-color: #81c784;
  background: #eafaee;
}
.waiting-partner.done .avatar::after {
  content: '✓';
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 28px;
  height: 28px;
  background: #2e7d32;
  color: #fff;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid #fff;
}
.waiting-partner.done .status { color: #2e7d32; }

/* Pending: pink ring + subtle expanding halo. */
.waiting-partner.pending .avatar {
  border-color: var(--accent);
  animation: waiting-ring 1.8s ease-out infinite;
}
@keyframes waiting-ring {
  0%   { box-shadow: 0 0 0 0   rgba(233, 30, 99, 0.45); }
  100% { box-shadow: 0 0 0 22px rgba(233, 30, 99, 0);   }
}
.waiting-partner.pending .status { color: var(--accent); }

/* Heartbeat between the two avatars. Aligned to the avatar centers via
   margin-top so it sits at eye level with them (not the names below). */
.waiting-heart {
  font-size: 30px;
  line-height: 1;
  margin-top: 30px;
  animation: heartbeat 1.4s ease-in-out infinite;
}
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  14%      { transform: scale(1.22); }
  28%      { transform: scale(1); }
  42%      { transform: scale(1.22); }
  70%      { transform: scale(1); }
}

/* Per-partner mini progress bar under each avatar. */
.waiting-partner .mini-progress {
  margin-top: 10px;
  width: 120px;
}
.waiting-partner .mini-progress .bar {
  height: 5px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.waiting-partner .mini-progress .bar > div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width 400ms ease;
}
.waiting-partner.done .mini-progress .bar > div {
  background: #81c784;
}
.waiting-partner .mini-progress .count {
  margin-top: 4px;
  font-size: 11px;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
}

.waiting-msg {
  margin: 4px auto 22px;
  max-width: 460px;
}

/* Poll-tick indicator. Pulse dot + label + slim 5s filling bar. */
.waiting-check {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.waiting-check-label {
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}
.waiting-progress {
  width: 220px;
  height: 3px;
  margin: 0;
  background: var(--line);
}
.waiting-progress > div {
  width: 0%;
  animation: waiting-tick 5s linear infinite;
}
@keyframes waiting-tick {
  0%   { width: 0%;   opacity: 1; }
  92%  { width: 96%;  opacity: 1; }
  100% { width: 100%; opacity: 0.5; }
}

@media (prefers-reduced-motion: reduce) {
  .waiting-partner.pending .avatar,
  .waiting-heart,
  .waiting-progress > div {
    animation: none !important;
  }
}

@media (max-width: 560px) {
  .waiting-duo { gap: 10px; }
  .waiting-partner { min-width: 90px; }
  .waiting-partner .avatar { width: 72px; height: 72px; font-size: 36px; }
  .waiting-heart { font-size: 26px; margin-top: 22px; }
  .waiting-partner .mini-progress { width: 90px; }
}

/* ----- Results ----- */
.score-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 6px;
}
@media (max-width: 720px) { .score-cards { grid-template-columns: 1fr; } }
.score-card {
  padding: 22px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.score-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
  color: var(--ink-soft);
}
.score-card .big-number {
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}
.score-card .sub {
  color: var(--ink-mute);
  font-size: 14px;
  margin-top: 6px;
}

.adv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 10px;
}
.adv-name { font-weight: 600; }
.adv-value { font-weight: 700; font-size: 20px; letter-spacing: -0.01em; }

.bar {
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}
.bar > div {
  height: 100%;
  background: linear-gradient(90deg, #ffb4c9, var(--accent));
  border-radius: 999px;
}

.category-section {
  margin-top: 28px;
}
.category-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.category-header .emj { font-size: 28px; }
.category-header h2 { margin: 0; font-size: 22px; }
.category-header .count { color: var(--ink-mute); font-size: 14px; }

.match {
  padding: 14px 16px;
  background: white;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  margin-bottom: 10px;
}
.match .q {
  font-size: 15px;
  color: var(--ink);
  line-height: 1.4;
}
.match .q .sep { color: var(--ink-mute); margin: 0 8px; }
.match .answers {
  display: flex;
  gap: 18px;
  margin-top: 8px;
  font-size: 14px;
  color: var(--ink-soft);
}
.match .answers span .emj { font-size: 18px; margin-left: 4px; vertical-align: middle; }

.empty-cat { color: var(--ink-mute); font-style: italic; padding: 6px 0; }

/* ----- Misc ----- */
footer.site {
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  padding: 20px;
  opacity: 0.8;
}
.pulse {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  vertical-align: middle;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(1.6); opacity: 0.4; }
}

.notice {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: #fff8e1;
  border: 1px solid #fde8a7;
  color: #6a4f00;
  font-size: 14px;
  margin-bottom: 12px;
}
.notice.error { background: #ffebee; border-color: #ffcdd2; color: #8e0000; }

.topline {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.topline .back { color: var(--ink-soft); font-size: 14px; }
.topline .back:hover { color: var(--accent); }

.checklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 14px;
  margin: 10px 0;
}
.checklist .chk { margin-right: 8px; }
