/*
 * 彩绘西游：人物场面与清晰指令（2026-09 第二轮）
 *
 * 木刻套印继续负责世界与人物，界面退成独立的轻绢信息层。战场、美术和
 * 数值不再互相争抢：桌面端保留完整横向舞台，窄屏把敌我拆成前后两列，
 * 顶栏改为底部短导航，避免所有控件一起压进画面上沿。
 */

:root {
  --paper: #fff8ec;
  --paper-dim: #f2e3ca;
  --ink: #252a31;
  --wood: #66503c;
  --wood-deep: #30241c;
  --zhu: #b8453d;
  --zhu-hi: #d45b48;
  --gold: #bd8b43;
  --gold-hi: #e0b86d;
  --qing: #357d77;
  --zhe: #8a5a36;
  --text-hi: #fff9eb;
  --text-de: #2c2a28;
  --silk: rgba(255, 250, 240, .91);
  --silk-strong: rgba(255, 252, 246, .975);
  --line: rgba(82, 69, 57, .22);
  --soft-shadow: 0 18px 48px rgba(37, 29, 24, .2);
}

html,
body {
  background: #e9dfcf;
  color: var(--ink);
}

button:focus-visible {
  outline: 3px solid rgba(205, 76, 64, .62);
  outline-offset: 2px;
}

.btn {
  border: 1px solid rgba(91, 68, 52, .36);
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(255, 253, 247, .98), rgba(244, 231, 207, .96));
  box-shadow: 0 7px 18px rgba(54, 39, 29, .11), inset 0 1px rgba(255, 255, 255, .86);
}

.btn:hover {
  filter: brightness(1.025);
  border-color: rgba(184, 69, 61, .58);
  box-shadow: 0 10px 25px rgba(54, 39, 29, .15), inset 0 1px #fff;
}

