:root {
  --bg: #eef0f5; --surface: #ffffff; --ink: #141a33; --muted: #5d6585; --line: #d9dde9;
  --accent: #c42a47; --accent-ink: #ffffff; --wash: #e4e7f1;
  --font-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Public Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1120; --surface: #171b30; --ink: #eceffa; --muted: #98a0be; --line: #2a3050;
          --accent: #ff5a78; --accent-ink: #1a0b10; --wash: #1e2340; }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--font-body); min-height: 100vh;
       display: flex; flex-direction: column; }
a { color: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.1; margin: 0; letter-spacing: -0.02em; }
h1 { font-size: clamp(2.2rem, 6vw, 3.8rem); font-weight: 800; }
h2 { font-size: 1.5rem; font-weight: 800; }
h3 { font-size: 1.1rem; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }

.top { display: flex; align-items: center; gap: 1.5rem; padding: .9rem clamp(1rem, 4vw, 2.5rem); border-bottom: 1px solid var(--line);
       background: var(--surface); position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.brand { font: 800 1.3rem var(--font-display); text-decoration: none; letter-spacing: -0.02em; }
.brand span { color: var(--accent); }
.top nav { display: flex; gap: 1.2rem; }
.top nav a { text-decoration: none; font-weight: 500; padding: .25rem 0; border-bottom: 2px solid transparent; }
.top nav a:hover, .top nav a[aria-current] { border-bottom-color: var(--accent); }
.search { margin-left: auto; position: relative; }
.search input, .toolbar input, .toolbar select {
  font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: .5rem 1rem; min-width: 14rem; }
.toolbar select { border-radius: var(--r); min-width: 0; }
.suggest { position: absolute; right: 0; left: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line);
           border-radius: var(--r); list-style: none; margin: 0; padding: .3rem; box-shadow: 0 10px 30px rgba(20,26,51,.15); z-index: 20; }
.suggest a { display: flex; gap: .6rem; align-items: center; padding: .35rem .5rem; border-radius: 6px; text-decoration: none; }
.suggest a:hover, .suggest a:focus { background: var(--wash); }

main { flex: 1; width: min(1180px, 100%); margin: 0 auto; padding: clamp(1.2rem, 3vw, 2.5rem) clamp(1rem, 4vw, 2rem) 4rem; }
.foot { text-align: center; padding: 1.5rem 1rem; color: var(--muted); font-size: .875rem; border-top: 1px solid var(--line); }

/* Hero + wardrobe rail */
.hero { padding: 1rem 0 0; max-width: 40rem; }
.hero p { margin-top: .9rem; font-size: 1.1rem; color: var(--muted); }
.hero form { margin-top: 1.4rem; display: flex; gap: .5rem; }
.hero input { flex: 1; font: inherit; padding: .8rem 1.1rem; border-radius: 999px; border: 2px solid var(--ink); background: var(--surface); color: inherit; min-width: 0; }
.btn { font: 600 1rem var(--font-body); background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px; padding: .8rem 1.4rem; cursor: pointer; text-decoration: none; display: inline-block; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); padding: .5rem 1rem; }
.btn:disabled { opacity: .4; cursor: default; }

.rail-wrap { margin: 2.5rem calc(clamp(1rem, 4vw, 2rem) * -1) 0; overflow-x: auto; padding: 0 clamp(1rem, 4vw, 2rem) 1rem; }
.rail { position: relative; display: flex; gap: 1.1rem; width: max-content; padding-top: 18px; }
.rail::before { content: ''; position: absolute; left: 0; right: 0; top: 6px; height: 4px; background: var(--ink); border-radius: 2px; }
.hang { position: relative; display: flex; flex-direction: column; align-items: center; text-decoration: none; width: 96px; transform-origin: 50% 0; transition: transform .25s ease; }
.hang::before { content: ''; position: absolute; top: -16px; width: 8px; height: 14px; border: 3px solid var(--ink); border-bottom: 0; border-radius: 6px 6px 0 0; }
.hang:hover { transform: rotate(-3deg); }
.hang canvas { box-shadow: 0 6px 14px rgba(20,26,51,.25); background: var(--wash); }
.hang b { margin-top: .6rem; font: 600 .85rem var(--font-body); text-align: center; line-height: 1.2; }
.hang span { font-size: .8rem; color: var(--muted); }
canvas.cape, img.px { image-rendering: pixelated; display: block; }

