:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1a2233;
  --ink-2: #5a6478;
  --ink-3: #8d96a8;
  --line: #e4e8f0;
  --brand: #2f5bea;
  --brand-soft: #eef2ff;
  --danger: #d93b4b;
  --danger-soft: #fdeef0;
  --ok: #16a34a;
  --ok-soft: #ecfdf3;
  --first: #d4a017;
  --second: #6b7a8f;
  --third: #b5713f;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .04), 0 6px 20px rgba(20, 30, 50, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

/* ---------------- 头部 ---------------- */
.hero {
  padding: 32px 4px 20px;
}
.hero .kicker {
  display: inline-block;
  font-size: 13px;
  letter-spacing: .08em;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}
.hero h1 {
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1.3;
  letter-spacing: -.01em;
}
.hero .sub {
  margin: 0;
  color: var(--ink-2);
  font-size: 14px;
}

/* ---------------- 卡片 / 题目 ---------------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 14px;
}
.card.compact { padding: 16px 18px; }

.q-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 14px;
}
.q-no {
  flex: none;
  min-width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  margin-top: 2px;
}
.q-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}
.req { color: var(--danger); margin-left: 2px; }
.q-desc {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-3);
  font-weight: 400;
}

/* ---------------- 姓名搜索 ---------------- */
.search-wrap {
  position: relative;
  margin-bottom: 12px;
}
.search-input {
  width: 100%;
  height: 48px;
  padding: 0 44px 0 42px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fbfcfe;
}
.search-input:focus { border-color: var(--brand); background: #fff; }
.search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--ink-3); pointer-events: none;
}
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border: 0; border-radius: 50%;
  background: #eef1f6; color: var(--ink-2); cursor: pointer; font-size: 15px;
  display: none; align-items: center; justify-content: center;
}

.name-list {
  max-height: 340px;
  overflow-y: auto;
  border-radius: 12px;
  background: #fbfcfe;
  border: 1px solid var(--line);
  padding: 6px;
  -webkit-overflow-scrolling: touch;
}
/* 未输入时收起整个列表容器，不占视觉空间 */
.name-list.is-idle {
  display: none;
}
.name-group + .name-group { margin-top: 6px; }
.group-label {
  font-size: 12px;
  color: var(--ink-3);
  padding: 8px 10px 4px;
  letter-spacing: .04em;
  position: sticky;
  top: -6px;
  background: #fbfcfe;
  z-index: 1;
}
.name-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font-size: 16px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.name-item:hover { background: #eef2f9; }
.name-item.is-selected { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.name-item .mark { font-size: 12px; color: var(--ink-3); font-weight: 400; }
.name-item.is-selected .mark { color: var(--brand); }

.empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--ink-3);
  font-size: 14px;
}

/* ---------------- 奖项条 ---------------- */
.award-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fbfcfe;
  border: 1px solid var(--line);
  margin-bottom: 16px;
}
.award-badge {
  flex: none;
  padding: 3px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}
.award-badge.FIRST { background: var(--first); }
.award-badge.SECOND { background: var(--second); }
.award-badge.THIRD { background: var(--third); }
.award-text { font-size: 14px; color: var(--ink-2); }
.award-text b { color: var(--ink); }

/* ---------------- 选项 ---------------- */
.options { display: grid; gap: 10px; }
.options.two { grid-template-columns: 1fr 1fr; }

.opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  transition: border-color .15s, background .15s;
  user-select: none;
}
.opt:hover { border-color: #c9d3ea; }
.opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.opt .dot {
  flex: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1.5px solid #c2cad9;
  position: relative;
  transition: border-color .15s;
}
.opt .dot::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--brand);
  transform: scale(0);
  transition: transform .15s;
}
.opt.is-checked { border-color: var(--brand); background: var(--brand-soft); }
.opt.is-checked .dot { border-color: var(--brand); }
.opt.is-checked .dot::after { transform: scale(1); }
.opt .label { flex: 1; }
.opt .hint { font-size: 12px; color: var(--ink-3); }

