:root {
  --concrete: #C9C6C1;
  --primer: #E6E3DE;
  --ink: #18161A;
  --magenta: #C81FC8;
  --gutter: #A8A49D;
  --ink-soft: #4A4650;
  --stitch: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14'%3E%3Cpath d='M5 5l4 4M9 5l-4 4' stroke='%23A8A49D' stroke-width='0.9' stroke-linecap='round' opacity='0.55'/%3E%3C/svg%3E");
  --display: "Silkscreen", "Reddit Sans", system-ui, sans-serif;
  --body: "Reddit Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--concrete);
  color: var(--ink);
  font: 400 16px/1.55 var(--body);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; }

/* ---------- top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: var(--concrete);
  border-bottom: 2px solid var(--ink);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand svg { image-rendering: pixelated; }
.brand span { font: 700 24px/1 var(--display); letter-spacing: 0.02em; }
.links { display: flex; gap: 22px; margin-left: auto; }
.links a { text-decoration: none; font-weight: 500; }
.links a:hover { color: var(--magenta); }
.wallet {
  border: 2px solid var(--ink); background: var(--primer); color: var(--ink);
  padding: 9px 16px; cursor: pointer; font-weight: 700;
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform .12s, box-shadow .12s;
}
.wallet:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.wallet.on { background: var(--ink); color: var(--primer); box-shadow: 4px 4px 0 var(--magenta); }

/* ---------- intro ---------- */
.intro { padding: clamp(28px, 6vw, 64px) clamp(16px, 4vw, 40px) 22px; max-width: 1180px; }
.intro h1 { font: 700 clamp(30px, 5.4vw, 64px)/1.08 var(--display); margin: 0 0 14px; }
.intro p { font-size: 18px; max-width: 640px; margin: 0; color: var(--ink-soft); }

/* ---------- stage: the canvas is the page ---------- */
.stage {
  position: relative;
  margin: 0 clamp(16px, 4vw, 40px);
  height: min(78vh, 760px);
  min-height: 420px;
  background: radial-gradient(120% 90% at 50% 30%, #D8D5D0 0%, var(--concrete) 70%);
  border: 2px solid var(--ink);
  overflow: hidden;
  touch-action: none;
}
#board { display: block; width: 100%; height: 100%; cursor: crosshair; }
#board.grabbing { cursor: grabbing; }
.hud {
  position: absolute; left: 14px; top: 14px;
  padding: 8px 12px; background: var(--primer); border: 2px solid var(--ink);
  font-weight: 500; pointer-events: none;
}
.minimap {
  position: absolute; right: 14px; bottom: 14px; margin: 0;
  background: var(--primer); border: 2px solid var(--ink); padding: 8px;
  box-shadow: 4px 4px 0 var(--ink);
}
.minimap canvas { display: block; width: 128px; height: 128px; image-rendering: pixelated; }
.minimap figcaption { font-size: 13px; text-align: center; margin-top: 4px; color: var(--ink-soft); }
.zoom { position: absolute; right: 14px; top: 14px; display: flex; flex-direction: column; gap: 6px; }
.zoom button {
  width: 38px; height: 38px; border: 2px solid var(--ink); background: var(--primer);
  font: 700 20px/1 var(--body); cursor: pointer;
}
.zoom button:hover { background: var(--ink); color: var(--primer); }

/* ---------- paint dock ---------- */
.dock {
  display: grid; grid-template-columns: 1fr minmax(260px, 340px); gap: 24px;
  margin: 18px clamp(16px, 4vw, 40px) 0;
  padding: 18px;
  background: var(--primer) var(--stitch);
  border: 2px solid var(--ink);
}
.palette { display: grid; grid-template-columns: repeat(8, minmax(34px, 1fr)); gap: 8px; align-content: center; }
.swatch {
  aspect-ratio: 1; border: 2px solid var(--ink); cursor: pointer; padding: 0;
  position: relative; transition: transform .1s;
}
.swatch:hover { transform: translateY(-2px); }
.swatch[aria-checked="true"] { outline: 3px solid var(--magenta); outline-offset: 3px; transform: translateY(-3px); }
.dock-side { display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.pick { margin: 0; font-weight: 500; }
.paint {
  border: 2px solid var(--ink); background: var(--magenta); color: #fff;
  padding: 14px 18px; font: 700 18px/1 var(--display); cursor: pointer;
  box-shadow: 5px 5px 0 var(--ink); transition: transform .12s, box-shadow .12s;
}
.paint:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--ink); }
.paint:disabled { background: var(--gutter); color: var(--primer); cursor: not-allowed; box-shadow: 3px 3px 0 var(--ink); }
.status { margin: 0; min-height: 1.5em; color: var(--ink-soft); }
.status.err { color: #9C1238; }

/* ---------- panels ---------- */
.panel {
  margin: 40px clamp(16px, 4vw, 40px) 0;
  padding: clamp(20px, 3vw, 34px);
  background: var(--primer) var(--stitch);
  border: 2px solid var(--ink);
  max-width: 1180px;
}
.panel h2 { font: 700 clamp(26px, 3vw, 40px)/1.1 var(--display); margin: 0 0 20px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.steps li { display: flex; gap: 14px; }
.steps .num {
  flex: none; width: 40px; height: 40px; display: grid; place-items: center;
  background: var(--ink); color: var(--primer); font: 700 22px/1 var(--display);
}
.steps h3 { margin: 4px 0 6px; font-size: 19px; }
.steps p { margin: 0; color: var(--ink-soft); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; padding: 0; }
.stats div { padding: 22px; border-right: 2px solid var(--ink); }
.stats div:last-child { border-right: 0; }
.stats b { display: block; font: 700 clamp(28px, 3.6vw, 44px)/1 var(--display); color: var(--magenta); }
.stats span { display: block; margin-top: 8px; font-weight: 500; }

.recent { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 26px; }
.recent li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--gutter); }
.recent li.empty { grid-column: 1 / -1; color: var(--ink-soft); border: 0; }
.recent .chip { width: 22px; height: 22px; border: 2px solid var(--ink); flex: none; }
.recent .who { font-weight: 700; }
.recent .when { margin-left: auto; color: var(--ink-soft); font-size: 14px; }

.faq details { border-top: 2px solid var(--ink); padding: 14px 0; }
.faq details:last-child { border-bottom: 2px solid var(--ink); }
.faq summary { cursor: pointer; font-weight: 700; font-size: 18px; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "+"; display: inline-block; width: 26px; color: var(--magenta); font-weight: 700; }
.faq details[open] summary::before { content: "\2212"; }
.faq p { margin: 10px 0 0 26px; color: var(--ink-soft); }

/* ---------- footer ---------- */
.foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 24px;
  margin-top: 56px; padding: 32px clamp(16px, 4vw, 40px) 40px;
  background: var(--ink); color: var(--primer);
}
.foot p { margin: 4px 0; }
.foot a { color: var(--primer); text-decoration-color: var(--magenta); text-underline-offset: 3px; }
.foot .built { font: 700 20px/1.3 var(--display); }
.foot .addr { word-break: break-all; }

@media (max-width: 860px) {
  .links { display: none; }
  .wallet { margin-left: auto; }
  .dock { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats div:nth-child(2) { border-right: 0; }
  .stats div:nth-child(-n+2) { border-bottom: 2px solid var(--ink); }
  .recent { grid-template-columns: 1fr; }
  .minimap canvas { width: 88px; height: 88px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