.summary { margin-top: 2rem; font-size: 1.05rem; }
.summary strong { font-family: var(--font-display); font-size: 1.3em; }

.section { margin-top: 3rem; }
.section > header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 1rem; gap: 1rem; }
.section > header a { color: var(--accent); font-weight: 600; }

/* Player grid / rows */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .75rem; }
.pcard { display: flex; gap: .8rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
         padding: .6rem; text-decoration: none; min-width: 0; }
.pcard:hover { border-color: var(--ink); }
.pcard img { width: 48px; height: 48px; border-radius: 6px; flex: none; background: var(--wash); }
.pcard div { min-width: 0; }
.pcard b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard small { color: var(--muted); }
.pcard small.has { color: var(--accent); font-weight: 600; }
.board { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); list-style: none; margin: 0; padding: .3rem; }
.board li a { display: grid; grid-template-columns: 2.2rem 40px 1fr auto; gap: .8rem; align-items: center; padding: .45rem .6rem; text-decoration: none; border-radius: 8px; }
.board li a:hover { background: var(--wash); }
.board .n { font: 800 1.1rem var(--font-display); color: var(--muted); text-align: right; }
.board li:nth-child(-n+3) .n { color: var(--accent); }
.board img { width: 40px; height: 40px; border-radius: 6px; }

.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; margin: 1.2rem 0; align-items: center; }
.pager { display: flex; gap: .8rem; align-items: center; justify-content: center; margin-top: 1.5rem; }

/* Cape gallery */
.capegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }
.capecard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1.1rem .8rem; text-decoration: none; display: flex; flex-direction: column; align-items: center; gap: .6rem; text-align: center; }
.capecard:hover { border-color: var(--ink); }
.capecard canvas { background: var(--wash); }

/* Profile */
.profile { display: grid; grid-template-columns: 300px 1fr; gap: 2.5rem; align-items: start; }
.stage { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem; display: flex; flex-direction: column; align-items: center; position: sticky; top: 5rem; }
.stage canvas { max-width: 100%; }
.stage .hint { font-size: .85rem; color: var(--muted); margin-top: .5rem; text-align: center; }
.facts { display: flex; flex-wrap: wrap; gap: .4rem 2rem; margin: 1rem 0 0; }
.facts div { min-width: 7rem; }
.facts dt { color: var(--muted); font-size: .85rem; }
.facts dd { margin: 0; font-weight: 600; }
.uuid { font: .85rem ui-monospace, Menlo, Consolas, monospace; color: var(--muted); word-break: break-all; margin-top: .8rem; }
.owned { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .8rem; margin-top: 1rem; }
.own { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .8rem .5rem; display: flex; flex-direction: column; align-items: center; gap: .5rem; text-align: center; }
.own button { background: none; border: 0; padding: 0; cursor: pointer; }
.own button[aria-pressed=true] canvas { outline: 3px solid var(--accent); outline-offset: 3px; }
.own a { font-weight: 600; font-size: .9rem; line-height: 1.2; }
.own small { color: var(--muted); }
.names { list-style: none; padding: 0; margin: .8rem 0 0; }
.names li { display: flex; gap: 1rem; padding: .4rem 0; border-bottom: 1px solid var(--line); }
.names li span:last-child { margin-left: auto; color: var(--muted); }
.empty { padding: 2rem; border: 1px dashed var(--line); border-radius: var(--r); color: var(--muted); }

@media (max-width: 760px) {
  .profile { grid-template-columns: 1fr; }
  .stage { position: static; }
  .search { margin-left: 0; width: 100%; } .search input { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
