/* ============================================================
 * 合成大·学校 —— 样式（白底、扁平、无渐变无发光）
 * ============================================================ */
:root {
  --bg: #ffffff;
  --ink: #111111;
  --muted: #767676;
  --line: #e3e3e3;
  --line-strong: #111111;
  --soft: #f6f6f6;
  --red: #e03131;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  overflow: hidden;
}

[hidden] { display: none !important; }

#app { height: 100%; display: flex; flex-direction: column; }

.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------------- 选校界面 ---------------- */
#selectScreen { overflow-y: auto; padding: 32px 20px 28px; align-items: center; }

.hero { text-align: center; margin-bottom: 20px; }

.hero h1 {
  margin: 0;
  font-size: clamp(22px, 5vw, 32px);
  font-weight: 700;
  letter-spacing: .08em;
}

.hero .sub {
  margin: 10px auto 0;
  max-width: 520px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.toolbar {
  width: 100%;
  max-width: 780px;
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.chip {
  font-size: 12px;
  color: var(--muted);
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.chip b { color: var(--ink); font-size: 14px; margin-left: 3px; }

.grid {
  width: 100%;
  max-width: 780px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  transition: border-color .12s, background .12s;
}

.card:hover { border-color: #b9b9b9; }

.card.selected {
  border-color: var(--line-strong);
  background: var(--soft);
}

.card img {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: #fff;
  object-fit: contain;
  border: 1px solid var(--line);
}

.card .name { font-size: 12.5px; font-weight: 500; text-align: center; line-height: 1.35; }

.card .rank {
  position: absolute;
  top: 8px; left: 8px;
  font-size: 10px;
  color: var(--muted);
}

.card .idx {
  position: absolute;
  top: 8px; right: 9px;
  font-size: 10px;
  color: #c4c4c4;
  font-variant-numeric: tabular-nums;
}

.card.selected .rank { color: var(--ink); }

.hint {
  max-width: 780px;
  width: 100%;
  margin: 18px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.8;
  text-align: center;
}

.actions { margin-top: 20px; }

.btn {
  font: inherit;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  padding: 11px 34px;
  cursor: pointer;
  transition: opacity .12s;
}

.btn:active { opacity: .7; }

.btn.primary { background: var(--ink); color: #fff; }

.btn.primary:disabled {
  background: #fff;
  border-color: var(--line);
  color: #bdbdbd;
  cursor: not-allowed;
}

.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }

/* ---------------- 游戏界面 ---------------- */
#gameScreen { padding: 12px 12px 8px; align-items: center; gap: 8px; }

.hud {
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hud-left { display: flex; gap: 8px; }

.hud-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.hud-item span { font-size: 11px; color: var(--muted); }
.hud-item b { font-size: 16px; font-variant-numeric: tabular-nums; }

.hud-right { display: flex; gap: 6px; }

.icon-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}

.icon-btn:hover { border-color: #b9b9b9; }
.icon-btn:active { background: var(--soft); }
.icon-btn.wide { width: auto; padding: 0 12px; font-size: 12px; }

.goal-bar {
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.goal-bar img {
  width: 22px; height: 22px;
  border-radius: 50%;
  object-fit: contain;
  border: 1px solid var(--line);
}

.goal-bar b { color: var(--ink); font-size: 13px; font-weight: 600; }
.goal-tip { margin-left: auto; font-size: 11px; }

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

#canvas {
  display: block;
  border: 1px solid var(--line);
  border-radius: 12px;
  touch-action: none;
  cursor: pointer;
  background: #fff;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .88);
}

.overlay .panel {
  text-align: center;
  padding: 26px 32px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  max-width: 88%;
}

.overlay h2 { margin: 0 0 8px; font-size: 20px; font-weight: 600; }
.overlay p { margin: 0 0 20px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.ov-actions { display: flex; gap: 8px; justify-content: center; }
.ov-actions .btn { padding: 9px 22px; font-size: 13px; }

.chain {
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  gap: 3px;
  overflow-x: auto;
  padding: 6px 2px 2px;
  scrollbar-width: none;
}
.chain::-webkit-scrollbar { display: none; }

.chain .chip {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 0;
  border: 0;
  opacity: .45;
}

.chain .chip.drop { opacity: 1; }

.chain .chip img {
  border-radius: 50%;
  object-fit: contain;
  border: 1px solid var(--line);
  background: #fff;
}

.chain .cn { font-size: 9px; color: var(--muted); white-space: nowrap; }
.chain .chip.drop .cn { color: var(--ink); }
.chain .arrow { flex: none; color: #d0d0d0; font-size: 10px; }

/* ---------------- 分享面板 ---------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(255, 255, 255, .9);
}

.sheet {
  width: 100%;
  max-width: 380px;
  max-height: 100%;
  overflow-y: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  text-align: center;
}

.sheet h3 { margin: 0 0 14px; font-size: 17px; font-weight: 600; }

.share-preview {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--soft);
  font-size: 13px;
  line-height: 1.75;
  text-align: left;
  word-break: break-word;
}

.share-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.share-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 11px 8px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.share-item:hover { border-color: #b9b9b9; }
.share-item:active { background: var(--soft); }
.share-item em { font-style: normal; font-size: 10px; color: var(--muted); }

.share-note {
  margin: 0 0 16px;
  font-size: 11.5px;
  line-height: 1.8;
  color: var(--muted);
  text-align: left;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  z-index: 60;
  transform: translateX(-50%);
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s;
}

.toast.on { opacity: 1; }

@media (max-width: 520px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
  .card img { width: 46px; height: 46px; }
  .card .name { font-size: 11px; }
  .hud-item b { font-size: 15px; }
  .goal-tip { display: none; }
}
