:root {
  --bg: #f2f7ff;
  --panel: #ffffff;
  --line: #d7e3f4;
  --ink: #0f172a;
  --muted: #64748b;
  --ok: #10b981;
  --bad: #ef4444;
  --dup: #f59e0b;
  --accent: #0ea5e9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "SF Pro Display", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% -8%, #dbeafe 0%, rgba(219, 234, 254, 0.12) 45%, transparent 65%),
    radial-gradient(circle at 90% 0%, #e0f2fe 0%, rgba(224, 242, 254, 0.08) 42%, transparent 60%),
    linear-gradient(180deg, #eef5ff 0%, var(--bg) 36%, #edf7ff 100%);
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 14px;
  row-gap: 8px;
  margin-bottom: 12px;
}

h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 38px);
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.controls {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  align-items: center;
  justify-self: end;
}

.mini,
.btn,
select {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  color: #0f172a;
  border-radius: 10px;
  padding: 7px 10px;
  font-weight: 700;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.top-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.btn.primary {
  color: #fff;
  border: none;
  background: linear-gradient(135deg, #06b6d4, #10b981);
}

.board-wrap {
  margin-top: 12px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  box-shadow:
    0 16px 34px rgba(15, 23, 42, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
  padding: 14px;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: linear-gradient(180deg, #fbfdff 0%, #f2f8ff 100%);
  padding: 7px 12px;
  font-weight: 700;
  font-size: 13px;
  text-align: center;
}

#feedback {
  margin: 8px 0 12px;
  min-height: 22px;
  font-weight: 700;
}

#feedback.good { color: var(--ok); }
#feedback.bad { color: var(--bad); }
#feedback.dup { color: var(--dup); }

.board {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  min-height: 520px;
  background:
    linear-gradient(135deg, rgba(224, 242, 254, 0.6) 0%, rgba(250, 245, 255, 0.6) 45%, rgba(236, 253, 245, 0.62) 100%),
    linear-gradient(180deg, #f8fbff 0%, #f4f9ff 100%);
  border-radius: 14px;
  padding: 8px;
}

.col {
  border: 1.5px solid var(--line);
  border-radius: 24px;
  padding: 14px 16px 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  min-height: 500px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.col-title {
  margin: 0 0 8px;
  color: #475569;
  font-size: 13px;
  letter-spacing: 0.3px;
  font-weight: 800;
}

.word-list {
  position: relative;
  flex: 1;
  min-height: 420px;
  margin-top: 10px;
}

.word-node {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  border: 1.5px solid #bfd5f8;
  background: linear-gradient(145deg, #ffffff 0%, #ecf5ff 100%);
  border-radius: 10px;
  width: 72px;
  min-width: 72px;
  max-width: 72px;
  aspect-ratio: 1 / 1;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.15;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.word-node:hover:not(:disabled) {
  background: linear-gradient(145deg, #eef8ff 0%, #ddf4ff 100%);
  border-color: #93c5fd;
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.16);
}

.word-node.matched,
.word-node:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  background: #eff6ff;
}

.word-node.distractor {
  border-style: solid;
  background: linear-gradient(145deg, #ffffff 0%, #ecf5ff 100%);
}

.word-node.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2);
}

.link-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.link-line {
  pointer-events: stroke;
  cursor: pointer;
}

.legend {
  margin-top: 12px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.dot.antonym { background: #10b981; }
.dot.co      { background: #f59e0b; }

.log {
  display: none;
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr;
  }
  .controls {
    justify-self: start;
    flex-wrap: wrap;
  }
  .hud { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board { grid-template-columns: 1fr; min-height: auto; }
  .col {
    border-radius: 20px;
    min-height: auto;
    aspect-ratio: auto;
  }
  .word-list {
    min-height: 300px;
  }
  .word-node {
    width: 64px;
    min-width: 64px;
    max-width: 64px;
  }
  .link-canvas { display: none; }
}
