/* arabic.fit — place
   Monochrome. Pure black, hairline rules, square corners, no ornament.
   The only colour on the page is the board itself and the paint swatches. */

:root {
  --bg: #000000;
  /* Near-opaque so panels stay black when the white board is behind them. */
  --surface: rgba(0, 0, 0, 0.9);
  --line: rgba(255, 255, 255, 0.16);
  --line-strong: rgba(255, 255, 255, 0.32);
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.56);
  --faint: rgba(255, 255, 255, 0.34);
  --danger: #ff3b30;
  --booster: #c084fc;

  --shadow: 0 24px 60px -18px rgba(0, 0, 0, 0.9);
  /* Apple-ish ease-out: fast start, long settle. */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --fast: 180ms;
  --med: 320ms;
  --slow: 620ms;

  /* SF Pro on Apple devices, Segoe UI Variable on Windows 11 — both are
     high-quality variable faces, and neither costs a network request. */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Segoe UI Variable Display", "Segoe UI Variable Text", "Segoe UI", Inter, system-ui,
    Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  /* dvh tracks the mobile URL bar showing and hiding; 100vh does not, which
     leaves the palette dock cut off under Safari's chrome. */
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-synthesis: none;
  overscroll-behavior: none;
}

button {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  border: 0;
  border-radius: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 1px solid #fff;
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

/* A class like `display: grid` outranks the UA rule for [hidden], so elements
   toggled via the hidden attribute need this or they never actually hide. */
[hidden] {
  display: none !important;
}

/* Micro-headings. Hierarchy comes from size and colour, never from capitals. */
.topbar .brand-name,
.hud-key,
.ik,
.modal h3 {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: -0.006em;
  color: var(--faint);
}

/* ── board ───────────────────────────────────────────────────────────────── */

#board {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#board:active {
  cursor: grabbing;
}
body.paint #board {
  cursor: crosshair;
}

/* ── shared surface ──────────────────────────────────────────────────────── */

.topbar,
.hud,
.dock,
.inspector,
.modal,
.toast {
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--line);
  border-radius: 0;
}

/* ── top bar ─────────────────────────────────────────────────────────────── */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 14px 0 18px;
  border-width: 0 0 1px 0;
  animation: drop var(--slow) var(--ease) both;
}

@keyframes drop {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}
.brand-mark {
  width: 13px;
  height: 13px;
  background: #fff;
}
.brand-name {
  font-size: 12px;
  font-weight: 600;
}
.brand .dim {
  color: var(--faint);
}

.invite {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 500;
  transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease),
    background var(--fast) var(--ease);
}
.invite:hover {
  color: #000;
  background: #fff;
  border-color: #fff;
}
.dc {
  width: 16px;
  height: 12px;
  fill: currentColor;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  color: var(--muted);
  transition: color var(--fast) var(--ease), background var(--fast) var(--ease),
    border-color var(--fast) var(--ease);
}
.icon-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: square;
  stroke-linejoin: miter;
}
#adminBtn svg {
  fill: currentColor;
  stroke: none;
}
.icon-btn:hover {
  color: #000;
  background: #fff;
  border-color: #fff;
}
.icon-btn.sm {
  width: 28px;
  height: 28px;
  font-size: 15px;
  line-height: 1;
}
.icon-btn.wide {
  width: auto;
  padding: 0 10px;
  font-size: 11.5px;
  letter-spacing: -0.006em;
}

.account {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 32px;
  padding: 0 14px;
  background: #fff;
  color: #000;
  font-weight: 600;
  font-size: 12.5px;
  transition: opacity var(--fast) var(--ease);
}
.account:hover {
  opacity: 0.82;
}
.account.signed {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  padding-left: 4px;
  font-weight: 500;
}
.account.signed:hover {
  opacity: 1;
  border-color: var(--line-strong);
}
.account img {
  width: 24px;
  height: 24px;
  display: block;
  filter: contrast(1.04);
}
.account .tag {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.006em;
  color: #000;
  background: #fff;
  padding: 3px 6px;
}
.account.signed.booster {
  border-color: color-mix(in srgb, var(--booster) 55%, transparent);
}
.account .tag.booster-tag {
  color: #160721;
  background: var(--booster);
}
.booster-name {
  color: var(--booster) !important;
}

