:root {
  --bg: #05070d; --ink: #e8ecf5; --dim: #8a93a8; --line: #1b2232; --panel: rgba(10, 14, 24, .86);
  --accent: #14f195; --accent2: #9945ff; --warn: #ffb547;
  --mono: 'JetBrains Mono', ui-monospace, monospace; --sans: 'Space Grotesk', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
#map { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; cursor: grab; }
#map.drag { cursor: grabbing; }
#map.hover { cursor: pointer; }

#top { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 16px; padding: 12px 16px;
  background: linear-gradient(var(--bg), transparent); z-index: 5; pointer-events: none; }
#top > * { pointer-events: auto; }
.brand { font-weight: 700; font-size: 20px; letter-spacing: -.02em; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px var(--accent); }
.search { position: relative; flex: 1; max-width: 520px; }
.search input { width: 100%; background: var(--panel); border: 1px solid var(--line); color: var(--ink); padding: 10px 14px; border-radius: 10px; font: 14px var(--sans); outline: none; }
.search input:focus { border-color: var(--accent); }
#sugg { position: absolute; top: 44px; left: 0; right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; backdrop-filter: blur(12px); }
#sugg:empty { display: none; }
#sugg div { padding: 8px 12px; font-size: 13px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
#sugg div:hover, #sugg div.on { background: #ffffff10; }
#sugg small { color: var(--dim); font-family: var(--mono); }
.stats { margin-left: auto; font-size: 13px; color: var(--dim); white-space: nowrap; font-family: var(--mono); }
.stats b { color: var(--ink); }

