:root {
  --bg: #12161c;
  --bg-2: #171d25;
  --card: #1b222b;
  --card-2: #222a35;
  --line: #2b3441;
  --text: #e6edf3;
  --dim: #8b96a5;
  --dim-2: #64707f;
  --accent: #4fc3f7;
  --accent-2: #1a98ff;
  --hang: #b33a27;
  --ding: #d68a2e;
  --ren: #e8b923;
  --npc: #8a8f98;
  --la: #5c6370;
  --shi: #6b4b3e;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
code {
  background: #263041;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 13px;
}

/* ---------------- 登录 ---------------- */
.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, #1d2a3a 0%, transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px 22px 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}
.brand {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .5px;
  background: linear-gradient(92deg, #7fd8ff, #4f9bff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.login-tip { color: var(--dim); font-size: 13.5px; margin: 12px 0 18px; }
#login-form { display: flex; flex-direction: column; gap: 10px; }
#code {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--text);
  font-size: 20px;
  letter-spacing: 6px;
  text-align: center;
  text-transform: uppercase;
  outline: none;
}
#code:focus { border-color: var(--accent); }
#login-form button, .primary {
  background: linear-gradient(180deg, #2fa8e8, #1a86c9);
  border: none;
  border-radius: 12px;
  padding: 13px 18px;
  font-weight: 600;
  color: #fff;
}
#login-form button:active, .primary:active { transform: translateY(1px); }
.login-msg { color: #ff8f7a; font-size: 13px; min-height: 18px; margin: 12px 0 0; }
.login-foot { color: var(--dim-2); font-size: 12px; margin: 4px 0 0; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0)) 16px 12px;
  background: rgba(18, 22, 28, .88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-main { flex: 1; min-width: 0; }
.topbar h1 {
  margin: 0;
  font-size: 19px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sub { color: var(--dim-2); font-size: 12px; margin-top: 2px; }
.me-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px 6px 6px;
  max-width: 42vw;
}
.me-btn img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.me-btn span {
  font-size: 13px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------- 工具条 ---------------- */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 16px 6px;
}
.tabs { display: flex; gap: 6px; }
.tab {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--dim);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
}
.tab.active { background: #1e3a4f; border-color: #2a6b93; color: #cdeeff; }
.search {
  flex: 1;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.search:focus { border-color: var(--accent); }

/* ---------------- 榜单一览 ---------------- */
.board { padding: 10px 16px calc(40px + env(safe-area-inset-bottom, 0)); }
.tier { margin: 22px 0 0; }
.tier-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--dim);
}
.tier-dot { width: 9px; height: 9px; border-radius: 50%; }
.tier-count { color: var(--dim-2); font-weight: 400; font-size: 12px; margin-left: 2px; }
.tier-line { flex: 1; height: 1px; background: var(--line); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 12px;
}
.gcard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  text-align: left;
  padding: 0;
  transition: transform .12s ease, border-color .12s ease;
}
.gcard:active { transform: scale(.985); border-color: #3d4a5c; }
.gcard .cover {
  position: relative;
  aspect-ratio: 460 / 215;
  background: #10141a;
}
.gcard .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gcard .cover .fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim-2);
  font-size: 12px;
}
.gcard .badge {
  position: absolute;
  right: 7px;
  bottom: 7px;
  background: rgba(10, 13, 18, .82);
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .3px;
}
.gcard .mine {
  position: absolute;
  left: 7px;
  top: 7px;
  background: rgba(26, 134, 201, .92);
  border-radius: 7px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
}
.gcard .meta { padding: 9px 10px 11px; }
.gcard .name {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 36px;
}
.gcard .info { color: var(--dim-2); font-size: 11.5px; margin-top: 4px; }

.empty { text-align: center; color: var(--dim-2); padding: 60px 20px; font-size: 13.5px; }