/* ── hud ─────────────────────────────────────────────────────────────────── */

.hud {
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 15;
  padding: 12px 14px;
  border-width: 1px 1px 0 0;
  display: grid;
  gap: 7px;
  min-width: 150px;
  animation: rise var(--slow) var(--ease) both;
  animation-delay: 90ms;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}
.hud-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}
.hud-key {
  color: var(--faint);
  font-size: 11.5px;
  font-weight: 600;
}
.hud-val {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.zoom-btns {
  display: flex;
  gap: 5px;
  margin-top: 4px;
}

/* ── palette dock ────────────────────────────────────────────────────────── */

.dock {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 18;
  display: flex;
  align-items: center;
  gap: 14px;
  /* Extra room so the scaled/ringed swatch never touches the edge. */
  padding: 15px 18px;
  border-width: 1px 1px 0 1px;
  animation: dockIn var(--slow) var(--ease) both;
  animation-delay: 150ms;
  max-width: min(96vw, 940px);
  --sw: clamp(17px, 2.3vw, 26px);
  --sgap: clamp(3px, 0.4vw, 5px);
}
@keyframes dockIn {
  from {
    opacity: 0;
    transform: translate(-50%, 22px);
  }
}

.swatches {
  display: flex;
  gap: var(--sgap);
  flex-wrap: nowrap;
  justify-content: center;
  flex: 0 0 auto;
}
/* Selection happens in place. Lifting the swatch out of the dock made the
   padding look uneven and clipped the ring, so hover/selection only ever
   scale and outline — the row's height never changes. */
.swatch {
  width: var(--sw);
  height: var(--sw);
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  transition: transform var(--med) var(--ease), box-shadow var(--med) var(--ease),
    border-color var(--fast) var(--ease);
}
.swatch:hover {
  transform: scale(1.14);
  border-color: rgba(255, 255, 255, 0.55);
  z-index: 2;
}
.swatch[aria-selected="true"] {
  transform: scale(1.14);
  border-color: transparent;
  box-shadow: 0 0 0 1px #000, 0 0 0 3px #fff;
  z-index: 3;
}
.swatch[aria-selected="true"]:hover {
  transform: scale(1.2);
}

.dock-divider {
  width: 1px;
  align-self: stretch;
  background: var(--line);
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 28px;
  padding: 0 13px;
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.006em;
  color: var(--muted);
  white-space: nowrap;
  transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.mode-btn:hover {
  color: var(--text);
  border-color: var(--line-strong);
}
body.paint .mode-btn {
  color: #000;
  background: #fff;
  border-color: #fff;
}
.mode-dot {
  width: 6px;
  height: 6px;
  background: var(--faint);
  transition: background var(--fast) var(--ease);
}
body.paint .mode-dot {
  background: #000;
  animation: blink 1.6s var(--ease-in-out) infinite;
}
@keyframes blink {
  50% {
    opacity: 0.25;
  }
}

/* Saved pixel balance and the progress toward the next earned pixel. */
.wallet {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  column-gap: 7px;
  row-gap: 3px;
  min-width: 112px;
  animation: fadeIn var(--med) var(--ease) both;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
}
.wallet-label,
.wallet #earnText {
  font-family: var(--mono);
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
  color: var(--faint);
  letter-spacing: -0.006em;
}
.wallet strong {
  justify-self: end;
  font-family: var(--mono);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.wallet #earnText {
  grid-column: 1 / -1;
  font-size: 10px;
  color: var(--muted);
}
.wallet.booster strong,
.wallet.booster #earnText {
  color: var(--booster);
}
.wallet-bar {
  grid-column: 1 / -1;
  height: 2px;
  background: rgba(255, 255, 255, 0.18);
}
.wallet-fill {
  height: 100%;
  width: 0;
  background: #fff;
  transform-origin: left;
  transition: width 250ms linear;
}
.wallet.booster .wallet-fill {
  background: var(--booster);
}

/* ── server panel ────────────────────────────────────────────────────────── */

.server {
  position: fixed;
  right: 0;
  top: 56px;
  z-index: 16;
  width: 316px;
  max-width: calc(100vw - 24px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--line);
  border-width: 0 0 1px 1px;
  animation: slideIn var(--slow) var(--ease) both;
  animation-delay: 210ms;
  /* Never taller than the screen, however busy the server is. */
  max-height: calc(100dvh - 56px);
}
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
}

