/* ARSENE battle HUD v2 — portrait-first, every element remains live game UI. */
#game.game-shell{width:min(480px,100%);min-height:0;margin-inline:auto;grid-template-rows:auto auto;align-content:start;border-inline:1px solid #172036;box-shadow:0 0 70px #000}
#game .game-header{display:none}
#game .battlefield{height:56svh;min-height:500px;max-height:650px;border-bottom:1px solid #68408d;isolation:isolate}
#game .battlefield::before{z-index:0;background:linear-gradient(180deg,#02030b40 0 62%,#02030be8 100%),radial-gradient(circle at 50% 22%,#782cff26,transparent 44%)}
#game .battlefield::after{z-index:0;bottom:-18%;height:43%;opacity:.22}

.battle-topbar{position:absolute;z-index:7;inset:max(8px,env(safe-area-inset-top)) 10px auto;display:flex;align-items:flex-start;justify-content:space-between;pointer-events:none}
.battle-topbar .turn-info{pointer-events:auto;width:86px;min-height:72px;display:grid;place-content:center;padding:7px 9px;text-align:center;border:1px solid #a78c62;background:linear-gradient(145deg,#09090df2,#02030aeb);clip-path:polygon(7px 0,100% 0,100% calc(100% - 7px),calc(100% - 7px) 100%,0 100%,0 7px);box-shadow:inset 0 0 0 2px #181521,0 5px 18px #000b}
.battle-topbar .turn-info span{font:700 7px Cinzel;letter-spacing:.18em;color:#bd7fff}
.battle-topbar .turn-info b{font:900 14px Cinzel;letter-spacing:.08em;color:#fff}
.battle-topbar .turn-info small{margin-top:2px;font:700 8px Cinzel;color:#d9d3dc;letter-spacing:.08em}
.battle-menu-button{pointer-events:auto;min-width:88px;padding:10px 13px;border:1px solid #a78c62;background:#07080df2;color:#eee;font:700 11px Cinzel;letter-spacing:.14em;clip-path:polygon(6px 0,100% 0,100% calc(100% - 6px),calc(100% - 6px) 100%,0 100%,0 6px);box-shadow:inset 0 0 0 2px #17141c,0 5px 18px #000c}
.battle-menu-button i{display:inline-block;width:13px;height:9px;margin-right:6px;border-block:1px solid currentColor;position:relative}.battle-menu-button i::after{content:"";position:absolute;inset:3px 0 auto;border-top:1px solid currentColor}
.battle-menu-popover{pointer-events:auto;position:absolute;right:0;top:46px;width:min(252px,calc(100vw - 24px));padding:10px;background:linear-gradient(150deg,#080913fa,#02030afa);border:1px solid #8a724e;box-shadow:inset 0 0 0 2px #181522,0 14px 34px #000;display:grid;gap:8px;clip-path:polygon(7px 0,100% 0,100% calc(100% - 7px),calc(100% - 7px) 100%,0 100%,0 7px)}.battle-menu-popover[hidden]{display:none}
.battle-menu-header{display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #443554;padding:0 0 7px}.battle-menu-header small{font:700 9px Cinzel;letter-spacing:.2em;color:#c5a0ff}.battle-menu-header button{width:28px;height:26px;padding:0!important;border-color:#67445c!important;background:#0a0910!important;color:#e9dfea;font-size:16px!important;box-shadow:inset 0 0 8px #4a173333}
.battle-audio-row{display:grid;grid-template-columns:42px minmax(0,1fr) 34px 39px;align-items:center;gap:5px;min-height:32px}.battle-audio-row>span{color:#e7e2eb;font:800 9px Cinzel;letter-spacing:.08em}.battle-audio-row input{width:100%;height:18px;margin:0;accent-color:#9b56dc}.battle-audio-row output{color:#bfc9dc;font:700 8px Cinzel;text-align:right}.battle-audio-row button{min-width:39px;padding:5px 3px!important;border:1px solid #397c9d!important;background:#081b28!important;color:#75ddff!important;font:800 8px Cinzel!important}.battle-audio-row button.off{border-color:#473c4b!important;background:#0a0910!important;color:#77717d!important}
.battle-menu-actions{display:grid;grid-template-columns:1fr 1fr;gap:6px;padding-top:2px}.battle-menu-popover .battle-menu-actions>button{min-height:36px;padding:6px;border:1px solid #34425a;background:#0a1020;color:#eee;font-weight:800;font-size:10px}.battle-menu-popover .battle-menu-actions>.test-return{border-color:#725538;background:#171007;color:#e9c88d}.battle-menu-actions .test-return small{display:block;margin-top:1px;color:#9a7952;font:700 6px Cinzel;letter-spacing:.14em}

#game .combatants{z-index:2;inset:66px 0 0;display:block}
#game .enemies{position:absolute;z-index:4;inset:18px 3% auto;width:94%;height:55%;padding:0;display:flex;align-items:flex-end;justify-content:space-around;gap:0;overflow:visible}
#game .enemy{--enemy-scale:.9;flex:0 1 32%;width:32%;height:100%;margin:0;transform:none;overflow:visible}
#game .enemy:nth-child(2){--enemy-scale:1.08;z-index:2}
#game .enemy:nth-child(3){--enemy-scale:.91}
#game .enemy[data-size="large"]{--enemy-scale:1.02}
#game .enemy[data-size="boss"]{--enemy-scale:1;flex-basis:100%;width:100%}
#game .enemy-visual{position:absolute;inset:34px 0 31px;transform:scale(var(--enemy-scale));transform-origin:center bottom;transition:filter .2s,transform .22s}
#game .enemy .slime{left:50%;bottom:4px;translate:-50% 0;width:min(31vw,142px);height:min(31vw,142px);transform:none}
#game .enemy .slime-shadow{left:50%;bottom:0;translate:-50%;width:82%;height:13px}
#game .boss-enemy .enemy-visual{inset:8px 0 29px;display:grid;place-items:end center}
#game .boss-enemy .noel-sprite{position:relative;inset:auto;translate:0;width:min(88vw,400px);height:calc(100% + 26px);background-position:center bottom;background-size:contain;background-repeat:no-repeat}
#game .enemy-nameplate{position:absolute;z-index:5;left:50%;top:0;translate:-50%;width:min(126%,160px);min-height:35px;padding:5px 6px 4px;text-align:center;background:linear-gradient(90deg,transparent,#050711e8 12% 88%,transparent);border-block:1px solid #5c476c;color:#fff;text-shadow:0 2px 4px #000}
#game .enemy-nameplate>span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:9px;font-weight:900}
#game .enemy-nameplate>span small{display:block;color:#b99bdd;font:700 6px Cinzel;letter-spacing:.08em;white-space:nowrap}
#game .enemy-nameplate .enemy-statuses{position:static;display:flex;justify-content:center;gap:3px;min-height:14px;margin:2px auto 0;padding:0;border:0;background:none}
#game .enemy-nameplate .status-chip{min-width:14px;max-width:42px;overflow:hidden;padding:2px 3px;font-size:6px;white-space:nowrap;text-overflow:ellipsis}
#game .enemy-hud,#game .boss-enemy .enemy-hud{position:absolute;z-index:5;left:50%;top:auto;bottom:0;translate:-50%;width:min(112%,146px);display:grid;grid-template-columns:18px 1fr;gap:2px 4px;align-items:center;padding:4px 7px;background:linear-gradient(100deg,#05070eed,#090b14ed);border:1px solid #6b5362;text-align:left;opacity:1;clip-path:polygon(5px 0,100% 0,calc(100% - 5px) 100%,0 100%)}
#game .enemy-hud label{grid-column:1;color:#ddd;font:900 7px Cinzel}
#game .enemy-hud .enemy-hp-meter{grid-column:2;height:7px;margin:0;transform:skewX(-13deg);border:1px solid #493647;background:#03040a}
#game .enemy-hud small{grid-column:1/-1;color:#e6e1e8;font:700 7px Cinzel;text-align:center;letter-spacing:.03em}
#game .targetable::after{top:30px}.targetable:focus-visible{outline:1px solid #77e7ff;outline-offset:2px}.targetable:hover{transform:none}.targetable:hover .enemy-visual,.targetable:focus-visible .enemy-visual{transform:scale(calc(var(--enemy-scale) * 1.04));filter:brightness(1.25) drop-shadow(0 0 10px #45dfff)}

#game .ren{position:absolute;z-index:3;left:-20px;bottom:0;width:252px;height:360px;margin:0;transform:none;transform-origin:center bottom}
#game .ren-sprite{
  inset:auto 0 0;
  width:100%;
  height:100%;
  background:url("../assets/playable-characters/ren/body-no-weapon.png") center bottom/contain no-repeat;
  image-rendering:auto;
  filter:drop-shadow(0 5px 3px #000c) drop-shadow(0 0 7px #0b6ddd88);
  animation:renBackIdle 3s ease-in-out infinite
}
#game .ren-shadow{left:38px;bottom:1px;width:175px;height:20px;background:#2d0d7255;box-shadow:0 0 22px #551dbd88}
#game .weapon-layer,
#game .weapon-layer::before,
#game .weapon-layer::after{
  display:none!important;
  visibility:hidden!important;
  opacity:0!important;
  background:none!important;
  background-image:none!important;
  content:none!important;
  animation:none!important;
}

/* 蓮は武器レイヤーから分離した全身立ち絵だけを表示する。 */
#game .ren-sprite{
  background-image:url("../assets/playable-characters/ren/body-no-weapon.png")!important;
  background-position:center bottom!important;
  background-size:contain!important;
  background-repeat:no-repeat!important;
}
@keyframes renBackIdle{50%{translate:0 -3px}}

#game .player-card{z-index:5;left:auto;right:8px;top:auto;bottom:11px;width:58%;max-width:278px;padding:10px 10px 9px 13px;background:linear-gradient(115deg,#05070ef2,#080c18ed);border:1px solid #705945;clip-path:polygon(8px 0,100% 0,100% calc(100% - 8px),calc(100% - 8px) 100%,0 100%,0 8px);box-shadow:0 7px 22px #000b}
#game .player-meta{height:auto;display:grid;grid-template-columns:auto 1fr;gap:0 7px;align-items:baseline;margin-bottom:5px}
#game .player-meta small{display:none}.player-meta strong{font-size:18px}.player-meta span{font-size:8px;color:#ddd;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#game .meter-row{grid-template-columns:20px 1fr 58px;gap:4px;margin:4px 0}.meter-row output{font-size:7px}.meter{height:8px}
#game .xp-row{margin-top:7px;gap:7px}.xp-cell small{font-size:6px}.xp-cell .meter{height:13px}.xp-cell output{font-size:6px}
#game .resonance-row{grid-template-columns:60px 1fr 30px;margin-top:5px;font-size:6px}
#game .player-statuses{min-height:18px;margin-top:5px;display:flex;gap:3px;overflow-x:auto}.player-statuses .status-chip{flex:none;padding:2px 4px;font-size:6px}

#game .battle-console{display:grid;grid-template-columns:1fr;gap:7px;min-height:0;padding:9px 10px max(10px,env(safe-area-inset-bottom));background:linear-gradient(180deg,#060711,#02040b);border-top:1px solid #745a76;box-shadow:0 -10px 28px #000}
.battle-assists{display:grid;grid-template-columns:1fr 1fr;gap:7px}.battle-assists button{min-height:42px;display:flex;align-items:center;justify-content:center;gap:8px;border:1px solid #34475e;background:linear-gradient(110deg,#08101e,#04070d);clip-path:polygon(6px 0,100% 0,calc(100% - 6px) 100%,0 100%)}.battle-assists button>b{font:900 20px Cinzel;color:#d9e4ef}.battle-assists button span{display:grid;font-size:11px}.battle-assists button small{font:700 7px Cinzel;letter-spacing:.12em;color:#58d6ff}.battle-assists button.active{border-color:#d0a74d;background:linear-gradient(110deg,#3b2a08,#100c06);box-shadow:inset 0 0 14px #d59b2344}.battle-assists button.active small{color:#ffda6c}
.command-heading{display:flex;align-items:end;justify-content:space-between;padding:1px 3px}.command-heading small{font:700 7px Cinzel;letter-spacing:.2em;color:#9d6ddf}.command-heading b{font:900 16px Cinzel;letter-spacing:.12em}
#game .command-panel{display:grid;grid-template-columns:repeat(3,1fr);gap:5px}
#game .command-panel button{min-height:58px;padding:7px 5px 6px;text-align:center;border-color:#635069;background:linear-gradient(145deg,#080a11,#04050a);clip-path:polygon(6px 0,100% 0,calc(100% - 6px) 100%,0 100%)}
#game .command-panel button i{position:static;display:block;width:9px;height:9px;margin:0 auto 4px;transform:rotate(45deg);background:#8762ad;box-shadow:0 0 7px #6c35a1}
#game .command-panel button strong{font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.command-panel button span{font-size:6px;color:#bd83f2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#game .command-panel button:hover,#game .command-panel button:focus-visible{transform:none;border-color:#e05578;background:linear-gradient(145deg,#4a0718,#11050b);box-shadow:inset 0 0 18px #d7134033}
#game .battle-log{order:10;display:block;min-height:70px;max-height:92px;padding:8px 10px;overflow:hidden;background:#03050a;border:1px solid #4b3440;clip-path:none}
#game .battle-log.expanded{position:fixed;z-index:80;inset:8svh max(10px,calc((100vw - 460px)/2));max-height:84svh;overflow:auto;box-shadow:0 0 0 100vmax #000b,0 0 30px #772c72}
#game .battle-log>small{display:block;margin-bottom:5px;color:#ef6780;font:700 7px Cinzel;letter-spacing:.16em}.battle-log-lines{display:grid;gap:2px;padding-top:2px}.battle-log p{margin:0;font-size:9px;line-height:1.45;color:#d8d5dc}.battle-log-lines p:nth-last-child(1){color:#71caff}

.simple-battle .ambient{display:none}.simple-battle .ren-sprite,.simple-battle .slime{animation:none!important}.simple-battle .float-number{animation-duration:.45s!important}

@media(min-width:761px){body{background:radial-gradient(circle at 50% 30%,#131026,#010207 62%)}#game.game-shell{width:480px}.battle-topbar{top:10px}}
@media(max-width:390px){
  #game .battlefield{height:54svh;min-height:465px}
  #game .ren{left:-22px;width:238px;height:320px}
  #game .ren-shadow{left:34px;width:160px}
  #game .player-card{right:6px;width:59%;padding-left:10px}
  .player-meta strong{font-size:16px}
  #game .enemy-nameplate{width:116%;padding-inline:3px}
  .battle-topbar .turn-info{width:78px}
  .command-panel button strong{font-size:10px}
}
@media(max-height:720px){#game .battlefield{height:58svh;min-height:430px}#game .ren{height:265px;width:200px}#game .player-card{bottom:6px}.battle-log{max-height:74px}}
@media(prefers-reduced-motion:reduce){#game .ren-sprite{animation:none}}

/* 旧端末向けの最低寸法。最終的な半身表示は末尾の参考レイアウトで上書きする。 */
@media(max-height:720px){
  #game .ren{left:-6px;width:220px;height:330px}
  #game .ren-sprite{inset:auto 0 0;width:100%;height:100%;background-size:contain!important}
}

/* COMMAND最終圧縮：2段目を半高化し、ステータス〜ログ間の空白を除去。 */
#game .player-card{bottom:2px}
#game .battle-console{gap:2px;padding:3px 8px max(7px,env(safe-area-inset-bottom))}
#game .command-panel[data-layout="main"]{column-gap:5px;row-gap:3px}
#game .command-panel[data-layout="main"]>button:nth-child(n+5){
  min-height:31px;height:31px;display:grid;grid-template-columns:21px minmax(0,1fr);grid-template-rows:1fr 1fr;
  align-items:center;column-gap:3px;padding:2px 3px;text-align:left;
}
#game .command-panel[data-layout="main"]>button:nth-child(n+5) i,
#game .command-panel[data-layout="main"]>button:nth-child(n+5) i.command-icon-image{
  grid-column:1;grid-row:1/3;width:20px;height:20px;margin:auto;
}
#game .command-panel[data-layout="main"]>button:nth-child(n+5) strong,
#game .command-panel[data-layout="main"]>button:nth-child(n+5) span{
  grid-column:2;min-width:0;margin:0;text-align:left;
}
#game .command-panel[data-layout="main"]>button:nth-child(n+5) strong{grid-row:1;align-self:end;font-size:8px;line-height:1}
#game .command-panel[data-layout="main"]>button:nth-child(n+5) span{grid-row:2;align-self:start;margin-top:1px;font-size:4.5px;line-height:1}
#game .battle-log{margin-top:0;min-height:58px;max-height:70px}

@media(max-width:393px){
  #game .player-card{bottom:1px}
  #game .battle-console{padding-top:2px}
  #game .command-panel[data-layout="main"]>button:nth-child(n+5){min-height:29px;height:29px}
}
@media(max-height:720px){
  #game .player-card{bottom:0}
  #game .command-panel[data-layout="main"]>button:nth-child(n+5){min-height:28px;height:28px}
}

/* 支給素材「バトル下部UI」を各ライブコマンドとログ枠へ接続。 */
#game .command-panel[data-layout="main"]>button::before,
#game .battle-log::before{display:none}
#game .command-panel[data-layout="main"]>button{
  border:0;background-position:center!important;background-size:100% 100%!important;background-repeat:no-repeat!important;
  box-shadow:none;
}
#game .command-panel[data-layout="main"]>button[data-action="attack"]{background-image:url("../assets/ui/battle/lower-ui-v2/command-attack-v2.png")!important}
#game .command-panel[data-layout="main"]>button[data-action="weaponArts"]{background-image:url("../assets/ui/battle/lower-ui-v2/command-weapon-v2.png")!important}
#game .command-panel[data-layout="main"]>button[data-action="skills"]{background-image:url("../assets/ui/battle/lower-ui-v2/command-skill-v2.png")!important}
#game .command-panel[data-layout="main"]>button[data-action="guard"]{background-image:url("../assets/ui/battle/lower-ui-v2/command-guard-v2.png")!important}
#game .command-panel[data-layout="main"]>button[data-action="item"]{background-image:url("../assets/ui/battle/lower-ui-v2/command-item-v2.png")!important}
#game .command-panel[data-layout="main"]>button[data-action="escape"]{background-image:url("../assets/ui/battle/lower-ui-v2/command-escape-v2.png")!important}
#game .command-panel[data-layout="main"]>button[data-action="simpleBattle"]{background-image:url("../assets/ui/battle/lower-ui-v2/command-simple-v2.png")!important}
#game .command-panel[data-layout="main"]>button[data-action="autoBattle"]{background-image:url("../assets/ui/battle/lower-ui-v2/command-auto-v2.png")!important}

/* 固定絵のボタンは画像内ラベルを使用。アイテム数とON/OFFだけライブ表示する。 */
#game .command-panel[data-layout="main"]>button:not([data-action="weaponArts"])>i,
#game .command-panel[data-layout="main"]>button:not([data-action="weaponArts"])>strong,
#game .command-panel[data-layout="main"]>button:not([data-action="weaponArts"]):not([data-action="item"])>span{opacity:0}
#game .command-panel[data-layout="main"]>button[data-action="item"]>span{
  position:absolute;z-index:3;right:4px;top:3px;width:auto;padding:2px 3px;margin:0;color:#8dffd8;
  background:#02110ddd;border:1px solid #2b8d70;font:800 5px/1 Cinzel;opacity:1;
}
#game .command-panel[data-layout="main"]>button[data-action="simpleBattle"]::after,
#game .command-panel[data-layout="main"]>button[data-action="autoBattle"]::after{
  content:"OFF";position:absolute;z-index:3;right:3px;top:3px;padding:2px 3px;color:#817d87;
  background:#03050bdc;border:1px solid #494757;font:800 5px/1 Cinzel;letter-spacing:.08em;
}
#game .command-panel[data-layout="main"]>button[data-action="simpleBattle"].active::after{content:"ON";color:#79e9ff;border-color:#4bc8e0;box-shadow:0 0 5px #36cbe0}
#game .command-panel[data-layout="main"]>button[data-action="autoBattle"].active::after{content:"ON";color:#ffdc75;border-color:#d8ac4c;box-shadow:0 0 5px #d8a438}

/* 武器学枠だけは内側をライブレイヤー化。装備変更時に既存JSが画像・名称を再描画する。 */
#game .command-panel[data-layout="main"]>button[data-action="weaponArts"]::after{
  content:"";position:absolute;z-index:0;inset:5px;background:radial-gradient(circle at 50% 34%,#102a53f2,#02050cf8 72%);
  border:1px solid #426da06b;pointer-events:none;
}
#game .command-panel[data-layout="main"]>button[data-action="weaponArts"]>i,
#game .command-panel[data-layout="main"]>button[data-action="weaponArts"]>strong,
#game .command-panel[data-layout="main"]>button[data-action="weaponArts"]>span{position:relative;z-index:2;opacity:1}

#game .battle-log{
  position:relative;background:url("../assets/ui/battle/lower-ui-v2/command-log-v2.png") center/100% 100% no-repeat!important;
  border:0;box-shadow:none;
}
#game .battle-log::after{content:"";position:absolute;z-index:0;inset:4px;background:#02040af5;pointer-events:none}
#game .battle-log>*{position:relative;z-index:2}
@media(max-width:390px) and (min-height:721px){
  #game .ren{left:-6px;width:228px;height:340px}
  #game .ren-sprite{inset:auto 0 0;width:100%;height:100%;background-size:contain!important}
}

/* 参考レイアウト：敵の足元HPバーの下に、蓮の半身後ろ姿を置く。 */
#game .battlefield{height:66svh;min-height:560px;max-height:610px}
#game .enemies{inset:22px 3% auto;height:52%}
#game .enemy-nameplate{
  min-height:54px;
  padding:8px 5px 6px;
  background:linear-gradient(145deg,#080a12f2,#05060cf0);
  border:1px solid #725b70;
  box-shadow:inset 0 0 0 2px #171221,0 5px 14px #000a;
}
#game .enemy-nameplate>span{font-size:10px;line-height:1.25}
#game .enemy-nameplate .enemy-statuses{min-height:20px;margin-top:4px}
#game .enemy-nameplate .enemy-statuses:empty::after{content:none}
#game .enemy .slime{width:min(40vw,158px);height:min(40vw,158px)}
#game .ren{left:-8px;bottom:-28px;width:210px;height:270px}
#game .ren-sprite{
  background-image:var(--battle-character-image,url("../assets/playable-characters/ren/battle/ren-back-idle-v1.png"))!important;
  background-size:auto 180%!important;
  background-position:center 12%!important;
  background-repeat:no-repeat!important;
}

/* コマンドは参考画像の大判タイル表現。機能とdata-actionは既存のまま。 */
#game .command-panel{gap:5px}
#game .command-panel button{min-height:66px;border:1px solid #745a48;background:linear-gradient(145deg,#080a10,#020408);box-shadow:inset 0 0 0 2px #141015}
#game .command-panel button i{width:28px;height:25px;margin:0 auto 3px;transform:none;background:none;box-shadow:none;color:#bfc2ca;font:900 23px/1 Cinzel}
#game .command-panel button i::before{content:"◆"}
#game .command-panel button[data-action="attack"] i::before{content:"⚔"}
#game .command-panel button[data-action="weaponArts"] i::before{content:"♪"}
#game .command-panel button[data-action="mainCmd"] i::before,#game .command-panel button[data-action="personal"] i::before{content:"✦"}
#game .command-panel button[data-action="resonance"] i::before{content:"◈"}
#game .command-panel button[data-action="item"] i::before{content:"♙"}
#game .command-panel button[data-action="escape"] i::before{content:"↗"}
#game .command-panel button[data-action="attack"]{border-color:#b62844;background:radial-gradient(circle at 50% 25%,#74152f,#10060b 65%);box-shadow:inset 0 0 16px #e61d4940,0 0 7px #e61d4928}
#game .command-panel button[data-action="attack"] i{color:#f2d9df}
#game .command-panel button strong{font-size:12px}
#game .command-panel button span{font-size:7px;color:#be75e9}

/* HTMLモックを既存の戦闘DOMへ接続した最終レイアウト。
   ダンジョン背景・敵スプライト・戦闘処理はすべて従来のライブ要素を使う。 */
#game.game-shell{
  --battle-gold:#b79a64;
  --battle-red:#e13a5a;
  --battle-blue:#258dff;
  --battle-purple:#9d55e8;
  width:min(480px,100%);
  background:#02030a;
}

#game .battlefield{
  height:610px;
  min-height:610px;
  max-height:610px;
  border:0;
  border-bottom:1px solid color-mix(in srgb,var(--character-border) 65%,var(--battle-gold));
}
#game .battlefield::before{
  background:
    linear-gradient(180deg,#01020a26 0 56%,#02030a8f 76%,#02030ae8 100%),
    radial-gradient(circle at 50% 22%,color-mix(in srgb,var(--character-glow) 32%,transparent),transparent 43%);
}

.battle-topbar{inset:max(10px,env(safe-area-inset-top)) 10px auto}
.battle-topbar .turn-info,
.battle-menu-button,
#game .enemy-nameplate,
#game .enemy-hud,
#game .player-card,
.battle-assists button,
#game .command-panel button,
#game .battle-log{
  border-color:color-mix(in srgb,var(--battle-gold) 62%,var(--character-border));
  box-shadow:inset 0 0 0 2px #17131d,0 5px 16px #000a;
}
.battle-topbar .turn-info{width:84px;min-height:76px;padding:8px 7px}
.battle-topbar .turn-info span{color:var(--character-text-accent);font-size:7px}
.battle-topbar .turn-info b{font-size:15px}
.battle-menu-button{min-width:96px;padding:11px 14px;background:linear-gradient(180deg,#0a090e,#030409f2)}

#game .combatants{inset:70px 0 0}
#game .enemies{inset:18px 2.5% auto;width:95%;height:53%;gap:2px}
#game .enemy{flex:1 1 0;width:33.333%;height:100%}
#game .enemy:nth-child(2){--enemy-scale:1.12}
#game .enemy-nameplate{
  width:min(124%,164px);
  min-height:55px;
  padding:8px 5px 6px;
  background:linear-gradient(180deg,#0c0a13f3,#04050bf1);
}
#game .enemy-nameplate>span{font-size:10px;line-height:1.25}
#game .enemy-nameplate .enemy-statuses{min-height:20px;margin-top:4px}
#game .enemy-visual{inset:57px 0 31px}
#game .enemy .slime{width:min(40vw,158px);height:min(40vw,158px)}
#game .enemy-hud,#game .boss-enemy .enemy-hud{
  width:min(112%,150px);
  min-height:36px;
  padding:5px 7px 4px;
  background:linear-gradient(105deg,#05060ced,#090914ed);
}
#game .enemy-hud label{color:#ead8df;font-size:7px}
#game .enemy-hud .enemy-hp-meter{height:7px;border-color:#673044}
#game .enemy-hud small{font-size:7px}

/* 参考画像と同じ、敵の下に半身の後ろ姿＋右側ステータス。 */
#game .ren{
  left:var(--battle-character-left,-20px);
  bottom:var(--battle-character-bottom,-52px);
  width:var(--battle-character-width,214px);
  height:var(--battle-character-height,278px)
}
#game .ren-sprite{
  background-image:var(--battle-character-image,url("../assets/playable-characters/ren/battle/ren-back-idle-v1.png"))!important;
  background-size:var(--battle-character-size,auto 178%)!important;
  background-position:var(--battle-character-position,center 12%)!important;
  mix-blend-mode:var(--battle-character-blend,normal);
  filter:drop-shadow(0 6px 3px #000c) drop-shadow(0 0 7px var(--character-glow));
}
#game .ren-shadow{display:none}
#game .player-card{
  right:8px;
  bottom:65px;
  width:59%;
  max-width:280px;
  min-height:126px;
  padding:10px 10px 9px 13px;
  background:linear-gradient(115deg,#05060df5,#070b14f2);
}
#game .player-meta{grid-template-columns:auto minmax(0,1fr);margin-bottom:5px}
#game .player-meta strong{font-size:18px;color:#f4f0f3}
#game .player-meta span{font-size:8px;color:#dfd6e2}
#game .meter-row{grid-template-columns:20px 1fr 60px;gap:4px;margin:4px 0}
#game .meter-row output{font-size:7px;color:#f3edf5}
#game .meter{height:8px}
#game .xp-row{margin-top:7px;gap:7px}
#game .xp-cell .meter{height:13px}
#game .xp-cell:first-child .meter i{background:linear-gradient(90deg,#c68418,#ffd761)}
#game .xp-cell:last-child .meter i{background:linear-gradient(90deg,#7c2ac8,var(--character-primary))}
#game .player-statuses{min-height:18px}

#game .battle-console{
  position:relative;
  gap:6px;
  padding:8px 10px max(10px,env(safe-area-inset-bottom));
  background:linear-gradient(180deg,#06070d,#010207);
  border-top-color:color-mix(in srgb,var(--character-border) 60%,var(--battle-gold));
}
.battle-assists{
  position:absolute;
  z-index:8;
  right:8px;
  top:-55px;
  width:59%;
  max-width:280px;
  gap:5px;
}
.battle-assists button{min-height:42px;padding:3px 7px;background:linear-gradient(110deg,#080c13,#03050a)}
.battle-assists button>b{font-size:17px}
.battle-assists button span{font-size:9px;line-height:1.05}
.battle-assists button small{font-size:6px}
.battle-assists button:active,.battle-assists button:focus-visible{
  outline:0;border-color:var(--character-primary);box-shadow:inset 0 0 14px color-mix(in srgb,var(--character-glow) 36%,transparent);
}
.command-heading{display:none}

/* メインだけ参考画像の4＋2構成。技・アイテム選択画面は3列を維持する。 */
#game .command-panel{grid-template-columns:repeat(3,minmax(0,1fr));gap:5px}
#game .command-panel[data-layout="main"]{grid-template-columns:repeat(4,minmax(0,1fr))}
#game .command-panel button{
  min-width:0;
  min-height:62px;
  padding:8px 3px 7px;
  background:linear-gradient(180deg,#0b0a11,#030409);
  clip-path:polygon(6px 0,100% 0,calc(100% - 6px) 100%,0 100%);
}
#game .command-panel[data-layout="main"]>button:nth-child(-n+4){min-height:76px}
#game .command-panel[data-layout="main"]>button:nth-last-child(-n+2){
  grid-column:span 2;
  min-height:42px;
  display:grid;
  grid-template-columns:28px minmax(0,1fr);
  grid-template-rows:auto auto;
  align-content:center;
  align-items:center;
  column-gap:7px;
  padding:5px 12px;
  text-align:left;
}
#game .command-panel[data-layout="main"]>button:nth-last-child(-n+2) i{grid-row:1/3;grid-column:1;margin:auto}
#game .command-panel[data-layout="main"]>button:nth-last-child(-n+2) strong,
#game .command-panel[data-layout="main"]>button:nth-last-child(-n+2) span{grid-column:2;margin:0;text-align:left}
#game .command-panel button i{width:30px;height:27px;margin:0 auto 3px;color:#c5c6ce;font-size:24px}
#game .command-panel button strong{font-size:11px;line-height:1.15}
#game .command-panel button span{font-size:6.5px;color:#c08ce8;letter-spacing:.08em}
#game .command-panel button:hover,
#game .command-panel button:active,
#game .command-panel button:focus-visible{
  transform:none;
  outline:0;
  border-color:var(--character-text-accent);
  box-shadow:inset 0 0 18px color-mix(in srgb,var(--character-glow) 30%,transparent),0 0 9px color-mix(in srgb,var(--character-glow) 26%,transparent);
}

/* 種類の色は固定し、選択時の縁取りだけメンバーのテーマ色にする。 */
#game .command-panel button[data-tone="attack"]{
  border-color:var(--command-tone-border,#b32643);background:radial-gradient(circle at 50% 24%,var(--command-tone-bg,#78142f),#10050a 66%);
}
#game .command-panel button[data-tone="attack"] i,#game .command-panel button[data-tone="attack"] span{color:var(--command-tone-glow,#ff6b87)}
#game .command-panel button[data-tone="weapon"]{
  border-color:var(--command-tone-border,#275fa5);background:radial-gradient(circle at 50% 24%,var(--command-tone-bg,#123f7c),#040914 68%);
}
#game .command-panel button[data-tone="weapon"] i,#game .command-panel button[data-tone="weapon"] span{color:var(--command-tone-glow,#5eb9ff)}
#game .command-panel button[data-tone="skill"]{
  border-color:var(--command-tone-border,#69409b);background:radial-gradient(circle at 50% 24%,var(--command-tone-bg,#402069),#090611 68%);
}
#game .command-panel button[data-tone="skill"] i,#game .command-panel button[data-tone="skill"] span{color:var(--command-tone-glow,#ca87ff)}
#game .command-panel button[data-tone="guard"]{
  border-color:var(--command-tone-border,#a9adb8);background:radial-gradient(circle at 50% 24%,var(--command-tone-bg,#3d414a),#08090d 68%);
}
#game .command-panel button[data-tone="guard"] i,#game .command-panel button[data-tone="guard"] span{color:var(--command-tone-glow,#f1f4fb)}
#game .command-panel button[data-tone="item"] i,#game .command-panel button[data-tone="item"] span{color:var(--command-tone-glow,#78d6bb)}
#game .command-panel button[data-action="weaponArts"] i::before{content:"♪"}
#game .command-panel button[data-action="skills"] i::before{content:"✦"}
#game .command-panel button[data-action="guard"] i::before{content:"◇"}
#game .command-panel button[data-action="item"] i::before{content:"⚗"}
#game .command-panel button[data-tone="guard"] i::before{content:"◇"}

#game .battle-log{
  min-height:82px;
  max-height:104px;
  padding:19px 10px 7px;
  background:linear-gradient(180deg,#04050a,#010207);
}
#game .battle-log>small{top:6px;left:10px;color:#ef637a}
#game .battle-log p{font-size:9px;line-height:1.35}
#game .battle-log-lines p:nth-last-child(1){color:var(--character-text-accent)}

@media(max-width:390px){
  #game .battlefield{height:580px;min-height:580px;max-height:580px}
  #game .ren{left:var(--battle-character-left,-20px);bottom:var(--battle-character-bottom,-50px);width:var(--battle-character-width,204px);height:var(--battle-character-height,266px)}
  #game .player-card{right:6px;bottom:60px;width:59%;padding-left:10px}
  .battle-assists{right:6px;top:-51px;width:59%}
  .battle-assists button{min-height:38px;padding-inline:4px}
  #game .command-panel button{min-height:60px}
  #game .command-panel[data-layout="main"]>button:nth-child(-n+4){min-height:72px}
  #game .command-panel[data-layout="main"]>button:nth-last-child(-n+2){min-height:40px}
  #game .command-panel button strong{font-size:10px}
}
@media(max-height:720px){
  #game .battlefield{height:540px;min-height:540px;max-height:540px}
  #game .ren{bottom:var(--battle-character-bottom,-44px);width:var(--battle-character-width,192px);height:var(--battle-character-height,248px)}
  #game .player-card{bottom:56px}
  .battle-assists{top:-49px}
  .battle-assists button{min-height:36px}
}

/* メインコマンド専用の線画アイコン。フレームはそのまま、武器種だけライブで差し替える。 */
#game .command-panel i.command-icon-svg::before{content:none!important}
#game .command-panel i.command-icon-svg{
  display:grid;
  place-items:center;
  width:34px;
  height:31px;
  color:inherit;
  filter:drop-shadow(0 0 3px currentColor);
}
#game .command-panel i.command-icon-svg svg{
  width:100%;
  height:100%;
  overflow:visible;
  pointer-events:none;
}
#game .command-panel i.command-icon-svg svg g{
  fill:none;
  stroke:currentColor;
  stroke-width:2.15;
  stroke-linecap:round;
  stroke-linejoin:round;
}
#game .command-panel i.command-icon-svg .icon-fill{
  fill:currentColor;
  fill-opacity:.19;
  stroke:currentColor;
  stroke-width:1.35;
}
#game .command-panel button:active i.command-icon-svg,
#game .command-panel button:focus-visible i.command-icon-svg{
  filter:drop-shadow(0 0 6px currentColor);
}
#game .command-panel button:disabled i.command-icon-svg{filter:none;opacity:.42}
#game .command-panel[data-layout="main"]>button:nth-last-child(-n+2) i.command-icon-svg{
  width:29px;
  height:27px;
}

