/* ── 全局重置 ─────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0f1117;
  --bg-card: #1a1d28;
  --bg-hover: #242738;
  --text: #e4e6f0;
  --text-muted: #8b8fa3;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --secondary: #374151;
  --border: #2a2d3a;
  --accent-gold: #f59e0b;
  --accent-green: #22c55e;
  --accent-blue: #3b82f6;
  --accent-purple: #a855f7;
  --accent-red: #ef4444;
  --radius: 8px;
  --radius-lg: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ── 布局 ─────────────────────────────────── */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 20px;
}

.header {
  text-align: center;
  padding: 30px 0 20px;
}
.header.has-bg {
  padding: 40px 0 30px;
  border-radius: var(--radius-lg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  margin-bottom: 8px;
  position: relative;
}
.header.has-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(15,17,23,0.55);
  border-radius: var(--radius-lg);
}
.header.has-bg .header-content {
  position: relative;
  z-index: 1;
}

.logo { font-size: 32px; font-weight: 700; }
.server-badge {
  display: inline-block;
  font-size: 18px;
  font-weight: 700;
  color: #f59e0b;
  background: rgba(245,158,11,0.12);
  padding: 4px 16px;
  border-radius: 8px;
  margin-top: 6px;
  border: 1px solid rgba(245,158,11,0.3);
}
.subtitle { color: var(--text-muted); margin-top: 6px; font-size: 15px; }

.back-link {
  display: inline-block;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--text-muted);
}
.back-link:hover { color: var(--primary-hover); }

.footer {
  text-align: center;
  padding: 30px 0;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
  margin-top: 30px;
}

/* ── 首页游戏卡片（含服务器） ──────────────── */
.game-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}
.game-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  border-color: var(--primary);
}
.game-card .game-card-bg {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 120px;
  background: linear-gradient(135deg, rgba(99,102,241,0.08) 0%, rgba(139,92,246,0.05) 100%);
  border-bottom: 1px solid var(--border);
}
.game-card-content {
  position: relative;
  padding: 24px;
}
.game-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.game-icon {
  width: 52px;
  height: 52px;
  background: rgba(99,102,241,0.1);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  overflow: hidden;
  border: 1px solid rgba(99,102,241,0.15);
}
.game-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.game-icon .game-icon-fallback { font-size: 28px; }
.game-name { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
.game-name-en { font-size: 13px; color: var(--text-muted); margin-top: 2px; letter-spacing: 0.3px; }

/* ── 服务器卡片 ── */
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.server-card {
  position: relative;
  display: block;
  text-decoration: none;
  border-radius: 14px;
  padding: 18px;
  overflow: hidden;
  transition: all 0.25s ease;
  cursor: pointer;
  border: 1.5px solid transparent;
}
/* 服务器主题色 */
.server-dark {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border-color: rgba(99,102,241,0.2);
}
.server-dark:hover {
  border-color: rgba(99,102,241,0.6);
  box-shadow: 0 4px 20px rgba(99,102,241,0.15);
  transform: translateY(-3px);
}
.server-vanilla {
  background: linear-gradient(135deg, #1a1a2e 0%, #2d1b3d 100%);
  border-color: rgba(245,158,11,0.2);
}
.server-vanilla:hover {
  border-color: rgba(245,158,11,0.6);
  box-shadow: 0 4px 20px rgba(245,158,11,0.12);
  transform: translateY(-3px);
}
.server-berry {
  background: linear-gradient(135deg, #1a1a2e 0%, #1e2a3d 100%);
  border-color: rgba(236,72,153,0.2);
}
.server-berry:hover {
  border-color: rgba(236,72,153,0.5);
  box-shadow: 0 4px 20px rgba(236,72,153,0.12);
  transform: translateY(-3px);
}
.server-card .server-bg {
  position: absolute;
  top: -50%; right: -50%;
  width: 100%; height: 100%;
  opacity: 0.03;
  pointer-events: none;
}
.server-content {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
}
.server-emoji {
  font-size: 30px;
  filter: none;
}
.server-name {
  font-size: 16px;
  font-weight: 700;
  color: #e2e8f0;
  letter-spacing: 0.2px;
}
.server-count {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}
.server-footer {
  position: relative;
  margin-top: 12px;
}
.server-meta {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  display: inline-block;
}
.server-warn {
  color: #f59e0b;
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.15);
}
.server-soon {
  color: var(--text-muted);
  background: rgba(255,255,255,0.04);
}
.server-card.server-disabled {
  opacity: 0.4;
  cursor: default;
  filter: grayscale(0.8);
  pointer-events: none;
}

/* ── 首页背景 ── */
.page-bg {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.03) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 50%, rgba(139,92,246,0.02) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ── 加载动画 ── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 0;
  color: var(--text-muted);
  font-size: 15px;
}
.loading-spin {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--border);
  border-top: 2.5px solid var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Logo ── */
.header-top {
  margin-bottom: 10px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 28px;
  margin: 0;
}
.logo-icon { font-size: 32px; }
.logo-text {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── 首页游戏网格 ── */
.game-grid {
  display: grid;
  gap: 24px;
}

.game-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
  display: block;
  color: var(--text);
}
.game-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.15);
  color: var(--text);
}

