:root {
  --bg: #0f1216;
  --bg-2: #171b22;
  --bg-3: #1f242d;
  --line: #2a313c;
  --text: #e6eaf0;
  --muted: #9aa4b2;
  --accent: #ffb020;
  --accent-2: #35c4e6;
  --danger: #ff5d5d;
  --r6: #ff7a3d;
  --r5: #ffcf3f;
  --r4: #b28cff;
  --r3: #58b2ff;
  --r2: #7ed957;
  --r1: #9aa4b2;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
}

.hidden { display: none !important; }

/* ---------------- 布局：左侧栏 + 内容区 ---------------- */
.layout { display: flex; align-items: flex-start; min-height: 100vh; }
.sidebar {
  width: 220px; flex: none;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #12161c, var(--bg));
  padding: 18px 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}

/* 访问量计数（侧边栏底部角落） */
.visits {
  margin-top: auto; padding: 12px 8px 4px;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 12px;
  display: flex; align-items: center; gap: 6px;
}
.visits-eye { opacity: .85; }
.visits-num { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.content { flex: 1; min-width: 0; }

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.brand-logo {
  width: 40px; height: 40px;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid var(--accent);
  background: #0a0c0f;
  flex: none;
}
.brand h1 { margin: 0; font-size: 18px; letter-spacing: .5px; }

/* 侧边栏导航 */
.sidenav { display: flex; flex-direction: column; gap: 4px; }
.sidenav-section {
  color: var(--muted); font-size: 12px; font-weight: 700;
  letter-spacing: 1px; margin: 6px 6px 6px;
}
.sidenav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  padding: 10px 12px; border-radius: 8px;
  background: transparent; border: 1px solid transparent;
  color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer;
  transition: .15s;
}
a.sidenav-item { text-decoration: none; }
.sidenav-item:hover { background: var(--bg-3); }
.sidenav-item.active {
  background: rgba(255, 176, 32, .14);
  border-color: rgba(255, 176, 32, .5);
  color: var(--accent);
}
.sidenav-item .ico { font-size: 16px; }
.sidenav-item .nav-ico {
  width: 26px; height: 26px; border-radius: 6px;
  object-fit: cover; border: none; flex: none; background: #0a0c0f;
}

#app { max-width: 1180px; margin: 0 auto; padding: 16px; }

/* 窄屏：侧边栏变为顶部横条 */
@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static;
    border-right: none; border-bottom: 1px solid var(--line);
    padding: 12px 14px;
  }
  .brand { margin-bottom: 10px; }
  .sidenav { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
  .sidenav-section { display: none; }
  .sidenav-item { width: auto; padding: 8px 12px; }
}