/* 設定資料のアイコン集を3×2のスプライトとして使用。未登録武器はSVGへ自動フォールバック。 */
#game .command-panel i.command-icon-art::before{content:none!important}
#game .command-panel i.command-icon-art{
  display:block;
  inset:auto!important;
  width:var(--command-icon-width,40px);
  height:var(--command-icon-height,27px);
  margin:0 auto 5px;
  background-image:var(--command-icon-image);
  background-repeat:no-repeat;
  background-size:var(--command-icon-sheet-width,120px) var(--command-icon-sheet-height,80px);
  background-position:var(--command-icon-x,0px) var(--command-icon-y,0px);
  filter:var(--command-icon-filter,drop-shadow(0 0 4px currentColor));
}
#game .command-panel i.command-icon-svg{inset:auto!important}
#game .command-panel button:disabled i.command-icon-art{filter:none;opacity:.42}
#game .command-panel[data-layout="main"]>button:nth-last-child(-n+2) i.command-icon-art{width:var(--command-icon-width,40px);height:var(--command-icon-height,27px);margin:0}

/* 生成した下半分プレートを、各ライブUIのフレームとして実際に使用する。 */
#game .player-card,
#game .battle-assists button,
#game .command-panel[data-layout="main"]>button,
#game .battle-log{
  position:relative;
  overflow:hidden;
  isolation:isolate;
  clip-path:none;
  border-color:transparent;
  background:#020309;
}
#game .player-card{position:absolute}
#game .player-card::before,
#game .battle-assists button::before,
#game .command-panel[data-layout="main"]>button::before,
#game .battle-log::before{
  content:"";
  position:absolute;
  z-index:0;
  pointer-events:none;
  background:url("../assets/ui/battle/battle-lower-ui-plate-v1.png") 0 0/100% 100% no-repeat;
}
#game .player-card>* ,
#game .battle-assists button>* ,
#game .command-panel[data-layout="main"]>button>* ,
#game .battle-log>*{position:relative;z-index:1}

