:root {
  --bg: #fdf6e3;
  --panel: #fff;
  --ink: #333;
  --accent: #e63946;
  --muted: #999;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* hidden 属性优先于任何 display 规则 */
[hidden] { display: none !important; }

body {
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

#app { max-width: 520px; margin: 0 auto; padding: 24px 16px 48px; }

header { text-align: center; margin-bottom: 20px; }
header h1 { font-size: 30px; }
.sub { color: var(--muted); margin-top: 6px; font-size: 14px; }

.card {
  background: var(--panel);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  margin-bottom: 16px;
}

.field { display: block; margin-bottom: 18px; }
.label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; }
.label small { color: var(--muted); font-weight: 400; }

input[type="text"] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
}
#invite-status { display: inline-block; margin-left: 8px; font-size: 13px; }
#invite-status.ok { color: #2a9d8f; }
#invite-status.bad { color: var(--accent); }

.stepper { display: flex; gap: 10px; }
.step-btn {
  width: 44px; height: 36px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fafafa;
  font-size: 18px;
  cursor: pointer;
}
.step-btn:hover { background: #f0f0f0; }

/* 级数格子 */
#level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 10px;
}
.cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  border: 2px dashed transparent;
  background: #fafafa;
}
.cell:hover { border-color: var(--accent); }
.cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cell .tag {
  position: absolute;
  left: 4px; top: 4px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 11px;
  border-radius: 4px;
  padding: 1px 5px;
}
.cell .clear {
  position: absolute;
  right: 4px; top: 4px;
  width: 20px; height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

/* 合成链预览 */
#chain-preview {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 8px;
  background: #fafafa;
  border-radius: 10px;
}
#chain-preview img { border-radius: 50%; object-fit: cover; }
#chain-preview .arrow { color: #bbb; font-size: 12px; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn.big { width: 100%; font-size: 17px; padding: 14px; }
.btn.ghost {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn:disabled { opacity: 0.5; cursor: default; }

.error { color: var(--accent); margin-top: 10px; font-size: 14px; }

/* 成功面板 */
#success-card h2 { margin-bottom: 10px; }
.share-row { display: flex; gap: 8px; margin: 12px 0; }
#share-url { flex: 1; background: #fafafa; font-size: 13px; }
.success-actions { display: flex; gap: 10px; }
