:root {
  --bg: #f5f3ee;
  --card: #ffffff;
  --ink: #26241f;
  --muted: #8a857c;
  --line: #e7e3da;
  --brand: #b8863b;
  --brand-dark: #966a26;
  --black: #2b2b2b;
  --win: #2f8f5b;
  --lose: #c04a3f;
  --draw: #7a7a7a;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(60, 50, 30, 0.06);
}

* { box-sizing: border-box; }

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

/* ---------- 顶栏 ---------- */
.topbar {
  background: linear-gradient(135deg, #2f2b24, #45403a);
  color: #f6f2ea;
  padding: 20px 20px 18px;
}
.brand { display: flex; align-items: center; gap: 14px; max-width: 900px; margin: 0 auto; }
.logo {
  width: 46px; height: 46px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f0cf8e, #c8933f);
  color: #3a2f18; font-size: 24px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 -3px 6px rgba(0,0,0,.18);
}
.topbar h1 { margin: 0; font-size: 19px; letter-spacing: .5px; }
.sub { margin: 3px 0 0; font-size: 12.5px; color: #cfc6b5; }

/* ---------- 标签页 ---------- */
.tabs {
  display: flex; gap: 4px; max-width: 900px; margin: 0 auto;
  padding: 10px 16px 0; overflow-x: auto;
}
.tab {
  flex: 0 0 auto;
  border: none; background: transparent; cursor: pointer;
  padding: 10px 16px; font-size: 14px; color: var(--muted);
  border-radius: 10px 10px 0 0; font-weight: 500;
  transition: all .15s;
}
.tab:hover { color: var(--ink); background: rgba(0,0,0,.03); }
.tab.active { color: var(--brand-dark); background: var(--card); box-shadow: var(--shadow); }

main { max-width: 900px; margin: 0 auto; padding: 16px; }

.panel { display: none; }
.panel.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card h2 { margin: 0 0 6px; font-size: 16px; }
.hint { margin: 0 0 16px; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
code { background: #f0ece3; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; flex: 1; min-width: 0; }
.field-row { display: flex; gap: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.opt { color: var(--muted); font-weight: 400; font-size: 11.5px; }

select, input[type="text"], input[type="date"], input[type="password"] {
  width: 100%; padding: 11px 12px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fcfbf8; color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
select:focus, input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(184, 134, 59, .14);
}
select:disabled { opacity: .5; cursor: not-allowed; }

.seg { display: flex; gap: 8px; }
.seg-btn {
  flex: 1; padding: 10px; border: 1px solid var(--line);
  background: #fcfbf8; border-radius: 10px; cursor: pointer;
  font-size: 14px; color: var(--muted); font-weight: 500; font-family: inherit;
  transition: all .15s;
}
.seg-btn:hover { border-color: var(--brand); color: var(--ink); }
.seg-btn.active {
  background: var(--brand); border-color: var(--brand);
  color: #fff; box-shadow: 0 2px 6px rgba(184,134,59,.3);
}
.seg-btn:disabled,
.seg-btn:disabled:hover {
  background: #f4f2ec; border-color: var(--line);
  color: #bcb6aa; cursor: not-allowed; box-shadow: none;
}

.fixed-value {
  padding: 11px 12px; font-size: 15px; font-weight: 500;
  border: 1px solid var(--line); border-radius: 10px;
  background: #f4f2ec; color: #6b6459;
}

/* ---------- 预览 ---------- */
.preview {
  background: #faf7f0; border: 1px dashed var(--line);
  border-radius: 10px; padding: 12px 14px; font-size: 14px;
  color: var(--muted); margin: 4px 0 16px; line-height: 1.6;
}
.preview strong { color: var(--ink); }
.preview .vs { color: var(--brand-dark); font-weight: 700; padding: 0 6px; }

/* ---------- 按钮 ---------- */
.primary {
  width: 100%; padding: 13px; border: none; border-radius: 11px;
  background: var(--brand); color: #fff; font-size: 15px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: background .15s, transform .05s;
}
.primary:hover:not(:disabled) { background: var(--brand-dark); }
.primary:active:not(:disabled) { transform: scale(.99); }
.primary:disabled { background: #d8d2c6; cursor: not-allowed; }
.primary.small { width: auto; padding: 11px 20px; flex: 0 0 auto; }

.add-row { display: flex; gap: 10px; margin-bottom: 16px; }
.add-row input { flex: 1; min-width: 0; }

/* ---------- 游客锁定提示 ---------- */
.lock-notice {
  display: flex; align-items: center; gap: 12px;
  background: #fdf6e8; border: 1px solid #f0e2c2;
  border-radius: 11px; padding: 12px 14px; margin-bottom: 18px;
}
.lock-icon { font-size: 19px; line-height: 1; flex: 0 0 auto; }
.lock-body { flex: 1; min-width: 0; }
.lock-body strong { display: block; font-size: 14px; color: #8a6a24; }
.lock-body p { margin: 3px 0 0; font-size: 12.5px; color: #a2895c; line-height: 1.55; }

/* 游客状态下整块表单变灰、不可交互 */
#registerForm.is-locked {
  opacity: .42;
  filter: grayscale(.4);
  pointer-events: none;
  user-select: none;
}

/* ---------- 管理模式 ---------- */
.admin-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px 12px;
}
.admin-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: #eaf5ee; color: #2f8f5b; font-size: 12.5px; font-weight: 600;
  padding: 5px 12px; border-radius: 20px;
}
.admin-badge::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%; background: #2f8f5b;
}

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; }
tbody tr:hover { background: #faf8f3; }
td.rank { font-weight: 700; color: var(--brand-dark); }
td.name { font-weight: 600; }
.win { color: var(--win); font-weight: 600; }
.lose { color: var(--lose); }
.medal { font-size: 15px; }

/* ---------- 进度 ---------- */
.progress-summary { text-align: center; padding: 8px 0; }
.big-num { font-size: 34px; font-weight: 700; color: var(--brand-dark); }
.big-num span:last-child { color: var(--muted); font-size: 22px; }
.big-label { font-size: 13px; color: var(--muted); margin: 2px 0 16px; }
.bar { display: block; height: 8px; background: #ece7dd; border-radius: 6px; overflow: hidden; }
.bar.big { height: 12px; max-width: 420px; margin: 0 auto; }
.bar-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #d9b168, #b8863b); border-radius: 6px; transition: width .5s ease; }
.pct { font-size: 13px; color: var(--muted); margin-top: 8px; }

.progress-list { display: flex; flex-direction: column; gap: 8px; }
.p-item { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.p-head {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; cursor: pointer; background: #fcfbf8;
  transition: background .15s;
}
.p-head:hover { background: #f7f4ec; }
.p-name { font-weight: 600; flex: 0 0 92px; }
.p-bar { display: block; flex: 1; }
.p-count { font-size: 13px; color: var(--muted); flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.p-body { display: none; padding: 12px 14px; border-top: 1px solid var(--line); background: #fff; }
.p-item.open .p-body { display: block; }
.p-body .tag {
  display: inline-block; background: #f3efe6; color: #6b6459;
  border-radius: 20px; padding: 4px 11px; font-size: 12.5px; margin: 0 6px 6px 0;
}
.p-body .done-tag { background: #eaf5ee; color: #2f8f5b; text-decoration: line-through; opacity: .7; }
.p-body .done-tag.lose-tag { background: #fbeceb; color: var(--lose); }
.p-body .empty { color: var(--muted); font-size: 13px; }

/* ---------- 名单 ---------- */
.player-list { display: flex; flex-direction: column; gap: 8px; }
.pl-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fcfbf8;
}
.pl-name { flex: 1; font-weight: 500; }
.pl-name input { padding: 6px 9px; font-size: 14px; }
.icon-btn {
  border: none; background: transparent; cursor: pointer;
  color: var(--muted); font-size: 13px; padding: 5px 9px; border-radius: 7px;
  font-family: inherit;
}
.icon-btn:hover { background: #f0ece3; color: var(--ink); }
.icon-btn.danger:hover { background: #fbeceb; color: var(--lose); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: #2f2b24; color: #fff; padding: 12px 20px; border-radius: 11px;
  font-size: 14px; max-width: 88%; text-align: center; line-height: 1.5;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 50;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: #2f8f5b; }
.toast.err { background: #c04a3f; }

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

/* ---------- 手机端适配 ---------- */
@media (max-width: 640px) {
  .topbar { padding: 16px 14px 14px; }
  .logo { width: 40px; height: 40px; font-size: 21px; }
  .topbar h1 { font-size: 17px; }

  .tabs { padding: 8px 10px 0; gap: 3px; }
  .tab {
    flex: 1 1 0; min-width: 0; padding: 10px 4px;
    font-size: 13px; text-align: center; white-space: nowrap;
  }

  main { padding: 12px; }
  .card { padding: 16px; }

  .field-row { flex-direction: column; gap: 0; }
  select, input[type="text"], input[type="date"], input[type="password"] { font-size: 16px; }
  .fixed-value { font-size: 16px; }
  .seg-btn { padding: 12px 6px; }

  th, td { padding: 9px 7px; font-size: 13px; }
  .table-wrap { -webkit-overflow-scrolling: touch; }

  .big-num { font-size: 28px; }
  .big-num span:last-child { font-size: 18px; }

  .p-head { padding: 10px 12px; gap: 8px; }
  .p-name {
    flex: 0 0 64px; font-size: 14px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .p-count { font-size: 12px; }
  .p-body { padding: 10px 12px; }

  .admin-bar { padding: 0 2px 10px; }

  .lock-notice { flex-wrap: wrap; gap: 8px 10px; padding: 11px 12px; }
  .lock-body { flex: 1 1 130px; }
  .lock-notice .primary.small { width: 100%; padding: 10px 16px; }

  .toast { bottom: 18px; font-size: 13.5px; }
}
