/* 背景三色随角色换（main.js 设 --c1/2/3），注册成颜色才能渐变过渡 */
@property --c1 { syntax: '<color>'; inherits: true; initial-value: #c4e6f8; }
@property --c2 { syntax: '<color>'; inherits: true; initial-value: #4f88be; }
@property --c3 { syntax: '<color>'; inherits: true; initial-value: #15284a; }

:root {
  --cream: #ece5d8;
  --cream2: #f6f2ea;
  --gold: #d3bc8e;
  --gold2: #ecd9a6;
  --ink: #495366;
  --ink2: #3b4255;
  --rw: 200px;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --ui: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #15284a; overflow: hidden; }
body { font-family: var(--ui); color: var(--cream); -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }

#app {
  display: grid; grid-template-columns: 1fr var(--rw); height: 100vh; height: 100dvh;
  background:
    linear-gradient(rgba(8,12,26,0) 70%, rgba(8,12,26,.3)),
    radial-gradient(90% 80% at var(--sx, 40%) var(--sy, 40%), var(--c1) 0%, var(--c2) 50%, var(--c3) 100%);
  transition: --c1 .8s ease, --c2 .8s ease, --c3 .8s ease;
}

/* ---------- 舞台 ---------- */
#stage { position: relative; overflow: hidden; touch-action: none; }
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#sky { pointer-events: none; z-index: 1; }
#gl { z-index: 2; cursor: grab; }
#stage.grabbing #gl { cursor: grabbing; }

.deco { position: absolute; inset: 0; pointer-events: none; }
.deco .floor { position: absolute; left: 0; right: 0; top: var(--floor, 80%); bottom: 0; }
/* 地平线：金色细线两头隐去 */
.deco .floor::before {
  content: ""; position: absolute; left: 6%; right: 6%; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(236,217,166,.55) 30%, rgba(236,217,166,.55) 70%, transparent);
}
/* 团子脚下一圈光 */
.deco .floor::after {
  content: ""; position: absolute; left: 50%; top: 0; width: min(78%, 620px); height: 70px; transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, rgba(255,255,255,.28), rgba(255,255,255,0));
}

.brand { position: absolute; left: 20px; top: 16px; z-index: 4; pointer-events: none; }
.brand .tag { display: block; font: 600 10px/1 var(--ui); letter-spacing: .32em; color: var(--gold2); opacity: .9; margin: 0 0 6px 2px; }
.brand h1 {
  margin: 0; font: 700 clamp(24px, 3.2vw, 34px)/1 var(--serif); color: var(--cream2); letter-spacing: .06em;
  text-shadow: 0 1px 2px rgba(0,0,0,.35), 0 0 18px rgba(0,0,0,.18);
}
.brand h1 em { font-style: normal; color: var(--gold2); margin-left: 2px; }
.brand .orn { display: block; position: relative; width: 150px; height: 9px; margin-top: 8px; }
.brand .orn::before { content: ""; position: absolute; left: 0; right: 0; top: 4px; height: 1px; background: linear-gradient(90deg, var(--gold2), rgba(236,217,166,0)); }
.brand .orn::after { content: ""; position: absolute; left: 2px; top: 1px; width: 7px; height: 7px; background: var(--gold2); transform: rotate(45deg); }

/* 右上角圆按钮（声音 / 手感） */
#mute, #feelBtn {
  position: absolute; top: 14px; z-index: 6; width: 42px; height: 42px; border-radius: 50%;
  border: 1.5px solid rgba(236,229,216,.7); background: rgba(30,36,54,.42); color: var(--cream2); cursor: pointer;
  display: grid; place-items: center; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  transition: background .15s, color .15s;
}
#mute { right: 14px; }
#feelBtn { right: 64px; }
#mute svg, #feelBtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#mute svg path:first-child { fill: currentColor; }
#mute .x { display: none; }
#mute.off .x { display: inline; }
#mute.off .wave { display: none; }
#feelBtn svg circle { fill: rgba(30,36,54,.9); }
#mute.open, #feelBtn.on { background: var(--cream); color: var(--ink); border-color: var(--gold); }
#feelBtn.on svg circle { fill: var(--cream); }