/* 元画像上の各フレーム領域をCSSで切り出す。ダンジョン背景と敵は従来どおりライブ表示。 */
#game .player-card::before{width:189.33%;height:615.33%;left:-88.44%;top:-90%}
#game .battle-assists button:first-child::before{width:430.3%;height:1963.8%;left:-212.1%;top:-617%}
#game .battle-assists button:last-child::before{width:415.6%;height:1963.8%;left:-306.3%;top:-617%}
#game .command-panel[data-layout="main"]>button:nth-child(1)::before{width:421.8%;height:762.8%;left:-9.4%;top:-301.7%}
#game .command-panel[data-layout="main"]>button:nth-child(2)::before{width:411.6%;height:762.8%;left:-105.3%;top:-301.7%}
#game .command-panel[data-layout="main"]>button:nth-child(3)::before{width:419.7%;height:762.8%;left:-208.4%;top:-301.7%}
#game .command-panel[data-layout="main"]>button:nth-child(4)::before{width:396.3%;height:762.8%;left:-289.3%;top:-301.7%}
#game .command-panel[data-layout="main"]>button:nth-child(5)::before{width:209.3%;height:802.6%;left:-4.67%;top:-420%}
#game .command-panel[data-layout="main"]>button:nth-child(6)::before{width:205.8%;height:802.6%;left:-102.2%;top:-420%}
#game .battle-log::before{width:101.9%;height:459.2%;left:-.96%;top:-298%}

