:root {
  /* ---------- 字体 ---------- */
  --font-sans: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;

  /* 字号刻度：全局只用这八级 */
  --text-1: 12px;
  --text-2: 13px;
  --text-3: 14px;
  --text-4: 15px;
  --text-5: 17px;
  --text-6: 22px;
  --text-7: 30px;
  --text-8: 40px;

  /* 字重：全局只用这四级 */
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* ---------- 颜色 ---------- */
  --color-bg: #f6f8fb;
  --color-surface: #ffffff;
  --color-surface-alt: #f8fafc;
  --color-line: #e4e7ec;
  --color-line-soft: #f0f2f5;
  --color-line-faint: #eef0f3;
  --color-line-strong: #d5dae1;
  --color-text: #14181f;
  --color-muted: #5b6675;
  --color-faint: #a0a8b4;
  --color-primary: #14b8c8;
  --color-primary-dark: #0d93a1;
  --color-primary-soft: rgba(20, 184, 200, 0.1);
  --color-primary-ring: rgba(20, 184, 200, 0.2);
  --color-on-accent: #ffffff;
  --color-positive: #12a05c;
  --color-negative: #e5484d;
  --color-negative-soft: #fdf2f2;
  --color-negative-line: #f0c6c6;
  --color-inverse-bg: #1f2937;
  --color-mask: rgba(17, 24, 39, 0.34);
  --color-topbar: rgba(255, 255, 255, 0.9);

  /* LOL 段位配色 */
  --color-tier-iron-bg: #e5e7eb;
  --color-tier-iron-text: #4b5563;
  --color-tier-bronze-bg: #f3e3d3;
  --color-tier-bronze-text: #8a5a2b;
  --color-tier-silver-bg: #e8ecef;
  --color-tier-silver-text: #52606d;
  --color-tier-gold-bg: #fff2cc;
  --color-tier-gold-text: #8a6200;
  --color-tier-platinum-bg: #e0f4f7;
  --color-tier-platinum-text: #0e7c8c;
  --color-tier-emerald-bg: #e6f8ee;
  --color-tier-emerald-text: #0f7b52;
  --color-tier-diamond-bg: #e6edff;
  --color-tier-diamond-text: #2a54d0;
  --color-tier-master-bg: #f1eaff;
  --color-tier-master-text: #6b3fd4;
  --color-tier-grandmaster-bg: #ffe8f0;
  --color-tier-grandmaster-text: #b4235a;
  --color-tier-challenger-bg: #fff0d6;
  --color-tier-challenger-text: #a9600a;

  /* 品牌渐变 */
  --color-brand-a: #e8453c;
  --color-brand-b: #ffc61a;
  --color-brand-c: #1fb8cc;

  /* 统计卡配色 */
  --color-tint-teal-bg: #e0f7fa;
  --color-tint-teal-text: #087f8c;
  --color-tint-yellow-bg: #fff6d6;
  --color-tint-yellow-text: #8a6200;
  --color-tint-green-bg: #e6f8ee;
  --color-tint-green-text: #0c7a4e;
  --color-tint-red-bg: #ffe8e6;
  --color-tint-red-text: #b8332b;

  /* 学生头像色板（按姓名散列，同一人永远同色） */
  --color-avatar-1-bg: #e8f0fe;
  --color-avatar-1-text: #1a56db;
  --color-avatar-2-bg: #fde8ef;
  --color-avatar-2-text: #b4235a;
  --color-avatar-3-bg: #e6f6ec;
  --color-avatar-3-text: #0f7b52;
  --color-avatar-4-bg: #fff3e0;
  --color-avatar-4-text: #a45a00;
  --color-avatar-5-bg: #efe9fe;
  --color-avatar-5-text: #5b21b6;
  --color-avatar-6-bg: #e4f5f8;
  --color-avatar-6-text: #0e6b7a;

  /* 名次 */
  --color-gold-bg: #f7d774;
  --color-gold-text: #5b4300;
  --color-silver-bg: #e2e6ea;
  --color-silver-text: #39424e;
  --color-bronze-bg: #eccdb4;
  --color-bronze-text: #5c3820;

  /* ---------- 形状与阴影 ---------- */
  --radius-xs: 7px;
  --radius-sm: 9px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --board-width: 820px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-up: 0 6px 16px rgba(16, 24, 40, 0.1), 0 2px 6px rgba(16, 24, 40, 0.06);
  --shadow-modal: 0 20px 48px rgba(16, 24, 40, 0.24);
}


* {
  box-sizing: border-box;
}

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

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-4);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea,
optgroup,
option {
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  color: inherit;
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--color-topbar);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--color-line);
}

