/* CK积分统计 — 上半模板 + 动态名次表（最多10人） */

:root {
  --bg: #000;
  --page: #070d11;
  --muted: #8b949e;
  --red: #e11d1d;
  --blue: #3b82f6;
  --text: #fff;
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --num: Oswald, "Noto Sans SC", sans-serif;
  --content-w: 1120px;
}

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

html,
body {
  height: 100%;
  overflow: hidden; /* 不要页面滚动条 */
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  padding: 10px 16px;
}

/* 控制台模式由 console.css 接管边距与背景 */
body.console {
  padding: 0;
  background: #05080b;
}

.app {
  width: min(100%, var(--content-w));
  height: 100%;
  margin: 0 auto;
  background: var(--page);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
}

/* 控制台内：高度随内容；宽度由 console.css 的 results-w 控制 */
body.console .app {
  height: auto;
  min-height: var(--idle-h, 810px);
  margin: 0;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* ===== 上半：cktemplate-top ===== */
.stage {
  position: relative;
  line-height: 0;
  flex: 0 0 auto;
}

.template {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  pointer-events: none;
}

.slot {
  position: absolute;
  z-index: 2;
  line-height: 1.2;
}

/* 时间 y=268/472 */
.slot--time {
  right: 2.32%;
  top: 56.78%;
  font-size: clamp(11px, 1.15vw, 13px);
  color: var(--muted);
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-style: normal;
  transform: translateY(-50%);
}

.slot--time::before {
  content: "";
  width: 12px;
  height: 12px;
  opacity: 0.8;
  background: center / contain no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239a9a9a' stroke-width='1.8'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* 车手名：头像右侧留白后左对齐 Cursor Write It */
.slot--mvp-id {
  left: 21%;
  top: 76.5%;
  width: 22%;
  text-align: left;
  font-size: clamp(15px, 1.7vw, 19px);
  font-weight: 700;
  color: #f0dcb4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

/* 车手说明：与车手名拉开行距，整体略下移 Cursor Write It */
.slot--mvp-side {
  left: 21%;
  top: 86.8%;
  width: 22%;
  font-size: clamp(12px, 1.2vw, 13px);
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  line-height: 1.3;
}

.slot--mvp-side .side {
  font-weight: 600;
}

.slot--mvp-side .side-blue {
  color: var(--blue);
}

.slot--mvp-side .side-red {
  color: var(--red);
}

.slot--mvp-side .mvp-sub {
  color: var(--muted);
}

/* 总分 + TOTAL：右移上移，留出底边余量 Cursor Write It */
.slot--mvp-score-wrap {
  left: 46.5%;
  top: 73.8%;
  transform: translateX(-50%);
  width: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  line-height: 1;
}

.slot--mvp-score {
  position: static;
  font-size: clamp(38px, 4.6vw, 52px);
  line-height: 1;
  color: #f0dcb4;
  text-align: center;
}

.slot--mvp-total {
  position: static;
  font-size: clamp(10px, 1.05vw, 11px);
  letter-spacing: 0.18em;
  color: var(--muted);
  text-align: center;
}

/* 比分：对齐模板蓝方 / 红方标签下方 */
.slot--score-blue,
.slot--score-red {
  top: 81.2%;
  width: 9%;
  text-align: center;
  font-size: clamp(34px, 4vw, 46px);
  line-height: 1;
  transform: none;
}

.slot--score-blue {
  left: 55.42%;
  color: #fff;
}

.slot--score-red {
  left: 72.93%;
  color: #fff;
}

/* 队徽框：VS 面板右侧，同高，宽按 1024:816 */
.slot--team-emblem {
  left: 84.39%;
  top: 66.24%;
  width: 13.08%;
  height: 31.62%;
  padding: 3px;
  box-sizing: border-box;
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow: hidden;
  background: transparent;
  border: 0;
}

.slot--team-emblem img {
  display: block;
  width: 100%;
  height: 100%;
  /* contain 完整显示队徽，避免 cover 裁切圆形徽章 Cursor Write It */
  object-fit: contain;
  object-position: center center;
  border-radius: 8px;
  user-select: none;
  pointer-events: none;
}

/*
  Oswald 无真斜体；设计稿斜体数字用正体粗 Oswald + skew。
  纯红(#e12)在深色底易糊；改用高亮度暖色兼顾辨识与清晰。
*/
.slant-num {
  display: inline-block;
  font-family: var(--num);
  font-weight: 700;
  font-style: normal;
  font-synthesis: none;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  transform: skewX(-14deg);
  -webkit-font-smoothing: antialiased;
}

/*
  名次表：按实际人数铺行（不补空行）。
  table-panel = 卡片（高度=表格）；table-fill = 透明弹性垫片撑满待机高度。
  ≤8 人固定行高，9～10 人可压缩。
*/
.table-panel {
  flex: 0 0 auto;
  margin: 2px 1.97% 8px;
  padding: 4px 14px 6px;
  line-height: normal;
  background: #0c1015;
  border: 1px solid #2a3036;
  border-radius: 12px;
  overflow: hidden;
}

.table-fill {
  display: none;
}

body.console .table-panel {
  flex: 0 0 auto;
  margin: 2px 1.97% 0;
  padding: 2px 12px 6px;
  display: block;
  height: auto;
  align-self: stretch;
}

body.console .table-fill {
  display: block;
  flex: 1 1 auto;
  min-height: 4px;
  margin: 0 1.97% 4px;
  pointer-events: none;
}

body.console .stats-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  height: auto !important;
  max-height: none !important;
  min-height: 0 !important;
}

body.console .stats-table tbody {
  height: auto !important;
}

body.console .stats-table tbody tr,
body.console .stats-table tbody td {
  height: 47px;
  max-height: 47px;
}

body.console .stats-table thead th {
  padding: 4px 2px 6px;
}

body.console .stats-table thead th.id {
  padding: 4px 2px 6px 36px;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: clamp(13px, 1.35vw, 15px);
}

/* dnf_rank：隐藏「未完成」列；列宽由 stats-view 重算以保持总宽 */
.stats-table th[data-col="dnf"][hidden] {
  display: none;
}

.stats-table thead th {
  color: #a1a1a1;
  font-weight: 500;
  font-size: clamp(11px, 1.1vw, 12px);
  padding: 8px 2px 12px;
  border-bottom: 1px solid #1d2327;
  text-align: center;
  white-space: nowrap;
}

.stats-table thead th.id {
  text-align: left;
  /* 仅表头「游戏ID」右移，数据行不跟 */
  padding: 8px 2px 12px 36px;
}

.stats-table tbody tr {
  height: 47px;
}

.stats-table td {
  text-align: center;
  vertical-align: middle;
  color: #bdbdbe;
  white-space: nowrap;
  padding: 0 2px;
  border-bottom: 1px solid #1d2327;
  font-weight: 400;
  height: 47px;
  box-sizing: border-box;
}

.stats-table td.num {
  font-variant-numeric: tabular-nums;
  font-size: clamp(14px, 1.45vw, 16px);
  color: #c8c8c9;
  letter-spacing: 0.02em;
}

.stats-table tbody tr:last-child td {
  /* 末行保留底边，卡片下沿有明确收口，不会和下方空白糊成一行 */
  border-bottom: 0;
}

.stats-table td.id {
  text-align: left;
  padding-left: 12px;
  color: #fff;
  font-weight: 500;
  font-size: clamp(14px, 1.4vw, 16px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-table td.total {
  font-size: clamp(16px, 1.65vw, 19px);
  /* 淡玫瑰红（亮度接近上一版暖金，避免抢眼/发糊） */
  color: #d9b4b8;
  letter-spacing: 0.01em;
}

/* 队伍圆点：设计稿实心饱和色点 ≈14px@1422 → ~12px@1120 */
.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 10px;
  vertical-align: 0;
  flex-shrink: 0;
}

.dot.b {
  background: #1c77f2;
  box-shadow: 0 0 0 1px rgba(28, 119, 242, 0.25);
}

.dot.r {
  background: #e32020;
  box-shadow: 0 0 0 1px rgba(227, 32, 32, 0.25);
}

/* 排名：略缩小以适配压缩行高 */
.medal-img {
  display: block;
  width: 30px;
  height: 30px;
  margin: 0 auto;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.medal-n {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin: 0 auto;
}

.medal-n .medal-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}

.medal-n__num {
  position: relative;
  z-index: 1;
  /* 对齐 medal-1/2/3 烘焙数字可视高度（原 12px 实际偏小） */
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  font-style: normal;
  font-synthesis: none;
  color: #fff;
  line-height: 1;
  letter-spacing: 0;
  -webkit-text-stroke: 0.4px rgba(0, 0, 0, 0.55);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
}

@media (max-width: 760px) {
  .app {
    width: 100%;
    margin: 0;
    border-radius: 0;
  }

  .table-panel {
    margin: 4px 8px 8px;
    padding: 4px 8px 4px;
  }

  body.console .table-fill {
    margin: 0 8px 8px;
  }

  .stats-table tbody tr,
  .stats-table td {
    height: 40px;
  }

  .medal-img,
  .medal-n {
    width: 26px;
    height: 26px;
  }

  .dot {
    width: 11px;
    height: 11px;
    margin-right: 8px;
  }
}
