/* Client game 2D: dùng chung biến màu với style.css */
html, body { height: 100%; overflow: hidden; background: #05080a; }
body { background: #05080a; }

.frame { position: fixed; inset: 0; display: grid; place-items: center; background: #05080a; }
.stage {
  position: relative; width: min(100vw, 177.78vh); aspect-ratio: 16 / 9; overflow: hidden;
  container-type: size; background: var(--ink); user-select: none; -webkit-user-select: none;
}
.stage.walk { cursor: crosshair; }
.stage.shake { animation: shake .28s; }
.layer, .bg, .props, .fx, .floaters, .overlay, .fade { position: absolute; inset: 0; }
.bg canvas, .bg img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.bg img.bgimg { opacity: 0; transition: opacity .5s; }
.bg img.bgimg.ok { opacity: 1; }
.props, .fx, .floaters { pointer-events: none; }
.props { z-index: 3; }
.vfx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.props .hs, .props .arrow { pointer-events: auto; }

/* ---------- vùng bấm ---------- */
.hs {
  position: absolute; background: transparent; border: 0; padding: 0; border-radius: 14px; cursor: pointer;
  outline: 0; transition: box-shadow .15s, background .15s;
}
.hs:hover, .hs:focus-visible, .stage.show-hs .hs {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--realm) 80%, transparent), 0 0 28px color-mix(in srgb, var(--realm) 35%, transparent);
  background: color-mix(in srgb, var(--realm) 8%, transparent);
}
.tip {
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); white-space: nowrap;
  background: rgba(8, 14, 18, .88); color: var(--text); font: 500 13px var(--sans); padding: 5px 11px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: opacity .12s;
}
.hs:hover .tip, .hs:focus-visible .tip { opacity: 1; }
.hs.arrow {
  display: grid; place-items: center; border-radius: 50%; aspect-ratio: 1; height: auto;
  background: rgba(8, 14, 18, .55); border: 1.5px solid color-mix(in srgb, var(--realm) 55%, transparent);
  backdrop-filter: blur(4px);
}
.hs.arrow svg { width: 52%; height: 52%; stroke: var(--realm); fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.hs.arrow.left svg { transform: rotate(-90deg); } .hs.arrow.right svg { transform: rotate(90deg); } .hs.arrow.back svg { transform: rotate(180deg); }
.hs.arrow .tip { bottom: auto; top: calc(100% + 6px); }

/* ---------- nhân vật & quái ---------- */
.actor { position: absolute; width: 8cqh; height: 16cqh; transform-origin: 50% 100%; pointer-events: none; will-change: left, top, transform; }
.actor.walking svg { animation: bob .36s ease-in-out infinite; }
.actor img { width: 100%; height: 100%; object-fit: contain; }
.monster { position: absolute; left: 35%; top: 35%; width: 30%; height: 46%; display: grid; place-items: center; border: 0; background: transparent; padding: 0; }
button.monster { cursor: pointer; pointer-events: auto; border-radius: 24px; }
button.monster:hover, button.monster:focus-visible { box-shadow: 0 0 0 2px color-mix(in srgb, var(--hp) 70%, transparent); background: color-mix(in srgb, var(--hp) 8%, transparent); outline: 0; }
.monster .sprite { font-size: 15cqw; line-height: 1; filter: drop-shadow(0 18px 24px rgba(0, 0, 0, .65)); animation: float 3.4s ease-in-out infinite; }
.monster img { max-width: 100%; max-height: 100%; object-fit: contain; filter: drop-shadow(0 18px 24px rgba(0, 0, 0, .65)); animation: float 3.4s ease-in-out infinite; }
.monster.boss .sprite { font-size: 19cqw; }
.monster.hit .sprite, .monster.hit img { animation: hit .3s; }
.monster.dead .sprite, .monster.dead img { animation: none; opacity: .15; filter: grayscale(1); transition: opacity .6s; }
.monster .tip { bottom: auto; top: 2%; }
button.monster:hover .tip, button.monster:focus-visible .tip { opacity: 1; }

/* ---------- HUD ---------- */
.glass { background: rgba(8, 14, 18, .66); backdrop-filter: blur(8px); border: 1px solid color-mix(in srgb, var(--realm) 22%, rgba(255, 255, 255, .06)); border-radius: 14px; }
.hud { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.hud > * { pointer-events: auto; }
.hud-l { position: absolute; left: 1.4cqw; top: 2.4cqh; width: 22cqw; min-width: 190px; padding: 1.3cqh 1.2cqw; display: grid; gap: 1cqh; font-size: clamp(11px, 1.15cqw, 14px); }
.hud-l .seal-row { gap: 10px; } .hud-l .seal { width: 3.4cqw; height: 3.4cqw; min-width: 36px; min-height: 36px; font-size: clamp(14px, 1.5cqw, 20px); border-radius: 10px; }
.hud-l .realm-name { font-size: clamp(15px, 1.6cqw, 21px); }
.hud-l .realm-stage { font-size: clamp(11px, 1cqw, 13px); margin-top: 1px; }
.hud-l .meter-head { font-size: inherit; } .hud-l .bar { height: 6px; }
.hud-l .coin { display: flex; justify-content: space-between; align-items: baseline; color: var(--muted); }
.hud-l .coin b { font: 600 clamp(15px, 1.5cqw, 19px) var(--serif); color: var(--sta); }
.hud-r { position: absolute; right: 1.4cqw; top: 2.4cqh; display: flex; gap: 6px; justify-content: flex-end; }
.hud-r .btn { padding: 6px 12px; font-size: clamp(11px, 1.1cqw, 14px); background: rgba(8, 14, 18, .66); backdrop-filter: blur(8px); }
.hud-br { position: absolute; right: 1.4cqw; bottom: 1.2cqh; display: flex; gap: 6px; z-index: 2; }
.hud-br .btn { padding: 4px 10px; font-size: clamp(10px, 1cqw, 12px); background: rgba(8, 14, 18, .6); }
.loc { position: absolute; left: 50%; top: 2.4cqh; transform: translateX(-50%); font: 600 clamp(15px, 1.8cqw, 24px) var(--serif); text-shadow: 0 2px 12px #000; pointer-events: none; text-align: center; white-space: nowrap; }
.loc small { display: block; font: 400 clamp(11px, 1cqw, 13px) var(--sans); color: var(--muted); }

/* ---------- thanh chiến đấu / bế quan ---------- */
.cbar { position: absolute; left: 0; right: 0; bottom: 2.4cqh; display: flex; justify-content: center; align-items: flex-end; gap: 1.2cqw; padding: 0 1.4cqw; pointer-events: none; }
.cbar > * { pointer-events: auto; }
.pl-bars { width: 19cqw; min-width: 170px; padding: 1.2cqh 1cqw; display: grid; gap: .9cqh; font-size: clamp(11px, 1.05cqw, 13px); }
.pl-bars .meter-head { font-size: inherit; } .pl-bars .bar { height: 6px; }
.acts { display: flex; flex-wrap: wrap; gap: 6px; padding: 1.2cqh 1cqw; max-width: 56cqw; justify-content: center; }
.acts .btn { padding: 7px 13px; font-size: clamp(11px, 1.1cqw, 14px); }
.medbox { padding: 1.4cqh 1.6cqw; display: grid; gap: .9cqh; justify-items: center; text-align: center; width: min(46cqw, 520px); font-size: clamp(12px, 1.2cqw, 15px); }
.medbox .row-btn { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.medbox .meter { width: 100%; }
.mon-bar { position: absolute; left: 50%; top: 9cqh; transform: translateX(-50%); width: 30cqw; min-width: 220px; padding: 1cqh 1cqw; display: grid; gap: .6cqh; text-align: center; font-size: clamp(11px, 1.15cqw, 14px); }
.mon-bar b { font: 600 clamp(14px, 1.5cqw, 19px) var(--serif); }
.mon-bar .meter-head { font-size: inherit; } .mon-bar .bar { height: 8px; }
.clog { position: absolute; left: 50%; bottom: 20cqh; transform: translateX(-50%); width: min(60cqw, 640px); display: grid; gap: 3px; text-align: center; pointer-events: none; font-size: clamp(11px, 1.15cqw, 15px); text-shadow: 0 1px 8px #000; }
.clog p { margin: 0; color: rgba(231, 227, 214, .55); } .clog p:last-child { color: var(--text); }

.fx .vortex { position: absolute; left: 50%; top: 47%; width: 27cqw; transform: translate(-50%, -50%); }
.fx .vortex .core b { font-size: clamp(16px, 2.4cqw, 34px); } .fx .vortex .core span { font-size: clamp(10px, 1cqw, 13px); }
.floaters .fl { position: absolute; font: 700 clamp(20px, 3cqw, 40px) var(--serif); text-shadow: 0 2px 10px #000; animation: rise 1s ease-out forwards; transform: translate(-50%, 0); }
.fl.dmg { color: #ff8b7e; } .fl.heal { color: #8be59f; } .fl.crit { color: #ffd27a; font-size: clamp(26px, 4cqw, 52px); }
.flash { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 12cqw rgba(200, 60, 50, .0); animation: flash .35s; }

/* ---------- bảng phủ ---------- */
.overlay { display: none; place-items: center; background: rgba(4, 8, 10, .62); backdrop-filter: blur(3px); z-index: 5; }
.overlay.on { display: grid; }
.panel {
  width: min(86cqw, 940px); max-height: 86cqh; display: grid; grid-template-rows: auto 1fr; border-radius: 18px; overflow: hidden;
  background: var(--panel); border: 1px solid color-mix(in srgb, var(--realm) 30%, var(--line));
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
.panel.narrow { width: min(60cqw, 560px); }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--tint-hi); }
.panel-head h2 { font-size: 20px; }
.panel-body { padding: 18px 20px 22px; overflow-y: auto; }
.panel-body .group + .group { margin-top: 22px; }
.zones { display: grid; gap: 10px; }
.zcard { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; background: var(--panel-hi); padding: 12px 16px; border-radius: 12px; }
.zcard h3 { font: 600 17px var(--serif); } .zcard small { color: var(--muted); display: block; }
.zcard.locked { opacity: .55; }
.fade { background: #000; opacity: 0; pointer-events: none; transition: opacity .26s; z-index: 9; }
.fade.on { opacity: 1; pointer-events: auto; }
.hint-rotate { display: none; }
@media (max-aspect-ratio: 1/1) { .hint-rotate { display: block; position: fixed; left: 0; right: 0; top: 8px; text-align: center; color: var(--muted); font-size: 13px; z-index: 20; } }

@keyframes bob { 50% { transform: translateY(-3%); } }
@keyframes float { 50% { transform: translateY(-3%); } }
@keyframes hit { 0% { transform: translateX(0); filter: brightness(2) drop-shadow(0 18px 24px #000); } 30% { transform: translateX(-3%); } 60% { transform: translateX(3%); } 100% { transform: none; } }
@keyframes shake { 20% { transform: translate(-6px, 3px); } 40% { transform: translate(5px, -3px); } 60% { transform: translate(-4px, 2px); } 80% { transform: translate(3px, 0); } }
@keyframes rise { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -9cqh; } }
@keyframes flash { 0% { box-shadow: inset 0 0 12cqw rgba(200, 60, 50, .75); } 100% { box-shadow: inset 0 0 12cqw rgba(200, 60, 50, 0); } }
@media (prefers-reduced-motion: reduce) { .actor.walking svg, .monster .sprite, .monster img, .stage.shake, .flash, .monster.hit .sprite, .monster.hit img { animation: none; } .fade { transition: none; } }

/* ---------- hiệu ứng giao chiến ---------- */
.stage.fxbusy .acts { pointer-events: none; opacity: .5; transition: opacity .15s; }
.stage.shake2 { animation: shake2 .45s; }
.punch { animation: punch .32s ease-out; }
.monster.hit.big .sprite, .monster.hit.big img { animation: hitbig .42s; }
.monster.lunge .sprite, .monster.lunge img { animation: lunge .42s ease-in-out; }
.fl.big { font-size: clamp(30px, 4.6cqw, 60px); color: #ffd27a; text-shadow: 0 0 18px #ff9a3c, 0 2px 10px #000; }
@keyframes shake2 { 10% { transform: translate(-12px, 6px); } 25% { transform: translate(10px, -7px); } 40% { transform: translate(-8px, 5px); } 60% { transform: translate(6px, -3px); } 80% { transform: translate(-3px, 2px); } }
@keyframes punch { 0% { transform: scale(1); } 35% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes hitbig { 0% { transform: translateX(0) scale(1); filter: brightness(3) drop-shadow(0 18px 24px #000); } 25% { transform: translateX(-6%) scale(.94); } 55% { transform: translateX(5%) scale(1.03); } 100% { transform: none; } }
@keyframes lunge { 0% { transform: scale(1); } 40% { transform: scale(1.38) translateY(10%); filter: brightness(1.25) drop-shadow(0 18px 24px #000); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .stage.shake2, .punch, .monster.hit.big .sprite, .monster.hit.big img, .monster.lunge .sprite, .monster.lunge img { animation: none; } }
