@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;500;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    font-family: 'Kanit', sans-serif;
}

body {
    margin: 0;
    background: #050508;
    color: white;
    overflow: hidden;
    width: 100vw;
    /* 🌟 ล็อคหน้าจอให้พอดีกับพื้นที่ที่เห็นจริง (ป้องกันการตกลงไปด้านล่าง) */
    height: 100vh;
    /* เผื่อเบราว์เซอร์เก่า */
    height: 100dvh;
    /* สำหรับมือถือใหม่ๆ */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    touch-action: none;
}

#app {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}


/* =========================================
   Login Fullscreen Centered Layout
   ========================================= */

.login-fullscreen-layout {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #050508;
    overflow: hidden;
}

/* 🌟 1. ทำให้รูปภาพมีชีวิตชีวา (Breathing & Ken Burns Effect) */
.bg-media {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    animation: breatheAlive 12s ease-in-out infinite alternate;
    transform-origin: center 40%;
}

@keyframes breatheAlive {
    0% {
        transform: scale(1);
        filter: brightness(0.85);
    }

    100% {
        transform: scale(1.08);
        filter: brightness(1.05);
    }
}

/* 🌟 2. ปรับปรุงกล่องล็อกอิน */
.login-center-box {
    position: relative;
    z-index: 10;
    width: fit-content;
    min-width: 260px;
    max-width: 300px;
    background: rgba(30, 30, 40, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    border-radius: 16px;
    padding: 30px 25px 20px 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
    animation: fadeInSlideUp 0.8s ease-out forwards;
}

/* 🌟 3. เอฟเฟกต์แสงวิ่งรอบกล่อง (Running Border Light) */
.login-center-box::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 18px;
    background: linear-gradient(60deg, #00f3ff, transparent 30%, #ff2a2a, transparent 70%, #00f3ff);
    background-size: 300% 300%;
    z-index: -1;
    animation: runningLight 4s linear infinite;
}

@keyframes runningLight {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@keyframes fadeInSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 🌟 4. เอฟเฟกต์แสงฟ้าผ่า */
.lightning-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
    overflow: hidden;
}

.lightning-bolt {
    position: absolute;
    background-image: url('../assets/lightning.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center top;
    opacity: 0;
    filter: drop-shadow(0 0 15px #00f3ff) brightness(1.5);
}

.bolt-1 {
    top: -5%;
    left: 10%;
    width: 300px;
    height: 120%;
    transform: rotate(15deg);
    animation: realStrike 5s infinite;
}

.bolt-2 {
    top: -10%;
    right: 5%;
    width: 350px;
    height: 130%;
    transform: rotate(-10deg) scaleX(-1);
    animation: realStrike 7s infinite 3s;
}

@keyframes realStrike {

    0%,
    94%,
    100% {
        opacity: 0;
    }

    95% {
        opacity: 1;
    }

    96% {
        opacity: 0;
    }

    97% {
        opacity: 0.8;
    }

    98% {
        opacity: 0;
    }

    99% {
        opacity: 1;
    }
}

.google-wrapper {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-bottom: 20px;
}

.footer-note {
    color: #ccc;
    /* ปรับให้สว่างขึ้นเพื่อให้ตัดกับฉากหลังกล่อง */
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    margin: 0;
}

.btn-google {
    background: #fff;
    color: #000;
    width: 100%;
    padding: 15px;
    border-radius: 8px;
    border: none;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: 0.2s;
}

.btn-google:active {
    transform: scale(0.98);
}

/* --- Common Wrappers (Lobby, Profile, Shop, Customize) --- */
.lobby-wrapper,
.profile-wrapper,
.shop-wrapper,
.customize-wrapper {
    display: flex;
    width: 100%;
    height: 100%;
    /* 🌟 ปรับ Padding ด้านซ้ายและขวา เป็น 3% ตามที่ต้องการเป๊ะๆ */
    padding: 20px calc(env(safe-area-inset-right, 0px) + 3%) 20px calc(env(safe-area-inset-left, 0px) + 3%);
    gap: 20px;
    box-sizing: border-box;
}

.panel {
    background: rgba(26, 26, 36, 0.8);
    border: 1px solid #333;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

.panel-title {
    color: #00f3ff;
    font-size: 1.2rem;
    border-bottom: 2px solid #333;
    padding-bottom: 10px;
    margin-bottom: 15px;
    text-shadow: 0 0 5px rgba(0, 243, 255, 0.5);
    text-align: center;
}

/* 🌟 Back Button ปุ่มแดงพรีเมียม (สีแดงเข้มมีมิติ ดึงสไตล์จากปุ่มเริ่มต่อสู้) */
.btn-back-premium {
    width: 100%;
    padding: 12px;
    margin-top: auto;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    font-size: 1.2rem;

    /* 🌟 ไล่สีแดงเข้ม (สีเดียวกับปุ่มเริ่มต่อสู้) */
    background: linear-gradient(180deg, #e60000, #d00000);
    color: white;

    /* 🌟 ขอบสีแดงเข้มจัด (เกือบดำ) ให้ดูมีกรอบหนาและลึก */
    border: 2px solid #d00000;

    /* 🌟 เงาดำด้านนอก และแสงสะท้อนขอบบนด้านใน */
    box-shadow: 0 4px 10px rgba(230, 0, 0, 0.4), inset 0 2px 2px rgba(196, 0, 0, 0.1);

    transition: 0.2s;
    text-transform: uppercase;
}

/* 🌟 เอฟเฟกต์ตอนกด (Active) */
.btn-back-premium:active {
    transform: scale(0.95);
    background: #cc0000;
    box-shadow: 0 2px 5px rgba(230, 0, 0, 0.5), inset 0 3px 5px rgba(0, 0, 0, 0.3);
    border-color: #d00000;
}

/* =========================================
   LOBBY PAGE (AAA EFFECTS & UI)
   ========================================= */
.lobby-wrapper {
    display: flex;
    width: 100%;
    height: 100%;
    padding: 20px calc(env(safe-area-inset-right, 0px) + 3%) 20px calc(env(safe-area-inset-left, 0px) + 3%);
    gap: 20px;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

.lobby-bg-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -2;
    filter: brightness(0.7);
    /* เพิ่มให้มันมีการเคลื่อนไหวเล็กๆน้อยๆ */
    animation: breatheAliveLobbyPage 12s ease-in-out infinite alternate;
    transform-origin: center 40%;
}

@keyframes breatheAliveLobbyPage {
    0% {
        transform: scale(1);
        filter: brightness(0.85);
    }

    100% {
        transform: scale(1.08);
        filter: brightness(1.05);
    }
}

/* 🌟 แผงด้านซ้าย */
.lobby-wrapper .left-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    justify-content: center;
    z-index: 2;
}

.lobby-user-info-text {
    text-align: left;
    padding: 10px 0;
    background: transparent;
    border: none;
}

.lobby-stage-text {
    font-size: 1rem;
    color: #e7e7e7;
    font-weight: bold;
    text-shadow: 0 2px 4px black;
    margin-bottom: 5px;
}

.lobby-diamond-text {
    color: #00f3ff;
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 0 0 15px rgba(0, 243, 255, 0.8);
    margin: 0;
}

.menu-btn-glass {
    background: rgba(20, 25, 30, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 15px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    font-size: 1.1rem;
}

.menu-btn-glass:hover {
    background: rgba(0, 243, 255, 0.15);
    border-color: #00f3ff;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.3);
}

.menu-btn-glass:active {
    transform: scale(0.95);
}

/* 🌟 ตรงกลาง: ตัวละครและเอฟเฟกต์ */
.lobby-wrapper .center-panel {
    flex: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
}

/* 🌟 วงแหวนเวทย์ (ขยับขึ้นมาอีกนิด ไม่ให้ตกขอบจอ) */
.magic-circle-base {
    position: absolute;
    top: calc(50% + 110px);
    /* ⬅️ ปรับลดจาก 150px เป็น 110px เพื่อขยับขึ้น */
    left: 50%;
    transform: translate(-50%, -50%) rotateX(75deg);
    width: 450px;
    height: 450px;
    z-index: 1;
    pointer-events: none;
}

.magic-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    /* border: 3px solid transparent; */
    border: 6px solid transparent;
}

.ring-blue {
    border-top-color: rgba(0, 243, 255, 0.8);
    border-bottom-color: rgba(0, 243, 255, 0.8);
    animation: spinRing 5s linear infinite;
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.4), inset 0 0 20px rgba(0, 243, 255, 0.4);
}

.ring-red {
    border-left-color: rgba(255, 42, 42, 0.8);
    border-right-color: rgba(255, 42, 42, 0.8);
    animation: spinRing 7s linear infinite reverse;
    box-shadow: 0 0 20px rgba(255, 42, 42, 0.4), inset 0 0 20px rgba(255, 42, 42, 0.4);
    width: 80%;
    height: 80%;
    top: 10%;
    left: 10%;
}

@keyframes spinRing {
    to {
        transform: rotate(360deg);
    }
}

/* ตัวละครหายใจ + ซูมเข้าออก */
.hero-render {
    position: relative;
    width: 100%;
    height: 350px;
    display: flex;
    justify-content: center;
    align-items: center;
    /* z-index: 5; */
    z-index: 4;
    /* margin-bottom: 20px; */
    margin-bottom: 10px;
}

.hero-render img {
    height: 100%;
    object-fit: contain;
    animation: heroBreatheZoom 3.5s ease-in-out infinite alternate;
}

@keyframes heroBreatheZoom {
    0% {
        transform: translateY(0) scale(1);
        filter: drop-shadow(0 0 10px rgba(0, 243, 255, 0.3));
    }

    100% {
        transform: translateY(-10px) scale(1.03);
        filter: drop-shadow(0 0 25px rgba(0, 243, 255, 0.8));
    }
}

/* สายฟ้าผ่า */
.lobby-lightning-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.lobby-lightning {
    position: absolute;
    width: 250px;
    height: 120%;
    background-image: url('../assets/lightning.png');
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0;
    filter: drop-shadow(0 0 15px #00f3ff) brightness(1.8);
}

.bolt-1 {
    top: -10%;
    left: 20%;
    transform: rotate(15deg);
    animation: randomStrike 7s infinite 2s;
}

.bolt-2 {
    top: -5%;
    right: 25%;
    transform: rotate(-10deg) scaleX(-1);
    animation: randomStrike 11s infinite 5s;
}

@keyframes randomStrike {

    0%,
    95%,
    100% {
        opacity: 0;
    }

    96% {
        opacity: 1;
    }

    97% {
        opacity: 0;
    }

    98% {
        opacity: 0.8;
    }

    99% {
        opacity: 0;
    }
}

/* 🌟 กล่องข้อความทักทาย (ปรับให้เล็กลง และเลื่อนต่ำลงมาที่ระดับหน้าอก) */
.greeting-wrapper {
    position: absolute;
    top: 24%;
    /* ⬅️ ปรับจาก ขยับลงมาระดับหน้าอก */
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: inline-block;
}

.greeting-box {
    position: relative;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: inline-block;
    padding: 1px;
}

.greeting-box::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 6px;
    padding: 1px;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    z-index: -1;
    background: linear-gradient(60deg, #00f3ff, transparent 30%, #00f3ff, transparent 70%);
    background-size: 300% 300%;
    animation: runCharBorder 3s linear infinite;
}

.greeting-text {
    font-size: 0.85rem;
    /* ⬅️ ลดขนาดตัวอักษรลง */
    padding: 4px 10px;
    /* ⬅️ ลดขนาดกล่องให้พอดีคำ */
    color: rgba(255, 255, 255, 0.9);
    font-weight: normal;
    white-space: nowrap;
    overflow: hidden;
    border-right: 2px solid rgba(255, 255, 255, 0.7);
    width: 100%;
    animation: typing 1.5s steps(30, end) forwards, blinkCursor 0.75s step-end infinite;
}

@keyframes typing {
    from {
        width: 0;
    }

    to {
        width: 100%;
    }
}

@keyframes blinkCursor {
    50% {
        border-color: transparent;
    }
}

/* 🌟 แผงด้านขวา */
.lobby-wrapper .right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 2;
    justify-content: space-between;
}

.char-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    max-height: 250px;
    overflow-y: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
    padding-right: 5px;
}

.char-grid::-webkit-scrollbar {
    display: none;
}

/* 🌟 การ์ดตัวละคร */
.lobby-char-card {
    position: relative;
    width: 100%;
    height: 95px;
    border-radius: 12px;
    background: rgba(10, 15, 20, 0.55);
    backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: 0.2s;
    box-sizing: border-box;
}

.lobby-char-card:active {
    transform: scale(0.95);
}

.lobby-char-card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
    z-index: 2;
    position: relative;
    padding: 5px;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.2));
}

