@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Pixelify+Sans:wght@400;500;600;700&family=Silkscreen:wght@400;700&display=swap');

/* MOLT design system: pixel world */
:root {
  /* world */
  --bg: #1f2a44;          /* page navy */
  --bg-2: #18213a;        /* wells, insets */
  --surface: #24304d;     /* panels (floor band) */
  --surface-2: #2c3a5c;   /* raised / hover */
  --edge: #121a2e;        /* pixel outlines, hard shadows */
  --edge-2: #18213a;
  --hi: #34436b;          /* top-left bevel light */
  --lo: #1b2540;          /* bottom-right bevel dark */

  /* text */
  --ink: #eef2fc;
  --ink-2: #c9d3ea;
  --muted: #8a97b8;
  --line: #313f64;
  --line-2: #55648a;
  --night: #18213a;
  --night-2: #2a3758;

  --gold: #f5c542;
  --gold-2: #ffd86b;
  --gold-hi: #ffe593;
  --gold-lo: #c9971f;
  --gold-ink: #5c3f05;
  --good: #6fd3a8;
  --bad: #ff8292;

  --st0: #a9b4cf; --st0-bg: #2a3554; --st0-ink: #c9d3ea;
  --st1: #6fd3a8; --st1-bg: #1f3a40; --st1-ink: #8fe3bf;
  --st2: #6ea8f0; --st2-bg: #1f3358; --st2-ink: #a3c6f7;
  --st3: #b88cf0; --st3-bg: #2f2d58; --st3-ink: #d2b6f8;
  --st4: #f5c542; --st4-bg: #3a3528; --st4-ink: #f5c542;

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --pixel: 'Pixelify Sans', 'Inter', system-ui, sans-serif;
  --display: 'Silkscreen', 'Pixelify Sans', system-ui, sans-serif;
  --digits: 'Pixelify Sans', 'Inter', system-ui, sans-serif;

  --r-sm: 0;
  --r: 0;
  --r-lg: 0;
  --p: 3px; /* one art pixel */
  --pxb: 0 calc(var(--p) * -1) 0 0 var(--edge), 0 var(--p) 0 0 var(--edge), calc(var(--p) * -1) 0 0 0 var(--edge), var(--p) 0 0 0 var(--edge);
  --bevel: inset var(--p) var(--p) 0 0 var(--hi), inset calc(var(--p) * -1) calc(var(--p) * -1) 0 0 var(--lo);
  --drop: 0 calc(var(--p) * 3) 0 0 var(--edge);
  --shadow-hard: var(--pxb), var(--drop);
  --shadow-soft: var(--pxb);
  --wrap: 1160px;
  --gutter: 24px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg-2); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink-2);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }
