:root {
  --primary: #111827;
  --primary-dark: #000000;
  --primary-light: #f3f4f6;
  --gold: #f59e0b;
  --gold-dark: #b45309;
  --bg: #f6f7f8;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(17, 24, 39, 0.06), 0 4px 14px rgba(17, 24, 39, 0.05);
  --shadow-lg: 0 10px 30px rgba(17, 24, 39, 0.12);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

button { font-family: inherit; }
input { font-family: inherit; }

/* ========== 通用 ========== */
.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); }
.btn-primary:disabled { background: #d1d5db; cursor: not-allowed; }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

/* ========== 页头 ========== */
.page-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 26px 0 22px;
}
.page-header .container { position: relative; }
.page-header h1 { font-size: 23px; font-weight: 700; color: #111827; letter-spacing: 0.5px; }
.page-header .subtitle { margin-top: 5px; font-size: 14px; color: var(--text-2); }
.page-header .rule { margin-top: 10px; font-size: 12.5px; color: var(--text-3); max-width: 720px; }

/* ========== Tab 栏 ========== */
.tabbar-wrap {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.tabbar { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0; scrollbar-width: none; }
.tabbar::-webkit-scrollbar { display: none; }

.tab {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-2);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.tab:hover { border-color: var(--primary); color: var(--primary); }
.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.2);
}
.tab .idx {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  font-size: 12px;
  font-weight: 700;
}
.tab.active .idx { background: rgba(255, 255, 255, 0.25); }
.tab .done { display: none; color: #10b981; font-weight: 700; }
.tab.active .done { color: #fff; }
.tab.is-done .done { display: inline; }

/* ========== 已投票提示条 ========== */
.voted-banner {
  display: none;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 18px 0 0;
  padding: 12px 16px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 12px;
  color: #065f46;
  font-size: 14px;
}
.voted-banner.show { display: flex; }
.voted-banner .actions { margin-left: auto; display: flex; gap: 8px; }
.voted-banner .btn { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
/* 投票/打分未开启提示（琥珀色） */
.voted-banner.closed { background: #fffbeb; border-color: #fde68a; color: #92400e; }

/* ========== 卡片区 ========== */
main { padding: 22px 0 34px; }

.category-head { display: flex; align-items: baseline; gap: 12px; margin: 22px 0 14px; }
.category-head h2 { font-size: 19px; font-weight: 700; }
.category-head .picked {
  font-size: 13px;
  color: var(--text-2);
  background: var(--primary-light);
  border-radius: 999px;
  padding: 2px 12px;
}
.category-head .picked.ok { background: #ecfdf5; color: #059669; }

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

.card {
  position: relative;
  background: var(--card);
  border: 2px solid transparent;
  outline: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
  box-shadow: var(--shadow);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card.selected {
  border-color: var(--primary);
  outline-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(17, 24, 39, 0.08), var(--shadow-lg);
}

.card .shot {
  position: relative;
  height: 195px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(45deg, #f3f4f6 25%, transparent 25%, transparent 75%, #f3f4f6 75%),
    linear-gradient(45deg, #f3f4f6 25%, #fafafa 25%, #fafafa 75%, #f3f4f6 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}
.card .shot img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }

/* 查看大图按钮（左上角，悬停显示；触屏设备常显） */
.zoom-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.55);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
  z-index: 2;
}
.card:hover .zoom-btn { opacity: 1; }
.zoom-btn:hover { background: var(--primary); }
@media (hover: none) {
  .zoom-btn { opacity: 0.92; }
}

/* 大图预览弹层 */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(10, 12, 20, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 34px 20px 24px;
  cursor: zoom-out;
}
.lightbox.show { display: flex; }
.lightbox img {
  max-width: 94vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  cursor: default;
}
.lightbox-caption {
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  margin-top: 14px;
  letter-spacing: 0.5px;
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.28); }

.card .badge {
  position: absolute;
  top: 10px;
  right: 10px;
  display: none;
  align-items: center;
  gap: 4px;
  background: var(--primary);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 12px;
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.3);
}
.card.selected .badge { display: inline-flex; }

.card .body { padding: 12px 14px 13px; display: flex; align-items: center; gap: 10px; }
.card .cid { font-size: 15.5px; font-weight: 700; letter-spacing: 0.5px; }
.card .designer { font-size: 12.5px; color: var(--text-2); }
.card .ref {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}
.card .ref:hover { text-decoration: underline; }

/* ========== 底部操作栏 ========== */
.action-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 24px rgba(17, 24, 39, 0.07);
}
.action-bar .inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.progress { display: flex; align-items: center; gap: 8px; }
.progress .label { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; }
.progress .dots { display: flex; gap: 5px; }
.progress .dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #e5e7eb;
  transition: all 0.2s ease;
}
.progress .dot.on { background: #10b981; transform: scale(1.15); }

.action-bar .name-input {
  flex: 1;
  min-width: 160px;
  max-width: 320px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease;
}
.action-bar .name-input:focus { border-color: var(--primary); }
.action-bar .btn-submit { min-width: 130px; }

.action-bar .hint { font-size: 12.5px; color: var(--text-3); width: 100%; margin-top: -4px; }

.error-toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(20px);
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  font-size: 14px;
  font-weight: 500;
  border-radius: 10px;
  padding: 10px 18px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 80;
  max-width: 90vw;
}
.error-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ========== 结果弹层 ========== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(17, 24, 39, 0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.overlay.show { display: flex; }

.modal {
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  max-width: 520px;
  width: 100%;
  max-height: 86vh;
  overflow-y: auto;
  padding: 28px;
  text-align: center;
}
.modal .big-icon { font-size: 52px; line-height: 1; }
.modal h3 { font-size: 20px; margin: 12px 0 4px; }
.modal .sub { color: var(--text-2); font-size: 14px; }
.modal ul {
  list-style: none;
  text-align: left;
  margin: 18px 0 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.modal li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  font-size: 14px;
}
.modal li:nth-child(odd) { background: #fafafa; }
.modal li .k { color: var(--text-2); }
.modal li .v { font-weight: 700; }
.modal .btn { margin-top: 16px; width: 100%; }

/* ========== 后台页面 ========== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 36px 34px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.login-card .icon { font-size: 40px; }
.login-card h2 { font-size: 20px; margin: 10px 0 4px; }
.login-card p { color: var(--text-2); font-size: 13.5px; margin-bottom: 20px; }
.login-card input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 15px;
  outline: none;
  margin-bottom: 14px;
}
.login-card input:focus { border-color: var(--primary); }
.login-card .btn { width: 100%; }
.login-card .err { color: var(--danger); font-size: 13px; margin-bottom: 10px; min-height: 18px; }

.admin-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 18px 0;
}
.admin-header .row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.admin-header h1 { font-size: 20px; font-weight: 700; color: #111827; }
.admin-header .sub { font-size: 13px; color: var(--text-3); }
.admin-header .spacer { flex: 1; }
.admin-header .btn { background: #fff; color: var(--text); border: 1px solid var(--border); }
.admin-header .btn:hover { border-color: #111827; color: #111827; }

/* 后台投票开关按钮 */
.vote-switches { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.switch-btn .sw-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d1d5db;
  box-shadow: 0 0 0 3px rgba(209, 213, 219, 0.35);
  flex-shrink: 0;
}
.switch-btn:hover { border-color: var(--primary); }
.switch-btn:disabled { opacity: 0.6; cursor: wait; }
.switch-btn.on { border-color: #6ee7b7; background: #ecfdf5; color: #065f46; }
.switch-btn.on .sw-dot { background: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.22); }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin: 20px 0 22px; }
.stat {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.stat .num { font-size: 30px; font-weight: 800; color: var(--primary); line-height: 1.2; }
.stat .num small { font-size: 15px; font-weight: 600; color: var(--text-2); }
.stat .cap { font-size: 13px; color: var(--text-2); margin-top: 2px; }

.champion {
  background: linear-gradient(120deg, #fffbeb, #fef3c7);
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}
.champion .trophy { font-size: 44px; }
.champion .title { font-size: 13px; color: var(--gold-dark); font-weight: 700; letter-spacing: 2px; }
.champion .name { font-size: 24px; font-weight: 800; color: #92400e; }
.champion .score { margin-left: auto; text-align: right; }
.champion .score .n { font-size: 30px; font-weight: 800; color: var(--gold-dark); }
.champion .score .c { font-size: 12.5px; color: var(--gold-dark); }

.section { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 22px; }
.section > h2 { font-size: 17px; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.section > .desc { font-size: 13px; color: var(--text-3); margin-bottom: 16px; }

.rank-list { display: flex; flex-direction: column; gap: 12px; }
.rank-item { display: flex; align-items: center; gap: 12px; }
.rank-item .rk {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  background: #f3f4f6;
  color: var(--text-2);
  flex-shrink: 0;
}
.rank-item.r1 .rk { background: #fde68a; color: #92400e; }
.rank-item.r2 .rk { background: #e5e7eb; color: #4b5563; }
.rank-item.r3 .rk { background: #fed7aa; color: #9a3412; }
.rank-item .who { width: 120px; font-weight: 700; font-size: 15px; flex-shrink: 0; }
.rank-item .bar-wrap { flex: 1; height: 22px; background: #f3f4f6; border-radius: 999px; overflow: hidden; }
.rank-item .bar {
  height: 100%;
  border-radius: 999px;
  background: #334155;
  min-width: 2px;
  transition: width 0.5s ease;
}
.rank-item.r1 .bar { background: linear-gradient(90deg, #fbbf24, #d97706); }
.rank-item .sc { width: 60px; text-align: right; font-weight: 700; font-size: 15px; flex-shrink: 0; }
.rank-item .sc small { color: var(--text-3); font-weight: 500; }

.cat-section h3 { font-size: 15.5px; font-weight: 700; margin: 18px 0 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cat-section h3 .best { font-size: 12px; color: #92400e; background: #fef3c7; border-radius: 999px; padding: 1px 10px; font-weight: 600; }

.comp-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px 22px; }
.comp-row { display: flex; align-items: center; gap: 10px; }
.comp-row .id {
  width: 96px;
  font-weight: 700;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  display: flex;
  align-items: baseline;
  gap: 5px;
}
.comp-row .id .d { font-style: normal; font-weight: 500; font-size: 12.5px; color: var(--text-3); }
.comp-row.is-best .id .d { color: var(--gold-dark); }
.comp-row .bar-wrap { flex: 1; height: 18px; background: #f3f4f6; border-radius: 999px; overflow: hidden; }
.comp-row .bar { height: 100%; background: #64748b; border-radius: 999px; min-width: 2px; transition: width 0.5s ease; }
.comp-row.is-best .bar { background: linear-gradient(90deg, #fcd34d, #f59e0b); }
.comp-row .cnt { width: 46px; text-align: right; font-size: 13.5px; font-weight: 600; color: var(--text-2); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.comp-row.is-best .cnt { color: var(--gold-dark); font-weight: 800; }

table.votes { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.votes th, table.votes td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.votes th { color: var(--text-2); font-weight: 600; background: #fafafa; position: sticky; top: 0; }
table.votes td .cid-pill {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 700;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12.5px;
}
.table-scroll { overflow-x: auto; max-height: 480px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }
.empty { text-align: center; color: var(--text-3); padding: 30px 0; font-size: 14px; }

.loading { text-align: center; color: var(--text-3); padding: 80px 0; font-size: 15px; }

/* ========== 响应式 ========== */
@media (max-width: 640px) {
  .page-header { padding: 24px 0 46px; }
  .page-header h1 { font-size: 20px; }
  .tab { padding: 7px 13px; font-size: 13px; }
  .grid { grid-template-columns: 1fr; }
  .card .shot { height: 170px; }
  .action-bar .inner { gap: 10px; }
  .action-bar .name-input { min-width: 120px; }
  .modal { padding: 22px 18px; }
  .champion { flex-wrap: wrap; }
  .champion .score { margin-left: 0; text-align: left; width: 100%; }
  table.votes th, table.votes td { padding: 8px 9px; font-size: 12.5px; }
}