/* 技・魔法・アイテムだけ、横長リストを同じ枠内で縦スクロールする。 */
#game .command-panel[data-layout="list"]{
  display:flex;
  flex-direction:column;
  gap:4px;
  box-sizing:border-box;
  height:118px;
  padding:4px;
  overflow-x:hidden;
  overflow-y:auto;
  overscroll-behavior:contain;
  scrollbar-width:thin;
  scrollbar-color:var(--character-primary) #05050a;
  -webkit-overflow-scrolling:touch;
  background:linear-gradient(180deg,#07070e,#010207);
  border:1px solid #76563d;
}
#game .command-panel[data-layout="list"]>button{
  flex:0 0 auto;
  width:100%;
  min-height:61px;
  display:grid;
  grid-template-columns:42px minmax(0,1fr) auto;
  grid-template-rows:auto auto;
  gap:1px 8px;
  align-items:center;
  padding:7px 9px;
  text-align:left;
  clip-path:none;
  border:1px solid color-mix(in srgb,currentColor 48%,#3e3341);
  background:linear-gradient(100deg,#100a13,#04050a 72%);
}
#game .command-panel[data-layout="list"]>button i{
  grid-column:1;
  grid-row:1/3;
  width:35px;
  height:33px;
  margin:auto;
}
#game .command-panel[data-layout="list"]>button strong{
  grid-column:2;
  grid-row:1;
  align-self:end;
  font-size:11px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
