@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'VT323', sans-serif;
    background: linear-gradient(to bottom, #5bb4ff 0%, #85ccff 70%, #dff2ff 100%);
    color: #000;
    
    /* Không cho phép bôi đen trên trang */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Khôi phục quyền bôi đen chữ cho các ô nhập liệu */
input {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Mặt trời */
.sun {
    position: absolute;
    top: 75px;
    right: 100px;
    width: 60px;
    height: 60px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 20px 8px rgba(255, 255, 255, 0.6);
}

/* Hiệu ứng mây bay */
@keyframes float-cloud {
    0% { transform: translateX(-300px) scale(var(--scale, 1)); }
    100% { transform: translateX(100vw) scale(var(--scale, 1)); }
}

/* Hiệu ứng khinh khí cầu */
@keyframes float-airship {
    0% { transform: translateX(-100vw) translateY(0) scale(var(--scale, 1)); }
    25% { transform: translateX(-50vw) translateY(-15px) scale(var(--scale, 1)); }
    50% { transform: translateX(0vw) translateY(10px) scale(var(--scale, 1)); }
    75% { transform: translateX(50vw) translateY(-10px) scale(var(--scale, 1)); }
    100% { transform: translateX(100vw) translateY(0) scale(var(--scale, 1)); }
}

@keyframes float-airship-slow {
    0% { transform: translateX(-100vw) translateY(0) scale(var(--scale, 1)); }
    50% { transform: translateX(10vw) translateY(25px) scale(var(--scale, 1)); }
    100% { transform: translateX(100vw) translateY(0) scale(var(--scale, 1)); }
}

.cloud {
    position: absolute;
    animation: float-cloud linear infinite;
    opacity: 0.9;
    z-index: 2;
}

.cloud-1 { top: 10%; animation-duration: 40s; animation-delay: -5s; --scale: 1; }
.cloud-2 { top: 25%; animation-duration: 60s; animation-delay: -25s; --scale: 0.8; }
.cloud-3 { top: 15%; animation-duration: 50s; animation-delay: -40s; --scale: 1.2; }

.airship {
    position: absolute;
    animation: float-airship linear infinite;
    z-index: 3;
}

.khicau-img {
    display: block;
    position: relative;
    z-index: 2;
}

.khicau-gun {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
}

.airship-1 { top: 12%; animation-duration: 45s; animation-delay: -10s; --scale: 1; }
.airship-2 { top: 8%; animation-duration: 55s; animation-delay: -30s; animation-name: float-airship-slow; --scale: 0.7; }

/* Cây dừa trang trí (Bụi cây) */
.coconut-tree {
    position: absolute;
    bottom: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform-origin: bottom center;
}

.coconut-leaves {
    position: relative;
    z-index: 5;
    margin-bottom: -5px;
}

.coconut-trunk {
    position: relative;
    z-index: 4;
}

/* Bụi bên trái */
.tree-l1 { left: calc(50% - 240px); transform: scale(1.15) rotate(-3deg); z-index: 6; }
.tree-l2 { left: calc(50% - 300px); transform: scale(0.85) rotate(4deg); z-index: 5; }
.tree-l3 { left: calc(50% - 170px); transform: scale(0.95) rotate(-6deg); z-index: 4; }

/* Bụi bên phải */
.tree-r1 { left: calc(50% + 150px); transform: scale(1.1) scaleX(-1) rotate(5deg); z-index: 6; }
.tree-r2 { left: calc(50% + 220px); transform: scale(0.8) scaleX(-1) rotate(-3deg); z-index: 5; }
.tree-r3 { left: calc(50% + 260px); transform: scale(0.95) scaleX(-1) rotate(7deg); z-index: 4; }

/* Thanh menu dưới cùng */
.bottom-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40px;
    background: #b5cce6;
    border-top: 2px solid #849bb8;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    box-sizing: border-box;
    z-index: 20;
}

/* Form Container */
.form-container {
    position: absolute;
    bottom: 125px;
    left: 50%;
    transform: translateX(-50%);
    width: 280px;
    background: #d3dfed;
    border: 2px solid #556b7d;
    border-radius: 8px;
    z-index: 10;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    overflow: hidden;
}

/* Biến thể form ở giữa màn hình */
.form-centered {
    top: 50%;
    bottom: auto;
    transform: translate(-50%, -50%);
}

/* Viền kẻ sọc vàng đen trên cùng của form */
.form-header {
    height: 25px;
    background: repeating-linear-gradient(
        -45deg,
        #fdb913,
        #fdb913 15px,
        #3b434a 15px,
        #3b434a 30px
    );
    border-bottom: 2px solid #556b7d;
}

.form-body {
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.input-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.input-group label {
    text-shadow: 1px 1px 0 #fff;
    min-width: 95px;
    white-space: nowrap;
    font-weight: bold;
    color: #000;
}

.input-group input {
    flex: 1;
    padding: 6px 8px;
    border: 2px solid #556b7d;
    background: #25394a;
    outline: none;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
    width: 100%;
    transition: background-color 0.2s;
    box-sizing: border-box;
}

.input-group input:focus {
    background: #4677a3;
}

.input-group input::placeholder {
    color: #6a8ba6;
    opacity: 1;
}

.input-group input:focus::placeholder {
    color: #a4c4e0; 
}

.remember-group {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 5px;
}

.remember-group label {
    text-shadow: 1px 1px 0 #fff;
    font-weight: bold;
    cursor: pointer;
}

/* Checkbox "Nhớ" (Dùng sprite ảnh gốc) */
.custom-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background-image: url('/images/remember.png');
    background-size: 100% 200%;
    background-position: top;
    background-repeat: no-repeat;
    background-color: transparent;
    border: none;
    display: inline-block;
    cursor: pointer;
    box-sizing: border-box;
    margin-right: 5px;
    outline: none;
}

.custom-checkbox:checked {
    background-position: bottom;
}

/* Nút menu dưới cùng */
.btn {
    color: #1e3f6d;
    cursor: pointer;
    text-shadow: 1px 1px 0 #fff;
    text-transform: capitalize;
    transition: all 0.15s ease-in-out;
}

.btn:hover {
    color: #c93b16; /* Đổi sang màu đỏ cam */
    transform: scale(1.15); /* Phóng to nhẹ lên */
    text-shadow: 1px 1px 0 #fff, 0 0 5px rgba(201, 59, 22, 0.4); /* Thêm hiệu ứng phát sáng */
}

/* Hiển thị username góc phải trên */
.user-info {
    position: absolute;
    top: 10px;
    right: 15px;
    text-shadow: 1px 1px 0 #fff;
    z-index: 10;
}

/* Popup Menu */
.popup-menu {
    position: absolute;
    bottom: 48px; /* Tăng khoảng cách dưới vì có viền shadow */
    left: 8px;
    width: 150px;
    background: #c3d6e8;
    border: 5px solid #4a6482; /* Viền dày hơn màu xanh */
    z-index: 100;
    display: none;
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
    overflow: visible; /* Để hiển thị corner tràn ra ngoài */
}

/* 4 góc bằng hình ảnh corner.png */
.corner {
    position: absolute;
    width: 14px;
    height: 14px;
    background-image: url('/images/corner.png');
    background-size: contain;
    background-repeat: no-repeat;
    z-index: 101; /* Đè lên trên viền */
}

.corner-tl { top: -7px; left: -7px; }
.corner-tr { top: -7px; right: -7px; transform: scaleX(-1); }
.corner-bl { bottom: -7px; left: -7px; transform: scaleY(-1); }
.corner-br { bottom: -7px; right: -7px; transform: scaleX(-1) scaleY(-1); }
.popup-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.popup-menu li {
    color: #1e3f6d;
    cursor: pointer;
    border-bottom: 1px solid #a3b8cc;
}
.popup-menu li:last-child {
    border-bottom: none;
}
.popup-menu li a {
    display: block;
    padding: 8px 12px;
    color: #1e3f6d;
    text-decoration: none;
    text-shadow: 1px 1px 0px rgba(255, 255, 255, 0.7);
}

.popup-menu li:hover, .popup-menu li.active-item {
    background: #fdb913;
}
.popup-menu li:hover a, .popup-menu li.active-item a {
    color: #000;
    text-shadow: none;
}

/* Giao diện dạng Menu List (vd: trang Tải Về) */
.menu-list {
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
    width: 100%;
    background: #d3dfed;
}

.menu-list-item {
    display: block;
    width: calc(100% + 30px); /* Bù lại padding 15px của form-body */
    margin-left: -15px;
    margin-right: -15px;
    text-align: center;
    color: #fdb913; /* Màu vàng */
    text-shadow: 
        -1px -1px 0 #000,  
         1px -1px 0 #000,
        -1px  1px 0 #000,
         1px  1px 0 #000,
         0px  2px 0 #000;
    text-decoration: none;
    text-transform: uppercase;
    padding: 10px 0;
    position: relative;
    cursor: pointer;
    box-sizing: border-box;
}

/* Hover / Active State */
.menu-list-item:hover, .menu-list-item.active {
    background: #4779ff; /* Màu nền xanh dương cho item được chọn */
    border-top: 2px solid #a3b8cc; /* Viền sáng */
    border-bottom: 2px solid #25394a; /* Viền tối */
    margin-top: -2px; /* Bù lại viền để không đẩy content */
    margin-bottom: -2px;
    z-index: 2;
}

/* Mũi tên 2 bên cho active item */
.menu-list-item:hover::before, .menu-list-item.active::before {
    content: '>';
    position: absolute;
    left: 30px; /* Thụt vào trong một chút */
    color: #fff;
    text-shadow: 1px 1px 0 #000;
}

.menu-list-item:hover::after, .menu-list-item.active::after {
    content: '<';
    position: absolute;
    right: 30px;
    color: #fff;
    text-shadow: 1px 1px 0 #000;
}

/* Modal Thông Báo / Message */
.message-modal {
    position: absolute;
    bottom: 45px; /* Nằm ngay trên bottom-bar */
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 50px);
    max-width: 1000px;
    min-height: 60px;
    background: #c3d6e8;
    border: 5px solid #4a6482;
    z-index: 200;
    display: none;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    overflow: visible;
    /* Cần để .corner position:absolute hoạt động */
    position: absolute;
    
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px;
    color: #1e3f6d;
    text-shadow: 1px 1px 0px rgba(255, 255, 255, 0.7);
}
.message-modal.active {
    display: flex;
}

