body {
    font-family: 'Inter', sans-serif;
    background-color: #060812;
    color: #f8fafc;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

.font-xianxia {
    font-family: 'Noto Serif', serif;
}

.font-title {
    font-family: 'Cinzel', 'Noto Serif', serif;
}

/* Thanh máu vát chéo phong cách Tiên Hiệp */
.hp-bar-left {
    clip-path: polygon(0 0, 100% 0, 94% 100%, 0% 100%);
}

.hp-bar-right {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 6% 100%);
}

/* Nút kỹ năng tròn phát sáng giống ảnh mẫu */
.skill-orb {
    background: radial-gradient(circle at 30% 30%, rgba(56, 189, 248, 0.45), rgba(15, 23, 42, 0.92));
    border: 2px solid rgba(125, 211, 252, 0.75);
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.45), inset 0 0 12px rgba(186, 230, 253, 0.35);
    transition: all 0.15s ease;
}

    .skill-orb:hover, .skill-orb:active {
        transform: scale(1.08);
        border-color: #fde047;
        box-shadow: 0 0 24px rgba(250, 204, 21, 0.75), inset 0 0 15px rgba(254, 240, 138, 0.5);
    }

.btn-jade {
    background: linear-gradient(135deg, #0284c7 0%, #1d4ed8 50%, #312e81 100%);
    border: 1px solid #7dd3fc;
    box-shadow: 0 4px 20px rgba(14, 165, 233, 0.45);
    transition: all 0.18s ease;
}

    .btn-jade:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 26px rgba(56, 189, 248, 0.7);
        border-color: #fde047;
    }

.btn-crimson {
    background: linear-gradient(135deg, #991b1b 0%, #581c87 50%, #1e1b4b 100%);
    border: 1px solid #f472b6;
    box-shadow: 0 4px 20px rgba(192, 38, 211, 0.4);
    transition: all 0.18s ease;
}

    .btn-crimson:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 26px rgba(232, 121, 249, 0.65);
        border-color: #fde047;
    }

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

@keyframes pulseAura {
    0%, 100% {
        text-shadow: 0 0 14px rgba(56, 189, 248, 0.9), 0 0 28px rgba(250, 204, 21, 0.6);
    }

    50% {
        text-shadow: 0 0 24px rgba(125, 211, 252, 1), 0 0 45px rgba(250, 204, 21, 0.95);
    }
}

.glow-xianxia {
    animation: pulseAura 2.2s infinite;
}

/* ============================================================
 *  MÀN CHỌN TƯỚNG & LÔI ĐÀI (ui/roster.js) — theo art-source/game-scene/select-scene.png
 *  Mọi kích thước tính theo khung game (container query: 1cqw = 1% bề rộng, 1cqh = 1% bề cao)
 *  → giữ đúng tỉ lệ thiết kế ở mọi cỡ màn hình (khung game luôn 16:9).
 *  Vị trí (% khung): panel P1 x 5–25, P2 x 75–95, y 10–87 · cột giữa x 27–73 · nút chế độ y 82–90 · nút thử y 91–98
 * ============================================================ */
/* Ảnh UI cắt từ art-source/game-scene/*.jpg bằng docs/ui-templates/cut-select-scene.ps1 → assets/ui/select/ */
.select-scene {
    container-type: size;
    overflow: hidden;
    color: #f8fafc;
    background: #07080d;
}
.select-bg {   /* nền dùng chung: màn chọn, màn nạp */
    position: absolute; inset: 0; pointer-events: none;
    background:
        radial-gradient(ellipse 75% 70% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.55)),
        url('../assets/ui/select/backdrop.jpg') center / cover no-repeat;
}
/* Tàn lửa bay lên (2 lớp lệch nhịp) */
.select-embers {
    position: absolute; left: 0; right: 0; top: 0; height: 200%;
    background-image:
        radial-gradient(circle, rgba(251, 146, 60, 0.9) 0 1px, transparent 2px),
        radial-gradient(circle, rgba(56, 189, 248, 0.8) 0 1px, transparent 2px),
        radial-gradient(circle, rgba(252, 211, 77, 0.8) 0 1.5px, transparent 2.5px);
    background-size: 23cqw 31cqh, 29cqw 37cqh, 37cqw 43cqh;
    background-position: 3cqw 5cqh, 17cqw 21cqh, 9cqw 33cqh;
    animation: select-embers-rise 14s linear infinite;
    opacity: 0.55;
}
.select-embers-2 { background-size: 31cqw 27cqh, 19cqw 41cqh, 43cqw 35cqh; animation-duration: 21s; opacity: 0.35; }
@keyframes select-embers-rise { to { transform: translateY(-50%); } }