#game .command-panel[data-layout="list"]>button span{
  grid-column:3;
  grid-row:1;
  align-self:end;
  color:currentColor;
  font-size:7px;
  white-space:nowrap;
}
#game .command-panel[data-layout="list"]>button em{
  grid-column:2/4;
  grid-row:2;
  display:-webkit-box;
  overflow:hidden;
  color:#c8c0ca;
  font-size:7px;
  font-style:normal;
  line-height:1.25;
  -webkit-box-orient:vertical;
  -webkit-line-clamp:2;
}
#game .command-panel[data-layout="list"]>button[data-action="back"]{
  position:sticky;
  z-index:5;
  top:0;
  min-height:31px;
  grid-template-columns:1fr auto;
  grid-template-rows:1fr;
  padding:4px 10px;
  border-color:#80504f;
  background:linear-gradient(90deg,#250911,#080408);
}
#game .command-panel[data-layout="list"]>button[data-action="back"] strong{grid-column:1;grid-row:1;align-self:center}
#game .command-panel[data-layout="list"]>button[data-action="back"] span{grid-column:2;grid-row:1;align-self:center;color:#e47483}
#game .command-panel[data-layout="list"]>button[data-action="back"] i{display:none}

/* たたかう後：もどる＋敵A/B/Cを1列で選択。 */
#game .command-panel[data-layout="targets"]{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:5px;
}
#game .command-panel[data-layout="targets"]>button{
  min-height:55px;
  padding:6px 3px;
  clip-path:none;
}
#game .command-panel[data-layout="targets"]>button i{display:none}
#game .command-panel[data-layout="targets"]>button strong{display:block;font:900 17px/1 Cinzel}
#game .command-panel[data-layout="targets"]>button span{display:block;margin-top:5px;font-size:6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#game .command-panel[data-layout="targets"]>button[data-action="back"] strong{font-weight:800;font-size:9px;line-height:1.2}
#game .enemy.targetable>.enemy-nameplate,
#game .enemy-nameplate.targetable-nameplate{
  cursor:pointer;
  border-color:#62dcff;
  box-shadow:0 0 13px #35c7ff9c,inset 0 0 12px #1a76a955;
  animation:targetPlatePulse 1.15s ease-in-out infinite;
}
#game .enemy.targetable>.enemy-nameplate::after{
  content:"TAP";
  position:absolute;
  right:5px;
  bottom:2px;
  color:#76e8ff;
  font:800 5px Cinzel;
  letter-spacing:.12em;
}
@keyframes targetPlatePulse{50%{filter:brightness(1.3);box-shadow:0 0 18px #35c7ffcc,inset 0 0 15px #1a76a977}}

@media(max-width:390px){
  #game .command-panel[data-layout="list"]{height:118px}
  #game .command-panel[data-layout="list"]>button{min-height:59px}
  #game .command-panel[data-layout="targets"]>button{min-height:51px}
}

/* 技選択時はステータスの上から画面下まで、大型の右ドロワーを展開する。 */
#game .command-drawer[hidden]{display:none!important}
#game .command-drawer{
  position:absolute;
  z-index:35;
  right:5px;
  bottom:5px;
  width:61%;
  max-width:292px;
  display:flex;
  flex-direction:column;
  gap:5px;
  padding:7px;
  overflow-x:hidden;
  overflow-y:auto;
  overscroll-behavior:contain;
  scrollbar-width:thin;
  scrollbar-color:var(--character-primary) #05050a;
  -webkit-overflow-scrolling:touch;
  background:linear-gradient(145deg,#08050df8,#010207fc 68%);
  border:1px solid #84603d;
  box-shadow:0 0 0 2px #130d10,0 0 26px #000,inset 0 0 22px #25122d8c;
}
#game .command-drawer::before,
#game .command-drawer::after{
  content:"";
  position:sticky;
  z-index:7;
  display:block;
  flex:0 0 1px;
  width:100%;
  pointer-events:none;
  background:linear-gradient(90deg,transparent,#a87842,transparent);
  box-shadow:0 0 8px #7a3aa47d;
}
#game .command-drawer::before{top:0}
#game .command-drawer::after{bottom:0}
#game .command-drawer>button{
  position:relative;
  flex:0 0 auto;
  width:100%;
  min-height:67px;
  display:grid;
  grid-template-columns:43px minmax(0,1fr) auto;
  grid-template-rows:auto auto;
  gap:2px 8px;
  align-items:center;
  padding:8px 9px;
  overflow:hidden;
  color:#d9d4dd;
  text-align:left;
  border:1px solid #71414d;
  border-radius:0;
  background:linear-gradient(100deg,#19090f,#06050a 72%);
  box-shadow:inset 0 0 12px #6c173020;
}
#game .command-drawer>button::after{
  content:"";
  position:absolute;
  inset:3px;
  pointer-events:none;
  border:1px solid #7e405134;
}
#game .command-drawer>button i{
  position:static;
  grid-column:1;
  grid-row:1/3;
  width:36px;
  height:34px;
  margin:auto;
  color:currentColor;
  transform:none;
  background:none;
  box-shadow:none;
}
#game .command-drawer>button i::before{content:"◆"}
#game .command-drawer>button i.command-icon-svg::before{content:none!important}
#game .command-drawer>button i.command-icon-svg svg{width:100%;height:100%;overflow:visible;pointer-events:none}
#game .command-drawer>button i.command-icon-svg svg g{fill:none;stroke:currentColor;stroke-width:2.15;stroke-linecap:round;stroke-linejoin:round}
#game .command-drawer>button i.command-icon-svg .icon-fill{fill:currentColor;fill-opacity:.19;stroke:currentColor;stroke-width:1.35}
#game .command-drawer>button strong{
  grid-column:2;
  grid-row:1;
  align-self:end;
  min-width:0;
  overflow:hidden;
  color:#f1edf3;
  font-size:12px;
  white-space:nowrap;
  text-overflow:ellipsis;
}
#game .command-drawer>button span{
  grid-column:3;
  grid-row:1;
  align-self:end;
  color:currentColor;
  font:700 7px Cinzel;
  white-space:nowrap;
}
#game .command-drawer>button em{
  grid-column:2/4;
  grid-row:2;
  display:-webkit-box;
  overflow:hidden;
  color:#c9c0ca;
  font-size:7px;
  font-style:normal;
  line-height:1.3;
  -webkit-box-orient:vertical;
  -webkit-line-clamp:2;
}
#game .command-drawer>button[data-tone="weapon"]{color:#64bfff;border-color:#285c94;background:linear-gradient(100deg,#07152b,#03050a 72%)}
#game .command-drawer>button[data-tone="skill"]{color:#d18bff;border-color:#70429c;background:linear-gradient(100deg,#190a28,#05040a 72%)}
#game .command-drawer>button[data-tone="item"]{color:#72d9b9;border-color:#317c68;background:linear-gradient(100deg,#071b17,#030709 72%)}
#game .command-drawer>button:disabled{filter:grayscale(.65);opacity:.43}
#game .command-drawer>button:active,#game .command-drawer>button:focus-visible{outline:0;filter:brightness(1.3);box-shadow:inset 0 0 18px currentColor,0 0 8px currentColor}
#game .command-drawer>button[data-action="back"]{
  position:sticky;
  z-index:9;
  top:0;
  min-height:38px;
  grid-template-columns:1fr auto;
  grid-template-rows:1fr;
  padding:5px 10px;
  color:#ef7c8c;
  border-color:#91374a;
  background:linear-gradient(90deg,#300914,#080408);
}
#game .command-drawer>button[data-action="back"] i{display:none}
#game .command-drawer>button[data-action="back"] strong{grid-column:1;grid-row:1;align-self:center}
#game .command-drawer>button[data-action="back"] span{grid-column:2;grid-row:1;align-self:center}
#game .command-panel.drawer-open{filter:brightness(.58) saturate(.55)}

