:root {
  --bg: #0d1015;
  --bg-2: #0a0d11;
  --panel: #151a21;
  --panel-2: #1b222b;
  --panel-3: #232b36;
  --line: #28313d;
  --line-2: #364150;
  --raised: #1c232c;
  --text: #e7eaef;
  --text-2: #b9c1cc;
  --muted: #8a95a4;
  --faint: #5f6a79;
  --atk: #4f8ff7;
  --atk-2: #8fb8ff;
  --def: #ef5b5b;
  --def-2: #ff9d8f;
  --gold: #e3b341;
  --on-gold: #1a1300;
  --skill: #f0d080;
  --ok: #3fb97a;
  --bad: #f08a7e;
  --neutral: #5a6372;
  /* 平局在图表里的填充色：与文字里的金色同一色相、降低饱和度，避免和胜负色抢眼 */
  --draw: #8a7642;
  --accent: #3a7bf0;
  --danger: #d9534f;
  /* 圆角：标签 4 / 小块 6 / 控件 8 / 块 12 / 面板 14 */
  --r-xs: 4px; --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 14px;
  --radius: var(--r-xl);
  /* 动效：统一一条缓动曲线与三档时长（反馈 / 状态 / 进出场） */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);
  --t-fast: 120ms; --t-base: 200ms; --t-slow: 340ms;
  --shadow-pop: 0 18px 50px rgba(0, 0, 0, .5);
  --ph: linear-gradient(160deg, #1f2733, #11151b);
  --tap: 34px;
  --top-h: 56px;
  --seal: #b23a2f;
  --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --c-han: #b8913a; --c-wei: #3f7fd0; --c-shu: #3c9d62; --c-wu: #cc4848; --c-qun: #8a5cc6; --c-jin: #2fa3b2;
  font-family: "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
button { touch-action: manipulation; }
input, select { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 4px 7px; min-width: 0; transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease); }
input:focus, select:focus { border-color: var(--accent); outline: none; }
input[type=number] { -moz-appearance: textfield; font-variant-numeric: tabular-nums; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
mark { background: rgba(227, 179, 65, .3); color: inherit; border-radius: 2px; padding: 0 1px; }
[hidden] { display: none !important; }
::selection { background: rgba(58, 123, 240, .35); }
/* 深色细滚动条，和面板融为一体 */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ───────── 动效原语：进场一律“淡入 + 轻微上浮”，退场反向；系统要求减少动态时全部关闭 */
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes settle { from { opacity: 0; transform: translateY(4px); } }
@keyframes hold { from { visibility: visible; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes sink { to { opacity: 0; transform: translateY(8px); } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.985); } }
@keyframes pop-out { to { opacity: 0; transform: translateY(6px) scale(.985); } }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
@keyframes sheet-out { to { transform: translateY(24px); opacity: 0; } }
@keyframes shimmer { to { background-position: -150% 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::backdrop { transition-duration: 0s !important; animation-duration: 0s !important; animation-delay: 0s !important; scroll-behavior: auto !important; }
}

.btn { cursor: pointer; border: 1px solid var(--line-2); background: var(--panel-2); border-radius: var(--r-md); padding: 6px 12px; min-height: var(--tap); display: inline-flex; align-items: center; justify-content: center; gap: 6px; user-select: none; }
/* 可点元素统一反馈：悬停变色、按下轻压 */
.btn { transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease); }
.btn:hover { background: var(--panel-3); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.square { width: var(--tap); padding: 0; }
.btn.primary { background: linear-gradient(135deg, #3f82f4, #2a57bb); border-color: #3f82f4; color: #fff; }
.btn.primary:hover { background: linear-gradient(135deg, #4d8df7, #3262c9); }
.btn.danger { background: transparent; border-color: var(--danger); color: #ff8a86; }

/* ───────── 顶栏 */
.top { position: sticky; top: 0; z-index: 20; height: var(--top-h); display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left)); background: rgba(13, 16, 21, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.crumbs { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-width: 0; border-radius: var(--r-md); }
.brand-name { font-size: 16px; font-weight: 600; letter-spacing: 2px; white-space: nowrap; }
.crumbs .sep { color: var(--faint); font-size: 15px; }
.crumbs .here { font-size: 16px; font-weight: 600; letter-spacing: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs .brand .brand-name { color: var(--muted); font-weight: 500; transition: color var(--t-fast) var(--ease); }
.crumbs .brand:hover .brand-name { color: var(--text); }
.top-actions { display: flex; gap: 6px; }

/* 印章：朱砂底，宋体字 */
.seal { --size: 28px; width: var(--size); height: var(--size); flex: none; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--seal); color: #f7efe3; font-family: var(--serif); font-weight: 700; font-size: calc(var(--size) * .58); line-height: 1; box-shadow: inset 0 0 0 1.5px rgba(255, 240, 220, .28); }
.seal.lg { --size: 44px; border-radius: 9px; }

@media (max-width: 1080px) { :root { --tap: 40px; } }
@media (max-width: 560px) {
  :root { --top-h: 54px; }
  .top { padding: 0 12px; }
  .crumbs .brand .brand-name, .crumbs .sep { display: none; }
}

/* ───────── 提示 */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; background: var(--raised); border: 1px solid var(--line-2); border-radius: var(--r-lg); padding: 10px 14px; box-shadow: var(--shadow-pop); animation: pop var(--t-base) var(--ease) both; font-size: 13px; }
.toast.leaving { animation: pop-out var(--t-base) var(--ease-in) both; }
.toast.err { border-color: rgba(217, 83, 79, .6); }
.toast span { flex: 1; min-width: 0; word-break: break-all; }
.toast .btn { min-height: 28px; padding: 0 10px; font-size: 12px; }

/* ───────── 欢迎卡片（盟友提示） */
.welcome { position: fixed; right: 20px; bottom: var(--welcome-bottom, 20px); z-index: 60; width: min(372px, calc(100vw - 24px)); display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; padding: 16px 16px 14px; background: var(--raised); border: 1px solid var(--line-2); border-radius: var(--r-xl); box-shadow: var(--shadow-pop); animation: rise var(--t-slow) var(--ease) both; }
.welcome::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--seal); }
.welcome .seal { --size: 40px; writing-mode: vertical-rl; font-size: 15px; letter-spacing: 1px; height: 52px; }
.welcome h2 { margin: 1px 0 6px; font-size: 15px; font-weight: 600; }
.welcome p { margin: 0 0 6px; font-size: 13px; color: var(--text-2); line-height: 1.65; text-wrap: pretty; }
.welcome p b { color: var(--text); font-weight: 600; white-space: nowrap; }
.welcome .actions { display: flex; gap: 8px; margin-top: 10px; }
.welcome .actions .btn { min-height: 32px; font-size: 13px; padding: 0 14px; }
.welcome .btn.seal-btn { background: var(--seal); border-color: var(--seal); color: #fff3e6; }
.welcome .btn.seal-btn:hover { background: #c4443a; }
.welcome .close { position: absolute; top: 8px; right: 8px; width: 28px; min-height: 28px; padding: 0; border: 0; background: transparent; color: var(--faint); font-size: 14px; }
.welcome .close:hover { color: var(--text); background: transparent; }
.welcome.leaving { animation: sink var(--t-base) var(--ease-in) both; }
.welcome .welcome-text.reply { animation: settle var(--t-base) var(--ease); }
@media (max-width: 560px) {
  .welcome { right: 12px; left: 12px; width: auto; }
}

/* ───────── 滑块：统一样式；触屏上把手更大 */
input[type=range] { --thumb: 18px; -webkit-appearance: none; appearance: none; width: 100%; height: calc(var(--thumb) + 6px); padding: 0; margin: 0; border: 0; border-radius: 0; background: transparent; cursor: pointer; touch-action: pan-y; }
input[type=range]:disabled { cursor: not-allowed; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--line-2); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line-2); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: var(--thumb); height: var(--thumb); margin-top: calc((4px - var(--thumb)) / 2); border-radius: 50%; background: var(--text); border: 3px solid var(--accent); box-shadow: 0 2px 8px rgba(0, 0, 0, .45); transition: transform var(--t-fast) var(--ease); }
input[type=range]::-moz-range-thumb { width: var(--thumb); height: var(--thumb); box-sizing: border-box; border-radius: 50%; background: var(--text); border: 3px solid var(--accent); box-shadow: 0 2px 8px rgba(0, 0, 0, .45); }
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.12); }
input[type=range]:focus-visible { outline: none; }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(58, 123, 240, .35); }
input[type=range]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px rgba(58, 123, 240, .35); }
@media (pointer: coarse) { input[type=range] { --thumb: 26px; } }

/* ───────── 悬浮说明（ui.js initTips）：任何 data-tip 元素共用一个浮层 */
.tip { position: fixed; left: 0; top: 0; z-index: 80; max-width: min(300px, calc(100vw - 16px)); padding: 8px 11px; border-radius: var(--r-md); background: var(--raised); border: 1px solid var(--line-2); box-shadow: var(--shadow-pop); color: var(--text-2); font-size: 12.5px; line-height: 1.65; text-wrap: pretty; pointer-events: none; opacity: 0; transition: opacity var(--t-fast) var(--ease); }
.tip.on { opacity: 1; }