::selection { background: var(--gold); color: var(--edge); }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.px, img[src*="/api/art/"], img[src*="/assets/showcase/"], img[src*="molt.png"] { image-rendering: pixelated; image-rendering: crisp-edges; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- type ---------- */
h1, h2, h3, h4 { margin: 0; line-height: 1.1; font-weight: 600; color: var(--ink); font-family: var(--pixel); letter-spacing: 0; }
h1, h2 {
  font-family: var(--display); font-weight: 400; letter-spacing: .01em;
  text-shadow: 3px 3px 0 var(--edge);
}
h1 { color: var(--gold); }
.display { font-family: var(--display); font-weight: 400; line-height: 1.02; color: var(--gold); text-shadow: 4px 4px 0 var(--edge); }
h1.display { font-size: clamp(38px, 6vw, 72px); }
h2 { font-size: clamp(24px, 3vw, 34px); }
h3 { font-size: 21px; }
p { margin: 0; }
.lead { font-size: clamp(16px, 1.5vw, 19px); color: var(--ink-2); max-width: 34em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12.5px; }
.num { font-family: var(--digits); font-weight: 600; letter-spacing: 0; font-variant-numeric: tabular-nums; color: var(--ink); }
.mono-addr { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 13.5px; }
strong, b { color: var(--ink); }

.section { padding: 64px 0; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 30px; flex-wrap: wrap; }
.section-head p { color: var(--muted); max-width: 40em; margin-top: 10px; }

/* ---------- buttons ---------- */
.btn {
  --b-bg: var(--surface-2); --b-ink: var(--ink); --b-hi: #3e4e7a; --b-lo: #222e4c;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  background: var(--b-bg); color: var(--b-ink);
  border: 0; border-radius: 0;
  box-shadow: var(--pxb), 0 6px 0 0 var(--edge), inset 3px 3px 0 0 var(--b-hi), inset -3px -3px 0 0 var(--b-lo);
  font-family: var(--pixel); font-weight: 600; font-size: 17px; line-height: 1; text-decoration: none; white-space: nowrap;
  cursor: pointer; user-select: none;
  transition: none;
}
.btn:hover { --b-bg: #35456c; }
.btn:active { transform: translateY(3px); box-shadow: var(--pxb), 0 3px 0 0 var(--edge), inset 3px 3px 0 0 var(--b-lo), inset -3px -3px 0 0 var(--b-hi); }
.btn[disabled], .btn.is-disabled { opacity: .45; cursor: not-allowed; transform: none; pointer-events: none; }
.btn-gold { --b-bg: var(--gold); --b-ink: var(--edge); --b-hi: var(--gold-hi); --b-lo: var(--gold-lo); }
.btn-gold:hover { --b-bg: var(--gold-2); }
.btn-dark { --b-bg: var(--bg-2); --b-ink: var(--ink); --b-hi: #2a3658; --b-lo: #121a2e; }
.btn-dark:hover { --b-bg: #202b48; }
.btn-ghost { background: transparent; box-shadow: none; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface); color: var(--ink); }
.btn-ghost:active { transform: none; box-shadow: none; }
.btn-lg { min-height: 54px; padding: 0 26px; font-size: 20px; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 15px; box-shadow: var(--pxb), 0 4px 0 0 var(--edge), inset 2px 2px 0 0 var(--b-hi), inset -2px -2px 0 0 var(--b-lo); }
.btn-sm:active { transform: translateY(2px); box-shadow: var(--pxb), 0 2px 0 0 var(--edge); }
.btn-block { width: 100%; }
.btn .ico { width: 18px; height: 18px; flex: none; }
.btn.is-busy { pointer-events: none; }
.btn.is-busy::after { content: ''; width: 10px; height: 10px; background: currentColor; animation: spin .8s steps(4) infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.link { color: var(--gold); font-weight: 600; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; text-decoration-color: rgba(245, 197, 66, .45); }
.link:hover { text-decoration-color: var(--gold); }

/* ---------- surfaces ---------- */
.card {
  background: var(--surface);
  border: 0; border-radius: 0;
  box-shadow: var(--pxb), var(--drop), var(--bevel);
  padding: 24px;
}
.panel {
  background: var(--surface);
  border: 0; border-radius: 0;
  box-shadow: var(--pxb), var(--bevel);
  padding: 20px;
}
.well { background: var(--bg-2); padding: 14px 16px; box-shadow: inset 3px 3px 0 0 var(--edge); }
.screen {
  background: var(--bg-2);
  color: var(--ink);
  border: 0; border-radius: 0;
  box-shadow: var(--pxb), var(--drop), inset 3px 3px 0 0 #232e4c;
  position: relative;
  overflow: hidden;
}

/* ---------- forms ---------- */
.field { display: grid; gap: 8px; }
.field label { font-family: var(--pixel); font-size: 15px; font-weight: 500; color: var(--ink-2); }
.input, .select {
  width: 100%; min-height: 46px; padding: 0 14px;
  background: var(--bg-2); color: var(--ink);
  border: 0; border-radius: 0;
  box-shadow: var(--pxb), inset 3px 3px 0 0 var(--edge);
}
.input::placeholder { color: #56648a; }
.input:focus, .select:focus { outline: none; box-shadow: 0 -3px 0 0 var(--gold), 0 3px 0 0 var(--gold), -3px 0 0 0 var(--gold), 3px 0 0 0 var(--gold), inset 3px 3px 0 0 var(--edge); }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer; font-family: var(--pixel); font-size: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 5 3' shape-rendering='crispEdges'%3E%3Cpath fill='%23f5c542' d='M0 0h5v1H4v1H3v1H2V2H1V1H0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 8px;
}
.select option { background: var(--bg-2); color: var(--ink); }
.input-row { display: flex; gap: 12px; }
.input-row .input { flex: 1; min-width: 0; }

/* ---------- tables (inventory rows) ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); box-shadow: var(--pxb), var(--drop); }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-family: var(--pixel); font-size: 14px; font-weight: 500; color: var(--muted); padding: 12px 16px; border-bottom: 3px solid var(--edge); background: var(--bg-2); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 2px solid var(--line); white-space: nowrap; color: var(--ink-2); }
.table tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; }

/* ---------- empty state ---------- */
.empty {
  display: grid; justify-items: center; text-align: center; gap: 10px;
  padding: 40px 20px; border: 3px dashed var(--line-2); color: var(--muted);
  background: var(--bg-2);
}
.empty strong { color: var(--ink); font-family: var(--pixel); font-weight: 600; font-size: 19px; }
.empty .empty-art { width: 64px; height: 64px; opacity: .45; filter: grayscale(1); }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--bg-2);
  border-bottom: 3px solid var(--edge);
}
.nav { display: flex; align-items: center; gap: 20px; height: 70px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; flex: none; }
.brand img { width: 40px; height: 40px; box-shadow: var(--pxb); }
.brand span { font-family: var(--display); font-weight: 700; font-size: 26px; color: var(--gold); text-shadow: 3px 3px 0 var(--edge); }
.nav-links { display: flex; align-items: center; gap: 4px; margin-right: auto; }
.nav-links a {
  text-decoration: none; font-family: var(--pixel); font-weight: 500; font-size: 17px; color: var(--ink-2);
  padding: 7px 11px;
}
.nav-links a:hover { color: var(--ink); background: var(--surface); }
.nav-links a[aria-current="page"] { color: var(--gold); background: var(--surface); box-shadow: inset 0 -3px 0 0 var(--gold); }
.nav-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.nav-toggle { display: none; width: 44px; height: 44px; padding: 0; }
.wallet-btn .addr { font-variant-numeric: tabular-nums; }

@media (max-width: 1040px) {
  .nav-links {
    display: none; position: absolute; top: 70px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--bg-2); border-bottom: 3px solid var(--edge); padding: 8px var(--gutter) 16px;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 13px 12px; font-size: 18px; }
  .nav-toggle { display: inline-flex; }
  .nav { gap: 10px; }
  .nav-actions { margin-left: auto; }
}
@media (max-width: 560px) {
  :root { --gutter: 16px; }
  .nav { height: 64px; }
  .nav-links { top: 64px; }
  .brand span { display: none; }
  .brand img { width: 36px; height: 36px; }
  .nav-actions { gap: 6px; }
  .nav-actions .btn { padding: 0 11px; min-height: 38px; font-size: 15px; }
  .nav-actions .nav-toggle { padding: 0; width: 40px; }
  .nav-actions .buy-btn .lbl-long { display: none; }
}

/* ---------- footer ---------- */
.site-footer { background: var(--bg-2); border-top: 3px solid var(--edge); margin-top: 48px; padding: 36px 0 48px; color: var(--muted); font-size: 14px; }
.footer-grid { display: flex; gap: 24px 40px; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; }
.footer-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.footer-brand img { width: 30px; height: 30px; box-shadow: var(--pxb); }
.footer-brand span { font-family: var(--display); font-weight: 700; font-size: 20px; color: var(--gold); text-shadow: 2px 2px 0 var(--edge); }
.footer-links { display: flex; gap: 8px 20px; flex-wrap: wrap; }
.footer-links a { text-decoration: none; color: var(--ink-2); font-family: var(--pixel); font-size: 16px; }
.footer-links a:hover { color: var(--gold); }

/* ---------- contract box ---------- */
.ca-box {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-2); box-shadow: var(--pxb), inset 3px 3px 0 0 var(--edge);
  padding: 6px 6px 6px 16px; min-height: 56px; max-width: 100%;
}
.ca-box .ca-label { font-family: var(--display); font-weight: 700; font-size: 16px; color: var(--gold); flex: none; }
.ca-box .ca-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 14px; color: var(--ink); }
.ca-box.is-empty .ca-value { font-family: var(--pixel); font-size: 16px; color: var(--muted); }
.ca-box .btn { min-height: 38px; margin: 0 4px 3px 0; }