.brand {
  font-weight: var(--weight-semibold);
  font-size: var(--text-5);
  letter-spacing: 0.01em;
  text-decoration: none;
  color: var(--color-text);
  white-space: nowrap;
}

.topbar-spacer {
  flex: 1;
}

.topbar select {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  max-width: 220px;
}

.who {
  color: var(--color-muted);
  font-size: var(--text-2);
  white-space: nowrap;
}

/* ---------- 布局 ---------- */

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-head h1 {
  margin: 0;
  font-size: var(--text-6);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.01em;
}

.muted {
  color: var(--color-muted);
  font-size: var(--text-2);
  margin: 4px 0 0;
}

.actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- 按钮 ---------- */

a {
  color: inherit;
  text-decoration: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-line);
  background: var(--color-surface);
  color: var(--color-text);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}

.btn:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-line-strong);
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-on-accent);
}

.btn.primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--color-muted);
}

.btn.ghost:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
}

.btn.danger {
  color: var(--color-negative);
  border-color: var(--color-negative-line);
}

.btn.danger:hover {
  background: var(--color-negative-soft);
}

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- 学生卡片墙 ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 12px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  transition: box-shadow 0.12s, transform 0.06s, border-color 0.12s;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.card:hover {
  box-shadow: var(--shadow-up);
  border-color: var(--color-line-strong);
}

.card:active {
  transform: scale(0.985);
}

.card-name {
  flex: 1;
  min-width: 0;
  font-size: var(--text-4);
  font-weight: var(--weight-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-score {
  font-size: var(--text-7);
  font-weight: var(--weight-semibold);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.card.is-negative .card-score {
  color: var(--color-negative);
}

.card-meta {
  font-size: var(--text-1);
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
}

.card.bump {
  animation: bump 0.28s ease-out;
}

@keyframes bump {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
  }
}

.float {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  font-weight: var(--weight-semibold);
  font-size: var(--text-5);
  color: var(--color-positive);
  animation: floatUp 0.7s ease-out forwards;
}

.float.neg {
  color: var(--color-negative);
}

@keyframes floatUp {
  0% {
    opacity: 0;
    transform: translate(-50%, 4px);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -36px);
  }
}

/* ---------- 空状态 ---------- */

.empty {
  padding: 48px 24px;
  text-align: center;
  background: var(--color-surface);
  border: 1px dashed var(--color-line);
  border-radius: var(--radius);
  color: var(--color-muted);
}

.empty h2 {
  margin: 0 0 6px;
  font-size: var(--text-5);
  font-weight: var(--weight-medium);
  color: var(--color-text);
}

/* ---------- 表单 ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: var(--text-2);
  color: var(--color-muted);
}

.field input,
.field textarea,
.field select {
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.field textarea {
  height: auto;
  padding: 9px 11px;
  resize: vertical;
  min-height: 62px;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-ring);
}

.form-row {
  display: flex;
  gap: 10px;
}

.form-row > * {
  flex: 1;
}

/* ---------- 登录 / 初始化 ---------- */

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate-card {
  width: 100%;
  max-width: 380px;
  padding: 28px;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-up);
}

.gate-card h1 {
  margin: 0 0 4px;
  font-size: var(--text-6);
  font-weight: var(--weight-semibold);
}

.gate-card p {
  margin: 0 0 22px;
  color: var(--color-muted);
  font-size: var(--text-2);
}

.gate-card .btn {
  width: 100%;
  height: 40px;
  margin-top: 4px;
}

/* ---------- 右键 / 长按菜单 ---------- */

.menu {
  position: fixed;
  z-index: 50;
  min-width: 168px;
  padding: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-up);
}

.menu button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.menu button:hover {
  background: var(--color-surface-alt);
}

.menu .sep {
  height: 1px;
  margin: 5px 4px;
  background: var(--color-line);
}

.menu .danger {
  color: var(--color-negative);
}

/* ---------- 弹窗 ---------- */

.mask {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--color-mask);
  animation: fade 0.14s ease-out;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.modal {
  width: 100%;
  max-width: 420px;
  max-height: 86vh;
  overflow: auto;
  padding: 22px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
}

.modal.wide {
  max-width: 620px;
}

