:root {
  --ground: #14103a; --paper: #1f1a52; --soft: #2a2368; --text: #f1eeff; --muted: #b3acdf;
  --edge: #7468e0; --line: #353079; --accent: #ff6aa0; --on-accent: #1c1547; --pop: #ffd23f;
  --ok: #5ee0b0; --bad: #ff8aa8; --stage-s: 38%; --stage-l: 24%;
  --font: "Outfit", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --display: "Sora", "Avenir Next", "Avenir Next", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --ground: #e9e6ff; --paper: #ffffff; --soft: #f4f2ff; --text: #1c1547; --muted: #5a5486;
  --edge: #1c1547; --line: #d9d4f3; --accent: #ff4f8b; --on-accent: #1c1547; --pop: #ffd23f;
  --ok: #0f7a55; --bad: #c01e4a; --stage-s: 78%; --stage-l: 84%;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--ground); color: var(--text); font: 400 16px/1.5 var(--font); }
.wrap {
  max-width: 960px; margin: 0 auto; display: grid; gap: 40px;
  padding-block: max(22px, env(safe-area-inset-top, 0px)) max(56px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Top bar and the step rail */
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.brand { margin: 0; display: flex; align-items: center; gap: 10px; font: 800 1.5rem/1 var(--display); letter-spacing: 0; }
.brand img { border-radius: 8px; }
.chip-net { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 13px; font-weight: 500; }
.chip-net::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--pop); }
.chip-net.live::before { background: var(--ok); }
.mode { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); color: var(--text); display: grid; place-items: center; padding: 0; }
.mode::before { content: ""; width: 16px; height: 16px; border-radius: 50%; background: var(--text); box-shadow: inset -6px -2px 0 0 var(--paper); }
:root[data-theme="light"] .mode::before { box-shadow: none; background: var(--pop); border: 2px solid var(--edge); width: 14px; height: 14px; }
.nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.nav a { color: var(--muted); font-weight: 500; font-size: 14px; text-decoration: none; }
.nav a:hover { color: var(--text); }
.nav { gap: 4px 22px; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
#recent, #how, #about, #trade { scroll-margin-top: 16px; }
.head { margin-bottom: 14px; }
.head h2 { margin: 0; }
.curvebox { display: grid; gap: 8px; margin-bottom: 18px; }
#curve { width: 100%; height: auto; display: block; overflow: visible; }
#curve .grid { stroke: var(--edge); stroke-opacity: 0.25; stroke-width: 1; }
#curve .axis { fill: var(--muted); font: 600 11px var(--font); }
#curve .line { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
#curve .area { fill: var(--accent); fill-opacity: 0.12; }
#curve .goal { fill: var(--pop); stroke: var(--edge); stroke-width: 2; }
#curve .goal-t { fill: var(--text); font: 700 12px var(--font); }
#curve .pin { cursor: pointer; }
#curve .pin circle.ring { fill: var(--paper); stroke: var(--pop); stroke-width: 3; }
#curve .pin:hover circle.ring, #curve .pin:focus-visible circle.ring { stroke: var(--accent); }
#curve .pin:focus-visible { outline: none; }
#curve .pin text { fill: var(--text); font: 700 14px var(--display); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.feed { display: flex; flex-wrap: wrap; gap: 8px; }
.feed:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--soft); color: var(--text); text-decoration: none; font: 500 14px/1.2 var(--font); max-width: 100%; }
.chip:hover { border-color: var(--accent); }
.chip img, .chip .noimg { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; background: var(--paper); display: grid; place-items: center; font: 700 13px/1 var(--display); color: var(--muted); }
.chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.band { display: grid; gap: 18px; }
.band h2 { margin: 0; font: 700 1.5rem/1.2 var(--display); }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 26px 28px; margin: 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; display: grid; gap: 6px; align-content: start; }
.steps li::before { content: counter(s); display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); color: var(--muted); font-weight: 600; font-size: 14px; }
.steps b { font: 600 1.05rem/1.3 var(--display); }
.steps span { color: var(--muted); font-size: 15px; }
.aboutgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 18px 40px; align-items: start; }
@media (max-width: 760px) { .aboutgrid { grid-template-columns: 1fr; } }
.about { margin: 0; max-width: 52ch; color: var(--muted); }
.faq { display: grid; max-width: 70ch; }
.faq details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.faq details:first-child { border-top: 1px solid var(--line); }
.faq summary { cursor: pointer; font-weight: 500; }
.faq p { margin: 8px 0 0; color: var(--muted); font-size: 15px; }

h1 { margin: 0; font: 700 clamp(2rem, 5.5vw, 3.2rem)/1.08 var(--display); letter-spacing: -0.025em; text-wrap: balance; max-width: 18ch; }
.lede { margin: 0; color: var(--muted); max-width: 48ch; font-size: 1.1rem; }
.hero { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px 24px; padding: 22px 0 8px; overflow: hidden; border-radius: 14px; }
.hero-text { position: relative; display: grid; gap: 14px; min-width: 0; }
.hero-curve { position: absolute; inset: auto 0 0 0; width: 100%; height: 70%; z-index: 0; }
.hero-mascot { position: relative; width: clamp(150px, 26vw, 280px); height: auto; }
@media (max-width: 560px) { .hero { grid-template-columns: 1fr; } .hero-mascot { display: none; } }

/* Panels */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 22px; padding: 26px; min-width: 0; }
.panel h2 { margin: 0; font: 700 1.3rem/1.2 var(--display); }
.panel.stack2 { display: grid; gap: 16px; }

