/* 象棋三国志 强度排行。只用系统字体，不引外部资源（国内要能打开）。 */
:root {
  --paper: #f4ecdc;
  --paper-2: #ebe0c9;
  --card: #fbf7ee;
  --ink: #2a211b;
  --ink-2: #5b4d40;
  --ink-3: #8a7a68;
  --line: #d8c9ac;
  --seal: #b8322a;
  --seal-dark: #8f241e;
  --gold: #b88a2e;
  --t0: #e8534a;   /* 夯 红 */
  --t1: #f29a3f;   /* 顶级 橙 */
  --t2: #f4d35e;   /* 人上人 黄 */
  --t3: #efe3c6;   /* NPC 浅米 */
  --t4: #ffffff;   /* 拉 白 */
  --r0: #8d9a86; --r1: #4d84b8; --r2: #8a5cb5; --r3: #c9962b; --r4: #b8322a;
  --shadow: 0 1px 2px rgba(60, 40, 20, .12), 0 4px 14px rgba(60, 40, 20, .08);
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
  --tile: 76px;
}
/* 各语言用本语言的系统字体（简中的宋体/雅黑排西文、俄文、越南文字母很散） */
:root:lang(zh-TW) {
  --sans: "PingFang TC", "Microsoft JhengHei", "Noto Sans CJK TC", "Source Han Sans TC", sans-serif;
  --serif: "Songti TC", "PMingLiU", "MingLiU", "Noto Serif CJK TC", "Source Han Serif TC", serif;
}
:root:lang(ja) {
  --sans: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", "Meiryo", "Noto Sans CJK JP", sans-serif;
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "MS PMincho", "Noto Serif CJK JP", serif;
}
:root:lang(ko) {
  --sans: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans CJK KR", "Nanum Gothic", sans-serif;
  --serif: "AppleMyungjo", "Nanum Myeongjo", "Batang", "Noto Serif CJK KR", serif;
}
:root:lang(en), :root:lang(ru), :root:lang(vi) {
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  --serif: Georgia, "Times New Roman", "Noto Serif", "Songti SC", "SimSun", serif;
}
/* Georgia 缺越南语的叠加声调字母（ố ế 会拆开），越南语换全覆盖的衬线体 */
:root:lang(vi) { --serif: "Times New Roman", "Noto Serif", Tinos, "Songti SC", "SimSun", serif; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.6;
}
a { color: var(--seal); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }

/* 顶栏 */
.top { border-bottom: 1px solid var(--line); background: var(--paper-2); }
.top .wrap { display: flex; align-items: center; gap: 12px; height: 52px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-family: var(--serif); font-weight: 700; font-size: 18px; }
.brand .piece { width: 30px; height: 30px; font-size: 16px; }
.top nav { margin-left: auto; display: flex; gap: 14px; font-size: 14px; }
.top nav a { color: var(--ink-2); text-decoration: none; }
.top nav a:hover { color: var(--seal); }

/* 语言菜单（右上角） */
.lang { position: relative; flex-shrink: 0; font-size: 13px; }
.lang summary {
  list-style: none; display: flex; align-items: center; gap: 4px; cursor: pointer; user-select: none;
  color: var(--ink-2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px; background: var(--card);
}
.lang summary::-webkit-details-marker { display: none; }
.lang summary::after { content: ""; border: 4px solid transparent; border-top-color: currentColor; border-bottom: 0; margin-left: 1px; }
.lang summary:hover, .lang[open] summary { color: var(--seal); border-color: var(--seal); }
.lang svg { display: block; }
.lang .menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 132px; padding: 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
}
.lang .menu a { display: block; padding: 6px 10px; border-radius: 5px; color: var(--ink); text-decoration: none; white-space: nowrap; font-size: 14px; }
.lang .menu a:hover { background: var(--paper-2); }
.lang .menu a.on { color: var(--seal); font-weight: 700; }

/* 棋子圆（品牌和无立绘的占位） */
.piece {
  display: inline-grid; place-items: center; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fffaf0, #f1dfba 70%);
  border: 2px solid var(--seal); color: var(--seal);
  font-family: var(--serif); font-weight: 700; box-shadow: inset 0 0 0 3px #fffaf0, inset 0 0 0 4px rgba(184, 50, 42, .35);
}

/* 首页 */
.hero { padding: 40px 0 24px; text-align: center; }
.hero h1 { font-family: var(--serif); font-size: 40px; margin: 0; letter-spacing: 4px; }
.hero p { color: var(--ink-2); margin: 10px auto 18px; max-width: 34em; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--seal); background: var(--seal); color: #fff; text-decoration: none;
  padding: 9px 20px; border-radius: 6px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--seal-dark); }
