/* Góc nhìn từ trên xuống: điểm tọa độ là bàn chân, không phải giữa thân. */
body.battle-mode #battle-card .battle-title{max-width:none}
body.battle-mode #battle-card{--battle-height:calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));padding:env(safe-area-inset-top) max(8px,env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px,env(safe-area-inset-left))}
body.battle-mode #battle-card .battle-title{position:absolute;z-index:500;top:env(safe-area-inset-top);left:50%;transform:translateX(-50%);width:min(calc(100% - 16px - env(safe-area-inset-left) - env(safe-area-inset-right)),calc(var(--battle-height) * 16/9));height:40px;min-height:40px;border:0;padding:0 6px;background:linear-gradient(#263b30b3,transparent);pointer-events:none}
body.battle-mode #battle-card .battle-title button{pointer-events:auto}
body.battle-mode #battle-card #battle-beast-element{display:none}
body.battle-mode #battle-card #battle-beast-name{font-size:12px;text-shadow:0 1px 2px #172319}
body.battle-mode #battle-card .battle-scene,
body[data-online=true].battle-mode #battle-card .battle-scene,
body.battle-mode #battle-card.finished .battle-scene,
body[data-online=true].battle-mode #battle-card.finished .battle-scene{width:min(100%,calc(var(--battle-height) * 16/9));height:auto;min-height:0;aspect-ratio:16/9;flex:0 0 auto}
body.battle-mode #battle-card .fighter.hero,
body[data-online=true].battle-mode #battle-card .fighter.hero{
  width:6.8%;height:12.088889%;
}
body.battle-mode #battle-card .fighter.beast,
body[data-online=true].battle-mode #battle-card .fighter.beast,
body.battle-mode #battle-card .fighter.beast.wave-beast,
body[data-online=true].battle-mode #battle-card .fighter.beast.wave-beast{
  width:7%;height:12.444444%;
}
body.battle-mode #battle-card .fighter.beast.elite{width:8.4%;height:14.933333%}
body.battle-mode #battle-card .fighter.beast[data-boss=true]{width:18%;height:32%}
body.battle-mode #battle-card .fighter{
  transform:translate(-50%,-96.484375%);overflow:visible;
}
body.battle-mode #battle-card .fighter .monster-animation{height:100%;object-fit:fill;filter:drop-shadow(0 1px 1px #28362266)}
body.battle-mode #battle-card .fighter>img{object-position:center bottom;filter:drop-shadow(0 1px 1px #28362266)}
body.battle-mode #battle-card .fighter::before{
  content:'';position:absolute;z-index:-1;left:50%;bottom:-3%;width:55%;height:15%;
  transform:translateX(-50%);border-radius:50%;background:radial-gradient(ellipse,#29352b70 0%,#29352b30 48%,transparent 74%);
  filter:none;animation:none;pointer-events:none;
}
body.battle-mode #battle-card .fighter.hero::before{width:38%;height:12%}
body.battle-mode #battle-card .fighter>b{display:none}
body.battle-mode #battle-card .wave-beast .wave-enemy-name{display:none}
body.battle-mode #battle-card .wave-beast .actor-head-up{
  top:-4px;transform:translate(-50%,-100%);width:clamp(78px,8cqw,128px);min-width:0;gap:1px;
}
body.battle-mode #battle-card .actor-head-up strong{
  border:0;background:transparent;color:#fff8df;font-size:clamp(9px,.9cqw,14px);padding:0 2px;
  text-shadow:-1px 0 #293c2a,1px 0 #293c2a,0 -1px #293c2a,0 1px #293c2a;
}
body.battle-mode #battle-card .actor-health-bar{height:clamp(5px,.5cqw,8px);border:1px solid #314230;border-radius:2px;background:#3e3729;width:100%}
body.battle-mode #battle-card .actor-health-value{font-size:clamp(8px,.75cqw,11px);color:#fffbe6;text-shadow:0 1px 2px #101b14}
body.battle-mode #battle-card .arena-vitals{
  top:max(32px,calc(var(--actor-y,50%) - 12.5%));left:clamp(48px,var(--actor-x,50%),calc(100% - 48px));
  width:clamp(94px,9cqw,144px);min-width:0;transform:translate(-50%,-100%);padding:0;gap:1px;border:0;border-radius:0;background:transparent;box-shadow:none;
}
body.battle-mode #battle-card #beast-vitals{top:max(28px,calc(var(--actor-y,50%) - var(--head-height,13%)))}
body.battle-mode #battle-card #beast-vitals[data-boss=true]{top:45px;left:50%;transform:translateX(-50%);width:42%;gap:3px}
body.battle-mode #battle-card #beast-vitals[data-boss=true] strong{font-size:clamp(11px,1cqw,17px);align-self:flex-start}
body.battle-mode #battle-card #beast-vitals[data-boss=true] .actor-health-bar{height:clamp(7px,.7cqw,11px)}
body.battle-mode #battle-card #beast-vitals[data-boss=true] .actor-health-value{position:absolute;right:0;top:0}
body.battle-mode #battle-card .hero-vital-row{gap:3px}
body.battle-mode #battle-card .arena-vitals .actor-health-value,
body.battle-mode #battle-card .arena-vitals .hero-actor-spirit small{font-size:clamp(8px,.75cqw,11px)}
body.battle-mode #battle-card #battle-spirit-bar{height:clamp(5px,.5cqw,8px);border-radius:2px}
body.battle-mode #battle-card .wave-beast.selected-target::after{
  left:13%;right:13%;bottom:-5%;height:19%;border:1px solid #f6e5a5;border-radius:50%;box-shadow:0 0 0 1px #7759238c;
}
body.battle-mode #battle-card .fighter.beast.defeated::before{display:block;opacity:.45}
body.battle-mode #battle-card .fighter[data-pose=prepare] .monster-animation{filter:brightness(1.12) drop-shadow(0 0 3px #f4bc78)}
body.battle-mode #battle-card .fighter.hero[data-pose=cast] .monster-animation{filter:drop-shadow(0 0 4px #a0e7e5)}
body.battle-mode #battle-card .fighter.beast.enraged .monster-animation{filter:drop-shadow(0 0 4px #e56532)}
body.battle-mode #battle-card :is(.hero-fx-layer,.monster-fx-layer,.arena-projectile,.arena-enemy-projectile,.beast-shield-effect,.arena-damage){z-index:200}
body.battle-mode #battle-card .arena-vitals{z-index:300}
body.battle-mode #battle-card :is(.arena-hint,.encounter-progress,.fate-battle-status){z-index:310}
body.battle-mode #battle-card :is(.battle-actions,.battle-item-bar,.arena-joystick,.combat-help){z-index:400}
body.battle-mode #battle-card .battle-item-bar{grid-template-columns:repeat(5,minmax(0,1fr));width:250px;max-width:40%;left:41%;gap:4px}
body.battle-mode #battle-card .battle-actions .skill-name{white-space:normal;line-height:1.05;text-align:center;max-width:100%}
body.battle-mode #battle-card .battle-actions button{background:var(--skill-fill,radial-gradient(circle at 42% 32%,#eedda4,#948365))!important;border-color:var(--skill-border,#786c4b)!important;color:var(--skill-ink,#293b2c)!important}
body.battle-mode #battle-card .battle-actions button[data-state=ready]{--skill-fill:radial-gradient(circle at 42% 32%,#f5edba,#b8ad78);--skill-border:#bba86a}
body.battle-mode #battle-card .battle-actions button:is([data-state=cooldown],[data-state=casting]){--skill-fill:linear-gradient(#c2c9bc,#89988c);--skill-border:#78877b;--skill-ink:#26392d}
body.battle-mode #battle-card .battle-actions button:is([data-state=missing],[data-state=used]){--skill-fill:linear-gradient(#c8cbbf,#9aab9e);--skill-border:#7e8c7d;--skill-ink:#485846;opacity:.75}
body.battle-mode #battle-card .battle-actions button[data-state=spirit]{--skill-fill:linear-gradient(#b8d4d7,#839ca6);--skill-ink:#24424e}
body.battle-mode #battle-card .battle-actions .skill-status{color:inherit!important}
body.battle-mode #battle-card .arena-hint{top:45px;width:36%;left:32%;padding:4px 7px;background:#fff9e7d9;border:1px solid #82795370;border-radius:4px;box-shadow:none}
body.battle-mode #battle-card .boss-scene .arena-hint{top:84px}
body.battle-mode #battle-card .encounter-progress{top:45px}
body.battle-mode #battle-card .fate-battle-status{top:45px}
body.battle-mode #battle-card .arena-hint strong{font-size:10px}
body.battle-mode #battle-card #arena-hint-copy{display:none}
body.battle-mode #battle-card .encounter-progress button{background:#fff8d9b8;border:1px solid #82795370;color:#4b5734;min-height:30px}
body.battle-mode #battle-card .battle-potion{background:#fff9e1d9;border:1px solid #9d8f62;color:#4c5138}
body.battle-mode #battle-card .battle-potion:disabled{opacity:.65}
.combat-tray{display:contents}
body.battle-mode #battle-card .arena-warning{border-width:2px;border-color:#c94937;background:#d85a3624;box-shadow:inset 0 0 12px #b4412929,0 0 0 1px #fff5d788}
body.battle-mode #battle-card .arena-warning.special{border-color:#b82f32;background:#c53b362e}
body.battle-mode #battle-card .arena-warning[data-attack=ranged]{border-color:#477d7a;background:#76cbd12c;border-style:dashed}
body.battle-mode #battle-card .boss-danger-zone{border-width:2px;border-color:#bd4136;background:#b9554024;box-shadow:inset 0 0 10px #a93b3020,0 0 0 1px #fff5d788}
body.battle-mode #battle-card .boss-danger-zone b{background:#943d31d9;border-radius:3px;padding:2px 5px}
body.battle-mode #battle-card.finished .combat-tray{display:none}
/* Máy tính dùng dãy phím gọn ở đáy; điện thoại giữ vùng bấm đủ rộng. */
@media(hover:hover) and (pointer:fine) and (min-width:1000px){
  body.battle-mode #battle-card .arena-joystick{opacity:.42;width:70px;height:70px}
  body.battle-mode #battle-card .arena-joystick:hover{opacity:.9}
  body.battle-mode #battle-card .combat-help{bottom:94px}
  body.battle-mode #battle-card .combat-tray{position:absolute;z-index:400;display:flex;align-items:center;gap:18px;left:50%;bottom:12px;transform:translateX(-50%);width:min(76%,680px);padding:7px 13px;border:3px double #786f53;border-radius:4px;background:linear-gradient(#f1ecd3e8,#b9b89ceb);box-shadow:0 2px 8px #34453670}
  body.battle-mode #battle-card .battle-actions{position:static;display:flex;align-items:center;gap:7px;width:55%;height:auto;transform:none;order:2}
  body.battle-mode #battle-card .battle-actions button,
  body.battle-mode #battle-card #attack-beast,
  body.battle-mode #battle-card #guard-beast,
  body.battle-mode #battle-card #cast-movement,
  body.battle-mode #battle-card #cast-secret,
  body.battle-mode #battle-card #cast-ultimate{position:relative;inset:auto;width:clamp(44px,4.2cqw,62px);height:clamp(44px,4.2cqw,62px);flex:1 1 0;border-radius:50%;background:radial-gradient(circle at 42% 32%,#eedda4,#948365);border:2px solid #6b654d;color:#293b2c;box-shadow:inset 0 0 0 1px #fff6d3}
  body.battle-mode #battle-card .battle-actions .skill-name{font-size:10px}
  body.battle-mode #battle-card .battle-item-bar{position:static;transform:none;width:45%;max-width:none;margin:0;gap:6px;order:1}
  body.battle-mode #battle-card .battle-potion{min-height:46px;border-radius:2px;background:#eae5ce;border:2px solid #a59b79;box-shadow:inset 0 0 0 1px #fdf8e9}
  body.battle-mode #battle-card .arena-hint strong{font-size:14px}
  body.battle-mode #battle-card .encounter-progress strong{font-size:13px}
}
