/* battle.css — trận đấu. Trạng thái do thuộc tính data-battle-state trên .battle điều khiển:
   idle | normal-hit | critical-hit | wrong-answer | tip-open | ultimate | counter | shield-break | victory
   Kèm: data-rank (bronze|silver|gold|boss) · data-qtype (mul|div|shield|seal) · data-ring (on|off) · data-fx (star|petal|flame|wave) */

.screen--battle { max-width: 620px; gap: var(--space-2); overflow: hidden; height: min(100%, 920px); min-height: 0; align-self: center; }
.topbar--battle .topbar__title { gap: 6px; }
.turns { display: flex; gap: 5px; }
.turns i { width: 11px; height: 11px; border-radius: 50%; background: rgba(255,255,255,.75); border: 2px solid #fff; }
.turns i.is-done { background: var(--color-success); }
.turns i.is-now  { background: var(--color-accent); transform: scale(1.3); box-shadow: 0 0 0 3px rgba(255,255,255,.6); }

/* ---------- ĐẤU TRƯỜNG ---------- */
.arena { position: relative; flex: 1; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: var(--space-2); }

/* đối thủ: tên + thanh năng lượng bên trái, hình ở góc trên-phải — để chưởng bay CHÉO cả màn hình */
.opp { display: flex; flex-direction: row; align-items: flex-start; gap: var(--space-3); }
.opp__figure { position: relative; flex: none; width: clamp(118px, 36vw, 176px); }
.oppart--battle { display: block; width: 100%; }
.opp__info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding-top: 4px; }
.opp__name { font-family: var(--font-head); font-size: var(--fs-md); line-height: 1.15; color: var(--color-ink); background: rgba(255,255,255,.85); border-radius: 999px; padding: 2px 12px; align-self: flex-start; }
.opp__info small { align-self: flex-start; font-size: var(--fs-xs); color: var(--color-ink); background: rgba(255,255,255,.82); border-radius: 999px; padding: 0 9px; }