.btn.ghost { background: transparent; color: var(--seal); }
.btn.ghost:hover { background: rgba(184, 50, 42, .08); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.section-title { font-family: var(--serif); font-size: 22px; margin: 28px 0 12px; }
.boards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 40px; }
.board-card {
  display: block; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; color: var(--ink); text-decoration: none; box-shadow: var(--shadow); transition: transform .12s;
}
.board-card:hover { transform: translateY(-2px); border-color: var(--seal); }
.board-card h3 { margin: 0; font-family: var(--serif); font-size: 20px; }
.board-card .sub { color: var(--ink-3); font-size: 13px; margin: 2px 0 10px; }
.board-card .faces { display: flex; }
.board-card .faces img, .board-card .faces .piece { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--card); margin-right: -8px; background: var(--paper-2); object-fit: cover; }
.board-card .faces .piece { font-size: 16px; }
.top-label { font-size: 12px; color: var(--seal); font-weight: 700; margin-bottom: 4px; }
.top5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.top-item { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.top-face {
  position: relative; width: 44px; height: 44px; border-radius: 6px; overflow: hidden; border: 2px solid var(--rc, var(--r0));
  background: linear-gradient(160deg, #fffaf0, #eadbbb);
}
.top-face img { width: 100%; height: 100%; display: block; }
.top-face .piece { width: 74%; height: 74%; margin: 13%; font-size: 15px; }
.top-face i {
  position: absolute; left: 0; top: 0; background: var(--seal); color: #fff; font-style: normal; font-size: 10px;
  line-height: 13px; padding: 0 3px; border-radius: 0 0 4px 0;
}
.top5 .top-item:first-child .top-face { border-color: var(--t0); box-shadow: 0 0 0 2px rgba(232, 83, 74, .3); }
.top-name { font-size: 11px; line-height: 1.3; margin-top: 2px; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.top-avg { font-size: 11px; color: var(--seal); font-weight: 700; line-height: 1.2; }
.board-card .count { color: var(--ink-2); font-size: 13px; margin-top: 10px; }
.foot { border-top: 1px solid var(--line); color: var(--ink-3); font-size: 13px; padding: 18px 0 28px; text-align: center; }

/* 榜单页 */
.board-bar { display: flex; align-items: flex-end; gap: 14px; padding-top: 10px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.board-bar h1 { margin: 0 0 6px; font-family: var(--serif); font-size: 26px; white-space: nowrap; }
.board-sub { color: var(--ink-3); font-size: 13px; margin: -4px 0 8px; }
.board-bar .tabs { margin: 0; border-bottom: 0; }
.tabs { display: flex; gap: 6px; margin: 14px 0 12px; border-bottom: 1px solid var(--line); }
.tabs button {
  border: 0; background: none; font: inherit; font-size: 16px; padding: 8px 14px; cursor: pointer; color: var(--ink-2);
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tabs button.on { color: var(--seal); border-bottom-color: var(--seal); font-weight: 700; }
.hint { color: var(--ink-2); font-size: 13px; margin: 0 0 10px; }
.notice { background: #fff6e0; border: 1px solid #e9cf8f; border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; font-size: 14px; }

/* 档位表 */
.tierlist { border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; background: #2a211b; }
.tier { display: flex; min-height: calc(var(--tile) + 10px); border-top: 2px solid var(--ink); background: #fffdf8; }
.tier:first-child { border-top: 0; }
.tier-label {
  flex: 0 0 84px; display: grid; place-items: center; text-align: center;
  font-family: var(--serif); font-weight: 800; font-size: 22px; color: #2a211b; border-right: 2px solid var(--ink);
  user-select: none;
}
.tier-label small { display: block; font-family: var(--sans); font-weight: 400; font-size: 11px; color: rgba(42, 33, 27, .65); }
.t0 .tier-label { background: var(--t0); color: #fff; }
.t0 .tier-label small { color: rgba(255, 255, 255, .8); }
.t1 .tier-label { background: var(--t1); }
.t2 .tier-label { background: var(--t2); }
.t3 .tier-label { background: var(--t3); }
.t4 .tier-label { background: var(--t4); }
.tn .tier-label { background: #ddd3c2; font-size: 15px; }
.zone { flex: 1; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 4px; padding: 4px; min-height: 100%; }
.zone.over { background: #fff1d1; }
.pickable .zone { cursor: pointer; }

/* 我来排：左边档位，右边待排（翻页） */
.rank-grid { display: grid; grid-template-columns: minmax(0, 1fr) var(--pool-w, 344px); gap: 12px; align-items: start; }
.pool-wrap { display: flex; flex-direction: column; gap: 6px; }
.pool-head { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); min-height: 30px; }
.pool-head b { flex: 1; font-weight: 600; }
.pool {
  --tile-max: 72px;
  background: var(--card); border: 1px dashed var(--line); border-radius: 8px; min-height: calc(var(--tile) + 12px);
  overflow: hidden; justify-content: flex-start; align-content: flex-start;
}
.pager { display: flex; align-items: center; gap: 6px; }
.pager[hidden] { display: none; }
.pager span { font-size: 13px; color: var(--ink-2); white-space: nowrap; min-width: 40px; text-align: center; }
.pager button {
  border: 1px solid var(--seal); background: var(--card); color: var(--seal); border-radius: 6px;
  width: 34px; height: 30px; font: inherit; font-size: 18px; line-height: 1; cursor: pointer;
}
.pager button:hover:not(:disabled) { background: rgba(184, 50, 42, .08); }
.pager button:disabled { opacity: .35; cursor: default; }
.pool-wrap .actions { margin: 0; gap: 8px; flex-wrap: nowrap; }
.pool-wrap .actions .btn { flex: 1; padding: 9px 8px; white-space: nowrap; }

/* 整屏模式（排榜时）：页面不滚动，档位平分高度 */
body.fit { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
body.fit .foot { display: none; }
body.fit main { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; }
body.fit #rank { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-bottom: 10px; }
body.fit .rank-grid { flex: 1; min-height: 0; align-items: stretch; }
body.fit .tierlist { --tile-max: 72px; display: flex; flex-direction: column; min-height: 0; }
body.fit .tier { flex: 1 1 0; min-height: 0; }
body.fit .tierlist .zone { overflow: hidden; min-height: 0; }
body.fit .pool-wrap { min-height: 0; }
body.fit .pool { flex: 1 1 0; min-height: 0; }
body.fit .board-sub { display: none; }
.rank-hint { margin: 0 0 8px; }

/* 头像格：名字叠在头像底部，不额外占高度 */
.tile {
  position: relative; width: var(--tile); height: var(--tile); flex: 0 0 var(--tile); cursor: grab;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: pan-y;
}
.tile .face {
  display: block; width: var(--tile); height: var(--tile); border-radius: 6px; overflow: hidden;
  border: 2px solid var(--rc, var(--r0)); background: linear-gradient(160deg, #fffaf0, #eadbbb);
}
.tile .face img { width: 100%; height: 100%; display: block; pointer-events: none; }
.tile .face .piece { display: grid; width: 60%; height: 60%; margin: 7% auto 0; font-size: calc(var(--tile) * .3); }
.tile .nm {
  position: absolute; left: 2px; right: 2px; bottom: 2px; border-radius: 0 0 4px 4px; pointer-events: none;
  background: rgba(42, 33, 27, .72); color: #fff; text-align: center;
  font-size: max(9px, calc(var(--tile) * .16)); line-height: 1.35; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.tiny .tile .nm { display: none; }
.tiny .tile .face .piece { width: 74%; height: 74%; margin: 13%; font-size: calc(var(--tile) * .36); }
.tile.sel .face { outline: 3px solid var(--seal); outline-offset: 1px; }
.tile.ghost { opacity: .3; }
.tile .badge {
  position: absolute; right: 2px; top: 2px; display: flex; flex-direction: column; align-items: flex-end; gap: 1px;
  font-size: 10px; line-height: 14px; pointer-events: none;
}
.tile .badge span { background: rgba(42, 33, 27, .82); color: #fff; border-radius: 3px; padding: 0 3px; }
.tile .rank { position: absolute; left: 2px; top: 2px; background: var(--seal); color: #fff; font-size: 10px; line-height: 14px; border-radius: 3px; padding: 0 3px; pointer-events: none; }
.r0 { --rc: var(--r0); } .r1 { --rc: var(--r1); } .r2 { --rc: var(--r2); } .r3 { --rc: var(--r3); } .r4 { --rc: var(--r4); }
.drag-float { position: fixed; z-index: 50; pointer-events: none; transform: translate(-50%, -60%) scale(1.08); filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .3)); }

/* 底部操作 */
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 16px 0; }
.actions .grow { flex: 1; color: var(--ink-3); font-size: 13px; }
.selbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: min(640px, 100%);
  z-index: 20; background: var(--ink); color: #fff; border-radius: 10px 10px 0 0; box-shadow: 0 -4px 18px rgba(0, 0, 0, .25);
  padding: 10px 14px; display: none; align-items: center; gap: 10px; font-size: 14px;
}
.selbar.show { display: flex; flex-direction: column; align-items: stretch; }
.selrow { display: flex; align-items: center; gap: 8px; }
.selbar button { background: none; border: 1px solid rgba(255, 255, 255, .5); color: #fff; border-radius: 5px; padding: 4px 10px; font: inherit; cursor: pointer; }
.selbar .grow { flex: 1; }
.selrow.put { margin-top: 8px; gap: 6px; }
.selrow.put button { flex: 1; border: 0; color: #2a211b; font-weight: 700; padding: 8px 0; }
.selrow.put button.back { background: #ddd3c2; flex: 0 0 auto; padding: 8px 10px; font-weight: 400; }

/* 我的排行（截图卡） */
.mine-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; box-shadow: var(--shadow); margin: 6px 0 18px; }
.mine-card h2 { font-family: var(--serif); margin: 0 0 10px; font-size: 20px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.mine-card h2 small { font-family: var(--sans); font-size: 12px; color: var(--ink-3); font-weight: 400; }
.mine-card .tile { cursor: default; }

/* 详情弹窗 */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(30, 20, 12, .55); display: none; align-items: flex-end; justify-content: center; }
.modal.show { display: flex; }
.sheet { background: var(--card); width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; border-radius: 14px 14px 0 0; padding: 18px 18px 24px; }
@media (min-width: 640px) { .modal { align-items: center; } .sheet { border-radius: 14px; } }
.sheet .hd { display: flex; gap: 14px; align-items: center; }
.sheet .hd .face { width: 88px; height: 88px; flex: 0 0 88px; border-radius: 8px; overflow: hidden; border: 2px solid var(--rc, var(--r0)); background: linear-gradient(160deg, #fffaf0, #eadbbb); }
.sheet .hd .face img { width: 100%; height: 100%; }
.sheet .hd .face .piece { width: 74%; height: 74%; margin: 13%; font-size: 30px; }
.sheet h2 { margin: 0; font-family: var(--serif); font-size: 24px; }
.sheet .meta { color: var(--ink-3); font-size: 13px; }
.sheet .close { margin-left: auto; align-self: flex-start; border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--ink-3); }
.bars { margin: 14px 0 6px; }
.bar { display: grid; grid-template-columns: 54px 1fr 70px; align-items: center; gap: 8px; font-size: 13px; margin: 4px 0; }
.bar .lab { font-weight: 700; text-align: center; border-radius: 4px; padding: 1px 0; border: 1px solid var(--line); }
.bar .track { height: 14px; background: var(--paper-2); border-radius: 7px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--seal); }
.bar .num { color: var(--ink-2); text-align: right; }
.skills { margin-top: 12px; border-top: 1px solid var(--line); }
.skill { padding: 10px 0; border-bottom: 1px solid var(--line); }
.skill b { font-size: 15px; }
.skill .tag { display: inline-block; font-size: 11px; border-radius: 3px; padding: 0 5px; margin-left: 6px; vertical-align: 1px; background: var(--paper-2); color: var(--ink-2); }
.skill .tag.a { background: var(--seal); color: #fff; }
.skill p { margin: 4px 0 0; color: var(--ink-2); font-size: 14px; white-space: pre-line; }

.empty { color: var(--ink-3); padding: 24px 0; text-align: center; }

@media (max-width: 860px) {
  :root { --pool-w: 260px; }
}
@media (max-width: 600px) {
  :root { --tile: 60px; }
  /* 手机上下排：上面五档，下面待排（翻页），同一屏；点头像再点底部档位按钮 */
  .rank-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  body.fit .rank-grid { grid-template-rows: minmax(0, 1.3fr) minmax(0, 1fr); }
  body.fit .tierlist { --tile-max: 52px; }
  .pool { --tile-max: 52px; }
  body.fit .tier-label { flex-basis: 48px; font-size: 15px; }
  body.fit .tier-label small { display: none; }
  body.fit .rank-hint { display: none; }
  .board-bar h1 { font-size: 20px; }
  .pool-wrap .actions .btn { padding: 7px 6px; font-size: 14px; }
  .selbar { border-radius: 12px 12px 0 0; }
  .hero h1 { font-size: 32px; }
  .tier-label { flex-basis: 56px; font-size: 17px; }
  .tier-label small { font-size: 10px; }
  .tile .nm { font-size: 11px; }
  .actions .grow { flex-basis: 100%; }
  .top nav { gap: 12px; font-size: 13px; overflow-x: auto; scrollbar-width: none; }
  .top nav a, .brand { white-space: nowrap; flex-shrink: 0; }
  .brand { font-size: 16px; }
}