/* 🌟 เส้นขอบผสม "สีน้ำเงิน + แดง" วิ่งตอน "ไม่ได้เลือก" */
.lobby-char-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    padding: 2px;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    z-index: 1;
    pointer-events: none;
    background: linear-gradient(60deg, #00f3ff, transparent 40%, #e50000, transparent 60%);
    background-size: 300% 300%;
    animation: runCharBorder 6s linear infinite;
}

/* 🌟 เส้นขอบ "สีเขียว" วิ่งตอน "ถูกเลือก" */
.lobby-char-card.selected::after {
    background: linear-gradient(60deg, #39ff14, transparent 30%, #39ff14, transparent 70%);
    background-size: 300% 300%;
    animation: runCharBorder 2s linear infinite;
}

@keyframes runCharBorder {
    0% {
        background-position: 0% 50%;
    }

    100% {
        background-position: 100% 50%;
    }
}

.lobby-check-badge {
    position: absolute;
    bottom: 6px;
    left: 6px;
    background: #39ff14;
    color: #000;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 13px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 8px #39ff14;
    z-index: 3;
}

/* 🌟 ปุ่มเริ่มต่อสู้ (ปรับขนาดให้มาตรฐาน ไม่บังตัวละคร) */
.btn-battle-modern {
    width: 100%;
    font-size: 1.2rem;
    /* 🌟 ปรับลดฟอนต์ให้มาตรฐานเท่าปุ่มหน้าอื่น */
    padding: 12px;
    /* 🌟 ลดความสูงปุ่มให้กะทัดรัดขึ้น */
    border-radius: 8px;
    /* 🌟 ปรับความโค้งให้เข้ากับปุ่มอื่นๆ */
    font-weight: bold;
    cursor: pointer;
    margin-top: auto;
    margin-bottom: 0;
    /* 🌟 เอาขอบล่างที่ลอยสูงเกินไปออก (กรอบหลักมี Padding ดันขอบล่างไว้ให้อยู่แล้ว) */
    background: linear-gradient(180deg, #e60000, #990000);
    /* สีแดงพรีเมียมเหมือนเดิม */
    color: white;
    border: 2px solid #a80000;
    box-shadow: 0 4px 10px rgba(230, 0, 0, 0.4), inset 0 2px 2px rgba(255, 255, 255, 0.1);
    text-transform: uppercase;
    transition: 0.2s;
}

.btn-battle-modern:active {
    transform: scale(0.95);
    background: #cc0000;
    box-shadow: 0 2px 5px rgba(230, 0, 0, 0.5);
}

.btn-battle-modern:hover {
    box-shadow: 0 0 20px rgba(230, 0, 0, 0.6);
    border-color: #ff2a2a;
}

/* 🌟 ตั้งค่าขนาด Skeleton Loading ให้หน้า Lobby (ตอนรอข้อมูล) */
.hero-skeleton {
    width: 200px;
    height: 320px;
    border-radius: 16px;
    /* เพิ่มเงาเบาๆ ให้กล่องโหลดดูมีมิติ */
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.1);
}

.skel-card {
    width: 100%;
    height: 95px;
    /* ขนาดความสูงเป๊ะๆ เท่ากับการ์ดตัวละครของคุณ */
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* --- Profile --- */
.profile-wrapper {
    display: flex;
    width: 100%;
    height: 100%;
    padding: 20px calc(env(safe-area-inset-right, 0px) + 3%) 20px calc(env(safe-area-inset-left, 0px) + 3%);
    gap: 20px;
    box-sizing: border-box;
    position: relative;
}

.profile-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('../assets/profile-bg.jpg');
    background-size: cover;
    background-position: center;
    z-index: -2;
    /* เพิ่มความสว่างให้พื้นหลังนิดนึง */
    filter: brightness(0.7);
    /* เพิ่มให้มันมีการเคลื่อนไหวเล็กๆน้อยๆ */
    animation: breatheAliveProfile 12s ease-in-out infinite alternate;
    transform-origin: center 40%;
}

@keyframes breatheAliveProfile {
    0% {
        transform: scale(1);
        filter: brightness(0.85);
    }

    100% {
        transform: scale(1.08);
        filter: brightness(1.05);
    }
}

/* 🌟 ปรับให้โปร่งใสมากขึ้น (Opacity 0.15) เพื่อให้เห็นพื้นหลังชัดๆ */
.profile-wrapper .panel {
    position: relative;
    border-radius: 16px;
    background: rgba(10, 15, 20, 0.15);
    backdrop-filter: blur(5px);
    /* ลดเบลอลงให้เห็นภาพหลังชัดขึ้น */
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    z-index: 1;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.profile-wrapper .left-panel {
    flex: 1;
}

.profile-wrapper .right-panel {
    flex: 1.8;
}

/* 🌟 (ห้ามเปลี่ยน) เทคนิค CSS Masking เจาะกล่องเหลือแค่ขอบ */
.profile-wrapper .panel::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    padding: 2px;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    z-index: 10;
}

/* 🌟 (ห้ามเปลี่ยน) แสงขอบวิ่ง */
.profile-wrapper .left-panel::after {
    /* background: linear-gradient(60deg, #00f3ff, transparent 30%, #ff2a2a, transparent 70%, #00f3ff); */
    background: linear-gradient(60deg, #00f3ff, transparent 30%, #00f3ff, transparent 70%);
    background-size: 300% 300%;
    animation: runBorderLeft 3.5s linear infinite;
}

.profile-wrapper .right-panel::after {
    background: linear-gradient(-60deg, #ff2a2a, transparent 30%, #00f3ff, transparent 70%, #ff2a2a);
    background-size: 300% 300%;
    animation: runBorderRight 4.5s linear infinite;
}

@keyframes runBorderLeft {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@keyframes runBorderRight {
    0% {
        background-position: 100% 50%;
    }

    50% {
        background-position: 0% 50%;
    }

    100% {
        background-position: 100% 50%;
    }
}

.panel-inner {
    background: transparent;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    z-index: 2;
}

.left-content {
    padding: 20px;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 15px;
}

.right-scroll-area {
    padding: 20px;
    overflow-y: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.right-scroll-area::-webkit-scrollbar {
    display: none;
}

/* 🌟 เปลี่ยนสี Title สถิติอาคม เป็นสีขาว */
.profile-wrapper .panel-title {
    color: #ffffff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
}

/* 🌟 แก้รูปโปรไฟล์: ป้องกันการบีบ (flex-shrink:0), เปลี่ยนเป็นสี่เหลี่ยมโค้ง, เอาเส้นเขียวออก, ใส่แสงออร่า */
.avatar-circle {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 12px;
    border: none;
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.5);
    /* เรืองแสงสีฟ้าอ่อนๆ */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    overflow: hidden;
}

/* 🌟 บังคับรูปด้านในให้เป็นสี่เหลี่ยม (ทับคำสั่งวงกลมใน JS เดิม) */
.avatar-circle img {
    border-radius: 12px !important;
    object-fit: cover !important;
}

.player-name {
    font-size: 1.5rem;
    font-weight: bold;
    color: #fff;
}

/* 🌟 เปลี่ยนสี UID เป็นสีขาวและขยายให้เห็นชัดเจนขึ้น */
.player-id {
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 500;
}

.diamond-text {
    font-size: 1.5rem;
    color: #00f3ff;
    font-weight: bold;
    text-shadow: 0 0 15px rgba(0, 243, 255, 0.6);
    margin: 15px 0;
}

.stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 25px !important;
}

.stat-label {
    display: flex;
    align-items: center;
    width: 35% !important;
    font-weight: bold;
    color: #ccc;
    font-size: 0.95rem;
}

/* 🌟 ขยายรูปสกิลให้ใหญ่ขึ้นเป็น 60px */
.stat-label img {
    width: 60px !important;
    height: 60px !important;
    margin-right: 15px !important;
    border-radius: 8px;
    object-fit: contain;
    filter: drop-shadow(0 0 10px rgba(0, 243, 255, 0.7));
}

.stat-bar-bg {
    width: 55% !important;
    flex-shrink: 0;
    margin: 0 10px;
    height: 16px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    position: relative;
}

.stat-bar-fill {
    height: 100%;
    border-radius: 8px;
}

.stat-value {
    font-size: 0.8rem;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px black;
}

/* สีหลอดสกิล */
.fill-sword {
    width: 85%;
    background: #ff2a2a;
    box-shadow: 0 0 10px #ff2a2a;
}

.fill-punch {
    width: 60%;
    background: #ffbf00;
    box-shadow: 0 0 10px #ffbf00;
}

.fill-kick {
    width: 70%;
    background: #ff8800;
    box-shadow: 0 0 10px #ff8800;
}

.fill-steel {
    width: 45%;
    background: #ccc;
    box-shadow: 0 0 10px #ccc;
}

.fill-magic {
    width: 90%;
    background: #00f3ff;
    box-shadow: 0 0 10px #00f3ff;
}

.fill-buffalo {
    width: 80%;
    background: #ffd700;
    box-shadow: 0 0 10px #ffd700;
}

.fill-dodge {
    width: 95%;
    background: #fff;
    box-shadow: 0 0 10px #fff;
}

/* Skeleton */
.skeleton {
    background-color: rgba(30, 37, 60, 0.5) !important;
    background-image: linear-gradient(90deg, transparent 0px, rgba(255, 255, 255, 0.05) 40px, transparent 80px) !important;
    background-size: 200% 100% !important;
    animation: shimmer 1.5s infinite linear !important;
    color: transparent !important;
    border-color: transparent !important;
}

.skeleton * {
    visibility: hidden !important;
}

@keyframes shimmer {
    0% {
        background-position: 100% 0;
    }

    100% {
        background-position: -100% 0;
    }
}

.skel-text {
    min-width: 80px;
    min-height: 20px;
    border-radius: 4px;
    display: inline-block;
}

.skel-text-long {
    min-width: 150px;
}

.skel-avatar {
    min-width: 80px;
    min-height: 80px;
    border-radius: 50%;
    display: flex;
}

/* =========================================
   SHOP PAGE (ดีไซน์กระจกฝ้า + แสงวิ่งระดับ AAA)
   ========================================= */
.shop-wrapper {
    display: flex;
    width: 100%;
    height: 100%;
    padding: 20px calc(env(safe-area-inset-right, 0px) + 3%) 20px calc(env(safe-area-inset-left, 0px) + 3%);
    gap: 20px;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

.shop-bg-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -2;
    /* เพิ่มความสว่างให้พื้นหลังนิดนึง */
    filter: brightness(0.7);
    /* เพิ่มให้มันมีการเคลื่อนไหวเล็กๆน้อยๆ */
    animation: breatheAliveShop 12s ease-in-out infinite alternate;
    transform-origin: center 40%;
}

@keyframes breatheAliveShop {
    0% {
        transform: scale(1);
        filter: brightness(0.85);
    }

    100% {
        transform: scale(1.08);
        filter: brightness(1.05);
    }
}


/* 🌟 กล่องหลัก: ความโปร่งใสเป๊ะๆ แบบหน้า Profile */
.shop-panel {
    position: relative;
    border-radius: 16px;
    background: rgba(10, 15, 20, 0.15);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    z-index: 1;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    min-height: 0;
    height: 100%;
    border: none;
}

.shop-sidebar {
    flex: 1;
}

.shop-content-area {
    flex: 1.8;
}

/* 🌟 (ห้ามเปลี่ยน) เทคนิค CSS Masking เจาะขอบ 2px แบบหน้า Profile */
.shop-panel::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    padding: 2px;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    z-index: 10;
}

/* 🌟 แสงกล่องซ้าย: เน้นน้ำเงินล้วน */
.shop-sidebar::after {
    background: linear-gradient(60deg, #00f3ff, transparent 30%, #00f3ff, transparent 70%);
    background-size: 300% 300%;
    animation: runShopBorderLeft 3.5s linear infinite;
}

/* 🌟 แสงกล่องขวา: เน้นแดงสลับน้ำเงิน */
.shop-content-area::after {
    background: linear-gradient(-60deg, #ff2a2a, transparent 30%, #00f3ff, transparent 70%, #ff2a2a);
    background-size: 300% 300%;
    animation: runShopBorderRight 4.5s linear infinite;
}

@keyframes runShopBorderLeft {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@keyframes runShopBorderRight {
    0% {
        background-position: 100% 50%;
    }

    50% {
        background-position: 0% 50%;
    }

    100% {
        background-position: 100% 50%;
    }
}

/* 🌟 กล่องใน: โปร่งใส 100% */
.shop-panel-inner {
    background: transparent;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    z-index: 2;
    min-height: 0;
    padding: 20px;
}

.shop-sidebar .shop-panel-inner {
    align-items: center;
    justify-content: flex-start;
    text-align: center;
    gap: 15px;
}

.shop-scroll-area {
    overflow-y: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.shop-scroll-area::-webkit-scrollbar {
    display: none;
}

/* 🌟 ตกแต่งข้อมูลกล่องซ้าย (ชื่อสีขาว, เพชรไร้กรอบ) */
.shop-sidebar-title {
    color: #ffffff;
    font-size: 1.5rem;
    font-weight: bold;
    /* margin-bottom: 10px; */
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.shop-contact-text {
    color: #ccc;
    font-size: 0.95rem;
    /* margin-top: 10px; */
    margin-bottom: 10px;
}

.shop-diamond-display {
    font-size: 1.8rem;
    color: #00f3ff;
    font-weight: bold;
    text-shadow: 0 0 15px rgba(0, 243, 255, 0.6);
    margin: 15px 0;
    background: transparent;
    border: none;
    padding: 0;
}

/* 🌟 การ์ดไอเทมด้านขวา (ปรับให้โปร่งใส กลืนไปกับพื้นหลัง) */
.shop-item-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    width: 100%;
}

.shop-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: rgba(0, 0, 0, 0.15);
    /* 🌟 โปร่งใสขึ้นมากๆ */
    border-radius: 12px;
    padding: 25px 20px;
    width: 100%;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: 0.3s;
}

.shop-card:hover {
    border-color: rgba(0, 243, 255, 0.4);
    background: rgba(0, 243, 255, 0.05);
}

/* รูปไอเทมเรืองแสง */
.shop-img-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
}

.shop-item-img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    filter: drop-shadow(0 0 15px rgba(0, 243, 255, 0.7));
}

.shop-lv-text {
    color: #ccc;
    font-weight: bold;
    font-size: 1rem;
    margin-bottom: 10px;
}

.shop-progress-bg {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    height: 6px;
    margin-bottom: 20px;
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.shop-progress-fill {
    height: 100%;
    transition: width 0.3s;
}

/* 🌟 แถบพรีวิวเลเวล (ปรับโปร่งใส) */
.shop-preview-title {
    font-size: 0.9rem;
    color: #aaa;
    margin-bottom: 8px;
    text-align: left;
    width: 100%;
}

.shop-level-track {
    display: flex;
    overflow-x: auto;
    gap: 15px;
    padding: 15px 10px;
    background: rgba(255, 255, 255, 0.03);
    /* โปร่งใสสวยงาม */
    border-radius: 8px;
    width: 100%;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.shop-level-track::-webkit-scrollbar {
    display: none;
}

.shop-level-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 60px;
    cursor: pointer;
    transition: 0.2s;
}

.shop-level-node:active {
    transform: scale(0.95);
}

.shop-level-node img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 5px;
    border: 1px solid transparent;
}

.shop-level-node span {
    font-size: 0.85rem;
    margin-top: 5px;
    color: #888;
    font-weight: bold;
}

.shop-check-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #39ff14;
    color: #000;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    box-shadow: 0 0 8px #39ff14;
    z-index: 2;
}

/* 🌟 ป้ายวงกลมแม่กุญแจ (มุมซ้ายบน) สำหรับสกินที่ยังไม่ปลดล็อค */
.shop-lock-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    /* 🌟 เปลี่ยน left เป็น right ตรงนี้ครับ */
    /* วางที่มุมซ้ายบนตามที่คุณต้องการ */
    background: #2a2a35;
    /* พื้นหลังสีเทาเข้มให้ดูกลมกลืน */
    color: #fff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    /* ย่ออิโมจิให้พอดีกล่อง */
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
    z-index: 2;
    border: 1px solid #444;
    /* ขอบสีเทาหม่นๆ บ่งบอกถึงการล็อค */
}

/* 🌟 ปุ่มกดอัปเกรด/ซื้อ (ดีไซน์ใหม่! Ghost Button สวยหรู) */
.shop-btn-buy {
    width: 100%;
    max-width: 350px;
    padding: 12px;
    font-size: 1.2rem;
    border-radius: 8px;
    font-weight: bold;
    margin-top: 15px;
    cursor: pointer;
    transition: 0.2s;
}

.shop-btn-buy:active {
    transform: scale(0.95);
}

/* ปุ่มสีน้ำเงิน (ยาต่อชีวิต) - ขอบเรืองแสง พื้นใส */
.shop-btn-potion {
    background: rgba(0, 243, 255, 0.1);
    border: 1px solid #00f3ff;
    color: #00f3ff;
    box-shadow: inset 0 0 10px rgba(0, 243, 255, 0.1), 0 0 15px rgba(0, 243, 255, 0.2);
}

.shop-btn-potion:hover {
    background: rgba(0, 243, 255, 0.2);
    box-shadow: inset 0 0 15px rgba(0, 243, 255, 0.3), 0 0 20px rgba(0, 243, 255, 0.4);
}

/* ปุ่มสีทอง (อัปเกรดอาคม) - ขอบเรืองแสง พื้นใส */
.shop-btn-normal {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid #ffd700;
    color: #ffd700;
    box-shadow: inset 0 0 10px rgba(255, 215, 0, 0.1), 0 0 15px rgba(255, 215, 0, 0.2);
}

.shop-btn-normal:hover {
    background: rgba(255, 215, 0, 0.2);
    box-shadow: inset 0 0 15px rgba(255, 215, 0, 0.3), 0 0 20px rgba(255, 215, 0, 0.4);
}

/* ปุ่มเต็ม (อัปเกรดไม่ได้) */
.shop-btn-maxed {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #444;
    color: #666;
    cursor: not-allowed;
}

/* =========================================
   🌟 POPUP ALERTS ร้านค้าระดับมืออาชีพ
   ========================================= */
.shop-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.shop-popup-box {
    background: rgba(15, 20, 25, 0.95);
    border-radius: 16px;
    padding: 35px 25px;
    text-align: center;
    width: 85%;
    max-width: 380px;
    position: relative;
    animation: shopPopZoom 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes shopPopZoom {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.shop-popup-confirm {
    border: 2px solid #00f3ff;
    box-shadow: 0 0 30px rgba(0, 243, 255, 0.3);
}

.shop-popup-success {
    border: 2px solid #39ff14;
    box-shadow: 0 0 30px rgba(57, 255, 20, 0.3);
}

.shop-popup-error {
    border: 2px solid #ff2a2a;
    box-shadow: 0 0 30px rgba(255, 42, 42, 0.3);
}

.shop-popup-loading {
    border: 2px solid #ffd700;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
}

.shop-popup-title {
    font-size: 2.2rem;
    margin-top: 10px;
    margin-bottom: 15px;
    font-weight: bold;
}

.shop-popup-desc {
    font-size: 1.2rem;
    color: #fff;
    margin-bottom: 25px;
    line-height: 1.5;
}

.shop-error-text {
    color: #ff9999;
}

.shop-text-cyan {
    color: #00f3ff;
    text-shadow: 0 0 10px rgba(0, 243, 255, 0.6);
}

.shop-text-green {
    color: #39ff14;
    text-shadow: 0 0 10px rgba(57, 255, 20, 0.6);
}

.shop-text-red {
    color: #ff2a2a;
    text-shadow: 0 0 10px rgba(255, 42, 42, 0.6);
}

.shop-text-gold {
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
}

.shop-popup-icon {
    width: 70px;
    height: 70px;
    margin: 0 auto;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem;
    font-weight: bold;
    color: #000;
}

.shop-icon-green {
    background: #39ff14;
    box-shadow: 0 0 20px #39ff14;
}

.shop-icon-red {
    background: #ff2a2a;
    box-shadow: 0 0 20px #ff2a2a;
    color: white;
}

.shop-popup-actions {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.shop-popup-actions button,
.shop-btn-ok,
.shop-btn-close {
    flex: 1;
    padding: 12px;
    font-size: 1.2rem;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}

.shop-popup-actions button:active,
.shop-btn-ok:active,
.shop-btn-close:active {
    transform: scale(0.95);
}

.shop-btn-cancel {
    background: #333;
    color: white;
    border: 1px solid #555;
}

.shop-btn-confirm {
    background: #00f3ff;
    color: #000;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.4);
}

.shop-btn-ok {
    width: 100%;
    background: #39ff14;
    color: #000;
    box-shadow: 0 0 15px rgba(57, 255, 20, 0.4);
}

.shop-btn-close {
    width: 100%;
    background: #ff2a2a;
    color: white;
    box-shadow: 0 0 15px rgba(255, 42, 42, 0.4);
}

.shop-spinner {
    width: 60px;
    height: 60px;
    margin: 20px auto;
    border: 6px solid rgba(255, 215, 0, 0.2);
    border-top-color: #ffd700;
    border-radius: 50%;
    animation: shopSpin 1s linear infinite;
}

@keyframes shopSpin {
    to {
        transform: rotate(360deg);
    }
}



/* --- Customize --- */
.customize-wrapper .left-panel {
    flex: 0.8;
    justify-content: space-between;
}

.char-info-box {
    background: #111;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #444;
    text-align: center;
    margin-bottom: 15px;
}

.char-label {
    color: #888;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.char-name {
    color: #39ff14;
    font-size: 1.4rem;
    font-weight: bold;
    margin-top: 5px;
}

.customize-wrapper .center-panel {
    flex: 1.5;
    align-items: center;
    justify-content: center;
    position: relative;
    background: radial-gradient(circle at center, #1a1a24 0%, #050508 100%);
}

.pedestal {
    width: 250px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #00f3ff;
    position: absolute;
    bottom: 20%;
    box-shadow: 0 0 30px rgba(0, 243, 255, 0.5);
    transform: rotateX(70deg);
    z-index: 1;
}

.hero-preview {
    width: 200px;
    height: 300px;
    background: #111;
    border: 2px solid #555;
    border-radius: 15px;
    animation: float 3s infinite ease-in-out;
    position: relative;
    z-index: 2;
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
}

.customize-wrapper .right-panel {
    flex: 2.2;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    overflow-y: auto;
    padding-right: 5px;
}

.item-slot {
    background: #111;
    border: 2px solid #444;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: 0.2s;
    position: relative;
}

.item-slot.selected {
    border-color: #00f3ff;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.5);
    background: #1a1a24;
}

.item-slot.equipped {
    border-color: #39ff14;
}

.equipped-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #39ff14;
    color: black;
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 8px;
    font-weight: bold;
    display: none;
}

.item-slot.equipped .equipped-badge {
    display: block;
}

.item-details {
    margin-top: auto;
    background: #111;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.item-desc h3 {
    color: #00f3ff;
    font-size: 1.2rem;
}

.item-desc p {
    color: #ccc;
    font-size: 0.95rem;
}

.btn-equip {
    background: #00f3ff;
    border: none;
    color: black;
    padding: 15px 30px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    font-size: 1.1rem;
}

.btn-equip.active {
    background: #39ff14;
}

/* =========================================
   BATTLE PAGE (AAA Polished)
   ========================================= */
.battle-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background: #0a0a0c;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    overflow: hidden;
}

/* 🌟 Parallax Layers */
.parallax-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-repeat: repeat-x;
    background-position-y: bottom;
    will-change: background-position;
}

/* 🌟 Parallax 2 Layers (แบบตั้งต้น รอ JS มาเปลี่ยนรูปให้ตามด่าน) */
.layer-sky {
    /* รูปเริ่มต้น เผื่อ JS โหลดไม่ทัน */
    background-image: url('../assets/bg_sky_1.jpg');
    background-size: auto 100%;
    z-index: 1;
    filter: brightness(0.6);
}

.layer-ground {
    /* รูปเริ่มต้น พื้นดินพร้อมป่าไผ่ */
    background-image: url('../assets/bg_ground_1.png');
    background-size: auto 100%;
    /* เปลี่ยนให้เป็น 100% เพราะเรารวมต้นไม้ไว้กับพื้นแล้ว */
    z-index: 2;
    filter: brightness(0.85);
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 10;
}

/* 🌟 เลย์เอาต์ปุ่ม (กู้คืนของเดิม 100% + เพิ่มแค่โปร่งใสเบลอ) */
.top-left-zone {
    position: absolute;
    top: 20px;
    left: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
    z-index: 50;
}

.btn-magic-menu {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid #00f3ff;
    background: rgba(20, 25, 30, 0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.4);
    position: relative;
    overflow: hidden;
}

.sub-menu {
    display: none;
    gap: 10px;
    flex-direction: row;
}

.btn-sub {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 2px solid #00f3ff;
    /* border: 2px solid #fff; */
    background: rgba(20, 25, 30, 0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    position: relative;
    overflow: hidden;
    transition: transform 0.1s;
}

.btn-steel-punch {
    position: absolute;
    bottom: 40px;
    left: 220px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid #ccc;
    background: rgba(20, 25, 30, 0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
    pointer-events: auto;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s;
}

.action-zone {
    position: absolute;
    bottom: 30px;
    right: 30px;
    width: 240px;
    height: 240px;
    pointer-events: auto;
}

.btn {
    position: absolute;
    border-radius: 50%;
    color: white;
    font-weight: bold;
    border: 2px solid #00f3ff;
    background: rgba(20, 25, 30, 0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.4);
    transition: transform 0.1s;
}

.btn:active,
.btn-sub:active,
.btn-magic-menu:active,
.btn-steel-punch:active {
    transform: scale(0.9);
    box-shadow: 0 0 25px rgba(0, 243, 255, 0.8);
}

/* ตำแหน่งปุ่มแอคชั่น (กู้คืนของเดิมของคุณเป๊ะๆ) */
.btn-sword {
    bottom: 0;
    right: 0;
    width: 65px;
    height: 65px;
    font-size: 1.4rem;
    border-color: #ff2a2a;
    box-shadow: 0 0 15px rgba(255, 42, 42, 0.4);
}

.btn-punch {
    bottom: 85px;
    right: 85px;
    width: 45px;
    height: 45px;
    font-size: 0.9rem;
    border-color: #ffbf00;
    box-shadow: 0 0 15px rgba(255, 191, 0, 0.4);
}

.btn-kick {
    bottom: 10px;
    right: 100px;
    width: 45px;
    height: 45px;
    font-size: 0.9rem;
    border-color: #ff8800;
    box-shadow: 0 0 15px rgba(255, 136, 0, 0.4);
}

.btn-magic {
    bottom: 120px;
    right: 15px;
    width: 45px;
    height: 45px;
    font-size: 1rem;
    border-color: #00f3ff;
}

.btn-dodge {
    bottom: -10px;
    right: 175px;
    width: 40px;
    height: 40px;
    font-size: 1.8rem;
    border-color: #fff;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
}

.btn img,
.btn-sub img,
.btn-steel-punch img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
    pointer-events: none;
}

.locked-skill {
    filter: grayscale(100%) opacity(0.4);
    pointer-events: none;
    border-color: #555 !important;
    box-shadow: none !important;
}

/* 🌟 ตัวเลขจำนวนยา (ไม่มีกรอบ ไม่มีพื้นหลัง เป็นตัวเลขเพียวๆ) */
.potion-count-badge {
    position: absolute;
    bottom: 2px;
    /* ให้อยู่ชิดขอบล่าง */
    font-size: 0.5rem;
    font-weight: 900;
    color: #ffffff;
    background: transparent;
    /* ลบพื้นหลัง */
    border: none;
    /* ลบกรอบ */
    /* ใส่แสงเงาหนักๆ รอบตัวอักษร เพื่อให้อ่านออกไม่ว่าจะทับสีอะไร */
    text-shadow: 0px 2px 4px #000, 0px -1px 2px #000, 1px 1px 2px #000, -1px -1px 2px #000;
    pointer-events: none;
    z-index: 5;
}

/* 🌟 HUD และ Joystick */
.hud-bottom-center {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    pointer-events: none;
    min-width: 200px;
    z-index: 40;
}

.hp-bar {
    width: 50%;
    /* ทำให้หลอดสั้นลงครึ่งนึง */
    height: 8px;
    /* ทำให้หลอดบางลง */
    background: rgba(255, 0, 0, 0.8);
    border: 1px solid #fff;
    border-radius: 7px;

    /* 🌟 เคล็ดลับจัดกึ่งกลาง: บน 0, ซ้ายขวา auto, ล่าง 5px */
    margin: 0 auto 5px auto;

    overflow: hidden;
    box-shadow: 0 0 10px rgba(57, 255, 20, 0.6);
}

.hp-fill {
    height: 100%;
    background: #39ff14;
    box-shadow: 0 0 10px #39ff14;
    transition: width 0.1s;
}

.controls-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

.joystick-zone {
    position: absolute;
    bottom: 30px;
    left: 60px;
    width: 120px;
    height: 120px;
    background: rgba(0, 243, 255, 0.1);
    border: 2px solid rgba(0, 243, 255, 0.3);
    border-radius: 50%;
    pointer-events: auto;
}

.joystick-knob {
    position: absolute;
    top: 41px;
    left: 41px;
    width: 41px;
    height: 41px;
    background: rgba(0, 243, 255, 0.6);
    box-shadow: 0 0 15px #00f3ff;
    border-radius: 50%;
    pointer-events: none;
    transition: transform 0.05s;
}

/* =========================================
   🌟 POPUP สรุปผล (Win/Lose)
   ========================================= */
#gameResultOverlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.result-box {
    background: rgba(20, 25, 30, 0.95);
    padding: 30px 20px;
    border-radius: 12px;
    width: 80%;
    max-width: 350px;
    text-align: center;
    animation: popZoom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.result-win {
    border: 2px solid #39ff14;
    box-shadow: 0 0 20px rgba(57, 255, 20, 0.3);
}

.result-lose {
    border: 2px solid #ff2a2a;
    box-shadow: 0 0 20px rgba(255, 42, 42, 0.3);
}

.result-title {
    font-size: 2.8rem;
    margin-bottom: 10px;
    font-style: italic;
}

.title-win {
    color: #39ff14;
    text-shadow: 0 0 15px rgba(57, 255, 20, 0.6);
}

.title-lose {
    color: #ff2a2a;
    text-shadow: 0 0 15px rgba(255, 42, 42, 0.6);
}

.result-desc {
    margin: 10px 0 20px;
    color: #ccc;
    font-size: 1rem;
}

.result-btn-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    width: 100%;
}

.result-btn {
    flex: 1;
    padding: 12px 10px;
    border-radius: 8px;
    border: none;
    font-weight: bold;
    cursor: pointer;
    font-size: 1.1rem;
    transition: 0.2s;
    text-transform: uppercase;
}

.result-btn:active {
    transform: scale(0.95);
}

.btn-win-next {
    background: linear-gradient(180deg, #39ff14, #00b300);
    color: black;
    border: 2px solid #004d00;
}

.btn-lose-retry {
    background: linear-gradient(180deg, #ff4d4d, #cc0000);
    color: white;
    border: 2px solid #660000;
}

.btn-back-home {
    background: #333;
    color: white;
    border: 1px solid #555;
}

/* =========================================
   🌟 VS SCREEN OVERLAY
   ========================================= */
.vs-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #050508;
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    color: white;
    transition: opacity 0.5s ease-out;
    overflow: hidden;
}

.vs-slash-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 150%;
    height: 220px;
    background: linear-gradient(90deg, transparent, #cc0000, #ff2a2a, #cc0000, transparent);
    transform: translate(-50%, -50%) rotate(-15deg);
    z-index: -1;
    box-shadow: 0 0 40px #ff2a2a;
    opacity: 0.8;
}

.battle-avatar {
    width: 140px;
    height: 140px;
    border-radius: 16px;
    object-fit: cover;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.8);
    background: rgba(0, 0, 0, 0.5);
}

.avatar-player {
    border: 4px solid #39ff14;
    box-shadow: 0 0 25px rgba(57, 255, 20, 0.6);
}

.avatar-ai {
    border: 4px solid #2ac6ff;
    box-shadow: 0 0 25px rgba(42, 188, 255, 0.6);
}

.vs-box {
    text-align: center;
}

.vs-text {
    font-size: 5rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 20px rgba(0, 0, 0, 0.8), 0 0 40px rgba(255, 255, 255, 0.5);
    font-style: italic;
}

.vs-name {
    font-size: 1.8rem;
    margin-top: 15px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 2px 5px black;
}

.slide-in-left {
    animation: clashLeft 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.slide-in-right {
    animation: clashRight 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes clashLeft {
    0% {
        transform: translateX(-150%) skewX(10deg);
        opacity: 0;
    }

    100% {
        transform: translateX(0) skewX(0);
        opacity: 1;
    }
}

@keyframes clashRight {
    0% {
        transform: translateX(150%) skewX(-10deg);
        opacity: 0;
    }

    100% {
        transform: translateX(0) skewX(0);
        opacity: 1;
    }
}


/* =========================================
   Orientation Warning (บังคับเล่นแนวนอน)
   ========================================= */

#orientation-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(5, 5, 8, 0.95);
    /* พื้นหลังมืดโปร่งแสงนิดๆ */
    backdrop-filter: blur(10px);
    /* เบลอฉากหลังให้ดูมีมิติ */
    -webkit-backdrop-filter: blur(10px);
    z-index: 999999;
    /* อยู่บนสุดทับทุกสิ่ง */
    justify-content: center;
    align-items: center;
}

/* 🌟 ตั้งค่ารูปภาพไอคอน */
.rotate-img-icon {
    width: 160px;
    /* ปรับขนาดความกว้างของรูปได้ตามต้องการ */
    height: auto;
    /* ใส่แสงออร่าสีฟ้าด้านหลังรูปภาพให้ดูเท่ขึ้น (ถ้ารูปเป็น PNG พื้นใสจะสวยมาก) */
    filter: drop-shadow(0 0 20px rgba(0, 243, 255, 0.6));
    animation: gentleTilt 2s ease-in-out infinite;
    /* เรียกใช้แอนิเมชันโยกเบาๆ */
    transform-origin: center center;
}

/* 🌟 แอนิเมชันจำลองการขยับมือถือ (โยกซ้าย-ขวาเบาๆ) */
@keyframes gentleTilt {
    0% {
        transform: rotate(0deg) scale(1);
    }

    25% {
        transform: rotate(-10deg) scale(1.05);
    }

    /* โยกไปซ้ายนิดนึง พร้อมขยายร่างนิดๆ */
    75% {
        transform: rotate(10deg) scale(1.05);
    }

    /* โยกไปขวานิดนึง */
    100% {
        transform: rotate(0deg) scale(1);
    }
}

/* บังคับโชว์หน้าเตือนหมุนจอเมื่อโทรศัพท์อยู่ในแนวตั้ง (Portrait) 100% ทุกระบบ */
@media screen and (orientation: portrait) {
    #orientation-warning {
        display: flex !important;
    }
}