/* =================================================================
   1. CÀI ĐẶT CHUNG & BIẾN (VARIABLES)
   ================================================================= */
:root {
    /* Bảng màu Neon Tương Lai */
    --primary-color: #00E5FF;       /* Xanh Cyan (Chủ đạo) */
    --secondary-color: #2979FF;     /* Xanh Dương (User) */
    --accent-color: #FFD700;        /* Vàng (Đô Rê Bi) */
    --success-color: #00E676;       /* Xanh Lá (Thành công/Dùng đồ) */
    --danger-color: #FF1744;        /* Đỏ (Lỗi/Đóng) */
    --text-light: #FFFFFF;
    --text-dark: #212121;
    
    /* Cấu hình hiệu ứng Kính (Glassmorphism) */
    --glass-bg: rgba(15, 23, 42, 0.85); /* Nền tối mờ */
    --glass-border: 1px solid rgba(255, 255, 255, 0.15);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    --radius: 16px;
    --anim-speed: 0.3s;
}

/* Reset để game full màn hình không bị vỡ bởi theme WordPress */
body.page-template-default, body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* =================================================================
   2. KHUNG BAO & MÀN HÌNH 3D
   ================================================================= */
#kdr-game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99999; /* Đè lên tất cả header/footer của Web */
    background: linear-gradient(180deg, #87CEEB 0%, #B2EBF2 100%); /* Màu nền dự phòng */
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-light);
    line-height: 1.5;
}

#3d-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0; /* Nằm dưới cùng */
    display: block;
}

/* =================================================================
   3. GIAO DIỆN CHÍNH (UI OVERLAY)
   ================================================================= */
#kdr-ui-overlay {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 92%;
    max-width: 480px; /* Kích thước chuẩn Mobile/Tablet */
    
    /* Hiệu ứng Kính */
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: var(--glass-border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--glass-shadow);
    
    z-index: 10;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Class để ẩn UI (khi bấm nút Ẩn/Hiện) */
#kdr-ui-overlay.hidden-ui {
    transform: translateX(-50%) translateY(120%);
    opacity: 0;
}

/* Header nhỏ */
.kdr-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
    margin-bottom: 12px;
}

.kdr-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

/* =================================================================
   4. NÚT BẤM NEON (NEON BUTTONS)
   ================================================================= */
.neon-btn {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    border: none;
    border-radius: 8px;
    color: white;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(0, 229, 255, 0.3);
    outline: none;
}

.neon-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 229, 255, 0.5);
}

.neon-btn:active {
    transform: translateY(0);
}

.neon-btn.small {
    padding: 4px 8px;
    font-size: 11px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: none;
}

.neon-btn.disabled {
    background: #555;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.6;
}

/* =================================================================
   5. KHUNG CHAT (CHAT BOX)
   ================================================================= */
#chat-history {
    height: 220px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    
    /* Scrollbar đẹp */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

#chat-history::-webkit-scrollbar { width: 5px; }
#chat-history::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

.chat-message {
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.4;
    max-width: 85%;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Tin nhắn Khang (User) */
.chat-message.user {
    background: rgba(41, 121, 255, 0.85);
    align-self: flex-end;
    color: white;
    border-bottom-right-radius: 2px;
}

/* Tin nhắn Đô Rê Bi (AI) */
.chat-message.dorebi {
    background: rgba(255, 193, 7, 0.9);
    align-self: flex-start;
    color: var(--text-dark);
    border-bottom-left-radius: 2px;
    font-weight: 500;
}

/* Tin nhắn Hệ thống */
.chat-message.system {
    align-self: center;
    background: transparent;
    border: 1px dashed rgba(255,255,255,0.2);
    color: #ccc;
    font-size: 12px;
    text-align: center;
    width: 90%;
}

/* Input Khu vực nhập liệu */
.chat-input-area {
    display: flex;
    gap: 8px;
}

#user-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 10px 15px;
    color: white;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#user-input:focus {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.15);
}

#loading-indicator {
    animation: blink 1.5s infinite;
}
@keyframes blink { 50% { opacity: 0.5; } }

/* =================================================================
   6. NÚT CHỌN CHẾ ĐỘ (QUICK ACTIONS)
   ================================================================= */
.action-btn {
    transition: transform 0.2s, filter 0.2s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.action-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}
.action-btn:active {
    transform: scale(0.98);
}

/* =================================================================
   7. CỬA HÀNG (SHOP MODAL)
   ================================================================= */
#shop-modal {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 92%;
    max-width: 480px;
    max-height: 65vh; /* Không quá cao */
    
    background: rgba(20, 25, 40, 0.98);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius);
    padding: 15px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    z-index: 100;
    
    display: flex;
    flex-direction: column;
}

#shop-modal h3 {
    text-align: center;
    color: var(--accent-color);
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 1px dashed rgba(255,255,255,0.2);
    font-size: 16px;
    text-transform: uppercase;
}

/* Lưới sản phẩm */
#shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    overflow-y: auto;
    padding-right: 5px;
}

/* Thẻ sản phẩm */
.shop-item-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.shop-item-name {
    font-size: 11px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 5px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shop-item-price {
    font-size: 11px;
    margin-bottom: 8px;
}

.shop-item-card .buy-btn {
    width: 100%;
    padding: 5px 0;
    font-size: 11px;
}

/* =================================================================
   8. RESPONSIVE (MOBILE)
   ================================================================= */
@media screen and (max-width: 600px) {
    #kdr-ui-overlay {
        width: 95%;
        bottom: 10px;
        padding: 12px;
    }

    #chat-history {
        height: 180px; /* Giảm chiều cao trên mobile để không che hết màn hình */
    }

    .kdr-header h2 {
        font-size: 14px;
    }

    #shop-grid {
        grid-template-columns: repeat(3, 1fr); /* 3 cột trên mobile */
    }
    
    .shop-item-name {
        font-size: 10px;
    }
}