/* ===== BMFont Fake Input ===== */
.input-group {
    position: relative; /* cần để fake input định vị tuyệt đối */
}

/* Ẩn input thật, giữ nó nhận sự kiện bàn phím */
.input-group input[data-bm-input="true"] {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: text;
    z-index: 2;
}

/* Fake div hiển thị chữ bitmap */
.bmfont-fake-input {
    flex: 1;
    min-height: 26px;
    padding: 4px 8px;
    border: 2px solid #556b7d;
    background: #25394a;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    overflow: hidden;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
}

.bmfont-fake-input.is-focused {
    background: #4677a3;
}

/* Placeholder text */
.bmfont-placeholder {
    color: #6a8ba6;
}

.bmfont-fake-input.is-focused .bmfont-placeholder {
    color: #a4c4e0;
}

/* Con trỏ nhấp nháy */
.bm-caret {
    display: inline-block;
    width: 1px;
    height: 13px;
    background: #fff;
    vertical-align: top;
    margin-right: 1px;
    animation: bm-blink 1s step-start infinite;
}

@keyframes bm-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Text bên trong message modal */
.bmfont-message-text {
    display: block;
    text-align: center;
    line-height: 1.5;
    word-wrap: break-word;
    /* Loại bỏ padding mặc định nếu có để chữ cân đối */
    margin: 5px 0;
}

