/* ===== LNTU日麻联盟段位登记系统 ===== */
:root {
  color-scheme: dark;
  --bg: #101827;
  --card: #1a2338;
  --card-2: #222d47;
  --border: #2c3a5a;
  --text: #e8ecf4;
  --text-dim: #93a0b8;
  --gold: #e6b84c;
  --blue: #4f8ef7;
  --red: #e5484d;
  --green: #3fb27f;
  --violet: #9a88f0;
  --seat-0: #4f8ef7; /* 东 */
  --seat-1: #e5484d; /* 南 */
  --seat-2: #9a88f0; /* 西 */
  --seat-3: #3fb27f; /* 北 */
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

h2 { font-size: 17px; margin: 18px 0 10px; }
h2:first-child { margin-top: 0; }

/* ===== 按钮与表单 ===== */
.btn {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-2);
  color: var(--text);
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: opacity .15s, transform .05s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.small { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
.btn.warn { background: transparent; border-color: var(--red); color: var(--red); }
.btn.ghost { background: transparent; }

.field { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.field span { font-size: 12px; color: var(--text-dim); }
.field input, .field select {
  width: 100%;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 11px 12px;
  font-size: 15px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--blue); }

.form-error {
  color: var(--red);
  font-size: 13px;
  margin: 10px 0;
  background: rgba(229, 72, 77, .1);
  border: 1px solid rgba(229, 72, 77, .35);
  border-radius: 8px;
  padding: 8px 10px;
}

/* ===== 登录页 ===== */
.auth-view {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 22px;
}
.auth-tile {
  width: 58px; height: 58px;
  margin: 0 auto 14px;
  background: #f7f2e7;
  color: #b03a3a;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 700;
  font-family: "Songti SC", "SimSun", serif;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
}
.auth-title { font-size: 19px; text-align: center; line-height: 1.4; }
.auth-sub { text-align: center; color: var(--text-dim); font-size: 12px; margin: 8px 0 18px; }
.tab-switch {
  display: flex;
  background: var(--bg);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 16px;
}
.tab-switch-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 8px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.tab-switch-btn.active { background: var(--card-2); color: var(--text); font-weight: 600; }
#authForm { display: flex; flex-direction: column; gap: 12px; }

/* ===== 主框架 ===== */
.app-view { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: rgba(16, 24, 39, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 15px; font-weight: 700; }
.topbar-dot { color: var(--gold); margin: 0 6px; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-dim); }

.content {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(88px + env(safe-area-inset-bottom));
}

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.panel-head h2 { margin: 0; }
.switch-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-dim); cursor: pointer;
}
.switch-label input { accent-color: var(--gold); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.loading { text-align: center; color: var(--text-dim); padding: 30px 0; font-size: 13px; }

/* ===== 排行榜 ===== */
.board { display: flex; flex-direction: column; gap: 8px; }
.board-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}
.board-row.retired { opacity: .5; filter: grayscale(.7); }
.rank-num {
  width: 34px; height: 34px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--card-2);
  font-weight: 700; font-size: 14px;
  color: var(--text-dim);
}
.rank-num.p1 { background: var(--gold); color: #101827; }
.rank-num.p2 { background: #c0c8d8; color: #101827; }
.rank-num.p3 { background: #c98a5e; color: #101827; }
.board-main { flex: 1; min-width: 0; }
.board-name { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.board-sub { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.board-pt { font-size: 18px; font-weight: 700; color: var(--gold); white-space: nowrap; }
.board-pt small { font-size: 11px; color: var(--text-dim); font-weight: 400; }

.badge {
  font-size: 10px; padding: 2px 6px; border-radius: 6px;
  font-weight: 500; white-space: nowrap;
}
.badge.admin { background: rgba(230, 184, 76, .15); color: var(--gold); border: 1px solid rgba(230, 184, 76, .4); }
.badge.retired-badge { background: rgba(147, 160, 184, .15); color: var(--text-dim); border: 1px solid var(--border); }
.badge.active-badge { background: rgba(63, 178, 127, .12); color: var(--green); border: 1px solid rgba(63, 178, 127, .4); }

/* ===== 录分 ===== */
.form-card { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: flex; gap: 12px; }
.seat-row { display: flex; align-items: center; gap: 8px; }
.seat-tag {
  width: 30px; height: 30px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  font-size: 13px; font-weight: 700; color: #fff;
}
.seat-0 { background: var(--seat-0); }
.seat-1 { background: var(--seat-1); }
.seat-2 { background: var(--seat-2); }
.seat-3 { background: var(--seat-3); }
.seat-row select { flex: 1; }
.seat-row input { width: 96px; }
.sum-hint { font-size: 13px; color: var(--text-dim); text-align: right; }
.sum-hint.ok { color: var(--green); font-weight: 600; }
.sum-hint.bad { color: var(--text-dim); }

/* ===== 历史 ===== */
#historyList, #adminMembers { display: flex; flex-direction: column; gap: 10px; }
.game-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--text-dim); margin-bottom: 10px;
}
.game-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.game-cell {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; min-width: 0;
}
.game-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.game-cell b { font-weight: 600; }
.game-cell em { font-style: normal; font-weight: 700; font-size: 12px; }
.game-cell em.pos { color: var(--green); }
.game-cell em.neg { color: var(--red); }
.game-remark { font-size: 12px; color: var(--text-dim); margin-top: 8px; }
.game-foot { font-size: 11px; color: var(--text-dim); margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 8px; }

/* ===== 管理 ===== */
.member-row { display: flex; align-items: center; gap: 10px; }
.member-row .board-main { flex: 1; }
.danger-title { color: var(--red); margin-top: 26px; }
.danger-card p { font-size: 13px; color: var(--text-dim); line-height: 1.6; margin-bottom: 12px; }

/* ===== 弹窗 / Toast ===== */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-card {
  width: 100%; max-width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
}
.modal-card h3 { font-size: 16px; margin-bottom: 10px; }
.modal-warn {
  font-size: 13px; color: var(--red); line-height: 1.6;
  background: rgba(229, 72, 77, .08);
  border: 1px solid rgba(229, 72, 77, .3);
  border-radius: 8px; padding: 10px; margin-bottom: 10px;
}
.modal-input {
  width: 100%;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 11px 12px;
  font-size: 15px;
  margin: 8px 0 14px;
}
.modal-input:focus { outline: none; border-color: var(--red); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

.toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%) translateY(-8px);
  z-index: 60;
  max-width: 86vw;
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(229, 72, 77, .5); color: #ff9ea1; }

/* ===== 底部导航 ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex;
  background: rgba(16, 24, 39, .96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 12px 0 10px;
  font-size: 12px;
  cursor: pointer;
  position: relative;
}
.nav-btn.active { color: var(--gold); font-weight: 600; }
.nav-btn.active::before {
  content: "";
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 28px; height: 3px; border-radius: 0 0 3px 3px;
  background: var(--gold);
}
