/* ============================================================
   守夜桌游助手 · 网页版
   品牌色（B 方案 暖木奶油）：米色底 + 咖啡木主色 + 朱红点缀 + 浅木金
   ============================================================ */
:root {
  --bg: #ebe2d1;
  --bg-card: #f6f0e4;
  --card: #fbf7ee;
  --primary: #5f4430;
  --primary-light: #8a5a3b;
  --primary-dark: #43331f;
  --accent: #a8402f;
  --gold: #b08968;
  --gold-light: #cdb586;
  --olive: #6b7f5e;
  --text: #2c2c2c;
  --text-light: #6b6b6b;
  --text-muted: #8c8274;
  --border: #d3c7b0;
  --border-light: #e2d7c1;
  --radius: 12px;
  --shadow: 0 3px 16px rgba(67, 51, 31, 0.08);
}

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

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 10px 12px 96px;
  position: relative;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 2px 12px;
}
.tb-logo { display: block; line-height: 0; }
.tb-logo img { width: 48px; height: 48px; display: block; }
.tb-actions { display: flex; align-items: center; gap: 8px; }
.tb-icon {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1.5px solid var(--border);
  background: rgba(255, 255, 255, 0.6);
  color: var(--primary); font-size: 16px; line-height: 1;
}
.tb-icon:active { background: #ede3d0; }
.tb-me {
  width: 34px; height: 34px; border-radius: 50%; overflow: hidden;
  border: 2px solid rgba(255, 251, 240, 0.9);
  background: linear-gradient(135deg, #8a5a3b, #43331f);
  color: #fbf7ee; font-size: 17px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(67, 51, 31, 0.22);
  padding: 0;
}
.tb-me img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- 卡片 / 区块 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 11px;
}
.card-tight { padding: 9px 10px; }

.sec-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 15px 3px 8px;
}
.sec-title .st-main { font-size: 16px; font-weight: 700; color: var(--primary); letter-spacing: 0.5px; }
.sec-title .st-sub { font-size: 11px; color: var(--text-muted); }
.sec-num { color: var(--accent); font-weight: 800; font-style: italic; margin-right: 5px; }