/* ---------- stage color helpers ---------- */
.st-0 { --st: var(--st0); --st-bg: var(--st0-bg); --st-ink: var(--st0-ink); }
.st-1 { --st: var(--st1); --st-bg: var(--st1-bg); --st-ink: var(--st1-ink); }
.st-2 { --st: var(--st2); --st-bg: var(--st2-bg); --st-ink: var(--st2-ink); }
.st-3 { --st: var(--st3); --st-bg: var(--st3-bg); --st-ink: var(--st3-ink); }
.st-4 { --st: var(--st4); --st-bg: var(--st4-bg); --st-ink: var(--st4-ink); }
.stage-tag { display: inline-flex; align-items: center; gap: 7px; font-family: var(--pixel); font-weight: 500; font-size: 15px; color: var(--st-ink); }
.stage-tag::before { content: ''; width: 9px; height: 9px; background: var(--st); box-shadow: 0 0 0 2px var(--edge); }

/* ---------- creature frame (inventory slot) ---------- */
.frame {
  position: relative; aspect-ratio: 1; width: 100%;
  background: var(--st-bg, var(--bg-2));
  box-shadow: var(--pxb);
  overflow: hidden;
}
.frame img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; image-rendering: crisp-edges; }
.frame.is-mythic { box-shadow: 0 -3px 0 0 var(--gold), 0 3px 0 0 var(--gold), -3px 0 0 0 var(--gold), 3px 0 0 0 var(--gold), 0 -6px 0 0 var(--edge), 0 6px 0 0 var(--edge), -6px 0 0 0 var(--edge), 6px 0 0 0 var(--edge); }

