/* ============================================================
 * 合成大·学校 —— 样式（白底、扁平、无渐变无发光）
 * ============================================================ */
: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: 18px 20px 28px; align-items: center; }

/* ---------------- 返回上一级 ---------------- */
.page-bar {
  width: 100%;
  max-width: 780px;
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

#gameScreen .page-bar { max-width: 560px; margin-bottom: 2px; }

.back-link {
  display: inline-block;
  font: inherit;
  font-size: 12.5px;
  line-height: 1;
  color: var(--muted);
  text-decoration: none;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  transition: border-color .12s, color .12s;
}

.back-link:hover { border-color: #b9b9b9; color: var(--ink); }
.back-link:active { background: var(--soft); }

.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; }

/* ---------------- 开局选项 ---------------- */
.opts {
  width: 100%;
  max-width: 780px;
  margin-top: 14px;
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.opt {
  flex: 1;
  min-width: 0;
  padding: 12px 16px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.opt-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.opt-head span { font-size: 12px; color: var(--muted); }
.opt-head b { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* 离散滑块（参考 Codex 思考深度）：细轨道 + 停靠点 + 旋钮，下面一行档位名。
   .range-rail 与 .range-labels 左右都内缩半个旋钮（9px），
   停靠点、旋钮、填色、标签都按同一个百分比定位，任何宽度下都对得齐。 */
.range {
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
  padding: 2px 0;
}

.range-rail {
  position: relative;
  height: 18px;
  margin: 0 9px;
}

.range-rail::before,
.range-fill {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  height: 4px;
  margin-top: -2px;
  border-radius: 999px;
}

.range-rail::before { right: 0; background: var(--line); }

.range-fill {
  width: 0;
  background: var(--ink);
  transition: width .18s cubic-bezier(.32, .72, 0, 1);
}

.range-dot {
  position: absolute;
  top: 50%;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--line);
  transform: translate(-50%, -50%);
  transition: border-color .18s;
}

.range-dot.on { border-color: var(--ink); }

.range-knob {
  position: absolute;
  top: 50%;
  left: 0;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .14);
  transform: translate(-50%, -50%);
  transition: left .18s cubic-bezier(.32, .72, 0, 1), transform .12s ease, box-shadow .12s;
}

.range.drag .range-knob { transform: translate(-50%, -50%) scale(1.12); }
.range:focus-visible .range-knob { box-shadow: 0 0 0 4px rgba(17, 17, 17, .14); }

.range-labels {
  position: relative;
  height: 16px;
  margin: 8px 9px 0;
}

.range-name {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  transition: color .18s;
}

.range-name.cur { color: var(--ink); font-weight: 600; }

.opt-toggle {
  flex: 0 0 auto;
  width: 186px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}

.opt-toggle em { font-style: normal; font-size: 10.5px; color: var(--muted); }
.opt-toggle.on { border-color: var(--line-strong); background: var(--soft); }
.opt-toggle.on em { color: var(--ink); }

.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;
  cursor: pointer;
}

.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; }
}
