:root {
  --bg: #07080d;
  --panel: rgba(19, 22, 32, 0.72);
  --panel-solid: #12151f;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #e8edf7;
  --muted: #8b96ad;
  --accent: #6ee7ff;
  --accent2: #a78bfa;
  --good: #34d399;
  --warn: #fbbf24;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { overflow-x: hidden; }

#aurora {
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 70vh;
  background:
    radial-gradient(38% 52% at 22% 18%, rgba(110, 231, 255, 0.16), transparent 70%),
    radial-gradient(34% 46% at 78% 12%, rgba(167, 139, 250, 0.18), transparent 72%),
    radial-gradient(46% 40% at 52% 44%, rgba(52, 211, 153, 0.10), transparent 74%);
  filter: blur(18px);
  pointer-events: none;
  animation: drift 22s ease-in-out infinite alternate;
  z-index: 0;
}

@keyframes drift {
  from { transform: translate3d(-2%, 0, 0) scale(1); }
  to   { transform: translate3d(3%, 3%, 0) scale(1.12); }
}

.top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px clamp(16px, 4vw, 44px) 10px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }

.logo {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  color: #06121a;
  background: linear-gradient(140deg, var(--accent), var(--accent2));
  box-shadow: 0 8px 26px rgba(110, 231, 255, 0.28);
}

h1 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0.04em;
  font-weight: 650;
}

.sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.badges { display: flex; gap: 10px; flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}

.badge b { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 650; }

.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
}

.dot.live {
  background: var(--good);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: clamp(14px, 2vw, 26px);
  padding: 8px clamp(16px, 4vw, 44px) 40px;
  align-items: start;
  max-width: 1400px;
  margin: 0 auto;
}

.stage { min-width: 0; }

.canvas-wrap {
  position: relative;
  border-radius: 16px;
  padding: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01));
  border: 1px solid var(--line);
  box-shadow: 0 26px 70px -30px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255,255,255,0.05);
  touch-action: none;
  overflow: hidden;
  width: 100%;
  max-width: min(100%, calc(100vh - 250px));
  margin: 0 auto;
}

.canvas-wrap.crosshair { cursor: crosshair; }
.canvas-wrap.picking { cursor: copy; }

#board {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 9px;
  background: #0b0e15;
  image-rendering: pixelated;
  cursor: crosshair;
}

.cursors {
  position: absolute;
  inset: 10px;
  pointer-events: none;
  overflow: hidden;
}

.ghost-cursor {
  position: absolute;
  width: 0; height: 0;
  transition: transform 140ms cubic-bezier(.2,.8,.3,1);
  will-change: transform;
}

