/* ==========================================================================
   掼蛋赛事记分系统 · 设计系统
   墨绿 × 金 · 棋牌赛事气质
   ========================================================================== */

:root {
  --ink: #10231C;
  --ink-2: #3D4F48;
  --ink-3: #78867F;
  --line: #E2E0D8;
  --line-2: #EFEDE6;
  --bg: #F5F4EF;
  --card: #FFFFFF;
  --brand: #0C3B2E;
  --brand-2: #14513F;
  --brand-3: #1E6B54;
  --gold: #C6A15B;
  --gold-2: #A8843F;
  --gold-bg: #FBF6EA;
  --red: #C0392B;
  --red-bg: #FDEEEC;
  --green: #1F7A5A;
  --green-bg: #EAF5F0;
  --blue: #2563EB;
  --shadow-sm: 0 1px 2px rgba(16, 35, 28, .05), 0 1px 3px rgba(16, 35, 28, .04);
  --shadow: 0 2px 8px rgba(16, 35, 28, .06), 0 8px 24px rgba(16, 35, 28, .05);
  --shadow-lg: 0 12px 40px rgba(16, 35, 28, .14);
  --r: 14px;
  --r-sm: 10px;
  --r-lg: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

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

body { min-height: 100vh; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
a { color: var(--brand-3); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- 布局 ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.wrap-sm { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; min-width: 0; }
.mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 20px; } .mt-4 { margin-top: 30px; }
.mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 20px; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.hidden { display: none !important; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(12, 59, 46, .97);
  backdrop-filter: saturate(1.4) blur(12px);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.topbar .wrap, .topbar .wrap-sm {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; gap: 12px;
}
.tb-title { font-size: 15px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-sub { font-size: 11px; color: rgba(255, 255, 255, .55); letter-spacing: .06em; }
.tb-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.card-flat { box-shadow: none; }
.card-pad-0 { padding: 0; overflow: hidden; }
.card-h {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line-2); gap: 10px;
}
.card-h h3 { font-size: 15px; }
.card-b { padding: 16px 18px; }

.section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: .12em;
  color: var(--ink-3); text-transform: uppercase;
  margin: 26px 0 10px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--r-sm);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: transform .12s, background .15s, border-color .15s, box-shadow .15s;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(.975); }
.btn:hover { border-color: #D3D0C6; }
.btn-primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 2px 8px rgba(12, 59, 46, .22);
}
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #2A1F08; font-weight: 700; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--brand-3); }
.btn-ghost:hover { background: rgba(12, 59, 46, .06); }
.btn-danger { color: var(--red); border-color: #F0CFCA; background: #fff; }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn-lg { height: 52px; padding: 0 26px; font-size: 16px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 9px; }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; font-weight: 700; color: var(--ink-2); letter-spacing: .03em; }
.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; padding: 10px 12px; min-height: 96px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand-3); box-shadow: 0 0 0 3px rgba(30, 107, 84, .1);
}
.input::placeholder, .textarea::placeholder { color: #B4BDB8; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2378867F' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 560px) { .grid-3 { grid-template-columns: 1fr 1fr; } }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  background: var(--line-2); color: var(--ink-2);
  white-space: nowrap;
}
.badge-brand { background: var(--green-bg); color: var(--green); }
.badge-gold { background: var(--gold-bg); color: var(--gold-2); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-live { background: var(--red-bg); color: var(--red); }
.badge-live::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--red); animation: pulse 1.6s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* ---------- 排名 ---------- */
.rank {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px;
  font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums;
  background: var(--line-2); color: var(--ink-2); flex-shrink: 0;
}
.rank-1 { background: linear-gradient(135deg, #E8C479, #C6A15B); color: #FFF; box-shadow: 0 2px 6px rgba(198, 161, 91, .4); }
.rank-2 { background: linear-gradient(135deg, #D5D9DC, #A8B0B5); color: #FFF; }
.rank-3 { background: linear-gradient(135deg, #D8A882, #B98155); color: #FFF; }

/* ---------- 表格 ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .06em;
  color: var(--ink-3); padding: 10px 12px; border-bottom: 1px solid var(--line);
  background: #FCFBF7; white-space: nowrap; text-transform: uppercase;
}
.tbl td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: #FDFCF8; }
.tbl .t-r { text-align: right; }
.tbl .t-c { text-align: center; }
.tbl-compact td { padding: 8px 12px; }

/* ---------- 分段控件 ---------- */
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: #EDEBE3; border-radius: 10px;
}
.seg button {
  border: none; background: transparent; height: 30px; padding: 0 14px;
  border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--ink-3);
  cursor: pointer; transition: all .15s;
}
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: none; background: none; padding: 12px 14px; font-size: 14px; font-weight: 600;
  color: var(--ink-3); cursor: pointer; white-space: nowrap; position: relative;
}
.tabs button.on { color: var(--brand); }
.tabs button.on::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px;
  background: var(--brand); border-radius: 2px;
}

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(28px + var(--safe-b));
  transform: translateX(-50%) translateY(20px);
  background: #14251F; color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 200;
  max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #8E2A1F; }
.toast.ok { background: #14513F; }

.empty {
  padding: 44px 20px; text-align: center; color: var(--ink-3); font-size: 14px;
}
.empty-ico { font-size: 30px; opacity: .35; margin-bottom: 10px; }

/* ---------- 弹层 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(16, 35, 28, .45);
  backdrop-filter: blur(3px); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .22s;
}
.mask.show { opacity: 1; pointer-events: auto; }
.sheet {
  background: #fff; width: 100%; max-width: 520px;
  border-radius: 20px 20px 0 0; padding: 22px 20px calc(22px + var(--safe-b));
  transform: translateY(100%); transition: transform .28s cubic-bezier(.32, .72, 0, 1);
  max-height: 88vh; overflow-y: auto;
}
.mask.show .sheet { transform: translateY(0); }
@media (min-width: 700px) {
  .mask { align-items: center; }
  .sheet { border-radius: 18px; transform: translateY(16px) scale(.98); opacity: 0; padding: 24px; }
  .mask.show .sheet { transform: none; opacity: 1; }
}

/* ---------- 记分专用 ---------- */
.score-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 16px 18px; border-radius: 14px;
  border: 1.5px solid var(--line); background: #fff;
  cursor: pointer; transition: all .15s; text-align: left;
}
.score-btn:active { transform: scale(.985); }
.score-btn .sb-main { font-size: 16px; font-weight: 700; }
.score-btn .sb-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.score-btn .sb-up {
  font-size: 20px; font-weight: 800; color: var(--gold-2);
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.score-btn:active { border-color: var(--brand-3); background: #F7FBF9; }

/* ---------- 大屏 ---------- */
.dark-bg { background: #08160F; color: #F2F0E8; }
.dark-bg .card { background: rgba(255,255,255,.04); border-color: rgba(255,255,255,.09); box-shadow: none; }
.dark-bg .tbl th { background: rgba(255,255,255,.03); color: rgba(242,240,232,.5); border-color: rgba(255,255,255,.08); }
.dark-bg .tbl td { border-color: rgba(255,255,255,.07); color: #F2F0E8; }
.dark-bg .tbl tbody tr:hover { background: rgba(255,255,255,.03); }
.dark-bg .muted { color: rgba(242,240,232,.45); }
.dark-bg .rank { background: rgba(255,255,255,.1); color: rgba(242,240,232,.8); }

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; }
}