#board { position: fixed; left: 16px; top: 70px; bottom: 16px; width: 330px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; backdrop-filter: blur(14px); display: flex; flex-direction: column; z-index: 4; overflow: hidden; }
.tabs { display: flex; padding: 6px; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: none; border: 0; padding: 7px 4px; border-radius: 8px; font-size: 12px; color: var(--dim); }
.tabs button.on { background: #ffffff12; color: var(--ink); }
.scope { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px 0; font-size: 13px; }
.scope button { background: none; border: 0; color: var(--dim); font-size: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.chips button { background: none; border: 1px solid var(--line); border-radius: 20px; padding: 3px 9px; font-size: 11px; color: var(--dim); display: flex; gap: 5px; align-items: center; }
.chips button i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.chips button.off { opacity: .35; }
#list { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; flex: 1; counter-reset: r; }
#list li { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; padding: 7px 12px; cursor: pointer; font-size: 13px; }
#list li:hover, #list li.on { background: #ffffff0d; }
#list li .r { color: var(--dim); font-family: var(--mono); font-size: 11px; }
#list li .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#list li .n small { display: block; color: var(--dim); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
#list li .v { font-family: var(--mono); font-size: 11px; text-align: right; }
#list li .v em { display: block; font-style: normal; color: var(--accent); }
.foot { padding: 8px 12px; font-size: 11px; color: var(--dim); border-top: 1px solid var(--line); }
.foot a { color: var(--ink); cursor: pointer; }

#card { position: fixed; right: 16px; top: 70px; width: 360px; max-height: calc(100vh - 86px); overflow-y: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(14px); z-index: 4; padding: 16px; }
#card .x { position: absolute; right: 10px; top: 8px; background: none; border: 0; color: var(--dim); font-size: 20px; }
#card h2 { margin: 0 24px 2px 0; font-size: 20px; line-height: 1.2; word-break: break-word; }
#card .who { color: var(--dim); font-size: 13px; }
#card .tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
#card .tag { font-size: 11px; padding: 3px 8px; border-radius: 6px; background: #ffffff0f; font-family: var(--mono); }
#card p { font-size: 13px; color: #c3c9d6; line-height: 1.5; }
#card .metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
#card .metrics div { background: #ffffff08; border-radius: 8px; padding: 8px 10px; }
#card .metrics b { display: block; font-family: var(--mono); font-size: 16px; }
#card .metrics small { color: var(--dim); font-size: 11px; }
.pairbox { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-top: 12px; background: linear-gradient(135deg, #14f19512, #9945ff12); }
.pairbox .pp { font-size: 12px; color: var(--dim); }
.pairbox .pair { font-size: 22px; font-weight: 700; margin: 2px 0 10px; }
.btn { display: block; width: 100%; padding: 11px; border-radius: 10px; border: 0; background: var(--accent); color: #04140c; font-weight: 700; font-size: 14px; text-align: center; text-decoration: none; }
.btn.ghost { background: none; border: 1px solid var(--line); color: var(--ink); font-weight: 500; margin-top: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.link { color: var(--accent); font-size: 12px; text-decoration: none; }
.note { font-size: 11px; color: var(--dim); margin-top: 8px; line-height: 1.5; }

#tip { position: fixed; pointer-events: none; z-index: 6; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; font-size: 12px; max-width: 260px; backdrop-filter: blur(10px); }
#tip small { color: var(--dim); display: block; font-family: var(--mono); font-size: 10px; }
#legend { position: fixed; right: 16px; bottom: 14px; font-size: 11px; color: var(--dim); display: flex; gap: 10px; z-index: 3; font-family: var(--mono); }
#legend i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; }

dialog#launch { background: #0a0e18; color: var(--ink); border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(480px, calc(100vw - 32px)); }
dialog#launch::backdrop { background: #000a; backdrop-filter: blur(3px); }
.lh { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.lh h3 { margin: 0; font-size: 17px; }
.lb { padding: 16px 18px; display: grid; gap: 12px; }
.lb label { font-size: 12px; color: var(--dim); display: grid; gap: 5px; }
.lb input, .lb select, .lb textarea { background: #ffffff08; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); padding: 9px 10px; font: 14px var(--sans); outline: none; }
.lb input:focus, .lb select:focus { border-color: var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.modes button { background: #ffffff06; border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: left; font-size: 12px; color: var(--dim); }
.modes button b { display: block; color: var(--ink); font-size: 13px; margin-bottom: 3px; }
.modes button.on { border-color: var(--accent); background: #14f19510; }
.warn { font-size: 11px; color: var(--warn); line-height: 1.5; }
.out { font-family: var(--mono); font-size: 12px; background: #ffffff08; border-radius: 8px; padding: 10px; word-break: break-all; }

@media (max-width: 760px) {
  .stats { display: none; }
  #board { top: auto; height: 38vh; left: 8px; right: 8px; width: auto; bottom: 8px; }
  #card { left: 8px; right: 8px; width: auto; top: 64px; max-height: 50vh; }
  #legend { display: none; }
}
#list li.empty { display: block; color: var(--dim); cursor: default; }

.hint { padding: 8px 12px 0; font-size: 11px; color: var(--dim); line-height: 1.45; }
.locsrc { font-size: 11px; color: var(--dim); margin-top: 6px; line-height: 1.5; padding: 6px 8px; border-left: 2px solid var(--accent); background: #14f19508; border-radius: 0 6px 6px 0; }
.locsrc b { color: var(--ink); font-weight: 500; }
#list li .v small { color: var(--dim); font-size: 10px; }
#legend { background: #03050aaa; padding: 5px 10px; border-radius: 8px; backdrop-filter: blur(8px); }
dialog#launch { overflow-x: hidden; max-height: calc(100vh - 32px); }
.lb input, .lb select, .lb textarea { width: 100%; min-width: 0; box-sizing: border-box; }
.row2, .modes { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.lb label { min-width: 0; }
.imgpick .lbl { font-size: 12px; color: var(--dim); margin-bottom: 5px; }
.imgs { display: flex; gap: 8px; flex-wrap: wrap; }
.imgs button { background: #ffffff06; border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: grid; gap: 4px; justify-items: center; width: 104px; }
.imgs button.on { border-color: var(--accent); background: #14f19510; }
.imgs img { width: 88px; height: 88px; object-fit: cover; border-radius: 8px; background: #0003; }
.imgs small { font-size: 10px; color: var(--dim); max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upl { margin-top: 8px; }

.fw { display: flex; gap: 6px; }
.fw input { flex: 1; }
.fw .btn.ghost { width: auto; margin: 0; padding: 0 10px; font-size: 12px; white-space: nowrap; }
.sponsor { font-size: 12px; color: var(--dim); line-height: 1.55; padding: 10px 12px; border: 1px solid #14f19544; border-radius: 10px; background: #14f19508; }
.sponsor b { display: block; color: var(--ink); margin-bottom: 4px; }

.nav { display: flex; gap: 14px; font-size: 13px; }
.nav a { color: var(--dim); text-decoration: none; }
.nav a:hover { color: var(--accent); }
.zhint { position: fixed; left: 50%; bottom: 52px; transform: translateX(calc(-50% + 170px)); z-index: 5; display: grid; gap: 3px; max-width: 460px;
  background: linear-gradient(135deg, #14f19522, #9945ff22), var(--panel); border: 1px solid #14f19566; border-radius: 14px; padding: 12px 40px 12px 16px;
  backdrop-filter: blur(12px); box-shadow: 0 10px 40px #000a, 0 0 30px #14f19522; transition: opacity .5s, transform .5s; animation: hintIn .8s ease both .6s; }
.zhint b { font-size: 14px; }
.zhint span { font-size: 12px; color: #c3c9d6; line-height: 1.45; }
.zhint kbd { font-family: var(--mono); background: #ffffff14; border-radius: 4px; padding: 0 5px; }
.zhint button { position: absolute; right: 8px; top: 6px; background: none; border: 0; color: var(--dim); font-size: 18px; }
.zhint.gone { opacity: 0; transform: translateX(calc(-50% + 170px)) translateY(20px); pointer-events: none; }
@keyframes hintIn { from { opacity: 0; transform: translateX(calc(-50% + 170px)) translateY(20px); } }
.ctrls { position: fixed; right: 16px; top: 50%; transform: translateY(-50%); z-index: 4; display: grid; gap: 6px; }
.ctrls button { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: 17px; backdrop-filter: blur(10px); transition: border-color .2s, transform .15s; }
.ctrls button:hover { border-color: var(--accent); transform: scale(1.06); }
.ctrls button.on { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 14px #14f19555; }
.inview { position: fixed; left: 362px; top: 74px; z-index: 3; font: 11px var(--mono); color: var(--dim); background: #03050a99; padding: 4px 9px; border-radius: 6px; }
#card:not([hidden]) ~ .ctrls { right: 392px; }
@media (max-width: 760px) {
  .nav { display: none; }
  .zhint { left: 8px; right: 8px; transform: none; bottom: calc(38vh + 16px); max-width: none; animation: none; }
  .zhint.gone { transform: translateY(20px); }
  .ctrls { top: 70px; transform: none; right: 8px; }
  .inview { left: 8px; top: 64px; }
}
@media (max-width: 760px) { .zhint span { display: none; } .zhint { padding: 10px 36px 10px 14px; } }

.brand .logo { width: 30px; height: 30px; border-radius: 8px; filter: drop-shadow(0 0 10px #14f19566); }

/* our coin (only rendered once a CA is set) */
.ca-pill { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-radius: 10px; border: 1px solid #14f19566; background: #14f19512; font-size: 12px; white-space: nowrap; animation: caIn .5s ease both; }
.ca-pill b { color: var(--accent); }
.ca-pill code { font-family: var(--mono); color: var(--ink); }
.ca-pill button, .ca-pill a { border: 0; background: #ffffff10; color: var(--ink); border-radius: 7px; padding: 5px 8px; font: 600 11px var(--sans); text-decoration: none; cursor: pointer; }
.ca-pill a { background: var(--accent); color: #04140c; }
@keyframes caIn { from { opacity: 0; transform: translateY(-6px); } }
@media (max-width: 760px) { .ca-pill code { display: none; } }

.xlink { display: inline-flex; align-items: center; gap: 5px; color: var(--ink) !important; text-decoration: none; }
.xlink:hover { color: var(--accent) !important; }
