:root {
  --bg: #f2e9d8;
  --panel: #f8f1e3;
  --ink: #2b2620;
  --muted: #7a6f5d;
  --faint: #a89a80;
  --line: #d8cbb2;
  --accent: #b4552d;
  --up: #4e7d43;
  --down: #ab4632;
  --shadow: #dbcba9;
  --soil: #2b2620;
  --soil-ink: #d8cec0;
  --soil-muted: #918674;
}

/* stepped pixel frames, NES-dialog style: 12x12 ring, 4px thick, chamfered corners */
.card, .moodcell, .welcome, .tab, .wallet-pick {
  border: 4px solid transparent;
  border-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M2 0h8v2H2zM0 2h12v2H0zM0 8h12v2H0zM2 10h8v2H2zM0 2h4v8H0zM8 2h4v8H8z' fill='%23bca987'/%3E%3C/svg%3E") 4 stretch;
  background-clip: padding-box;
}
button, .cta, dialog#token-dialog {
  border: 4px solid transparent;
  border-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M2 0h8v2H2zM0 2h12v2H0zM0 8h12v2H0zM2 10h8v2H2zM0 2h4v8H0zM8 2h4v8H8z' fill='%232b2620'/%3E%3C/svg%3E") 4 stretch;
  background-clip: padding-box;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  /* sparse pixel dot grid, quieter than a checker */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Crect x='11' y='11' width='2' height='2' fill='%23e2d5ba'/%3E%3C/svg%3E");
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 14px;
  line-height: 1.6;
}

.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 2; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' fill='white'/%3E%3C/svg%3E");
}

::selection { background: var(--accent); color: var(--bg); }

.wrap { max-width: 880px; margin: 0 auto; padding: 3.5rem 1.4rem 5rem; }

/* ---- hero: animated pixel market ---- */

#hero {
  position: relative;
  height: 420px;
  overflow: hidden;
  border-bottom: 3px solid var(--line);
}

#market {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  image-rendering: pixelated;
}

#hero-creatures { position: absolute; inset: 0; pointer-events: none; }

.rider {
  position: absolute;
  visibility: hidden; /* shown once the first tick has placed it on the terrain */
  width: 64px;
  margin-left: -32px;
  pointer-events: auto;
  cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: top 0.55s ease;
  animation: drift 3.4s ease-in-out infinite;
}
.rider svg { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.rider:nth-child(2n) { animation-duration: 4.1s; animation-delay: 0.6s; }
.rider:nth-child(3n) { animation-delay: 1.2s; }

@keyframes drift {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

#tape {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
  background: #efe6d2;
  border-top: 2px solid var(--line);
  overflow: hidden; white-space: nowrap;
  font-size: 12px; padding: 0.3rem 0;
  color: var(--muted);
}
.tape-track { display: inline-block; padding-left: 100%; animation: tape 40s linear infinite; }
@keyframes tape { to { transform: translateX(-100%); } }
#tape .up { color: var(--up); }
#tape .down { color: var(--down); }
#tape b { font-weight: 600; color: var(--ink); }

.hero-inner {
  position: relative; z-index: 1;
  max-width: 880px; margin: 0 auto;
  padding: 3.2rem 1.4rem 0;
  pointer-events: none;
  /* 1px paper outline keeps text readable over the skyline */
  text-shadow: 1px 0 0 var(--bg), -1px 0 0 var(--bg), 0 1px 0 var(--bg), 0 -1px 0 var(--bg);
}
.hero-inner .cta { text-shadow: none; }
.hero-inner a, .hero-inner .cta { pointer-events: auto; }

.cta-row { margin: 1.2rem 0 0.8rem; }

.cta {
  display: inline-block;
  font-size: 13px;
  color: var(--bg); background: var(--accent);
  text-decoration: none;
  padding: 0.4rem 1rem;
  margin-right: 0.6rem;
  box-shadow: 3px 3px 0 rgba(43, 38, 32, 0.35);
}
.cta:active { transform: translate(3px, 3px); box-shadow: none; }
.cta.ghost { color: var(--ink); background: var(--panel); }

@media (max-width: 560px) {
  #hero { height: 360px; }
  .rider { width: 48px; margin-left: -24px; }
}

h1 {
  font-family: "Silkscreen", ui-monospace, monospace;
  font-size: 2rem; font-weight: 700; margin: 0 0 0.6rem;
}

h2 {
  font-family: "Silkscreen", ui-monospace, monospace;
  font-size: 0.95rem; font-weight: 400; margin: 0 0 0.5rem;
}

.tagline { color: var(--muted); max-width: 60ch; margin: 0 0 1rem; }

.statusline { font-size: 13px; color: var(--muted); margin: 0 0 0.5rem; }
.statusline a { color: var(--accent); text-decoration: none; border-bottom: 1px dashed var(--accent); }

section { margin: 3.2rem 0 0; }
h2::after {
  content: ""; display: block;
  width: 40px; height: 4px; margin-top: 6px;
  background: var(--accent);
  box-shadow: 46px 0 0 var(--accent), 58px 0 0 var(--line);
}

.note { color: var(--muted); font-size: 13px; max-width: 62ch; margin: 0 0 1.1rem; }
.note code { color: var(--ink); word-break: break-all; }

.dim { color: var(--faint); font-size: 13px; }

.cards { display: flex; flex-wrap: wrap; gap: 1rem; }

.card {
  background: var(--panel);
  box-shadow: 4px 4px 0 var(--shadow);
  padding: 0.9rem 0.9rem 0.8rem;
  width: 158px;
  text-align: center;
  transition: transform 0.08s steps(2), box-shadow 0.08s steps(2);
}
.card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--shadow); }
#gallery .card { cursor: pointer; }