/* ---------- 头图 ---------- */
.hero {
  background: linear-gradient(160deg, #5f4430 0%, #43331f 100%);
  border-radius: var(--radius); padding: 18px 16px 16px;
  color: #fbf7ee; position: relative; overflow: hidden; margin-bottom: 12px;
}
.hero::after {
  content: ""; position: absolute; right: -28px; top: -28px;
  width: 118px; height: 118px; border-radius: 50%;
  background: rgba(201, 162, 39, 0.16);
}
.hero-h1 { font-size: 22px; font-weight: 800; letter-spacing: 1px; }
.hero-sub { font-size: 12px; opacity: 0.78; margin-top: 4px; }
.hero-meta { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; position: relative; z-index: 1; }
.hm-item {
  padding: 3px 10px; border-radius: 999px; font-size: 11px; line-height: 1.5;
  background: rgba(246, 241, 230, 0.12);
  border: 1px solid rgba(201, 162, 39, 0.35);
  color: #e9dcc0;
}

/* ---------- 分段控件 / chips ---------- */
.seg { display: flex; background: #ded2b8; border-radius: 10px; padding: 3px; margin-bottom: 10px; }
.seg-item {
  flex: 1; text-align: center; padding: 8px 0; font-size: 13px;
  color: var(--text-light); border-radius: 8px; transition: all 0.18s;
}
.seg-item.on { background: var(--card); color: var(--primary); font-weight: 700; box-shadow: 0 1px 6px rgba(67, 51, 31, 0.12); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.chips.nowrap { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
.chip {
  padding: 5px 12px; border-radius: 999px; font-size: 12px; white-space: nowrap;
  border: 1px solid var(--border); background: var(--card); color: var(--text-light);
}
.chip.on { background: var(--primary); border-color: var(--primary); color: #fbf7ee; font-weight: 600; }

/* ---------- 列表行 ---------- */
.row {
  display: flex; align-items: center; padding: 11px 3px;
  border-bottom: 1px solid var(--border-light); cursor: pointer;
}
.row:last-child { border-bottom: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-right { text-align: right; margin-left: 8px; flex: none; }
.row-holder { font-size: 11px; color: var(--primary-light); margin-top: 1px; }
.row-holder.waiting { color: var(--text-muted); }

.rank-no {
  width: 32px; flex: none; text-align: center; font-weight: 800;
  font-size: 14px; color: var(--text-muted);
}
.rank-no.m1 { color: var(--gold); font-size: 17px; }
.rank-no.m2 { color: #9aa3ab; font-size: 16px; }
.rank-no.m3 { color: #b87333; font-size: 16px; }

.rank-row {
  display: flex; align-items: center; padding: 10px 8px;
  border-radius: 8px; border-bottom: 1px solid var(--border-light); cursor: pointer;
}
.rank-row:last-child { border-bottom: none; }
.rank-row.top1 { background: linear-gradient(90deg, rgba(201, 162, 39, 0.16), transparent); }
.ava {
  width: 32px; height: 32px; border-radius: 50%; flex: none; margin-right: 9px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700; overflow: hidden;
  background: linear-gradient(135deg, #8a5a3b, #5f4430);
}
.ava img { width: 100%; height: 100%; object-fit: cover; }
.pt { font-size: 17px; font-weight: 800; color: var(--primary); }
.pt.neg { color: var(--olive); }
.pt-meta { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.score-avg { font-size: 17px; font-weight: 600; color: var(--primary-light); }
.score-avg.muted { color: var(--text-muted); }
.score-n { font-size: 10px; color: var(--text-muted); text-align: right; }

/* ---------- 按钮 ---------- */
.btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 44px; border: none; border-radius: 10px;
  font-size: 15px; font-weight: 600;
  background: var(--primary); color: #fbf7ee;
}
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-accent { background: var(--accent); }
.btn-sm { height: 32px; font-size: 13px; border-radius: 8px; padding: 0 12px; width: auto; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; margin-top: 8px; }
.btn-row .btn { flex: 1 1 0; min-width: 0; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 11px; }
.field-label { font-size: 12px; color: var(--text-light); margin-bottom: 5px; display: flex; justify-content: space-between; }
.input, .picker-box {
  width: 100%; height: 44px; background: #fff;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 0 11px; font-size: 15px; outline: none; appearance: none;
}
textarea.input { height: 96px; padding: 10px 11px; resize: vertical; line-height: 1.6; }
.input:focus { border-color: var(--primary-light); }
.input-lg { height: 48px; font-size: 17px; font-weight: 700; text-align: center; }

.seat-line { display: flex; align-items: center; gap: 7px; margin-bottom: 9px; }
.seat-tag {
  width: 46px; height: 44px; line-height: 44px; flex: none; border-radius: 8px;
  text-align: center; font-size: 13px; font-weight: 700; color: #fbf7ee;
}
.seat-tag.s0 { background: #5f4430; }
.seat-tag.s1 { background: #a8402f; }
.seat-tag.s2 { background: #b08968; color: #3e2f1c; }
.seat-tag.s3 { background: #2b5876; }
.seat-name { flex: 1; min-width: 0; }
.seat-score { width: 104px; flex: none; text-align: center; font-weight: 700; }

.suggest {
  border: 1px solid var(--border-light); border-radius: 8px; overflow: hidden;
  background: #fff; margin: -4px 0 9px; box-shadow: 0 6px 18px rgba(67, 51, 31, 0.12);
}
.suggest-item { padding: 9px 12px; font-size: 14px; border-bottom: 1px solid var(--border-light); cursor: pointer; }
.suggest-item:last-child { border-bottom: none; }
.suggest-item:active { background: #ebe2d1; }

.sum-line {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px;
  border-radius: 8px; background: #f1e9d9; font-size: 13px; color: var(--text-light);
}
.sum-line .sum-num { font-size: 17px; font-weight: 800; color: var(--text); }
.sum-line.ok { background: rgba(107, 127, 94, 0.12); }
.sum-line.ok .sum-state { color: var(--olive); font-weight: 700; }
.sum-line:not(.ok) .sum-state { color: var(--accent); }

.preview { margin-top: 10px; padding: 9px 10px; border: 1.5px dashed var(--border); border-radius: 9px; }
.pv-cell { background: var(--card); border: 1px solid var(--border-light); border-radius: 8px; padding: 8px 5px; text-align: center; }
.pv-rank { font-size: 11px; color: var(--text-muted); }
.pv-name { font-size: 12px; font-weight: 700; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-pt { font-size: 14px; font-weight: 800; color: var(--primary); }
.pv-pt.neg { color: var(--olive); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }

/* ---------- 空状态 / 提示 ---------- */
.empty { padding: 44px 15px; text-align: center; color: var(--text-muted); font-size: 13px; }
.empty-icon { font-size: 38px; margin-bottom: 8px; opacity: 0.5; }
.hint { font-size: 11px; color: var(--text-muted); line-height: 1.7; margin-top: 6px; }
.hint.tc { text-align: center; }
.c-primary { color: var(--primary); }
.c-muted { color: var(--text-muted); }
.tr { text-align: right; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; }

/* ---------- 我的页 ---------- */
.me-hero { padding: 17px 15px 14px; }
.mh-top { display: flex; align-items: center; gap: 10px; position: relative; z-index: 1; }
.mh-avatar {
  width: 48px; height: 48px; border-radius: 50%; flex: none; overflow: hidden;
  background: rgba(246, 241, 230, 0.16);
  border: 1.5px solid rgba(246, 241, 230, 0.55);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.mh-avatar img { width: 100%; height: 100%; object-fit: cover; }
.mh-avatar span { font-size: 26px; line-height: 1; }
.mh-h1 { font-size: 20px; font-weight: 800; color: #fbf7ee; }
.mh-edit {
  flex: none; margin-left: auto; font-size: 12px; color: #fbf7ee;
  background: rgba(246, 241, 230, 0.16);
  border: 1px solid rgba(246, 241, 230, 0.4);
  border-radius: 999px; padding: 5px 12px;
}
.mh-sub { margin-top: 9px; font-size: 12px; color: #d9c49a; font-weight: 600; position: relative; z-index: 1; }
.mh-level {
  margin-top: 8px; display: inline-flex; align-items: center; gap: 6px;
  background: rgba(201, 162, 39, 0.14); border: 1px solid rgba(201, 162, 39, 0.4);
  border-radius: 999px; padding: 5px 11px; position: relative; z-index: 1;
}
.mh-level-name { font-size: 12px; font-weight: 800; color: #d9c49a; }
.mh-level-line { font-size: 10px; color: rgba(246, 241, 230, 0.75); }
.mh-stats { margin-top: 12px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; position: relative; z-index: 1; }
.mh-stat { text-align: center; padding: 8px 0 6px; border-radius: 8px; background: rgba(246, 241, 230, 0.08); cursor: pointer; }
.mh-stat-v { font-size: 20px; font-weight: 800; color: #fbf7ee; line-height: 1.2; }
.mh-stat-k { font-size: 10px; color: rgba(246, 241, 230, 0.72); margin-top: 2px; }

.rec-tabs { display: flex; gap: 5px; margin-bottom: 7px; }
.rec-tab { flex: 1; text-align: center; font-size: 12px; padding: 7px 0; border-radius: 7px; background: rgba(95, 68, 48, 0.06); }
.rec-tab.on { background: var(--primary); color: #fbf7ee; font-weight: 700; }
.rec-score { font-size: 13px; font-weight: 700; color: var(--primary-light); }
.stat-cell { text-align: center; }
.stat-v { font-size: 18px; font-weight: 800; color: var(--primary); }
.stat-v.neg { color: var(--olive); }
.stat-k { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

.persona-card, .title-card { display: flex; align-items: flex-start; gap: 10px; }
.persona-icon { font-size: 26px; line-height: 1; }
.persona-t { font-size: 15px; font-weight: 800; }
.persona-d { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.persona-tag {
  margin-top: 6px; display: inline-block; font-size: 10px; color: var(--primary);
  background: rgba(95, 68, 48, 0.08); border-radius: 999px; padding: 3px 9px;
}
.foot-logo { display: block; width: 92px; margin: 12px auto 4px; opacity: 0.9; }
.admin-link { color: var(--text-muted); text-decoration: underline; cursor: pointer; }

/* ---------- 桌游详情 ---------- */
.bg-hero { position: relative; border-radius: var(--radius); overflow: hidden; margin-bottom: 11px; background: linear-gradient(160deg, #5f4430, #43331f); }
.bg-cover { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; }
.bg-cover-ph { width: 100%; aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; font-size: 64px; color: rgba(251, 247, 238, 0.35); }
.bg-hero-info { position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 14px 12px; color: #fbf7ee; background: linear-gradient(transparent, rgba(30, 22, 14, 0.86)); }
.bg-cn { font-size: 21px; font-weight: 800; }
.bg-en { font-size: 11px; opacity: 0.8; margin-top: 2px; }
.bg-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.bg-tag { font-size: 10px; padding: 2px 8px; border-radius: 999px; background: rgba(246, 241, 230, 0.16); border: 1px solid rgba(201, 162, 39, 0.3); }

.rate-faces { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 6px; }
.rate-face {
  border: 1.5px solid var(--border-light); background: #fff; border-radius: 9px;
  padding: 8px 0 6px; text-align: center; font-size: 20px; line-height: 1.2;
}
.rate-face small { display: block; font-size: 10px; color: var(--text-muted); }
.rate-face.on { border-color: var(--primary); background: rgba(95, 68, 48, 0.08); }
.rate-face.on small { color: var(--primary); }

.mark-row { display: flex; gap: 10px; margin-top: 10px; }
.mark-btn {
  flex: 1; height: 40px; border-radius: 9px; border: 1.5px solid var(--border);
  background: #fff; color: var(--text-light); font-size: 13px; font-weight: 600;
}
.mark-btn.on { background: var(--primary); border-color: var(--primary); color: #fbf7ee; }

/* ---------- 工具 ---------- */
.tool-tile {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  background: var(--card); border: 1px solid var(--border-light);
  border-radius: var(--radius); margin-bottom: 10px; box-shadow: var(--shadow); cursor: pointer;
}
.tool-tile i { font-size: 26px; }
.tool-tile b { display: block; font-size: 15px; }
.tool-tile small { color: var(--text-muted); font-size: 11px; }
.tool-hd { display: flex; align-items: center; justify-content: space-between; font-size: 16px; font-weight: 700; color: var(--primary); margin: 4px 3px 10px; }
.tool-back { font-size: 13px; color: var(--text-muted); font-weight: 500; cursor: pointer; }
.timer-display { font-size: 46px; font-weight: 800; text-align: center; color: var(--primary); font-variant-numeric: tabular-nums; letter-spacing: 2px; }
.timer-display.done { color: var(--accent); }
.ct-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border-light); }
.ct-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; }
.ct-total { width: 62px; text-align: right; font-weight: 800; color: var(--primary); }
.ct-total.neg { color: var(--olive); }
.ct-op { color: var(--accent); font-size: 18px; padding: 0 6px; cursor: pointer; }
.draw-result { margin-top: 12px; padding: 12px; border-radius: 9px; background: rgba(95, 68, 48, 0.06); font-size: 15px; font-weight: 600; white-space: pre-wrap; line-height: 1.8; }

/* ---------- 弹层 / 提示 ---------- */
.mask { position: fixed; inset: 0; background: rgba(20, 28, 24, 0.55); z-index: 99; display: flex; align-items: flex-end; justify-content: center; }
.mask[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 480px; max-height: 86vh; overflow-y: auto;
  background: #fdfbf5; border-radius: 18px 18px 0 0;
  padding: 17px 17px calc(17px + env(safe-area-inset-bottom));
  position: relative;
}
.sheet-cap { font-size: 11px; color: var(--accent); font-weight: 700; }
.sheet-h1 { font-size: 18px; font-weight: 800; margin-top: 3px; }
.sheet-x { position: absolute; top: 12px; right: 16px; font-size: 22px; color: #8c8274; line-height: 1; padding: 4px; cursor: pointer; border: none; background: none; }
.sheet-note { margin-top: 11px; background: rgba(107, 127, 94, 0.1); border: 1px solid rgba(107, 127, 94, 0.25); border-radius: 8px; padding: 9px 11px; }
.sn-t { font-size: 12px; font-weight: 700; color: var(--olive); }
.sn-d { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.f-label { font-size: 12px; font-weight: 700; margin: 14px 0 6px; }
.emoji-row { display: flex; flex-wrap: wrap; gap: 9px; }
.emoji-cell {
  width: 42px; height: 42px; border-radius: 50%; font-size: 22px;
  background: rgba(95, 68, 48, 0.08); border: 1.5px solid transparent;
  display: flex; align-items: center; justify-content: center;
}
.emoji-cell.on { border-color: var(--primary); background: rgba(95, 68, 48, 0.14); }
.save-btn { margin-top: 18px; height: 46px; font-size: 15px; font-weight: 700; border-radius: 10px; background: var(--primary); color: #fbf7ee; border: none; width: 100%; }

.toast-wrap { position: fixed; left: 0; right: 0; bottom: 92px; z-index: 200; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast-wrap li {
  background: rgba(20, 18, 14, 0.88); color: #f6f0e4; font-size: 13px;
  padding: 9px 14px; border-radius: 999px; max-width: 80%; text-align: center;
  animation: toastIn 0.18s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 同步状态灯 ---------- */
.sync-badge {
  position: fixed; left: max(12px, calc(50% - 228px)); bottom: 76px; z-index: 90;
  display: flex; align-items: center; gap: 5px; padding: 5px 10px;
  border-radius: 999px; background: rgba(20, 18, 14, 0.8); color: #f1e9d9;
  font-size: 11px; cursor: pointer; box-shadow: 0 3px 12px rgba(0, 0, 0, 0.25);
}
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: #4caf50; }
.sync-dot.busy { background: #f5a623; }
.sync-dot.err { background: #e5484d; }

/* ---------- 底部标签栏 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 95;
  display: flex; background: rgba(251, 247, 238, 0.97);
  border-top: 1px solid var(--border-light);
  padding-bottom: env(safe-area-inset-bottom);
  backdrop-filter: blur(8px);
}
.tab {
  flex: 1; text-align: center; padding: 7px 0 6px;
  font-size: 10px; color: #a3947f;
}
.tab i { display: block; font-size: 19px; font-style: normal; line-height: 1.3; }
.tab.on { color: var(--primary); font-weight: 700; }

.loading { text-align: center; padding: 28px; color: var(--text-muted); font-size: 13px; }