/* ---------------- 详情 ---------------- */
.detail { padding-bottom: calc(40px + env(safe-area-inset-bottom, 0)); }
.detail-top {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 5;
  padding: calc(10px + env(safe-area-inset-top, 0)) 12px;
}
.back {
  background: rgba(10, 13, 18, .6);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  width: 38px;
  height: 38px;
  font-size: 17px;
  line-height: 1;
  backdrop-filter: blur(8px);
}
.hero { position: relative; height: 220px; background: #0d1117; }
.hero-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-fade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(13, 17, 23, .15) 0%, rgba(18, 22, 28, .55) 55%, var(--bg) 100%);
}
.hero-text { position: absolute; left: 16px; right: 16px; bottom: 12px; }
.hero-text h2 { margin: 0; font-size: 24px; line-height: 1.2; text-shadow: 0 2px 12px rgba(0, 0, 0, .6); }
.hero-alt { color: #9fb4c7; font-size: 12.5px; margin-top: 3px; text-shadow: 0 1px 8px rgba(0, 0, 0, .6); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag {
  font-size: 11.5px;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .14);
  color: #d5e3ef;
  backdrop-filter: blur(4px);
}
.tag.custom { background: rgba(79, 195, 247, .18); border-color: rgba(79, 195, 247, .5); color: #bfeaff; }

.detail-body { padding: 4px 16px 0; }
.score-row { display: flex; align-items: flex-end; gap: 14px; margin-top: 14px; }
.score-big { display: flex; align-items: center; gap: 10px; }
.score-big span { font-size: 34px; font-weight: 800; letter-spacing: -.5px; }
.tier-chip {
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  color: #12161c;
}
.score-meta { display: flex; flex-direction: column; color: var(--dim-2); font-size: 12px; padding-bottom: 6px; }

.rate-box {
  margin: 14px 0 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
}
.rate-head { display: flex; justify-content: space-between; align-items: baseline; }
.rate-head span { color: var(--dim); font-size: 13px; }
.rate-head strong { font-size: 20px; }
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  margin: 6px 0 2px;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #6b4b3e 0%, #5c6370 10%, #8a8f98 50%, #e8b923 60%, #d68a2e 70%, #b33a27 90%);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  margin-top: -9px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #1a86c9;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .5);
}
.rate-actions { display: flex; gap: 10px; margin-top: 8px; }
.rate-actions .primary { flex: 1; padding: 10px 16px; }
.ghost {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 16px;
  color: var(--dim);
}
.rate-msg { color: #6fd08c; font-size: 12.5px; min-height: 17px; margin: 8px 0 0; }

.desc {
  color: var(--dim);
  font-size: 13px;
  line-height: 1.65;
  margin: 16px 0 0;
  max-height: 6.6em;
  overflow: hidden;
  position: relative;
}
.desc.more { max-height: none; }

.sec-title { font-size: 14px; color: var(--dim); margin: 22px 0 10px; font-weight: 600; }

.ratings { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ratings li { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.ratings img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; background: var(--card-2); }
.ratings .nick { flex: 1; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ratings .val { font-weight: 700; }
.ratings li.mine .nick { color: var(--accent); }

.comments { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.comment { display: flex; gap: 10px; }
.comment img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--card-2); flex: none; }
.comment .c-body { flex: 1; min-width: 0; }
.comment .c-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.comment .c-head .nick { color: var(--dim); font-weight: 600; }
.comment .c-head .ago { color: var(--dim-2); font-size: 11.5px; }
.comment .c-head .pin { font-size: 10.5px; color: #ffd479; border: 1px solid rgba(255, 212, 121, .4); border-radius: 999px; padding: 0 6px; }
.comment .c-text { font-size: 13.5px; margin-top: 3px; white-space: pre-wrap; word-break: break-word; }
.comment.mine .c-text { color: #dff0ff; }

.comment-box { margin: 14px 0 0; display: flex; flex-direction: column; gap: 8px; }
.comment-box textarea {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  resize: vertical;
  outline: none;
}
.comment-box textarea:focus { border-color: var(--accent); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: rgba(20, 26, 34, .95);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 99;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