.ghost-cursor .tip {
  position: absolute;
  left: -4px; top: -4px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--c, #fff);
  box-shadow: 0 0 0 2px rgba(7, 8, 13, 0.85), 0 0 14px var(--c, #fff);
}

.ghost-cursor .name {
  position: absolute;
  left: 10px; top: 6px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10.5px;
  line-height: 1.5;
  white-space: nowrap;
  color: #07080d;
  background: var(--c, #fff);
  font-weight: 650;
  opacity: 0.92;
}

.hint {
  position: absolute;
  left: 22px; bottom: 22px;
  padding: 6px 12px;
  font-size: 11.5px;
  color: var(--muted);
  background: rgba(7, 8, 13, 0.7);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  pointer-events: none;
  transition: opacity 400ms;
}

.hint.gone { opacity: 0; }

.replay-bar {
  position: absolute;
  left: 10px; right: 10px; bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 0 0 9px 9px;
  background: rgba(8, 10, 16, 0.88);
  border-top: 1px solid var(--line-strong);
  backdrop-filter: blur(12px);
}

.replay-bar.hidden { display: none; }

.rbtn {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 140ms;
}

.rbtn:hover { background: rgba(255,255,255,0.14); }

#rRange { flex: 1; accent-color: var(--accent); height: 3px; }

.rtime {
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 108px;
  text-align: right;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.swatches {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  padding: 9px 12px;
  border-radius: 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.swatch {
  width: 26px; height: 26px;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.14);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
  position: relative;
  padding: 0;
}

.swatch:hover { transform: translateY(-2px) scale(1.06); }

.swatch.active {
  transform: translateY(-2px) scale(1.1);
  box-shadow: 0 0 0 2px #07080d, 0 0 0 4px var(--accent);
}

.tools { display: flex; gap: 8px; flex-wrap: wrap; }

.tool {
  padding: 9px 13px;
  font-size: 12.5px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: color 140ms, border-color 140ms, background 140ms;
  white-space: nowrap;
}

.tool:hover { color: var(--text); border-color: var(--line-strong); }
.tool.on { color: #06121a; background: linear-gradient(140deg, var(--accent), var(--accent2)); border-color: transparent; font-weight: 620; }

.meter {
  position: relative;
  margin-top: 12px;
  height: 30px;
  border-radius: 9px;
  background: rgba(255,255,255,0.045);
  border: 1px solid var(--line);
  overflow: hidden;
  display: flex;
  align-items: center;
}

.meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, rgba(110,231,255,0.28), rgba(167,139,250,0.28));
  transition: width 100ms linear;
}

.meter span {
  position: relative;
  padding-left: 12px;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.side { display: grid; gap: 14px; }

.card {
  padding: 16px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.card h2 {
  margin: 0 0 13px;
  font-size: 12.5px;
  font-weight: 620;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tag {
  font-size: 9.5px;
  padding: 2px 7px;
  border-radius: 5px;
  letter-spacing: 0.08em;
  background: rgba(52, 211, 153, 0.16);
  color: var(--good);
  border: 1px solid rgba(52, 211, 153, 0.3);
}

.tag.quiet {
  background: rgba(255,255,255,0.06);
  color: var(--muted);
  border-color: var(--line);
  font-variant-numeric: tabular-nums;
}

.row {
  display: grid;
  grid-template-columns: 40px 1fr 48px;
  align-items: center;
  gap: 9px;
  margin-bottom: 9px;
  font-size: 11.5px;
  color: var(--muted);
}

.row b {
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 560;
  font-size: 11.5px;
}

.bar {
  height: 5px;
  border-radius: 999px;
  background: rgba(255,255,255,0.07);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 600ms cubic-bezier(.2,.8,.3,1);
}

#spark { width: 100%; display: block; margin: 4px 0 8px; opacity: 0.9; height: 46px; }

.meta {
  margin: 0;
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.7;
  font-variant-numeric: tabular-nums;
}

.people, .board-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
  max-height: 200px;
  overflow-y: auto;
}

.people li, .board-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
}

.people .empty, .board-list .empty {
  color: var(--muted);
  font-size: 11.5px;
  font-style: italic;
}

.people .chip {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 10px currentColor;
}

.people .me { color: var(--accent); font-size: 9.5px; margin-left: auto; letter-spacing: .06em; }
.people .cnt { margin-left: auto; color: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }

.board-list { counter-reset: rank; }
.board-list li { counter-increment: rank; }
.board-list li::before {
  content: counter(rank);
  width: 16px;
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}
.board-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list .n { margin-left: auto; color: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }

.ghost p { margin: 0 0 9px; font-size: 11.5px; line-height: 1.75; color: var(--muted); }
.ghost p:last-child { margin-bottom: 0; }
.ghost .tiny { font-size: 10.5px; opacity: 0.8; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  padding: 10px 18px;
  border-radius: 11px;
  font-size: 12.5px;
  color: var(--text);
  background: rgba(18, 21, 31, 0.95);
  border: 1px solid var(--line-strong);
  box-shadow: 0 18px 46px -18px #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms, transform 200ms;
  z-index: 50;
  max-width: min(90vw, 420px);
  text-align: center;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: rgba(248, 113, 113, 0.5); }

@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); display: grid; }
  .toolbar { justify-content: center; }
}

@media (max-width: 560px) {
  .top { padding: 16px 14px 6px; }
  .layout { padding: 6px 14px 32px; gap: 12px; }
  .badges { width: 100%; }
  .badge { font-size: 11.5px; padding: 6px 11px; }
  .swatch { width: 23px; height: 23px; }
  .canvas-wrap { padding: 6px; }
  .cursors { inset: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  #aurora { animation: none; }
  * { transition-duration: 1ms !important; }
}

.nightlink {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dashed rgba(110, 231, 255, 0.4);
  padding-bottom: 1px;
  transition: color 140ms, border-color 140ms;
}

.nightlink:hover {
  color: #fff;
  border-bottom-color: var(--accent);
}
