:root {
  --bg: #1d0b0f;
  --bg2: #270f14;
  --panel: #2d1218;
  --panel2: #39171e;
  --line: #52242b;
  --text: #f8eee9;
  --muted: #c49da1;
  --gold: #e0443c;
  --gold2: #ff6b5e;
  --red: #ff4d42;
  --green: #3ecf8e;
  --blue: #e07a6f;
  --shadow: 0 12px 40px rgba(22,2,4,.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}
h1,h2,h3 { margin: 0; line-height: 1.3; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 14px; color: var(--text);
  background: #0f141c; border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; outline: none; width: 100%; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
input[readonly] { opacity: .75; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }

.primary, .secondary, .ghost, .danger {
  border: none; border-radius: 8px; padding: 10px 16px; font-size: 14px; font-weight: 600;
  transition: transform .08s, filter .15s, background .15s;
}
.primary { background: linear-gradient(135deg, var(--gold), var(--gold2)); color: #ffffff; }
.primary:hover { filter: brightness(1.08); }
.secondary { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
.secondary:hover { border-color: var(--gold); }
.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.ghost:hover { color: var(--text); border-color: var(--muted); }
.danger { background: rgba(229,72,77,.12); color: var(--red); border: 1px solid rgba(229,72,77,.4); }
.danger:hover { background: rgba(229,72,77,.22); }
.primary:disabled, .secondary:disabled, .ghost:disabled { opacity: .5; cursor: not-allowed; }
.block { width: 100%; }
.full { width: 100%; }
.small { padding: 6px 10px; font-size: 12px; }

/* 登录 */
.auth-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px; box-shadow: var(--shadow); }
.brand-lockup { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.brand-lockup h1 { font-size: 22px; }
.brand-lockup p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 12px; flex: 0 0 48px;
  background: linear-gradient(135deg, var(--gold), #7a1712); color: #ffffff;
  display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 800;
}
.auth-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.auth-tabs button { flex: 1; background: transparent; border: 1px solid var(--line); color: var(--muted); padding: 9px; border-radius: 8px; font-size: 14px; }
.auth-tabs button.active { color: #ffffff; background: linear-gradient(135deg, var(--gold), var(--gold2)); border-color: transparent; font-weight: 700; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-msg { min-height: 18px; margin: 6px 0 0; color: var(--red); font-size: 13px; text-align: center; }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 18px 0; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-hint { margin: 16px 0 0; color: var(--muted); font-size: 12px; }
.auth-hint code { color: var(--gold2); }

/* 主应用 */
.app { max-width: 1120px; margin: 0 auto; padding: 0 18px 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 0; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; flex: 0 0 40px; background: linear-gradient(135deg, var(--gold), #7a1712); color: #ffffff; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800; }
.brand strong { font-size: 16px; }
.brand small { display: block; color: var(--muted); font-size: 11px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.top-user { color: var(--muted); font-size: 13px; }

.view { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.section-heading { margin: 18px 0 16px; }
.section-heading h2 { font-size: 22px; }
.section-heading p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.section-heading.split { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.eyebrow { letter-spacing: .18em; color: var(--gold); font-size: 11px; font-weight: 700; text-transform: uppercase; margin: 0; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.panel + .panel { margin-top: 16px; }
/* 并排网格中的相邻卡片取消上边距，避免顶部/标题错位 */
.home-grid > .panel + .panel,
.grid-two > .panel + .panel,
.scan-layout > .panel + .panel { margin-top: 0; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-title h3 { font-size: 16px; }
.pill { font-size: 11px; padding: 3px 10px; border-radius: 20px; background: rgba(224,68,60,.12); color: var(--gold2); border: 1px solid rgba(224,68,60,.3); }

.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* 同盟列表 */
.alliance-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.alliance-card { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 16px; cursor: pointer; transition: border-color .15s, transform .1s; }
.alliance-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.alliance-card h4 { margin: 0 0 6px; font-size: 16px; }
.alliance-card .meta { color: var(--muted); font-size: 12px; }
.alliance-card .role { float: right; font-size: 11px; color: var(--gold2); }

/* 同盟头 */
.alliance-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 18px 0 14px; }
.alliance-head h2 { font-size: 24px; }
.alliance-head-actions { display: flex; align-items: center; gap: 8px; }

/* 标签页 */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs button { background: transparent; border: none; color: var(--muted); padding: 10px 16px; font-size: 14px; border-bottom: 2px solid transparent; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--gold2); border-bottom-color: var(--gold); font-weight: 700; }
.tab-view { display: none; }
.tab-view.active { display: block; animation: fade .2s ease; }

/* 指标 */
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { display: block; font-size: 28px; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.metric small { color: var(--muted); font-size: 11px; }
.metric.accent { border-color: rgba(224,68,60,.4); background: linear-gradient(160deg, rgba(224,68,60,.1), var(--panel)); }

/* 排行 */
.ranking { display: flex; flex-direction: column; gap: 8px; }
.rank-row { display: flex; align-items: center; gap: 12px; }
.rank-number { width: 28px; height: 28px; border-radius: 8px; background: var(--panel2); display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--muted); flex: 0 0 28px; }
.rank-number.top { background: linear-gradient(135deg, var(--gold), var(--gold2)); color: #ffffff; font-weight: 700; }
.rank-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-val { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--gold2); }

/* 上传识别 */
.scan-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.uploader { display: flex; flex-direction: column; gap: 12px; }
.drop-zone { border: 2px dashed var(--line); border-radius: 14px; padding: 30px 20px; text-align: center; transition: border-color .15s; }
.drop-zone:hover { border-color: var(--gold); }
.upload-icon { font-size: 34px; color: var(--gold); }
.drop-zone h3 { margin: 8px 0 4px; }
.drop-zone p { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.preview { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.ocr-status { color: var(--muted); font-size: 13px; }
.ocr-text-note { color: var(--muted); font-size: 12px; margin: -6px 0 12px; }

/* 表格 */
.table-panel { padding-bottom: 12px; }
.table-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.table-tools input, .table-tools select { width: auto; min-width: 160px; }
.change-tools input { min-width: 180px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 12px; font-weight: 600; cursor: default; }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--gold2); }
th.sort-asc::after { content: " ↑"; color: var(--gold2); }
th.sort-desc::after { content: " ↓"; color: var(--gold2); }
td.num { font-variant-numeric: tabular-nums; }
.delta-up { color: var(--green); font-weight: 700; font-variant-numeric: tabular-nums; }
.delta-down { color: var(--red); font-weight: 700; font-variant-numeric: tabular-nums; }
.delta-zero { color: var(--muted); font-variant-numeric: tabular-nums; }
.link-button { background: none; border: none; color: var(--blue); font-size: 13px; padding: 0 4px; }
.link-button.danger { color: var(--red); }
.table-name { font-weight: 600; }
.table-foot { padding: 10px 2px 0; color: var(--muted); font-size: 12px; }

/* 变化值对比 */
.compare-select { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.compare-select label { min-width: 200px; }
.compare-select .muted { padding-bottom: 12px; }
.compare-result { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.compare-card { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 16px; text-align: center; }
.compare-card span { display: block; color: var(--muted); font-size: 13px; }
.compare-card strong { display: block; font-size: 24px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.compare-card .time { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* 成员管理 */
.member-manage { display: flex; flex-direction: column; gap: 8px; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--panel2); border-radius: 8px; }
.member-row .name { flex: 1; }
.member-row select { width: auto; }

.danger-panel { border-color: rgba(229,72,77,.35); }
.danger-panel .danger { margin-right: 10px; }

.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px); background: #0b0e14; color: var(--text); border: 1px solid var(--gold); border-radius: 10px; padding: 10px 18px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 99; font-size: 14px; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 860px) {
  .home-grid, .grid-two, .scan-layout { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .compare-result { grid-template-columns: 1fr; }
}
/* 弹窗 */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.62); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.modal-card h3 { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.modal-actions .primary, .modal-actions .ghost { width: auto; }

/* 图表 */
.chart-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chart-controls select { width: auto; min-width: 90px; }
.chart-wrap { position: relative; height: 320px; margin-top: 8px; }
.chart-wrap .muted { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }

/* ===== 红黑战争主题 · 动态背景 ===== */
.bg-scene { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-grid {
  position: absolute; inset: -25%;
  background-image:
    linear-gradient(rgba(255,77,66,.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,77,66,.055) 1px, transparent 1px);
  background-size: 54px 54px;
  transform: perspective(600px) rotateX(58deg) translateY(16%);
  animation: gridDrift 26s linear infinite;
  -webkit-mask-image: radial-gradient(ellipse at center, rgba(0,0,0,.85), transparent 74%);
  mask-image: radial-gradient(ellipse at center, rgba(0,0,0,.85), transparent 74%);
}
@keyframes gridDrift { from { background-position: 0 0; } to { background-position: 0 54px; } }

.bg-glow { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .55; animation: glowPulse 9s ease-in-out infinite; }
.glow-a { width: 62vw; height: 62vw; left: -18vw; top: -22vw; background: radial-gradient(circle, rgba(190,30,22,.5), transparent 65%); }
.glow-b { width: 56vw; height: 56vw; right: -16vw; bottom: -20vw; background: radial-gradient(circle, rgba(128,14,16,.5), transparent 65%); animation-delay: -4.5s; }
@keyframes glowPulse { 0%, 100% { opacity: .35; transform: scale(1); } 50% { opacity: .65; transform: scale(1.08); } }

.ember {
  position: absolute; bottom: -12px; border-radius: 50%;
  background: radial-gradient(circle, #ff8a70, #e0443c 55%, rgba(224,68,60,0) 75%);
  box-shadow: 0 0 10px 2px rgba(255,77,66,.5);
  animation-name: rise; animation-timing-function: linear; animation-iteration-count: infinite;
}
@keyframes rise {
  0% { transform: translateY(0) translateX(0) scale(1); opacity: 0; }
  8% { opacity: .9; }
  100% { transform: translateY(-112vh) translateX(36px) scale(.35); opacity: 0; }
}

/* 红黑主题细节强化 */
.brand-mark { animation: brandPulse 3s ease-in-out infinite; }
@keyframes brandPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(224,68,60,.45); } 50% { box-shadow: 0 0 18px 5px rgba(224,68,60,.3); } }
.topbar { position: relative; }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: linear-gradient(90deg, transparent, rgba(224,68,60,.85), transparent); }
.panel { transition: border-color .2s, box-shadow .2s; }
.panel:hover { border-color: rgba(224,68,60,.4); box-shadow: 0 8px 30px rgba(120,12,14,.16); }
.pill { animation: pillGlow 2.4s ease-in-out infinite; }
@keyframes pillGlow { 0%, 100% { box-shadow: 0 0 0 0 rgba(224,68,60,0); } 50% { box-shadow: 0 0 10px 1px rgba(224,68,60,.35); } }
.metric.accent { border-color: rgba(224,68,60,.45); }
.alliance-card { transition: border-color .15s, transform .1s, box-shadow .15s; }
.alliance-card:hover { border-color: #e0443c; transform: translateY(-2px); box-shadow: 0 10px 28px rgba(120,12,14,.25); }

.video-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.video-tools label.inline { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.video-tools input[type="number"] { width: 72px; }



/* ===== 电影感主界面：两侧武将 + 底部场景 ===== */
.scene-bottom { position: fixed; left: 0; right: 0; bottom: 0; height: 30vh; z-index: 0; pointer-events: none; }
.scene-svg { width: 100%; height: 100%; display: block; }
.scene-mist { position: fixed; left: -8%; right: -8%; bottom: 18vh; height: 20vh; z-index: 0; pointer-events: none; background: radial-gradient(ellipse at 32% 100%, rgba(224,68,60,.12), transparent 62%); filter: blur(28px); animation: mistDrift 18s ease-in-out infinite; }
@keyframes mistDrift { 0%, 100% { transform: translateX(0); opacity: .8; } 50% { transform: translateX(4%); opacity: 1; } }

.hero-general { position: fixed; top: 12vh; bottom: auto; width: min(18vw, 260px); height: 46vh; z-index: 0; pointer-events: none; filter: drop-shadow(0 0 30px rgba(224,68,60,.32)); animation: generalFloat 8s ease-in-out infinite; }
.general-left { left: 10px; }
.general-right { right: 10px; animation-delay: -4s; }
.general-svg { width: 100%; height: 100%; display: block; }
.general-glyph { position: absolute; left: -20%; right: -20%; top: 0; height: 46%; display: flex; align-items: center; justify-content: center; font-size: min(20vw, 260px); font-weight: 800; color: rgba(224,68,60,.10); font-family: "STKaiti","KaiTi","SimSun",serif; z-index: -1; }
@keyframes generalFloat { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-16px) rotate(-1.4deg); } }

.banner { transform-box: fill-box; transform-origin: 0% 100%; animation: bannerWave 5s ease-in-out infinite; }
.banner2 { animation-delay: -2.4s; }
@keyframes bannerWave { 0%, 100% { transform: skewY(0deg); } 50% { transform: skewY(3.2deg); } }

/* 首页：创建/加入同盟卡片统一尺寸并对齐 */
.home-grid { align-items: stretch; }
.home-grid > .panel { display: flex; flex-direction: column; }
.home-grid .home-form { display: flex; flex-direction: column; flex: 1; }
.home-grid .home-form .form-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.home-grid .home-form .form-footer { margin-top: auto; }

@media (max-width: 1480px) { .hero-general { display: none; } }
@media (max-width: 900px) { .scene-bottom { height: 20vh; } }


/* 首页名称与简介（无按钮） */
.hero { position: relative; margin: 4px 0 18px; padding: 36px 26px 30px; text-align: center; border-radius: 20px; border: 1px solid rgba(224,68,60,.22); background: radial-gradient(120% 170% at 50% -20%, rgba(224,68,60,.20), transparent 58%), linear-gradient(180deg, rgba(224,68,60,.08), rgba(29,11,15,0) 65%); overflow: hidden; }
.hero-inner { position: relative; z-index: 1; }
.hero h1 { font-size: clamp(28px, 4.2vw, 48px); font-weight: 800; letter-spacing: .04em; line-height: 1.12; margin: 8px 0 10px; background: linear-gradient(180deg, #ffffff, #f0c9c4); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { color: var(--muted); font-size: 14px; max-width: 640px; margin: 0 auto; }
@media (max-width: 640px) { .hero { padding: 26px 16px 22px; } .hero-sub { font-size: 13px; } }

.pill.me { background: rgba(224,68,60,.22); color: #fff; border-color: rgba(255,107,94,.5); margin-left: 6px; }


/* ===== 反馈区 ===== */
.hero-feedback { margin-top: 18px; }
.hero-feedback .ghost { border-color: rgba(224,68,60,.45); color: var(--text); padding: 10px 22px; border-radius: 30px; }
.hero-feedback .ghost:hover { border-color: var(--gold); color: var(--gold2); }
.feedback-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(12,4,6,.72); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 24px; }
.feedback-panel { width: min(680px, 100%); max-height: 86vh; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow); }
.feedback-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.feedback-head h3 { font-size: 18px; }
.feedback-list { flex: 1; overflow-y: auto; padding: 12px 20px; }
.fb-post { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid rgba(82,36,43,.55); }
.fb-avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--gold), #7a1712); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 700; flex: 0 0 38px; }
.fb-body { flex: 1; min-width: 0; }
.fb-meta { display: flex; align-items: baseline; gap: 10px; }
.fb-name { font-weight: 700; color: var(--text); }
.fb-time { color: var(--muted); font-size: 12px; }
.fb-content { margin-top: 6px; color: var(--text); word-break: break-word; }
.fb-actions { margin-top: 6px; }
.fb-actions .link-button { font-size: 12px; }
.fb-replies { margin-top: 10px; background: var(--panel2); border-radius: 10px; padding: 10px 12px; }
.fb-reply { padding: 4px 0; font-size: 13px; color: var(--text); }
.fb-reply .fb-name { color: var(--gold2); }
.fb-reply .fb-time { margin-left: 8px; }
.feedback-form { border-top: 1px solid var(--line); padding: 14px 20px; background: var(--panel2); }
.feedback-form-row { display: flex; gap: 10px; margin-bottom: 8px; }
.feedback-form-row input { flex: 1; }
.feedback-form textarea { width: 100%; resize: vertical; }
.feedback-form .primary { white-space: nowrap; }
#fbReplyHint { margin-top: 6px; }