/* ---------------- buttons ---------------- */
.btn {
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: .15s;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 700; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn.tie {
  background: transparent;
  border-color: var(--accent-2);
  color: var(--accent-2);
  padding: 10px 16px;
  font-weight: 600;
}
.btn.tie:hover { background: rgba(53,196,230,.12); }

/* ---------------- toolbar / filters ---------------- */
.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.toolbar-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.search {
  flex: 1;
  min-width: 220px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.count { color: var(--accent); font-weight: 700; white-space: nowrap; }
.chip {
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--muted);
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
}
.chip.active { color: #111; font-weight: 700; }
.chip.active[data-rarity="6"] { background: var(--r6); border-color: var(--r6); }
.chip.active[data-rarity="5"] { background: var(--r5); border-color: var(--r5); }
.chip.active[data-rarity="4"] { background: var(--r4); border-color: var(--r4); }
.chip.active[data-rarity="3"] { background: var(--r3); border-color: var(--r3); }
.chip.active[data-rarity="2"] { background: var(--r2); border-color: var(--r2); }
.chip.active[data-rarity="1"] { background: var(--r1); border-color: var(--r1); }
.chip.active[data-cls] { background: var(--accent-2); border-color: var(--accent-2); }
.chip.active[data-nation] { background: #ff7ac0; border-color: #ff7ac0; }
.btn.small { padding: 5px 10px; font-size: 12px; white-space: nowrap; }

/* ---------------- grid ---------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 10px;
}
.op {
  position: relative;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--bg-2);
  cursor: pointer;
  overflow: hidden;
  transition: .12s;
  text-align: center;
}
.op:hover { transform: translateY(-2px); }
.op img { width: 100%; aspect-ratio: 1/1; object-fit: cover; display: block; background: #0a0c0f; }
.op .nm { font-size: 12px; padding: 4px 3px; line-height: 1.25; color: var(--text); }
.op[data-r="6"] { border-color: var(--r6); }
.op[data-r="5"] { border-color: var(--r5); }
.op[data-r="4"] { border-color: var(--r4); }
.op[data-r="3"] { border-color: var(--r3); }
.op[data-r="2"] { border-color: var(--r2); }
.op[data-r="1"] { border-color: var(--r1); }
.op:not(.sel) { filter: grayscale(.85) brightness(.6); border-color: var(--line); }
.op .check {
  position: absolute;
  top: 4px; right: 4px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #111;
  font-size: 13px; font-weight: 900;
  display: none;
  align-items: center; justify-content: center;
}
.op.sel .check { display: flex; }

/* ---------------- footer bar ---------------- */
.footer-bar {
  position: sticky;
  bottom: 0;
  margin-top: 16px;
  padding: 12px 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(0deg, var(--bg), transparent);
}
.hint { color: var(--muted); font-size: 13px; }

/* ---------------- sort view ---------------- */
.progress-wrap { margin: 8px 0 6px; }
.progress-info { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.progress-bar { height: 8px; background: var(--bg-3); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .2s; }
.vs-toolbar { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 18px 0; flex-wrap: wrap; }
.vs-hint { text-align: center; color: var(--muted); font-size: 13px; margin: 0; }

.vs {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: center;
  max-width: 760px;
  margin: 0 auto;
}
.op-card.choice {
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  color: var(--text);
  transition: .12s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.op-card.choice:hover { border-color: var(--accent); transform: translateY(-3px); }
.op-card.choice img { width: 150px; height: 150px; border-radius: 12px; object-fit: cover; background: #0a0c0f; transition: .12s; }
.portrait-mode .op-card.choice img { width: 190px; height: 300px; object-fit: cover; object-position: top center; }
.op-card .card-name { font-size: 18px; font-weight: 700; }
.op-card .card-sub { font-size: 12px; color: var(--muted); }
.op-card[data-r="6"] { border-color: var(--r6); }
.op-card[data-r="5"] { border-color: var(--r5); }
.op-card[data-r="4"] { border-color: var(--r4); }
.op-card[data-r="3"] { border-color: var(--r3); }
.op-card[data-r="2"] { border-color: var(--r2); }
.op-card[data-r="1"] { border-color: var(--r1); }
.vs-mid { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.vs-badge { font-size: 26px; font-weight: 900; color: var(--accent); letter-spacing: 1px; }
.sort-controls { display: flex; justify-content: center; gap: 12px; margin-top: 24px; }

/* ---------------- result view (tiered ranking) ---------------- */
.result-head { margin-bottom: 14px; }
.result-head h2 { margin: 0 0 4px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.ranking { margin-top: 4px; }
.tier-podium { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; margin-bottom: 24px; }
.tier-big { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 14px; margin-bottom: 24px; }
.tier-small { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 14px; }

/* 通用条目 */
.rank-item { box-sizing: border-box; text-align: center; }
.rank-item .frame {
  position: relative;
  border: 4px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #0a0c0f;
}
.rank-item .frame img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
/* 横版半身立绘：图按固定高度铺、顶部对齐，只露出头到腰的一段 */
.banner-item .art {
  position: absolute; inset: 0;
  background-repeat: no-repeat;
  background-position: center top;
}
.rank-item .place-badge {
  position: absolute; right: 6px; bottom: 6px;
  background: rgba(10, 12, 15, .82);
  color: #fff; font-weight: 800; letter-spacing: .5px;
  padding: 2px 9px; border-radius: 8px; font-size: 15px;
}
.rank-item .rk-name { margin-top: 7px; font-weight: 700; font-size: 16px; word-break: break-word; }
.rank-item .rk-sub { font-size: 12px; color: var(--muted); }

/* 稀有度边框色 */
.rank-item[data-r="6"] .frame { border-color: var(--r6); }
.rank-item[data-r="5"] .frame { border-color: var(--r5); }
.rank-item[data-r="4"] .frame { border-color: var(--r4); }
.rank-item[data-r="3"] .frame { border-color: var(--r3); }
.rank-item[data-r="2"] .frame { border-color: var(--r2); }
.rank-item[data-r="1"] .frame { border-color: var(--r1); }

/* 领奖台（前 3 名）：金牌整行大 banner，银/铜下一行并排 */
.podium-item.gold { width: 100%; display: flex; flex-direction: column; align-items: center; }
.podium-item.gold .frame { width: min(560px, 100%); height: 300px; }
.podium-item.silver, .podium-item.bronze { width: min(300px, calc(50% - 8px)); }
.podium-item.silver .frame, .podium-item.bronze .frame { height: 250px; }
.podium-item.gold .art { background-size: auto 520px; }
.podium-item.silver .art, .podium-item.bronze .art { background-size: auto 440px; }
.podium-item.gold .frame { background: linear-gradient(to top left, #945101, 28%, #fffbac); box-shadow: 0 0 24px rgba(255, 190, 60, .4); animation: goldPulse 2.2s ease-in-out infinite; }
@keyframes goldPulse {
  0%, 100% { box-shadow: 0 0 22px rgba(255, 190, 60, .35); }
  50% { box-shadow: 0 0 40px rgba(255, 205, 80, .75); }
}
.podium-item.silver .frame { background: linear-gradient(to top left, #4a4560, 28%, #c0ddec); }
.podium-item.bronze .frame { background: linear-gradient(to top left, #6e4130, 28%, #ffddb8); }
.podium-item .place-badge { font-size: 22px; padding: 3px 13px; }
.podium-item .rk-name { font-size: 19px; }

/* 大图（4~18 名）：横版半身卡片网格 */
.big-item { width: calc(20% - 12px); }
.big-item .frame { height: 155px; background: linear-gradient(to top left, #2b2530, 30%, #4b4150); }
.big-item .art { background-size: auto 270px; }

/* 小图（其余，方形头像） */
.small-item { width: 100px; }
.small-item .rk-name-sm { font-size: 14px; font-weight: 700; margin-bottom: 4px; color: var(--text); }
.small-item .frame { width: 100px; height: 100px; }
.small-item .caption { margin-top: 5px; font-size: 13px; word-break: break-word; }

@media (max-width: 1000px) { .big-item { width: calc(25% - 11px); } }
@media (max-width: 700px) {
  .podium-item.gold, .podium-item.silver, .podium-item.bronze { width: 100%; max-width: none; }
  .podium-item .frame { height: 220px; }
  .big-item { width: calc(33.333% - 10px); }
  .small-item { width: calc(25% - 11px); }
  .small-item .frame { width: 100%; height: auto; aspect-ratio: 1 / 1; }
}

/* 手气抽卡按钮 */
.btn.lucky { border-color: #b98bff; color: #d9c2ff; }
.btn.lucky:hover { background: rgba(160, 120, 255, .16); }

/* 趣味称号 */
.result-badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.badge-chip {
  font-size: 13px; font-weight: 700; color: #ffe9a8;
  background: linear-gradient(135deg, rgba(255, 190, 60, .18), rgba(255, 120, 120, .18));
  border: 1px solid rgba(255, 200, 90, .45);
  padding: 4px 12px; border-radius: 999px;
}

/* 冠军彩带 */
.confetti-canvas {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 9999;
}
@media (prefers-reduced-motion: reduce) {
  .podium-item.gold .frame { animation: none; }
}

/* ======================= 竞猜小游戏 ======================= */
.quiz-entry { border-color: #5ad1c4; color: #b7f2ea; }
.quiz-entry:hover { background: rgba(90, 209, 196, .16); }

.quiz-setup, .quiz-over { max-width: 620px; margin: 12px auto; text-align: center; }
.quiz-setup h2, .quiz-over h2 { margin: 8px 0; }
.quiz-field { display: flex; align-items: center; gap: 10px; justify-content: center; margin: 14px 0; flex-wrap: wrap; }
.quiz-label { color: var(--muted); font-size: 14px; min-width: 40px; }
.quiz-choices { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.quiz-actions { display: flex; gap: 12px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }

.quiz-play { max-width: 720px; margin: 0 auto; }
.quiz-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.quiz-top .quiz-stat { font-weight: 700; font-size: 15px; }
.quiz-top #quiz-quit { margin-right: auto; }

.quiz-timerbar { height: 8px; background: var(--panel); border-radius: 6px; overflow: hidden; margin-bottom: 14px; }
.quiz-timerfill { height: 100%; width: 100%; background: linear-gradient(90deg, #5ad1c4, #7CFFB2); transition: background .3s; }
.quiz-timerfill.low { background: linear-gradient(90deg, #ff8a5b, #ff5b5b); }

.quiz-art { display: flex; justify-content: center; margin-bottom: 16px; }
.quiz-art .frame {
  width: min(360px, 92vw); height: 360px;
  border: 3px solid var(--line); border-radius: 12px; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, #2a3038, #0a0c0f 80%);
}
.quiz-art .art { width: 100%; height: 100%; background-repeat: no-repeat; background-position: center; background-size: contain; }

.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quiz-opt {
  padding: 16px 12px; font-size: 17px; font-weight: 700;
  color: var(--text); background: var(--panel);
  border: 2px solid var(--line); border-radius: 10px; cursor: pointer;
  transition: transform .08s, background .15s, border-color .15s;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-2px); }
.quiz-opt:disabled { cursor: default; }
.quiz-opt.right { background: rgba(90, 220, 140, .22); border-color: #4dd08a; color: #d8ffe6; }
.quiz-opt.wrong { background: rgba(255, 90, 90, .2); border-color: #ff6b6b; color: #ffd8d8; }

.quiz-score-big { font-size: 46px; font-weight: 800; margin: 10px 0; color: var(--accent); }
.quiz-final-sub { color: var(--muted); font-size: 15px; }

@media (max-width: 560px) {
  .quiz-art .frame { height: 300px; }
  .quiz-opt { padding: 13px 8px; font-size: 15px; }
}

.sitefoot { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 16px 40px; }
.sitefoot a { color: var(--accent-2); text-decoration: none; }
.sitefoot a:hover { text-decoration: underline; }

@media (max-width: 560px) {
  .op-card.choice img { width: 110px; height: 110px; }
  .portrait-mode .op-card.choice img { width: 110px; height: 180px; }
  .op-card.choice { padding: 10px; }
  .vs { gap: 8px; }
}

@media print {
  .topbar, .toolbar, .result-actions, .sitefoot, .footer-bar { display: none !important; }
  body { background: #fff; color: #000; }
  .rank-item .rk-name, .rank-item .caption, .rank-item .rk-sub { color: #000; }
}