.select-title {
    position: absolute; left: 0; right: 0; top: 3.2cqh; margin: 0; text-align: center;
    font-family: 'Cinzel', 'Noto Serif', serif; font-weight: 900; font-size: 4.3cqw; letter-spacing: 0.04em; line-height: 1;
    color: transparent;
    background: linear-gradient(90deg, #cbd5e1 0%, #f8fafc 18%, #fcd34d 40%, #fde68a 52%, #fbbf24 62%, #e9d5ff 82%, #c4b5fd 100%);
    -webkit-background-clip: text; background-clip: text;
    filter: drop-shadow(0 0.2cqw 0.15cqw rgba(0, 0, 0, 0.9)) drop-shadow(0 0 1.2cqw rgba(251, 191, 36, 0.35));
    pointer-events: none;
}

/* ---------- Panel người chơi (cờ hiệu, đáy nhọn) ---------- */
.player-banner {
    position: absolute; top: 9.5cqh; height: 78cqh; width: 21cqw; padding: 0; border: 0;
    background: url('../assets/ui/select/banner-p1.png') center / 100% 100% no-repeat;
    cursor: pointer; transition: transform 0.18s ease, filter 0.18s ease;
    --banner-color: #22d3ee; --banner-glow: rgba(34, 211, 238, 0.55); --banner-dark: #04141c;
}
.player-banner-p1 { left: 4.6cqw; }
.player-banner-p2 { right: 4.2cqw; background-image: url('../assets/ui/select/banner-p2.png'); --banner-color: #ef4444; --banner-glow: rgba(239, 68, 68, 0.55); --banner-dark: #1c0606; }
.player-banner:hover { transform: translateY(-0.3cqh); }
.player-banner.is-active { animation: banner-pulse 1.8s ease-in-out infinite; }
@keyframes banner-pulse { 50% { filter: drop-shadow(0 0 1.2cqw var(--banner-glow)) brightness(1.08); } }
/* Lòng khung cờ hiệu (theo ảnh banner-p*.png 296×610: lòng x 11–92%, y 4.6–94%, đáy nhọn từ ~83%) */
.banner-frame { position: absolute; inset: 0; display: block; }
.banner-inner {
    position: absolute; left: 11%; right: 9%; top: 4.6%; bottom: 6%; display: block; overflow: hidden;
    clip-path: polygon(0 0, 100% 0, 100% 87%, 50% 100%, 0 87%);
    background: radial-gradient(ellipse 80% 50% at 50% 45%, color-mix(in srgb, var(--banner-color) 18%, transparent), transparent 70%);
}
.banner-label {
    /* chứa biệt danh (≤ 16 ký tự) + trạng thái → không được tràn khỏi khung cờ hiệu */
    position: absolute; top: 2.2cqh; left: 2.2cqw; right: 2.2cqw; z-index: 2; text-align: center;
    overflow: hidden; text-overflow: ellipsis;
    font-family: 'Inter', sans-serif; font-weight: 800; font-size: 0.82cqw; letter-spacing: 0.03em; white-space: nowrap;
    color: var(--banner-color); text-shadow: 0 0 0.6cqw var(--banner-glow);
}
.banner-figure { position: absolute; left: 0; right: 0; top: 5.5cqh; bottom: 20cqh; display: flex; align-items: flex-end; justify-content: center; }
.banner-img {
    max-width: 92%; max-height: 100%; object-fit: contain; object-position: bottom center; display: block;
    filter: drop-shadow(0 0 1cqw var(--banner-glow));
}
.player-banner-p2 .banner-img { transform: scaleX(-1); }
.banner-img-fallback { width: 100%; height: 100%; align-items: center; justify-content: center; font-size: 6cqw; }
.banner-text {
    position: absolute; left: 0.4cqw; right: 0.4cqw; bottom: 8cqh; z-index: 2;
    display: flex; flex-direction: column; align-items: center; gap: 0.4cqh; text-align: center;
}
.banner-text::before {
    content: ""; position: absolute; left: -1cqw; right: -1cqw; top: -5cqh; bottom: -9cqh; z-index: -1;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.82) 30%);
}
.banner-name {
    font-family: 'Noto Serif', serif; font-weight: 700; font-size: 2.2cqw; line-height: 1.08; text-transform: uppercase;
    color: color-mix(in srgb, var(--banner-color) 55%, #fff);
    text-shadow: 0 0 0.8cqw var(--banner-glow), 0 0.15cqw 0.2cqw #000;
}
.player-banner-p2 .banner-name { color: #fdba74; text-shadow: 0 0 0.8cqw rgba(249, 115, 22, 0.6), 0 0.15cqw 0.2cqw #000; }
.banner-meta, .banner-skill {
    font-family: 'Noto Serif', serif; font-weight: 700; font-size: 1.15cqw; line-height: 1.2; text-transform: uppercase;
    color: color-mix(in srgb, var(--banner-color) 45%, #fff);
}
.banner-skill { color: #fcd34d; }
.player-banner-p2 .banner-meta { color: #fca5a5; }
.banner-meta, .banner-skill { display: flex; align-items: center; gap: 0.4cqw; }
.banner-icon { width: 1.7cqw; height: 1.7cqw; object-fit: contain; flex: none; filter: drop-shadow(0 0 0.3cqw rgba(0, 0, 0, 0.8)); }
/* Huy hiệu P1/P2 hình khiên ở góc trên cờ hiệu */
.banner-badge {
    display: none;  /* khung banner-p*.png đã có huy hiệu tròn P1/P2; badge-p*.png (khiên) để dành cho HUD */
    position: absolute; top: -1.2cqh; z-index: 3; width: 3.4cqw; height: 3.4cqw;
    background: url('../assets/ui/select/badge-p1.png') center / contain no-repeat;
    filter: drop-shadow(0 0 0.6cqw var(--banner-glow));
}
.player-banner-p1 .banner-badge { left: -1.1cqw; }
.player-banner-p2 .banner-badge { right: -1.1cqw; background-image: url('../assets/ui/select/badge-p2.png'); }

/* ---------- Cột giữa ---------- */
.select-center { position: absolute; left: 27.5cqw; right: 27cqw; top: 15.5cqh; bottom: 19cqh; display: flex; flex-direction: column; align-items: stretch; }
.select-section-head { display: flex; align-items: baseline; justify-content: center; gap: 2cqw; position: relative; padding-bottom: 0.6cqh; }
.select-section-head::after {
    content: ""; position: absolute; left: 6%; right: 6%; bottom: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(251, 191, 36, 0.55), transparent);
}
.select-section-title {
    font-family: 'Noto Serif', serif; font-weight: 700; font-size: 1.85cqw; letter-spacing: 0.04em;
    color: transparent; background: linear-gradient(180deg, #fde68a, #f59e0b); -webkit-background-clip: text; background-clip: text;
    filter: drop-shadow(0 0.1cqw 0.1cqw #000);
}
.select-hint { font-size: 0.85cqw; color: #cbd5e1; }
/* Dòng gợi ý cạnh tiêu đề mục (có thể chứa biệt danh đối thủ) — 1 dòng, cắt "…", không đẩy tiêu đề xuống dòng */
.select-section-head .select-section-title { white-space: nowrap; flex-shrink: 0; }
.select-section-head .select-hint { min-width: 0; max-width: 30cqw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.select-strip {
    margin-top: 1.2cqh; padding: 0.7cqw; border-radius: 0.3cqw;
    background: linear-gradient(180deg, rgba(15, 17, 24, 0.92), rgba(5, 6, 10, 0.92));
    border: 1px solid rgba(148, 163, 184, 0.25); box-shadow: inset 0 0 1.2cqw rgba(0, 0, 0, 0.8);
}

/* Dải thẻ tướng: 1 hàng, cuộn ngang khi nhiều tướng.
   Thẻ = chân dung cắt hình bình hành nghiêng + khung ảnh phủ lên (card.png / card-p1.png / card-p2.png, đã có nhãn P1/P2) */
.hero-roster { display: flex; gap: 0.15cqw; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; scroll-snap-type: x proximity; padding: 0.2cqw; justify-content: safe center; }
.hero-card {
    position: relative; flex: 1 1 0; min-width: 6.4cqw; max-width: 7.4cqw; aspect-ratio: 118 / 146; scroll-snap-align: start;
    padding: 0; border: 0; background: none; cursor: pointer;
    transition: transform 0.12s ease, filter 0.12s ease;
}
.hero-card::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: url('../assets/ui/select/card.png') center / 100% 100% no-repeat;
}
.hero-card.is-p1::after { background-image: url('../assets/ui/select/card-p1.png'); }
.hero-card.is-p2::after { background-image: url('../assets/ui/select/card-p2.png'); }
.hero-card.is-p1.is-p2::after { background-image: url('../assets/ui/select/card-p2.png'), url('../assets/ui/select/card-p1.png'); }
.hero-card:hover { transform: translateY(-0.3cqh); filter: brightness(1.15) drop-shadow(0 0 0.6cqw rgba(251, 191, 36, 0.6)); }
.hero-card.is-p1, .hero-card.is-p2 { filter: drop-shadow(0 0 0.5cqw rgba(255, 255, 255, 0.15)); }
/* Lòng khung thẻ (theo card-p1.png 118×146): bình hành nghiêng phải */
.hero-card-img, .hero-card-img-fallback {
    clip-path: polygon(15% 7%, 93% 7%, 84% 93%, 7% 93%);
}
.hero-card-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; display: block; background: #0b0d12; }
.hero-card-img-fallback { position: absolute; inset: 0; background: #0b0d12; }
.hero-card-img-fallback, .arena-card-img-fallback { width: 100%; height: 100%; align-items: center; justify-content: center; font-size: 2.4cqw; }
.hero-card-name {
    position: absolute; left: 9%; right: 13%; bottom: 7%; padding: 2.2cqh 0 0.7cqh; text-align: center; text-transform: uppercase;
    font-family: 'Noto Serif', serif; font-weight: 700; font-size: 0.72cqw; line-height: 1.12; color: #fef3c7;
    background: linear-gradient(transparent, rgba(2, 4, 10, 0.95) 45%);
    text-shadow: 0 0.1cqw 0.2cqw #000;
}
.hero-badges { display: none; }  /* khung card-p1/p2.png đã có nhãn P1/P2 */

/* Chữ VS (ảnh vs.png: V lửa + S điện) */
.select-vs {
    flex: 1; position: relative; min-height: 0; pointer-events: none;
    background: url('../assets/ui/select/vs.png') center / contain no-repeat;
    transform: scale(1.75);
    filter: drop-shadow(0 0 1.2cqw rgba(249, 115, 22, 0.35));
}
.select-vs > span { display: none; }

/* Dải thẻ lôi đài, cuộn ngang khi nhiều map. Khung ảnh arena.png phủ lên; lôi đài đang chọn dùng khung lửa arena-fire.png (lửa tràn ra ngoài) */
.select-section-head-arena { margin-bottom: 0.4cqh; }
.arena-picker { display: flex; gap: 0.5cqw; overflow-x: auto; overflow-y: hidden; padding: 1.6cqh 0.8cqw 0.6cqh; justify-content: safe center; scroll-snap-type: x proximity; scrollbar-width: thin; }
.arena-card {
    position: relative; flex: 1 1 0; min-width: 9cqw; max-width: 11cqw; aspect-ratio: 154 / 106; cursor: pointer; scroll-snap-align: start;
    padding: 0; border: 0; background: none;
    transition: transform 0.12s ease, filter 0.12s ease;
}
.arena-card::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: url('../assets/ui/select/arena.png') center / 100% 100% no-repeat;
}
.arena-card.is-selected::after {
    /* khung lửa 166×124 so với khung thường 154×106: rộng hơn 6px mỗi bên, lửa trên cao hơn ~12px */
    inset: -11% -3.9% -5.7% -3.9%;
    background-image: url('../assets/ui/select/arena-fire.png');
    animation: arena-fire 1.2s ease-in-out infinite;
}
@keyframes arena-fire { 50% { filter: brightness(1.25) drop-shadow(0 0 0.8cqw rgba(249, 115, 22, 0.8)); } }
.arena-card:hover { transform: translateY(-0.3cqh); filter: brightness(1.15); }
.arena-card-img, .arena-card-img-fallback { position: absolute; left: 5%; right: 5%; top: 7.5%; bottom: 7.5%; width: 90%; height: 85%; }
.arena-card-img { object-fit: cover; display: block; border-radius: 0.2cqw; }
.arena-card-name {
    position: absolute; left: 5%; right: 5%; bottom: 7.5%; padding: 1.4cqh 0.3cqw 0.5cqh; text-align: center; line-height: 1.15; z-index: 1;
    font-family: 'Noto Serif', serif; font-weight: 700; font-size: 0.9cqw; color: #fef3c7;
    background: linear-gradient(transparent, rgba(2, 4, 10, 0.92) 55%);
    text-shadow: 0 0.1cqw 0.2cqw #000;
}

/* ---------- Nút chế độ (ảnh btn-ai / btn-pvp 425×102) & nút thử (btn-test 724×88) ---------- */
.select-actions { position: absolute; left: 24cqw; right: 24cqw; top: 80cqh; height: 10.8cqh; display: flex; gap: 1.2cqw; }
.select-mode-btn {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 0.8cqw; cursor: pointer; border: 0; color: #fff;
    font-family: 'Noto Serif', serif; font-weight: 700; font-size: 1.95cqw; letter-spacing: 0.02em;
    background: url('../assets/ui/select/btn-ai.png') center / 100% 100% no-repeat;
    text-shadow: 0 0.15cqw 0.25cqw rgba(0, 0, 0, 0.9);
    transition: transform 0.15s ease, filter 0.15s ease;
}
.select-mode-pvp { background-image: url('../assets/ui/select/btn-pvp.png'); }
.select-mode-btn:hover { transform: translateY(-0.3cqh); filter: brightness(1.2) drop-shadow(0 0 0.8cqw rgba(253, 224, 71, 0.5)); }
.select-mode-icon { width: 2.6cqw; height: 2.6cqw; object-fit: contain; filter: drop-shadow(0 0.1cqw 0.2cqw rgba(0, 0, 0, 0.8)); }
.select-test { position: absolute; left: 24cqw; right: 24cqw; top: 91cqh; height: 8cqh; }
.select-test-btn {
    width: 100%; height: 100%; cursor: pointer; padding: 0 6cqw; border: 0;
    font-family: 'Noto Serif', serif; font-weight: 700; font-size: 1.15cqw; line-height: 1.25; color: #fde68a;
    background: url('../assets/ui/select/btn-test.png') center / 100% 100% no-repeat;
    text-shadow: 0 0.1cqw 0.2cqw #000;
    transition: filter 0.15s ease;
}
.select-test-btn:hover { filter: brightness(1.25); }

/* Song đấu (net/online.js): .is-online = chỉ chọn tướng của mình, lôi đài do server bốc; .is-ready = đã chốt tướng */
#start-screen.is-online .player-banner { cursor: default; }
#start-screen.is-ready .hero-roster, #start-screen.is-ready .arena-picker { opacity: 0.55; pointer-events: none; }
/* Huy hiệu trên thẻ lôi đài: ai đang chọn lôi đài này (lam = bên trái P1, đỏ = bên phải P2) */
.arena-badges { position: absolute; left: 5%; right: 5%; top: 9%; z-index: 2; display: flex; justify-content: space-between; gap: 0.2cqw; pointer-events: none; }
.arena-badge {
    padding: 0.15cqh 0.4cqw; border-radius: 0.3cqw; line-height: 1.2;
    font-family: 'Noto Serif', serif; font-weight: 700; font-size: 0.72cqw; color: #fff; text-shadow: 0 0.08cqw 0.15cqw #000;
}
.arena-badge-p1 { background: rgba(2, 132, 199, 0.9); box-shadow: 0 0 0.5cqw rgba(56, 189, 248, 0.7); }
.arena-badge-p2 { background: rgba(185, 28, 28, 0.9); box-shadow: 0 0 0.5cqw rgba(248, 113, 113, 0.7); margin-left: auto; }
#start-screen.is-ready #select-confirm { filter: hue-rotate(-35deg) brightness(1.1); }

/* ============================================================
 *  MÀN CHỌN CHẾ ĐỘ (#mode-screen, ui/menu.js) — hiện đầu tiên: ĐẤU VỚI MÁY / SONG ĐẤU (tìm trận online)
 * ============================================================ */
.mode-emblem { top: 17cqh; height: 44cqh; }
.mode-actions { top: 65cqh; }
.mode-scene.is-searching .mode-actions { opacity: 0.35; pointer-events: none; }
/* Phòng riêng: [TẠO PHÒNG] [mã 5 số] [VÀO PHÒNG] — ẩn khi đang tìm trận / chờ trong phòng */
.mode-room { position: absolute; left: 27cqw; right: 27cqw; top: 78cqh; height: 6.8cqh; display: flex; gap: 0.8cqw; align-items: stretch; }
.mode-scene.is-searching .mode-room { visibility: hidden; }
.mode-room-btn { flex: 1; padding: 0; font-size: 1.1cqw; }
.mode-room-input {
    width: 10cqw; padding: 0 0.6cqw; text-align: center; outline: none;
    font-family: 'Cinzel', 'Noto Serif', serif; font-weight: 900; font-size: 1.5cqw; letter-spacing: 0.2em; color: #fde68a;
    background: rgba(2, 6, 23, 0.75); border: 0.12cqw solid rgba(253, 230, 138, 0.55); border-radius: 0.4cqw;
}
.mode-room-input::placeholder { color: rgba(203, 213, 225, 0.55); font-family: 'Noto Serif', serif; font-weight: 600; font-size: 0.95cqw; letter-spacing: 0.02em; }
.mode-room-input:focus { border-color: #fde68a; box-shadow: 0 0 0.8cqw rgba(251, 191, 36, 0.5); }
.matchmaking-code {
    display: none; font-family: 'Cinzel', 'Noto Serif', serif; font-weight: 900; font-size: 2.6cqw; letter-spacing: 0.25em; color: #fff;
    text-shadow: 0 0 1cqw rgba(251, 191, 36, 0.8), 0 0.15cqw 0.2cqw #000; user-select: all;
}
.matchmaking.is-hosting .matchmaking-code { display: inline; }
.matchmaking.is-hosting .matchmaking-spinner { display: none; }
.matchmaking-buttons { display: flex; gap: 0.8cqw; }
.matchmaking-copy { display: none; }
.matchmaking.is-hosting .matchmaking-copy { display: block; }
.mode-notice {
    position: absolute; left: 18cqw; right: 18cqw; top: 87cqh; text-align: center; pointer-events: none;
    font-family: 'Noto Serif', serif; font-weight: 700; font-size: 1.2cqw; color: #fca5a5;
    text-shadow: 0 0.1cqw 0.25cqw #000;
}
.matchmaking {
    position: absolute; left: 22cqw; right: 22cqw; top: 77cqh;
    display: flex; flex-direction: column; align-items: center; gap: 1.2cqh;
}
.matchmaking-row {
    display: flex; align-items: center; gap: 0.8cqw;
    font-family: 'Noto Serif', serif; font-weight: 700; font-size: 1.45cqw; color: #fde68a;
    text-shadow: 0 0.1cqw 0.25cqw #000, 0 0 0.8cqw rgba(251, 191, 36, 0.45);
}
.matchmaking-time { min-width: 3.2cqw; color: #7dd3fc; font-variant-numeric: tabular-nums; }
.matchmaking-spinner {
    width: 1.5cqw; height: 1.5cqw; border-radius: 50%;
    border: 0.22cqw solid rgba(253, 230, 138, 0.25); border-top-color: #fde68a;
    animation: matchmaking-spin 0.9s linear infinite;
}
@keyframes matchmaking-spin { to { transform: rotate(360deg); } }
.matchmaking-cancel { width: 17cqw; height: 7cqh; padding: 0; font-size: 1.15cqw; }

/* Trong trận song đấu: chưa nhận được phím của đối thủ */
.net-waiting {
    left: 50%; top: 20%; transform: translateX(-50%); pointer-events: none; white-space: nowrap;
    padding: 0.45em 1.3em; border-radius: 999px;
    background: rgba(2, 6, 23, 0.78); border: 1px solid rgba(253, 230, 138, 0.5);
    font-family: 'Noto Serif', serif; font-weight: 700; font-size: clamp(12px, 1.25vw, 20px); color: #fde68a;
}
#rematch-button.is-disabled { opacity: 0.4; filter: grayscale(1); pointer-events: none; }

/* ---------- Hướng dẫn phím: nút nhỏ góc trái dưới, bảng nổi ---------- */
.select-guide { position: absolute; left: 1.2cqw; bottom: 1.6cqh; z-index: 5; font-size: 0.95cqw; text-align: left; }
.select-guide summary {
    cursor: pointer; list-style: none; padding: 0.4cqw 0.8cqw; border-radius: 0.4cqw;
    font-family: 'Noto Serif', serif; font-weight: 700; color: #fde68a;
    background: rgba(15, 23, 42, 0.85); border: 1px solid rgba(251, 191, 36, 0.45);
}
.select-guide summary::-webkit-details-marker { display: none; }
.select-guide-body {
    position: absolute; left: 0; bottom: calc(100% + 0.6cqh); width: 46cqw; max-height: 70cqh; overflow-y: auto; padding-top: 0.8cqw;
    background: rgba(2, 6, 23, 0.96); border: 1px solid rgba(56, 189, 248, 0.35); border-radius: 0.6cqw;
    box-shadow: 0 0 2cqw rgba(0, 0, 0, 0.8); font-size: 1cqw;
}

/* Ma khí vần vũ (ui/select-fx.js): canvas ngay trên ảnh nền, dưới mọi khung/nút */
.select-mist { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* Nút âm thanh (góc phải dưới, hiện cả trong trận) — ảnh art-source/game-scene/back-ground-sound.png → assets/ui/select/btn-sound.png.
   Khung game là container theo bề rộng → cqw = % bề rộng khung, nút co giãn cùng khung. */
.game-wrapper { container-type: inline-size; }
/* Cụm nút góc phải dưới (âm thanh, toàn màn hình): cùng cỡ, có cỡ tối thiểu cho màn nhỏ; chỉ hiện ở màn chọn tướng */
.corner-buttons { top: 5px; right: 5px; gap: 5px; }
/* Trong trận: cùng góc phải trên như màn chọn tướng (nằm trên HUD, z-30 > HUD z-20) nhưng đè lên khung chân dung P2
   → nhỏ hơn (24px) & mờ 60%; rê chuột / chạm / đang focus thì rõ lại */
.game-wrapper.in-match .corner-buttons { gap: 4px; opacity: 0.6; transition: opacity 0.15s ease; }
.game-wrapper.in-match .corner-buttons:hover, .game-wrapper.in-match .corner-buttons:focus-within,
.game-wrapper.in-match .corner-buttons:active { opacity: 1; }
.game-wrapper.in-match .sound-toggle { width: max(1.9cqw, 24px); height: max(1.9cqw, 24px); font-size: max(1cqw, 12px); }
/* Nút tròn nhỏ chỉ có biểu tượng (âm thanh, toàn màn hình) — viền vàng mảnh, nền tối mờ */
.sound-toggle {
    width: max(2.4cqw, 30px); height: max(2.4cqw, 30px); padding: 0; cursor: pointer; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: max(1.2cqw, 15px); line-height: 1;
    color: #fde68a; background: radial-gradient(circle at 50% 35%, rgba(41, 37, 36, 0.85), rgba(5, 6, 10, 0.85));
    border: 1px solid rgba(251, 191, 36, 0.6);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
    transition: filter 0.15s ease, transform 0.15s ease;
}
.sound-toggle:hover { filter: brightness(1.25); transform: scale(1.06); border-color: #fde68a; }
/* Nút ngôn ngữ EN / VI (core/i18n.js) — cùng khung tròn với nút âm thanh, chữ thay biểu tượng */
.lang-toggle { font-family: 'Inter', sans-serif; font-weight: 800; font-size: max(0.85cqw, 11px); letter-spacing: 0.04em; }

/* ============================================================
 *  MÀN NẠP (ui/loading-screen.js) — cùng bộ ảnh màn chọn (assets/ui/select/)
 *  Nạp game: biểu tượng VS thở sáng + thanh tiến độ trong biển vàng (btn-test.png)
 *  Nạp trận (.is-match): cờ hiệu P1 trái / P2 phải + VS + tên lôi đài
 * ============================================================ */
.load-scene { container-type: size; overflow: hidden; color: #f8fafc; background: #07080d; }
.load-tagline {
    position: absolute; left: 0; right: 0; top: 11.5cqh; text-align: center; pointer-events: none;
    font-family: 'Noto Serif', serif; font-weight: 700; font-size: 1.05cqw; letter-spacing: 0.25em; color: #7dd3fc;
    text-shadow: 0 0 0.8cqw rgba(56, 189, 248, 0.6);
}
.load-emblem {
    position: absolute; left: 35cqw; right: 35cqw; top: 22cqh; height: 50cqh; pointer-events: none;
    background: url('../assets/ui/select/vs.png') center / contain no-repeat;
    animation: load-breathe 2.2s ease-in-out infinite;
}
@keyframes load-breathe {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 1cqw rgba(249, 115, 22, 0.35)); }
    50% { transform: scale(1.06); filter: drop-shadow(0 0 2.4cqw rgba(96, 165, 250, 0.55)); }
}
.load-matchup { position: absolute; inset: 0; pointer-events: none; }
.load-banner { top: 16cqh; height: 66cqh; width: 18cqw; cursor: default; }
.load-banner.player-banner-p1 { left: 10cqw; animation: load-slide-left 0.5s ease-out both; }
.load-banner.player-banner-p2 { right: 10cqw; animation: load-slide-right 0.5s ease-out both; }
.load-banner:hover { transform: none; }
@keyframes load-slide-left { from { transform: translateX(-12cqw); opacity: 0; } }
@keyframes load-slide-right { from { transform: translateX(12cqw); opacity: 0; } }
.load-vs {
    position: absolute; left: 36cqw; right: 36cqw; top: 26cqh; height: 38cqh;
    background: url('../assets/ui/select/vs.png') center / contain no-repeat;
    animation: load-vs-in 0.45s 0.15s cubic-bezier(0.2, 1.6, 0.4, 1) both, load-breathe 2.2s 0.6s ease-in-out infinite;
}
@keyframes load-vs-in { from { transform: scale(2.4); opacity: 0; } }
.load-arena {
    position: absolute; left: 26cqw; right: 26cqw; top: 66cqh; text-align: center; white-space: pre-line;
    font-family: 'Noto Serif', serif; font-weight: 700; font-size: 1.6cqw; color: #fde68a;
    text-shadow: 0 0 1cqw rgba(251, 191, 36, 0.45), 0 0.15cqw 0.2cqw #000;
}
.load-progress {
    position: absolute; left: 26cqw; right: 26cqw; top: 82cqh; height: 11cqh;
    background: url('../assets/ui/select/btn-test.png') center / 100% 100% no-repeat;
}
.load-track {
    position: absolute; left: 7%; right: 7%; top: 24%; height: 24%; overflow: hidden;
    border-radius: 999px; background: rgba(5, 6, 10, 0.9);
    border: 0.1cqw solid rgba(202, 138, 4, 0.75); box-shadow: inset 0 0 0.6cqw rgba(0, 0, 0, 0.9);
}
.load-bar {
    height: 100%; border-radius: 999px; transition: width 0.2s ease-out;
    background: linear-gradient(90deg, #0e7490, #38bdf8 45%, #fde68a 80%, #f97316);
    box-shadow: 0 0 0.8cqw rgba(56, 189, 248, 0.8);
}
.load-status {
    position: absolute; left: 8%; right: 8%; top: 56%; display: flex; justify-content: space-between; align-items: center;
    font-family: 'Noto Serif', serif; font-size: 1.05cqw; text-shadow: 0 0.1cqw 0.2cqw #000;
}
.load-label { font-style: italic; color: #bae6fd; }
.load-percent { font-weight: 700; color: #fcd34d; }
.load-error { position: absolute; left: 25cqw; right: 25cqw; top: 68cqh; text-align: center; }
.load-error p { font-size: 1.1cqw; color: #fda4af; margin-bottom: 1cqh; text-shadow: 0 0.1cqw 0.2cqw #000; }
.load-retry { width: 18cqw; height: 7cqh; margin: 0 auto; font-size: 1.4cqw; }

/* ============================================================
 *  BẢNG KẾT QUẢ TRẬN (game/match.js) — phủ mờ lên trận (vẫn thấy người thắng tung tư thế chiến thắng)
 *  Cờ hiệu người thắng bên trái (hoà: VS) · bên phải: tiêu đề, tên người thắng, câu bình, chỉ số, 2 nút ảnh
 * ============================================================ */
.result-scene { container-type: size; overflow: hidden; color: #f8fafc; animation: result-fade 0.45s ease-out both; }
@keyframes result-fade { from { opacity: 0; } }
.result-shade {
    position: absolute; inset: 0;
    background:
        radial-gradient(ellipse 60% 70% at 62% 50%, rgba(5, 6, 10, 0.55), rgba(5, 6, 10, 0.88)),
        linear-gradient(90deg, rgba(5, 6, 10, 0.35), transparent 40%);
    backdrop-filter: blur(2px);
}
.result-banner { left: 10cqw; top: 9cqh; height: 80cqh; width: 21cqw; cursor: default; animation: result-banner-in 0.55s 0.1s cubic-bezier(0.2, 1.3, 0.4, 1) both, banner-pulse 2.2s 0.7s ease-in-out infinite; }
.result-banner:hover { transform: none; }
@keyframes result-banner-in { from { transform: translateY(6cqh) scale(0.92); opacity: 0; } }
.result-draw {
    position: absolute; left: 9cqw; top: 20cqh; width: 24cqw; height: 50cqh;
    background: url('../assets/ui/select/vs.png') center / contain no-repeat;
    animation: load-breathe 2.2s ease-in-out infinite;
}
.result-panel {
    position: absolute; left: 37cqw; right: 7cqw; top: 13cqh; bottom: 9cqh;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.2cqh; text-align: center;
    animation: result-panel-in 0.5s 0.25s ease-out both;
}
@keyframes result-panel-in { from { transform: translateX(4cqw); opacity: 0; } }
.result-head { width: 70%; }
.result-title {
    margin: 0; font-family: 'Noto Serif', serif; font-weight: 700; font-size: 3.3cqw; line-height: 1.1; text-transform: uppercase;
    color: transparent; -webkit-background-clip: text; background-clip: text;
    background-image: linear-gradient(180deg, #fef3c7, #fbbf24 55%, #b45309);
    filter: drop-shadow(0 0.2cqw 0.2cqw rgba(0, 0, 0, 0.9)) drop-shadow(0 0 1.2cqw rgba(251, 191, 36, 0.45));
}
.result-title-p1 { background-image: linear-gradient(180deg, #f0fdff, #67e8f9 50%, #0e7490); filter: drop-shadow(0 0.2cqw 0.2cqw rgba(0, 0, 0, 0.9)) drop-shadow(0 0 1.2cqw rgba(34, 211, 238, 0.55)); }
.result-title-p2 { background-image: linear-gradient(180deg, #fff1e6, #fb923c 50%, #b91c1c); filter: drop-shadow(0 0.2cqw 0.2cqw rgba(0, 0, 0, 0.9)) drop-shadow(0 0 1.2cqw rgba(239, 68, 68, 0.55)); }
.result-subtitle { margin: 0; font-family: 'Noto Serif', serif; font-style: italic; font-size: 1.45cqw; color: #e2e8f0; text-shadow: 0 0.1cqw 0.2cqw #000; }
.result-stats { display: flex; gap: 1.2cqw; width: 100%; justify-content: center; }
.result-stat {
    flex: 1; max-width: 15cqw; padding: 1.2cqh 0.8cqw; display: flex; flex-direction: column; gap: 0.4cqh;
    background: linear-gradient(180deg, rgba(41, 33, 15, 0.9), rgba(15, 12, 6, 0.9));
    border: 0.1cqw solid rgba(202, 138, 4, 0.6); border-radius: 0.4cqw; box-shadow: inset 0 0 1cqw rgba(0, 0, 0, 0.8);
    font-family: 'Noto Serif', serif;
}
.result-stat span { font-size: 0.9cqw; color: #cbd5e1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-stat b { font-size: 1.7cqw; color: #fde68a; }
.result-stat.is-p1 b { color: #67e8f9; }
.result-stat.is-p2 b { color: #fca5a5; }
.result-actions { display: flex; gap: 1.4cqw; width: 92%; height: 10.5cqh; margin-top: 1cqh; }

/* Màn nạp game: 2 hero đứng 2 bên VS (ảnh toàn thân, P2 lật quay vào giữa), quầng sáng lam / đỏ dưới chân */
.load-figures { position: absolute; inset: 0; pointer-events: none; }
.load-figure {
    position: absolute; bottom: 19cqh; height: 62cqh; max-width: 26cqw; object-fit: contain; object-position: bottom center;
    opacity: 0; transition: opacity 0.6s ease, transform 0.6s ease;
}
.load-figure-p1 { left: 10cqw; transform: translateX(-4cqw); filter: drop-shadow(0 0 1.4cqw rgba(34, 211, 238, 0.55)); }
.load-figure-p2 { right: 10cqw; transform: translateX(4cqw) scaleX(-1); filter: drop-shadow(0 0 1.4cqw rgba(239, 68, 68, 0.55)); }
.load-figure-p1.is-shown { opacity: 1; transform: none; animation: load-figure-float 3.2s ease-in-out infinite; }
.load-figure-p2.is-shown { opacity: 1; transform: scaleX(-1); animation: load-figure-float-p2 3.2s 0.8s ease-in-out infinite; }
@keyframes load-figure-float { 50% { transform: translateY(-0.8cqh); } }
@keyframes load-figure-float-p2 { 50% { transform: scaleX(-1) translateY(-0.8cqh); } }
.load-figures::before, .load-figures::after {
    content: ""; position: absolute; bottom: 16cqh; width: 22cqw; height: 8cqh; border-radius: 50%;
    background: radial-gradient(ellipse, rgba(34, 211, 238, 0.35), transparent 70%);
}
.load-figures::before { left: 12cqw; }
.load-figures::after { right: 12cqw; background: radial-gradient(ellipse, rgba(239, 68, 68, 0.35), transparent 70%); }

/* ============================================================
 *  HUD TRẬN ĐẤU — ảnh art-source/game-scene/match/*.png → assets/ui/hud/ (docs/ui-templates/build-match-hud.ps1)
 *  Mọi toạ độ ô bên trong tính theo % kích thước ảnh gốc (đo bằng [UiFlood]::Region trong ui-flood.cs):
 *    statbar-p1.png 442×150: rãnh máu x 15–411, y 47–72 · rãnh chân nguyên x 11–382, y 82–92
 *    statbar-p2.png 442×150: rãnh máu x 28–427, y 51–76 · rãnh chân nguyên x 56–430, y 85–96
 *    avatar-p1.png 132×152 / avatar-p2.png 155×151: chân dung cắt theo avatar-p*-mask.png (lòng khiên)
 *    timer.png 738×592 (time.png ghép đối xứng): mặt đồng hồ tâm (369, 314), rộng 273
 *  Kích thước theo cqw (khung game là container) → co giãn cùng khung game.
 * ============================================================ */
.game-hud { height: 16cqw; }
.hud-side { position: absolute; top: 0; width: 46cqw; height: 15cqw; --side-color: #22d3ee; --side-glow: rgba(34, 211, 238, 0.6); }
.hud-side-p1 { left: 0; }
.hud-side-p2 { right: 0; --side-color: #ef4444; --side-glow: rgba(239, 68, 68, 0.6); }
.hud-side > * { position: absolute; }

/* Khung chân dung: khung ảnh dưới (lòng khiên vẽ đặc), chân dung phủ trên cắt theo mặt nạ lòng khiên, huy hiệu Lv trên cùng */
.hud-avatar { z-index: 2; top: 0.9cqw; width: 8.8cqw; aspect-ratio: 132 / 152; filter: drop-shadow(0 0 0.6cqw var(--side-glow)); }
.hud-side-p1 .hud-avatar { left: 1.8cqw; }
.hud-side-p2 .hud-avatar { right: 1.4cqw; width: 10.3cqw; aspect-ratio: 155 / 151; }
.hud-avatar::after {
    content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0;
    background: url('../assets/ui/hud/avatar-p1.png') center / 100% 100% no-repeat;
}
.hud-side-p2 .hud-avatar::after { background-image: url('../assets/ui/hud/avatar-p2.png'); }
.hud-portrait {
    position: absolute; inset: 0; z-index: 1; display: flex; align-items: center; justify-content: center; font-size: 3cqw; overflow: hidden;
    background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--side-color) 30%, #0b1220), #05070c 70%);
    -webkit-mask: url('../assets/ui/hud/avatar-p1-mask.png') center / 100% 100% no-repeat;
    mask: url('../assets/ui/hud/avatar-p1-mask.png') center / 100% 100% no-repeat;
}
.hud-side-p2 .hud-portrait {
    -webkit-mask-image: url('../assets/ui/hud/avatar-p2-mask.png');
    mask-image: url('../assets/ui/hud/avatar-p2-mask.png');
}
/* Ảnh chân dung (portrait.png 256²: đầu & thân trên) đặt vào vùng lòng khiên */
.hud-portrait img { position: absolute; left: 14%; top: 18%; width: 70%; height: 70%; object-fit: cover; object-position: 50% 10%; display: block; }
.hud-side-p2 .hud-portrait img { left: 18%; top: 20%; width: 64%; height: 72%; transform: scaleX(-1); }
.hud-level {
    left: 50%; bottom: 0.2cqw; transform: translateX(-50%); z-index: 2; white-space: nowrap;
    padding: 0.05cqw 0.55cqw; border-radius: 0.5cqw; font-family: 'Noto Serif', serif; font-weight: 700; font-size: 0.85cqw; color: #fde68a;
    background: linear-gradient(180deg, #1c1a14, #0a0907); border: 0.12cqw solid #ca8a04; box-shadow: 0 0 0.4cqw rgba(0, 0, 0, 0.8);
}
.hud-avatar > .hud-level { position: absolute; z-index: 2; }

/* Tên */
.hud-name {
    top: 1.7cqw; max-width: 30cqw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-family: 'Noto Serif', serif; font-weight: 700; font-size: 1.6cqw; letter-spacing: 0.02em; text-transform: uppercase;
    color: transparent; background: linear-gradient(180deg, #fffbeb, #fcd34d 70%, #b45309); -webkit-background-clip: text; background-clip: text;
    filter: drop-shadow(0 0.12cqw 0.12cqw rgba(0, 0, 0, 0.95));
}
.hud-side-p1 .hud-name { left: 11cqw; }
.hud-side-p2 .hud-name { right: 11cqw; }

/* Khung thanh trạng thái (ảnh statbar): chứa cả rãnh máu & rãnh chân nguyên. Hai thanh đặt tuyệt đối theo % ảnh. */
.hud-statbar { top: 1.6cqw; width: 33cqw; aspect-ratio: 442 / 150; background: url('../assets/ui/hud/statbar-p1.png') center / 100% 100% no-repeat; }
.hud-side-p1 .hud-statbar { left: 9.6cqw; }   /* sát mép phải khung khiên P1 */
.hud-side-p2 .hud-statbar { right: 9.6cqw;   /* đối xứng gương với P1 (viền lửa khung P2 phủ lên đầu thanh) */ background-image: url('../assets/ui/hud/statbar-p2.png'); }
.hud-statbar > * { position: absolute; }
.hud-hp { left: 3.4%; width: 89.8%; top: 31.3%; height: 17.3%; }
.hud-side-p2 .hud-hp { left: 6.8%; width: 89.8%; top: 34%; }   /* cùng độ dài rãnh máu P1, mép trong khớp rãnh ảnh (x 427/442) */
.hud-hp-fill-area { position: absolute; inset: 0; overflow: hidden; }
.hud-side-p1 .hud-hp-fill-area { clip-path: polygon(0 0, 100% 0, 97.5% 100%, 0 100%); }
.hud-side-p2 .hud-hp-fill-area { clip-path: polygon(0 0, 100% 0, 100% 100%, 2.5% 100%); }
.hud-hp-delay, .hud-hp-bar { position: absolute; top: 0; height: 100%; }
.hud-hp-delay { background: #fcd34d; transition: width 0.5s ease-out; }
.hud-hp-bar { transition: width 0.1s linear; }
.hud-side-p1 .hud-hp-delay, .hud-side-p1 .hud-hp-bar { left: 0; }
.hud-side-p2 .hud-hp-delay, .hud-side-p2 .hud-hp-bar { right: 0; }
.hud-side-p1 .hud-hp-bar { background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 45%, rgba(0, 0, 0, 0.2)), linear-gradient(90deg, #991b1b, #dc2626 45%, #f97316 85%, #fbbf24); }
.hud-side-p2 .hud-hp-bar { background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 45%, rgba(0, 0, 0, 0.2)), linear-gradient(270deg, #581c87, #7e22ce 45%, #a855f7 85%, #d946ef); }
.hud-hp-text {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 1;
    font-family: 'Noto Serif', serif; font-weight: 700; font-size: 1.1cqw; color: #fff; text-shadow: 0 0 0.3cqw #000, 0 0.1cqw 0.15cqw #000;
}
.hud-energy { left: 2.5%; width: 84.2%; top: 54.7%; height: 7.3%; overflow: hidden; }
.hud-side-p2 .hud-energy { left: 12.7%; width: 84.8%; top: 56.7%; height: 8%; }
.hud-energy-bar { height: 100%; transition: width 0.15s linear; box-shadow: 0 0 0.6cqw var(--side-glow); }
.hud-side-p1 .hud-energy-bar { background: linear-gradient(90deg, #0369a1, #22d3ee 70%, #cffafe); }
.hud-side-p2 .hud-energy-bar { margin-left: auto; background: linear-gradient(270deg, #a21caf, #e879f9 70%, #fae8ff); }

/* Ô tuyệt kỹ: sáng khi đủ chân nguyên tung 1 tuyệt kỹ */
.hud-pips { top: 9.4cqw; display: flex; gap: 0.6cqw; }
.hud-side-p1 .hud-pips { left: 11cqw; }
.hud-side-p2 .hud-pips { right: 11cqw; flex-direction: row-reverse; }
.hud-pips span {
    width: 1.4cqw; height: 1.4cqw; border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #1e293b, #05070c 70%);
    border: 0.14cqw solid #94a3b8; box-shadow: inset 0 0 0.3cqw #000;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}
.hud-pips span.is-on {
    background: radial-gradient(circle at 40% 35%, #fff, color-mix(in srgb, var(--side-color) 80%, #fff) 35%, var(--side-color) 75%);
    box-shadow: 0 0 0.7cqw var(--side-glow), inset 0 0 0.2cqw #fff;
}

/* Giữa: VS trên, huy chương đồng hồ (timer.png, 2 cánh) dưới, chế độ dưới cùng */
.hud-center { position: absolute; left: 50%; top: 0; width: 15cqw; height: 15cqw; transform: translateX(-50%); }
.hud-medallion {
    position: absolute; left: 50%; top: 2.6cqw; width: 13.5cqw; aspect-ratio: 738 / 592; transform: translateX(-50%);
    background: url('../assets/ui/hud/timer.png') center / 100% 100% no-repeat;
    filter: drop-shadow(0 0.2cqw 0.4cqw rgba(0, 0, 0, 0.8));
}
.hud-timer {
    position: absolute; left: 50%; top: 53.1%; transform: translate(-50%, -50%);
    font-family: 'Noto Serif', serif; font-weight: 700; font-size: 2.4cqw; line-height: 1;
    color: transparent; background: linear-gradient(180deg, #fffbeb, #fcd34d 60%, #b45309); -webkit-background-clip: text; background-clip: text;
    filter: drop-shadow(0 0.1cqw 0.1cqw #000);
}
.hud-vs {
    position: absolute; left: 50%; top: -0.6cqw; width: 11cqw; height: 7cqw; transform: translateX(-50%); z-index: 1;
    font-size: 0; color: transparent;
    background: url('../assets/ui/select/vs.png') center / contain no-repeat;
    filter: drop-shadow(0 0 0.6cqw rgba(249, 115, 22, 0.4));
}
.hud-mode {
    position: absolute; left: 0; right: 0; top: 13.6cqw; text-align: center;
    font-family: 'Noto Serif', serif; font-weight: 700; font-size: 0.95cqw; letter-spacing: 0.06em; white-space: nowrap;
    color: #e2e8f0; text-shadow: 0 0 0.4cqw #000, 0 0.1cqw 0.15cqw #000;
}

/* ============================================================
 *  CHỮ TRONG TRẬN — cùng phong cách UI mới (kim loại tối viền bạc/vàng, chữ Noto Serif ánh kim)
 *  Kích thước theo cqw (khung game là container) → co giãn cùng HUD.
 * ============================================================ */
/* Banner giữa màn: chữ ánh kim bật phóng to, 2 vệt hoa văn hai bên, tan dần (showBanner trong ui/hud.js) */
.match-banner { display: flex; align-items: center; justify-content: center; --banner-duration: 1100ms; }
.match-banner-plate {
    position: relative; padding: 1.2cqw 6cqw;
    background: radial-gradient(ellipse 50% 60% at 50% 50%, rgba(5, 6, 10, 0.75), rgba(5, 6, 10, 0) 75%);
}
.match-banner-plate::before, .match-banner-plate::after {
    content: ""; position: absolute; top: 50%; width: 14cqw; height: 0.25cqw; transform: translateY(-50%);
    background: linear-gradient(90deg, transparent, var(--banner-line, #fbbf24) 70%, #fff);
    filter: drop-shadow(0 0 0.5cqw var(--banner-line, #fbbf24));
}
.match-banner-plate::before { right: 100%; margin-right: -4.5cqw; }
.match-banner-plate::after { left: 100%; margin-left: -4.5cqw; transform: translateY(-50%) scaleX(-1); }
.match-banner-text {
    margin: 0; font-family: 'Cinzel', 'Noto Serif', serif; font-weight: 900; font-size: 5.4cqw; letter-spacing: 0.06em; line-height: 1.1;
    text-transform: uppercase; white-space: nowrap; color: transparent;
    background: var(--banner-fill, linear-gradient(180deg, #fffbeb 0%, #fde68a 35%, #f59e0b 65%, #92400e 100%));
    -webkit-background-clip: text; background-clip: text;
    filter: drop-shadow(0 0.2cqw 0 #1c1206) drop-shadow(0 0 1.4cqw var(--banner-line, rgba(251, 191, 36, 0.6)));
}
.match-banner.is-gold { --banner-line: #fbbf24; }
.match-banner.is-danger { --banner-line: #ef4444; --banner-fill: linear-gradient(180deg, #fff1f2 0%, #fca5a5 35%, #dc2626 70%, #7f1d1d 100%); }
.match-banner.is-info { --banner-line: #38bdf8; --banner-fill: linear-gradient(180deg, #f0f9ff 0%, #bae6fd 35%, #38bdf8 70%, #0c4a6e 100%); }
.match-banner.is-info .match-banner-text { font-size: 3.2cqw; }
.match-banner.is-playing .match-banner-plate { animation: match-banner-in var(--banner-duration) ease-out both; }
@keyframes match-banner-in {
    0% { transform: scale(1.9); opacity: 0; }
    14% { transform: scale(0.96); opacity: 1; }
    22% { transform: scale(1); }
    80% { opacity: 1; }
    100% { transform: scale(1.04); opacity: 0; }
}

/* Lửa quanh khung chân dung & thanh máu (ui/hud-flames.js): canvas phủ toàn HUD, không nhận chuột */
.hud-flames { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }

/* ============================================================
 *  THIẾT BỊ & TOÀN MÀN HÌNH (ui/device-mode.js gắn class lên <html>)
 *    .input-touch      đang điều khiển cảm ứng → hiện cụm nút chiêu & D-pad (khi trong trận)
 *    .is-mobile-device điện thoại / máy tính bảng → màn nhắc xoay ngang khi cầm dọc
 *    .can-fullscreen   trình duyệt hỗ trợ toàn màn hình (mọi thiết bị; iPhone Safari không có) → hiện nút toàn màn hình
 * ============================================================ */
html:not(.input-touch) #skill-bar { display: none; }
.fullscreen-toggle { display: none; }   /* cùng cỡ & nền với nút âm thanh (.sound-toggle) */
.can-fullscreen .fullscreen-toggle { display: flex; }
/* Toàn màn hình: khung game chiếm tối đa màn hình (bỏ lề / bo góc) */
:fullscreen body { padding: 0; }
:fullscreen #game-wrapper { max-width: none; max-height: 100vh; width: min(100vw, 100vh * 16 / 9); border-radius: 0; border: 0; }

.rotate-overlay {
    display: none; position: fixed; inset: 0; z-index: 100;
    flex-direction: column; align-items: center; justify-content: center; gap: 4vw; padding: 8vw; text-align: center;
    color: #f8fafc;
    background:
        radial-gradient(ellipse 80% 60% at 50% 45%, transparent 40%, rgba(0, 0, 0, 0.7)),
        url('../assets/ui/select/backdrop.jpg') center / cover no-repeat, #07080d;
}
@media (orientation: portrait) {
    .is-mobile-device .rotate-overlay { display: flex; }
    .is-mobile-device #game-wrapper { visibility: hidden; }
}
.rotate-phone {
    position: relative; width: 22vw; height: 38vw; border-radius: 3.5vw;
    border: 1.2vw solid #cbd5e1; box-shadow: 0 0 4vw rgba(56, 189, 248, 0.5), inset 0 0 3vw rgba(56, 189, 248, 0.25);
    animation: rotate-phone 2.4s ease-in-out infinite;
}
.rotate-phone span { position: absolute; left: 50%; bottom: 2vw; width: 5vw; height: 1vw; border-radius: 1vw; background: #cbd5e1; transform: translateX(-50%); }
@keyframes rotate-phone {
    0%, 20% { transform: rotate(0deg); }
    55%, 85% { transform: rotate(-90deg); }
    100% { transform: rotate(0deg); }
}
.rotate-title {
    margin: 0; font-family: 'Cinzel', 'Noto Serif', serif; font-weight: 900; font-size: 7vw; letter-spacing: 0.04em; line-height: 1.15;
    color: transparent; background: linear-gradient(180deg, #fffbeb, #fcd34d 55%, #b45309); -webkit-background-clip: text; background-clip: text;
    filter: drop-shadow(0 0.4vw 0.4vw rgba(0, 0, 0, 0.9));
}
.rotate-text { margin: 0; font-family: 'Noto Serif', serif; font-size: 4vw; line-height: 1.5; color: #e2e8f0; text-shadow: 0 0.3vw 0.5vw #000; }
/* Nút trong màn nhắc xoay: chữ 2 dòng, chừa lề 2 đầu (phần hoa văn nhọn của ảnh btn-ai.png) → chữ & biểu tượng nằm gọn trong nút */
.rotate-fullscreen {
    display: none; flex: none; width: 84vw; height: 22vw; padding: 0 13vw; gap: 3vw;
    font-size: 3.8vw; line-height: 1.2; white-space: normal; text-align: left;
}
.rotate-fullscreen-icon { font-size: 6vw; line-height: 1; flex: none; }
.can-fullscreen .rotate-fullscreen { display: flex; }

/* ============================================================
 *  BỘ ĐIỀU KHIỂN CẢM ỨNG — ảnh assets/ui/pad/* (cắt từ art-source/game-scene/match/Game-PAD.png bằng docs/ui-templates/cut-gamepad.ps1)
 *  Bố cục theo Game-Pad-Reference.jpg (khung 1376×768): vị trí = toạ độ TÂM nút tính từ mép phải/trái & mép dưới (px ảnh tham khảo),
 *  đổi ra màn hình bằng --p = 1 px tham khảo (co theo khung game, tối thiểu 0.47px → nút nhỏ nhất ~44px).
 *    Trái : joystick (ui/touch-joystick.js → phím mũi tên) + nút hộ thể (D, khiên) sát cạnh joystick, ngang hàng nút tuyệt kỹ
 *    Phải : A kiếm to · W khinh công (mũi tên lên) · S chém · E thế võ · R lướt · Q tuyệt kỹ (vòng xoáy)
 *  Chỉ hiện khi điều khiển cảm ứng (html.input-touch — ui/device-mode.js) và đang trong trận (#skill-bar hết .hidden).
 * ============================================================ */
/* Lớp phủ là container riêng → --p theo cạnh hạn chế của khung (rộng/1376 hoặc cao/768) — khung bị ép thấp vẫn không lấn HUD */
.pad-layer { position: absolute; inset: 0; pointer-events: none; container-type: size; }
.pad-btn, .pad-joystick { --p: max(min(calc(100cqw / 1376), calc(100cqh / 768)), 0.47px); }
.touch-dpad { display: none; }
.input-touch #skill-bar:not(.hidden) ~ .touch-dpad { display: block; }
.pad-btn {
    position: absolute; pointer-events: auto; padding: 0; border: 0; cursor: pointer;
    width: calc(var(--d) * var(--p)); height: calc(var(--d) * var(--p));
    background: var(--img) center / contain no-repeat;
    filter: drop-shadow(0 calc(4 * var(--p)) calc(8 * var(--p)) rgba(0, 0, 0, 0.55));
    touch-action: none; -webkit-tap-highlight-color: transparent; user-select: none;
    transition: transform 0.08s ease, filter 0.08s ease;
}
.pad-right .pad-btn { right: calc((var(--x) - var(--d) / 2) * var(--p)); bottom: calc((var(--y) - var(--d) / 2) * var(--p)); }
.pad-left .pad-btn  { left: calc((var(--x) - var(--d) / 2) * var(--p)); bottom: calc((var(--y) - var(--d) / 2) * var(--p)); }
.pad-btn:active, .pad-btn.is-pressed { transform: scale(0.92); filter: brightness(1.3) drop-shadow(0 0 calc(10 * var(--p)) rgba(253, 230, 138, 0.6)); }
.pad-btn > span { display: none; }   /* nhãn tên chiêu (data-move-label) giữ cho hướng dẫn phím, không hiện trên nút ảnh */
/* Kích thước (--d) & tâm (--x từ mép, --y từ đáy) theo ảnh tham khảo; ảnh nút có viền trang trí → --d lớn hơn đĩa nút một chút */
.pad-attack   { --img: url('../assets/ui/pad/btn-attack.png');   --d: 190; --x: 144; --y: 141; }
.pad-guard    { --img: url('../assets/ui/pad/btn-guard.png');    --d: 122; --x: 392; --y: 75;  }   /* cạnh joystick (phía trong), ngang hàng nút tuyệt kỹ bên phải (cùng --y) */
.pad-slash    { --img: url('../assets/ui/pad/btn-slash.png');    --d: 100; --x: 211; --y: 298; }
.pad-stance   { --img: url('../assets/ui/pad/btn-stance.png');   --d: 100; --x: 298; --y: 205; }
.pad-dash     { --img: url('../assets/ui/pad/btn-dash.png');     --d: 100; --x: 304; --y: 85;  }
.pad-ultimate { --img: url('../assets/ui/pad/btn-ultimate.png'); --d: 118; --x: 433; --y: 75;  }
.pad-jump     { --img: url('../assets/ui/pad/btn-jump.png');     --d: 108; --x: 88;  --y: 313; }   /* bên phải, trên cùng cụm chiêu */
/* Tuyệt kỹ đủ chân nguyên → sáng nhịp (ui/hud.js gắn .is-ready) */
.pad-ultimate.is-ready { animation: pad-ultimate-ready 1.4s ease-in-out infinite; }
@keyframes pad-ultimate-ready { 50% { filter: brightness(1.35) drop-shadow(0 0 calc(18 * var(--p)) rgba(168, 85, 247, 0.9)); } }
.pad-ultimate:not(.is-ready) { filter: grayscale(0.55) brightness(0.75) drop-shadow(0 calc(4 * var(--p)) calc(8 * var(--p)) rgba(0, 0, 0, 0.55)); }

/* Joystick tối giản, trong suốt (không che nhân vật): vòng mảnh viền vàng nhạt + núm tròn mờ.
   Lúc nghỉ mờ 45%; chạm vào thì rõ hơn và có quầng sáng. Vạch nhỏ 4 hướng ở mép vòng. */
.pad-joystick {
    position: absolute; pointer-events: auto; touch-action: none;
    --d: 250; --x: 190; --y: 178;
    width: calc(var(--d) * var(--p)); height: calc(var(--d) * var(--p));
    left: calc((var(--x) - var(--d) / 2) * var(--p)); bottom: calc((var(--y) - var(--d) / 2) * var(--p));
    border-radius: 50%;
    border: calc(2.5 * var(--p)) solid rgba(253, 230, 138, 0.55);
    background:
        radial-gradient(circle, transparent 60%, rgba(253, 230, 138, 0.08) 61%, transparent 75%),
        rgba(8, 10, 16, 0.12);
    opacity: 0.45;
    transition: opacity 0.15s ease;
}
.pad-joystick::before {   /* 4 vạch hướng */
    content: ""; position: absolute; inset: calc(10 * var(--p)); border-radius: 50%; pointer-events: none;
    background:
        linear-gradient(rgba(253, 230, 138, 0.7), rgba(253, 230, 138, 0.7)) top center / calc(3 * var(--p)) calc(14 * var(--p)) no-repeat,
        linear-gradient(rgba(253, 230, 138, 0.7), rgba(253, 230, 138, 0.7)) bottom center / calc(3 * var(--p)) calc(14 * var(--p)) no-repeat,
        linear-gradient(rgba(253, 230, 138, 0.7), rgba(253, 230, 138, 0.7)) left center / calc(14 * var(--p)) calc(3 * var(--p)) no-repeat,
        linear-gradient(rgba(253, 230, 138, 0.7), rgba(253, 230, 138, 0.7)) right center / calc(14 * var(--p)) calc(3 * var(--p)) no-repeat;
}
.pad-knob {
    position: absolute; left: 50%; top: 50%; width: 38%; height: 38%; pointer-events: none; border-radius: 50%;
    transform: translate(calc(-50% + var(--kx, 0px)), calc(-50% + var(--ky, 0px)));
    background: radial-gradient(circle at 40% 35%, rgba(255, 251, 235, 0.55), rgba(253, 230, 138, 0.28) 55%, rgba(180, 83, 9, 0.18));
    border: calc(2 * var(--p)) solid rgba(253, 230, 138, 0.7);
    transition: transform 0.12s ease-out;
}
.pad-joystick.is-active { opacity: 0.85; box-shadow: 0 0 calc(18 * var(--p)) rgba(253, 230, 138, 0.35); }

.fullscreen-toggle svg { width: 58%; height: 58%; display: block; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.8)); }
.matchmaking-hint { font-family: 'Noto Serif', serif; font-weight: 600; font-size: 1cqw; color: #cbd5e1; text-shadow: 0 0.1cqw 0.2cqw #000; min-height: 1.4cqw; }

/* ============================================================
 *  HƯỚNG DẪN CHƠI (#howto, ui/menu.js) — bảng nổi trên màn chọn chế độ, tự mở lần đầu
 * ============================================================ */
.mode-guide-btn {
    position: absolute; left: 1.2cqw; bottom: 1.6cqh; z-index: 5; cursor: pointer;
    padding: 0.6cqh 1cqw; border-radius: 0.4cqw; border: 0.1cqw solid rgba(253, 230, 138, 0.5);
    background: rgba(2, 6, 23, 0.7); color: #fde68a;
    font-family: 'Noto Serif', serif; font-weight: 700; font-size: 1.05cqw;
    transition: filter 0.15s ease, box-shadow 0.15s ease;
}
.mode-guide-btn:hover { filter: brightness(1.2); box-shadow: 0 0 0.8cqw rgba(251, 191, 36, 0.5); }
.howto-scene {
    container-type: size; display: flex; align-items: center; justify-content: center;
    background: rgba(2, 4, 10, 0.72); backdrop-filter: blur(2px);
}
.howto-panel {
    width: 74cqw; max-height: 92cqh; overflow-y: auto; padding: 2.6cqh 2.2cqw 2.2cqh;
    display: flex; flex-direction: column; align-items: center; gap: 1.6cqh;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.97), rgba(7, 8, 13, 0.97));
    border: 0.12cqw solid rgba(253, 230, 138, 0.45); border-radius: 0.8cqw;
    box-shadow: 0 0 2.5cqw rgba(0, 0, 0, 0.8), inset 0 0 1.5cqw rgba(251, 191, 36, 0.08);
    color: #e2e8f0; font-family: 'Inter', 'Noto Serif', sans-serif; font-size: 1.05cqw; line-height: 1.45;
    animation: howto-in 0.22s ease-out;
}
@keyframes howto-in { from { opacity: 0; transform: translateY(1.5cqh) scale(0.98); } }
.howto-title {
    margin: 0; font-family: 'Cinzel', 'Noto Serif', serif; font-weight: 900; font-size: 2.3cqw; letter-spacing: 0.05em;
    color: transparent; background: linear-gradient(90deg, #f8fafc, #fcd34d 45%, #fbbf24 60%, #e9d5ff);
    -webkit-background-clip: text; background-clip: text;
}
.howto-goal { font-family: 'Noto Serif', serif; font-weight: 700; font-size: 1.25cqw; color: #fde68a; text-align: center; }
.howto-grid { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 1.2cqw; }
.howto-card {
    padding: 1.4cqh 1.2cqw; border-radius: 0.5cqw;
    background: rgba(30, 41, 59, 0.55); border: 0.08cqw solid rgba(148, 163, 184, 0.25);
}
.howto-card-wide { grid-column: 1 / -1; }
.howto-card h3 { margin: 0 0 0.9cqh; font-family: 'Noto Serif', serif; font-weight: 700; font-size: 1.3cqw; color: #7dd3fc; }
.howto-keys, .howto-tips { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 0.7cqh; }
.howto-keys li { display: flex; align-items: center; gap: 0.8cqw; }
.howto-keys li > span { flex: 0 0 9.5cqw; display: flex; gap: 0.25cqw; }
.howto-tips li { padding-left: 1cqw; position: relative; }
.howto-tips li::before { content: '✦'; position: absolute; left: 0; color: #fbbf24; font-size: 0.75cqw; top: 0.25cqw; }
.howto-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7cqh 1.6cqw; }
.howto-panel b { color: #fde68a; }
.howto-panel kbd {
    display: inline-block; min-width: 2cqw; padding: 0.15cqh 0.45cqw; text-align: center;
    font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.95cqw; color: #f8fafc;
    background: linear-gradient(#334155, #1e293b); border: 0.08cqw solid #64748b; border-bottom-width: 0.25cqw; border-radius: 0.3cqw;
}
.howto-note { margin: 1.1cqh 0 0; font-size: 0.95cqw; color: #cbd5e1; }
.howto-close { flex: 0 0 auto; width: 22cqw; height: 9cqh; }

/* ============================================================
 *  BIỆT DANH (ui/player-profile.js) — chip góc trái trên màn chọn chế độ; bấm tên để đổi
 * ============================================================ */
.profile-chip {
    position: absolute; left: 1.2cqw; top: 2.2cqh; z-index: 5; display: flex; flex-direction: column; gap: 0.3cqh;
    padding: 0.8cqh 0.9cqw; border-radius: 0.5cqw; border: 0.1cqw solid rgba(253, 230, 138, 0.4); background: rgba(2, 6, 23, 0.65);
}
.profile-label { font-family: 'Noto Serif', serif; font-weight: 600; font-size: 0.8cqw; color: #94a3b8; }
.profile-name, .profile-input {
    width: 15cqw; padding: 0.2cqh 0.4cqw; text-align: left; border-radius: 0.3cqw;
    font-family: 'Noto Serif', serif; font-weight: 700; font-size: 1.15cqw; color: #fde68a;
}
.profile-name {
    cursor: pointer; border: 0; background: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    text-shadow: 0 0.1cqw 0.2cqw #000, 0 0 0.6cqw rgba(251, 191, 36, 0.35);
}
.profile-name::after { content: ' ✏️'; font-size: 0.8cqw; opacity: 0.7; }
.profile-name:hover { filter: brightness(1.2); }
.profile-input { outline: none; background: rgba(2, 6, 23, 0.9); border: 0.1cqw solid #fde68a; box-shadow: 0 0 0.6cqw rgba(251, 191, 36, 0.45); }