.card .sprite, .card .sprite svg, .card img {
  width: 128px; height: auto; display: block; margin: 0 auto 0.5rem;
  image-rendering: pixelated;
}

.card .sprite, .card img { cursor: pointer; user-select: none; -webkit-user-select: none; }

.hop {
  animation: hop 0.45s ease;
  transform-origin: 50% 100%;
}

@keyframes hop {
  0% { transform: none; }
  30% { transform: translateY(-12px) scaleY(1.06); }
  60% { transform: translateY(0) scaleY(0.9) scaleX(1.08); }
  80% { transform: translateY(-3px); }
  100% { transform: none; }
}

.card .sym { font-weight: 600; }

.card .price { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.card .mood { font-size: 12px; color: var(--faint); }
.card .mood.up { color: var(--up); }
.card .mood.down { color: var(--down); }

button {
  font: inherit; font-size: 13px;
  color: var(--bg); background: var(--accent);
  padding: 0.3rem 0.9rem; margin-top: 0.55rem;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--shadow);
}
button:active { transform: translate(3px, 3px); box-shadow: none; }
button:disabled { background: var(--faint); cursor: default; }

.wallet-pick {
  color: var(--ink); background: var(--panel);
  box-shadow: none; margin-right: 0.5rem;
}

.moodstrip { display: flex; flex-wrap: wrap; gap: 0.9rem; margin: 0 0 1.3rem; }
.moodcell {
  width: 76px; text-align: center;
  font-size: 11px; color: var(--muted);
  background: var(--panel);
  box-shadow: 3px 3px 0 var(--shadow);
  padding: 0.5rem 0.3rem 0.4rem;
}
.moodcell svg { display: block; width: 56px; height: auto; margin: 0 auto 0.3rem; image-rendering: pixelated; }

.card .count { font-size: 11px; color: var(--faint); }

/* ---- release sections ---- */

.welcome[hidden] { display: none; }
.welcome {
  background: var(--panel);
  box-shadow: 4px 4px 0 var(--shadow);
  padding: 1rem 1.2rem;
  margin-top: 1rem;
  display: flex; gap: 1.2rem; align-items: center;
}
.welcome svg, .welcome img { width: 128px; height: auto; image-rendering: pixelated; flex: none; }
.welcome .dim { font-size: 12px; word-break: break-all; }

.card .sprite.happy { filter: none; }

.tabs { margin: 0 0 1rem; font-size: 13px; }
.tab {
  color: var(--muted); text-decoration: none;
  background: var(--panel);
  padding: 0.2rem 0.8rem; margin-right: 0.5rem;
  display: inline-block;
}
.tab.active { color: var(--bg); background: var(--accent); }

.linkish {
  font: inherit; font-size: 12px;
  color: var(--accent); background: none; border: 0; padding: 0;
  border-bottom: 1px dashed var(--accent); cursor: pointer; margin: 0;
}

.proof-raw {
  font-size: 11px; line-height: 1.5; color: var(--muted);
  background: var(--bg); border: 2px solid var(--line);
  padding: 0.6rem 0.8rem; margin: 0;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all;
  max-height: 220px; overflow-y: auto;
}