/* khiên: hiện khi đối thủ đỡ đòn (trả lời sai) hoặc khi câu hỏi là "phá khiên" */
.shield { position: absolute; inset: -8%; display: grid; place-items: center; opacity: 0; pointer-events: none; }
.shield__half { position: absolute; top: 6%; bottom: 2%; width: 44%; border: 4px solid #fff; background: linear-gradient(180deg, rgba(200,238,255,.92), rgba(92,199,255,.92)); box-shadow: 0 0 18px rgba(92,199,255,.9); }
.shield__half--l { right: 50%; border-right: 0; border-radius: 26% 0 0 90% / 16% 0 0 60%; }
.shield__half--r { left: 50%;  border-left: 0;  border-radius: 0 26% 90% 0 / 0 16% 60% 0; }
.shield__num { position: relative; z-index: 2; font-family: var(--font-num); font-weight: 800; font-size: clamp(36px, 11vw, 58px); line-height: 1; color: #fff; text-shadow: 0 3px 0 #1566B8, 2px 0 0 #1566B8, -2px 0 0 #1566B8, 0 -2px 0 #1566B8; }
[data-qtype="shield"] .shield { opacity: 1; }
[data-battle-state="wrong-answer"] .shield, [data-battle-state="tip-open"] .shield { opacity: 1; animation: shield-up .45s var(--ease-bounce); }

.oppbubble {
  position: absolute; left: -14px; top: -12px; padding: 5px 11px; border-radius: 50%; background: #fff; border: 3px solid var(--color-ink);
  font-family: var(--font-fx); font-size: 19px; line-height: 1.1; color: var(--color-primary); transform: rotate(-10deg) scale(0); opacity: 0; pointer-events: none;
}

/* câu hỏi */
.qwrap { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; min-height: 0; padding-bottom: 3%; }
.qtag {
  font-family: var(--font-head); font-weight: 800; font-size: var(--fs-sm); letter-spacing: .04em; color: #fff; background: var(--color-magic);
  padding: 2px 14px; border-radius: 999px; border: 2px solid #fff; box-shadow: 0 3px 0 rgba(0,0,0,.16);
}
[data-rage-full="1"] .qtag { background: var(--color-primary); animation: glow-pulse 1s ease-in-out infinite; }
.qcard {
  position: relative; min-width: min(88%, 360px); padding: 12px 24px; text-align: center; background: var(--color-surface);
  border: var(--bw-4) solid var(--q-border); border-radius: var(--radius-lg); box-shadow: 0 6px 0 var(--q-edge), 0 16px 24px var(--color-shadow);
  animation: q-in .4s var(--ease-pop) both;
}
.qcard::before, .qcard::after { content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle, var(--color-accent) 0 28%, var(--color-secondary) 30% 100%); border: 2px solid #fff; }
.qcard::before { left: -9px; top: -9px; } .qcard::after { right: -9px; bottom: -9px; }
.qcard__text { font-family: var(--font-num); font-weight: 800; font-size: clamp(40px, 12.5vw, 68px); line-height: 1.05; color: var(--color-ink); white-space: nowrap; }
.qhint { font-size: var(--fs-sm); color: var(--color-ink); background: rgba(255,255,255,.85); padding: 2px 12px; border-radius: 999px; text-align: center; }
.qhint:empty { display: none; }

/* vòng năng lượng — CHỈ có ở hạng Bạc và Vàng (data-ring="on"); không bao giờ là đồng hồ số */
.ring { position: absolute; inset: -13px; width: calc(100% + 26px); height: calc(100% + 26px); overflow: visible; pointer-events: none; display: none; }
[data-ring="on"] .ring { display: block; }
.ring rect { fill: none; stroke-width: 6; vector-effect: non-scaling-stroke; }
.ring__track { stroke: rgba(255,255,255,.75); }
.ring__run { stroke: var(--color-energy-ring); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 0; filter: drop-shadow(0 0 5px var(--color-energy-ring)); animation: ring-drain var(--ring-sec, 6s) linear .35s forwards; }
.battle:not([data-battle-state="idle"]) .ring__run { animation-play-state: paused; }
.battle:not([data-battle-state="idle"]) .ring { opacity: 0; }
.is-demo .ring__run { animation-iteration-count: infinite; }

/* nhân vật của bé: KHÔNG có thanh máu, chỉ có thanh nộ */
.me { display: flex; align-items: flex-end; gap: var(--space-3); min-height: 0; }
.me__figure { flex: none; width: clamp(112px, 36vw, 176px); aspect-ratio: 1; }
.me__side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; padding-bottom: 6px; }
.combo { min-height: 46px; display: flex; align-items: baseline; justify-content: flex-end; gap: 4px; font-size: clamp(26px, 8.4vw, 42px); transform: rotate(-7deg); opacity: 0; }
.combo.is-on { opacity: 1; animation: combo-pulse .45s var(--ease-bounce); }
.praise {
  align-self: flex-start; min-height: 30px; padding: 3px 12px; border-radius: 999px; background: #fff; border: 2px solid var(--color-primary);
  font-family: var(--font-head); font-weight: 800; font-size: var(--fs-sm); color: var(--color-primary-dark); opacity: 0; transform: scale(.6); transform-origin: left bottom;
}
.rage__label { align-self: flex-start; font-size: var(--fs-xs); color: var(--color-ink); background: rgba(255,255,255,.82); border-radius: 999px; padding: 0 9px; }
[data-rage-full="1"] .rage__track { box-shadow: 0 0 0 3px var(--color-accent), 0 0 16px 4px var(--color-accent); }
[data-rage-full="1"] .rage__star { animation: glow-pulse .9s ease-in-out infinite; }

/* ---------- LÁ ĐÁP ÁN ---------- */
.answers { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); flex: none; position: relative; z-index: 3; }
.answers[data-kind="expr"] { grid-template-columns: repeat(2, 1fr); }
.ans {
  position: relative; display: grid; place-items: center; min-height: 74px; padding: 4px;
  border-radius: var(--radius-card); background: var(--ans-fill); color: var(--ans-text);
  border: var(--bw-3) solid var(--ans-border); box-shadow: 0 6px 0 var(--ans-edge), 0 12px 14px var(--color-shadow);
  font-family: var(--font-num); font-weight: 800; font-size: clamp(30px, 9.4vw, 48px); line-height: 1; white-space: nowrap;
  transition: transform .12s, box-shadow .12s, opacity .2s, filter .2s;
  animation: ans-in .38s var(--ease-pop) backwards; animation-delay: calc(.1s + var(--i) * 60ms);
}
.ans > span { transform: translateY(.04em); }
.answers[data-kind="expr"] .ans { min-height: 62px; font-size: clamp(26px, 8vw, 40px); }
/* bàn phím số của hạng Kim Cương: 2 hàng 6 phím */
.answers[data-kind="pad"] { grid-template-columns: repeat(6, 1fr); gap: 6px; }
.key {
  position: relative; display: grid; place-items: center; min-height: 54px; padding: 2px;
  border-radius: var(--radius-sm); background: var(--ans-fill); color: var(--ans-text);
  border: var(--bw-2) solid var(--ans-border); box-shadow: 0 5px 0 var(--ans-edge), 0 8px 10px var(--color-shadow);
  font-family: var(--font-num); font-weight: 800; font-size: clamp(24px, 7.4vw, 34px); line-height: 1;
  transition: transform .1s, box-shadow .1s, opacity .2s; animation: ans-in .3s var(--ease-pop) backwards; animation-delay: calc(.06s + var(--i) * 25ms);
}
.key > span { transform: translateY(.04em); }
.key:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ans-edge); }
.key--del { font-size: var(--fs-sm); color: var(--color-text-muted); }
.key--ok { font-size: var(--fs-md); background: var(--btn-fill); color: #fff; border-color: #fff; box-shadow: 0 5px 0 var(--btn-edge), 0 8px 10px var(--color-shadow); text-shadow: 0 2px 0 var(--btn-edge); }
.key--ok:active { box-shadow: 0 1px 0 var(--btn-edge); }
.key.is-dim { opacity: .5; }
.key.is-correct { background: linear-gradient(180deg, #FFFBC2 0%, #FFD21F 58%, #FFB300 100%); color: var(--ans-text); border-color: #fff; box-shadow: 0 5px 0 #E08A00, 0 0 22px 6px rgba(255,210,31,.85); text-shadow: none; }
[data-input="pad"] .qcard__text { letter-spacing: .01em; }
[data-theme="cute"] .ans:nth-child(3) { --ans-border: #6CCBFF; --ans-edge: #3FA9E6; background: linear-gradient(180deg, #fff, #E3F5FF); }
.ans:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ans-edge); }
.ans.is-correct {
  z-index: 2; transform: scale(1.07); border-color: #fff; background: linear-gradient(180deg, #FFFBC2 0%, #FFD21F 58%, #FFB300 100%);
  box-shadow: 0 6px 0 #E08A00, 0 0 0 4px #FFD21F, 0 0 28px 8px rgba(255,210,31,.85); animation: ans-win .5s var(--ease-bounce);
}
.ans.is-correct::after { content: ""; position: absolute; inset: -14px; pointer-events: none; background:
  radial-gradient(circle, #fff 0 3px, transparent 4px) 8% 12% / 100% 100% no-repeat,
  radial-gradient(circle, #fff 0 4px, transparent 5px) 92% 22% / 100% 100% no-repeat,
  radial-gradient(circle, #fff 0 3px, transparent 4px) 84% 90% / 100% 100% no-repeat,
  radial-gradient(circle, #fff 0 4px, transparent 5px) 14% 86% / 100% 100% no-repeat; animation: twinkle .8s ease-in-out infinite; }
.ans.is-dim { opacity: .5; filter: saturate(.55); }
.ans.is-wrong { opacity: .38; filter: grayscale(.7); animation: ans-nope .4s; }

/* ---------- LỚP HIỆU ỨNG ---------- */
/* chữ hiệu ứng nằm ở khoảng trống giữa đối thủ và lá câu hỏi; chừa một bên cho thẻ tuyệt chiêu */
.fx { position: absolute; left: 20%; right: 0; top: 19%; height: 40%; z-index: var(--z-fx); pointer-events: none; display: grid; place-items: center; }
.fx > * { grid-area: 1 / 1; opacity: 0; }
.fx__burst {
  display: none; width: min(96vw, 520px); aspect-ratio: 1; clip-path: var(--burst-poly);
  background: radial-gradient(circle, #fff 0 10%, var(--burst-a) 24%, var(--burst-b) 44%, var(--burst-c) 64%);
}
.fx__crit  { font-size: clamp(36px, 11.5vw, 72px); transform: translateY(-62%) rotate(-5deg) skewX(var(--fx-skew)); }
.fx__dmg   { font-size: clamp(44px, 14vw, 84px); transform: translateY(26%) rotate(-3deg); }
.fx__label { font-size: clamp(26px, 8vw, 44px); transform: translateY(-70%) rotate(-4deg) skewX(var(--fx-skew)); --fill-title: var(--fill-crit); --stroke-title: var(--stroke-crit); }
.fx__label .comic { --halo: #fff; }

.fxp { position: absolute; left: -13px; top: -13px; width: 26px; height: 26px; opacity: 0; animation: fxp-fly .66s var(--ease-impact) var(--d) forwards; }
.fxp--big { left: -19px; top: -19px; width: 38px; height: 38px; }
.fxp--star  { background: linear-gradient(180deg, #FFFBC2, #FFC21A); clip-path: polygon(50% 0, 62% 35%, 100% 38%, 70% 60%, 80% 100%, 50% 76%, 20% 100%, 30% 60%, 0 38%, 38% 35%); }
.fxp--petal { background: linear-gradient(135deg, #fff, #FF7EB6); border-radius: 85% 0 85% 0; }
.fxp--flame { background: radial-gradient(circle at 50% 72%, #FFF27A 0 22%, #FF9F1C 48%, #FF3B30 78%); clip-path: polygon(50% 0, 72% 30%, 96% 62%, 78% 100%, 22% 100%, 4% 62%, 30% 34%); }
.fxp--wave  { background: radial-gradient(circle at 34% 32%, #fff 0 16%, #8FE3FF 40%, #2E8BFF 78%); border-radius: 50%; }

/* thẻ tuyệt chiêu bật ở góc */
.skillcard {
  position: absolute; z-index: calc(var(--z-fx) - 1); left: 0; top: 23%; width: clamp(96px, 27vw, 150px); pointer-events: none; opacity: 0;
  display: flex; flex-direction: column; overflow: hidden; border-radius: var(--radius-md); border: var(--bw-3) solid var(--color-gold);
  background: linear-gradient(160deg, #3B2A8F, #8A3BD6); box-shadow: 0 0 0 3px #fff, 0 12px 24px rgba(0,0,0,.35);
  --skill-rot: -7deg; --skill-from: -150%;
}
[data-theme="cute"] .skillcard { background: linear-gradient(160deg, #FF8FCB, #B98BFF); }
.skillcard__art { display: block; aspect-ratio: 4 / 3; overflow: hidden; }
.skillcard__art { background: radial-gradient(circle at 50% 40%, rgba(255,255,255,.85), rgba(255,255,255,0) 68%); }
.skillcard__art img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 16%; }
.skillcard__name { position: relative; margin-top: -.75em; text-align: center; font-size: clamp(20px, 6.2vw, 30px); transform: rotate(-4deg) skewX(var(--fx-skew)); }
.skillcard__sub { padding: 2px 6px 7px; text-align: center; font-size: 11px; font-weight: 800; line-height: 1.25; color: #fff; }

/* ---------- CHƯỞNG: màn tối lại, nhân vật vẫn sáng, canvas vẽ chiêu phủ lên trên ----------
   Tầng: lớp tối 14 < nhân vật 16 < canvas 17 < thẻ chiêu 19 < chữ hiệu ứng 20 */
.vfxdim { position: fixed; inset: 0; z-index: 14; pointer-events: none; opacity: 0; transition: opacity .2s; background: radial-gradient(ellipse at 50% 42%, rgba(30, 18, 78, .66), rgba(10, 6, 36, .88)); }
.vfx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 17; pointer-events: none; }
.battle[data-dim="1"] .vfxdim { opacity: 1; }
.me__figure { position: relative; }
.battle[data-dim="1"] .opp__figure, .battle[data-dim="1"] .me__figure, .battle[data-dim="1"] .opp__info { z-index: 16; }
.opp__info { position: relative; }
/* đầy nộ: hào quang bùng quanh nhân vật */
[data-rage-full="1"] .me__figure .art::before { inset: -8%; opacity: 1; animation: aura-pulse .55s ease-in-out infinite; }
[data-rage-full="1"] .me__figure .art img { animation: aura-flicker .5s ease-in-out infinite; }

/* ---------- THẺ MẸO (khi trả lời sai) ---------- */
.tipveil { position: absolute; inset: 0; z-index: var(--z-popup); display: none; place-items: center; padding: var(--space-4); background: rgba(44, 28, 96, .38); }
[data-battle-state="tip-open"] .tipveil { display: grid; animation: fade-in .25s both; }
.tipcard {
  position: relative; width: min(100%, 380px); display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 34px 18px 18px;
  background: var(--color-surface); border: var(--bw-4) solid var(--color-accent); border-radius: var(--radius-xl);
  box-shadow: 0 8px 0 var(--color-accent-dark), 0 22px 40px rgba(0,0,0,.3); animation: tip-in .5s var(--ease-bounce) both;
}
.tipcard__bulb { position: absolute; top: -28px; width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; background: var(--color-accent); color: var(--color-ink); border: 4px solid #fff; box-shadow: 0 4px 0 var(--color-accent-dark); }
.tipcard__title { font-family: var(--font-head); font-size: var(--fs-lg); color: var(--color-primary-dark); line-height: 1; }
.tipcard__text { font-family: var(--font-head); font-weight: 700; font-size: var(--fs-lg); line-height: 1.3; text-align: center; color: var(--color-ink); }
.dots { display: flex; flex-direction: column; gap: 4px; padding: 9px; background: #fff; border-radius: 12px; border: 2px dashed var(--color-outline); }
.dots__row { display: flex; gap: 4px; }
.dots i { width: 13px; height: 13px; border-radius: 50%; background: var(--color-info); }
.dots__row.is-a i { background: var(--color-primary); }
.tipcard .btn { min-width: 180px; font-size: var(--fs-lg); }

/* ---------- ĐẠI CHIÊU: cắt cảnh toàn màn hình ---------- */
.cutin { position: absolute; inset: 0; z-index: var(--z-cut); overflow: hidden; display: grid; place-items: center; pointer-events: none; opacity: 0; }
.cutin__lines { position: absolute; inset: -30%; background: repeating-linear-gradient(98deg, transparent 0 16px, rgba(255,255,255,.6) 16px 20px), linear-gradient(120deg, var(--color-magic), var(--color-primary)); }
.cutin__band { position: absolute; left: -12%; right: -12%; top: 24%; height: 36%; overflow: hidden; display: grid; place-items: start center; transform: rotate(-8deg); background: linear-gradient(90deg, var(--color-accent), #fff 45%, var(--color-accent)); border-top: 6px solid var(--color-ink); border-bottom: 6px solid var(--color-ink); }
.cutin__face { display: block; width: min(118vw, 60vh); height: min(118vw, 60vh); margin-top: -2%; transform: rotate(8deg); }
.cutin__face img { width: 100%; height: 100%; object-fit: contain; object-position: 50% 0; }
.cutin__name { position: relative; margin-top: 46%; font-size: clamp(32px, 10.5vw, 70px); transform: rotate(-6deg) skewX(var(--fx-skew)); }
.cutin__sub { position: absolute; top: 12%; left: 0; right: 0; text-align: center; font-family: var(--font-head); font-weight: 800; font-size: var(--fs-xl); letter-spacing: .3em; color: #fff; text-shadow: 0 3px 0 var(--color-ink); }

/* ---------- KẾT LIỄU ---------- */
.finish { position: absolute; inset: 0; z-index: var(--z-cut); display: grid; place-items: center; pointer-events: none; opacity: 0; font-size: clamp(40px, 13vw, 78px); background: radial-gradient(circle, rgba(255,255,255,.92) 0, rgba(255,255,255,0) 62%); }
.finish .comic { transform: rotate(-5deg) skewX(var(--fx-skew)); }

/* =====================================================================
   BẢNG TRẠNG THÁI → HIỆU ỨNG
   ===================================================================== */
/* --hit = lúc chiêu chạm đối thủ, do js/battle.js đặt theo từng chiêu */
.battle { --hit: 450ms; }
[data-battle-state="normal-hit"] .fx__dmg,
[data-battle-state="critical-hit"] .fx__dmg,
[data-battle-state="counter"] .fx__dmg,
[data-battle-state="shield-break"] .fx__dmg,
[data-battle-state="ultimate"] .fx__dmg { animation: dmg-pop 1.25s var(--ease-pop) calc(var(--hit) + 40ms) both; }
[data-battle-state="critical-hit"] .fx__crit { animation: crit-pop 1.3s var(--ease-pop) calc(var(--hit) - 60ms) both; }
[data-battle-state="counter"] .fx__label,
[data-battle-state="shield-break"] .fx__label,
[data-battle-state="ultimate"] .fx__label { animation: label-pop 1.25s var(--ease-pop) calc(var(--hit) - 60ms) both; }

[data-battle-state="normal-hit"] .skillcard,
[data-battle-state="critical-hit"] .skillcard,
[data-battle-state="counter"] .skillcard,
[data-battle-state="shield-break"] .skillcard { animation: skill-in 1.45s var(--ease-pop) both; }

[data-battle-state="normal-hit"] .opp__figure,
[data-battle-state="counter"] .opp__figure,
[data-battle-state="shield-break"] .opp__figure { animation: opp-hit .55s var(--hit); }
[data-battle-state="critical-hit"] .opp__figure { animation: opp-rattle .62s var(--hit); }
[data-battle-state="ultimate"] .opp__figure { animation: opp-rattle .9s var(--hit); }
[data-battle-state="normal-hit"] .oppbubble,
[data-battle-state="critical-hit"] .oppbubble,
[data-battle-state="counter"] .oppbubble,
[data-battle-state="shield-break"] .oppbubble,
[data-battle-state="ultimate"] .oppbubble { animation: bubble-pop 1s var(--hit) both; }

/* tư thế ra chiêu của nhân vật */
[data-cast="volley"][data-battle-state="normal-hit"] .me__figure { animation: me-strike .5s var(--ease-impact) .1s; }
[data-cast="beam"][data-battle-state="critical-hit"] .me__figure,
[data-cast="beam"][data-battle-state="normal-hit"] .me__figure { animation: me-charge .38s linear, me-fire .8s var(--ease-impact) .38s; }
[data-cast="thunder"][data-battle-state="shield-break"] .me__figure { animation: me-charge .38s linear, me-strike .5s var(--ease-impact) .38s; }
[data-cast="spirit"][data-battle-state="ultimate"] .me__figure { animation: me-charge .9s linear 1s, me-fire .7s var(--ease-impact) 1.9s; }
[data-cast="teleport"][data-battle-state="counter"] .me__figure { animation: me-teleport 1.3s linear both; }
[data-battle-state="normal-hit"] .praise,
[data-battle-state="critical-hit"] .praise,
[data-battle-state="counter"] .praise,
[data-battle-state="shield-break"] .praise,
[data-battle-state="ultimate"] .praise { animation: praise-pop 1.3s var(--ease-bounce) .15s both; }

/* phản đòn: quả cầu của đối thủ bay xuống rồi bị bật ngược */
.opp__figure::after { content: ""; position: absolute; left: 50%; top: 60%; width: 34px; height: 34px; margin: -17px; border-radius: 50%; opacity: 0; pointer-events: none; background: radial-gradient(circle at 35% 30%, #fff, var(--color-magic) 60%, #4B2AA8); box-shadow: 0 0 16px 4px var(--color-magic); }
[data-battle-state="idle"][data-qtype="div"] .opp__figure::after { opacity: 1; animation: orb-wait 1.2s ease-in-out infinite; }
[data-battle-state="counter"] .opp__figure::after { opacity: 0; }

/* phá khiên: khiên tách đôi */
[data-battle-state="shield-break"] .shield { opacity: 1; }
[data-battle-state="shield-break"] .shield__half--l { animation: half-l .7s var(--ease-impact) var(--hit) forwards; }
[data-battle-state="shield-break"] .shield__half--r { animation: half-r .7s var(--ease-impact) var(--hit) forwards; }
[data-battle-state="shield-break"] .shield__num { animation: fade-out .3s var(--hit) forwards; }

[data-battle-state="ultimate"] .cutin { animation: cutin-all 1.05s var(--ease-soft) both; }
[data-battle-state="ultimate"] .cutin__lines { animation: lines-run .45s linear infinite; }
[data-battle-state="ultimate"] .cutin__face { animation: face-slide 1.05s var(--ease-impact) both; }
[data-battle-state="ultimate"] .cutin__name { animation: name-slam .9s var(--ease-pop) .12s both; }
[data-battle-state="victory"] .finish { animation: finish-in 1.5s var(--ease-pop) both; }
[data-battle-state="victory"] .opp__figure { animation: opp-bye .9s var(--ease-soft) forwards; }

/* ---------- điện thoại cầm ngang: đấu trường bên trái, câu hỏi + đáp án bên phải ---------- */
@media (orientation: landscape) and (max-height: 540px) {
  .screen--battle { max-width: 1000px; display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); grid-template-rows: auto minmax(0, 1fr) auto; column-gap: var(--space-5); row-gap: var(--space-2); }
  .topbar--battle { grid-column: 1 / -1; min-height: 48px; }
  .arena { display: contents; }
  .opp { grid-column: 1; grid-row: 2; align-self: start; }
  .me  { grid-column: 1; grid-row: 3; }
  .qwrap { grid-column: 2; grid-row: 2; }
  .answers { grid-column: 2; grid-row: 3; }
  .opp__figure { width: clamp(96px, 24vh + 20px, 150px); }
  .me__figure { width: clamp(84px, 26vh, 130px); }
  .qcard__text { font-size: clamp(34px, 12vh, 56px); }
  .ans { min-height: 56px; font-size: clamp(26px, 9vh, 40px); }
  .fx { top: 14%; height: 76%; left: 0; right: 50%; }
  .skillcard { top: 30%; width: clamp(84px, 26vh, 128px); }
  .combo { min-height: 34px; font-size: clamp(22px, 8vh, 34px); }
  .fx__crit { font-size: clamp(28px, 13vh, 50px); }
  .fx__dmg { font-size: clamp(34px, 16vh, 60px); }
  .fx__label { font-size: clamp(22px, 9vh, 36px); }
  .fx__burst { width: min(46vw, 92vh); }
  .cutin__name { margin-top: 30vh; font-size: clamp(36px, 18vh, 70px); }
  .cutin__face { width: 70vh; height: 70vh; }
  .finish { font-size: clamp(36px, 20vh, 78px); }
}
/* màn thấp (điện thoại nhỏ cầm dọc): thu hình lại để đủ chỗ */
@media (orientation: portrait) and (max-height: 700px) {
  .opp__figure { width: clamp(96px, 28vw, 130px); }
  .me__figure { width: clamp(92px, 28vw, 124px); }
  .ans { min-height: 62px; }
  .qcard { padding: 8px 20px; }
}
