diff --git a/frontend/pet.html b/frontend/pet.html
index 36fda75..16024e7 100644
--- a/frontend/pet.html
+++ b/frontend/pet.html
@@ -1107,6 +1107,14 @@ async function renderBgPicker() {
c.addEventListener('click', () => selectBgInline(c.dataset.id, +c.dataset.price, c.dataset.owned === '1')));
}
async function selectBgInline(id, price, owned) {
+ // покупка платного фона — подтверждение + предпроверка баланса
+ if (!owned && id !== 'default') {
+ const coins = _petData ? (_petData.coins ?? 0) : 0;
+ if (coins < price) { LS.toast?.('Недостаточно монет: нужно ' + price, 'warn'); return; }
+ const ok = await LS.confirm('Купить фон «' + (BG_NAMES[id] || id) + '» за ' + price + ' монет?',
+ { title: 'Покупка фона', confirmText: 'Купить за ' + price, danger: false });
+ if (!ok) return;
+ }
const endpoint = owned ? '/api/pet/bg' : '/api/pet/shop/buy';
const res = await LS.api(endpoint, { method: owned ? 'PATCH' : 'POST', body: JSON.stringify({ id }) }).catch(e => {
if (e?.data?.error === 'insufficient_coins') LS.toast?.('Недостаточно монет', 'error');