/* header doubles as the collapse control */
.server-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px 14px;
  text-align: left;
  transition: background var(--fast) var(--ease);
}
.server-head:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Server icon, sized to sit centred against both lines of the title block. */
.server-icon {
  position: relative;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  align-self: center;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  overflow: hidden;
}
/* Until the real icon loads, show the server's initial rather than a hole. */
.server-icon::before {
  content: attr(data-initial);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}
.server-icon img {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity var(--med) var(--ease);
}
.server-icon.loaded img {
  opacity: 1;
}

/* The liveness cue moves inline with the count. */
.live-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  background: #fff;
  animation: live 2.4s var(--ease-in-out) infinite;
}
@keyframes live {
  50% {
    opacity: 0.28;
  }
}
.server.offline .live-dot {
  background: var(--faint);
  animation: none;
}

.server-id {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.server-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.015em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.server-count {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--faint);
}

.chev {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.6;
  stroke-linecap: square;
  transition: transform var(--med) var(--ease), stroke var(--fast) var(--ease);
}
.server-head:hover .chev {
  stroke: var(--text);
}
.server.collapsed .chev {
  transform: rotate(-90deg);
}

/* 1fr -> 0fr animates the height smoothly without hardcoding one */
.server-wrap {
  display: grid;
  grid-template-rows: 1fr;
  min-height: 0;
  max-height: calc(100dvh - 117px);
  overflow: hidden;
  visibility: visible;
  transition:
    grid-template-rows var(--med) var(--ease),
    max-height var(--med) var(--ease),
    opacity var(--med) var(--ease),
    visibility 0s linear 0s;
}
.server.collapsed .server-wrap {
  grid-template-rows: 0fr;
  max-height: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition-delay: 0s, 0s, 0s, var(--med);
}
.server-body {
  overflow: hidden;
  min-height: 0;
  height: min(720px, calc(100dvh - 117px));
  display: grid;
  grid-template-rows: minmax(0, 3fr) minmax(178px, 1fr);
}
.server-community {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Only the sections scroll — the join button stays pinned to the bottom of the
   panel instead of being pushed off-screen by a long member list. */
.server-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden; /* long usernames must ellipsis, not scroll sideways */
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.server-scroll::-webkit-scrollbar {
  width: 4px;
}
.server-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
}

.server-section {
  border-top: 1px solid var(--line);
  padding: 12px 14px;
}
.server-section h4 {
  margin: 0 0 10px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--faint);
  letter-spacing: -0.006em;
}
.server-section h4 .dim {
  color: rgba(255, 255, 255, 0.22);
}

/* voice channels */
.vc + .vc {
  margin-top: 12px;
}
.vc-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.vc-icon {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.vc-name {
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.vc-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
}
.vc-faces {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 8px 0 0 21px;
  flex-wrap: wrap;
}
.vc-more {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--faint);
}

/* member list */
/* No scroll of its own — the panel body owns the single scroll region, so
   there's never a scrollbar inside a scrollbar. */
