🎮 Atari 2600
🎮 Atari Jaguar
🎮 game boy
🎮 game boy color
🎮 Nintendo NES
🎮 Nintendo NES
🎮 Nintendo NES
🎮 Super Nintendo
🎮 TurboGrafx-16/PC
🎮 Wonderswan
🎮 Wonderswan Color
(sel, ctx=document) => Array.from(ctx.querySelectorAll(sel));
const chips = $$('#chips .chip');
const cards = $$('#list .game-item');
const empty = $('#empty');
const kwTop = $('#kw');
let state = { platform: 'all', keyword: '' };
function normalize(txt){ return (txt || '').toLowerCase().trim(); }
function applyFilters(){
const term = normalize(state.keyword);
let visible = 0;
cards.forEach(card=>{
const plat = card.dataset.platform;
const text = (card.innerText || '').toLowerCase();
const matchPlatform = state.platform === 'all' || plat.includes(state.platform);
const matchText = !term || text.includes(term);
const show = matchPlatform && matchText;
card.classList.toggle('hide', !show);
visible += show ? 1 : 0;
});
empty.classList.toggle('hide', visible !== 0);
}
chips.forEach(chip=>{
chip.addEventListener('click', ()=>{
chips.forEach(c=>c.classList.remove('active'));
chip.classList.add('active');
state.platform = chip.dataset.platform;
applyFilters();
});
});
$('#clear').addEventListener('click', ()=>{
state = { platform: 'all', keyword: '' };
kwTop.value = '';
chips.forEach(c=>c.classList.remove('active'));
$('#chips .chip.all').classList.add('active');
applyFilters();
});
kwTop.addEventListener('input', ()=>{ state.keyword = kwTop.value; applyFilters(); });
applyFilters();