/* Đảm bảo corner trong message-modal không bị ảnh hưởng bởi flex */
.message-modal .corner {
    position: absolute;
    flex-shrink: 0;
}

/* Nâng cấp / Upgrade styles */
.upgrade-header {
    height: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
}
.upgrade-header-title {
    font-size: 18px;
    margin-top: 2px;
}
.upgrade-header-subtitle {
    font-size: 14px;
    margin-top: -2px;
}
.upgrade-btn-close {
    position: absolute;
    right: 10px;
    top: 8px;
    padding: 2px 8px;
    font-size: 12px;
}
.upgrade-char-avatar {
    text-align: center;
    margin-bottom: 10px;
}
.upgrade-char-avatar img {
    width: 50px;
    image-rendering: pixelated;
}
.stat-icon-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
}
.upgrade-reset-wrapper {
    text-align: center;
    margin-top: 10px;
}
.upgrade-popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 15;
}
.upgrade-popup-container {
    width: 220px;
    background-color: #c9dff0;
    position: absolute;
}
.upgrade-popup-title {
    text-align: center;
    margin-bottom: 15px;
    font-size: 16px;
}
.upgrade-popup-title-label {
    margin-right: 4px;
}
.upgrade-popup-input-wrapper {
    padding: 0 30px;
}
.upgrade-popup-buttons {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
}