.icon-badge {
  color: #fffaf0;
  border-color: rgba(255, 255, 255, .52);
  background: linear-gradient(145deg, #c85b48, #9e3735);
  box-shadow: 0 5px 12px rgba(100, 45, 38, .22);
}

.wood-frame,
.modal-panel,
.ending-panel {
  border: 1px solid rgba(82, 69, 57, .28);
  border-radius: 16px;
  background: linear-gradient(145deg, var(--silk-strong), rgba(240, 225, 201, .95));
  box-shadow: var(--soft-shadow), inset 0 1px rgba(255, 255, 255, .8);
  backdrop-filter: blur(14px) saturate(.9);
}

/* 顶栏是一条轻绢导航，不再是一根压住画面的黑木梁。 */
.topbar {
  z-index: 55;
  height: 52px;
  gap: 8px;
  padding: 0 22px;
  border: 0;
  border-bottom: 1px solid rgba(113, 82, 57, .2);
  background: linear-gradient(90deg, rgba(255, 252, 244, .98), rgba(238, 244, 241, .96) 58%, rgba(255, 241, 232, .97));
  box-shadow: 0 9px 28px rgba(54, 42, 33, .13);
}

.topbar::before,
.topbar::after { display: none; }

.topbar-title {
  color: #3b3c3b;
  text-shadow: none;
  font-size: 16px;
  letter-spacing: 4px;
}

.topbar-sep { background: rgba(111, 85, 65, .18); }

.topbar-btn {
  min-height: 34px;
  color: #414244;
  text-shadow: none;
  border: 1px solid rgba(83, 77, 70, .18);
  border-radius: 2px;
  background: transparent;
  box-shadow: none;
}

.topbar-btn:hover,
.topbar-btn.open {
  color: #a83d3b;
  border-color: rgba(184, 69, 61, .42);
  background: rgba(255, 250, 242, .96);
}

.topbar-dropdown {
  top: 42px;
  border: 1px solid rgba(91, 68, 52, .28);
  border-radius: 12px;
  background: rgba(255, 250, 239, .98);
  box-shadow: var(--soft-shadow);
}

.topbar-dropdown .topbar-btn { color: #414244; }
.screen { inset: 52px 0 0; }
.overworld-root,
.treasure-root,
.battle-root,
.ending-root,
.story-bg { inset: 52px 0 0; }

/* 满幅山火中的行旅，不再把封面截成左右两张卡。 */
.title-screen { align-items: flex-start; justify-content: center; padding: 6vh 8vw; background: #f9e3b5; }
.title-cover { inset: 0; background-position: center; filter: none; }
.title-mask { background: linear-gradient(90deg, #fff3dce8, #fff3dcba 26%, #f8e5c333 52%, transparent 76%), linear-gradient(0deg, #193e3d99, transparent 35%); }
.title-logo { position: relative; margin: 0; text-align: left; align-self: flex-start; }
.title-kicker { color: #8f392b; font-size: 13px; letter-spacing: 5px; margin-bottom: 26px; }
.title-logo h1 { color: #163f39; font-size: clamp(80px, 9vw, 140px); line-height: 1.02; letter-spacing: .04em; white-space: normal; text-shadow: 0 2px #fff8e0; font-weight: 700; }
.title-line { display: block; }
.title-seal { display: block; margin-top: 22px; width: max-content; background: #b13b26; color: #fff5dd; border: 3px double #f5c786; padding: 8px 14px; font-size: 16px; letter-spacing: 8px; transform: rotate(-4deg); }
.title-logo p { max-width: 350px; margin-top: 20px; color: #35534a; font-size: 15px; line-height: 1.8; letter-spacing: 1px; text-shadow: none; }
.title-menu { align-self: flex-start; width: 300px; margin-top: 30px; gap: 8px; }
.title-btn { width: 100%; min-height: 48px; padding: 10px 20px; text-align: left; border: 0; border-bottom: 1px solid #5e746466; border-radius: 0; color: #1c423a; font-size: 17px; letter-spacing: 3px; background: #fff8e8dc; box-shadow: none; }
.title-btn:first-child { background: #ae3e29; color: #fff9e9; }
.title-btn::after { content: '→'; float: right; letter-spacing: 0; }
.title-btn:hover { background: #fff8e8; box-shadow: none; }
.title-btn:first-child:hover { background: #8c321f; }
.title-hero { position: absolute; right: 0; bottom: -13%; width: 59%; height: 113%; object-fit: contain; object-position: bottom; pointer-events: none; filter: drop-shadow(8px 18px 8px #4e371939); }
.title-inscription { position: absolute; right: 4%; top: 8%; writing-mode: vertical-rl; color: #fff6df; background: #173e39e8; padding: 20px 12px; font-size: 14px; letter-spacing: 6px; line-height: 1.7; }

/* 地图提示和剧情对白拥有自己的可读层，不再直接压暗整幅画。 */
.overworld-tip,
.overworld-loc,
.round-tag,
.field-rule {
  color: #393735;
  text-shadow: none;
  border: 1px solid rgba(88, 67, 52, .24);
  background: rgba(255, 250, 239, .9);
  box-shadow: 0 7px 20px rgba(42, 31, 24, .14);
  backdrop-filter: blur(10px);
}

.overworld-tip { top: 14px; max-width: min(720px, calc(100% - 32px)); }
.overworld-loc { bottom: 18px; }

/* 对话人物与文字各占一个景别，旁白不占用空头像。 */
.dlg-stage { position: absolute; inset: 0; z-index: 49; pointer-events: none; background: linear-gradient(0deg, #173d3566, transparent 60%); overflow: hidden; }
.dlg-stage[hidden] { display: none; }
.dlg-portrait { position: absolute; left: 0; bottom: -28%; width: 45%; height: 120%; object-fit: contain; object-position: center bottom; border: 0; border-radius: 0; background: none; box-shadow: none; filter: drop-shadow(5px 6px 4px #142e3133); }
.dlg-box { left: 40%; bottom: 10%; width: 52%; min-height: 190px; padding: 28px 36px 24px; transform: none; border: 0; border-top: 3px solid #be4b30; border-radius: 0; background: #fff9eef5; box-shadow: 0 15px 60px #173d3550; backdrop-filter: blur(12px); z-index: 50; }
.dlg-box.narration { left: 20%; width: 60%; bottom: 12%; min-height: 140px; }
.dlg-right { width: 100%; }
.dlg-name { color: #a53925; text-shadow: none; border: 0; background: none; padding: 0 0 14px; font-size: 25px; font-weight: 600; letter-spacing: 4px; }
.dlg-text { color: #263f37; font-size: 20px; line-height: 1.9; max-height: 30vh; overflow: auto; }
.dlg-next { color: #756b57; font-size: 11px; letter-spacing: 1px; padding-top: 18px; }

/* 战斗画面先读舞台，再读界面。 */
.battle-field {
  border: 0;
  background-position: center bottom;
}

.battle-field::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 247, 231, .06), transparent 30%),
    linear-gradient(0deg, rgba(33, 27, 23, .17), transparent 34%);
}

.order-bar {
  top: 12px;
  left: 18px;
  right: auto;
  max-width: calc(100% - 300px);
  min-height: 42px;
  padding: 5px 10px;
  border: 1px solid rgba(82, 69, 57, .22);
  border-radius: 12px;
  background: rgba(255, 250, 239, .9);
  box-shadow: 0 8px 22px rgba(44, 34, 28, .14);
  backdrop-filter: blur(10px);
}

.order-label { color: #8f3c38; text-shadow: none; }
.order-chips { overflow-x: auto; scrollbar-width: none; }
.order-chips::before { background: linear-gradient(90deg, rgba(184, 69, 61, .52), rgba(189, 139, 67, .18)); }
.order-chip {
  flex: none;
  border-color: rgba(92, 74, 59, .2);
  background: rgba(255, 253, 247, .9);
}
.order-chip img { background: rgba(215, 201, 181, .52); border-color: rgba(92, 74, 59, .2); }
.order-chip-name { color: #3d3c3a; text-shadow: none; }
.order-chip-spd { color: #837568; }

.round-tag { top: 12px; right: 16px; }
.formation-btn { top: 55px; right: 16px; }
.field-rule {
  top: 94px;
  right: 16px;
  max-width: 260px;
  color: #9e4037;
}

.unit-card { width: 168px; z-index: 4; }
.unit-card.party[data-portrait="wukong"] .unit-portrait { transform: none; }
/* 悟空立绘本就朝左、不镜像,呼吸帧不能套 breatheFlip,否则插值过 scaleX(0) 被压成一道虚影 */
.unit-card.party[data-portrait="wukong"].commanding .unit-portrait { animation-name: breathe; }
.unit-portrait {
  width: 218px;
  height: 326px;
  filter: drop-shadow(0 9px 8px rgba(31, 24, 20, .35));
}
.unit-card.big { width: 246px; }
.unit-card.big .unit-portrait { width: 310px; height: 390px; }
.unit-shadow { bottom: 70px; width: 88px; opacity: .72; }
.unit-card.big .unit-shadow { width: 156px; bottom: 70px; }

.unit-name {
  min-width: 92px;
  margin-top: -1px;
  color: #233e38;
  text-shadow: none;
  text-align: center;
  border: 1px solid rgba(86, 66, 51, .24);
  border-radius: 2px;
  background: rgba(255, 250, 239, .96);
  box-shadow: 0 5px 14px rgba(38, 29, 24, .14);
}

.unit-bars { width: 126px; gap: 2px; }
.bar {
  height: 12px;
  border: 1px solid rgba(69, 52, 42, .52);
  background: rgba(42, 35, 31, .84);
}
.bar-text { line-height: 11px; font-size: 10px; }
.bar-cap { display: none; }
.buff-chip { color: #363433; text-shadow: none; border-color: rgba(99, 76, 57, .25); background: rgba(255, 249, 236, .94); }
.elem-badge { top: 8px; left: 9px; width: 27px; height: 27px; border-color: rgba(255,255,255,.72); }

.battle-bottom {
  height: 168px; flex-shrink: 0;
  gap: 10px;
  padding: 10px 14px;
  border: 0;
  border-top: 1px solid rgba(88, 69, 54, .2);
  background: linear-gradient(105deg, #fdf5e4 0%, #fff9ef 35%, #e5ede5 100%);
  box-shadow: 0 -12px 34px rgba(43, 34, 28, .15);
}

.cmd-status {
  width: 32%;
  padding: 7px 10px;
  position: relative; overflow: hidden;
  border: 1px solid rgba(87, 67, 52, .22);
  border-radius: 3px;
  background: transparent;
  box-shadow: 0 6px 16px rgba(48, 38, 31, .08);
}
.cmd-avatar { position: absolute; left: -20px; top: 0; width: 180px; height: 270px; object-fit: cover; object-position: center top; border: 0; border-radius: 0; background: none; box-shadow: none; }
.cmd-who { margin-left: 150px; }
.cmd-who-name { color: #21473f; font-size: 23px; }
.cmd-who-tip { color: #8b442f; font-size: 12px; margin-top: 9px; }
.cmd-btn { font-size: 17px; border: 1px solid #47625944; border-radius: 0; box-shadow: none; background: #fffdf6; }
.cmd-btn .icon-badge { background: transparent; color: #b33e28; border: none; box-shadow: none; font-size: 24px; }
.cmd-btn.selected, .cmd-btn.kbd-focus { background: #ae402b; color: #fff9ed; border-color: #ae402b; }
.cmd-btn.selected .icon-badge, .cmd-btn.kbd-focus .icon-badge { color: #fff9ed; }
.cmd-grid { gap: 8px; }
.wuxing-ring {
  /* 落在名字/提示那一栏下方，不压立绘的下半身和兵器 */
  position: absolute; left: 168px; bottom: 8px; z-index: 7;
  margin-left: 0;
  color: #3e3c38;
  border-color: rgba(88, 68, 52, .22);
  background: rgba(255, 251, 242, .78);
  box-shadow: none;
}
.ring-arrow { color: #9e7160; }

.cmd-preview {
  animation: none;
  left: 32px;
  top: 176px;
  bottom: auto;
  color: #3c3a37;
  border: 1px solid rgba(184, 69, 61, .38);
  background: rgba(255, 251, 242, .96);
  box-shadow: var(--soft-shadow);
}
.pv-main { color: #33312f; }
.pv-side.good { color: #276334; }
.pv-side.bad { color: #a73420; }
.pv-side.none { color: #62584a; }
.battle-scene-heading {
  position: absolute; top: 80px; left: 32px; z-index: 2;
  padding: 12px 22px 12px 14px; border-left: 3px solid #ab422c;
  background: linear-gradient(90deg, rgba(255,250,235,.95), rgba(255,250,235,.75));
  color: #244139; pointer-events: none;
}
.scene-heading-kicker { color: #856b4c; font-size: 10px; letter-spacing: 3px; }
.battle-scene-heading h2 { font-size: 28px; letter-spacing: 4px; margin-top: 5px; font-weight: 500; }


/* 寻宝、结局同样使用轻绢容器，让背景保持是世界而不是遮罩底图。 */
.treasure-veil { background: linear-gradient(180deg, rgba(37,28,22,.16), rgba(37,28,22,.36)); }
.treasure-panel {
  border: 1px solid rgba(82, 69, 57, .28);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(255, 252, 245, .975), rgba(240, 226, 201, .96));
  box-shadow: var(--soft-shadow);
}
.treasure-status { border: 0; border-radius: 10px; background: rgba(70, 57, 46, .9); }
.treasure-tile { border: 1px solid rgba(90, 69, 52, .34); border-radius: 12px; box-shadow: 0 7px 16px rgba(43, 31, 23, .15); }

.ending-root { background: #ccd7d4; }
.ending-bg { filter: none; }
.ending-panel { color: #343432; }

/* ---------- 打磨:读得清的血条、跟着动画走的飘字、形态立绘 ---------- */
.unit-bars { width: 132px; }
.bar { height: 10px; }
.bar.hp { height: 15px; }
.bar.hp .bar-text {
  font-size: 12px; line-height: 14px; font-weight: bold; letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 2px #000, 0 1px 1px #000, 1px 0 1px #000, -1px 0 1px #000;
}
.bar.mp .bar-text { display: none; }
.bar.sp .bar-text { font-size: 9px; line-height: 9px; }
/* 状态签一律「名·N回合」:小一号、不折行 */
.buff-chip { white-space: nowrap; font-size: 10.5px; }
.buff-chip.form-chip { color: #fff8e6; border-color: transparent; font-weight: bold; letter-spacing: 1px; }
.buff-chip.form-chip[data-el="金"] { background: #a8831f; }
.buff-chip.form-chip[data-el="木"] { background: #3e7d3a; }
.buff-chip.form-chip[data-el="水"] { background: #24607e; }
.buff-chip.form-chip[data-el="火"] { background: #a8382a; }
.buff-chip.form-chip[data-el="土"] { background: #7d5a34; }
/* 形态立绘与悟空原画同朝向:不镜像 */
.unit-card.party.form-art .unit-portrait { transform: none; }
.unit-card.party.form-art.commanding .unit-portrait { animation-name: breathe; }
.unit-card.transformed.form-art .unit-portrait { filter: drop-shadow(0 9px 8px rgba(31, 24, 20, .35)); }
/* 缺形态图时:按五行给原立绘染色 */
.unit-card.form-tint[data-form="shenjiang"] .unit-portrait { filter: sepia(.6) saturate(2.2) hue-rotate(-8deg) brightness(1.08) drop-shadow(0 0 10px rgba(230, 190, 60, .9)); }
.unit-card.form-tint[data-form="lieyuan"] .unit-portrait { filter: sepia(.5) saturate(2.6) hue-rotate(-35deg) drop-shadow(0 0 10px rgba(230, 80, 40, .9)); }
.unit-card.form-tint[data-form="xuangui"] .unit-portrait { filter: grayscale(.4) sepia(.3) hue-rotate(170deg) saturate(1.6) brightness(.85) drop-shadow(0 0 10px rgba(60, 140, 200, .9)); }
.unit-card.form-tint[data-form="chongzi"] .unit-portrait { filter: sepia(.4) saturate(1.8) hue-rotate(30deg) drop-shadow(0 0 10px rgba(200, 220, 90, .9)); }

.unit-card.small .unit-portrait { height: 236px; }

/* 倒下的伙伴:躺倒在原地、灰而半透明,名字还在(可被回魂丹救起) */
/* 只躺立绘:绕自身中心转、缩到本卡宽内并压回脚线，不横进邻位的名牌血条;名牌与牌条栈原位不动 */
.unit-card.party.dead { opacity: .62; filter: grayscale(1); z-index: 3; }
.unit-card.party.dead .unit-portrait { transform: translateY(36px) rotate(-84deg) scale(.74) !important; transform-origin: 50% 50%; animation: none !important; }
.unit-card.party.dead .unit-name { display: block; opacity: .9; }
.unit-card.party.dead .elem-badge { display: none; }
.unit-card.party.dead .unit-bars { display: flex; visibility: hidden; }
.unit-card.party.dead .buff-chips { display: flex; visibility: hidden; }
.unit-card.dead.revivable { pointer-events: auto; opacity: .9; cursor: pointer; }
.unit-card.dead.revivable .unit-portrait { outline: 3px dashed #4fe06a; outline-offset: 2px; }

/* 飘字:红、大、带深描边,落在胸口高度;暴击更大,治疗绿 */
.unit-card .float-anchor { top: 35%; }
/* 3px 深描边+暗晕：火口橙底、受击泛红的立绘上也压得住数字 */
.float-text { -webkit-text-stroke: 3px #2a0e08; paint-order: stroke fill; text-shadow: 0 2px 0 #1a0804, 0 0 8px rgba(10, 4, 2, .9), 0 0 3px rgba(10, 4, 2, .9); }
.unit-card.enemy .float-text.dmg,
.unit-card.enemy .float-text.ke-big,
.unit-card.enemy .float-text.beike,
.unit-card.enemy .float-text.combo-dmg { color: #ff3b2f; }
.unit-card.party .float-text.dmg,
.unit-card.party .float-text.ke-big,
.unit-card.party .float-text.beike,
.unit-card.party .float-text.combo-dmg { color: #ff6a4a; }
.float-text.dmg, .float-text.ke-big, .float-text.beike, .float-text.combo-dmg {
  font-size: 30px; font-weight: 900; animation: dmgBounce 1.25s ease-out forwards;
}
.float-text.ke-big { font-size: 34px; }
.float-text.crit { font-size: 40px; }
.float-text.huge { font-size: 40px; }
.float-text.heal { color: #4fe06a; font-size: 26px; font-weight: 900; }
@keyframes dmgBounce {
  0% { opacity: 0; margin-top: 0; transform: translateX(-50%) scale(1.4); }
  14% { opacity: 1; transform: translateX(-50%) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; margin-top: -54px; transform: translateX(-50%) scale(1); }
}

/* 印章(克/暴击/连击)挂在数字上方,不再盖住伤害数字 */
.unit-card .float-stamp { top: -64px; }
.unit-card .float-stamp.crit-stamp { top: -102px; }

/* 收服印:场中央一枚不透明的朱印卡 */
.seal-toast {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%) rotate(-3deg);
  z-index: 26; pointer-events: none; text-align: center;
  padding: 18px 38px; background: #b33a26; color: #fff6e2;
  border: 4px double #f4cf88; box-shadow: 0 12px 40px rgba(40, 14, 8, .45);
  animation: sealIn .32s cubic-bezier(.2,1.4,.4,1);
}
.seal-toast-title { font-size: 32px; letter-spacing: 8px; font-weight: bold; }
.seal-toast-sub { margin-top: 6px; font-size: 14px; letter-spacing: 2px; opacity: .92; }
@keyframes sealIn { from { opacity: 0; transform: translate(-50%, -50%) rotate(-3deg) scale(1.6); } }

/* 指令台:十个指令两行;选目标时菜单变淡但可点(点别的指令即撤销选目标) */
.cmd-grid { grid-template-columns: repeat(5, 1fr); }
.cmd-btn { letter-spacing: 2px; }
.cmd-grid.picking, .cmd-list.picking { opacity: .55; }
.cmd-cancel-chip {
  position: absolute; right: 18px; top: -46px; z-index: 12;
  padding: 6px 16px; font-size: 14px; letter-spacing: 2px;
  background: #fffaf0; color: #a53925; border: 1px solid #a5392566; border-radius: 16px;
}
.cmd-menu { position: relative; }
.cmd-item.with-icon { flex-direction: row; align-items: center; gap: 8px; padding: 6px 14px 6px 8px; }
.item-icon { width: 40px; height: 40px; display: block; flex: none; border-radius: 7px; }
.item-icon.sm { width: 34px; height: 34px; }
.item-icon.xs { width: 22px; height: 22px; border-radius: 4px; }
.cmd-avatar.enemy { transform: scaleX(-1); }

/* 挂机中·接手 */
.auto-all-chip {
  position: absolute; left: 50%; top: 64px; transform: translateX(-50%); z-index: 9;
  padding: 7px 20px; font-size: 15px; letter-spacing: 3px;
  background: #ae402b; color: #fff9ed; border: 0; border-radius: 18px;
  box-shadow: 0 6px 18px rgba(80, 30, 20, .3); animation: autoPulse 1.6s ease-in-out infinite;
}
.auto-all-chip[hidden] { display: none; }
@keyframes autoPulse { 50% { filter: brightness(1.15); } }

/* 战况:逐行长出来,克/暴击/被克着色 */
.battle-report-lines { gap: 4px; }
.battle-report-line { font-size: 14px; letter-spacing: 1px; padding-bottom: 2px; }
.battle-report-line.fresh { animation: logIn .25s ease; font-weight: bold; }
.battle-report-line.ke { color: #b8860b; }
.battle-report-line.crit { color: #c0321f; }
.battle-report-line.beike { color: #7a7066; }
.battle-report-line.heal { color: #2f7d3d; }
.battle-report-line.burn { color: #c25a1e; }
.battle-report-line.skill { color: #24607e; }
@keyframes logIn { from { opacity: 0; transform: translateY(6px); } }

/* 预览条:贴在指令台上沿,窄、不折行,不压敌人头顶的五行徽 */
/* 放在天空一带(行动顺序条下方正中):人物都站在下半场,不会压到谁的五行徽或血条 */
.battle-root .cmd-preview { top: 62px; bottom: auto; left: 50%; transform: translateX(-50%); max-width: 46vw; padding: 6px 14px; z-index: 40; }
.pv-line { display: flex; flex-wrap: wrap; column-gap: 10px; }
.pv-main { white-space: nowrap; }
.pv-side { display: inline-flex; flex-wrap: wrap; column-gap: 8px; }
.pv-seg { white-space: nowrap; }
.defeat-hint { margin-top: 10px; padding: 8px 12px; border-left: 3px solid #a53925; background: rgba(165, 57, 37, .07); color: #6a2a18; line-height: 1.7; }

/* 战斗中只留「设置」:队伍按钮由战场自己的阵型钮与指令代替 */
body.phase-battle #topbar .topbar-group:not(:last-child) { visibility: hidden; }

@media (max-height: 820px) {
  /* 矮屏:法术/道具/特技菜单排成五列网格,「返回」固定在第一格,不会被挤出指令台 */
  .cmd-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; align-content: start; }
  .cmd-list .cmd-item { min-height: 52px; min-width: 0; padding: 5px 9px; }
  .cmd-list > .cmd-btn[data-cmd="back"] { order: -1; min-height: 52px; }
  .cmd-item-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .cmd-item-meta { font-size: 10.5px; line-height: 1.35; }
}

@media (max-width: 1360px) {
  .cmd-status { width: 30%; }
  .cmd-preview { left: 32px; }
  .wuxing-ring { padding-inline: 6px; }
  .order-bar { max-width: calc(100% - 260px); }
}

/* 窄屏不是桌面缩略图：导航下沉，战场敌我拆层，所有关键按钮保持可触。 */
@media (max-width: 700px) {
  .topbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    height: 60px;
    justify-content: space-around;
    padding: 6px 8px;
    border-top: 1px solid rgba(96, 75, 59, .2);
    border-bottom: 0;
    box-shadow: 0 -8px 26px rgba(50, 40, 33, .14);
  }

  .topbar-title,
  .topbar-sep,
  .topbar-spacer { display: none; }
  .topbar-group { flex: 1; justify-content: space-around; gap: 4px; }
  .topbar-btn {
    flex: 1;
    min-width: 0;
    min-height: 46px;
    flex-direction: column;
    gap: 1px;
    padding: 3px 4px;
    font-size: 10px;
    letter-spacing: 0;
  }
  .topbar-btn .icon-badge { width: 23px; height: 23px; font-size: 12px; }
  .topbar-sys { flex: 0 0 54px; }
  .topbar-dropdown { top: auto; right: 0; bottom: 54px; width: 150px; }

  body:not(.no-topbar) .screen,
  body:not(.no-topbar) .overworld-root,
  body:not(.no-topbar) .treasure-root,
  body:not(.no-topbar) .battle-root,
  body:not(.no-topbar) .ending-root,
  body:not(.no-topbar) .story-bg { inset: 0 0 60px; }

  .title-screen { padding: 40px 26px 28px; justify-content: flex-start; }
  .title-cover { inset: 0; background-position: 65% center; }
  .title-mask { background: linear-gradient(180deg, #fff1d9ef, #fff1d9aa 25%, transparent 49%, #f9edd6f5 80%); }
  .title-kicker { font-size: 10px; letter-spacing: 2px; margin-bottom: 14px; }
  .title-logo h1 { font-size: 62px; line-height: 1.05; }
  .title-seal { display: none; }
  .title-logo p { font-size: 12px; max-width: 210px; margin-top: 12px; }
  .title-hero { right: -8%; bottom: 15%; height: 62%; width: 90%; }
  .title-inscription { top: 10%; right: 18px; font-size: 10px; padding: 12px 7px; letter-spacing: 3px; }
  .title-menu { width: 100%; margin-top: auto; gap: 8px; }
  .title-btn { min-height: 48px; font-size: 15px; padding: 10px 18px; }
  .battle-scene-heading { top: 86px; left: 10px; padding: 6px 10px; }
  .scene-heading-kicker { display: none; }
  .battle-scene-heading h2 { font-size: 13px; letter-spacing: 1px; margin: 0; }
  .battle-field:has(.field-rule) .battle-scene-heading { top: 113px; }

  .dlg-portrait { left: -7%; bottom: 6%; width: 90%; height: 80%; }
  .dlg-box, .dlg-box.narration { left: 12px; bottom: 74px; width: calc(100% - 24px); min-height: 148px; padding: 18px 20px; }
  .dlg-box.narration { bottom: 18%; }
  .dlg-name { font-size: 21px; padding-bottom: 6px; }
  .dlg-text { font-size: 16px; line-height: 1.7; max-height: 24vh; }
  .dlg-next { padding-top: 10px; }
  .battle-bottom {
    height: 184px;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: 50px 1fr;
    gap: 7px;
    padding: 8px 9px;
  }
  .cmd-status { grid-column: 1; width: auto; min-width: 0; padding: 5px 8px; }
  .cmd-avatar { position: static; width: 34px; height: 38px; object-fit: contain; }
  .cmd-who { margin-left: 0; }
  .cmd-who-name { font-size: 14px; }
  .cmd-who-tip { font-size: 10px; }
  .cmd-menu { grid-column: 1 / -1; grid-row: 2; min-height: 0; }
  .cmd-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .cmd-btn { min-height: 48px; font-size: 13px; letter-spacing: 1px; gap: 4px; padding: 5px 2px; }
  .cmd-btn .icon-badge { width: 20px; height: 22px; font-size: 12px; }
  .cmd-list { gap: 5px; }
  .cmd-item { flex: 1 1 46%; padding: 7px 9px; }
  .wuxing-ring {
    position: static;
    grid-column: 2;
    grid-row: 1;
    align-self: stretch;
    max-width: 170px;
    padding: 4px 6px;
    overflow: hidden;
  }
  .ring-el { width: 20px; height: 20px; font-size: 11px; }
  .ring-arrow { font-size: 9px; }

  .order-bar {
    top: 8px;
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    min-height: 38px;
    padding: 4px 7px;
  }
  .order-label { font-size: 11px; letter-spacing: 1px; }
  .order-chip { padding-right: 4px; }
  .order-chip img { width: 22px; height: 22px; }
  .order-chip-name,
  .order-chip-spd { display: none; }
  .round-tag { top: 52px; right: 8px; font-size: 11px; }
  .formation-btn { top: 52px; left: 8px; right: auto; font-size: 11px; padding: 4px 8px; }
  .field-rule {
    top: 83px;
    right: 8px;
    left: 8px;
    max-width: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
    text-align: center;
  }

  .unit-card { width: 88px; }
  .unit-portrait { width: 92px; height: 134px; }
  .unit-card.big { width: 118px; }
  .unit-card.big .unit-portrait { width: 122px; height: 184px; }
  .unit-name { min-width: 66px; max-width: 84px; padding: 1px 4px; font-size: 10px; letter-spacing: 0; }
  .unit-bars { width: 76px; margin-top: 2px; }
  .bar { height: 10px; }
  .bar-text { line-height: 9px; font-size: 7px; }
  .buff-chips { min-height: 12px; max-width: 82px; gap: 1px; }
  .buff-chip { font-size: 7px; padding: 0 2px; }
  .elem-badge { top: 4px; left: 5px; width: 22px; height: 22px; font-size: 11px; }
  .unit-shadow { bottom: 48px; width: 56px; }
  .unit-card.big .unit-shadow { bottom: 48px; width: 92px; }

  .cmd-preview {
    left: 10px;
    right: 10px;
    top: 145px;
    bottom: auto;
    min-width: 0;
    max-width: none;
    font-size: 12px;
  }
  .pv-line { flex-direction: column; gap: 2px; }
  .pv-side { white-space: normal; font-size: 11px; }

  .modal-panel { width: calc(100% - 20px); max-height: calc(100% - 24px); padding: 18px 16px 14px; }
  .modal-title { font-size: 18px; letter-spacing: 3px; }
  .modal-foot { flex-wrap: wrap; }
  .modal-btn { flex: 1 1 40%; padding: 8px 12px; }

  .treasure-panel {
    width: calc(100% - 18px);
    height: calc(100% - 18px);
    min-height: 0;
    padding: 16px 12px;
    overflow: auto;
  }
  .treasure-head { display: block; }
  .treasure-title { font-size: 20px; letter-spacing: 3px; }
  .treasure-guide { margin-top: 4px; font-size: 12px; }
  .treasure-status { grid-template-columns: 1fr; gap: 5px; }
  .treasure-grid,
  .treasure-grid.deep { width: 100%; margin-top: 8px; grid-template-columns: repeat(2, 1fr); gap: 7px; }
  .treasure-tile { min-height: 92px; grid-template-columns: 32px 1fr; padding: 9px; }

  .ending-panel {
    width: calc(100% - 20px);
    max-height: calc(100% - 24px);
    overflow: auto;
    padding: 18px 16px;
  }
  .ending-panel p { font-size: 14px; line-height: 1.7; }
  .ending-title { font-size: 20px; letter-spacing: 3px; }
}

@media (max-height: 680px) and (min-width: 701px) {
  .battle-bottom { height: 142px; }
  .unit-portrait { height: 132px; }
  .unit-card.big .unit-portrait { height: 204px; }
}

@media (min-width: 701px) and (max-width: 1100px) {
  .unit-card { width: 140px; }
  .unit-portrait { width: 155px; height: 245px; }
  .unit-card.big { width: 200px; }
  .unit-card.big .unit-portrait { width: 192px; height: 258px; }
  .title-logo h1 { font-size: 78px; }
}
@media (max-height: 720px) and (min-width: 701px) {
  .title-screen { padding-top: 36px; padding-bottom: 90px; }
  .title-logo h1 { font-size: 66px; }
  .title-kicker { margin-bottom: 14px; }
  .title-menu { margin-top: 18px; gap: 8px; }
  .title-logo p { margin-top: 14px; }
  .title-journey { bottom: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