@media(max-width:390px){
  #game .command-drawer{right:4px;bottom:4px;width:62%;padding:6px}
  #game .command-drawer>button{min-height:64px;padding:7px}
}

/* 2026-08-24: 設定資料のTURN / MENU / 敵名フレームをライブUIへ接続。 */
.battle-topbar .turn-info{
  position:relative;width:74px;min-height:92px;padding:11px 8px 10px;overflow:hidden;
  border:0;clip-path:none;background:url("../assets/ui/battle/turn-wave-panel-v1.png") center/100% 100% no-repeat;box-shadow:none;
}
.battle-topbar .turn-info::before{content:"";position:absolute;z-index:0;inset:7px 8px 8px;background:linear-gradient(180deg,#06050af7,#010207 56%,#07050bf5)}
.battle-topbar .turn-info>*{position:relative;z-index:1}
.battle-topbar .turn-info span{font-size:7px;color:#e6d8ff}
.battle-topbar .turn-info b{font-size:16px;line-height:1.05}
.battle-topbar .turn-info small{font-size:7px}
.battle-menu-button{
  width:98px;min-width:98px;height:34px;min-height:34px;padding:0;overflow:hidden;border:0;clip-path:none;
  background:url("../assets/ui/battle/menu-button-v1.png") center/100% 100% no-repeat;box-shadow:none;color:transparent;font-size:0;
}
.battle-menu-button i{display:none}

/* 390〜393pxで3枚＋gapを95%以内へ収める。1・2体時は中央配置。 */
#game .enemies{left:10px;right:10px;width:auto;gap:8px;justify-content:center;translate:0}
#game .enemy{flex:1 1 calc((100% - 16px)/3);width:calc((100% - 16px)/3);min-width:0;max-width:120px}
#game .enemy[data-size="boss"]{width:100%;max-width:none;flex-basis:100%}
#game .enemy-nameplate{
  box-sizing:border-box;left:0;top:0;translate:0;width:100%;max-width:120px;height:48px;min-height:48px;
  padding:3px 7px 2px;display:grid;grid-template-rows:24px 19px;align-content:center;overflow:hidden;
  border:0;clip-path:none;background:url("../assets/ui/battle/enemy-nameplate-v1.png") center/100% 100% no-repeat;box-shadow:none;
}
#game .enemy-nameplate::before{
  content:"";position:absolute;z-index:0;inset:6px 6px 5px;
  background:linear-gradient(90deg,#0a0914f7 0,#03030afc 28%,#000 50%,#03030afc 72%,#0a0914f7 100%);
}
#game .enemy-nameplate::after{
  content:"";position:absolute;z-index:1;left:9px;right:9px;top:28px;height:1px;
  background:linear-gradient(90deg,transparent,#8d6a37 14%,#7d45a8 50%,#8d6a37 86%,transparent);box-shadow:0 0 3px #7c36bd88;
}
#game .enemy-nameplate>span,#game .enemy-nameplate .enemy-statuses{position:relative;z-index:2}
#game .enemy-nameplate>span{align-self:center;font-size:13px;line-height:1;font-weight:900}
#game .enemy-nameplate>span small{display:none}
#game .enemy-nameplate .enemy-statuses{min-height:19px;height:19px;margin:1px auto 0;gap:2px;align-items:center;overflow:hidden}
#game .enemy-nameplate .status-chip{box-sizing:border-box;width:22px;min-width:22px;max-width:24px;height:22px;padding:2px;font-size:6px;line-height:16px}
#game .boss-enemy .enemy-nameplate{left:50%;translate:-50%;width:min(210px,70vw);max-width:210px}
#game .enemy-visual{inset:49px 0 31px}

/* 個別武器画像。白背景素材はJSで外周連結部分だけ透過してから表示する。 */
#game .command-panel i.command-icon-image,#game .command-drawer i.command-icon-image{
  display:block;position:relative;inset:auto!important;width:40px;height:31px;margin:0 auto 3px;
  background-image:var(--command-icon-image);background-position:center;background-size:contain;background-repeat:no-repeat;
  filter:var(--command-icon-filter,drop-shadow(0 0 4px currentColor));
}
#game .command-panel i.command-icon-image::before,#game .command-drawer i.command-icon-image::before{content:none!important}
#game .command-panel[data-layout="main"]>button:nth-last-child(-n+2) i.command-icon-image{width:38px;height:29px;margin:0}

@media(max-width:393px){
  .battle-topbar{left:8px;right:8px}
  #game .enemies{left:10px;right:10px;gap:8px}
  #game .enemy-nameplate{height:48px;min-height:48px}
}

/* 2026-08-24 final mobile layout: 戦場を主役にし、操作8枠を4×2へ統合。 */
#game.game-shell{width:min(430px,100%)}
#game .battlefield{height:600px;min-height:600px;max-height:600px}
#game .player-card{right:8px;bottom:12px;width:59%;max-width:254px}
#game .ren{bottom:var(--battle-character-bottom,-48px)}
#game .battle-console{gap:7px;padding:8px 8px max(9px,env(safe-area-inset-bottom))}
#game .command-panel[data-layout="main"]{grid-template-columns:repeat(4,minmax(0,1fr));gap:5px}
#game .command-panel[data-layout="main"]>button,
#game .command-panel[data-layout="main"]>button:nth-child(-n+4),
#game .command-panel[data-layout="main"]>button:nth-last-child(-n+2){
  grid-column:auto;min-width:0;min-height:60px;height:60px;display:block;padding:5px 2px 4px;text-align:center;
}
#game .command-panel[data-layout="main"]>button i,
#game .command-panel[data-layout="main"]>button:nth-last-child(-n+2) i,
#game .command-panel[data-layout="main"]>button:nth-last-child(-n+2) i.command-icon-image{
  display:block;grid-row:auto;grid-column:auto;width:31px;height:27px;margin:0 auto 2px;
}
#game .command-panel[data-layout="main"]>button strong,
#game .command-panel[data-layout="main"]>button span,
#game .command-panel[data-layout="main"]>button:nth-last-child(-n+2) strong,
#game .command-panel[data-layout="main"]>button:nth-last-child(-n+2) span{
  display:block;grid-column:auto;margin:0;overflow:hidden;text-align:center;white-space:nowrap;text-overflow:ellipsis;
}
#game .command-panel[data-layout="main"]>button strong{font-size:9px;line-height:1.12}
#game .command-panel[data-layout="main"]>button span{margin-top:2px;font-size:5.5px;line-height:1}
#game .command-panel button[data-tone="simple"]{border-color:#347e9e;background:radial-gradient(circle at 50% 24%,#123d55,#03080d 68%)}
#game .command-panel button[data-tone="simple"] i,#game .command-panel button[data-tone="simple"] span{color:#6ce4ff}
#game .command-panel button[data-tone="auto"]{border-color:#4d4434;background:radial-gradient(circle at 50% 24%,#282215,#060604 68%)}
#game .command-panel button[data-tone="auto"] i,#game .command-panel button[data-tone="auto"] span{color:#9f947a}
#game .command-panel button[data-action="autoBattle"].active{border-color:#d6aa4b;background:radial-gradient(circle at 50% 24%,#745017,#140d03 70%);box-shadow:inset 0 0 16px #e8aa3d55,0 0 8px #d9a43866}
#game .command-panel button[data-action="autoBattle"].active i,#game .command-panel button[data-action="autoBattle"].active span{color:#ffdb73;filter:drop-shadow(0 0 4px #e9a92d)}
#game .command-panel button[data-action="simpleBattle"].active{border-color:#56cbe7;box-shadow:inset 0 0 14px #40c8e744,0 0 7px #38bddf55}
#game .battle-log{min-height:62px;max-height:76px;padding:18px 9px 6px}
#game .battle-log-lines{max-height:43px;overflow:hidden}
#game .battle-log p{font-size:8px;line-height:1.3}