.member-list {
  display: grid;
  gap: 2px;
}
.member {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 6px;
  margin: 0 -6px;
  transition: background var(--fast) var(--ease);
}
.member:hover {
  background: rgba(255, 255, 255, 0.05);
}
.member-name {
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.member:hover .member-name {
  color: var(--text);
}
.member.booster .member-name {
  color: var(--booster);
}
.member-game {
  font-size: 10.5px;
  color: var(--faint);
  max-width: 92px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* avatar with a status pip */
.av {
  position: relative;
  display: block;
  width: var(--av);
  height: var(--av);
  flex: 0 0 auto;
}
.av img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  filter: contrast(1.04);
  background: #111;
}
.av.booster img {
  outline: 1px solid var(--booster);
  outline-offset: 1px;
}
.av::after {
  content: "";
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 7px;
  height: 7px;
  border: 1.5px solid #000;
}
/* Status reads as brightness rather than colour — a wall of red dots would be
   the loudest thing on an otherwise black and white page. */
.av-online::after {
  background: #fff;
}
.av-idle::after {
  background: rgba(255, 255, 255, 0.5);
}
.av-dnd::after {
  background: rgba(255, 255, 255, 0.22);
}
.av-offline::after {
  background: rgba(255, 255, 255, 0.12);
}

.server-join {
  display: block;
  padding: 12px;
  border-top: 1px solid var(--line);
  text-align: center;
  text-decoration: none;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  transition: color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.server-join:hover {
  color: #000;
  background: #fff;
}

/* The bottom quarter of the community panel is a compact clan leaderboard. */
.home-clans {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 60%);
}
.home-clans-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px 9px;
  border-bottom: 1px solid var(--line);
}
.home-clans-head h4 {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 650;
  color: var(--text);
}
.home-clans-head span {
  display: block;
  font-size: 9.5px;
  color: var(--faint);
}
.home-clans-head button {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease),
    background var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.home-clans-head button:hover {
  color: #000;
  border-color: #fff;
  background: #fff;
  transform: translateY(-1px);
}
.home-clan-list {
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
.home-clan-row {
  --i: 0;
  width: 100%;
  min-height: 47px;
  display: grid;
  grid-template-columns: 22px 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 7px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  animation: clanItemIn 420ms var(--ease) both;
  animation-delay: calc(var(--i) * 45ms);
  transition: background var(--fast) var(--ease), padding-left var(--fast) var(--ease);
}
.home-clan-row:hover {
  padding-left: 17px;
  background: rgba(255, 255, 255, 0.055);
}
.home-clan-rank, .clan-rank {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--faint);
}
.home-clan-mark {
  width: 22px;
  height: 22px;
  display: block;
  flex: 0 0 22px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}
.home-clan-copy, .home-clan-pixels {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.home-clan-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  font-weight: 620;
}
.home-clan-copy small, .home-clan-pixels small {
  font-size: 9.5px;
  color: var(--faint);
}
.home-clan-pixels {
  justify-items: end;
  font-family: var(--mono);
}
.home-clan-pixels strong {
  font-size: 10.5px;
  font-weight: 500;
}
.home-clan-empty {
  margin: 0;
  padding: 18px 14px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  animation: fade var(--med) var(--ease) both;
}

/* ── pixel inspector ─────────────────────────────────────────────────────── */

.inspector {
  position: fixed;
  z-index: 22;
  width: 272px;
  padding: 16px;
  animation: insp var(--med) var(--ease) both;
}
@keyframes insp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}
.inspector-close {
  position: absolute;
  top: 10px;
  right: 12px;
  color: var(--faint);
  font-size: 17px;
  line-height: 1;
  transition: color var(--fast) var(--ease);
}
.inspector-close:hover {
  color: var(--text);
}
.inspector-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 15px;
}
.inspector-avatar {
  width: 42px;
  height: 42px;
  background: #111;
  border: 1px solid var(--line);
  object-fit: cover;
  filter: contrast(1.04);
}
.inspector-name {
  font-weight: 600;
  font-size: 14px;
}
.inspector-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
}
.inspector-meta {
  display: grid;
  gap: 9px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.inspector-meta > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.ik {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--faint);
}
.iv {
  font-family: var(--mono);
  font-size: 11.5px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.iv .chip {
  width: 11px;
  height: 11px;
  border: 1px solid var(--line-strong);
}
.inspector-actions {
  margin-top: 15px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

#inspClanRow {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.clan-chip {
  border-bottom: 1px solid currentColor;
  padding-bottom: 1px;
}

button.danger {
  width: 100%;
  height: 32px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: -0.006em;
  transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease),
    background var(--fast) var(--ease);
}
button.danger:hover {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

/* ── modals ──────────────────────────────────────────────────────────────── */

.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  animation: fade var(--med) var(--ease) both;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
.modal {
  width: min(430px, 100%);
  padding: 28px;
  animation: modalIn var(--med) var(--ease) both;
}
.modal.wide {
  width: min(760px, 100%);
}
@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}
.modal h2 {
  margin: 0 0 10px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.modal h3 {
  margin: 0 0 11px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--faint);
}
.modal-sub {
  margin: 0 0 20px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}
.modal-sub strong {
  color: var(--text);
  font-weight: 600;
}
.profile-modal {
  width: min(460px, 100%);
}