.creature-card {
  display: grid; gap: 10px; text-decoration: none; color: inherit;
  background: var(--surface); border: 0;
  box-shadow: var(--pxb), 0 9px 0 0 var(--edge), var(--bevel); padding: 12px 12px 12px;
}
a.creature-card:hover { transform: translateY(-3px); background: var(--surface-2); }
.creature-card .frame { box-shadow: inset 3px 3px 0 0 rgba(0, 0, 0, .25); }
.creature-card .frame.is-mythic { box-shadow: inset 0 0 0 3px var(--gold), inset 0 0 0 6px var(--edge); }
.creature-card .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 2px; }
.creature-card .cid { font-family: var(--digits); font-weight: 600; font-size: 19px; color: var(--ink); }
.creature-card .sub { display: flex; justify-content: space-between; gap: 8px; padding: 0 2px; font-size: 13px; color: var(--muted); }
.mythic-mark {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--pixel); font-weight: 600; font-size: 15px; color: var(--gold);
}
.mythic-mark svg { width: 14px; height: 14px; }
.creature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 18px; }
@media (max-width: 480px) { .creature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }

.bob { animation: bob 1.4s steps(1, end) infinite; }
@keyframes bob { 0% { transform: translateY(0); } 50% { transform: translateY(-4px); } 100% { transform: translateY(0); } }

/* ---------- meter ---------- */
.meter { height: 24px; background: var(--bg-2); box-shadow: var(--pxb), inset 3px 3px 0 0 var(--edge); overflow: hidden; position: relative; }
.meter > i { display: block; height: 100%; background: var(--gold); box-shadow: inset 0 3px 0 0 var(--gold-hi), inset 0 -3px 0 0 var(--gold-lo), 3px 0 0 0 var(--edge); min-width: 0; }
.meter.is-zero > i { box-shadow: none; }