dialog#token-dialog {
  background: var(--panel); color: var(--ink);
  box-shadow: 8px 8px 0 rgba(43, 38, 32, 0.35);
  padding: 0; max-width: 560px; width: calc(100% - 2rem);
}
dialog#token-dialog::backdrop { background: rgba(43, 38, 32, 0.45); }
.dlg-body { padding: 1.2rem 1.4rem 1.4rem; display: flex; gap: 1.3rem; }
.dlg-art { flex: none; width: 200px; }
.dlg-art svg, .dlg-art img { width: 200px; height: auto; image-rendering: pixelated; display: block; }
.dlg-meta { min-width: 0; flex: 1; }
.dlg-meta h2 { margin-top: 0; }
#dlg-attrs { font-size: 13px; color: var(--muted); }
#dlg-attrs div {
  display: flex; justify-content: space-between; gap: 1rem;
  border-bottom: 2px solid #e8dcc2; padding: 0.25rem 0;
}
#dlg-close { float: right; }

/* ---- the den ---- */

.den-wrap { padding-top: 2.6rem; }
.den-head { margin-bottom: 1.2rem; }

.roster { display: flex; flex-wrap: wrap; gap: 0.7rem; margin: 0 0 1.4rem; }
.den-card { width: 104px; padding: 0.5rem 0.4rem 0.45rem; }
.den-card .sprite, .den-card .sprite svg { width: 64px; }
.den-card .sym { font-size: 12px; }
.den-card.picked {
  border-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M2 0h8v2H2zM0 2h12v2H0zM0 8h12v2H0zM2 10h8v2H2zM0 2h4v8H0zM8 2h4v8H8z' fill='%23b4552d'/%3E%3C/svg%3E") 4 stretch;
}

.den-grid { display: grid; grid-template-columns: 1fr 320px; gap: 1.3rem; align-items: start; }

.stage {
  position: relative;
  height: 330px;
  background: #f6efdf;
  box-shadow: 4px 4px 0 var(--shadow);
  border: 4px solid transparent;
  border-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M2 0h8v2H2zM0 2h12v2H0zM0 8h12v2H0zM2 10h8v2H2zM0 2h4v8H0zM8 2h4v8H8z' fill='%23bca987'/%3E%3C/svg%3E") 4 stretch;
  background-clip: padding-box;
  overflow: hidden;
}

/* room: wainscot band + baseboard above the floor */
.stage-wall {
  position: absolute; left: 0; right: 0; bottom: 44px; height: 74px;
  background: #efe5cf;
  border-top: 3px solid #e2d5ba;
}
.stage-ground {
  position: absolute; left: 0; right: 0; bottom: 0; height: 44px;
  background: #eadcbe;
  border-top: 3px solid var(--line);
}

.stage-pet {
  position: absolute; bottom: 40px; width: 170px; margin-left: -85px;
  left: 48%; z-index: 1;
  transition: left 3s steps(15);
  transform-origin: 50% 100%;
}
.stage-pet svg {
  display: block; width: 100%; height: auto; image-rendering: pixelated;
  transform: scaleX(var(--flip, 1));
}

.prop { position: absolute; bottom: 46px; width: 44px; image-rendering: pixelated; }
.prop svg, .prop::before { display: block; }
.prop-bowl { left: 26px; height: 20px; }
.prop-bowl::before {
  content: ""; display: block; width: 44px; height: 20px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 5'%3E%3Cpath d='M1 2h9v1H9v1H8v1H3V4H2V3H1z' fill='%23a5722f'/%3E%3Cpath d='M0 1h1v2H0zM10 1h1v2h-1z' fill='%236d4318'/%3E%3C/svg%3E") no-repeat center / contain;
}
.prop-bowl.full::before {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 5'%3E%3Cpath d='M2 1h7v1H2z' fill='%23d9a24e'/%3E%3Cpath d='M1 2h9v1H9v1H8v1H3V4H2V3H1z' fill='%23a5722f'/%3E%3Cpath d='M0 1h1v2H0zM10 1h1v2h-1z' fill='%236d4318'/%3E%3C/svg%3E") no-repeat center / contain;
}
.prop-ball { right: 30px; width: 26px; height: 26px; }
.prop-ball::before {
  content: ""; display: block; width: 26px; height: 26px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath d='M2 1h4v1H2zM1 2h6v4H1zM2 6h4v1H2z' fill='%23ab4632'/%3E%3Cpath d='M2 2h2v1H2z' fill='%23d2704f'/%3E%3C/svg%3E") no-repeat center / contain;
}