.clan-modal {
  width: min(100%, 560px);
  max-height: min(760px, calc(100dvh - 40px));
  padding: 0;
  overflow: hidden;
  box-shadow: 0 36px 100px -34px rgba(0, 0, 0, 0.96);
}
.clan-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 24px 19px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.045), transparent 62%);
}
.clan-modal-head .modal-sub {
  max-width: 430px;
  margin: 0;
}
.modal-close {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease),
    background var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.modal-close span {
  display: block;
  transform: translateY(-1px);
  font-size: 23px;
  line-height: 1;
  font-weight: 300;
}
.modal-close:hover {
  color: #000;
  border-color: #fff;
  background: #fff;
  transform: rotate(4deg) scale(1.04);
}
.clan-modal-body {
  max-height: calc(min(760px, 100dvh - 40px) - 116px);
  overflow-y: auto;
  padding: 20px 24px 24px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.clan-section-title {
  margin: 24px 0 10px;
  font-size: 10.5px;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.clan-form {
  display: grid;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.022);
  animation: clanEditorIn var(--med) var(--ease) both;
}
.clan-field {
  display: grid;
  gap: 8px;
}
.clan-field-label {
  display: block;
  margin: 0;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.clan-form input[type="text"] {
  min-width: 0;
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  outline: 0;
  background: rgba(0, 0, 0, 0.62);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease),
    box-shadow var(--fast) var(--ease);
}
.clan-form input[type="text"]:focus {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.07);
}
.clan-color-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.clan-color-field legend {
  width: 100%;
  margin-bottom: 9px;
  padding: 0;
}
.clan-color-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 7px;
}
.clan-color-option {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
  transition: transform var(--fast) var(--ease), border-color var(--fast) var(--ease),
    box-shadow var(--fast) var(--ease);
}
.clan-color-option:hover {
  z-index: 1;
  transform: translateY(-2px) scale(1.06);
  border-color: rgba(255, 255, 255, 0.8);
}
.clan-color-option[aria-pressed="true"] {
  z-index: 2;
  transform: scale(1.11);
  border-color: #fff;
  box-shadow: 0 0 0 2px #000, 0 0 0 3px #fff;
}
.clan-form button, .clan-card button, .clan-request button, .clan-notice button,
.clan-owner-actions button, #profileClan {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  background: #171717;
  color: var(--text);
  font-size: 11.5px;
  font-weight: 600;
  transition: color var(--fast) var(--ease), background var(--fast) var(--ease),
    border-color var(--fast) var(--ease), transform var(--fast) var(--ease), opacity var(--fast) var(--ease);
}
.clan-form button:hover, .clan-card button:hover, .clan-request button:hover,
.clan-notice button:hover, .clan-owner-actions button:hover, #profileClan:hover {
  background: #fff;
  color: #000;
  border-color: #fff;
  transform: translateY(-1px);
}
.clan-form .clan-primary {
  justify-self: start;
  min-width: 132px;
  height: 40px;
  padding: 0 17px;
  background: #fff;
  color: #000;
  border-color: #fff;
}
.clan-primary.loading {
  opacity: 0.55;
  cursor: wait;
}
.clan-primary:disabled {
  pointer-events: none;
}
.clan-list {
  display: grid;
  gap: 8px;
}
.clan-card, .clan-request {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  animation: clanItemIn 420ms var(--ease) both;
  animation-delay: calc(var(--i, 0) * 38ms);
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease),
    transform var(--fast) var(--ease);
}
.clan-card:hover, .clan-request:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.045);
  transform: translateY(-1px);
}
.clan-card.featured {
  min-height: 76px;
  background: linear-gradient(110deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.014));
}
.clan-mark {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: block;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.17);
  transition: transform var(--med) var(--ease);
}
.clan-card:hover .clan-mark {
  transform: rotate(3deg) scale(1.05);
}
.clan-card strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  font-weight: 650;
}
.clan-detail, .clan-empty {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11.5px;
}
.clan-empty {
  margin: 18px 0;
  line-height: 1.5;
  animation: fade var(--med) var(--ease) both;
}
.clan-empty.compact {
  margin: 12px 0 0;
}
.clan-request-avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  object-fit: cover;
  border: 1px solid var(--line);
}
.clan-request .grow {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.clan-owner-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.clan-request .danger-action:hover,
.clan-owner-actions .danger-action:hover {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}
.clan-request .transfer-action {
  color: var(--booster);
}
.clan-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--booster);
  background: rgba(192, 132, 252, 0.045);
  animation: clanEditorIn var(--med) var(--ease) both;
}
.clan-notice p {
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}
.clan-notice .muted-action {
  color: var(--booster);
  opacity: 0.8;
}
.clan-skeleton {
  display: grid;
  gap: 10px;
}
.clan-skeleton i {
  display: block;
  height: 58px;
  border: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(255,255,255,.025), rgba(255,255,255,.075), rgba(255,255,255,.025));
  background-size: 220% 100%;
  animation: clanShimmer 1.1s linear infinite;
}
@keyframes clanItemIn {
  from { opacity: 0; transform: translateY(8px); }
}
@keyframes clanEditorIn {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
}
@keyframes clanShimmer {
  to { background-position: -220% 0; }
}
.profile-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.profile-head h2 {
  margin-bottom: 4px;
}
.profile-avatar {
  width: 64px;
  height: 64px;
  object-fit: cover;
  background: #111;
  border: 1px solid var(--line-strong);
}
.profile-role {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.profile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  margin-bottom: 16px;
}
.profile-stats > div {
  display: grid;
  gap: 7px;
  padding: 14px;
  min-width: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.profile-stats > div:nth-child(2n) {
  border-right: 0;
}
.profile-stats > div:nth-last-child(-n + 2) {
  border-bottom: 0;
}
.profile-stats span {
  font-size: 10.5px;
  color: var(--faint);
}
.profile-stats strong {
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.profile-note {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.profile-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.profile-actions button {
  width: 100%;
  height: 38px;
}

.profile-stats > div,
.identity,
.row,
.server-section,
.profile-head,
.profile-note {
  animation: uiPieceIn 430ms var(--ease) both;
}
@keyframes uiPieceIn {
  from { opacity: 0; transform: translateY(7px); }
}
.demo-note {
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
  border: 1px solid var(--line);
  border-left: 2px solid #fff;
  padding: 12px 14px;
  margin-bottom: 18px;
}
.demo-note strong {
  color: var(--text);
}
.demo-note code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
}

.identities {
  display: grid;
  gap: 1px;
  margin-bottom: 18px;
  background: var(--line);
  border: 1px solid var(--line);
}
.identity {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 14px;
  background: #000;
  text-align: left;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.identity:hover {
  background: #fff;
  color: #000;
}
.identity img {
  width: 32px;
  height: 32px;
}
.identity b {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
}
.identity span {
  font-size: 11px;
  color: var(--faint);
}
.identity:hover span {
  color: rgba(0, 0, 0, 0.6);
}

button.ghost {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.006em;
  transition: color var(--fast) var(--ease), background var(--fast) var(--ease),
    border-color var(--fast) var(--ease);
}
button.ghost:hover {
  color: #000;
  background: #fff;
  border-color: #fff;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 20px;
}
.list {
  display: grid;
  gap: 1px;
  max-height: 260px;
  overflow-y: auto;
}
.list:empty::after {
  content: "none";
  font-size: 11.5px;
  color: var(--faint);
  font-family: var(--mono);
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  font-size: 12.5px;
}
.row img {
  width: 22px;
  height: 22px;
}
.row .grow {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row .count {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--faint);
}
.pixel-grant {
  display: flex;
  gap: 4px;
}
.pixel-grant input {
  width: 58px;
  min-width: 0;
  height: 27px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 0;
  outline: 0;
  background: #080808;
  color: var(--text);
  font: 11px var(--mono);
}
.pixel-grant input:focus {
  border-color: #fff;
}
.pixel-grant button:disabled {
  opacity: 0.45;
  cursor: wait;
}
.row button {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.006em;
  padding: 4px 9px;
  border: 1px solid var(--line);
  color: var(--muted);
  transition: color var(--fast) var(--ease), background var(--fast) var(--ease),
    border-color var(--fast) var(--ease);
}
.row button:hover {
  color: #000;
  background: #fff;
  border-color: #fff;
}
.row button.ban:hover {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

/* ── toasts ──────────────────────────────────────────────────────────────── */

.toasts {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: grid;
  gap: 8px;
  justify-items: center;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  animation: toastIn var(--med) var(--ease) both;
}
.toast.out {
  animation: toastOut 220ms var(--ease-in-out) forwards;
}
.toast::before {
  content: "";
  width: 5px;
  height: 5px;
  background: #fff;
}
.toast.err::before {
  background: var(--danger);
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
}
@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(-6px);
  }
}

/* ── boot ────────────────────────────────────────────────────────────────── */

.boot {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity var(--slow) var(--ease), visibility var(--slow);
}
.boot.done {
  opacity: 0;
  visibility: hidden;
}
.boot-mark {
  width: 20px;
  height: 20px;
  background: #fff;
  animation: bootPulse 1.3s var(--ease-in-out) infinite;
}
@keyframes bootPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.45);
    opacity: 0.35;
  }
}

/* ── responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .hud {
    bottom: auto;
    top: 56px;
    border-width: 0 1px 1px 0;
  }
}

@media (max-width: 900px) {
  .invite span {
    display: none;
  }
  .admin-grid {
    grid-template-columns: 1fr;
  }
  /* The panel stays, but starts folded to its header so it never covers the
     board. Tapping the header opens it. */
  .server {
    width: 260px;
  }
  .member-list {
    max-height: 34vh;
  }
}

/* Once the full desktop dock no longer fits, give the palette its own balanced
   row and keep the mode/wallet controls together underneath it. */
@media (max-width: 760px) {
  .dock {
    --sw: clamp(20px, calc((100vw - 96px) / 11), 26px);
    max-width: 100vw;
    width: 100%;
    left: 0;
    transform: none;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
    border-width: 1px 0 0 0;
  }
  @keyframes dockIn {
    from {
      opacity: 0;
      transform: translateY(22px);
    }
  }
  .swatches {
    display: grid;
    grid-template-columns: repeat(11, var(--sw));
    justify-content: center;
    flex: 1 1 100%;
    min-width: 0;
    gap: 6px;
  }
  .dock-divider {
    display: none;
  }
}

@media (max-width: 560px) {
  .topbar {
    height: 52px;
    gap: 10px;
    padding: 0 10px 0 12px;
  }
  .account {
    padding: 0 10px;
    max-width: 46vw;
  }
  .account-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .server {
    top: 52px;
    width: min(300px, calc(100vw - 16px));
  }
  .server-body {
    height: min(650px, calc(100dvh - 113px));
    grid-template-rows: minmax(0, 2.5fr) minmax(170px, 1fr);
  }
  .member-list {
    max-height: 30vh;
  }

  .hud {
    display: none;
  }

  /* Floating next to a pixel doesn't work on a small screen — dock the
     inspector to the bottom, above the palette, at full width. */
  .inspector {
    left: 0 !important;
    right: 0;
    top: auto !important;
    bottom: 0;
    width: 100%;
    border-width: 1px 0 0 0;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    animation: sheetUp var(--med) var(--ease) both;
  }
  @keyframes sheetUp {
    from {
      opacity: 0;
      transform: translateY(16px);
    }
  }
  body.inspecting .dock {
    /* Get the palette out of the way while the sheet is up. */
    transform: translateY(120%);
    pointer-events: none;
  }

  .modal {
    padding: 22px;
  }
  .clan-modal {
    padding: 0;
    max-height: calc(100dvh - 20px);
  }
  .clan-modal-head {
    padding: 20px 18px 16px;
  }
  .clan-modal-body {
    max-height: calc(100dvh - 122px);
    padding: 17px 18px 20px;
  }
  .clan-color-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
  }
  .clan-card, .clan-request {
    gap: 9px;
    padding: 10px;
  }
  .clan-request {
    flex-wrap: wrap;
  }
  .clan-notice {
    align-items: flex-start;
    flex-direction: column;
  }
  .profile-actions {
    grid-template-columns: 1fr;
  }
  .toasts {
    top: 64px;
    width: 100%;
    padding: 0 12px;
  }
  .toast {
    white-space: normal;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

/* Touch devices: hover styles stick after a tap, so only apply the swatch
   lift where a real pointer exists. */
@media (hover: none) {
  .swatch:hover {
    transform: none;
    border-color: rgba(255, 255, 255, 0.2);
  }
  .swatch[aria-selected="true"] {
    transform: scale(1.14);
    border-color: transparent;
  }
  .swatch {
    min-width: var(--sw);
    min-height: var(--sw);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