/* ---------- stat ---------- */
.stat { display: grid; gap: 4px; }
.stat .v { font-family: var(--digits); font-weight: 600; font-size: clamp(28px, 3vw, 36px); line-height: 1; color: var(--ink); }
.stat .k { color: var(--muted); font-size: 14px; }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px;
  background: rgba(14, 20, 36, .78);
  animation: fade .12s steps(2);
}
.modal {
  width: min(480px, calc(100% - 12px)); max-height: calc(100vh - 40px); overflow: auto;
  background: var(--surface); border: 0;
  box-shadow: var(--pxb), 0 12px 0 0 var(--edge), var(--bevel); padding: 24px;
  animation: pop .16s steps(3);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-head h3 { font-family: var(--display); font-weight: 700; font-size: 22px; color: var(--gold); text-shadow: 2px 2px 0 var(--edge); }
.modal-close { width: 40px; height: 40px; padding: 0; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(12px); opacity: 0; } }

/* ---------- toast ---------- */
.toasts { position: fixed; z-index: 90; right: 16px; bottom: 16px; display: grid; gap: 14px; width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface); box-shadow: var(--pxb), 0 7px 0 0 var(--edge), var(--bevel);
  padding: 12px 14px; font-size: 15px;
  animation: pop .16s steps(3);
}
.toast .t-ico { width: 22px; height: 22px; flex: none; box-shadow: 0 0 0 2px var(--edge); display: grid; place-items: center; margin-top: 1px; color: var(--edge); }
.toast.ok .t-ico { background: var(--st1); }
.toast.err .t-ico { background: var(--bad); }
.toast.wait .t-ico { background: var(--gold); }
.toast.info .t-ico { background: var(--st2); }
.toast .t-body { flex: 1; min-width: 0; }
.toast .t-title { font-family: var(--pixel); font-weight: 600; font-size: 17px; color: var(--ink); }
.toast .t-msg { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.toast a { font-weight: 600; color: var(--gold); }

/* ---------- status lines (no dots) ---------- */
.note {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; font-size: 15px;
  background: var(--bg-2); color: var(--ink-2); box-shadow: inset 3px 0 0 0 var(--line-2);
}
.note.ok { background: #1c3638; color: var(--st1-ink); box-shadow: inset 3px 0 0 0 var(--st1); }
.note.warn { background: #34301f; color: #f7d77e; box-shadow: inset 3px 0 0 0 var(--gold); }
.note.err { background: #3a2233; color: #ffb3bd; box-shadow: inset 3px 0 0 0 var(--bad); }
.note svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }

/* ---------- steps ---------- */
.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.step { position: relative; padding: 22px; background: var(--surface); box-shadow: var(--pxb), var(--drop), var(--bevel); }
.step .n {
  width: 40px; height: 40px; display: grid; place-items: center; margin-bottom: 16px;
  font-family: var(--display); font-weight: 700; font-size: 20px;
  background: var(--gold); color: var(--edge);
  box-shadow: var(--pxb), inset 3px 3px 0 0 var(--gold-hi), inset -3px -3px 0 0 var(--gold-lo);
}
.step h3 { margin-bottom: 8px; font-size: 22px; }
.step p { color: var(--muted); font-size: 15px; }
@media (max-width: 900px) { .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .steps { grid-template-columns: 1fr; } }

/* ---------- code block ---------- */
.code {
  background: var(--edge); color: #dfe6fb; box-shadow: var(--pxb);
  padding: 16px 18px; font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 13.5px;
  line-height: 1.6; overflow: auto; white-space: pre; max-height: 420px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 560px) {
  .section { padding: 44px 0; }
  .card { padding: 18px; }
}

/* segmented strip (stage multipliers etc.) */
.segs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; background: var(--edge); box-shadow: var(--pxb); }
.segs > div { display: grid; gap: 4px; padding: 10px 6px; text-align: center; background: var(--st-bg); }
.segs .s-n { font-family: var(--pixel); font-size: 14px; font-weight: 500; color: var(--st-ink); }
.segs .s-v { font-family: var(--digits); font-weight: 600; font-size: 21px; color: var(--ink); }
@media (max-width: 400px) { .segs .s-n { font-size: 11.5px; } .segs > div { padding: 8px 2px; } }

/* pixel world: square everything */
*, *::before, *::after { border-radius: 0 !important; }