/* 名牌：元素图标 + 名字 / 称号 / 命之座 */
#nameplate {
  position: absolute; z-index: 4; left: 50%; top: calc(var(--floor, 80%) + 12px); transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 5px; pointer-events: none; white-space: nowrap;
}
#nameplate.in { animation: npIn .5s cubic-bezier(.2,.8,.3,1); }
@keyframes npIn { from { opacity: 0; transform: translate(-50%, 8px); } }
.np-main { display: flex; align-items: center; gap: 8px; }
.np-el { width: 28px; height: 28px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.np-name { font: 700 clamp(22px, 3vw, 30px)/1 var(--ui); color: var(--cream2); letter-spacing: .08em; text-shadow: 0 1px 3px rgba(0,0,0,.45); }
.np-title {
  display: flex; align-items: center; gap: 10px; font: 600 13px/1 var(--ui); color: var(--gold2); letter-spacing: .2em;
  text-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.np-title::before, .np-title::after { content: ""; width: 34px; height: 1px; background: linear-gradient(90deg, rgba(236,217,166,0), var(--gold2)); }
.np-title::after { transform: scaleX(-1); }
.np-sub { font: 500 11px/1 var(--ui); color: rgba(246,242,234,.7); letter-spacing: .12em; }

#nogl { position: absolute; inset: 0; display: grid; place-items: center; z-index: 9; font-weight: 700; }
#nogl[hidden], [hidden] { display: none !important; }

/* ---------- 面板（手感 / 声音）：原神那种米色弹窗 ---------- */
.fpanel {
  position: absolute; right: 14px; top: 66px; z-index: 6; width: min(300px, calc(100% - 28px));
  background: var(--cream); border-radius: 12px; padding: 12px 14px 14px;
  box-shadow: inset 0 0 0 4px var(--cream), inset 0 0 0 5px #d9c9a6, 0 12px 30px rgba(0,0,0,.35);
  font: 13px/1.2 var(--ui); color: var(--ink);
}
.fpanel[hidden] { display: none; }
.fp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.fp-head b { display: flex; align-items: center; gap: 7px; font: 700 16px/1 var(--ui); color: var(--ink2); }
.fp-head b::before { content: ""; width: 7px; height: 7px; background: var(--gold); transform: rotate(45deg); }
.fp-reset { margin-left: auto; border: 0; background: none; font: 600 12px/1 var(--ui); color: var(--ink); text-decoration: underline; cursor: pointer; padding: 4px; }
.fp-close { border: 0; background: var(--ink); color: var(--cream); width: 26px; height: 26px; border-radius: 50%; font: 600 17px/1 var(--ui); cursor: pointer; }
.sp-mute { margin-left: auto; border: 0; border-radius: 999px; background: var(--ink); font: 600 12px/1 var(--ui); color: var(--cream); padding: 7px 12px; cursor: pointer; }
.sp-mute.on { background: #c96b4c; }
#soundPanel.muted .fp-row { opacity: .4; }
.fp-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 6px; }
.fp-presets button {
  border: 1px solid #d3c3a1; border-radius: 999px; background: var(--cream2); font: 600 13px/1 var(--ui); padding: 7px 0; cursor: pointer; color: var(--ink);
}
.fp-presets button.on { background: var(--ink); border-color: var(--ink); color: var(--cream); box-shadow: 0 0 0 2px var(--gold) inset; }
.fp-row { display: grid; grid-template-columns: 40px 1fr 28px; column-gap: 6px; align-items: center; margin-top: 8px; }
.fp-name { font-weight: 700; }
.fp-row output { font: 700 12px/1 var(--ui); color: #b0894a; text-align: right; }
.fp-row input { width: 100%; margin: 0; accent-color: #c4a062; touch-action: pan-x; }
.fp-ends { grid-column: 2; display: flex; justify-content: space-between; font-size: 10px; line-height: 1; margin-top: 1px; color: rgba(73,83,102,.6); }
.fp-ends i { font-style: normal; }

/* ---------- 换人：照战斗界面右上角的队伍栏，名字 + 圆头像 ---------- */
#roster {
  position: relative; overflow-y: auto; overflow-x: hidden; padding: 70px 14px 24px 6px;
  background: linear-gradient(90deg, rgba(10,14,28,0), rgba(10,14,28,.22));
  scrollbar-width: none;
}
#roster::-webkit-scrollbar { display: none; }
#roster ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
#roster li button {
  position: relative; width: 100%; display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  background: none; border: 0; padding: 6px 4px 6px 10px; cursor: pointer; color: var(--cream2); border-radius: 999px 0 0 999px;
  transition: background .2s;
}
#roster li button:hover { background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.1)); }
.r-name { font: 600 15px/1 var(--ui); letter-spacing: .04em; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.r-ava {
  position: relative; flex: none; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 35%, rgba(255,255,255,.35), rgba(255,255,255,.08) 70%);
  box-shadow: 0 0 0 2px rgba(236,229,216,.55), 0 3px 8px rgba(0,0,0,.25);
  transition: box-shadow .2s, transform .25s cubic-bezier(.3,1.5,.5,1);
}
.r-ava img { width: 92%; height: 92%; object-fit: contain; pointer-events: none; transform: translateY(1px); }
.r-key {
  position: absolute; right: 0; bottom: 2px; width: 17px; height: 17px; border-radius: 50%;
  background: rgba(30,36,54,.75); color: var(--cream); font: 700 10px/17px var(--ui); text-align: center;
}
#roster li.on button { background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.2)); }
#roster li.on .r-name { color: var(--gold2); }
#roster li.on .r-ava { box-shadow: 0 0 0 2.5px var(--gold2), 0 0 14px var(--glow, #fff); transform: scale(1.06); }
#roster li.on .r-key { background: var(--gold); color: var(--ink2); }

/* 竖屏手机：右侧收窄，只放头像 + 小名字 */
@media (max-width: 720px) {
  :root { --rw: 80px; }
  #roster { padding: 66px 6px 20px 4px; }
  #roster li button { flex-direction: column-reverse; gap: 4px; padding: 5px 2px; border-radius: 12px; }
  .r-name { font-size: 10px; letter-spacing: 0; }
  .r-ava { width: 52px; height: 52px; }
  .r-key { display: none; }
  .brand { left: 14px; top: 12px; }
  .brand .orn { width: 110px; }
}

/* ---------- 加载 / 关于 ---------- */
#loading { position: absolute; inset: 0; display: grid; place-items: center; z-index: 5; pointer-events: none; font: 600 15px/1 var(--ui); color: var(--cream2); }
body.ready #loading { display: none; }
#aboutBtn {
  display: block; margin: 16px 0 0 auto; border: 0; background: none; color: rgba(246,242,234,.65); font: 600 12px/1 var(--ui);
  text-decoration: underline; cursor: pointer; padding: 6px 12px;
}
#about { position: fixed; inset: 0; z-index: 20; background: rgba(10,14,28,.55); display: grid; place-items: center; padding: 20px; }
#about[hidden] { display: none; }
.about-card {
  width: min(380px, 100%); background: var(--cream); border-radius: 14px; padding: 20px 22px 16px;
  box-shadow: inset 0 0 0 5px var(--cream), inset 0 0 0 6px #d9c9a6, 0 16px 40px rgba(0,0,0,.4);
  font: 14px/1.6 var(--ui); color: var(--ink);
}
.about-card h2 { margin: 0 0 10px; font: 700 24px/1 var(--serif); color: var(--ink2); }
.about-card h2 em { font-style: normal; color: #b0894a; }
.about-card p { margin: 0 0 10px; }
.about-card .small { font-size: 12px; color: rgba(73,83,102,.75); }
.about-close { display: block; margin-left: auto; border: 0; border-radius: 999px; background: var(--ink); color: var(--cream); font: 600 13px/1 var(--ui); padding: 9px 18px; cursor: pointer; }