.bubble {
  position: absolute; bottom: 218px; left: 48%; z-index: 2;
  width: 46px; height: 40px; margin-left: 30px;
  background: var(--panel);
  border: 3px solid var(--ink);
  padding: 5px;
  transition: left 3s steps(15);
}
.bubble::after {
  content: ""; position: absolute; left: 4px; bottom: -9px;
  width: 6px; height: 6px; background: var(--ink);
}
.bubble svg { display: block; width: 100%; height: 100%; image-rendering: pixelated; }

.stage-hint { position: absolute; left: 0; right: 0; top: 42%; text-align: center; }

.den-actions { margin: 0.9rem 0 0; display: flex; gap: 0.6rem; }
.den-actions button { flex: 1; margin-top: 0; padding: 0.5rem 0; }
.den-actions .key {
  font-size: 10px; opacity: 0.7; margin-left: 0.3rem;
  border: 1px solid rgba(242, 233, 216, 0.5); padding: 0 3px;
}

#particles { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.pixel-particle {
  position: absolute; bottom: 190px;
  font-size: 15px; color: var(--muted);
  animation: floatup 1.6s steps(8) forwards;
  opacity: 0;
}
.pixel-particle.heart { color: var(--down); }
@keyframes floatup {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-90px); opacity: 0; }
}

/* right column panels */
.den-right { display: grid; gap: 0.9rem; }
.panel { background: var(--panel); box-shadow: 4px 4px 0 var(--shadow); padding: 0.85rem 1rem 0.8rem; }
.panel h2 { margin: 0 0 0.3rem; }
.panel h2::after, .panel-title::after { display: none; }
.panel-title {
  font-family: "Silkscreen", ui-monospace, monospace;
  font-size: 0.8rem; font-weight: 400; margin: 0 0 0.55rem;
}
.panel-line { margin: 0 0 0.3rem; font-size: 13px; }
.fine { font-size: 11px; margin: 0.4rem 0 0; }

.status-words { margin: 0.35rem 0 0; font-size: 12.5px; color: var(--up); }
.status-words.down { color: var(--down); }

.meter { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.meter:last-child { margin-bottom: 0.1rem; }
.mlabel { width: 52px; font-size: 12px; color: var(--muted); }
.mcells { display: flex; gap: 3px; flex: 1; }
.mcell { width: 10%; height: 12px; background: #e6dabf; }
.mcell.on { background: var(--accent); }
.mcell.on.low { background: var(--down); }
.mnum { width: 26px; text-align: right; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }

.carelog { font-size: 12.5px; color: var(--muted); }
.carelog div {
  display: flex; justify-content: space-between; gap: 1rem;
  border-bottom: 2px solid #e8dcc2; padding: 0.26rem 0;
}
.carelog div:last-child { border-bottom: 0; }

@media (max-width: 560px) {
  .cards { justify-content: center; }
  .den-grid { grid-template-columns: 1fr; }
  .stage { height: 250px; }
  .stage-pet { width: 120px; margin-left: -60px; bottom: 36px; }
  .bubble { bottom: 160px; }
  .pixel-particle { bottom: 140px; }
  .cta-row .cta { display: block; margin: 0 0 0.5rem; text-align: center; }
  #tape { font-size: 11px; }
  .card { width: calc(50% - 0.5rem); }
  .card .sprite, .card .sprite svg, .card img { width: 96px; }
  .step { flex-direction: column; }
  .dlg-body { flex-direction: column; }
  .dlg-art, .dlg-art svg { width: 100%; }
  dialog#token-dialog { max-width: none; width: calc(100% - 1rem); }
  .welcome { flex-direction: column; align-items: flex-start; }
}

/* ---- shop ---- */

.shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-bottom: 0.5rem; }
.shop-item {
  background: var(--bg);
  border: 2px solid var(--line);
  padding: 0.5rem 0.4rem 0.45rem;
  text-align: center;
}
.shop-art svg { width: 44px; height: auto; display: block; margin: 0 auto 0.25rem; image-rendering: pixelated; }
.shop-name { font-size: 11.5px; }
.shop-price { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.shop-item button { width: 100%; margin-top: 0.35rem; padding: 0.2rem 0; font-size: 11.5px; }

.den-card .count.yours { color: var(--accent); font-weight: 600; }
.den-card .count { font-size: 10.5px; }

.thin-foot {
  border-top: 3px solid var(--line);
  background: var(--panel);
  margin-top: 3rem;
  font-size: 12.5px; color: var(--muted);
}
.thin-foot .wrap { padding: 1rem 1.4rem; }
.thin-foot a { color: var(--accent); text-decoration: none; border-bottom: 1px dashed var(--accent); }
.thin-foot #foot-addr { word-break: break-all; }