/* ---- 奖品卡片（带图）：纵向排布，图上文下 ---- */
.opt-media {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
  overflow: hidden;
  position: relative;
}
.opt-media .opt-img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #f7f9fd;
  border-bottom: 1px solid var(--line);
}
.opt-media .opt-img-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #aeb9cd;
}
.opt-media .opt-img-ph svg { width: 46%; height: 46%; max-width: 84px; }
.opt-media .label {
  flex: none;
  padding: 12px 14px 13px;
  font-weight: 600;
  text-align: center;
}
.opt-media .dot {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #fff;
}
.opt-media.is-checked .dot { background: #fff; }
.opt-media.is-checked { background: var(--brand-soft); }
.opt-media.is-checked .label { color: var(--brand); }
.opt-media:hover .opt-img { opacity: .92; }

/* ---------------- 输入 ---------------- */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 14px;
  color: var(--ink-2);
  margin-bottom: 6px;
}
/* 用 padding + line-height 归零让文字在框内垂直居中，不依赖 height 与行高巧合 */
.field input, .field textarea, .search-input {
  display: block;
  width: 100%;
  font-size: 16px;
  font-family: inherit;
  line-height: normal;
  color: var(--ink);
  background: #fbfcfe;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  outline: none;
  transition: border-color .15s, background .15s;
}
.field input {
  height: 46px;
  padding: 0 14px;
}
.field textarea {
  height: auto;
  min-height: 66px;
  padding: 11px 14px;
  line-height: 1.55;
  resize: vertical;
}
/* placeholder 与输入文字同色系、同基线，避免视觉上偏上偏下 */
.field input::placeholder, .field textarea::placeholder, .search-input::placeholder {
  color: var(--ink-3);
  opacity: 1;
  line-height: normal;
}
.field input:focus, .field textarea:focus { border-color: var(--brand); background: #fff; }
.field input.is-error { border-color: var(--danger); background: var(--danger-soft); }
.field .err {
  display: none;
  margin-top: 5px;
  font-size: 13px;
  color: var(--danger);
}
.field.has-error .err { display: block; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 50px;
  border: 0;
  border-radius: 13px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity .15s, transform .06s, background .15s;
}
.btn:active { transform: scale(.99); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:disabled { background: #b9c4e0; cursor: not-allowed; }
.btn-ghost {
  background: #fff;
  color: var(--ink-2);
  border: 1.5px solid var(--line);
  height: 44px;
  font-weight: 500;
}
.btn-sm { width: auto; height: 38px; padding: 0 16px; font-size: 14px; }

.submit-bar { margin-top: 20px; }
.foot-note {
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-3);
  text-align: center;
}

/* ---------------- 结果卡片 ---------------- */
.result { text-align: center; padding: 28px 20px; }
.result .icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 28px;
}
.result h2 { margin: 0 0 6px; font-size: 20px; }
.result p { margin: 0; color: var(--ink-2); font-size: 14px; }

.kv {
  margin: 18px 0 0;
  border-top: 1px solid var(--line);
  text-align: left;
}
.kv-row {
  display: flex;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.kv-row:last-child { border-bottom: 0; }
.kv-key { flex: none; width: 92px; color: var(--ink-3); }
.kv-val { flex: 1; color: var(--ink); word-break: break-all; }

.notice {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 11px;
  background: #fff8e6;
  color: #8a6100;
  font-size: 13.5px;
  text-align: left;
  line-height: 1.6;
}

/* ---------------- 提示条 ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(26, 34, 51, .94);
  color: #fff;
  padding: 11px 18px;
  border-radius: 11px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
  max-width: 86vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.skeleton {
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(90deg, #eef1f7 25%, #f6f8fc 37%, #eef1f7 63%);
  background-size: 400% 100%;
  animation: sk 1.4s ease infinite;
  margin-bottom: 8px;
}
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.hidden { display: none !important; }

/* ---------------- 管理页 ---------------- */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.stat {
  background: #fff;
  border-radius: 13px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat .n { font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat .t { font-size: 13px; color: var(--ink-3); }

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: 14px;
}
.bar-row .k { flex: none; width: 108px; color: var(--ink-2); }
.bar-row .bar {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: #eef1f7;
  overflow: hidden;
}
.bar-row .bar > i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--brand);
  transition: width .35s;
}
.bar-row .v { flex: none; width: 46px; text-align: right; font-variant-numeric: tabular-nums; }

.tag-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 4px; }
.tag {
  padding: 3px 9px;
  border-radius: 7px;
  background: #f1f3f8;
  font-size: 13px;
  color: var(--ink-2);
}

.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.admin-table th { color: var(--ink-3); font-weight: 500; font-size: 13px; }
.admin-table td.num { font-variant-numeric: tabular-nums; text-align: right; }

/* ---------------- 移动端适配 ---------------- */
@media (max-width: 560px) {
  html, body { font-size: 15px; }
  .page { padding: 0 12px 40px; }
  .hero { padding: 22px 2px 14px; }
  .hero h1 { font-size: 22px; }
  .hero .sub { font-size: 13.5px; }
  .card { padding: 16px; border-radius: 14px; }
  .card.compact { padding: 14px; }

  /* 礼品卡片在窄屏保持两列，但图更小，避免过于占屏 */
  .options.two { grid-template-columns: 1fr 1fr; gap: 8px; }
  .opt-media .opt-img { aspect-ratio: 1 / 1; }
  .opt-media .label { padding: 9px 8px 10px; font-size: 14px; }

  /* 领奖方式在窄屏单列大按钮，方便手指点 */
  .name-list { max-height: 46vh; }
  .name-item { padding: 13px 12px; }
  .kv-key { width: 80px; }
  .btn { height: 48px; }

  /* 管理页统计卡在窄屏两列 */
  .admin-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 12px; }
  .stat .n { font-size: 22px; }
  .bar-row .k { width: 84px; font-size: 13px; }
  .admin-table { font-size: 13px; }
  .admin-table th, .admin-table td { padding: 8px 5px; }
}

@media (max-width: 380px) {
  .options.two { grid-template-columns: 1fr 1fr; }
  .opt-media .label { font-size: 13px; padding: 8px 6px 9px; }
  .admin-grid { grid-template-columns: 1fr 1fr; }
}

/* 触摸设备去掉 hover 残留 */
@media (hover: none) {
  .opt:hover { border-color: var(--line); }
  .opt-media:hover .opt-img { opacity: 1; }
  .name-item:hover { background: transparent; }
}

@media (max-width: 420px) {
  .hero h1 { font-size: 23px; }
  .kv-key { width: 84px; }
}