@media(max-width:393px){
  #game .battlefield{height:590px;min-height:590px;max-height:590px}
  #game .player-card{right:6px;bottom:10px;width:59%}
  #game .command-panel[data-layout="main"]>button,
  #game .command-panel[data-layout="main"]>button:nth-child(-n+4),
  #game .command-panel[data-layout="main"]>button:nth-last-child(-n+2){min-height:57px;height:57px}
}
@media(max-height:720px){
  #game .battlefield{height:530px;min-height:530px;max-height:530px}
  #game .player-card{bottom:8px}
  #game .ren{bottom:var(--battle-character-bottom,-42px)}
  #game .command-panel[data-layout="main"]>button,
  #game .command-panel[data-layout="main"]>button:nth-child(-n+4),
  #game .command-panel[data-layout="main"]>button:nth-last-child(-n+2){min-height:54px;height:54px}
  #game .battle-log{min-height:58px;max-height:68px}
}

/* Cascade lock: この圧縮値をバトルUIの最終仕様として固定する。 */
#game .player-card{bottom:2px}
#game .battle-console{gap:2px;padding:3px 8px max(7px,env(safe-area-inset-bottom))}
#game .command-panel[data-layout="main"]{column-gap:5px;row-gap:3px}
#game .command-panel[data-layout="main"]>button:nth-child(n+5),
#game .command-panel[data-layout="main"]>button:nth-last-child(-n+2){
  min-height:31px;height:31px;display:grid;grid-template-columns:21px minmax(0,1fr);grid-template-rows:1fr 1fr;
  align-items:center;column-gap:3px;padding:2px 3px;text-align:left;
}
#game .command-panel[data-layout="main"]>button:nth-child(n+5) i,
#game .command-panel[data-layout="main"]>button:nth-child(n+5) i.command-icon-image,
#game .command-panel[data-layout="main"]>button:nth-last-child(-n+2) i,
#game .command-panel[data-layout="main"]>button:nth-last-child(-n+2) i.command-icon-image{
  display:block;grid-column:1;grid-row:1/3;width:20px;height:20px;margin:auto;
}
#game .command-panel[data-layout="main"]>button:nth-child(n+5) strong,
#game .command-panel[data-layout="main"]>button:nth-child(n+5) span,
#game .command-panel[data-layout="main"]>button:nth-last-child(-n+2) strong,
#game .command-panel[data-layout="main"]>button:nth-last-child(-n+2) span{
  grid-column:2;min-width:0;margin:0;text-align:left;
}
#game .command-panel[data-layout="main"]>button:nth-child(n+5) strong,
#game .command-panel[data-layout="main"]>button:nth-last-child(-n+2) strong{grid-row:1;align-self:end;font-size:8px;line-height:1}
#game .command-panel[data-layout="main"]>button:nth-child(n+5) span,
#game .command-panel[data-layout="main"]>button:nth-last-child(-n+2) span{grid-row:2;align-self:start;margin-top:1px;font-size:4.5px;line-height:1}
#game .battle-log{margin-top:0;min-height:58px;max-height:70px}