/* Studio: prompt on the left, the animal on the right */
.studio { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr); gap: 32px; padding: 28px; border-radius: 26px; }
@media (max-width: 820px) { .studio { grid-template-columns: 1fr; } }
.ask { display: grid; gap: 14px; align-content: start; min-width: 0; }
.ask label.q { font: 700 1.2rem/1.2 var(--display); }
.say { display: grid; gap: 10px; }
input[type="text"], input[type="number"] {
  width: 100%; background: var(--soft); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; font: inherit; min-width: 0;
}
input::placeholder { color: var(--muted); opacity: 0.8; }
#a-prompt { font-size: 1.15rem; padding: 14px 16px; border-radius: 14px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; }
.eg { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--text); font: 500 13px/1.2 var(--font); cursor: pointer; }
.eg.more { border-style: dashed; color: var(--muted); }
.eg:hover { background: var(--pop); color: #1c1547; }
button { font: inherit; cursor: pointer; }
.btn {
  padding: 11px 20px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); color: var(--text);
  font-weight: 600; transition: filter 0.12s, background-color 0.12s;
}
.btn:hover:not(:disabled) { background: var(--soft); }
.btn:active:not(:disabled) { filter: brightness(0.95); }
.btn.go { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.btn.go:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.status { margin: 0; min-height: 1.3em; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.status.bad, .dl-status.bad { color: var(--bad); font-weight: 600; }

/* Fields once an animal is drawn */
.fields { display: grid; gap: 10px; }
.fields label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.fields input { font-size: 1.05rem; font-weight: 600; }
.fields .desc { margin: 0; font-size: 15px; color: var(--text); }

/* The stage: tinted by the animal's own colour once it loads */
.stage {
  position: relative; display: grid; place-items: center; align-content: center; gap: 14px; min-height: 340px; padding: 22px;
  border-radius: 22px; overflow: hidden;
  background: hsl(var(--hue, 262) var(--stage-s) var(--stage-l));
  transition: background-color 0.5s;
}
.stage img { display: block; width: min(100%, 300px); aspect-ratio: 1; object-fit: cover; border-radius: 22px; background: var(--paper); max-width: 100%; box-shadow: 0 10px 30px rgba(0,0,0,0.25); }
.stage .tag { margin-top: 12px; display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 4px 10px; text-align: center; max-width: 100%; }
.stage .tag strong { font: 700 1.6rem/1.1 var(--display); letter-spacing: 0; overflow-wrap: anywhere; color: var(--text); }
.stage .tag span { padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); font-weight: 700; font-size: 13px; }
.empty { display: grid; place-items: center; gap: 8px; width: min(100%, 280px); aspect-ratio: 1; border: 2px dashed var(--line); border-radius: 22px; color: var(--muted); text-align: center; padding: 18px; }
.empty b { font: 700 4rem/1 var(--display); color: var(--text); opacity: 0.35; }
.stage[data-state="drawing"] .empty { animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.03) rotate(1deg); opacity: 0.7; } }
@media (prefers-reduced-motion: reduce) { .stage[data-state="drawing"] .empty { animation: none; } .stage, .btn { transition: none; } }
.stage[data-state="ready"] .empty, .stage[data-state="drawing"] #a-img, .stage[data-state="empty"] #a-img { display: none; }
.stage[data-state="drawing"] #a-tag, .stage[data-state="empty"] #a-tag { display: none; }

/* Launch and trade side by side */
.hint { margin: 0; font-size: 14px; color: var(--muted); }
.dl-status { margin: 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; min-height: 1.2em; }
.links summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.links-body { display: grid; gap: 10px; margin-top: 10px; }
.links-body label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.stack { display: grid; gap: 12px; min-width: 0; }
.castrip { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); }
.calab { font-size: 11px; font-weight: 700; color: var(--muted); }
.cavalue { font: 12px/1.4 var(--mono); overflow-wrap: anywhere; }
.ca-copy { padding: 4px 10px; font-size: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--text); font-weight: 600; }
.dl-result { display: grid; gap: 8px; }
.dl-result a { font-size: 14px; font-weight: 600; color: var(--text); text-underline-offset: 3px; }
details.trade summary { cursor: pointer; font: 600 1rem/1.2 var(--font); color: var(--muted); list-style: none; display: flex; align-items: center; gap: 8px; }
details.trade summary::-webkit-details-marker { display: none; }
details.trade summary::before { content: ""; width: 0; height: 0; border-left: 8px solid var(--text); border-top: 6px solid transparent; border-bottom: 6px solid transparent; transition: transform 0.15s; }
details.trade[open] summary::before { transform: rotate(90deg); }
.trade-body { display: grid; gap: 12px; margin-top: 14px; min-width: 0; }
.trade-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.trade-row input[type="text"] { flex: 1 1 200px; font-family: var(--mono); font-size: 12px; }
.trade-row input[type="number"] { width: 110px; }
.tbar { height: 10px; border-radius: 8px; background: var(--soft); border: 1px solid var(--line); overflow: hidden; }
.tbar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.4s; }
.foot { margin: 0; font-size: 13px; color: var(--muted); max-width: 70ch; }

.buyfirst { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
.buyrow { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--muted); }
.buyrow input { width: 120px; }
.buyfirst .hint { font-weight: 400; }

/* Wallet button in the header */
.wbar { position: relative; }
.wbtn { height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--text); font: 600 13px/1 var(--font); cursor: pointer; }
.wbtn.on { font-family: var(--mono); font-weight: 500; }
.wbtn.on::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--ok); }
.wmenu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; display: grid; min-width: 170px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.witem { text-align: left; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font: 500 14px/1.2 var(--font); cursor: pointer; }
.witem:hover, .witem:focus-visible { background: var(--soft); }
