@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/InterVariable.woff2") format("woff2");
}

:root {
  --bg: #f6f5f9;
  --card: #ffffff;
  --ink: #292930;
  --muted: #6b6b78;
  --line: #e6e4ee;
  --accent: #ec0b7a;          /* brand fills: progress, pips, borders, focus ring */
  --accent-strong: #e40a76;   /* button fill under white text: 4.56:1 (#ec0b7a is 4.29:1) */
  --accent-text: #e40a76;     /* accent-coloured body text on the card: 4.56:1 on #fff */
  --accent-ink: #ffffff;
  --chip: #f1eff6;
  --shadow: 0 10px 40px rgba(41, 41, 48, 0.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17171c;
    --card: #222229;
    --ink: #f2f1f6;
    --muted: #a3a2b0;
    --line: #34343e;
    --chip: #2c2c35;
    --accent-text: #f63b97;   /* 4.51:1 on #222229, 5.10:1 on #17171c (#ec0b7a is 3.68:1) */
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
/* Room for the fixed storage notice (set from app.js while it is open). */
html { scroll-padding-bottom: var(--notice-space, 0px); }
body { padding-bottom: var(--notice-space, 0px); }

/* One visible focus ring for every interactive element. */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* Headings and the notice receive focus programmatically; no ring needed there. */
[tabindex="-1"]:focus { outline: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 16px 48px;
}

.top { text-align: center; margin-bottom: 24px; }
.logo { font-size: 32px; font-weight: 800; letter-spacing: -0.03em; margin: 0; }
.logo span { color: var(--accent); }
.tag { color: var(--muted); margin: 6px 0 0; }
.tag span { display: block; text-wrap: balance; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.progress { display: flex; gap: 6px; margin-bottom: 20px; }
.progress i {
  flex: 1; height: 6px; border-radius: 99px; background: var(--line);
  transition: background .25s;
}
.progress i.on { background: var(--accent); }

.step { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.prompt { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin: 6px 0 20px; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt {
  font: inherit; text-align: left;
  background: var(--chip); color: var(--ink);
  border: 2px solid transparent; border-radius: 16px;
  padding: 14px; cursor: pointer;
  transition: transform .12s, border-color .12s;
}
.opt:hover { transform: translateY(-2px); border-color: var(--accent); }
.opt:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.opt.picked { border-color: var(--accent); }
.opt b { display: block; font-size: 16px; }
.opt small { color: var(--muted); font-size: 13px; }
.opt .emoji { font-size: 22px; display: block; margin-bottom: 4px; }

.name-row { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; min-width: 0; }
.name-row input {
  flex: 1 1 200px; min-width: 0; font: inherit; font-size: 18px;
  padding: 12px 14px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--card); color: var(--ink);
}
.name-row input { border-color: var(--muted); }
.name-row input:focus { border-color: var(--accent); }

button {
  font: inherit; font-weight: 600;
  background: var(--accent-strong); color: var(--accent-ink);
  border: 2px solid var(--accent-strong); border-radius: 999px;
  padding: 10px 18px; cursor: pointer;
}
button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
button.ghost:hover { border-color: var(--accent); }
button:disabled { opacity: .4; cursor: default; }

.nav { margin-top: 18px; display: flex; justify-content: space-between; }

/* Result */
.result { text-align: center; }
.stage {
  width: 100%; max-width: 320px; aspect-ratio: 1; margin: 0 auto;
  border-radius: 20px;
}
.stage svg { width: 100%; height: 100%; display: block; overflow: visible; }
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; margin: 12px 0 0; }
.buddy-name { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; margin: 8px 0 4px; }
.buddy-bio { color: var(--muted); margin: 0 0 18px; }

.dna {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin: 0 0 20px; text-align: left;
}
.dna div { background: var(--chip); border-radius: 12px; padding: 8px 10px; }
.dna dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.dna dd { margin: 2px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.toast { min-height: 1.2em; color: var(--muted); font-size: 14px; margin: 12px 0 0; text-align: center; }

.foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 24px; }

/* Blob motion */
.blob-body { transform-box: fill-box; transform-origin: 50% 100%; }
.m-bounce .blob-body { animation: bounce 1.6s ease-in-out infinite; }
.m-float  .blob-body { animation: float 3.4s ease-in-out infinite; }
.m-wobble .blob-body { animation: wobble 2.2s ease-in-out infinite; }
.m-pulse  .blob-body { animation: pulse 2s ease-in-out infinite; transform-origin: 50% 50%; }
.eyes { transform-box: fill-box; transform-origin: 50% 50%; animation: blink 4.5s infinite; }

@keyframes bounce { 0%,100% { transform: translateY(0) scale(1.04,.96); } 50% { transform: translateY(-14px) scale(.97,1.03); } }
@keyframes float  { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes wobble { 0%,100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes pulse  { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes blink  { 0%,92%,100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .opt:hover { transform: none; }
}
@media (max-width: 420px) {
  .options { grid-template-columns: 1fr; }
  .dna { grid-template-columns: repeat(2, 1fr); }
}

/* Personality */
.buddy-title { margin: 0; font-weight: 600; color: var(--accent-text); }
.catch { margin: 8px 0 18px; font-style: italic; color: var(--muted); }
.persona { text-align: left; display: grid; gap: 14px; margin-bottom: 18px; }
.traits { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.traits span { background: var(--chip); border-radius: 999px; padding: 4px 12px; font-size: 14px; font-weight: 600; }
.facts { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 15px; }
.facts b { color: var(--muted); font-weight: 600; }
.stats { display: grid; gap: 6px; }
.stat { display: grid; grid-template-columns: 96px 1fr 24px; align-items: center; gap: 8px; font-size: 14px; }
.stat .pips { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.stat .pips i { height: 10px; border-radius: 3px; background: var(--line); }
.stat .pips i.on { background: var(--accent); }
.stat .v { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

.dna-wrap { text-align: left; margin-bottom: 18px; }
.dna-wrap summary { cursor: pointer; font-weight: 600; color: var(--muted); font-size: 14px; line-height: 24px; margin-bottom: 4px; }

/* Gallery */
.gallery { margin-top: 24px; }
.gallery h3 { font-size: 16px; margin: 0 0 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.thumb { position: relative; }
.thumb .open { display: block; width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 6px 6px 8px; cursor: pointer; text-align: center; color: var(--ink); font-weight: 600; font-size: 13px; }
.thumb .open:hover { border-color: var(--accent); }
.thumb svg { width: 100%; height: auto; display: block; }
.thumb .blob-body, .thumb .eyes { animation: none; }
.thumb .x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; padding: 0; border-radius: 50%; font-size: 13px; line-height: 1; background: var(--chip); color: var(--muted); border: 1px solid var(--line); }

/* Storage notice */
.notice {
  position: fixed; left: 16px; right: 16px; bottom: 16px; max-width: 560px; margin: 0 auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  padding: 16px 18px; box-shadow: var(--shadow); font-size: 14px; z-index: 10;
}
.notice p { margin: 0 0 10px; }
.notice .actions { justify-content: flex-start; }

.link { background: none; border: 0; padding: 4px 2px; min-height: 24px; color: var(--muted); font-weight: 500; text-decoration: underline; font-size: 13px; }
a.link { display: inline-block; line-height: 16px; }
.notice a { color: inherit; font-weight: 600; }
.foot p { margin: 4px 0; }

/* Privacy page */
.logo a { color: inherit; text-decoration: none; }
.prose { line-height: 1.6; }
.prose h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; margin: 0; line-height: 1.2; }
.prose h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; margin: 28px 0 6px; line-height: 1.3; }
.prose p, .prose ul { margin: 0 0 12px; }
.prose ul { padding-left: 20px; }
.prose li { margin-bottom: 8px; }
.prose a { color: var(--accent-text); }
.prose code { font-size: 0.9em; background: var(--chip); border-radius: 6px; padding: 1px 5px; overflow-wrap: anywhere; }
.prose .updated { color: var(--muted); font-size: 14px; }
.prose .todo { background: var(--chip); border-left: 3px solid var(--accent); padding: 0 4px; }

/* Extras: hats, glasses, patterns, rare traits */
.rare-badge {
  display: inline-block; margin: 4px 0 0; padding: 4px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 700; letter-spacing: .01em;
  color: #6b4a00; background: #ffe9a8; border: 1px solid #f2c94c;
}
.rare-badge[hidden] { display: none; }
@media (prefers-color-scheme: dark) {
  .rare-badge { color: #ffe08a; background: rgba(255, 201, 60, .14); border-color: rgba(255, 201, 60, .45); }
}
.dna .wide { grid-column: 1 / -1; }
.odds { margin: -8px 0 16px; font-size: 13px; color: var(--muted); }

.prop { transform-box: fill-box; transform-origin: 50% 50%; animation: prop .6s linear infinite; }
.aura { animation: aura 3s ease-in-out infinite; }
.shimmer { animation: shimmer 3.6s ease-in-out infinite; }
.twinkle { transform-box: fill-box; transform-origin: 50% 50%; animation: twinkle 2.4s ease-in-out infinite; }
@keyframes prop    { 0%,100% { transform: scaleX(1); } 50% { transform: scaleX(.15); } }
@keyframes aura    { 0%,100% { opacity: .75; } 50% { opacity: 1; } }
@keyframes shimmer { 0% { transform: translateX(-90px); } 60%,100% { transform: translateX(190px); } }
@keyframes twinkle { 0%,100% { transform: scale(1) rotate(0deg); } 50% { transform: scale(1.2) rotate(18deg); } }
.thumb .prop, .thumb .aura, .thumb .shimmer, .thumb .twinkle { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .prop, .aura, .shimmer, .twinkle { animation: none !important; }
}
