/* Background: Midnight Blue Gradient */
body { 
    margin: 0; 
    overflow: hidden; 
    background: radial-gradient(circle at center, #0f2027 0%, #203a43 50%, #2c5364 100%); 
    background-color: #050d1a; 
    font-family: 'Times New Roman', serif; 
    user-select: none;
    -webkit-user-select: none;
    touch-action: none; 
}

#canvas-container { 
    width: 100vw; 
    height: 100vh; 
    position: absolute; 
    top: 0; 
    left: 0; 
    z-index: 1; 
    cursor: grab; 
}
#canvas-container:active { cursor: grabbing; }

/* UI Overlay */
#ui-layer {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 10; pointer-events: none;
    display: flex; flex-direction: column; 
    align-items: center;
    padding-top: 40px;
    box-sizing: border-box;
    transition: opacity 0.5s ease;
}

.ui-hidden { opacity: 0 !important; pointer-events: none !important; }

/* Typography */
h1 { 
    color: #fceea7; font-size: 8vw; 
    max-size: 56px; margin: 0; font-weight: 400; 
    letter-spacing: 6px; 
    text-shadow: 0 0 50px rgba(252, 238, 167, 0.6); 
    background: linear-gradient(to bottom, #fff, #eebb66);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    font-family: 'Cinzel', 'Times New Roman', serif;
    opacity: 0.9; transition: opacity 0.5s ease;
    text-align: center; pointer-events: none;
    white-space: nowrap;
}
@media (min-width: 768px) { h1 { font-size: 56px; } }

/* Controls Wrapper (Top Right) */
.controls-wrapper {
    position: absolute; 
    top: 30px; 
    right: 30px;        
    pointer-events: auto;
    display: flex; 
    flex-direction: column; 
    align-items: flex-end;
    gap: 10px; 
    z-index: 20;
    transition: opacity 0.5s ease;
}

.btn-group {
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
    align-items: flex-end;
}

.upload-btn {
    background: rgba(20, 20, 20, 0.6); 
    border: 1px solid rgba(212, 175, 55, 0.4); 
    color: #d4af37; 
    padding: 10px 20px; 
    cursor: pointer; 
    text-transform: uppercase; 
    letter-spacing: 2px; 
    font-size: 10px;
    transition: all 0.4s;
    display: flex; 
    align-items: center; 
    justify-content: center;
    backdrop-filter: blur(5px); 
    min-width: 120px; 
    white-space: nowrap;
}
.upload-btn:hover { 
    background: #d4af37; color: #000; 
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.5);
}

input[type="file"] { display: none; }

/* --- DONATE WIDGET (Desktop) --- */
#donate-desktop {
    position: absolute;
    bottom: 30px;
    right: 30px;
    z-index: 50;
    pointer-events: auto;
    animation: float 3s ease-in-out infinite;
    cursor: pointer; /* <--- THÊM DÒNG NÀY: Biến chuột thành bàn tay */
}

.qr-frame {
    background: rgba(255, 255, 255, 0.95);
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
    text-align: center;
    width: 120px;
    transition: transform 0.3s ease;
}

.qr-frame:hover {
    transform: scale(1.05);
}

.qr-frame img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

.qr-text {
    margin-top: 8px;
    font-family: 'Cinzel', serif;
    font-size: 12px;
    font-weight: bold;
    color: #333;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* --- DONATE MODAL (Mobile Popup) --- */
#donate-modal {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    position: relative;
    width: 250px;
    z-index: 101;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-content img {
    width: 100%;
    border-radius: 8px;
}

.modal-content p {
    color: #333;
    margin-top: 10px;
    font-family: sans-serif;
    font-size: 14px;
}

#close-modal-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #d4af37;
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.modal-backdrop {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 100;
}

@keyframes popIn {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* --- BOTTOM CONTROLS --- */
#bottom-controls {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    pointer-events: auto;
    z-index: 20;
}

.mode-btn-group {
    display: flex;
    gap: 25px;
}

.mode-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 1px solid #d4af37; 
    background: rgba(0, 0, 0, 0.6);
    color: #d4af37;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.3s ease;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.mode-btn:hover {
    background: #d4af37;
    color: #000;
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.6);
}

.mode-btn:active {
    transform: scale(0.95);
}

.hint-text-bottom {
    color: rgba(212, 175, 55, 0.7);
    font-size: 10px;
    letter-spacing: 1px;
    font-family: monospace;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    pointer-events: none;
    text-align: center;
    width: 100%;
}

/* Loading */
#loader {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: #050d1a; z-index: 100;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    transition: opacity 0.8s ease-out;
}
.spinner {
    width: 40px; height: 40px; border: 1px solid rgba(212, 175, 55, 0.2); 
    border-top: 1px solid #d4af37; border-radius: 50%; 
    animation: spin 1s linear infinite;
}
.loader-text {
    color: #d4af37; font-size: 14px; letter-spacing: 4px; margin-top: 20px;
    text-transform: uppercase; font-weight: 100;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- RESPONSIVE LOGIC --- */

/* Mặc định (Desktop): Ẩn nút Mobile */
.mobile-only {
    display: none !important;
}

/* Trên Mobile (< 768px) */
@media (max-width: 768px) {
    /* 1. Layout Header */
    #ui-layer {
        padding-top: 60px; 
    }
    h1 {
        font-size: 10vw; 
    }

    /* 2. Top Right Controls */
    .controls-wrapper {
        top: 15px;
        right: 15px;
    }
    .btn-group {
        flex-direction: row; 
        gap: 5px;
    }
    .upload-btn {
        min-width: auto; 
        padding: 6px 8px; 
        font-size: 8px; 
        letter-spacing: 1px;
    }

    /* 3. Donate Toggle */
    .desktop-only {
        display: none !important;
    }
    .mobile-only {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
}

/* Hiệu ứng khi nhạc đang bật (class active được thêm bởi JS) */
.mode-btn.active {
    background: rgba(212, 175, 55, 0.3); /* Màu vàng nhạt */
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.8);
    border-color: #fff;
    color: #fff;
    animation: pulseMusic 2s infinite;
}

@keyframes pulseMusic {
    0% { box-shadow: 0 0 10px rgba(212, 175, 55, 0.5); }
    50% { box-shadow: 0 0 20px rgba(212, 175, 55, 1); }
    100% { box-shadow: 0 0 10px rgba(212, 175, 55, 0.5); }
}
/* css/style.css - Thêm vào cuối file nếu chưa có */
.mode-btn.active {
    background: rgba(212, 175, 55, 0.8); /* Màu vàng đậm hơn */
    color: #000; /* Icon chuyển màu đen cho nổi */
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.8);
    border-color: #fff;
    animation: pulseMusic 2s infinite;
}