.game-icon { font-size: 40px; margin-bottom: 10px; }
.game-name { font-size: 18px; font-weight: 600; }
.game-name-en { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.game-count { font-size: 13px; color: var(--accent-green); margin-top: 10px; }

/* ── 筛选栏 ───────────────────────────────── */
.filter-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 12px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.filter-group label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.filter-input, .filter-select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
  min-width: 70px;
}
.filter-input:focus, .filter-select:focus {
  border-color: var(--primary);
}
.filter-input::placeholder { color: var(--text-muted); }

#accountSearch { width: 140px; }
.filter-select { min-width: 90px; cursor: pointer; }

.sep { color: var(--text-muted); padding: 0 2px; align-self: flex-end; margin-bottom: 6px; font-size: 13px; }

.filter-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
  align-items: flex-end;
}

/* ── 按钮 ─────────────────────────────────── */
.btn {
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary {
  background: var(--secondary);
  color: var(--text);
}
.btn-secondary:hover { background: #4b5563; }
.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  background: var(--secondary);
  color: var(--text);
}
.btn-sm:hover { background: #4b5563; }

/* ── 角色网格 ─────────────────────────────── */
.roles-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 10px;
}

.roles-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.roles-header h3 { font-size: 15px; font-weight: 600; }
.roles-count { font-size: 12px; color: var(--text-muted); }

.role-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 340px;
  overflow-y: auto;
  padding: 4px 0;
}
.role-grid::-webkit-scrollbar { width: 6px; }
.role-grid::-webkit-scrollbar-track { background: var(--bg); border-radius: 3px; }
.role-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.role-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  background: var(--bg);
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  white-space: nowrap;
}
.role-item:hover {
  border-color: var(--primary);
  background: var(--bg-hover);
}
.role-item.active {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
}
.role-item .role-color {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.role-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.role-avatar-sm {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  margin-right: 4px;
}
.role-item .role-avatar + .role-color { display: none; }
.role-avatar-xs {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.selected-role-tag .role-avatar-xs + .role-color { display: none; }

/* ── 搜索结果 ─────────────────────────────── */
.results-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.results-header h3 { font-size: 15px; font-weight: 600; }
.results-total { font-size: 12px; color: var(--accent-green); }

.results-actions {
  margin-bottom: 12px;
}

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

/* ── 已选角色条 ───────────────────────────── */
.selected-roles-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.selected-roles-label {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}
.selected-roles-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.selected-role-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 16px;
  font-size: 13px;
  border: 1px solid;
}
.selected-role-tag .role-color {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tag-remove {
  cursor: pointer;
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 2px;
  line-height: 1;
}
.tag-remove:hover { color: var(--accent-red); }

/* 卡片视图 */
.account-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: border-color 0.2s;
}
.account-card:hover {
  border-color: var(--primary);
}

.account-stone {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: 4px;
}
.account-level {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.account-id {
  font-size: 16px;
  color: var(--primary-hover);
  font-family: monospace;
  font-weight: 600;
  margin-bottom: 12px;
  word-break: break-all;
}
.account-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  color: var(--text);
}
.role-count-badge {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* W/M/S 计数行 */
.cookiep-row {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.cookiep-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 10px 3px 6px;
  font-size: 12px;
}
.cookiep-icon {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  object-fit: cover;
}
.cookiep-label {
  font-weight: 600;
  color: var(--text-muted);
}
.cookiep-val {
  font-weight: 700;
  color: var(--text);
  margin-left: 2px;
}

/* 列表视图 */
.results-grid.list-view {
  grid-template-columns: 1fr;
}
.list-view .account-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
}
.list-view .account-card .account-stone {
  font-size: 16px;
  min-width: 90px;
}
.list-view .account-card .account-level {
  margin-bottom: 0;
  min-width: 40px;
}
.list-view .account-card .account-roles {
  flex: 1;
}

/* 空状态 */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── 分页 ─────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.page-btn {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.page-btn:hover { border-color: var(--primary); }
.page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── 加载 & 错误 ──────────────────────────── */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}
.no-games, .error {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

/* ── 滚动条 ───────────────────────────────── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3d4050; }

/* ── 响应式 ───────────────────────────────── */
@media (max-width: 768px) {
  .filter-bar {
    flex-direction: column;
    gap: 10px;
  }
  .filter-actions {
    margin-left: 0;
    width: 100%;
  }
  .filter-actions .btn { flex: 1; }
  .results-grid { grid-template-columns: 1fr; }
  .list-view .account-card {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
}