.modal h2 {
  margin: 0 0 16px;
  font-size: var(--text-5);
  font-weight: var(--weight-semibold);
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* ---------- 分值输入 ---------- */

.seg {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.seg button {
  flex: 1;
  height: 36px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  cursor: pointer;
}

.seg button[aria-pressed='true'] {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: var(--weight-semibold);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.chip {
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  cursor: pointer;
  font-size: var(--text-2);
}

.chip[aria-pressed='true'] {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

/* ---------- 流水 ---------- */

.student-head {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 18px;
  margin-bottom: 18px;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
}

.big-score {
  font-size: var(--text-8);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.big-score.neg {
  color: var(--color-negative);
}

.student-head .actions {
  margin-left: auto;
}

.back {
  display: inline-block;
  margin-bottom: 14px;
  color: var(--color-muted);
  text-decoration: none;
  font-size: var(--text-2);
}

.back:hover {
  color: var(--color-text);
}

table.entries {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  overflow: hidden;
}

table.entries th {
  text-align: left;
  font-size: var(--text-1);
  font-weight: var(--weight-medium);
  color: var(--color-muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-line);
  background: var(--color-surface-alt);
  white-space: nowrap;
}

table.entries td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--color-line-soft);
  font-size: var(--text-3);
}

table.entries tr:last-child td {
  border-bottom: 0;
}

.delta {
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

.delta.pos {
  color: var(--color-positive);
}

.delta.neg {
  color: var(--color-negative);
}

tr.voided td {
  color: var(--color-faint);
}

tr.voided .delta {
  text-decoration: line-through;
  color: var(--color-faint);
}

.cell-time {
  color: var(--color-muted);
  font-size: var(--text-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------- 列表 ---------- */

.list {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  overflow: hidden;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--color-line-soft);
}

.list-row:last-child {
  border-bottom: 0;
}

.list-row .grow {
  flex: 1;
  min-width: 0;
}

.list-row .title {
  font-weight: var(--weight-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-row .sub {
  font-size: var(--text-1);
  color: var(--color-muted);
  margin-top: 2px;
}

/* ---------- toast ---------- */

#toast-root {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--color-inverse-bg);
  color: var(--color-on-accent);
  font-size: var(--text-3);
  box-shadow: var(--shadow-up);
  animation: toastIn 0.16s ease-out;
}

.toast.error {
  background: var(--color-negative);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ---------- 窄屏 ---------- */

@media (max-width: 640px) {
  .page {
    padding: 16px 14px 90px;
  }
  .topbar {
    padding: 8px 14px;
    gap: 10px;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 10px;
  }
  .card {
    padding: 12px;
  }
  .card-score {
    font-size: var(--text-6);
  }
  .card-name {
    font-size: var(--text-3);
  }
  .who {
    display: none;
  }
  .big-score {
    font-size: var(--text-7);
  }
  table.entries th:nth-child(4),
  table.entries td:nth-child(4) {
    display: none;
  }
}

/* ---------- 排行榜（投屏） ---------- */

.board {
  min-height: 100vh;
  padding: clamp(22px, 3.4vw, 52px);
  background: var(--color-surface);
}

/* 标题与榜单共用同一栏宽，左边缘对齐 */
.board-head,
.board-list {
  width: 100%;
  max-width: var(--board-width);
  margin-left: auto;
  margin-right: auto;
}

.board-head {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: clamp(16px, 2.4vw, 34px);
  padding-bottom: clamp(12px, 1.6vw, 20px);
  border-bottom: 2px solid var(--color-line);
}

.board-head h1 {
  margin: 0;
  font-size: clamp(var(--text-6), 3.4vw, var(--text-8));
  font-weight: var(--weight-bold);
  letter-spacing: -0.01em;
}

.board-head .muted {
  font-size: clamp(var(--text-2), 1.1vw, var(--text-5));
}

.board-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

/*
 * 按内容排布，不拉伸：
 * - 三列宽度都由内容决定，姓名列 = 全班最长名字的宽度
 * - 分数紧跟姓名，且因为共用同一列，所有分数竖直对齐
 * - display: contents 让每行的单元格参与这组共享列
 */
.board-list {
  display: grid;
  grid-template-columns: auto max-content auto;
  justify-content: start;
  align-items: center;
}

.board-row {
  display: contents;
}

.board-row > * {
  padding-top: clamp(7px, 1vw, 13px);
  padding-bottom: clamp(7px, 1vw, 13px);
  border-bottom: 1px solid var(--color-line-faint);
}

/* 单元格只负责居中；圆形是里层元素，避免被单元格内边距挤压 */
.board-rank {
  display: flex;
  align-items: center;
  justify-content: center;
}

.board-rank-badge {
  display: grid;
  place-items: center;
  width: clamp(30px, 2.6vw, 44px);
  height: clamp(30px, 2.6vw, 44px);
  border-radius: 50%;
  font-size: clamp(var(--text-3), 1.3vw, var(--text-6));
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  color: var(--color-muted);
  line-height: 1;
}

.board-row.rank-1 .board-rank-badge {
  background: var(--color-gold-bg);
  color: var(--color-gold-text);
}

.board-row.rank-2 .board-rank-badge {
  background: var(--color-silver-bg);
  color: var(--color-silver-text);
}

.board-row.rank-3 .board-rank-badge {
  background: var(--color-bronze-bg);
  color: var(--color-bronze-text);
}

.board-name {
  padding-left: clamp(10px, 1.2vw, 18px);
  padding-right: clamp(12px, 1.2vw, 22px);
  max-width: 60vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(var(--text-5), 1.9vw, var(--text-7));
  font-weight: var(--weight-medium);
}

.board-class {
  margin-left: 8px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-line);
  background: var(--color-surface-alt);
  font-size: clamp(var(--text-1), 0.9vw, var(--text-4));
  font-weight: var(--weight-regular);
  color: var(--color-muted);
  vertical-align: middle;
}

.board-score {
  text-align: right;
  font-size: clamp(var(--text-5), 2.1vw, var(--text-7));
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.board-score.neg {
  color: var(--color-negative);
}

@media (max-width: 860px) {
  .board-head {
    flex-wrap: wrap;
  }
}

/* ---------- 称号 ---------- */

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.badge-strip {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.badge-chip {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: var(--text-1);
  font-weight: var(--weight-medium);
  white-space: nowrap;
}

.badge-chip.is-more {
  background: var(--color-surface-alt);
  color: var(--color-muted);
}

.badge-x {
  border: 0;
  padding: 0 0 0 4px;
  background: transparent;
  color: inherit;
  font-size: var(--text-2);
  line-height: 1;
  cursor: pointer;
  opacity: 0.65;
}

.badge-x:hover {
  opacity: 1;
}

/* 排行榜里的称号跟着投屏字号放大，并保持与名字同行 */
.board-name .badge-strip {
  margin-top: 0;
  margin-left: 8px;
  vertical-align: middle;
}

.board-name .badge-chip {
  height: auto;
  padding: 2px 9px;
  font-size: clamp(var(--text-1), 0.85vw, var(--text-3));
}

/* ---------- 学生卡片：头像与统计 ---------- */

.card[hidden] {
  display: none;
}

.card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.card-avatar {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: var(--text-2);
  font-weight: var(--weight-semibold);
}

.tone-1 {
  background: var(--color-avatar-1-bg);
  color: var(--color-avatar-1-text);
}
.tone-2 {
  background: var(--color-avatar-2-bg);
  color: var(--color-avatar-2-text);
}
.tone-3 {
  background: var(--color-avatar-3-bg);
  color: var(--color-avatar-3-text);
}
.tone-4 {
  background: var(--color-avatar-4-bg);
  color: var(--color-avatar-4-text);
}
.tone-5 {
  background: var(--color-avatar-5-bg);
  color: var(--color-avatar-5-text);
}
.tone-6 {
  background: var(--color-avatar-6-bg);
  color: var(--color-avatar-6-text);
}

.card:hover {
  transform: translateY(-1px);
}

.card-score.score-pulse {
  animation: score-pulse 0.32s ease-out;
}

@keyframes score-pulse {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.14);
  }
  100% {
    transform: scale(1);
  }
}

/* 顶部统计条 */

.stats {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.stat {
  flex: 1 1 0;
  min-width: 104px;
  padding: 10px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat b {
  font-size: var(--text-6);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat b.neg {
  color: var(--color-negative);
}

.stat b.pos {
  color: var(--color-positive);
}

.stat span {
  font-size: var(--text-1);
  color: var(--color-muted);
}

/* 搜索 */

.search-row {
  margin-bottom: 14px;
}

.search-input {
  width: 100%;
  max-width: 320px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-ring);
}

@media (max-width: 640px) {
  .stat {
    min-width: 0;
    flex: 1 1 45%;
  }
  .stat b {
    font-size: var(--text-5);
  }
  .card-avatar {
    width: 24px;
    height: 24px;
    font-size: var(--text-1);
  }
}

/* ---------- 品牌与统计卡配色 ---------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--color-brand-a), var(--color-brand-b));
  color: var(--color-on-accent);
  font-size: var(--text-1);
  font-weight: var(--weight-bold);
  line-height: 1;
}

/* 顶栏顶部一条极细的品牌色渐变，作为整体的一点点颜色 */
.topbar {
  position: sticky;
}

.topbar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-brand-a), var(--color-brand-b), var(--color-brand-c));
}

.stat--teal {
  background: var(--color-tint-teal-bg);
  border-color: transparent;
}

.stat--teal b {
  color: var(--color-tint-teal-text);
}

.stat--yellow {
  background: var(--color-tint-yellow-bg);
  border-color: transparent;
}

.stat--yellow b {
  color: var(--color-tint-yellow-text);
}

.stat--green {
  background: var(--color-tint-green-bg);
  border-color: transparent;
}

.stat--green b {
  color: var(--color-tint-green-text);
}

.stat--red {
  background: var(--color-tint-red-bg);
  border-color: transparent;
}

.stat--red b {
  color: var(--color-tint-red-text);
}

/* 增减的颜色优先于卡片底色 */
.stat b.neg {
  color: var(--color-negative);
}

.stat b.pos {
  color: var(--color-positive);
}

/* ---------- Logo ---------- */

.brand-logo {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  object-fit: contain;
  background: var(--color-surface);
  flex: none;
}

.gate-logo {
  display: block;
  width: 88px;
  height: 88px;
  margin: 0 0 16px;
  object-fit: contain;
}

@media (max-width: 640px) {
  .brand-logo {
    width: 24px;
    height: 24px;
  }
  .gate-logo {
    width: 72px;
    height: 72px;
    margin-bottom: 12px;
  }
}

/* ---------- 头像选择 ---------- */

.avatar-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.avatar-option {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 0.12s, transform 0.08s;
}

.avatar-option img {
  display: block;
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.avatar-option:hover {
  border-color: var(--color-line-strong);
}

.avatar-option:active {
  transform: scale(0.94);
}

.avatar-option.is-active {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-ring);
}

.card-avatar--img {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  overflow: hidden;
  background: transparent;
}

.card-avatar--img img {
  display: block;
  width: 100%;
  height: 100%;
}

/* 榜单里的头像 */
.board-avatar {
  display: inline-grid;
  place-items: center;
  width: clamp(24px, 2.2vw, 36px);
  height: clamp(24px, 2.2vw, 36px);
  border-radius: 9px;
  margin-right: 10px;
  vertical-align: middle;
  font-size: clamp(12px, 1.1vw, 16px);
  font-weight: var(--weight-semibold);
  line-height: 1;
}

.board-avatar--img {
  overflow: hidden;
  background: transparent;
}

.board-avatar--img img {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- 角色标签 ---------- */

.role-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: var(--text-1);
  font-weight: var(--weight-medium);
  vertical-align: middle;
}

.role-tag.is-teacher {
  background: var(--color-surface-alt);
  color: var(--color-muted);
  border: 1px solid var(--color-line);
}

/* 登录卡片：没有说明文字时，标题和表单之间留出呼吸感 */
.gate-card h1 {
  margin: 0 0 20px;
}

.gate-card h1.has-msg {
  margin-bottom: 4px;
}

/* ---------- 发奖倒计时条 ---------- */

.cd-bar {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--color-line);
  background: linear-gradient(90deg, var(--color-tint-teal-bg), var(--color-tint-yellow-bg));
}

.cd-bar > span {
  font-size: var(--text-2);
  color: var(--color-muted);
}

.cd-bar b {
  font-size: var(--text-6);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.cd-bar > span:last-child {
  margin-left: auto;
}

.list-val {
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

/* ---------- 段位徽章 ---------- */

.tier-chip,
.tier-badge {
  display: inline-block;
  flex: none;
  border-radius: 6px;
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  vertical-align: middle;
}

.tier-chip {
  padding: 0 6px;
  font-size: var(--text-1);
  line-height: 16px;
}

.tier-badge {
  margin-left: 8px;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--text-2);
  font-weight: var(--weight-semibold);
}

.tier-iron { background: var(--color-tier-iron-bg); color: var(--color-tier-iron-text); }
.tier-bronze { background: var(--color-tier-bronze-bg); color: var(--color-tier-bronze-text); }
.tier-silver { background: var(--color-tier-silver-bg); color: var(--color-tier-silver-text); }
.tier-gold { background: var(--color-tier-gold-bg); color: var(--color-tier-gold-text); }
.tier-platinum { background: var(--color-tier-platinum-bg); color: var(--color-tier-platinum-text); }
.tier-emerald { background: var(--color-tier-emerald-bg); color: var(--color-tier-emerald-text); }
.tier-diamond { background: var(--color-tier-diamond-bg); color: var(--color-tier-diamond-text); }
.tier-master { background: var(--color-tier-master-bg); color: var(--color-tier-master-text); }
.tier-grandmaster { background: var(--color-tier-grandmaster-bg); color: var(--color-tier-grandmaster-text); }
.tier-challenger { background: var(--color-tier-challenger-bg); color: var(--color-tier-challenger-text); }