@media(max-width:393px){
  #game .player-card{bottom:1px}
  #game .battle-console{padding-top:2px}
  #game .command-panel[data-layout="main"]>button:nth-child(n+5),
  #game .command-panel[data-layout="main"]>button:nth-last-child(-n+2){min-height:29px;height:29px}
}
@media(max-height:720px){
  #game .player-card{bottom:0}
  #game .command-panel[data-layout="main"]>button:nth-child(n+5),
  #game .command-panel[data-layout="main"]>button:nth-last-child(-n+2){min-height:28px;height:28px}
}

/* 共通「武器技」カード。装備ごとの差はタップ後の技一覧で反映する。 */
#game .command-panel[data-layout="main"]>button[data-action="weaponArts"]{
  background-image:url("../assets/ui/battle/lower-ui-v2/command-weapon-v3.png")!important;
  background-size:100% 100%!important;
  background-position:center!important;
}
#game .command-panel[data-layout="main"]>button[data-action="weaponArts"]::after{display:none}
#game .command-panel[data-layout="main"]>button[data-action="weaponArts"]>i,
#game .command-panel[data-layout="main"]>button[data-action="weaponArts"]>strong,
#game .command-panel[data-layout="main"]>button[data-action="weaponArts"]>span{opacity:0!important}

/* 下部UI仕上げ: メイン4枠を正方形寄りにし、補助4枠とログの余白を詰める。 */
#game .battle-console{gap:1px;padding-top:2px;padding-bottom:max(6px,env(safe-area-inset-bottom))}
#game .command-panel[data-layout="main"]{row-gap:2px}
#game .command-panel[data-layout="main"]>button:nth-child(-n+4){
  min-height:68px;
  height:68px;
}
#game .command-panel[data-layout="main"]>button:nth-child(n+5),
#game .command-panel[data-layout="main"]>button:nth-last-child(-n+2){
  min-height:34px;
  height:34px;
}
#game .battle-log{
  min-height:56px;
  max-height:68px;
  padding:10px 9px 6px;
}
#game .battle-log-lines{max-height:45px}
@media(max-width:393px){
  #game .command-panel[data-layout="main"]>button:nth-child(-n+4){min-height:66px;height:66px}
  #game .command-panel[data-layout="main"]>button:nth-child(n+5),
  #game .command-panel[data-layout="main"]>button:nth-last-child(-n+2){min-height:33px;height:33px}
}
@media(max-height:720px){
  #game .command-panel[data-layout="main"]>button:nth-child(-n+4){min-height:62px;height:62px}
  #game .command-panel[data-layout="main"]>button:nth-child(n+5),
  #game .command-panel[data-layout="main"]>button:nth-last-child(-n+2){min-height:31px;height:31px}
}
#game .command-panel.turn-locked>button:not([data-action="autoBattle"]){opacity:.45;pointer-events:none;filter:saturate(.55)}
#game .command-panel.turn-locked>button[data-action="autoBattle"]{animation:autoInterruptPulse 1.15s ease-in-out infinite}
@keyframes autoInterruptPulse{50%{filter:brightness(1.34);box-shadow:0 0 12px #e5bb55aa}}

/* 支給されたTURN / WAVEフレーム。文字だけをライブ情報として上から3段で重ねる。 */
.battle-topbar .turn-info{
  width:84px;
  min-width:84px;
  max-width:90px;
  height:140px;
  min-height:140px;
  max-height:150px;
  padding:12px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  text-align:center;
  border:0;
  clip-path:none;
  overflow:hidden;
  background:url("../assets/ui/battle/turn-wave-panel-v2.png") center/100% 100% no-repeat;
  box-shadow:none;
}
.battle-topbar .turn-info::before{display:none}
.battle-topbar .turn-info>*{position:relative;z-index:1;margin:0;align-self:center}
.battle-topbar .turn-info span{font:700 14px/1 Cinzel,serif;letter-spacing:.16em;color:#fff}
.battle-topbar .turn-info span{font-size:12px;margin-bottom:10px}
.battle-topbar .turn-info b{font:700 28px/1 Cinzel,serif;letter-spacing:.03em;color:#fff;margin-bottom:12px}
.battle-topbar .turn-info small{font:700 9px/1 Cinzel,serif;letter-spacing:.03em;color:#fff;white-space:nowrap}
.battle-topbar .turn-info #checkpoint-label{display:none!important}
.battle-topbar{inset:max(14px,env(safe-area-inset-top)) 14px auto}
@media(max-width:393px){.battle-topbar .turn-info{width:84px;min-width:84px;height:140px;min-height:140px}}

/* 敵名プレート: 3体でも画面内へ均等配置。役割色は後から data-kind で追加できる。 */
#game .enemies{left:8px;right:8px;gap:8px;width:auto;justify-content:space-between}
#game .enemy{flex:0 1 145px;width:calc((100% - 16px)/3);max-width:145px}
#game .enemy-nameplate{
  --nameplate-accent:#b861ff;
  width:145px;
  max-width:100%;
  height:34px;
  min-height:34px;
  padding:4px 8px 2px;
  grid-template-rows:16px 10px;
  overflow:visible;
}
#game .enemy[data-kind="boss"] .enemy-nameplate{--nameplate-accent:#ff405a}
#game .enemy[data-kind="rare"] .enemy-nameplate{--nameplate-accent:#ffcf59}
#game .enemy-nameplate::before{box-shadow:inset 0 0 14px color-mix(in srgb,var(--nameplate-accent) 24%,transparent)}
#game .enemy-nameplate::after{left:8px;right:8px;top:20px;background:linear-gradient(90deg,transparent,var(--nameplate-accent) 16%,#fff 50%,var(--nameplate-accent) 84%,transparent);box-shadow:0 0 4px color-mix(in srgb,var(--nameplate-accent) 72%,transparent)}
#game .enemy-nameplate>span{overflow:visible;text-overflow:clip;white-space:nowrap;font-size:13px;font-weight:700;line-height:1;text-align:center;text-shadow:0 1px 2px #0009,0 0 6px color-mix(in srgb,var(--nameplate-accent) 38%,transparent)}
#game .enemy-nameplate>span.long-name{font-size:11px;letter-spacing:-.04em}
#game .enemy-nameplate .enemy-statuses{height:10px;min-height:10px;margin:0;gap:1px}
#game .enemy-nameplate .status-chip{width:10px;min-width:10px;max-width:10px;height:10px;padding:0;font-size:0;line-height:1;border-width:1px}
#game .enemy[data-size="boss"]{flex-basis:100%;max-width:none;width:100%}
#game .boss-enemy .enemy-nameplate{width:min(210px,70vw);max-width:210px;height:42px;min-height:42px;grid-template-rows:22px 12px}
#game .boss-enemy .enemy-nameplate::after{top:27px}
